Add the hot desking interface.

This commit is contained in:
Mark Crane 2012-06-04 16:39:12 +00:00
parent d39e74b530
commit c81286af71
5 changed files with 639 additions and 0 deletions

View File

@ -0,0 +1,33 @@
<?php
//application details
$apps[$x]['name'] = "Hot Desking";
$apps[$x]['uuid'] = 'f4ae30f0-68ff-46d2-afd3-34caff2887c9';
$apps[$x]['category'] = 'Switch';;
$apps[$x]['subcategory'] = '';
$apps[$x]['version'] = '';
$apps[$x]['license'] = 'Mozilla Public License 1.1';
$apps[$x]['url'] = 'http://www.fusionpbx.com';
$apps[$x]['description']['en'] = 'Login into hot desking with an ID and your voicemail password to direct your calls to a remote extension. Then make and receive calls as if you were at your extension.';
//menu details
$apps[$x]['menu'][0]['title']['en'] = 'Hot Desking';
$apps[$x]['menu'][0]['uuid'] = 'baa57691-37d4-4c7d-b227-f2929202b480';
$apps[$x]['menu'][0]['parent_uuid'] = 'bc96d773-ee57-0cdd-c3ac-2d91aba61b55';
$apps[$x]['menu'][0]['category'] = 'internal';
$apps[$x]['menu'][0]['path'] = '/app/hot_desking/index.php';
$apps[$x]['menu'][0]['groups'][] = 'superadmin';
//permission details
$apps[$x]['permissions'][0]['name'] = 'hot_desk_view';
$apps[$x]['permissions'][0]['groups'][] = 'superadmin';
$apps[$x]['permissions'][1]['name'] = 'hot_desk_add';
$apps[$x]['permissions'][1]['groups'][] = 'superadmin';
$apps[$x]['permissions'][2]['name'] = 'hot_desk_edit';
$apps[$x]['permissions'][2]['groups'][] = 'superadmin';
$apps[$x]['permissions'][3]['name'] = 'hot_desk_delete';
$apps[$x]['permissions'][3]['groups'][] = 'superadmin';
?>

View File

@ -0,0 +1,70 @@
<?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>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('extension_delete')) {
//access granted
}
else {
echo "access denied";
exit;
}
if (count($_GET)>0) {
$id = $_GET["id"];
}
//delete the extension
if (strlen($id)>0) {
$sql .= "update v_extensions ";
$sql .= "set unique_id = null ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and extension_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement, $sql);
}
//redirect the user
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=index.php\">\n";
echo "<br />\n";
echo "<div align='center'>\n";
echo " <table width='40%'>\n";
echo " <tr>\n";
echo " <th align='left'>Message</th>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td class='row_style1'><strong>Delete Complete</strong></td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <br />\n";
echo "</div>\n";
require_once "includes/footer.php";
return;
?>

View File

@ -0,0 +1,305 @@
<?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>
Copyright (C) 2008-2012 All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('extension_add') || permission_exists('extension_edit')) {
//access granted
}
else {
echo "access denied";
exit;
}
//set the action as an add or an update
if (isset($_REQUEST["id"])) {
$action = "update";
$extension_uuid = check_str($_REQUEST["id"]);
}
else {
$action = "add";
}
//get the http values and set them as php variables
if (count($_POST)>0) {
//get the values from the HTTP POST and save them as PHP variables
$extension_uuid = check_str($_POST["extension_uuid"]);
$unique_id = check_str($_POST["unique_id"]);
$vm_password = check_str($_POST["vm_password"]);
$dial_string = check_str($_POST["dial_string"]);
}
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//check for all required data
//if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
if (strlen($extension_uuid) == 0) { $msg .= "Please provide the extension<br>\n"; }
if (strlen($unique_id) == 0) { $msg .= "Please provide the unique ID.<br>\n"; }
//get the number of rows in v_extensions
$sql = "select count(*) as num_rows from v_extensions ";
$sql .= "where unique_id = '".$unique_id."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) {
$msg .= "The ID is not unqiue please provide a unique ID.<br>\n";
}
}
unset($prep_statement, $result);
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "includes/header.php";
require_once "includes/persistformvar.php";
echo "<div align='center'>\n";
echo "<table><tr><td>\n";
echo $msg."<br />";
echo "</td></tr></table>\n";
persistformvar($_POST);
echo "</div>\n";
require_once "includes/footer.php";
return;
}
//set the default user context
if (if_group("superadmin")) {
//allow a user assigned to super admin to change the user_context
}
else {
//if the user_context was not set then set the default value
if (strlen($user_context) == 0) {
if (count($_SESSION["domains"]) > 1) {
$user_context = $_SESSION['domain_name'];
}
else {
$user_context = "default";
}
}
}
//add or update the database
if ($_POST["persistformvar"] != "true") {
//update the extension
if ($action == "add" && permission_exists('extension_edit')) {
$sql = "update v_extensions set ";
$sql .= "unique_id = '$unique_id' ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and extension_uuid = '$extension_uuid'";
$db->exec(check_sql($sql));
unset($sql);
}
//update the extension
if ($action == "update" && permission_exists('extension_edit')) {
$sql = "update v_extensions set ";
$sql .= "unique_id = '$unique_id', ";
if (strlen($vm_password) > 0) {
$sql .= "vm_password = '$vm_password' ";
}
else {
$sql .= "vm_password = 'user-choose' ";
}
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and extension_uuid = '$extension_uuid'";
$db->exec(check_sql($sql));
unset($sql);
}
//show the action and redirect the user
require_once "includes/header.php";
echo "<meta http-equiv=\"refresh\" content=\"2;url=index.php\">\n";
echo "<br />\n";
echo "<div align='center'>\n";
echo " <table width='40%'>\n";
echo " <tr>\n";
echo " <th align='left'>Message</th>\n";
echo " </tr>\n";
echo " <tr>\n";
if ($action == "add") {
echo " <td class='row_style1'><strong>Add Complete</strong></td>\n";
}
if ($action == "update") {
echo " <td class='row_style1'><strong>Update Complete</strong></td>\n";
}
echo " </tr>\n";
echo " </table>\n";
echo "<br />\n";
echo "</div>\n";
require_once "includes/footer.php";
return;
} //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form
if ($_POST["persistformvar"] != "true") {
//$extension_uuid = $_GET["id"];
$sql = "select * from v_extensions ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and extension_uuid = '$extension_uuid' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$extension = $row["extension"];
$dial_string = $row["dial_string"];
$unique_id = $row["unique_id"];
$password = $row["password"];
$vm_password = $row["vm_password"];
$vm_password = str_replace("#", "", $vm_password); //preserves leading zeros
}
unset ($prep_statement);
}
//set the defaults
if (strlen($limit_max) == 0) { $limit_max = '5'; }
//begin the page content
require_once "includes/header.php";
echo "<script type=\"text/javascript\" language=\"JavaScript\">\n";
echo "\n";
echo "function enable_change(enable_over) {\n";
echo " var endis;\n";
echo " endis = !(document.iform.enable.checked || enable_over);\n";
echo " document.iform.range_from.disabled = endis;\n";
echo " document.iform.range_to.disabled = endis;\n";
echo "}\n";
echo "\n";
echo "function show_advanced_config() {\n";
echo " document.getElementById(\"show_advanced_box\").innerHTML='';\n";
echo " aodiv = document.getElementById('show_advanced');\n";
echo " aodiv.style.display = \"block\";\n";
echo "}\n";
echo "\n";
echo "function hide_advanced_config() {\n";
echo " document.getElementById(\"show_advanced_box\").innerHTML='';\n";
echo " aodiv = document.getElementById('show_advanced');\n";
echo " aodiv.style.display = \"none\";\n";
echo "}\n";
echo "</script>";
echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
echo "<tr class='border'>\n";
echo " <td align=\"left\">\n";
echo " <br>";
echo "<form method='post' name='frm' action=''>\n";
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
echo "<tr>\n";
echo " <td width='30%' nowrap='nowrap' align='left' valign='top'>\n";
echo " <b>Hot Desking</b>\n";
echo " </td>\n";
echo " <td width='70%' align='right' valign='top'>\n";
echo " <input type='submit' name='submit' class='btn' value='Save'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='index.php'\" value='Back'>\n";
echo " </td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " Extension:\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
if ($action == "add") {
echo "<select id=\"extension_uuid\" name=\"extension_uuid\" class='formfld' \">\n";
echo "<option value=''></option>\n";
$sql = "select extension, extension_uuid, description FROM v_extensions ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "order by extension asc ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
if ($result_count > 0) {
foreach($result as $row) {
if ($extension_uuid == $row['extension_uuid']) {
echo "<option value=\"".$row['extension_uuid']."\" selected>".$row['extension']." ".$row['description']."</option>\n";
}
else {
echo "<option value=\"".$row['extension_uuid']."\">".$row['extension']." ".$row['description']."</option>\n";
}
}
}
unset($sql, $result, $result_count);
echo "</select><br />\n";
echo "Select the extension number.\n";
}
if ($action == "update") {
echo " $extension<br />\n";
echo "Extension number.\n";
}
echo "<br />\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Unique ID:\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='unique_id' autocomplete='off' maxlength='255' value=\"$unique_id\">\n";
echo "<br />\n";
echo "A unique ID to identify the extension and domain.\n";
echo "</td>\n";
echo "</tr>\n";
if ($action == "update") {
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Voicemail Password:\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='password' name='vm_password' id='vm_password' onfocus=\"document.getElementById('show_vm_password').innerHTML = 'Password: '+document.getElementById('vm_password').value;\" maxlength='255' value='$vm_password'>\n";
echo "<br />\n";
echo "<span onclick=\"document.getElementById('show_vm_password').innerHTML = ''\">Enter the voicemail password here. </span><span id='show_vm_password'></span>\n";
echo "</td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " Dial String:\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='dial_string' maxlength='255' value=\"$dial_string\">\n";
echo "<br />\n";
echo "Location of the endpoint.\n";
echo "</td>\n";
echo "</tr>\n";
echo "<input type='hidden' name='extension_uuid' maxlength='255' value=\"$extension_uuid\">\n";
}
echo "</table>";
echo "</form>";
echo " </td>";
echo " </tr>";
echo "</table>";
echo "</div>";
require_once "includes/footer.php";
?>

181
app/hot_desking/index.php Normal file
View File

@ -0,0 +1,181 @@
<?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>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
include "root.php";
require_once "includes/require.php";
require_once "includes/checkauth.php";
if (permission_exists('extension_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
require_once "includes/header.php";
require_once "includes/paging.php";
//get the http values and set them as variables
if (isset($_GET["order_by"])) {
$order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]);
}
//show the content
echo "<div align='center'>";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
echo "<tr class='border'>\n";
echo " <td align=\"center\">\n";
echo " <br>";
//show the content header
echo "<table width=\"100%\" border=\"0\" cellpadding=\"6\" cellspacing=\"0\">\n";
echo " <tr>\n";
echo " <td align='left'><b>Hot Desking</b><br>\n";
echo " Login into hot desking with an ID and your voicemail password to direct your calls to a remote extension. Then make and receive calls as if you were at your extension.\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<br />";
//get the number of rows in v_extensions
$sql = "select count(*) as num_rows from v_extensions ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and unique_id is not null ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows'];
}
else {
$num_rows = '0';
}
}
unset($prep_statement, $result);
//prepare to page the results
$rows_per_page = 150;
$param = "";
if (!isset($_GET['page'])) { $_GET['page'] = 0; }
$_GET['page'] = check_str($_GET['page']);
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $_GET['page'];
//get the extension list
$sql = "select * from v_extensions ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and unique_id is not null ";
if (isset($order_by)) {
$sql .= "order by $order_by $order ";
}
else {
$sql .= "order by extension asc ";
}
$sql .= " limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$result_count = count($result);
unset ($prep_statement, $sql);
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<div align='center'>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo th_order_by('extension', 'Extension', $order_by, $order);
echo th_order_by('unique_id', 'Unique ID', $order_by, $order);
echo th_order_by('dial_user', 'Forward To', $order_by, $order);
//echo th_order_by('dial_domain', 'Domain', $order_by, $order);
//echo th_order_by('call_group', 'Domain', $order_by, $order);
echo th_order_by('description', 'Description', $order_by, $order);
echo "<td align='right' width='42'>\n";
if (permission_exists('extension_add')) {
echo " <a href='extension_edit.php' alt='add'>$v_link_label_add</a>\n";
}
echo "</td>\n";
echo "<tr>\n";
if ($result_count > 0) {
foreach($result as $row) {
echo "<tr >\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['extension']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['unique_id']."&nbsp;</td>\n";
if (strlen($row['dial_user']) > 0) {
echo " <td valign='top' class='".$row_style[$c]."'>".$row['dial_user']."@".$row['dial_domain']."&nbsp;</td>\n";
}
else {
echo " <td valign='top' class='".$row_style[$c]."'>&nbsp;</td>\n";
}
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['dial_domain']."&nbsp;</td>\n";
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['domain_uuid']."&nbsp;</td>\n";
echo " <td valign='top' class='row_stylebg' width='30%'>".$row['description']."&nbsp;</td>\n";
echo " <td valign='top' align='right'>\n";
if (permission_exists('extension_edit')) {
echo " <a href='extension_edit.php?id=".$row['extension_uuid']."' alt='edit'>$v_link_label_edit</a>\n";
}
if (permission_exists('extension_delete')) {
echo " <a href='extension_delete.php?id=".$row['extension_uuid']."' alt='delete' onclick=\"return confirm('Do you really want to delete this?')\">$v_link_label_delete</a>\n";
}
echo " </td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
unset($sql, $result, $row_count);
} //end if results
echo "<tr>\n";
echo "<td colspan='6' align='left'>\n";
echo " <table border='0' width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td width='33.3%' align='right'>\n";
if (permission_exists('extension_add')) {
echo " <a href='extension_edit.php' alt='add'>$v_link_label_add</a>\n";
}
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "</div>";
echo "<br><br>";
echo "<br><br>";
echo "</td>";
echo "</tr>";
echo "</table>";
echo "</div>";
echo "<br><br>";
//show the footer
require_once "includes/footer.php";
?>

50
app/hot_desking/root.php Normal file
View File

@ -0,0 +1,50 @@
<?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>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
// make sure the PATH_SEPARATOR is defined
if (!defined("PATH_SEPARATOR")) {
if ( strpos( $_ENV[ "OS" ], "Win" ) !== false ) { define("PATH_SEPARATOR", ";"); } else { define("PATH_SEPARATOR", ":"); }
}
// make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", "/", $_SERVER["SCRIPT_FILENAME"]);
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
//echo "DOCUMENT_ROOT: ".$_SERVER["DOCUMENT_ROOT"]."<br />\n";
//echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."<br />\n";
//echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."<br />\n";
// if the project directory exists then add it to the include path otherwise add the document root to the include path
if (is_dir($_SERVER["DOCUMENT_ROOT"].'/fusionpbx')){
if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', '/fusionpbx'); }
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER["DOCUMENT_ROOT"].'/fusionpbx' );
}
else {
if(!defined('PROJECT_PATH')) { define('PROJECT_PATH', ''); }
set_include_path( get_include_path() . PATH_SEPARATOR . $_SERVER['DOCUMENT_ROOT'] );
}
?>