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

@ -1,5 +1,5 @@
-- ------------------------------------------
-- Friendica 3.5.3-dev (Asparagus)
-- Friendica 3.6-dev (Asparagus)
-- DB_UPDATE_VERSION 1234
-- ------------------------------------------
@ -1084,7 +1084,6 @@ CREATE TABLE IF NOT EXISTS `user` (
`account_expired` tinyint(1) NOT NULL DEFAULT 0,
`account_expires_on` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`expire_notification_sent` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',
`service_class` varchar(32) NOT NULL DEFAULT '',
`def_gid` int(11) NOT NULL DEFAULT 0,
`allow_cid` mediumtext,
`allow_gid` mediumtext,

View file

@ -38,7 +38,6 @@ Table user
| account_expired | | tinyint(1) | NO | | 0 | |
| account_expires_on | timestamp when account expires and will be deleted | datetime | NO | | 0001-01-01 00:00:00 | |
| expire_notification_sent | timestamp of last warning of account expiration | datetime | NO | | 0001-01-01 00:00:00 | |
| service_class | service class for this account, determines what if any limits/restrictions are in place | varchar(32) | NO | | | |
| def_gid | | int(11) | NO | | 0 | |
| allow_cid | default permission for this user | mediumtext | NO | | NULL | |
| allow_gid | default permission for this user | mediumtext | NO | | NULL | |

View file

@ -37,7 +37,6 @@ Example: To set the directory value please add this line to your .htconfig.php:
* **db_log_index_blacklist** - Blacklist of indexes that shouldn't be watched
* **dbclean** (Boolean) - Enable the automatic database cleanup process
* **dbclean-expire-days** (Integer) - Days after which remote items will be deleted. Own items, and marked or filed items are kept.
* **default_service_class** -
* **diaspora_test** (Boolean) - For development only. Disables the message transfer.
* **directory** - The path to global directory. If not set then "http://dir.friendica.social" is used.
* **disable_email_validation** (Boolean) - Disables the check if a mail address is in a valid format and can be resolved via DNS.
@ -96,10 +95,6 @@ Example: To set the directory value please add this line to your .htconfig.php:
* **worker_cooldown** - Cooldown time after each worker function call. Default value is 0 seconds.
* **xrd_timeout** - Timeout for fetching the XRD links. Default value is 20 seconds.
## service_class ##
* **upgrade_link** -
## experimental ##
* **exp_themes** (Boolean) - Show experimental themes as well.

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) {

View file

@ -832,24 +832,6 @@ function photos_post(App $a) {
$imagedata = @file_get_contents($src);
$limit = service_class_fetch($a->data['user']['uid'], 'photo_upload_limit');
if ($limit) {
$r = q("SELECT SUM(OCTET_LENGTH(`data`)) AS `total` FROM `photo` WHERE `uid` = %d AND `scale` = 0 AND `album` != 'Contact Photos'",
intval($a->data['user']['uid'])
);
$size = $r[0]['total'];
if (($size + strlen($imagedata)) > $limit) {
notice( upgrade_message() . EOL );
@unlink($src);
$foo = 0;
call_hooks('photo_post_end',$foo);
killme();
}
}
$ph = new Photo($imagedata, $type);
if (! $ph->is_valid()) {
@ -1145,15 +1127,6 @@ function photos_content(App $a) {
));
$usage_message = '';
$limit = service_class_fetch($a->data['user']['uid'], 'photo_upload_limit');
if ($limit !== false) {
$r = q("SELECT SUM(`datasize`) AS `total` FROM `photo` WHERE `uid` = %d AND `scale` = 0 AND `album` != 'Contact Photos'",
intval($a->data['user']['uid'])
);
$usage_message = sprintf(t("You have used %1$.2f Mbytes of %2$.2f Mbytes photo storage."), $r[0]['total'] / 1024000, $limit / 1024000 );
}
// Private/public post links for the non-JS ACL form
$private_post = 1;

View file

@ -874,12 +874,7 @@ function settings_content(App $a) {
$tpl = get_markup_template("settings_connectors.tpl");
if (! service_class_allows(local_user(),'email_connect')) {
$mail_disabled_message = upgrade_bool_message();
} else {
$mail_disabled_message = (($mail_disabled) ? t('Email access is disabled on this site.') : '');
}
$mail_disabled_message = (($mail_disabled) ? t('Email access is disabled on this site.') : '');
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_connectors"),

View file

@ -114,26 +114,6 @@ function wall_attach_post(App $a) {
killme();
}
$limit = service_class_fetch($page_owner_uid,'attach_upload_limit');
if ($limit) {
$r = q("select sum(octet_length(data)) as total from photo where uid = %d and scale = 0 and album != 'Contact Photos' ",
intval($page_owner_uid)
);
$size = $r[0]['total'];
if (($size + strlen($imagedata)) > $limit) {
$msg = upgrade_message(true);
if ($r_json) {
echo json_encode(array('error'=>$msg));
} else {
echo $msg. EOL ;
}
@unlink($src);
killme();
}
}
$filedata = @file_get_contents($src);
$mimetype = z_mime_content_type($filename);
$hash = get_guid(64);

View file

@ -189,29 +189,6 @@ function wall_upload_post(App $a, $desktopmode = true) {
killme();
}
$limit = service_class_fetch($page_owner_uid, 'photo_upload_limit');
if ($limit) {
$r = q("SELECT SUM(OCTET_LENGTH(`data`)) AS `total` FROM `photo`
WHERE `uid` = %d AND `scale` = 0
AND `album` != 'Contact Photos' ",
intval($page_owner_uid)
);
$size = $r[0]['total'];
if (($size + strlen($imagedata)) > $limit) {
$msg = upgrade_message(true);
if ($r_json) {
echo json_encode(array('error'=>$msg));
} else {
echo $msg. EOL;
}
@unlink($src);
killme();
}
}
$imagedata = @file_get_contents($src);
$ph = new Photo($imagedata, $filetype);