/**
  * remove the current subscription
  * @see kernel/classes/eZPersistentObject#remove($conditions, $extraConditions)
  */
 function remove($conditions = null, $extraConditions = null)
 {
     CjwNewsletterLog::writeNotice('CjwNewsletterSubscription::remove', 'subscription', 'remove', array('nl_user' => $this->attribute('newsletter_user_id'), 'subscription_id' => $this->attribute('id'), 'modifier' => eZUser::currentUserID()));
     foreach ($currentNewsletterSubscriptionObjects as $subscription) {
         $subscription->remove();
     }
     parent::remove($conditions, $extraConditions);
 }
Exemplo n.º 2
0
 /**
  * fetch all active subscriptions with current import id
  * and set status to remove by admin
  * @return array subscriptions => nl_user_id
  */
 public function removeActiveSubscriptionsByAdmin()
 {
     $count = CjwNewsletterSubscription::fetchSubscriptionListByImportIdAndStatusCount($this->attribute('id'), CjwNewsletterSubscription::STATUS_APPROVED);
     CjwNewsletterLog::writeNotice("CjwNewsletterImport::removeActiveSubscriptionsByAdmin", 'import', 'start', array('import_id' => $this->attribute('id'), 'active_subscriptions' => $count, 'current_user' => eZUser::currentUserID()));
     // count active subscriptions for import id
     $removeSubscriptionArray = array();
     $limit = 100;
     $loops = ceil($count / $limit);
     // get active subscriptions partly
     for ($i = 0; $i < $loops; $i++) {
         // get active subscriptions
         $subscriptionObjectList = CjwNewsletterSubscription::fetchSubscriptionListByImportIdAndStatus($this->attribute('id'), CjwNewsletterSubscription::STATUS_APPROVED, $limit);
         foreach ($subscriptionObjectList as $subscription) {
             $subscription->removeByAdmin();
             $removeSubscriptionArray[$subscription->attribute('id')] = $subscription->attribute('newsletter_user_id');
         }
     }
     $count = CjwNewsletterSubscription::fetchSubscriptionListByImportIdAndStatusCount($this->attribute('id'), CjwNewsletterSubscription::STATUS_APPROVED);
     CjwNewsletterLog::writeNotice("CjwNewsletterImport::removeActiveSubscriptionsByAdmin", 'import', 'end', array('import_id' => $this->attribute('id'), 'subscriptions_remove_count' => count($removeSubscriptionArray), 'current_user' => eZUser::currentUserID()));
     return $removeSubscriptionArray;
 }
                    $createNewSubscription = 1;
                    $newListSubscription = CjwNewsletterSubscription::create($listContentObjectId, $newsletterUserId, $outputFormatArray, CjwNewsletterSubscription::STATUS_APPROVED);
                    $newListSubscription->setAttribute('import_id', $importId);
                    // set new remote_id
                    $newListSubscription->setAttribute('remote_id', 'cjwnl:csvimport:' . CjwNewsletterUtils::generateUniqueMd5Hash($newsletterUserId . $importId));
                    $newListSubscription->store();
                    $subscriptionObject = $newListSubscription;
                    $newSubscriptionStatus = $subscriptionObject->attribute('status');
                }
            }
        }
        $listSubscriptionArray[$rowId] = array('subscription_object' => $subscriptionObject, 'email_ok' => $emailOk, 'user_created' => $createNewUser, 'newsletter_user_id' => $newsletterUserId, 'subscription_created' => $createNewSubscription, 'user_status_old' => $existingUserStatus, 'user_status_new' => $newUserStatus, 'subscription_status_old' => $existingSubscriptionStatus, 'subscription_status_new' => $newSubscriptionStatus);
    }
    // imported timestamp + set count for imported users + subscriptions
    $importObject->setImported();
    CjwNewsletterLog::writeNotice('subscription_list_csvimport', 'import', 'end', array('import_id' => $importObject->attribute('id'), 'current_user' => eZUser::currentUserID()));
    // store result to File
    storeImportResultToFile($importId, $listSubscriptionArray);
}
//}
$viewParameters = array('offset' => 0, 'namefilter' => '');
$userParameters = $Params['UserParameters'];
$viewParameters = array_merge($viewParameters, $userParameters);
$tpl = templateInit();
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('list_node', $listNode);
$tpl->setVariable('import_id', $importId);
$tpl->setVariable('import_object', $importObject);
$tpl->setVariable('selected_output_format_array', $selectedOutputFormatArray);
$tpl->setVariable('csv_data_array', $csvDataArray);
$tpl->setVariable('list_subscription_array', $listSubscriptionArray);
Exemplo n.º 4
0
 /**
  * remove the current newlsetter user and all depending nl subscriptions
  * @see kernel/classes/eZPersistentObject#remove($conditions, $extraConditions)
  */
 function remove($conditions = null, $extraConditions = null)
 {
     // remove subscriptions
     $currentNewsletterSubscriptionObjects = $this->attribute('subscription_array');
     CjwNewsletterLog::writeNotice('CjwNewsletterUser::remove', 'user', 'remove', array('nl_user' => $this->attribute('id'), 'subscription_count' => count($currentNewsletterSubscriptionObjects), 'subscriptions_to_remove' => implode('|', array_keys($currentNewsletterSubscriptionObjects)), 'modifier' => eZUser::currentUserID()));
     foreach ($currentNewsletterSubscriptionObjects as $subscription) {
         $subscription->remove();
     }
     $blackListItem = CjwNewsletterBlacklistItem::fetchByEmail($this->attribute('email'));
     if (is_object($blackListItem)) {
         $blackListItem->setAttribute('newsletter_user_id', 0);
         $blackListItem->store();
     }
     parent::remove($conditions, $extraConditions);
 }