function save_config($smarty, $module_name, $local_templates_dir, $arrLang, $ext, $pDB_ast) { $paloVoice = new paloSantoVoiceMail($pDB_ast); $arrDat = $paloVoice->loadConfiguration($ext); $arrForm = createFieldFormConfig($arrLang); $oForm = new paloForm($smarty, $arrForm); if (!$oForm->validateForm($_POST) || $_POST['password'] != $_POST['password_confir']) { $smarty->assign("mb_title", "Validation Error"); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>'The following fields contain errors':</b><br/>"; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k}, "; } } if ($_POST['password'] != $_POST['password_confir']) { $strErrorMsg .= "Confirm Password"; } $smarty->assign("mb_message", $strErrorMsg); return false; } $option = $_POST['status'] == "Enable" ? 1 : 0; $Ext = $ext; $VoiceMail_PW = $_POST['password']; $password_2 = $_POST['password_confir']; $Name = $arrDat[2]; $VM_Email_Address = $_POST['email']; $VM_Pager_Email_Addr = $_POST['pager_email']; $VM_Options = $arrDat[5]; $VM_EmailAttachment = $_POST['email_attach'] == 'Yes' ? 'yes' : 'no'; $VM_Play_CID = $_POST['play_cid'] == 'Yes' ? 'yes' : 'no'; $VM_Play_Envelope = $_POST['play_envelope'] == 'Yes' ? 'yes' : 'no'; $VM_Delete_Vmail = $_POST['delete_vmail'] == 'Yes' ? 'yes' : 'no'; $bandera = $paloVoice->writeFileVoiceMail($Ext, $Name, $VoiceMail_PW, $VM_Email_Address, $VM_Pager_Email_Addr, $VM_Options, $VM_EmailAttachment, $VM_Play_CID, $VM_Play_Envelope, $VM_Delete_Vmail, $option); if ($bandera == true) { return true; } else { $smarty->assign("mb_title", "Error"); $smarty->assign("mb_message", $paloVoice->errMsg); return false; } }
/** * Functional point that sets the configuration for the voicemail of the extension of the authenticated user * * @param boolean $enable true if the configuration will be enabled or false if it will be disabled * @param string $email email for the voicemail * @param string $pagerEmail (optional) pager email for the voicemail * @param string $password password for the voicemail * @param string $confirmPassword must be equal to $password * @param boolean $emailAttachment true if the email Attachment is on or false if it is off * @param boolean $playCID true if the play CID is on or false if it is off * @param boolean $playEnvelope true if the play Envelope is on or false if it is off * @param boolean $deleteVmail true if the delete Vmail is on or false if it is off * @return boolean True if the voicemail was configurated, or false if an error exists */ public function setConfiguration($enable, $email, $pagerEmail, $password, $confirmPassword, $emailAttachment, $playCID, $playEnvelope, $deleteVmail) { $extension = $this->_leerExtension(); if (is_null($extension)) { return false; } if (!isset($enable) || !isset($email) || !isset($password) || !isset($confirmPassword) || !isset($emailAttachment) || !isset($playCID) || !isset($playEnvelope) || !isset($deleteVmail)) { $this->errMsg["fc"] = 'PARAMERROR'; $this->errMsg["fm"] = 'Required Parameter'; $this->errMsg["fd"] = "The Parameters 'enable', 'email', 'password', 'confirmPassword', 'emailAttachment', 'playCID', 'playEnvelope' and 'deleteVmail' are required"; $this->errMsg["cn"] = get_class($this); return false; } if (!preg_match("/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,4})+\$/", $email)) { $this->errMsg["fc"] = 'PARAMERROR'; $this->errMsg["fm"] = 'Validation Error'; $this->errMsg["fd"] = "{$email} is not a valid email"; $this->errMsg["cn"] = get_class($this); return false; } if (isset($pagerEmail)) { if (!preg_match("/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,4})+\$/", $pagerEmail)) { $this->errMsg["fc"] = 'PARAMERROR'; $this->errMsg["fm"] = 'Validation Error'; $this->errMsg["fd"] = "{$pagerEmail} is not a valid email"; $this->errMsg["cn"] = get_class($this); return false; } } if ($password != $confirmPassword) { $this->errMsg["fc"] = 'PARAMERROR'; $this->errMsg["fm"] = 'Validation Error'; $this->errMsg["fd"] = "'password' and 'confirmPassword' do not match"; $this->errMsg["cn"] = get_class($this); return false; } $paloVoice = new paloSantoVoiceMail($this->_getDB($this->_astDSN)); $arrDat = $paloVoice->loadConfiguration($ext); if ($emailAttachment) { $VM_EmailAttachment = 'yes'; } else { $VM_EmailAttachment = 'no'; } if ($playCID) { $VM_Play_CID = 'yes'; } else { $VM_Play_CID = 'no'; } if ($playEnvelope) { $VM_Play_Envelope = 'yes'; } else { $VM_Play_Envelope = 'no'; } if ($deleteVmail) { $VM_Delete_Vmail = 'yes'; } else { $VM_Delete_Vmail = 'no'; } if ($enable) { $option = 1; } else { $option = 0; } $bandera = $paloVoice->writeFileVoiceMail($extension, $arrDat[2], $password, $email, $pagerEmail, $arrDat[5], $VM_EmailAttachment, $VM_Play_CID, $VM_Play_Envelope, $VM_Delete_Vmail, $option); if (!$bandera) { $this->errMsg["fc"] = 'ERROR'; $this->errMsg["fm"] = 'Error writing the file'; $this->errMsg["fd"] = "An error occurs while writing the file: {$paloVoice->errMsg}"; $this->errMsg["cn"] = get_class($paloVoice); return false; } return true; }