2012-12-29 10:17:12 +01:00
|
|
|
<?php
|
|
|
|
|
/*
|
|
|
|
|
FusionPBX
|
|
|
|
|
Version: MPL 1.1
|
|
|
|
|
|
|
|
|
|
The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
|
1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
|
the License. You may obtain a copy of the License at
|
|
|
|
|
http://www.mozilla.org/MPL/
|
|
|
|
|
|
|
|
|
|
Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
|
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
|
for the specific language governing rights and limitations under the
|
|
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
The Original Code is FusionPBX
|
|
|
|
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
2019-09-19 15:45:34 +02:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2019
|
2012-12-29 10:17:12 +01:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
|
|
|
|
require_once "root.php";
|
2013-07-06 08:03:27 +02:00
|
|
|
require_once "resources/require.php";
|
2013-07-06 07:50:55 +02:00
|
|
|
require_once "resources/check_auth.php";
|
2012-12-29 10:17:12 +01:00
|
|
|
if (permission_exists('voicemail_message_add') || permission_exists('voicemail_message_edit')) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//add multi-lingual support
|
2015-01-18 11:04:43 +01:00
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
2012-12-29 10:17:12 +01:00
|
|
|
|
|
|
|
|
//action add or update
|
2019-08-17 15:02:58 +02:00
|
|
|
if (is_uuid($_REQUEST["id"])) {
|
2012-12-29 10:17:12 +01:00
|
|
|
$action = "update";
|
2019-08-17 15:02:58 +02:00
|
|
|
$voicemail_message_uuid = $_REQUEST["id"];
|
2012-12-29 10:17:12 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$action = "add";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//set the parent uuid
|
2019-08-17 15:02:58 +02:00
|
|
|
if (is_uuid($_GET["voicemail_uuid"])) {
|
|
|
|
|
$voicemail_uuid = $_GET["voicemail_uuid"];
|
2012-12-29 10:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//get http post variables and set them to php variables
|
|
|
|
|
if (count($_POST)>0) {
|
2019-08-17 15:02:58 +02:00
|
|
|
$voicemail_uuid = $_POST["voicemail_uuid"];
|
|
|
|
|
$created_epoch = $_POST["created_epoch"];
|
|
|
|
|
$read_epoch = $_POST["read_epoch"];
|
|
|
|
|
$caller_id_name = $_POST["caller_id_name"];
|
|
|
|
|
$caller_id_number = $_POST["caller_id_number"];
|
|
|
|
|
$message_length = $_POST["message_length"];
|
|
|
|
|
$message_status = $_POST["message_status"];
|
|
|
|
|
$message_priority = $_POST["message_priority"];
|
2012-12-29 10:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
|
|
|
|
|
|
|
$msg = '';
|
|
|
|
|
if ($action == "update") {
|
2019-08-17 15:02:58 +02:00
|
|
|
$voicemail_message_uuid = $_POST["voicemail_message_uuid"];
|
2012-12-29 10:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
2019-09-19 15:45:34 +02:00
|
|
|
//validate the token
|
|
|
|
|
$token = new token;
|
|
|
|
|
if (!$token->validate($_SERVER['PHP_SELF'])) {
|
|
|
|
|
message::add($text['message-invalid_token'],'negative');
|
|
|
|
|
header('Location: voicemails.php');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2012-12-29 10:17:12 +01:00
|
|
|
//check for all required data
|
|
|
|
|
//if (strlen($voicemail_uuid) == 0) { $msg .= "Please provide: Voicemail UUID<br>\n"; }
|
|
|
|
|
//if (strlen($created_epoch) == 0) { $msg .= "Please provide: Created Epoch<br>\n"; }
|
|
|
|
|
//if (strlen($read_epoch) == 0) { $msg .= "Please provide: Read Epoch<br>\n"; }
|
|
|
|
|
//if (strlen($caller_id_name) == 0) { $msg .= "Please provide: Caller ID Name<br>\n"; }
|
|
|
|
|
//if (strlen($caller_id_number) == 0) { $msg .= "Please provide: Caller ID Number<br>\n"; }
|
|
|
|
|
//if (strlen($message_length) == 0) { $msg .= "Please provide: Length<br>\n"; }
|
|
|
|
|
//if (strlen($message_status) == 0) { $msg .= "Please provide: Status<br>\n"; }
|
|
|
|
|
//if (strlen($message_priority) == 0) { $msg .= "Please provide: Priority<br>\n"; }
|
|
|
|
|
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/header.php";
|
2013-07-06 08:21:12 +02:00
|
|
|
require_once "resources/persist_form_var.php";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "<div align='center'>\n";
|
|
|
|
|
echo "<table><tr><td>\n";
|
|
|
|
|
echo $msg."<br />";
|
|
|
|
|
echo "</td></tr></table>\n";
|
|
|
|
|
persistformvar($_POST);
|
|
|
|
|
echo "</div>\n";
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2012-12-29 10:17:12 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//add or update the database
|
|
|
|
|
if ($_POST["persistformvar"] != "true") {
|
|
|
|
|
if ($action == "add" && permission_exists('voicemail_message_add')) {
|
2019-08-17 15:02:58 +02:00
|
|
|
//begin insert array
|
|
|
|
|
$array['voicemail_messages'][0]['voicemail_message_uuid'] = uuid();
|
|
|
|
|
//message
|
|
|
|
|
message::add($text['message-add']);
|
|
|
|
|
}
|
2012-12-29 10:17:12 +01:00
|
|
|
|
|
|
|
|
if ($action == "update" && permission_exists('voicemail_message_edit')) {
|
2019-08-17 15:02:58 +02:00
|
|
|
//begin update array
|
|
|
|
|
$array['voicemail_messages'][0]['voicemail_message_uuid'] = $voicemail_message_uuid;
|
|
|
|
|
//set message
|
|
|
|
|
message::add($text['message-update']);
|
|
|
|
|
}
|
2012-12-29 10:17:12 +01:00
|
|
|
|
2019-08-17 15:02:58 +02:00
|
|
|
if (is_array($array) && @sizeof($array) != 0) {
|
|
|
|
|
//add common array fields
|
|
|
|
|
$array['voicemail_messages'][0]['domain_uuid'] = $domain_uuid;
|
|
|
|
|
$array['voicemail_messages'][0]['voicemail_uuid'] = $voicemail_uuid;
|
|
|
|
|
$array['voicemail_messages'][0]['created_epoch'] = $created_epoch;
|
|
|
|
|
$array['voicemail_messages'][0]['read_epoch'] = $read_epoch;
|
|
|
|
|
$array['voicemail_messages'][0]['caller_id_name'] = $caller_id_name;
|
|
|
|
|
$array['voicemail_messages'][0]['caller_id_number'] = $caller_id_number;
|
|
|
|
|
$array['voicemail_messages'][0]['message_length'] = $message_length;
|
|
|
|
|
$array['voicemail_messages'][0]['message_status'] = $message_status;
|
|
|
|
|
$array['voicemail_messages'][0]['message_priority'] = $message_priority;
|
|
|
|
|
//execute insert/update
|
|
|
|
|
$database = new database;
|
|
|
|
|
$database->app_name = 'voicemails';
|
|
|
|
|
$database->app_uuid = 'b523c2d2-64cd-46f1-9520-ca4b4098e044';
|
|
|
|
|
$database->save($array);
|
|
|
|
|
unset($array);
|
|
|
|
|
//redirect
|
|
|
|
|
header("Location: voicemail_edit.php?id=".$voicemail_uuid);
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2012-12-29 10:17:12 +01:00
|
|
|
|
|
|
|
|
//pre-populate the form
|
2019-08-17 15:02:58 +02:00
|
|
|
if (count($_GET)>0 && is_uuid($_GET["id"]) && $_POST["persistformvar"] != "true") {
|
|
|
|
|
$voicemail_message_uuid = $_GET["id"];
|
2012-12-29 10:17:12 +01:00
|
|
|
$sql = "select * from v_voicemail_messages ";
|
2019-08-17 15:02:58 +02:00
|
|
|
$sql .= "where domain_uuid = :domain_uuid ";
|
|
|
|
|
$sql .= "and voicemail_message_uuid = :voicemail_message_uuid ";
|
|
|
|
|
$parameters['domain_uuid'] = $domain_uuid;
|
|
|
|
|
$parameters['voicemail_message_uuid'] = $voicemail_message_uuid;
|
|
|
|
|
$database = new database;
|
|
|
|
|
$row = $database->select($sql, $parameters, 'row');
|
|
|
|
|
if (is_array($row) && @sizeof($row) != 0) {
|
2012-12-29 10:17:12 +01:00
|
|
|
$voicemail_uuid = $row["voicemail_uuid"];
|
|
|
|
|
$created_epoch = $row["created_epoch"];
|
|
|
|
|
$read_epoch = $row["read_epoch"];
|
|
|
|
|
$caller_id_name = $row["caller_id_name"];
|
|
|
|
|
$caller_id_number = $row["caller_id_number"];
|
|
|
|
|
$message_length = $row["message_length"];
|
|
|
|
|
$message_status = $row["message_status"];
|
|
|
|
|
$message_priority = $row["message_priority"];
|
|
|
|
|
}
|
2019-08-17 15:02:58 +02:00
|
|
|
unset($sql, $parameters, $row);
|
2012-12-29 10:17:12 +01:00
|
|
|
}
|
|
|
|
|
|
2019-09-19 15:45:34 +02:00
|
|
|
//create token
|
|
|
|
|
$object = new token;
|
|
|
|
|
$token = $object->create($_SERVER['PHP_SELF']);
|
|
|
|
|
|
2012-12-29 10:17:12 +01:00
|
|
|
//show the header
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/header.php";
|
2012-12-29 10:17:12 +01:00
|
|
|
|
|
|
|
|
//show the content
|
|
|
|
|
echo "<form method='post' name='frm' action=''>\n";
|
2015-02-15 08:59:02 +01:00
|
|
|
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "<tr>\n";
|
2013-01-03 20:54:29 +01:00
|
|
|
echo "<td align='left' width='30%' nowrap='nowrap'><b>Voicemail Messages</b></td>\n";
|
2018-08-28 04:33:50 +02:00
|
|
|
echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='voicemail_edit.php?id=".escape($voicemail_uuid)."'\" value='Back'></td>\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " Created Epoch\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-08-28 04:33:50 +02:00
|
|
|
echo " <input class='formfld' type='text' name='created_epoch' maxlength='255' value='".escape($created_epoch)."'>\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " Read Epoch\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-08-28 04:33:50 +02:00
|
|
|
echo " <input class='formfld' type='text' name='read_epoch' maxlength='255' value='".escape($read_epoch)."'>\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " Caller ID Name\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-08-28 04:33:50 +02:00
|
|
|
echo " <input class='formfld' type='text' name='caller_id_name' maxlength='255' value=\"".escape($caller_id_name)."\">\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " Caller ID Number\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-08-28 04:33:50 +02:00
|
|
|
echo " <input class='formfld' type='text' name='caller_id_number' maxlength='255' value=\"".escape($caller_id_number)."\">\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " Length\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-08-28 04:33:50 +02:00
|
|
|
echo " <input class='formfld' type='text' name='message_length' maxlength='255' value='".escape($message_length)."'>\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " Status\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-08-28 04:33:50 +02:00
|
|
|
echo " <input class='formfld' type='text' name='message_status' maxlength='255' value=\"".escape($message_status)."\">\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
2015-02-15 07:50:00 +01:00
|
|
|
echo " Priority\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "<td class='vtable' align='left'>\n";
|
2018-08-28 04:33:50 +02:00
|
|
|
echo " <input class='formfld' type='text' name='message_priority' maxlength='255' value=\"".escape($message_priority)."\">\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "<br />\n";
|
|
|
|
|
echo "\n";
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <td colspan='2' align='right'>\n";
|
2018-08-28 04:33:50 +02:00
|
|
|
echo " <input type='hidden' name='voicemail_uuid' value='".escape($voicemail_uuid)."'>\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
if ($action == "update") {
|
2018-08-28 04:33:50 +02:00
|
|
|
echo " <input type='hidden' name='voicemail_message_uuid' value='".escape($voicemail_message_uuid)."'>\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
}
|
2019-09-19 15:45:34 +02:00
|
|
|
echo " <input type='hidden' name='".$token['name']."' value='".$token['hash']."'>\n";
|
2015-02-15 10:20:19 +01:00
|
|
|
echo " <br>";
|
2015-02-15 08:59:02 +01:00
|
|
|
echo " <input type='submit' name='submit' class='btn' value='Save'>\n";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>";
|
|
|
|
|
echo "</table>";
|
2015-02-15 08:59:02 +01:00
|
|
|
echo "<br><br>";
|
2012-12-29 10:17:12 +01:00
|
|
|
echo "</form>";
|
|
|
|
|
|
|
|
|
|
//include the footer
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2019-08-17 15:02:58 +02:00
|
|
|
|
|
|
|
|
?>
|