function saveEditDID($smarty, $module_name, $local_templates_dir, &$pDB, $arrConf, $credentials) { $pDID = new paloDidPBX($pDB); $error = ""; $exito = false; $idDID = getParameter("id_did"); if (!preg_match("/^[0-9]+\$/", $idDID)) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Invalid DID")); return reportDID($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } $arrChannel = array("none" => _tr("--Select one--")); $tmpChannel = $pDID->getAnalogChannelsFree(); if ($tmpChannel != false) { $arrChannel = array_merge($arrChannel, $tmpChannel); } $arrForm = createFieldForm($arrChannel); $oForm = new paloForm($smarty, $arrForm); if (!$oForm->validateForm($_POST)) { // Validation basic, not empty and VALIDATION_TYPE $smarty->assign("mb_title", _tr("Validation Error")); $arrErrores = $oForm->arrErroresValidacion; $strErrorMsg = "<b>" . _tr("The following fields contain errors") . ":</b><br/>"; if (is_array($arrErrores) && count($arrErrores) > 0) { foreach ($arrErrores as $k => $v) { $strErrorMsg .= "{$k} [{$v['mensaje']}], "; } } $smarty->assign("mb_message", $strErrorMsg); return viewFormDID($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $arrProp = array(); $did = $pDID->getDID_id($idDID); if ($did == false) { $error .= $pDID->errMsg; } else { $arrProp["country"] = getParameter("country"); if ($arrProp["country"] == "0" || !isset($arrProp["country"])) { $error = _tr("You must select a country"); } else { $arrProp["id_did"] = $idDID; $arrProp["city"] = getParameter("city"); $arrProp["country_code"] = getParameter("country_code"); $arrProp["area_code"] = getParameter("area_code"); $arrProp["select_chans"] = getParameter("select_chans"); $pDB->beginTransaction(); $exito = $pDID->saveEditDID($arrProp); if ($exito) { $pDB->commit(); } else { $pDB->rollBack(); } $error .= $pDID->errMsg; } } } if ($exito) { //procedemos a reescribir los archivos extensions_did.conf chan_dhadi_additonals.conf $smarty->assign("mb_title", _tr("MESSAGE")); if (writeDidFile($error, $did["type"]) == true) { $smarty->assign("mb_message", _tr("DID was updated successfully")); } else { $smarty->assign("mb_message", _tr("DID couldn't be updated. ") . $error); } $content = reportDID($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } else { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", $error); $content = viewFormDID($smarty, $module_name, $local_templates_dir, $pDB, $arrConf, $credentials); } return $content; }