function deleteUserOrganization($idUser) { $pACL = new paloACL($this->_DB); $pEmail = new paloEmail($this->_DB); $pFax = new paloFax($this->_DB); $Exito = false; //1)se comprueba de que el ID de USUARIO se un numero //2)se verifica que exista dicho usuario //3)se recompila los datos del usuario de las tablas acl_user y user_properties //4)se elimina al usuario de la base //5)se elimina la extension de uso del usuario y la extension de fax //6)se trata de eliminar la cuenta de fax //7)se elimina el buzon de correo if (!preg_match('/^[[:digit:]]+$/', "{$idUser}")) { $this->errMsg = _tr("User ID is not numeric"); return false; } else { $arrUser = $pACL->getUsers($idUser); if ($arrUser === false || count($arrUser) == 0) { $this->errMsg = _tr("User dosen't exist"); return false; } } $idDomain = $arrUser[0][4]; $query = "Select domain from organization where id=?"; $getDomain = $this->_DB->getFirstRowQuery($query, false, array($idDomain)); if ($getDomain == false) { $this->errMsg = $this->_DB->errMsg; return false; } $pDevice = new paloDevice($getDomain[0], "sip", $this->_DB); $arrExten = $pDevice->getExtension($arrUser[0][5]); $faxList = $pFax->getFaxList($arrUser[0][6], $getDomain[0]); $arrFaxExten = $faxList[0]; $this->_DB->beginTransaction(); //tomamos un backup de las extensiones que se van a eliminar de la base astDB por si algo sale mal //y ahi que restaurar la extension $arrExt = $pDevice->backupAstDBEXT($arrUser[0][5]); if ($pDevice->deleteExtension($arrUser[0][5])) { if ($pFax->deleteFaxByUser($idUser)) { if ($pACL->deleteUser($idUser)) { if ($pEmail->deleteAccount($arrUser[0][1])) { $Exito = true; $this->_DB->commit(); $pDevice->tecnologia->prunePeer($arrExten["device"], $arrExten["tech"]); $pDevice->tecnologia->prunePeer($arrFaxExten["device"], $arrFaxExten["tech"]); $pFax->restartService(); } else { $this->errMsg = _tr("Email Account cannot be deleted") . $pEmail->errMsg; $this->_DB->rollBack(); $pDevice->restoreBackupAstDBEXT($arrExt); $pFax->createFaxFileConfig($arrFaxExten['dev_id'], $getDomain[0]); } } else { $this->errMsg = $pACL->errMsg; $this->_DB->rollBack(); $pDevice->restoreBackupAstDBEXT($arrExt); $pFax->createFaxFileConfig($arrFaxExten['dev_id'], $getDomain[0]); } } else { $this->errMsg = _tr("Fax cannot be deleted") . $pFax->errMsg; $this->_DB->rollBack(); $pDevice->restoreBackupAstDBEXT($arrExt); } } else { $this->errMsg = _tr("User Extension can't be deleted") . $pDevice->errMsg; $this->_DB->rollBack(); $pDevice->restoreBackupAstDBEXT($arrExt); } return $Exito; }
function create_email_domain($pDB, &$errMsg) { $bReturn = FALSE; $pEmail = new paloEmail($pDB); $bExito = $pEmail->createDomain($_POST['domain_name']); if (!$bExito) { $errMsg = _tr($pEmail->errMsg); } return $bExito; }
function edit_email_account($pDB, &$error) { global $arrLang; $bExito = TRUE; $error_pwd = ''; $virtual = FALSE; $pEmail = new paloEmail($pDB); if (isset($_POST['password1']) && trim($_POST['password1']) != "") { $username = $_POST['username']; $bool = $pEmail->setAccountPassword($username, $_POST['password1']); if (!$bool) { $error_pwd = _tr('Password could not be changed') . ': ' . $pEmail->errMsg; $bExito = FALSE; } } if ($_POST['old_quota'] != $_POST['quota']) { $bExito = $pEmail->setAccountQuota($_POST['username'], $_POST['quota']); if (!$bExito) { $error = _tr($pEmail->errMsg); } } if ($bExito && !empty($error_pwd)) { $error = $error_pwd; } return $bExito; }
function reconstruct_mailbox(&$pDB, $arrConf, $credentials) { require_once "libs/paloSantoEmail.class.php"; $pACL = new paloACL(new paloDB($arrConf['elastix_dsn']['acl'])); $pEmail = new paloEmail($pDB); $jsonObject = new PaloSantoJSON(); $username = getParameter('username'); if (empty($username)) { $jsonObject->set_error('Invalid Username'); return $jsonObject->createJSON(); } $user = $pACL->getUserByUsername($username); if ($user == false) { $jsonObject->set_error($pACL->errMsg); return $jsonObject->createJSON(); } if ($credentials["userlevel"] == "administrator") { $user['id_organization'] != $credentials['id_organization']; $jsonObject->set_error(_tr('Invalid User')); return $jsonObject->createJSON(); } if ($pEmail->resconstruirMailBox($username)) { $jsonObject->set_message(_tr("The MailBox was reconstructed succefully")); return $jsonObject->createJSON(); } else { $jsonObject->set_error(_tr("The MailBox couldn't be reconstructed.\n" . $pEmail->errMsg)); return $jsonObject->createJSON(); } return $jsonObject->createJSON(); }
function saveNewList($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf) { $pEmaillist = new paloSantoEmaillist($pDB); $pEmail = new paloEmail($pDB); $arrDominios = array("0" => '-- ' . _tr("Select a domain") . ' --'); $arrDomains = $pEmail->getDomains(); foreach ($arrDomains as $domain) { $arrDominios[$domain[0]] = $domain[1]; } $arrFormEmaillist = createFieldForm($arrDominios); $oForm = new paloForm($smarty, $arrFormEmaillist); $emailmailman = getParameter("emailmailman") ? getParameter("emailmailman") : null; $passwdmailman = getParameter("passwdmailman") ? getParameter("passwdmailman") : null; $id_domain = getParameter("domain"); $namelist = getParameter("namelist"); $password = getParameter("password"); $passwordconfirm = getParameter("passwordconfirm"); $emailadmin = getParameter("emailadmin"); $namelist = strtolower($namelist); if (!$oForm->validateForm($_POST)) { // Falla la validación básica del formulario $strErrorMsg = "<b>" . _tr('The following fields contain errors') . ":</b><br/>"; $arrErrores = $oForm->arrErroresValidacion; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}: [{$v['mensaje']}] <br /> "; } } $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", $strErrorMsg); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } elseif (!preg_match("/^[[:alpha:]]+([\\-_\\.]?[[:alnum:]]+)*\$/", $namelist)) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Wrong List Name")); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } elseif ($password != $passwordconfirm) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The Password List and Confirm Password List do not match")); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } elseif (!$pEmaillist->domainExists($id_domain)) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The domain selected does not exist")); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } elseif ($pEmaillist->listExistsbyName($namelist)) { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The List entered already exists")); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } if (isset($emailmailman) && isset($passwdmailman) && !$pEmaillist->isMailmanListCreated()) { if (!$pEmaillist->mailmanCreateList("mailman", $emailmailman, $passwdmailman)) { $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Could not create the list") . " mailman"); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } } $pDB->beginTransaction(); if (!$pEmaillist->saveEmailList($id_domain, $namelist, $password, $emailadmin)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", $pEmaillist->getError()); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } $domainName = $pEmaillist->getDomainName($id_domain); if (!isset($domainName)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("The domain selected does not exist")); return viewFormEmaillist($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } if (!$pEmaillist->mailmanCreateList($namelist, $emailadmin, $password, $domainName)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Could not create the list") . " {$namelist}"); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } if (!$pEmaillist->mailmanCreateVirtualAliases($namelist, $domainName)) { $pDB->rollBack(); $smarty->assign("mb_title", _tr("Error")); $smarty->assign("mb_message", _tr("Could not create the virtual alias")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); } $pDB->commit(); $smarty->assign("mb_title", _tr("Message")); $smarty->assign("mb_message", _tr("The List was successfully created")); return reportEmailList($smarty, $module_name, $local_templates_dir, $pDB, $arrConf); }