Portions created by the Initial Developer are Copyright (C) 2008-2012 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane */ require_once "root.php"; require_once "resources/require.php"; require_once "resources/check_auth.php"; if (permission_exists('voicemail_add') || permission_exists('voicemail_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']]; } //action add or update if (isset($_REQUEST["id"])) { $action = "update"; $voicemail_uuid = check_str($_REQUEST["id"]); } else { $action = "add"; } //get http variables and set them to php variables $referer_path = check_str($_REQUEST["referer_path"]); $referer_query = check_str($_REQUEST["referer_query"]); if (count($_POST)>0) { //set the variables from the HTTP values $voicemail_id = check_str($_POST["voicemail_id"]); $voicemail_password = check_str($_POST["voicemail_password"]); $greeting_id = check_str($_POST["greeting_id"]); $voicemail_mail_to = check_str($_POST["voicemail_mail_to"]); $voicemail_attach_file = check_str($_POST["voicemail_attach_file"]); $voicemail_local_after_email = check_str($_POST["voicemail_local_after_email"]); $voicemail_enabled = check_str($_POST["voicemail_enabled"]); $voicemail_description = check_str($_POST["voicemail_description"]); //remove the space $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); } if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $voicemail_uuid = check_str($_POST["voicemail_uuid"]); } //check for all required data //if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } //if (strlen($voicemail_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-voicemail_uuid']."
\n"; } //if (strlen($voicemail_id) == 0) { $msg .= $text['message-required']." ".$text['label-voicemail_id']."
\n"; } //if (strlen($voicemail_password) == 0) { $msg .= $text['message-required']." ".$text['label-voicemail_password']."
\n"; } //if (strlen($greeting_id) == 0) { $msg .= $text['message-required']." ".$text['label-greeting_id']."
\n"; } //if (strlen($voicemail_mail_to) == 0) { $msg .= $text['message-required']." ".$text['label-voicemail_mail_to']."
\n"; } //if (strlen($voicemail_attach_file) == 0) { $msg .= $text['message-required']." ".$text['label-voicemail_attach_file']."
\n"; } //if (strlen($voicemail_local_after_email) == 0) { $msg .= $text['message-required']." ".$text['label-voicemail_local_after_email']."
\n"; } //if (strlen($voicemail_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-voicemail_enabled']."
\n"; } //if (strlen($voicemail_description) == 0) { $msg .= $text['message-required']." ".$text['label-voicemail_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_add')) { $sql = "insert into v_voicemails "; $sql .= "("; $sql .= "domain_uuid, "; $sql .= "voicemail_uuid, "; $sql .= "voicemail_id, "; $sql .= "voicemail_password, "; if (strlen($greeting_id) > 0) { $sql .= "greeting_id, "; } $sql .= "voicemail_mail_to, "; $sql .= "voicemail_attach_file, "; $sql .= "voicemail_local_after_email, "; $sql .= "voicemail_enabled, "; $sql .= "voicemail_description "; $sql .= ")"; $sql .= "values "; $sql .= "("; $sql .= "'$domain_uuid', "; $sql .= "'".uuid()."', "; $sql .= "'$voicemail_id', "; $sql .= "'$voicemail_password', "; if (strlen($greeting_id) > 0) { $sql .= "'$greeting_id', "; } $sql .= "'$voicemail_mail_to', "; $sql .= "'$voicemail_attach_file', "; $sql .= "'$voicemail_local_after_email', "; $sql .= "'$voicemail_enabled', "; $sql .= "'$voicemail_description' "; $sql .= ")"; $db->exec(check_sql($sql)); unset($sql); require_once "resources/header.php"; echo "\n"; echo "
\n"; echo " ".$text['message-add']."\n"; echo "
\n"; require_once "resources/footer.php"; return; } //if ($action == "add") if ($action == "update" && permission_exists('voicemail_edit')) { $sql = "update v_voicemails set "; $sql .= "voicemail_id = '$voicemail_id', "; $sql .= "voicemail_password = '$voicemail_password', "; if (strlen($greeting_id) > 0) { $sql .= "greeting_id = '$greeting_id', "; } else { $sql .= "greeting_id = null, "; } $sql .= "voicemail_mail_to = '$voicemail_mail_to', "; $sql .= "voicemail_attach_file = '$voicemail_attach_file', "; $sql .= "voicemail_local_after_email = '$voicemail_local_after_email', "; $sql .= "voicemail_enabled = '$voicemail_enabled', "; $sql .= "voicemail_description = '$voicemail_description' "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and voicemail_uuid = '$voicemail_uuid'"; $db->exec(check_sql($sql)); unset($sql); require_once "resources/header.php"; if ($referer_path == "/app/voicemails/voicemail_messages.php") { echo "\n"; } else { echo "\n"; } echo "
\n"; echo " ".$text['message-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_uuid = check_str($_GET["id"]); $sql = "select * from v_voicemails "; $sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "and voicemail_uuid = '$voicemail_uuid' "; $prep_statement = $db->prepare(check_sql($sql)); $prep_statement->execute(); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); foreach ($result as &$row) { $voicemail_id = $row["voicemail_id"]; $voicemail_password = $row["voicemail_password"]; $greeting_id = $row["greeting_id"]; $voicemail_mail_to = $row["voicemail_mail_to"]; $voicemail_attach_file = $row["voicemail_attach_file"]; $voicemail_local_after_email = $row["voicemail_local_after_email"]; $voicemail_enabled = $row["voicemail_enabled"]; $voicemail_description = $row["voicemail_description"]; break; //limit to 1 row } unset ($prep_statement); } //remove the spaces $voicemail_mail_to = str_replace(" ", "", $voicemail_mail_to); //set defaults if (strlen($voicemail_attach_file) == 0) { $voicemail_attach_file = "true"; } if (strlen($voicemail_local_after_email) == 0) { $voicemail_local_after_email = "true"; } if (strlen($voicemail_enabled) == 0) { $voicemail_enabled = "true"; } //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"; 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 "\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 "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo " \n"; echo " \n"; echo " "; echo "
".$text['title-voicemail']."\n"; echo " \n"; echo "
\n"; echo " ".$text['label-voicemail_id'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-voicemail_id']."\n"; echo "
\n"; echo " ".$text['label-voicemail_password'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-voicemail_password']." \n"; echo "
\n"; echo " ".$text['label-greeting_id'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-greeting_id']."\n"; echo "
\n"; echo " ".$text['label-voicemail_mail_to'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-voicemail_mail_to']."\n"; echo "
\n"; echo " ".$text['label-voicemail_attach_file'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-voicemail_attach_file']."\n"; echo "
\n"; echo " ".$text['label-voicemail_local_after_email'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-voicemail_local_after_email']."\n"; echo "
\n"; echo " ".$text['label-voicemail_enabled'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-voicemail_enabled']."\n"; echo "
\n"; echo " ".$text['label-voicemail_description'].":\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-voicemail_description']."\n"; echo "
\n"; if ($action == "update") { echo " \n"; } $http_referer = parse_url($_SERVER["HTTP_REFERER"]); echo " \n"; echo " \n"; echo " \n"; echo "
"; echo ""; echo "
"; echo "
"; //include the footer require_once "resources/footer.php"; ?>