}
 if ($http->hasPostVariable('RobinsonlistEntry_Mobile')) {
     if ($http->postVariable('RobinsonlistEntry_Mobile') != "") {
         $empty_input = false;
         if ($http->hasPostVariable('AddButton')) {
             if (!eZRobinsonListEntry::inList($http->postVariable('RobinsonlistEntry_Mobile'), eZRobinsonListEntry::MOBILE)) {
                 eZRobinsonListEntry::create($http->postVariable('RobinsonlistEntry_Mobile'), eZRobinsonListEntry::MOBILE, eZRobinsonListEntry::IMPORT_LOCAL);
                 $done = true;
             } else {
                 $warning = ezpI18n::tr('eznewsletter/robinson_user', 'Entered mobile phone number is already in the list.');
                 $done = true;
             }
         } else {
             if ($http->hasPostVariable('RemoveButton')) {
                 if (eZRobinsonListEntry::inList($http->postVariable('RobinsonlistEntry_Mobile'), eZRobinsonListEntry::MOBILE, eZRobinsonListEntry::IMPORT_LOCAL)) {
                     eZRobinsonListEntry::removeByValue($http->postVariable('RobinsonlistEntry_Mobile'), eZRobinsonListEntry::MOBILE, eZRobinsonListEntry::IMPORT_LOCAL);
                     $done = true;
                 } else {
                     $warning = ezpI18n::tr('eznewsletter/robinson_user', 'Entered mobile phone number is not in the list.');
                     $done = true;
                 }
             }
         }
     }
 }
 if (!$done && $warning == "") {
     $warning = ezpI18n::tr('eznewsletter/robinson_user', 'An error occured, no updates were made.');
 }
 if ($done && $warning == "") {
     $warning = ezpI18n::tr('eznewsletter/robinson_user', 'Updates complete.');
 }
            } else {
                $labelMap = array();
                foreach (array_keys($data) as $label) {
                    $mapName = 'LabelMap_' . $label;
                    if ($http->hasPostVariable($mapName)) {
                        if ($http->postVariable($mapName) != '0') {
                            $labelMap[$http->postVariable($mapName)] = $label;
                        }
                    }
                }
                if ($http->hasPostVariable('RowNum')) {
                    $subscriptionListID = $subscriptionList->attribute('id');
                    foreach ($http->postVariable('RowNum') as $rowIndex) {
                        if ($data[$labelMap['email']][$rowIndex] != "") {
                            if (!eZSubscription::fetchByEmailSubscriptionListID($data[$labelMap['email']][$rowIndex], $subscriptionListID)) {
                                if (!eZRobinsonListEntry::inList($data[$labelMap['email']][$rowIndex])) {
                                    $subscription = eZSubscription::create($subscriptionListID, $data[$labelMap['firstname']][$rowIndex], $data[$labelMap['name']][$rowIndex], $data[$labelMap['mobile']][$rowIndex], $data[$labelMap['email']][$rowIndex]);
                                    $subscription->setAttribute('status', eZSubscription::StatusApproved);
                                    $subscription->publish();
                                }
                            }
                        }
                    }
                }
                $http->removeSessionVariable('CSVData');
                return $Module->redirectToView('subscription_list', array($subscriptionList->attribute('url_alias')));
            }
        }
    }
}
$data = array();
 static function importData($data, $labels, $rows, $global, $type, $options)
 {
     if ($type == self::EMAIL) {
         $mapping = $labels['email'];
     } else {
         if ($type == self::MOBILE) {
             $mapping = $labels['mobile'];
         }
     }
     //add new entries
     if ($options == self::ADD) {
         foreach ($rows as $rowIndex) {
             //add new from new data
             $value = $data[$mapping][$rowIndex];
             //echo "Adding: ".$value." ".$type." ".$global."<br>";
             eZRobinsonListEntry::create($value, $type, $global);
         }
     } else {
         if ($options == self::SYNC) {
             $new_values = array();
             foreach ($rows as $rowIndex) {
                 $new_values = array_merge($new_values, $data[$mapping][$rowIndex]);
             }
             foreach ($new_values as $value) {
                 //add new from new data
                 //echo "Sync Adding: ".$value." ".$type." ".$global."<br>";
                 eZRobinsonListEntry::create($value, $type, $global);
             }
             //get all current data
             $old_values = eZRobinsonListEntry::fetchValues($type, $global);
             foreach ($old_values as $value) {
                 if (!in_array($value, $new_values)) {
                     //remove from database
                     //echo "Sync Removing: ".$value." ".$type." ".$global."<br>";
                     eZRobinsonListEntry::removeByValue($value, $type, $global);
                 }
             }
         }
     }
     //echo "<br>";
 }
示例#4
0
 function addNumber($number)
 {
     if (!eZRobinsonListEntry::inList($number, eZRobinsonListEntry::MOBILE)) {
         $this->numbers[] = $this->numberClean($number);
     }
 }
         }
     }
 } else {
     $password = false;
     if ($subscriptionList->attribute('require_password')) {
         if ($http->postVariable('Password1') != 'password' && $http->postVariable('Password1') === $http->postVariable('Password2') && strlen(trim($http->postVariable('Password1'))) > 0) {
             $password = $http->postVariable('Password1');
         } else {
             $warning = ezi18n('eznewsletter/register_subscription', 'Passwords did not match.');
         }
     }
     $firstname = $http->postVariable('Firstname');
     $name = $http->postVariable('Name');
     $email = $http->postVariable('Email');
     $mobile = $http->postVariable('Mobile');
     if (!eZRobinsonListEntry::inList($http->postVariable('Email')) && !eZRobinsonListEntry::inList($http->postVariable('Mobile'))) {
         if (!$firstname) {
             $warning = ezi18n('eznewsletter/register_subscription', 'You must enter a first name.');
         }
         if (!$name) {
             $warning = ezi18n('eznewsletter/register_subscription', 'You must enter a last name.');
         }
         if (!eZMail::validate($email)) {
             $warning = ezi18n('eznewsletter/register_subscription', 'You must provide a valid email address.');
         }
         if (!$warning) {
             $subscription = $subscriptionList->registerSubscription($firstname, $name, $mobile, $email, $password);
             if (!$subscription) {
                 $warning = ezi18n('eznewsletter/register_subscription', 'You\'re already a registered subscriber');
             } else {
                 if ($http->hasPostVariable('OutputFormat')) {
    $parser = new eZCSVParser($binaryFile->attribute('filename'), $http->hasPostVariable('FirstRowLabel') ? true : false);
    $data = $parser->data();
    $http->setSessionVariable('CSVData', $data);
} else {
    if ($http->hasSessionVariable('CSVData')) {
        $data = $http->sessionVariable('CSVData');
    }
}
$tpl = eZNewsletterTemplateWrapper::templateInit();
$tpl->setVariable('data', $data);
if (isset($warning)) {
    $tpl->setVariable('warning', $warning);
}
$tpl->setVariable('global_map', eZRobinsonListEntry::globalNameMap());
$tpl->setVariable('type_map', eZRobinsonListEntry::typeNameMap());
$tpl->setVariable('import_map', eZRobinsonListEntry::importNameMap());
if ($http->hasPostVariable('import_list')) {
    $tpl->setVariable('import_list', $http->postVariable('import_list'));
}
if ($http->hasPostVariable('import_options')) {
    $tpl->setVariable('import_options', $http->postVariable('import_options'));
}
if ($http->hasPostVariable('import_datatype')) {
    $tpl->setVariable('import_datatype', $http->postVariable('import_datatype'));
}
if ($http->hasPostVariable('RowNum')) {
    $tpl->setVariable('RowNum', $http->postVariable('RowNum'));
}
$Result = array();
$Result['newsletter_menu'] = 'design:parts/content/robinson_menu.tpl';
$Result['left_menu'] = 'design:parts/content/eznewsletter_menu.tpl';
$limitList = array('1' => 10, '2' => 25, '3' => 50);
$limit = $limitList[(string) $limitKey];
$viewParameters = array('offset' => $offset);
if ($http->hasPostVariable('CreateRobinsonlistEntryButton')) {
    $robinsonlistEntry = eZRobinsonListEntry::create();
    return $Module->redirectToView('robinson_edit', array($robinsonlistEntry->attribute('id')));
}
$condArray = array();
if (!in_array(-1, $statusFilterArray)) {
    $condArray['global'] = array($statusFilterArray);
}
$robinsonlist_Email = eZRobinsonListEntry::fetchByOffset(eZRobinsonListEntry::EMAIL, $condArray, $offset, $limit);
$robinsonlist_Mobile = eZRobinsonListEntry::fetchByOffset(eZRobinsonListEntry::MOBILE, $condArray, $offset, $limit);
$tpl = eZNewsletterTemplateWrapper::templateInit();
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('statusFilter', $statusFilterArray);
$tpl->setVariable('limit', $limit);
$tpl->setVariable('robinsonlist_Email', $robinsonlist_Email);
$tpl->setVariable('robinsonlist_Mobile', $robinsonlist_Mobile);
$tpl->setVariable('status_map', eZRobinsonListEntry::globalNameMap());
$tpl->setVariable('type_map', eZRobinsonListEntry::typeNameMap());
$tpl->setVariable('robinsonlistCount_Email', eZRobinsonListEntry::countAll(eZRobinsonListEntry::EMAIL, $condArray));
$tpl->setVariable('robinsonlistCount_Mobile', eZRobinsonListEntry::countAll(eZRobinsonListEntry::MOBILE, $condArray));
if (isset($warning)) {
    $tpl->setVariable('warning', $warning);
}
$Result = array();
$Result['newsletter_menu'] = 'design:parts/content/robinson_menu.tpl';
$Result['left_menu'] = 'design:parts/content/eznewsletter_menu.tpl';
$Result['content'] = $tpl->fetch("design:eznewsletter/robinson_show.tpl");
$Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('eznewsletter/robinson_show', 'Opt-out list')));
 function buildSendList()
 {
     $mailsettings = eZINI::instance('bounce.ini');
     $bounceCountStop = $mailsettings->variable('BounceSettings', 'BounceCount') ? $mailsettings->variable('BounceSettings', 'BounceCount') : 2;
     $db = eZDB::instance();
     $db->begin();
     $sql = "SELECT email, SUM(bounce_count) FROM ezsubscription GROUP BY email HAVING SUM(bounce_count) >=" . $bounceCountStop;
     $bouncedRecipients = $db->arrayQuery($sql);
     $bounceEmails = array();
     foreach ($bouncedRecipients as $bounce) {
         if (!in_array($bounce['email'], $bounceEmails)) {
             $bounceEmails[] = $bounce['email'];
         }
     }
     $newsletterType = $this->attribute('newsletter_type');
     foreach ($newsletterType->attribute('subscription_list') as $newsletterSubscriptionLink) {
         $offset = 0;
         $subscriptionList = $newsletterSubscriptionLink->attribute('subscription_object');
         while ($subscriptionArray = $subscriptionList->fetchSubscriptionArray($offset, eZNewsletter::MaxSubscriptionFetchLimit, true, eZSubscription::VersionStatusPublished, array(array(eZSubscription::StatusApproved, eZSubscription::StatusConfirmed)))) {
             foreach ($subscriptionArray as $subscription) {
                 if (!eZRobinsonListEntry::inList($subscription->attribute('email'), eZRobinsonListEntry::EMAIL)) {
                     if (in_array($subscription->attribute('email'), $bounceEmails)) {
                         //This recipient is in the bounce register, we set mailing on hold
                         eZSendNewsletterItem::create($this->attribute('id'), $subscription->attribute('id'), eZSendNewsletterItem::SendStatusOnHold);
                     } else {
                         if (eZMail::validate($subscription->attribute('email'))) {
                             eZSendNewsletterItem::create($this->attribute('id'), $subscription->attribute('id'));
                             echo ".";
                         } else {
                             echo "Invalid email address: <" . $subscription->attribute('email') . ">" . "\n";
                         }
                     }
                 } else {
                     echo "Ignoring <" . $subscription->attribute('email') . "> (in robinsonlist)" . "\n";
                 }
             }
             $offset += eZNewsletter::MaxSubscriptionFetchLimit;
         }
     }
     $db->commit();
 }