Example #1
0
 /**
  * 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');
     }
 }
Example #2
0
 /**
  * Unsubscribes an e-mail address from CampaignMonitor and our database
  *
  * @param string $email   The emailaddress to unsubscribe.
  * @param string $groupId The group wherefrom the emailaddress should be unsubscribed.
  * @return bool
  */
 public static function unsubscribe($email, $groupId = null)
 {
     $groupId = !empty($groupId) ? $groupId : BackendMailmotorModel::getDefaultGroupID();
     $groupCMId = self::getCampaignMonitorID('list', $groupId);
     // group exists
     if (BackendMailmotorModel::existsGroup($groupId)) {
         self::getCM()->unsubscribe($email, $groupCMId);
         $subscriber = array();
         $subscriber['status'] = 'unsubscribed';
         $subscriber['unsubscribed_on'] = BackendModel::getUTCDate('Y-m-d H:i:s');
         BackendModel::getContainer()->get('database')->update('mailmotor_addresses_groups', $subscriber, 'email = ? AND group_id = ?', array($email, $groupId));
         return true;
     }
     return false;
 }