implement "follow" service limits

This commit is contained in:
friendica 2012-06-24 22:23:17 -07:00
parent c464bc494c
commit ad6c82bdea
3 changed files with 51 additions and 2 deletions

View file

@ -62,6 +62,11 @@ function new_contact($uid,$url,$interactive = false) {
} }
} }
// This extra param just confuses things, remove it // This extra param just confuses things, remove it
if($ret['network'] === NETWORK_DIASPORA) if($ret['network'] === NETWORK_DIASPORA)
$ret['url'] = str_replace('?absolute=true','',$ret['url']); $ret['url'] = str_replace('?absolute=true','',$ret['url']);
@ -89,6 +94,11 @@ function new_contact($uid,$url,$interactive = false) {
$ret['notify'] = ''; $ret['notify'] = '';
} }
if(! $ret['notify']) { if(! $ret['notify']) {
$result['message'] .= t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL; $result['message'] .= t('Limited profile. This person will be unable to receive direct/personal notifications from you.') . EOL;
} }
@ -129,6 +139,32 @@ function new_contact($uid,$url,$interactive = false) {
} }
else { else {
// check service class limits
$r = q("select count(*) as total from contact where uid = %d and pending = 0 and self = 0",
intval($uid)
);
if(count($r))
$total_contacts = $r[0]['total'];
if(! service_class_allows($uid,'total_contacts',$total_contacts)) {
$result['message'] .= upgrade_message();
return $result;
}
$r = q("select count(network) as total from contact where uid = %d and network = '%s' and pending = 0 and self = 0",
intval($uid),
dbesc($network)
);
if(count($r))
$total_network = $r[0]['total'];
if(! service_class_allows($uid,'total_contacts_' . $network,$total_network)) {
$result['message'] .= upgrade_message();
return $result;
}
$new_relation = (($ret['network'] === NETWORK_MAIL) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING); $new_relation = (($ret['network'] === NETWORK_MAIL) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
if($ret['network'] === NETWORK_DIASPORA) if($ret['network'] === NETWORK_DIASPORA)
$new_relation = CONTACT_IS_FOLLOWER; $new_relation = CONTACT_IS_FOLLOWER;

View file

@ -353,4 +353,17 @@ function service_class_allows($uid,$property,$usage = false) {
return true; return true;
return (((intval($usage)) < intval($arr[$property])) ? true : false); return (((intval($usage)) < intval($arr[$property])) ? true : false);
} }
} }
function upgrade_link() {
$l = get_config('service_class','upgrade_link');
$t = sprintf('<a href="%s">' . t('Click here to upgrade.') . '</div>', $l);
if($l)
return $t;
return '';
}
function upgrade_message() {
$x = upgrade_link();
return t('This action exceeds the limits set by your subscription plan.') . (($x) ? ' ' . $x : '') ;
}

View file

@ -1,5 +1,5 @@
Hey, Hey,
I'm $sitename. I'm $sitename;
The friendica developers released update $update recently, The friendica developers released update $update recently,
but when I tried to install it, something went terribly wrong. but when I tried to install it, something went terribly wrong.
This needs to be fixed soon and I can't do it alone. Please contact a This needs to be fixed soon and I can't do it alone. Please contact a