function get_templateEmail($smarty, $module_name, $local_templates_dir, $arrConf, &$pImap) { $jsonObject = new PaloSantoJSON(); global $arrCredentials; $alias = getParameter('destination'); if (!empty($alias)) { $username = explode("@", $alias); $destination = $username[0] . "@" . $arrCredentials['domain']; $smarty->assign("USERNAME", $destination); } $smarty->assign("TO", _tr('To')); $smarty->assign("CC", _tr('CC')); $smarty->assign("BCC", _tr('BCC')); $smarty->assign("REPLYTO", _tr('Reply to')); $smarty->assign("SUBJECT", _tr('Subject')); //eliminamos el contenido de la variable de session elastix_emailAttachs //esta variable contiene el nombre de los archivos atachados unset($_SESSION['elastix_emailAttachs']); //es necesario obtener el lenguage del usuario para la traduccion del lenguage //para el complemento que se usa para componer los mensajes global $arrCredentials; $idUser = $arrCredentials['idUser']; $lang = 'en'; //default language $pDB = new paloDB($arrConf['elastix_dsn']['elastix']); $pACL = new paloACL($pDB); $defLang = $pACL->getUserProp($idUser, 'language'); if ($defLang == false) { $lang = $defLang; } unset($_SESSION['elastix_emailAttachs']); //unset($_POST['?menu=home&action=attach_file&rawmode=yes']); //unset($_FILES['attachFileButton']); $smarty->assign("USER_LANG", $lang); $smarty->assign("MSG_EMPTYTO", _tr("Field 'To' can not be empty")); $smarty->assign("MSG_SUBJECT", _tr("Do you wish send this message with empty subject")); $smarty->assign("MSG_CONTENT", _tr("Do you wish send this message with empty body")); $smarty->assign("TEXT_UPLOADING", _tr("Uploading..")); $internalContacts = $pImap->getListInternalContacts(); $externalContacts = $pImap->getListExternalContacts(); $arrContacts = array(); if (is_array($internalContacts)) { foreach ($internalContacts as $contact) { $arrContacts[] = htmlentities($contact['name'], ENT_COMPAT, 'UTF-8') . " <" . htmlentities($contact['username'], ENT_COMPAT, 'UTF-8') . ">"; } } if (is_array($externalContacts)) { foreach ($externalContacts as $contact) { $arrContacts[] = htmlentities($contact['name'], ENT_COMPAT, 'UTF-8') . " <" . htmlentities($contact['username'], ENT_COMPAT, 'UTF-8') . ">"; } } $contenidoModulo = $smarty->fetch("file:{$local_templates_dir}/compose.tpl"); $arrData = array(); $arrData['modulo'] = $contenidoModulo; $arrData['contacts'] = $arrContacts; $jsonObject->set_message($arrData); return $jsonObject->createJSON(); }
function updateUserOrganization($idUser, $name, $md5password, $password1, $extension, $fax_extension, $countryCode, $areaCode, $clidNumber, $cldiName, $idGrupo, $quota, $userLevel1, &$reAsterisk) { require_once "apps/general_settings/libs/paloSantoGlobalsPBX.class.php"; $pACL = new paloACL($this->_DB); $pEmail = new paloEmail($this->_DB); $pFax = new paloFax($this->_DB); $continuar = true; $Exito = false; $error = ""; $cExten = false; $cFExten = false; $arrBackup = array(); $editFax = false; $faxProperties = array(); $arrUser = $pACL->getUsers2($idUser); if ($arrUser === false || count($arrUser) == 0 || !isset($idUser)) { $this->errMsg = _tr("User dosen't exist"); return false; } if ($pACL->isUserSuperAdmin($arrUser[0]['username'])) { $this->errMsg = _tr("Invalid Action"); return false; } $arrOrgz = $this->getOrganizationById($arrUser[0]['id_organization']); $username = $arrUser[0]['username']; $oldExten = $arrUser[0]['extension']; $oldFaxExten = $arrUser[0]['fax_extension']; $pDevice = new paloDevice($arrOrgz["domain"], "sip", $this->_DB); $arrExtUser = $pDevice->getExtension($oldExten); $listFaxs = $pFax->getFaxList(array("exten" => $oldFaxExten, "organization_domain" => $arrOrgz['domain'])); $faxUser = $listFaxs[0]; if ($name == "") { $name = $username; } if ($userLevel1 == "other") { $extension = $arrUser[0]['extension']; $fax_extension = $arrUser[0]['fax_extension']; $quota = $pACL->getUserProp($idUser, "email_quota"); $idGrupo = $arrUser[0]['id_group']; $modificarExts = false; } else { //verificar si el usuario cambio de extension y si es asi que no este siendo usado por otro usuario if ($extension != $oldExten) { if ($pDevice->existDevice($extension, "{$arrOrgz["code"]}_{$extension}", $arrExtUser["tech"]) == true) { $this->errMsg = $pDevice->errMsg; return false; } else { $cExten = true; } } if ($fax_extension != $oldFaxExten) { //si el usairo quiere cambiar el patron de marcado asociado al fax verificar que el nuevo //patron de marcado no este siendo usado dentro de la organizacion if ($pDevice->tecnologia->existExtension($fax_extension, $pDevice->getDomain())) { $this->errMsg = $pDevice->errMsg; return false; } else { $cFExten = true; } } //para cambiar al usuario de extension o faxextension es necesario que se haya llenado el campo password para //poder crear las extensiones con la clave correcta if ($cExten || $cFExten) { if (is_null($md5password) || $md5password == "" || is_null($password1) || $password1 == "") { $this->errMsg = _tr("Please set a password"); return false; } } } if (empty($clidNumber) && $clidNumber != 0) { $clidNumber = $faxUser['clid_number']; } if (empty($cldiName) && $cldiName != 0) { $cldiName = $faxUser['clid_name']; } if (empty($country_code)) { $country_code = $faxUser['country_code']; } if (empty($area_code)) { $area_code = $faxUser['area_code']; } $this->_DB->beginTransaction(); //actualizamos la informacion de usuario que esta en la tabla acl_user if ($pACL->updateUser($idUser, $name, $extension, $fax_extension)) { //actualizamos el grupo al que pertennece el usuario if ($pACL->addToGroup($idUser, $idGrupo)) { $old_quota = $pACL->getUserProp($idUser, "email_quota"); if ($old_quota === false) { $old_quota = 1; } //actualizamos la quota de correo if (isset($quota) && $quota != "" && $continuar) { if ($pEmail->updateQuota($old_quota * 1024, $quota * 1024, $username)) { if (!$pACL->setUserProp($idUser, "email_quota", $quota, "email")) { $error = _tr("Error setting email quota") . $pACL->errMsg; $pEmail->updateQuota($quota, $old_quota); $this->_DB->rollBack(); $continuar = false; } } else { $error = _tr("Error setting email quota") . $pEmail->errMsg; $continuar = false; } } if ($continuar) { if ($cExten && $userLevel1 != "other") { if (!$this->modificarExtensionUsuario($arrOrgz["domain"], $oldExten, $extension, $password1, $name, $username, $arrBackup)) { $error = "Couldn't updated user extension. " . $this->errMsg; $continuar = false; } } } //actualizamos el password del usuario if ($password1 !== "" && $continuar) { if ($pACL->changePassword($idUser, $md5password)) { //en caso que no se hayan modificado la extensiones del usuario //entonces es necesario actualizar el passoword para la extension y el fax if (!$cExten) { if (!$pDevice->changePasswordExtension($password1, $extension)) { $this->errMsg = _tr("Extension password couldn't be updated") . $pDevice->errMsg; $continuar = false; } } //editamos la configuracion del fax if ($continuar) { if ($cFExten && $userLevel1 != "other") { //cuando se cambia el patron de marcado asociado al fax del usuario //es necesario incluir el parametro oldFaxExten entre los parametros para //la actualizacion correcta de los datos if (!$pFax->editFaxToUser(array("idUser" => $idUser, "oldFaxExten" => $oldFaxExten, "country_code" => $countryCode, "area_code" => $areaCode, "clid_name" => $cldiName, "clid_number" => $clidNumber))) { $error = "Couldn't updated user fax. " . $pFax->errMsg; $continuar = false; } } else { if (!$pFax->editFaxToUser(array("idUser" => $idUser, "country_code" => $countryCode, "area_code" => $areaCode, "clid_name" => $cldiName, "clid_number" => $clidNumber))) { $error = "Couldn't updated user fax. " . $pFax->errMsg; $continuar = false; } } } if ($continuar) { if (!$pEmail->setAccountPassword($username, $password1)) { $continuar = false; $error = _tr("Password couldn't be updated") . " " . $pEmail->errMsg; $editFax = true; } } //debemos actualizar el password en las variable de session if ($continuar && $_SESSION['elastix_user'] == $username) { $_SESSION['elastix_pass'] = $md5password; $_SESSION['elastix_pass2'] = $password1; } } else { $error = _tr("Password couldn't be updated") . " " . $pACL->errMsg; $continuar = false; } } else { //editamos la configuracion del fax if ($continuar) { if ($cFExten && $userLevel1 != "other") { //cuando se cambia el patron de marcado asociado al fax del usuario //es necesario incluir el parametro oldFaxExten entre los parametros para //la actualizacion correcta de los datos if (!$pFax->editFaxToUser(array("idUser" => $idUser, "oldFaxExten" => $oldFaxExten, "country_code" => $countryCode, "area_code" => $areaCode, "clid_name" => $cldiName, "clid_number" => $clidNumber))) { $error = "Couldn't updated user fax. " . $pFax->errMsg; $continuar = false; } } else { if (!$pFax->editFaxToUser(array("idUser" => $idUser, "country_code" => $countryCode, "area_code" => $areaCode, "clid_name" => $cldiName, "clid_number" => $clidNumber))) { $error = "Couldn't updated user fax. " . $pFax->errMsg; $continuar = false; } } } } if ($continuar) { $Exito = true; $this->_DB->commit(); //recargamos la configuracion en realtime de los dispositivos para que tomen efectos los cambios if ($cExten) { //se cambio la extension del usuario hay que eliminar de cache la anterior $pDevice->tecnologia->prunePeer($arrExtUser["device"], $arrExtUser["tech"]); } else { $pDevice->tecnologia->prunePeer($arrExtUser["device"], $arrExtUser["tech"]); $pDevice->tecnologia->loadPeer($arrExtUser["device"], $arrExtUser["tech"]); } if ($cFExten) { //se cambio la faxextension del usuario hay que eliminar de cache la anterior $pDevice->tecnologia->prunePeer($faxUser["device"], $faxUser["tech"]); } else { //se recarga la faxextension del usuario por los cambios que pudo haber $pDevice->tecnologia->prunePeer($faxUser["device"], $faxUser["tech"]); $pDevice->tecnologia->loadPeer($faxUser["device"], $faxUser["tech"]); } $pFax->restartService(); } else { $this->_DB->rollBack(); if ($editFax == true) { $pFax->editFaxFileConfig($faxUser['dev_id'], $faxUser['country_code'], $faxUser['area_code'], $faxUser['clid_name'], $faxUser['clid_number'], $arrUser[0]['md5_password'], 0, $arrOrgz['domain']); } if ($cExten == true) { $pDevice->deleteAstDBExt($extension, "sip"); $pDevice->restoreBackupAstDBEXT($arrBackup); } } } else { $error = _tr("Failed Updated Group") . " " . $pACL->errMsg; $this->_DB->rollBack(); } } else { $error = _tr("User couldn't be update") . " " . $pACL->errMsg; $this->_DB->rollBack(); } if ($cExten || $cFExten) { $reAsterisk = true; } $this->errMsg = $error . " " . $this->errMsg; return $Exito; }
/** * Procedimiento para obtener de la base settings el tema actual de elastix * * @return string nombre del tema actual si lo encontro, vacio si no */ function getThemeActual($uid) { $pACL = new paloACL($this->_DB); $theme = $pACL->getUserProp($uid, 'theme'); return $theme; }
function handleJSON_getUserProfile($smarty, $module_name) { include_once "libs/paloSantoForm.class.php"; include "configs/languages.conf.php"; //este archivo crea el arreglo language que contine los idiomas soportados //por elastix Header('Content-Type: application/json'); $arrCredentials = getUserCredentials($_SESSION['elastix_user']); $lang = get_language(); $error_msg = ''; $archivos = array(); $langElastix = array(); global $arrConf; $ERROR = ''; $pDB = new paloDB($arrConf['elastix_dsn']["elastix"]); $pACL = new paloACL($pDB); $jsonObject = new PaloSantoJSON(); $dataProfile = getDataProfile($pDB, $ERROR); if ($dataProfile === FALSE) { $smarty->assign("MSG_ERROR_FIELD", getErrorMsg()); $jsonObject->set_error(getErrorMsg()); return $jsonObject->createJSON(); } $extension = "{$dataProfile['exten']}/{$dataProfile['device']}"; leer_directorio("/usr/share/elastix/lang", $error_msg, $archivos); if (count($archivos) > 0) { foreach ($languages as $lang => $lang_name) { if (in_array("{$lang}.lang", $archivos)) { $langElastix[$lang] = $lang_name; } } } $selectedLanguage = $pACL->getUserProp($arrCredentials['idUser'], "language"); if ($selectedLanguage === FALSE) { $jsonObject->set_error(_tr("Invalid Language")); return $jsonObject->createJSON(); } $smarty->assign("TITLE_POPUP", _tr("My Profile ")); $smarty->assign("SAVE_POPUP", _tr("Save changes")); $smarty->assign("CHANGE_PASSWD_POPUP", _tr("Change Password")); $smarty->assign("userProfile_label", _tr("User")); $smarty->assign("userProfile", $dataProfile['username']); $smarty->assign("extenProfile_label", _tr("Extension")); $smarty->assign("extenProfile", $extension); $smarty->assign("faxProfile_label", _tr("Fax")); $smarty->assign("faxProfile", $dataProfile['fax_extension']); $smarty->assign("nameProfile", $dataProfile['name']); $smarty->assign('ID_PICTURE', $arrCredentials['idUser']); $smarty->assign('DeleteImage', _tr('Delete Image')); $dataProfile['languageProfile'] = $selectedLanguage; $arrFormFilter = createProfileForm($langElastix); $oFilterForm = new paloForm($smarty, $arrFormFilter); $htmlFilter = $oFilterForm->fetchForm("/var/www/html/web/themes/elastix3/_common/profile_uf.tpl", _tr('My Profile'), $dataProfile); $jsonObject = new PaloSantoJSON(); $jsonObject->set_message($htmlFilter); return $jsonObject->createJSON(); }
function viewFormUser($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $pACL = new paloACL($pDB); $pORGZ = new paloSantoOrganization($pDB); $arrFill = array(); $action = getParameter("action"); $arrOrgz = array(0 => "Select one Organization"); if ($credentials["userlevel"] == "superadmin") { $orgTmp = $pORGZ->getOrganization(array()); } else { $orgTmp = $pORGZ->getOrganization(array("id" => $credentials["id_organization"])); } if ($orgTmp === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pORGZ->errMsg)); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } elseif (count($orgTmp) == 0) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("You need yo have at least one organization created before you can create a user")); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if (($action == "new_user" || $action == "save_new") && count($orgTmp) <= 1) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("It's necesary you create a new organization so you can create new user")); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } foreach ($orgTmp as $value) { $arrOrgz[$value["id"]] = $value["name"]; $arrDomains[$value["id"]] = $value["domain"]; } $smarty->assign("ORGANIZATION", htmlentities($orgTmp[0]["name"], ENT_COMPAT, 'UTF-8')); } $idUser = getParameter("id"); $arrFill = $_POST; if ($action == "view" || getParameter("edit") || getParameter("save_edit")) { if (!isset($idUser)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid User")); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if ($credentials["userlevel"] == "superadmin") { $arrUsers = $pACL->getUsers($idUser); } else { $arrUsers = $pACL->getUsers($idUser, $credentials["id_organization"], null, null); } } if ($arrUsers === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { if (count($arrUsers) == 0) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("User doesn't exist")); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $picture = $pACL->getUserPicture($idUser); if ($picture !== false) { $smarty->assign("ShowImg", 1); } foreach ($arrUsers as $value) { $arrFill["username"] = $value[1]; $arrFill["name"] = $value[2]; $arrFill["password1"] = ""; $arrFill["password2"] = ""; $arrFill["organization"] = $value[4]; $arrFill["group"] = $value[7]; $extu = isset($value[5]) ? $value[5] : _tr("Not assigned yet"); $extf = isset($value[6]) ? $value[6] : _tr("Not assigned yet"); $arrFill["extension"] = $extu; $arrFill["fax_extension"] = $extf; } if ($arrFill["organization"] != 1) { $smarty->assign("ORGANIZATION", htmlentities($arrOrgz[$arrFill["organization"]], ENT_COMPAT, 'UTF-8')); } $smarty->assign("USERNAME", $arrFill["username"]); $nGroup = $pACL->getGroupNameByid($arrFill["group"]); if ($nGroup == "superadmin") { } $nGroup = _tr("NONE"); $smarty->assign("GROUP", $nGroup); $_POST["organization"] = $arrFill["organization"]; //ahora obtenemos las configuraciones de fax dle usuario $pFax = new paloFax($pACL->_DB); $listFaxs = $pFax->getFaxList(array("exten" => $extf, "organization_domain" => $arrDomains[$arrFill["organization"]])); if ($listFaxs != false) { $faxUser = $listFaxs[0]; $arrFill["country_code"] = $faxUser["country_code"]; $arrFill["area_code"] = $faxUser["area_code"]; $arrFill["clid_number"] = $faxUser["clid_number"]; $arrFill["clid_name"] = $faxUser["clid_name"]; } //ahora obtenemos la cuenta del email $arrFill["email_quota"] = $pACL->getUserProp($idUser, "email_quota"); if ($idUser == "1") { $arrFill["email_contact"] = $pACL->getUserProp($idUser, "email_contact"); } $smarty->assign("EMAILQOUTA", $arrFill["email_quota"]); $smarty->assign("EXTENSION", $extu); $smarty->assign("FAX_EXTENSION", $extf); if (getParameter("save_edit")) { $arrFill = $_POST; } } } } if ($credentials["userlevel"] != "superadmin") { $idOrgSel = $credentials["id_organization"]; } else { $idOrgSel = getParameter("organization"); } if (!isset($idOrgSel)) { $idOrgSel = 0; } if ($idOrgSel == 0) { $arrGrupos = array(); } else { $temp = $pACL->getGroupsPaging(null, null, $idOrgSel); if ($temp === false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr($pACL->errMsg)); return reportUser($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrCredentiasls); } foreach ($temp as $value) { $arrGrupos[$value[0]] = $value[1]; } } if (getParameter("create_user")) { $arrFill["country_code"] = $pORGZ->getOrganizationProp($idOrgSel, "country_code"); $arrFill["area_code"] = $pORGZ->getOrganizationProp($idOrgSel, "area_code"); $arrFill["email_quota"] = $pORGZ->getOrganizationProp($idOrgSel, "email_quota"); } $arrFormOrgz = createFieldForm($arrGrupos, $arrOrgz); $oForm = new paloForm($smarty, $arrFormOrgz); $smarty->assign("HEIGHT", "310px"); $smarty->assign("MARGIN_PIC", 'style="margin-top: 40px;"'); $smarty->assign("MARGIN_TAB", ""); if ($action == "view") { $smarty->assign("HEIGHT", "220px"); $smarty->assign("MARGIN_PIC", ""); $smarty->assign("MARGIN_TAB", "margin-top: 10px;"); $oForm->setViewMode(); $arrFill["password1"] = "*****"; $arrFill["password2"] = "*****"; $smarty->assign("HEIGHT", "220px"); } else { if (getParameter("edit") || getParameter("save_edit")) { $oForm->setEditMode(); } } global $arrPermission; if (in_array('create_user', $arrPermission)) { $smarty->assign("CREATE_USER", true); } if (in_array('edit_user', $arrPermission)) { $smarty->assign("EDIT_USER", true); } if (in_array('delete_user', $arrPermission)) { $smarty->assign("DEL_USER", true); } $smarty->assign("REQUIRED_FIELD", _tr("Required field")); $smarty->assign("CANCEL", _tr("Cancel")); $smarty->assign("APPLY_CHANGES", _tr("Apply changes")); $smarty->assign("SAVE", _tr("Save")); $smarty->assign("EDIT", _tr("Edit")); $smarty->assign("DELETE", _tr("Delete")); $smarty->assign("CONFIRM_CONTINUE", _tr("Are you sure you wish to continue?")); $smarty->assign("icon", "../web/_common/images/user_info.png"); $smarty->assign("FAX_SETTINGS", _tr("Fax Settings")); $smarty->assign("EMAIL_SETTINGS", _tr("Email Settings")); $smarty->assign("MODULE_NAME", $module_name); $smarty->assign("userLevel", $credentials["userlevel"]); $smarty->assign("id_user", $idUser); if (isset($arrUsers[0][1])) { $smarty->assign("isSuperAdmin", $pACL->isUserSuperAdmin($arrUsers[0][1])); } else { $smarty->assign("isSuperAdmin", FALSE); } $htmlForm = $oForm->fetchForm("{$local_templates_dir}/new.tpl", _tr("User"), $arrFill); $content = "<form method='POST' enctype='multipart/form-data' style='margin-bottom:0;' action='?menu={$module_name}'>" . $htmlForm . "</form>"; return $content; }
function get_language() { global $elxPath; require_once "{$elxPath}/configs/default.conf.php"; include "{$elxPath}/configs/languages.conf.php"; include_once "{$elxPath}/libs/paloSantoOrganization.class.php"; global $arrConf; $lang = ""; $pdB = new paloDB($arrConf['elastix_dsn']['elastix']); $pACL = new paloACL($pdB); $pOrgz = new paloSantoOrganization($pdB); $user = isset($_SESSION['elastix_user']) ? $_SESSION['elastix_user'] : ""; $uid = $pACL->getIdUser($user); if (empty($pDB->errMsg)) { if ($uid === false) { $lang = $pOrgz->getOrganizationProp(1, 'language'); } else { $lang = $pACL->getUserProp($uid, 'language'); } } //si no se encuentra tomar del archivo de configuracion if (empty($lang) || $lang === false) { $lang = isset($arrConf['language']) ? $arrConf['language'] : "en"; } //verificar que exista en el arreglo de idiomas, sino por defecto en if (!array_key_exists($lang, $languages)) { $lang = "en"; } return $lang; }