aboutsummaryrefslogtreecommitdiffstats
path: root/mod/import.php
diff options
context:
space:
mode:
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 ++;
}
}