1<?php 2/* 3 FusionPBX 4 Version: MPL 1.1 5 6 The contents of this file are subject to the Mozilla Public License Version 7 1.1 (the "License"); you may not use this file except in compliance with 8 the License. You may obtain a copy of the License at 9 http://www.mozilla.org/MPL/ 10 11 Software distributed under the License is distributed on an "AS IS" basis, 12 WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 13 for the specific language governing rights and limitations under the 14 License. 15 16 The Original Code is FusionPBX 17 18 The Initial Developer of the Original Code is 19 Mark J Crane <markjcrane@fusionpbx.com> 20 Portions created by the Initial Developer are Copyright (C) 2008-2012 21 the Initial Developer. All Rights Reserved. 22 23 Contributor(s): 24 Mark J Crane <markjcrane@fusionpbx.com> 25*/ 26require_once "root.php"; 27require_once "resources/require.php"; 28require_once "resources/check_auth.php"; 29if (permission_exists('voicemail_message_add') || permission_exists('voicemail_message_edit')) { 30 //access granted 31} 32else { 33 echo "access denied"; 34 exit; 35} 36 37//add multi-lingual support 38 $language = new text; 39 $text = $language->get(); 40 41//action add or update 42 if (isset($_REQUEST["id"])) { 43 $action = "update"; 44 $voicemail_message_uuid = check_str($_REQUEST["id"]); 45 } 46 else { 47 $action = "add"; 48 } 49 50//set the parent uuid 51 if (strlen($_GET["voicemail_uuid"]) > 0) { 52 $voicemail_uuid = check_str($_GET["voicemail_uuid"]); 53 } 54 55//get http post variables and set them to php variables 56 if (count($_POST)>0) { 57 $voicemail_uuid = check_str($_POST["voicemail_uuid"]); 58 $created_epoch = check_str($_POST["created_epoch"]); 59 $read_epoch = check_str($_POST["read_epoch"]); 60 $caller_id_name = check_str($_POST["caller_id_name"]); 61 $caller_id_number = check_str($_POST["caller_id_number"]); 62 $message_length = check_str($_POST["message_length"]); 63 $message_status = check_str($_POST["message_status"]); 64 $message_priority = check_str($_POST["message_priority"]); 65 } 66 67if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { 68 69 $msg = ''; 70 if ($action == "update") { 71 $voicemail_message_uuid = check_str($_POST["voicemail_message_uuid"]); 72 } 73 74 //check for all required data 75 //if (strlen($voicemail_uuid) == 0) { $msg .= "Please provide: Voicemail UUID<br>\n"; } 76 //if (strlen($created_epoch) == 0) { $msg .= "Please provide: Created Epoch<br>\n"; } 77 //if (strlen($read_epoch) == 0) { $msg .= "Please provide: Read Epoch<br>\n"; } 78 //if (strlen($caller_id_name) == 0) { $msg .= "Please provide: Caller ID Name<br>\n"; } 79 //if (strlen($caller_id_number) == 0) { $msg .= "Please provide: Caller ID Number<br>\n"; } 80 //if (strlen($message_length) == 0) { $msg .= "Please provide: Length<br>\n"; } 81 //if (strlen($message_status) == 0) { $msg .= "Please provide: Status<br>\n"; } 82 //if (strlen($message_priority) == 0) { $msg .= "Please provide: Priority<br>\n"; } 83 if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { 84 require_once "resources/header.php"; 85 require_once "resources/persist_form_var.php"; 86 echo "<div align='center'>\n"; 87 echo "<table><tr><td>\n"; 88 echo $msg."<br />"; 89 echo "</td></tr></table>\n"; 90 persistformvar($_POST); 91 echo "</div>\n"; 92 require_once "resources/footer.php"; 93 return; 94 } 95 96 //add or update the database 97 if ($_POST["persistformvar"] != "true") { 98 if ($action == "add" && permission_exists('voicemail_message_add')) { 99 $sql = "insert into v_voicemail_messages "; 100 $sql .= "("; 101 $sql .= "domain_uuid, "; 102 $sql .= "voicemail_message_uuid, "; 103 $sql .= "voicemail_uuid, "; 104 $sql .= "created_epoch, "; 105 $sql .= "read_epoch, "; 106 $sql .= "caller_id_name, "; 107 $sql .= "caller_id_number, "; 108 $sql .= "message_length, "; 109 $sql .= "message_status, "; 110 $sql .= "message_priority "; 111 $sql .= ")"; 112 $sql .= "values "; 113 $sql .= "("; 114 $sql .= "'$domain_uuid', "; 115 $sql .= "'".uuid()."', "; 116 $sql .= "'$voicemail_uuid', "; 117 $sql .= "'$created_epoch', "; 118 $sql .= "'$read_epoch', "; 119 $sql .= "'$caller_id_name', "; 120 $sql .= "'$caller_id_number', "; 121 $sql .= "'$message_length', "; 122 $sql .= "'$message_status', "; 123 $sql .= "'$message_priority' "; 124 $sql .= ")"; 125 $db->exec(check_sql($sql)); 126 unset($sql); 127 128 messages::add($text['message-add']); 129 header("Location: voicemail_edit.php?id=".$voicemail_uuid); 130 return; 131 } //if ($action == "add") 132 133 if ($action == "update" && permission_exists('voicemail_message_edit')) { 134 $sql = "update v_voicemail_messages set "; 135 $sql .= "voicemail_uuid = '$voicemail_uuid', "; 136 $sql .= "voicemail_uuid = '$voicemail_uuid', "; 137 $sql .= "created_epoch = '$created_epoch', "; 138 $sql .= "read_epoch = '$read_epoch', "; 139 $sql .= "caller_id_name = '$caller_id_name', "; 140 $sql .= "caller_id_number = '$caller_id_number', "; 141 $sql .= "message_length = '$message_length', "; 142 $sql .= "message_status = '$message_status', "; 143 $sql .= "message_priority = '$message_priority' "; 144 $sql .= "where domain_uuid = '$domain_uuid' "; 145 $sql .= "and voicemail_message_uuid = '$voicemail_message_uuid'"; 146 $db->exec(check_sql($sql)); 147 unset($sql); 148 149 messages::add($text['message-update']); 150 header("Location: voicemail_edit.php?id=".$voicemail_uuid); 151 return; 152 } //if ($action == "update") 153 } //if ($_POST["persistformvar"] != "true") 154} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) 155 156//pre-populate the form 157 if (count($_GET)>0 && $_POST["persistformvar"] != "true") { 158 $voicemail_message_uuid = check_str($_GET["id"]); 159 $sql = "select * from v_voicemail_messages "; 160 $sql .= "where domain_uuid = '$domain_uuid' "; 161 $sql .= "and voicemail_message_uuid = '$voicemail_message_uuid' "; 162 $prep_statement = $db->prepare(check_sql($sql)); 163 $prep_statement->execute(); 164 $result = $prep_statement->fetchAll(); 165 foreach ($result as &$row) { 166 $voicemail_uuid = $row["voicemail_uuid"]; 167 $created_epoch = $row["created_epoch"]; 168 $read_epoch = $row["read_epoch"]; 169 $caller_id_name = $row["caller_id_name"]; 170 $caller_id_number = $row["caller_id_number"]; 171 $message_length = $row["message_length"]; 172 $message_status = $row["message_status"]; 173 $message_priority = $row["message_priority"]; 174 break; //limit to 1 row 175 } 176 unset ($prep_statement); 177 } 178 179//show the header 180 require_once "resources/header.php"; 181 182//show the content 183 echo "<form method='post' name='frm' action=''>\n"; 184 echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; 185 echo "<tr>\n"; 186 echo "<td align='left' width='30%' nowrap='nowrap'><b>Voicemail Messages</b></td>\n"; 187 echo "<td width='70%' align='right'><input type='button' class='btn' name='' alt='back' onclick=\"window.location='voicemail_edit.php?id=$voicemail_uuid'\" value='Back'></td>\n"; 188 echo "</tr>\n"; 189 190 echo "<tr>\n"; 191 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 192 echo " Created Epoch\n"; 193 echo "</td>\n"; 194 echo "<td class='vtable' align='left'>\n"; 195 echo " <input class='formfld' type='text' name='created_epoch' maxlength='255' value='$created_epoch'>\n"; 196 echo "<br />\n"; 197 echo "\n"; 198 echo "</td>\n"; 199 echo "</tr>\n"; 200 201 echo "<tr>\n"; 202 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 203 echo " Read Epoch\n"; 204 echo "</td>\n"; 205 echo "<td class='vtable' align='left'>\n"; 206 echo " <input class='formfld' type='text' name='read_epoch' maxlength='255' value='$read_epoch'>\n"; 207 echo "<br />\n"; 208 echo "\n"; 209 echo "</td>\n"; 210 echo "</tr>\n"; 211 212 echo "<tr>\n"; 213 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 214 echo " Caller ID Name\n"; 215 echo "</td>\n"; 216 echo "<td class='vtable' align='left'>\n"; 217 echo " <input class='formfld' type='text' name='caller_id_name' maxlength='255' value=\"$caller_id_name\">\n"; 218 echo "<br />\n"; 219 echo "\n"; 220 echo "</td>\n"; 221 echo "</tr>\n"; 222 223 echo "<tr>\n"; 224 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 225 echo " Caller ID Number\n"; 226 echo "</td>\n"; 227 echo "<td class='vtable' align='left'>\n"; 228 echo " <input class='formfld' type='text' name='caller_id_number' maxlength='255' value=\"$caller_id_number\">\n"; 229 echo "<br />\n"; 230 echo "\n"; 231 echo "</td>\n"; 232 echo "</tr>\n"; 233 234 echo "<tr>\n"; 235 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 236 echo " Length\n"; 237 echo "</td>\n"; 238 echo "<td class='vtable' align='left'>\n"; 239 echo " <input class='formfld' type='text' name='message_length' maxlength='255' value='$message_length'>\n"; 240 echo "<br />\n"; 241 echo "\n"; 242 echo "</td>\n"; 243 echo "</tr>\n"; 244 245 echo "<tr>\n"; 246 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 247 echo " Status\n"; 248 echo "</td>\n"; 249 echo "<td class='vtable' align='left'>\n"; 250 echo " <input class='formfld' type='text' name='message_status' maxlength='255' value=\"$message_status\">\n"; 251 echo "<br />\n"; 252 echo "\n"; 253 echo "</td>\n"; 254 echo "</tr>\n"; 255 256 echo "<tr>\n"; 257 echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; 258 echo " Priority\n"; 259 echo "</td>\n"; 260 echo "<td class='vtable' align='left'>\n"; 261 echo " <input class='formfld' type='text' name='message_priority' maxlength='255' value=\"$message_priority\">\n"; 262 echo "<br />\n"; 263 echo "\n"; 264 echo "</td>\n"; 265 echo "</tr>\n"; 266 echo " <tr>\n"; 267 echo " <td colspan='2' align='right'>\n"; 268 echo " <input type='hidden' name='voicemail_uuid' value='$voicemail_uuid'>\n"; 269 if ($action == "update") { 270 echo " <input type='hidden' name='voicemail_message_uuid' value='$voicemail_message_uuid'>\n"; 271 } 272 echo " <br>"; 273 echo " <input type='submit' name='submit' class='btn' value='Save'>\n"; 274 echo " </td>\n"; 275 echo " </tr>"; 276 echo "</table>"; 277 echo "<br><br>"; 278 echo "</form>"; 279 280//include the footer 281 require_once "resources/footer.php"; 282?>