Merge pull request #1013 from moteus/issues_1008

Disable of sip profile does not work
This commit is contained in:
FusionPBX 2015-07-18 13:08:10 -07:00
commit b689e726a4
2 changed files with 25 additions and 7 deletions

View File

@ -161,6 +161,12 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//redirect the browser
$_SESSION["message"] = $text['message-update'];
header("Location: sip_profiles.php");
//save the sip profile xml
save_sip_profile_xml();
//apply settings reminder
$_SESSION["reload_xml"] = true;
return;
} //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)

View File

@ -2546,12 +2546,15 @@ if (!function_exists('save_sip_profile_xml')) {
return;
}
// make profile dir if needed
$profile_dir = $_SESSION['switch']['conf']['dir']."/sip_profiles";
if (!is_readable($profile_dir)) { mkdir($profile_dir,0775,true); }
//get the global variables
global $db, $domain_uuid;
//get the sip profiles from the database
$sql = "select * from v_sip_profiles ";
$sql .= "where sip_profile_enabled = 'true' ";
$sql = "select * from v_sip_profiles";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll();
@ -2559,8 +2562,17 @@ if (!function_exists('save_sip_profile_xml')) {
unset ($prep_statement, $sql);
if ($result_count > 0) {
foreach($result as $row) {
$sip_profile_uuid = $row['sip_profile_uuid'];
$sip_profile_name = $row['sip_profile_name'];
$sip_profile_uuid = $row['sip_profile_uuid'];
$sip_profile_name = $row['sip_profile_name'];
$sip_profile_enabled = $row['sip_profile_enabled'];
if ($sip_profile_enabled == 'false') {
$fout = fopen($profile_dir.'/'.$sip_profile_name.".xml","w");
if ($fout) {
fclose($fout);
}
continue;
}
//get the xml sip profile template
if ($sip_profile_name == "internal" || $sip_profile_name == "external" || $sip_profile_name == "internal-ipv6") {
@ -2588,14 +2600,14 @@ if (!function_exists('save_sip_profile_xml')) {
$file_contents = str_replace("{v_sip_profile_settings}", $sip_profile_settings, $file_contents);
//write the XML config file
if (is_readable($_SESSION['switch']['conf']['dir']."/sip_profiles/")) {
$fout = fopen($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name.".xml","w");
if (is_readable($profile_dir.'/')) {
$fout = fopen($profile_dir.'/'.$sip_profile_name.".xml","w");
fwrite($fout, $file_contents);
fclose($fout);
}
//if the directory does not exist then create it
if (!is_readable($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name)) { mkdir($_SESSION['switch']['conf']['dir']."/sip_profiles/".$sip_profile_name,0775,true); }
if (!is_readable($profile_dir.'/'.$sip_profile_name)) { mkdir($profile_dir.'/'.$sip_profile_name,0775,true); }
} //end foreach
unset($sql, $result, $row_count);