Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ include "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('voicemail_greeting_add') || permission_exists('voicemail_greeting_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support require_once "app_languages.php"; foreach($text as $key => $value) { $text[$key] = $value[$_SESSION['domain']['language']['code']]; } //set the action as an add or an update if (isset($_REQUEST["id"])) { $action = "update"; $voicemail_greeting_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get the form value and set to php variables $voicemail_id = check_str($_REQUEST["voicemail_id"]); if (count($_POST) > 0) { $greeting_name = check_str($_POST["greeting_name"]); $greeting_description = check_str($_POST["greeting_description"]); //clean the filename and recording name $greeting_name = str_replace(" ", "_", $greeting_name); $greeting_name = str_replace("'", "", $greeting_name); } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $voicemail_greeting_uuid = check_str($_POST["voicemail_greeting_uuid"]); } //check for all required data //if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid
\n"; } if (strlen($greeting_name) == 0) { $msg .= "".$text['confirm-name']."
\n"; } //if (strlen($greeting_description) == 0) { $msg .= "Please provide: Description
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persist_form_var.php"; echo "
\n"; echo "
\n"; echo $msg."
"; echo "
\n"; persistformvar($_POST); echo "
\n"; require_once "resources/footer.php"; return; } //add or update the database if ($_POST["persistformvar"] != "true") { if ($action == "add" && permission_exists('voicemail_greeting_add')) { $voicemail_greeting_uuid = uuid(); $sql = "insert into v_voicemail_greetings "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "voicemail_greeting_uuid, "; $sql .= "greeting_name, "; $sql .= "greeting_description "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'$voicemail_greeting_uuid', "; $sql .= "'$greeting_name', "; $sql .= "'$greeting_description' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); require_once "resources/header.php"; echo "\n"; echo "
\n"; echo "".$text['confirm-add']."\n"; echo "
\n"; require_once "resources/footer.php"; return; } //if ($action == "add") if ($action == "update" && permission_exists('voicemail_greeting_edit')) { //get the original filename $sql = "select * from v_voicemail_greetings "; $sql .= "where voicemail_greeting_uuid = '$voicemail_greeting_uuid' "; $sql .= "and voicemail_greeting_uuid = '$domain_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $greeting_name_orig = $row["greeting_name"]; break; //limit to 1 row } unset ($prep_statement); //if file name is not the same then rename the file if ($greeting_name != $greeting_name_orig) { //echo "orig: ".$voicemail_greetings_dir.'/'.$filename_orig."
\n"; //echo "new: ".$voicemail_greetings_dir.'/'.$greeting_name."
\n"; rename($voicemail_greetings_dir.'/'.$greeting_name_orig, $voicemail_greetings_dir.'/'.$greeting_name); } //update the database with the new data $sql = "update v_voicemail_greetings set "; $sql .= "greeting_name = '$greeting_name', "; $sql .= "greeting_description = '$greeting_description' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and voicemail_greeting_uuid = '$voicemail_greeting_uuid' "; $db->exec(check_sql($sql)); unset($sql); //redirect the user require_once "resources/header.php"; echo "\n"; echo "
\n"; echo "".$text['confirm-update']."\n"; echo "
\n"; require_once "resources/footer.php"; return; } //if ($action == "update") } //if ($_POST["persistformvar"] != "true") } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { $voicemail_greeting_uuid = check_str($_GET["id"]); $sql = "select * from v_voicemail_greetings "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and voicemail_greeting_uuid = '$voicemail_greeting_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $greeting_name = $row["greeting_name"]; $greeting_description = $row["greeting_description"]; break; //limit to 1 row } unset ($prep_statement); } //show the header require_once "resources/header.php"; //show the content echo "
"; echo "\n"; echo "\n"; echo " "; echo " "; echo "
\n"; echo "
"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; if ($action == "add") { echo "\n"; } if ($action == "update") { echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
".$text['label-add']."".$text['label-edit']."
\n"; echo " ".$text['label-name'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "".$text['description-name']."\n"; echo "
\n"; echo " ".$text['label-description'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo "".$text['description-info']."\n"; echo "
\n"; if ($action == "update") { echo " \n"; } echo " \n"; echo " \n"; echo "
"; echo ""; echo "
"; echo "
"; //include the footer require_once "resources/footer.php"; ?>