Fix for issue #763 Error creating new channel within the limits of the

subscription plan
This commit is contained in:
Christian Vogeley 2015-01-11 16:12:36 +01:00
parent 4a0150026b
commit 43f143a211
3 changed files with 28 additions and 2 deletions

View File

@ -590,6 +590,32 @@ function service_class_allows($uid,$property,$usage = false) {
}
}
// like service_class_allows but queries by account rather than channel
function account_service_class_allows($aid,$property,$usage = false) {
$a = get_app();
$r = q("select account_service_class as service_class from account where account_id = %d limit 1",
intval($aid)
);
if($r !== false and count($r)) {
$service_class = $r[0]['service_class'];
}
if(! x($service_class))
return true; // everything is allowed
$arr = get_config('service_class',$service_class);
if(! is_array($arr) || (! count($arr)))
return true;
if($usage === false)
return ((x($arr[$property])) ? (bool) $arr[$property] : true);
else {
if(! array_key_exists($property,$arr))
return true;
return (((intval($usage)) < intval($arr[$property])) ? true : false);
}
}
function service_class_fetch($uid,$property) {
$a = get_app();

View File

@ -34,7 +34,7 @@ function identity_check_service_class($account_id) {
$ret['total_identities'] = intval($r[0]['total']);
if(! service_class_allows($account_id,'total_identities',$r[0]['total'])) {
if(! account_service_class_allows($account_id,'total_identities',$r[0]['total'])) {
$result['message'] .= upgrade_message();
return $result;
}

View File

@ -131,7 +131,7 @@ function manage_content(&$a) {
intval(get_account_id()),
intval(PAGE_REMOVED)
);
$limit = service_class_fetch(local_user(),'total_identities');
$limit = account_service_class_fetch(get_account_id(),'total_identities');
if($limit !== false) {
$channel_usage_message = sprintf( t("You have created %1$.0f of %2$.0f allowed channels."), $r[0]['total'], $limit);
}