Removed "service class" functionality

This commit is contained in:
Michael 2017-10-18 21:44:27 +00:00
parent 1b53b8cae9
commit 0695fa699c
12 changed files with 6 additions and 224 deletions

View file

@ -947,19 +947,6 @@ function store_photo(App $a, $uid, $imagedata = "", $url = "") {
return(array());
}
/*
$r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
intval($uid)
);
$limit = service_class_fetch($uid,'photo_upload_limit');
if (($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) {
logger("Image exceeds personal limit of uid ".$uid, LOGGER_DEBUG);
return(array());
}
*/
$tempfile = tempnam(get_temppath(), "cache");
$stamp1 = microtime(true);

View file

@ -1708,7 +1708,6 @@ function db_definition() {
"account_expired" => array("type" => "tinyint(1)", "not null" => "1", "default" => "0"),
"account_expires_on" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"expire_notification_sent" => array("type" => "datetime", "not null" => "1", "default" => NULL_DATE),
"service_class" => array("type" => "varchar(32)", "not null" => "1", "default" => ""),
"def_gid" => array("type" => "int(11)", "not null" => "1", "default" => "0"),
"allow_cid" => array("type" => "mediumtext"),
"allow_gid" => array("type" => "mediumtext"),

View file

@ -197,32 +197,6 @@ function new_contact($uid, $url, $interactive = false, $network = '') {
$fields = array('rel' => $new_relation, 'subhub' => $subhub, 'readonly' => false);
dba::update('contact', $fields, array('id' => $r[0]['id']));
} 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 (dbm::is_result($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 (dbm::is_result($r)) {
$total_network = $r[0]['total'];
}
if (! service_class_allows($uid,'total_contacts_' . $network,$total_network)) {
$result['message'] .= upgrade_message();
return $result;
}
$new_relation = ((in_array($ret['network'], array(NETWORK_MAIL))) ? CONTACT_IS_FRIEND : CONTACT_IS_SHARING);
// create contact record

View file

@ -443,96 +443,6 @@ function install_theme($theme) {
}}
// check service_class restrictions. If there are no service_classes defined, everything is allowed.
// if $usage is supplied, we check against a maximum count and return true if the current usage is
// less than the subscriber plan allows. Otherwise we return boolean true or false if the property
// is allowed (or not) in this subscriber plan. An unset property for this service plan means
// the property is allowed, so it is only necessary to provide negative properties for each plan,
// or what the subscriber is not allowed to do.
function service_class_allows($uid,$property,$usage = false) {
if ($uid == local_user()) {
$service_class = $a->user['service_class'];
} else {
$r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($uid)
);
if (dbm::is_result($r)) {
$service_class = $r[0]['service_class'];
}
}
if (! x($service_class)) {
// everything is allowed
return true;
}
$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) {
if ($uid == local_user()) {
$service_class = $a->user['service_class'];
} else {
$r = q("SELECT `service_class` FROM `user` WHERE `uid` = %d LIMIT 1",
intval($uid)
);
if (dbm::is_result($r)) {
$service_class = $r[0]['service_class'];
}
}
if (! x($service_class))
return false; // everything is allowed
$arr = get_config('service_class',$service_class);
if (! is_array($arr) || (! count($arr)))
return false;
return((array_key_exists($property,$arr)) ? $arr[$property] : false);
}
function upgrade_link($bbcode = false) {
$l = get_config('service_class','upgrade_link');
if (! $l) {
return '';
}
if ($bbcode) {
$t = sprintf('[url=%s]' . t('Click here to upgrade.') . '[/url]', $l);
} else {
$t = sprintf('<a href="%s">' . t('Click here to upgrade.') . '</div>', $l);
}
return $t;
}
function upgrade_message($bbcode = false) {
$x = upgrade_link($bbcode);
return t('This action exceeds the limits set by your subscription plan.') . (($x) ? ' ' . $x : '') ;
}
function upgrade_bool_message($bbcode = false) {
$x = upgrade_link($bbcode);
return t('This action is not available under your subscription plan.') . (($x) ? ' ' . $x : '') ;
}
/**
* @brief Get the full path to relevant theme files by filename
*

View file

@ -169,11 +169,6 @@ function create_user($arr) {
return $result;
}
$default_service_class = get_config('system','default_service_class');
if(! $default_service_class)
$default_service_class = '';
$prvkey = $keys['prvkey'];
$pubkey = $keys['pubkey'];
@ -182,9 +177,9 @@ function create_user($arr) {
$sprvkey = $sres['prvkey'];
$spubkey = $sres['pubkey'];
$r = q("INSERT INTO `user` ( `guid`, `username`, `password`, `email`, `openid`, `nickname`,
`pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone`, `service_class`, `default-location` )
VALUES ( '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC', '%s', '' )",
$r = q("INSERT INTO `user` (`guid`, `username`, `password`, `email`, `openid`, `nickname`,
`pubkey`, `prvkey`, `spubkey`, `sprvkey`, `register_date`, `verified`, `blocked`, `timezone`, `default-location`)
VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, 'UTC', '')",
dbesc(generate_user_guid()),
dbesc($username),
dbesc($new_password_encoded),
@ -197,8 +192,7 @@ function create_user($arr) {
dbesc($sprvkey),
dbesc(datetime_convert()),
intval($verified),
intval($blocked),
dbesc($default_service_class)
intval($blocked)
);
if ($r) {