aboutsummaryrefslogtreecommitdiffstats
path: root/mod/item.php
diff options
context:
space:
mode:
authorChristian Vogeley <christian.vogeley@hotmail.de>2013-09-08 18:03:26 +0200
committerChristian Vogeley <christian.vogeley@hotmail.de>2013-09-08 18:03:26 +0200
commite70c9b3613088f2a34f83cb2e78a1eaee152f8cb (patch)
tree7b51c5e13cfd614ac475ec403860efa0945eb9a2 /mod/item.php
parentb88f60b51ff9416c35b5af9ce849026666c47cc8 (diff)
parentf4dfb90dbc9b7590d9b8bf84df9ca746f1aa1d6f (diff)
downloadvolse-hubzilla-e70c9b3613088f2a34f83cb2e78a1eaee152f8cb.tar.gz
volse-hubzilla-e70c9b3613088f2a34f83cb2e78a1eaee152f8cb.tar.bz2
volse-hubzilla-e70c9b3613088f2a34f83cb2e78a1eaee152f8cb.zip
Merge service class
//service class configure in .htconfig.php: $a->config['system']['default_service_class']='standard'; // this is the default service class that is attached to every new account $a->config['service_class']['standard'] = array('photo_upload_limit'=>20000000, // total photo storage limit per channel (here 20MB) 'total_identities' =>5, // number of channels an account can create 'total_items' =>2000, // number of top level posts a channel can create. Applies only to top level posts of the user, other posts and comments are unaffected 'total_pages' =>10, // number of pages a channel can create 'total_channels' =>500, // number of channels the user can add, other users can still add this channel, even if the limit is reached 'attach_upload_limit' =>20000000); // total attachment storage limit per channel (here 20MB)
Diffstat (limited to 'mod/item.php')
-rw-r--r--mod/item.php49
1 files changed, 48 insertions, 1 deletions
diff --git a/mod/item.php b/mod/item.php
index 3069bfa4d..f47180f19 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -71,7 +71,17 @@ function item_post(&$a) {
$webpage = ((x($_REQUEST,'webpage')) ? intval($_REQUEST['webpage']) : 0);
$pagetitle = ((x($_REQUEST,'pagetitle')) ? escape_tags($_REQUEST['pagetitle']) : '');
$layout_mid = ((x($_REQUEST,'layout_mid')) ? escape_tags($_REQUEST['layout_mid']): '');
-
+ /*
+ 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));
@@ -1115,3 +1125,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;
+}