aboutsummaryrefslogtreecommitdiffstats
path: root/mod/import.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2014-09-15 17:17:00 -0700
committerfriendica <info@friendica.com>2014-09-15 17:17:00 -0700
commitbbc9e4427e76761b0607ce2c1a1f5cc7f499b52f (patch)
tree46358c59fea737736aa7898439fd8ef3c576be14 /mod/import.php
parentc841714ba5d0df349e0f9d972fafa18a72fc4f1e (diff)
downloadvolse-hubzilla-bbc9e4427e76761b0607ce2c1a1f5cc7f499b52f.tar.gz
volse-hubzilla-bbc9e4427e76761b0607ce2c1a1f5cc7f499b52f.tar.bz2
volse-hubzilla-bbc9e4427e76761b0607ce2c1a1f5cc7f499b52f.zip
honour service class restrictions for total_identities, total_channels ("friends") and total_feeds both when importing channels and subsequently when syncing clones. Limits are based on the local system - additional entries are silently dropped.
Diffstat (limited to 'mod/import.php')
-rw-r--r--mod/import.php29
1 files changed, 28 insertions, 1 deletions
diff --git a/mod/import.php b/mod/import.php
index 7452bcdc9..22eb688ab 100644
--- a/mod/import.php
+++ b/mod/import.php
@@ -9,10 +9,25 @@ require_once('include/identity.php');
function import_post(&$a) {
- if(! get_account_id()) {
+ $account_id = get_account_id();
+ if(! $account_id)
return;
+
+ $max_identities = account_service_class_fetch($account_id,'total_identities');
+ $max_friends = account_service_class_fetch($account_id,'total_channels');
+ $max_feeds = account_service_class_fetch($account_id,'total_feeds');
+
+ if($max_identities !== false) {
+ $r = q("select channel_id from channel where channel_account_id = %d",
+ intval($account_id)
+ );
+ if($r && count($r) > $max_identities) {
+ notice( sprintf( t('Your service plan only allows %d channels.'), $max_identities) . EOL);
+ return;
+ }
}
+
$data = null;
$seize = ((x($_REQUEST,'make_primary')) ? intval($_REQUEST['make_primary']) : 0);
@@ -276,10 +291,18 @@ function import_post(&$a) {
// FIXME - ensure we have an xchan if somebody is trying to pull a fast one
+ $friends = 0;
+ $feeds = 0;
+
// import contacts
$abooks = $data['abook'];
if($abooks) {
foreach($abooks as $abook) {
+ if($max_friends !== false && $friends > $max_friends)
+ continue;
+ if($max_feeds !== false && ($abook['abook_flags'] & ABOOK_FLAG_FEED) && $feeds > $max_feeds)
+ continue;
+
unset($abook['abook_id']);
$abook['abook_account'] = get_account_id();
$abook['abook_channel'] = $channel['channel_id'];
@@ -289,6 +312,10 @@ function import_post(&$a) {
. "`) VALUES ('"
. implode("', '", array_values($abook))
. "')" );
+
+ $friends ++;
+ if($abook['abook_flags'] & ABOOK_FLAG_FEED)
+ $feeds ++;
}
}