} 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.'); }
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>"; }