diff --git a/app/hot_desking/app_config.php b/app/hot_desking/app_config.php new file mode 100644 index 0000000000..7baea56c0c --- /dev/null +++ b/app/hot_desking/app_config.php @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/app/hot_desking/extension_delete.php b/app/hot_desking/extension_delete.php new file mode 100644 index 0000000000..2ae31a355f --- /dev/null +++ b/app/hot_desking/extension_delete.php @@ -0,0 +1,70 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +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 "\n"; + echo "
\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Message
Delete Complete
\n"; + echo "
\n"; + echo "
\n"; + require_once "includes/footer.php"; + return; + +?> \ No newline at end of file diff --git a/app/hot_desking/extension_edit.php b/app/hot_desking/extension_edit.php new file mode 100644 index 0000000000..451a2131a0 --- /dev/null +++ b/app/hot_desking/extension_edit.php @@ -0,0 +1,305 @@ + + Copyright (C) 2008-2012 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +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
\n"; } + if (strlen($extension_uuid) == 0) { $msg .= "Please provide the extension
\n"; } + if (strlen($unique_id) == 0) { $msg .= "Please provide the unique ID.
\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.
\n"; + } + } + unset($prep_statement, $result); + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "includes/header.php"; + require_once "includes/persistformvar.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\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 "\n"; + echo "
\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if ($action == "add") { + echo " \n"; + } + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
Message
Add CompleteUpdate Complete
\n"; + echo "
\n"; + echo "
\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 ""; + + 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"; + + if ($action == "update") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + } + + echo "
\n"; + echo " Hot Desking\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " Extension:\n"; + echo "\n"; + if ($action == "add") { + echo "
\n"; + echo "Select the extension number.\n"; + } + if ($action == "update") { + echo " $extension
\n"; + echo "Extension number.\n"; + } + echo "
\n"; + + echo "
\n"; + echo " Unique ID:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "A unique ID to identify the extension and domain.\n"; + echo "
\n"; + echo " Voicemail Password:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Enter the voicemail password here. \n"; + echo "
\n"; + echo " Dial String:\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo "Location of the endpoint.\n"; + echo "
"; + echo ""; + + echo "
"; + echo "
"; + +require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/hot_desking/index.php b/app/hot_desking/index.php new file mode 100644 index 0000000000..68e432652b --- /dev/null +++ b/app/hot_desking/index.php @@ -0,0 +1,181 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ +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 "
"; + echo "\n"; + echo "\n"; + echo " "; + echo ""; + echo "
\n"; + echo "
"; + + //show the content header + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
Hot Desking
\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 "
\n"; + echo "
"; + + //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 "
\n"; + echo "\n"; + echo "\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 "\n"; + echo "\n"; + + if ($result_count > 0) { + foreach($result as $row) { + echo "\n"; + echo " \n"; + echo " \n"; + if (strlen($row['dial_user']) > 0) { + echo " \n"; + } + else { + echo " \n"; + } + //echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "
\n"; + if (permission_exists('extension_add')) { + echo " $v_link_label_add\n"; + } + echo "
".$row['extension']." ".$row['unique_id']." ".$row['dial_user']."@".$row['dial_domain']."  ".$row['dial_domain']." ".$row['domain_uuid']." ".$row['description']." \n"; + if (permission_exists('extension_edit')) { + echo " $v_link_label_edit\n"; + } + if (permission_exists('extension_delete')) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls\n"; + if (permission_exists('extension_add')) { + echo " $v_link_label_add\n"; + } + echo "
\n"; + echo "
"; + echo "
"; + echo "

"; + echo "

"; + + echo "
"; + echo "
"; + echo "

"; + +//show the footer + require_once "includes/footer.php"; +?> \ No newline at end of file diff --git a/app/hot_desking/root.php b/app/hot_desking/root.php new file mode 100644 index 0000000000..7b882438ea --- /dev/null +++ b/app/hot_desking/root.php @@ -0,0 +1,50 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// 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"]."
\n"; + //echo "PHP_SELF: ".$_SERVER["PHP_SELF"]."
\n"; + //echo "SCRIPT_FILENAME: ".$_SERVER["SCRIPT_FILENAME"]."
\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'] ); + } + +?> \ No newline at end of file