function savePatton($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf) { $paloEndPoint = new paloSantoEndPoint($dsnAsterisk, $dsnSqlite); $paloFileEndPoint = new PaloSantoFileEndPoint($arrConf["tftpboot_path"], $_SESSION["endpoint_mask"]); $arrSession = getSession(); for ($i = 0; $i < $arrSession["endpoint_configurator"]["analog_trunk_lines"]; $i++) { if (getParameter("line{$i}") == "" || getParameter("ID{$i}") == "" || getParameter("authentication_ID{$i}") == "") { $smarty->assign("mb_title", _tr("Validation Error")); $smarty->assign("mb_message", _tr("Fields Line, ID and authentication ID can not be empty")); return getLinesForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, true); } else { $arrSession["endpoint_configurator"]["line{$i}"] = getParameter("line{$i}"); $arrSession["endpoint_configurator"]["ID{$i}"] = getParameter("ID{$i}"); $arrSession["endpoint_configurator"]["authentication_ID{$i}"] = getParameter("authentication_ID{$i}"); } } if (!$paloEndPoint->savePattonData($arrSession["endpoint_configurator"])) { $smarty->assign("mb_title", _tr("ERROR")); if ($paloEndPoint->errMsg != "" && isset($paloEndPoint->errMsg)) { $smarty->assign("mb_message", $paloEndPoint->errMsg); } else { $smarty->assign("mb_message", _tr("In the query to database endpoint.db")); } return endpointConfiguratedShow($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } $tone_set = $paloEndPoint->getToneSet($arrSession["endpoint_configurator"]["country"]); if ($tone_set == false) { $smarty->assign("mb_title", _tr("ERROR")); $smarty->assign("mb_message", _tr("Could not get the tone set by country")); return endpointConfiguratedShow($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } $result = $paloFileEndPoint->buildPattonConfFile($arrSession["endpoint_configurator"], $tone_set); if ($result === false || is_null($result)) { $smarty->assign("mb_title", _tr("ERROR")); if ($paloFileEndPoint->errMsg != "" && isset($paloFileEndPoint->errMsg)) { $smarty->assign("mb_message", $paloFileEndPoint->errMsg); } else { $smarty->assign("mb_message", _tr("Could not create the patton configuration file")); } if (is_null($result)) { return getPattonData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } else { return endpointConfiguratedShow($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); } } $smarty->assign("mb_title", _tr("MESSAGE")); $smarty->assign("mb_message", _tr("The Patton was successfully configurated. The changes will apply after the Patton is finished rebooting")); unset($arrSession["endpoint_configurator"]); unset($arrSession["elastix_endpoints"]); putSession($arrSession); return endpointConfiguratedShow($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); }