/** * Execute the action */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if (BackendMailmotorModel::existsGroup($this->id)) { parent::execute(); $this->getData(); $this->loadForm(); $this->validateForm(); $this->parse(); $this->display(); } else { $this->redirect(BackendModel::createURLForAction('groups') . '&error=non-existing'); } }
/** * Execute the action * * @return void */ public function execute() { // get parameters $this->id = $this->getParameter('id', 'int'); // does the item exist if (BackendMailmotorModel::existsGroup($this->id)) { // call parent, this will probably add some general CSS/JS or other required files parent::execute(); // get all data for the item we want to edit $this->getData(); // load the form $this->loadForm(); // validate the form $this->validateForm(); // parse $this->parse(); // display the page $this->display(); } else { $this->redirect(BackendModel::createURLForAction('groups') . '&error=non-existing'); } }
/** * Unsubscribes an e-mail address from CampaignMonitor and our database * * @param string $email The emailaddress to unsubscribe. * @param string[optional] $groupId The group wherefrom the emailaddress should be unsubscribed. * @return bool */ public static function unsubscribe($email, $groupId = null) { // get objects $cm = self::getCM(); // set group ID $groupId = !empty($groupId) ? $groupId : BackendMailmotorModel::getDefaultGroupID(); // get group CM ID $groupCMId = self::getCampaignMonitorID('list', $groupId); // group exists if (BackendMailmotorModel::existsGroup($groupId)) { // unsubscribe the email from this group self::getCM()->unsubscribe($email, $groupCMId); // set variables $subscriber = array(); $subscriber['status'] = 'unsubscribed'; $subscriber['unsubscribed_on'] = BackendModel::getUTCDate('Y-m-d H:i:s'); // unsubscribe the user BackendModel::getDB(true)->update('mailmotor_addresses_groups', $subscriber, 'email = ? AND group_id = ?', array($email, $groupId)); // user unsubscribed return true; } // user not unsubscribed return false; }