/** * Delete addresses */ private function deleteAddresses() { // no group set if ($this->groupId == '') { $this->groupId = null; } // get all groups $groupIds = BackendMailmotorModel::getGroupIDs(); // loop the emails foreach ($this->emails as $email) { // the group ID is not set if ($this->groupId == null) { // if no groups were set, break here if (empty($groupIds)) { break; } // loop the group IDs foreach ($groupIds as $groupId) { // try to unsubscribe this address try { BackendMailmotorCMHelper::unsubscribe($email, $groupId); } catch (\Exception $e) { // do nothing } } // delete all addresses BackendMailmotorModel::deleteAddresses($email); } else { // group ID was set, unsubscribe the address for this group BackendMailmotorCMHelper::unsubscribe($email, $this->groupId); } } // trigger event BackendModel::triggerEvent($this->getModule(), 'after_delete_addresses'); // redirect $this->redirect(BackendModel::createURLForAction('Addresses') . '&report=delete-addresses' . (!empty($this->groupId) ? '&group_id=' . $this->groupId : '')); }