Copyright (C) 2013 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('device_key_add') || permission_exists('device_key_edit')) { //access granted } else { echo "access denied"; exit; } //add multi-lingual support $language = new text; $text = $language->get(); //action add or update if (is_uuid($_REQUEST["id"])) { $action = "update"; $device_key_uuid = $_REQUEST["id"]; $device_uuid = $_REQUEST["device_uuid"]; } else { $action = "add"; } //set the parent uuid if (is_uuid($_GET["device_key_uuid"])) { $device_key_uuid = $_GET["device_key_uuid"]; } //get http post variables and set them to php variables if (count($_POST)>0) { $device_key_id = $_POST["device_key_id"]; $device_key_category = $_POST["device_key_category"]; $device_key_type = $_POST["device_key_type"]; $device_key_line = $_POST["device_key_line"]; $device_key_value = $_POST["device_key_value"]; $device_key_extension = $_POST["device_key_extension"]; $device_key_label = $_POST["device_key_label"]; $device_key_icon = $_POST["device_key_icon"]; } if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { $msg = ''; if ($action == "update") { $device_key_uuid = $_POST["device_key_uuid"]; } //validate the token $token = new token; if (!$token->validate($_SERVER['PHP_SELF'])) { message::add($text['message-invalid_token'],'negative'); header('Location: devices.php'); exit; } //check for all required data //if (strlen($device_key_id) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_id']."
\n"; } //if (strlen($device_key_category) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_category']."
\n"; } //if (strlen($device_key_type) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_type']."
\n"; } //if (strlen($device_key_line) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_line']."
\n"; } //if (strlen($device_key_value) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_value']."
\n"; } //if (strlen($device_key_extension) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_extension']."
\n"; } //if (strlen($device_key_label) == 0) { $msg .= $text['message-required']." ".$text['label-device_key_label']."
\n"; } if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { require_once "resources/header.php"; require_once "resources/persistformvar.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('device_key_add')) { $array['device_keys'][0]['device_key_uuid'] = uuid(); message::add($text['message-add']); } if ($action == "update" && permission_exists('device_key_edit')) { $array['device_keys'][0]['device_key_uuid'] = $device_key_uuid; message::add($text['message-update']); } if (is_array($array) && @sizeof($array) != 0) { $array['device_keys'][0]['domain_uuid'] = $domain_uuid; $array['device_keys'][0]['device_uuid'] = $device_uuid; $array['device_keys'][0]['device_key_id'] = $device_key_id; $array['device_keys'][0]['device_key_category'] = $device_key_category; $array['device_keys'][0]['device_key_type'] = $device_key_type; $array['device_keys'][0]['device_key_line'] = $device_key_line; $array['device_keys'][0]['device_key_value'] = $device_key_value; $array['device_keys'][0]['device_key_extension'] = $device_key_extension; $array['device_keys'][0]['device_key_label'] = $device_key_label; $array['device_keys'][0]['device_key_icon'] = $device_key_icon; $database = new database; $database->app_name = 'devices'; $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; $database->save($array); unset($array); header("Location: device_edit.php?id=".$device_uuid); return; } } } //pre-populate the form if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { $device_key_uuid = $_GET["id"]; $sql = "select * from v_device_keys "; $sql .= "where domain_uuid = :domain_uuid "; $sql .= "and device_key_uuid = :device_key_uuid "; $parameters['domain_uuid'] = $domain_uuid; $parameters['device_key_uuid'] = $device_key_uuid; $database = new database; $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $device_uuid = $row["device_uuid"]; $device_key_id = $row["device_key_id"]; $device_key_category = $row["device_key_category"]; $device_key_type = $row["device_key_type"]; $device_key_line = $row["device_key_line"]; $device_key_value = $row["device_key_value"]; $device_key_extension = $row["device_key_extension"]; $device_key_label = $row["device_key_label"]; $device_key_icon = $row["device_key_icon"]; } unset($sql, $parameters, $row); } //create token $object = new token; $token = $object->create($_SERVER['PHP_SELF']); //show the header require_once "resources/header.php"; //show the content 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-device_key']."
\n"; echo " ".$text['label-device_key_category']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_key_category']."\n"; echo "
\n"; echo " ".$text['label-device_key_id']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_key_id']."\n"; echo "
\n"; echo " ".$text['label-device_key_line']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_key_line']."\n"; echo "
\n"; echo " ".$text['label-device_key_type']."\n"; echo "\n"; $device_key_types['Cisco'] = array( 'line' => 'line', 'disabled' => 'disabled' ); $device_key_types['Yealink'] = array( 0 => 'N/A (Memory Key Default)', 1 => 'Conference', 2 => 'Forward', 3 => 'Transfer', 4 => 'Hold', 5 => 'DND', 6 => 'Redial', 7 => 'Call Return', 8 => 'SMS', 9 => 'Call Pickup', 10 => 'Call Park', 11 => 'DTMF', 12 => 'Voicemail', 13 => 'SpeedDial', 14 => 'Intercom', 15 => 'Line (Line Key Default)', 16 => 'BLF', 17 => 'URL', 19 => 'Public Hold', 20 => 'Private', 21 => 'Shared Line', 22 => 'XML Group', 23 => 'Group Pickup', 24 => 'Paging', 25 => 'Record', 27 => 'XML Browser', 28 => 'History', 29 => 'Directory', 30 => 'Menu', 32 => 'New SMS', 33 => 'Status', 34 => 'Hot Desking', 35 => 'URL Record', 38 => 'LDAP', 39 => 'BLF List', 40 => 'Prefix', 41 => 'Zero-Sp-Touch', 42 => 'ACD', 43 => 'Local Phonebook', 44 => 'Broadsoft Phonebook', 45 => 'Local Group', 46 => 'Broadsoft Group', 47 => 'XML Phonebook', 48 => 'Switch Account Up', 49 => 'Switch Account Down', 50 => 'Keypad Lock' ); $device_key_types['Other'] = array( 'line' => 'line', 'other' => 'other' ); if ($device_key_type != '') { $selected[$device_key_type] = "selected='selected'"; $found = in_array($device_key_type, $device_key_types_yealink) || $device_key_type == 'disabled' || $device_key_type == 'line' ? true : false; } echo "\n"; unset($selected); echo "
\n"; echo $text['description-device_key_type']."\n"; echo "
\n"; echo " ".$text['label-device_key_value']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_key_value']."\n"; echo "
\n"; echo " ".$text['label-device_key_extension']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_key_extension']."\n"; echo "
\n"; echo " ".$text['label-device_key_label']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_key_label']."\n"; echo "
\n"; echo " ".$text['label-device_key_icon']."\n"; echo "\n"; echo " \n"; echo "
\n"; echo $text['description-device_key_icon']."\n"; echo "
\n"; echo " \n"; if ($action == "update") { echo " \n"; } echo " \n"; echo "
"; echo " \n"; echo "
"; echo "

"; echo "
"; //include the footer require_once "resources/footer.php"; ?>