function deleteEmailList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $pEmailList = new paloSantoEmaillist($pDB); $idList = getParameter('id'); if (empty($idList)) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Invalid Email List")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } if ($credentials['userlevel'] == 'superadmin') { $emailList = $pEmailList->getEmailList($idList); } else { $emailList = $pEmailList->getEmailList($idList, $credentials['domain']); } if ($emailList == false) { $smarty->assign("mb_title", _tr("Error")); $error = $emailList === false ? _tr("Couldn't be retrieved Email List data") : _tr("Email List does not exist"); $smarty->assign("mb_message", $error); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $pDB->beginTransaction(); if (!$pEmailList->deleteEmailList($idList)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pEmailList->getError()); } else { $pDB->commit(); $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("The email list(s) were successfully deleted")); } return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); }
function deleteEmailList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pEmaillist = new paloSantoEmaillist($pDB); $pDB->beginTransaction(); foreach ($_POST as $key => $value) { if ($value == "on") { if ($pEmaillist->listExistsbyId($key)) { $listName = $pEmaillist->getListName($key); if (is_null($listName)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Mailman could not remove the list")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } $id_domain = $pEmaillist->getIdDomainofList($key); if (is_null($id_domain)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Mailman could not remove the list")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } $domainName = $pEmaillist->getDomainName($id_domain); if (is_null($domainName)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Mailman could not remove the list")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } if (!$pEmaillist->deleteEmailList($key)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pEmaillist->getError()); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } if (!$pEmaillist->mailmanRemoveList($listName, $domainName)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Mailman could not remove the list")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } } } } $pDB->commit(); $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("The email list(s) were successfully deleted")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); }