diff options
author | Christian Vogeley <christian.vogeley@hotmail.de> | 2013-09-08 17:19:09 +0200 |
---|---|---|
committer | Christian Vogeley <christian.vogeley@hotmail.de> | 2013-09-08 17:19:09 +0200 |
commit | f4dfb90dbc9b7590d9b8bf84df9ca746f1aa1d6f (patch) | |
tree | ca3b772411fc6c6da25e7889cd2260427dc774ee | |
parent | 94fb9c240661a9cd2b7199a648e9c5b4f9b69e8d (diff) | |
download | volse-hubzilla-f4dfb90dbc9b7590d9b8bf84df9ca746f1aa1d6f.tar.gz volse-hubzilla-f4dfb90dbc9b7590d9b8bf84df9ca746f1aa1d6f.tar.bz2 volse-hubzilla-f4dfb90dbc9b7590d9b8bf84df9ca746f1aa1d6f.zip |
Service class items
Items / webpages /attachment message
-rw-r--r-- | include/attach.php | 2 | ||||
-rw-r--r-- | mod/item.php | 48 |
2 files changed, 49 insertions, 1 deletions
diff --git a/include/attach.php b/include/attach.php index 46d406f4b..da08154c6 100644 --- a/include/attach.php +++ b/include/attach.php @@ -339,7 +339,7 @@ function attach_store($channel,$observer_hash,$options = '',$arr = null) { intval($channel_id) ); if(($r) && (($r[0]['total'] + $filesize) > ($limit - $existing_size))) { - $ret['message'] = upgrade_message(true); + $ret['message'] = upgrade_message(true).sprintf(t("You have reached your limit of %1$.0f Mbytes attachment storage."),$limit / 1024000); @unlink($src); return $ret; } diff --git a/mod/item.php b/mod/item.php index 1893a6ef4..695fdb7bb 100644 --- a/mod/item.php +++ b/mod/item.php @@ -71,7 +71,18 @@ function item_post(&$a) { $webpage = ((x($_REQUEST,'webpage')) ? intval($_REQUEST['webpage']) : 0); $pagetitle = ((x($_REQUEST,'pagetitle')) ? escape_tags($_REQUEST['pagetitle']): ''); $buildblock = ((x($_REQUEST,'buildblock')) ? intval($_REQUEST['buildblock']) : 0); + /* + Check service class limits + */ + if (local_user() && !(x($_REQUEST,'parent')) && !(x($_REQUEST,'post_id'))) { + $ret=item_check_service_class(local_user(),x($_REQUEST,'webpage')); + if (!$ret['success']) { + notice( t($ret['message']) . EOL) ; + goaway($a->get_baseurl() . "/" . $return_path ); + killme(); + } + } if($pagetitle) { require_once('library/urlify/URLify.php'); $pagetitle = strtolower(URLify::transliterate($pagetitle)); @@ -1081,3 +1092,40 @@ function fix_attached_file_permissions($channel,$observer_hash,$body, } } } +function item_check_service_class($channel_id,$iswebpage) { + $ret = array('success' => false, $message => ''); + if ($iswebpage) { + $r = q("select count(i.id) as total from item i + right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) + and i.parent=i.id and (i.item_restrict & %d) and i.uid= %d ", + intval(ITEM_WEBPAGE), + intval($channel_id) + ); + } + else { + $r = q("select count(i.id) as total from item i + right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) + and i.parent=i.id and (i.item_restrict=0) and i.uid= %d ", + intval($channel_id) + ); + } + if(! ($r && count($r))) { + $ret['message'] = t('Unable to obtain identity information from database'); + return $ret; + } + if (!$iswebpage) { + if(! service_class_allows($channel_id,'total_items',$r[0]['total'])) { + $result['message'] .= upgrade_message().sprintf(t("You have reached your limit of %1$.0f top level posts."),$r[0]['total']); + return $result; + } + } + else { + if(! service_class_allows($channel_id,'total_pages',$r[0]['total'])) { + $result['message'] .= upgrade_message().sprintf(t("You have reached your limit of %1$.0f webpages."),$r[0]['total']); + return $result; + } + } + + $ret['success'] = true; + return $ret; +} |