/** * Deletes one or more groups * * @param mixed $ids The ids to delete. * @throws \CampaignMonitorException */ public static function deleteGroups($ids) { $db = BackendModel::getContainer()->get('database'); // if $ids is not an array, make one $ids = !is_array($ids) ? array($ids) : $ids; /* * I know this is messy, but since you can remove multiple groups at * the same time in the datagrid ànd remove the record in CM we need * to loop the ID's one by one */ // loop the list foreach ($ids as $id) { // a list was deleted try { self::getCM()->deleteList(self::getCampaignMonitorID('list', $id)); } catch (\CampaignMonitorException $e) { // if list doesn't exist anymore in CM, delete our list anyway if ($e->getMessage() != "400: Invalid ListID") { throw $e; } } BackendMailmotorModel::deleteGroups($id); $db->delete('mailmotor_campaignmonitor_ids', 'type = ? AND other_id = ?', array('list', $id)); } }