2012-06-04 16:58:40 +02: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>
|
2016-03-17 01:48:42 +01:00
|
|
|
Portions created by the Initial Developer are Copyright (C) 2008-2016
|
2012-06-04 16:58:40 +02:00
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
Contributor(s):
|
|
|
|
|
Mark J Crane <markjcrane@fusionpbx.com>
|
|
|
|
|
*/
|
|
|
|
|
include "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-06-04 16:58:40 +02:00
|
|
|
if (permission_exists('extension_view')) {
|
|
|
|
|
//access granted
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo "access denied";
|
|
|
|
|
exit;
|
|
|
|
|
}
|
2013-05-04 02:35:21 +02:00
|
|
|
|
|
|
|
|
//add multi-lingual support
|
2015-01-18 11:33:34 +01:00
|
|
|
$language = new text;
|
|
|
|
|
$text = $language->get();
|
2013-05-04 02:35:21 +02:00
|
|
|
|
2015-03-22 09:48:50 +01:00
|
|
|
//get the http values and set them as variables
|
|
|
|
|
$search = check_str($_GET["search"]);
|
2016-03-28 23:21:05 +02:00
|
|
|
$order_by = check_str($_GET["order_by"]);
|
|
|
|
|
$order = check_str($_GET["order"]);
|
2015-03-22 09:48:50 +01:00
|
|
|
|
2016-03-04 03:01:58 +01:00
|
|
|
//handle search term
|
|
|
|
|
$search = check_str($_GET["search"]);
|
|
|
|
|
if (strlen($search) > 0) {
|
|
|
|
|
$sql_mod = "and ( ";
|
|
|
|
|
$sql_mod .= "extension like '%".$search."%' ";
|
|
|
|
|
$sql_mod .= "or call_group like '%".$search."%' ";
|
|
|
|
|
$sql_mod .= "or user_context like '%".$search."%' ";
|
|
|
|
|
$sql_mod .= "or enabled like '%".$search."%' ";
|
|
|
|
|
$sql_mod .= "or description like '%".$search."%' ";
|
|
|
|
|
$sql_mod .= ") ";
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/header.php";
|
2014-07-10 02:32:50 +02:00
|
|
|
$document['title'] = $text['title-extensions'];
|
2013-05-04 02:35:21 +02:00
|
|
|
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/paging.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2015-03-22 09:17:04 +01:00
|
|
|
//get total extension count from the database
|
|
|
|
|
$sql = "select count(*) as num_rows from v_extensions where domain_uuid = '".$_SESSION['domain_uuid']."' ";
|
|
|
|
|
$prep_statement = $db->prepare($sql);
|
|
|
|
|
if ($prep_statement) {
|
|
|
|
|
$prep_statement->execute();
|
|
|
|
|
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
|
|
|
|
|
$total_extensions = $row['num_rows'];
|
|
|
|
|
}
|
|
|
|
|
unset($prep_statement, $row);
|
|
|
|
|
|
|
|
|
|
//get the number of extensions (reuse $sql from above)
|
2016-03-04 03:01:58 +01:00
|
|
|
$sql .= $sql_mod; //add search mod from above
|
2015-03-22 09:17:04 +01:00
|
|
|
$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'];
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
else {
|
2015-03-22 09:17:04 +01:00
|
|
|
$num_rows = '0';
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2015-03-22 09:17:04 +01:00
|
|
|
}
|
|
|
|
|
unset($prep_statement, $result);
|
|
|
|
|
|
|
|
|
|
//prepare to page the results
|
|
|
|
|
$rows_per_page = 150;
|
2016-03-04 03:01:58 +01:00
|
|
|
$param = "&search=".$search;
|
2015-03-22 09:17:04 +01:00
|
|
|
if (!isset($_GET['page'])) { $_GET['page'] = 0; }
|
|
|
|
|
$_GET['page'] = check_str($_GET['page']);
|
2016-03-04 03:01:58 +01:00
|
|
|
list($paging_controls_mini, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page, true); //top
|
|
|
|
|
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page); //bottom
|
2015-03-22 09:17:04 +01:00
|
|
|
$offset = $rows_per_page * $_GET['page'];
|
|
|
|
|
|
|
|
|
|
//get the extensions
|
|
|
|
|
$sql = "select * from v_extensions ";
|
|
|
|
|
$sql .= "where domain_uuid = '$domain_uuid' ";
|
2016-03-04 03:01:58 +01:00
|
|
|
$sql .= $sql_mod; //add search mod from above
|
2016-03-28 23:21:05 +02:00
|
|
|
if (strlen($order_by) > 0) {
|
|
|
|
|
$sql .= ($order_by == 'extension') ? "order by cast(extension as int) ".$order." " : "order by ".$order_by." ".$order." ";
|
2015-03-22 09:17:04 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2016-03-28 23:21:05 +02:00
|
|
|
$sql .= "order by cast(extension as int) asc ";
|
2015-03-22 09:17:04 +01:00
|
|
|
}
|
|
|
|
|
$sql .= " limit $rows_per_page offset $offset ";
|
|
|
|
|
$prep_statement = $db->prepare(check_sql($sql));
|
|
|
|
|
$prep_statement->execute();
|
2015-09-05 07:12:36 +02:00
|
|
|
$extensions = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
2015-03-22 09:17:04 +01:00
|
|
|
unset ($prep_statement, $sql);
|
|
|
|
|
|
2015-09-05 07:12:36 +02:00
|
|
|
//show the content
|
|
|
|
|
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
|
|
|
|
|
echo " <tr>\n";
|
2016-03-04 03:01:58 +01:00
|
|
|
echo " <td align='left' width='100%'><b>".$text['header-extensions']." (".$num_rows.")</b><br>\n";
|
2015-09-05 07:12:36 +02:00
|
|
|
echo " ".$text['description-extensions']."\n";
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " <form method='get' action=''>\n";
|
2016-03-04 03:01:58 +01:00
|
|
|
echo " <td style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
|
2015-12-11 00:07:46 +01:00
|
|
|
if (if_group("superadmin")) {
|
2016-03-04 03:01:58 +01:00
|
|
|
echo " <input type='button' class='btn' style='margin-right: 15px;' value='".$text['button-export']."' onclick=\"window.location.href='extension_download.php'\">\n";
|
2015-12-11 00:07:46 +01:00
|
|
|
}
|
2015-09-05 07:12:36 +02:00
|
|
|
echo " <input type='text' class='txt' style='width: 150px' name='search' value='".$search."'>";
|
|
|
|
|
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>";
|
2016-03-04 03:01:58 +01:00
|
|
|
if ($paging_controls_mini != '') {
|
|
|
|
|
echo "<span style='margin-left: 15px;'>".$paging_controls_mini."</span>\n";
|
|
|
|
|
}
|
2015-09-05 07:12:36 +02:00
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </form>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
echo "</table>\n";
|
|
|
|
|
echo "<br />";
|
|
|
|
|
|
2015-03-22 09:17:04 +01:00
|
|
|
$c = 0;
|
|
|
|
|
$row_style["0"] = "row_style0";
|
|
|
|
|
$row_style["1"] = "row_style1";
|
|
|
|
|
|
2016-03-17 01:48:42 +01:00
|
|
|
echo "<form name='frm' method='post' action='extension_delete.php'>\n";
|
2015-03-22 09:17:04 +01:00
|
|
|
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
|
|
|
|
echo "<tr>\n";
|
2016-03-17 01:48:42 +01:00
|
|
|
if (permission_exists('extension_delete') && $num_rows > 0) {
|
|
|
|
|
echo "<th style='width: 30px; text-align: center; padding: 0px;'><input type='checkbox' id='chk_all' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
|
|
|
|
|
}
|
2015-03-22 09:17:04 +01:00
|
|
|
echo th_order_by('extension', $text['label-extension'], $order_by, $order);
|
|
|
|
|
echo th_order_by('call_group', $text['label-call_group'], $order_by, $order);
|
|
|
|
|
//echo th_order_by('voicemail_mail_to', $text['label-voicemail_mail_to'], $order_by, $order);
|
|
|
|
|
echo th_order_by('user_context', $text['label-user_context'], $order_by, $order);
|
|
|
|
|
echo th_order_by('enabled', $text['label-enabled'], $order_by, $order);
|
|
|
|
|
echo th_order_by('description', $text['label-description'], $order_by, $order);
|
|
|
|
|
echo "<td class='list_control_icons'>\n";
|
|
|
|
|
if (permission_exists('extension_add')) {
|
|
|
|
|
if ($_SESSION['limit']['extensions']['numeric'] == '' || ($_SESSION['limit']['extensions']['numeric'] != '' && $total_extensions < $_SESSION['limit']['extensions']['numeric'])) {
|
2016-03-17 01:48:42 +01:00
|
|
|
echo "<a href='extension_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2015-03-22 09:17:04 +01:00
|
|
|
}
|
2016-03-17 01:48:42 +01:00
|
|
|
if (permission_exists('extension_delete') && $num_rows > 0) {
|
|
|
|
|
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
|
|
|
|
|
}
|
2015-03-22 09:17:04 +01:00
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
2015-09-05 07:12:36 +02:00
|
|
|
if ($num_rows > 0) {
|
|
|
|
|
foreach($extensions as $row) {
|
2015-03-22 09:17:04 +01:00
|
|
|
$tr_link = (permission_exists('extension_edit')) ? " href='extension_edit.php?id=".$row['extension_uuid']."'" : null;
|
|
|
|
|
echo "<tr ".$tr_link.">\n";
|
2016-03-17 01:48:42 +01:00
|
|
|
if (permission_exists('extension_delete')) {
|
|
|
|
|
echo " <td valign='top' class='".$row_style[$c]." tr_link_void' style='text-align: center; vertical-align: middle; padding: 0px;'>";
|
|
|
|
|
echo " <input type='checkbox' name='id[]' id='checkbox_".$row['extension_uuid']."' value='".$row['extension_uuid']."' onclick=\"if (!this.checked) { document.getElementById('chk_all').checked = false; }\">";
|
|
|
|
|
echo " </td>";
|
|
|
|
|
$ext_ids[] = 'checkbox_'.$row['extension_uuid'];
|
|
|
|
|
}
|
2015-03-22 09:17:04 +01:00
|
|
|
echo " <td valign='top' class='".$row_style[$c]."'>";
|
|
|
|
|
if (permission_exists('extension_edit')) {
|
|
|
|
|
echo "<a href='extension_edit.php?id=".$row['extension_uuid']."'>".$row['extension']."</a>";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
echo $row['extension'];
|
|
|
|
|
}
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo " <td valign='top' class='".$row_style[$c]."'>".$row['call_group']." </td>\n";
|
|
|
|
|
//echo " <td valign='top' class='".$row_style[$c]."'>".$row['voicemail_mail_to']." </td>\n";
|
|
|
|
|
echo " <td valign='top' class='".$row_style[$c]."'>".$row['user_context']."</td>\n";
|
|
|
|
|
echo " <td valign='top' class='".$row_style[$c]."'>".ucwords($row['enabled'])."</td>\n";
|
|
|
|
|
echo " <td valign='top' class='row_stylebg' width='30%'>".$row['description']." </td>\n";
|
|
|
|
|
echo " <td class='list_control_icons'>";
|
|
|
|
|
if (permission_exists('extension_edit')) {
|
|
|
|
|
echo "<a href='extension_edit.php?id=".$row['extension_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
|
|
|
|
|
}
|
|
|
|
|
if (permission_exists('extension_delete')) {
|
2016-03-17 01:48:42 +01:00
|
|
|
echo "<a href='extension_delete.php?id[]=".$row['extension_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
|
2015-03-22 09:17:04 +01:00
|
|
|
}
|
|
|
|
|
echo "</td>\n";
|
|
|
|
|
echo "</tr>\n";
|
|
|
|
|
if ($c==0) { $c=1; } else { $c=0; }
|
|
|
|
|
} //end foreach
|
2015-09-05 07:12:36 +02:00
|
|
|
unset($sql, $extensions, $row_count);
|
2015-03-22 09:17:04 +01:00
|
|
|
} //end if results
|
|
|
|
|
|
2016-03-17 01:48:42 +01:00
|
|
|
echo " <tr>\n";
|
|
|
|
|
echo " <td colspan='20' class='list_control_icons'>\n";
|
2015-03-22 09:17:04 +01:00
|
|
|
if (permission_exists('extension_add')) {
|
|
|
|
|
if ($_SESSION['limit']['extensions']['numeric'] == '' || ($_SESSION['limit']['extensions']['numeric'] != '' && $total_extensions < $_SESSION['limit']['extensions']['numeric'])) {
|
2016-03-17 01:48:42 +01:00
|
|
|
echo "<a href='extension_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
|
2012-06-04 16:58:40 +02:00
|
|
|
}
|
2015-03-22 09:17:04 +01:00
|
|
|
}
|
2016-03-17 01:48:42 +01:00
|
|
|
if (permission_exists('extension_delete') && $num_rows > 0) {
|
|
|
|
|
echo "<a href='javascript:void(0);' onclick=\"if (confirm('".$text['confirm-delete']."')) { document.forms.frm.submit(); }\" alt='".$text['button-delete']."'>".$v_link_label_delete."</a>";
|
|
|
|
|
}
|
|
|
|
|
echo " </td>\n";
|
|
|
|
|
echo " </tr>\n";
|
|
|
|
|
|
2015-03-22 09:17:04 +01:00
|
|
|
|
|
|
|
|
echo "</table>";
|
2016-03-17 01:48:42 +01:00
|
|
|
echo "</form>";
|
2016-03-04 03:01:58 +01:00
|
|
|
|
|
|
|
|
if (strlen($paging_controls) > 0) {
|
|
|
|
|
echo "<center>".$paging_controls."</center>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "<br><br>\n";
|
2012-06-04 16:58:40 +02:00
|
|
|
|
2016-03-17 01:48:42 +01:00
|
|
|
// check or uncheck all checkboxes
|
|
|
|
|
if (sizeof($ext_ids) > 0) {
|
|
|
|
|
echo "<script>\n";
|
|
|
|
|
echo " function check(what) {\n";
|
|
|
|
|
foreach ($ext_ids as $ext_id) {
|
|
|
|
|
echo "document.getElementById('".$ext_id."').checked = (what == 'all') ? true : false;\n";
|
|
|
|
|
}
|
|
|
|
|
echo " }\n";
|
|
|
|
|
echo "</script>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2012-06-04 16:58:40 +02:00
|
|
|
//show the footer
|
2013-07-06 08:29:50 +02:00
|
|
|
require_once "resources/footer.php";
|
2012-06-04 16:58:40 +02:00
|
|
|
?>
|