public function _edit() { $id = abs((int) $_GET['id']); if (!$id) { return; } // Convert data to ts $_POST['ts'] = strtotime($_POST['ts']); $subscriber = new EmailSubscriberEntity($id); $subscriber->loadDataFromArray($_POST); $subscriber->save(); App::add('Email Subscriber with email "' . $subscriber->getEmail() . '" updated'); Messages::sendMessage('Subscriber updated'); go('?p=' . P . '&highlight=' . $subscriber->getId()); }
/** * @param $email * @param array $additional_data * @return bool */ public static function addNewEmailSubscriber($email, array $additional_data = []) { // Check email if (!Verify::email($email)) { return false; } // Set supplied email $subscriber = new EmailSubscriberEntity(); $subscriber->setEmail($email); // Set any supplied data if ($additional_data) { $subscriber->loadDataFromArray($additional_data); } // Create subscriber $subscriber->save(); return true; }