function saveNewMyExtension($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrLang, $extension, $isAdministrator) { $pMyExtension = new paloSantoMyExtension($pDB); $arrFormMyExtension = createFieldForm($arrLang); $oForm = new paloForm($smarty, $arrFormMyExtension); $message = ""; if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $smarty->assign("mb_title", $arrLang["Validation Error"]); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>{$arrLang['The following fields contain errors']}:</b><br/>"; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } } $smarty->assign("mb_message", $strErrorMsg); } else { $s = $_SESSION["my_extension"]["extension"]; if (isset($_SESSION["my_extension"]["extension"])) { $extension = $_SESSION["my_extension"]["extension"]; $enableDND = getParameter("do_not_disturb"); //return on or off $enableCW = getParameter("call_waiting"); //return on or off $enableCF = getParameter("call_forward"); //return on or off $enableCFU = getParameter("call_forward_U"); //return on or off $enableCFB = getParameter("call_forward_B"); //return on or off $statusCW = $pMyExtension->setConfig_CallWaiting($enableCW, $extension); $statusDND = $pMyExtension->setConfig_DoNotDisturb($enableDND, $extension); $phoneNumberCF = trim(getParameter("phone_number_CF")); //is a number !! $phoneNumberCFU = trim(getParameter("phone_number_CFU")); $phoneNumberCFB = trim(getParameter("phone_number_CFB")); /*recordings*/ $recordIncomingOption = getParameter("record_incoming"); $recordOutgoingOption = getParameter("record_outgoing"); /************/ if ($enableCF == "on") { if (preg_match("/^[0-9]+\$/", $phoneNumberCF)) { $statusCF = $pMyExtension->setConfig_CallForward($enableCF, $phoneNumberCF, $extension); } else { $_SESSION["my_extension"]["enableCF"] = "on"; $_SESSION["my_extension"]["phoneNumberCF"] = $phoneNumberCF; $message .= $arrLang["Please check your phone number for Call Forward"] . "<br />"; $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $message); } } else { $statusCF = $pMyExtension->setConfig_CallForward($enableCF, "", $extension); } if ($enableCFU == "on") { if (preg_match("/^[0-9]+\$/", $phoneNumberCFU)) { $statusCFU = $pMyExtension->setConfig_CallForwardOnUnavail($enableCFU, $phoneNumberCFU, $extension); } else { $_SESSION["my_extension"]["enableCFU"] = "on"; $_SESSION["my_extension"]["phoneNumberCFU"] = $phoneNumberCFU; $message .= $arrLang["Please check your phone number for Call Forward On Unavailable"] . "<br />"; $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $message); } } else { $statusCFU = $pMyExtension->setConfig_CallForwardOnUnavail($enableCFU, "", $extension); } if ($enableCFB == "on") { if (preg_match("/^[0-9]+\$/", $phoneNumberCFB)) { $statusCFB = $pMyExtension->setConfig_CallForwardOnBusy($enableCFB, $phoneNumberCFB, $extension); } else { $_SESSION["my_extension"]["enableCFB"] = "on"; $_SESSION["my_extension"]["phoneNumberCFB"] = $phoneNumberCFB; $message .= $arrLang["Please check your phone number for Call Forward On Busy"] . "<br />"; $smarty->assign("mb_title", $arrLang["Validation Error"]); $smarty->assign("mb_message", $message); } } else { $statusCFB = $pMyExtension->setConfig_CallForwardOnBusy($enableCFB, "", $extension); } if (!$statusCW) { $message .= $arrLang["Error processing CallWaiting"] . "<br />"; } if (!$statusDND) { $message .= $arrLang["Error processing Do Not Disturb"] . "<br />"; } if (!$statusCF) { $message .= $arrLang["Error processing Call Forward"] . "<br />"; } if (!$statusCFU) { $message .= $arrLang["Error processing Call Forward on Unavailable"] . "<br />"; } if (!$statusCFB) { $message .= $arrLang["Error processing Call Forward on Busy"] . "<br />"; } /*recordings*/ $statusRecording = $pMyExtension->setRecordSettings($extension, $recordIncomingOption, $recordOutgoingOption); /************/ if ($statusCW && $statusDND && $statusCF && $statusCFU && $statusCFB && $statusRecording) { $message = $arrLang["Your configuration has been saved correctly"] . "<br />"; } $smarty->assign("mb_message", $message); } else { if ($isAdministrator) { $message = "<b>" . $arrLang["no_extension"] . "</b>"; } else { $message = "<b>" . $arrLang["contact_admin"] . "</b>"; } $smarty->assign("mb_message", $message); } } $content = viewFormMyExtension($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $arrLang, $extension); return $content; }
/** * Functional point that sets the option do not Disturb to the extension of the authenticated user * * @param boolean $doNotDisturb true the do not Disturb option will be set to on, false it will be set to off * @return boolean True if the do not Disturb option was set, or false if an error exists */ public function setDoNotDisturb($doNotDisturb) { global $root; if (!isset($doNotDisturb)) { $this->errMsg["fc"] = 'ERROR'; $this->errMsg["fm"] = 'Parameter Error'; $this->errMsg["fd"] = 'The parameter doNotDisturb has not been sent'; $this->errMsg["cn"] = get_class($this); return false; } $extension = $this->_leerExtension(); $pDB = new paloDB(generarDSNSistema('asteriskuser', 'asterisk', $root . "/")); $pMyExtension = new paloSantoMyExtension($pDB); if (is_null($extension)) { return false; } if ($doNotDisturb) { $enableDND = "on"; } else { $enableDND = "off"; } $statusDND = $pMyExtension->setConfig_DoNotDisturb($enableDND, $extension); if (!$statusDND) { $this->errMsg["fc"] = 'ERROR'; $this->errMsg["fm"] = 'Error Processing Do Not Disturb'; $this->errMsg["fd"] = 'The Do Not Disturb state could not be set'; $this->errMsg["cn"] = get_class($this); return false; } return true; }