| 1 |
<?php |
|---|
| 2 |
/* $Id$ */ |
|---|
| 3 |
//Copyright (C) 2006 Rob Thomas (xrobau@gmail.com) |
|---|
| 4 |
// |
|---|
| 5 |
//This program is free software; you can redistribute it and/or |
|---|
| 6 |
//modify it under the terms of version 2 of the GNU General Public |
|---|
| 7 |
//License as published by the Free Software Foundation. |
|---|
| 8 |
// |
|---|
| 9 |
//This program is distributed in the hope that it will be useful, |
|---|
| 10 |
//but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 |
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 |
//GNU General Public License for more details. |
|---|
| 13 |
|
|---|
| 14 |
//Both of these are used for switch on config.php |
|---|
| 15 |
$display = isset($_REQUEST['display'])?$_REQUEST['display']:'paging'; |
|---|
| 16 |
$type = isset($_REQUEST['type'])?$_REQUEST['type']:'tool'; |
|---|
| 17 |
|
|---|
| 18 |
$action = isset($_REQUEST['action'])?$_REQUEST['action']:''; |
|---|
| 19 |
$force_page = isset($_REQUEST['force_page']) ? $_REQUEST['force_page']:0; |
|---|
| 20 |
$selection = isset($_REQUEST['selection'])?$_REQUEST['selection']:''; |
|---|
| 21 |
$pagelist = isset($_REQUEST['pagelist'])?$_REQUEST['pagelist']:''; |
|---|
| 22 |
$pagenbr = isset($_REQUEST['pagenbr'])?$_REQUEST['pagenbr']:''; |
|---|
| 23 |
$pagegrp = isset($_REQUEST['pagegrp'])?$_REQUEST['pagegrp']:''; |
|---|
| 24 |
|
|---|
| 25 |
?> |
|---|
| 26 |
|
|---|
| 27 |
</div> |
|---|
| 28 |
<?php |
|---|
| 29 |
// Check to make sure that the paging database is propogated and |
|---|
| 30 |
// up to date. |
|---|
| 31 |
|
|---|
| 32 |
switch ($action) { |
|---|
| 33 |
case "add": |
|---|
| 34 |
paging_sidebar($selection, $type, $display); |
|---|
| 35 |
paging_show(null, $display, $type); |
|---|
| 36 |
break; |
|---|
| 37 |
case "delete": |
|---|
| 38 |
paging_del($selection); |
|---|
| 39 |
redirect_standard(); |
|---|
| 40 |
break; |
|---|
| 41 |
case "modify": |
|---|
| 42 |
paging_sidebar($selection, $type, $display); |
|---|
| 43 |
paging_show($selection, $display, $type); |
|---|
| 44 |
break; |
|---|
| 45 |
case "submit": |
|---|
| 46 |
paging_modify($pagegrp, $pagenbr, $pagelist, $force_page); |
|---|
| 47 |
redirect_standard(); |
|---|
| 48 |
break; |
|---|
| 49 |
default: |
|---|
| 50 |
paging_sidebar($selection, $type, $display); |
|---|
| 51 |
paging_text(); |
|---|
| 52 |
} |
|---|
| 53 |
|
|---|
| 54 |
function paging_text() { |
|---|
| 55 |
?> |
|---|
| 56 |
<p><?php echo _("This module is for specific phones that are capable of Paging or Intercom. This section is for configuring group paging, intercom is configured through <strong>Feature Codes</strong>.<br /><br />The current list of supported phones is GXP-2000 with firmware 1.0.13 or higher, Snom phones with 'recent' firmware, Polycom phones (provisioned to auto answer), Linksys/Sipura phones, and a few various others. Any phone that is always set to auto-answer should also work (such as the console extension if configured).") ?></p> |
|---|
| 57 |
<?php |
|---|
| 58 |
} |
|---|
| 59 |
|
|---|
| 60 |
function paging_show($xtn, $display, $type) { |
|---|
| 61 |
if ($xtn) { |
|---|
| 62 |
$rows = count(paging_get_devs($xtn))+1; |
|---|
| 63 |
if ($rows < 5) |
|---|
| 64 |
$rows = 5; |
|---|
| 65 |
if ($rows > 20) |
|---|
| 66 |
$rows = 20; |
|---|
| 67 |
echo "<a href='".$_SERVER['PHP_SELF']."?type=${type}&display=${display}&action=delete"; |
|---|
| 68 |
echo "&selection=${xtn}'>"._("Delete Group")." $xtn</a>"; |
|---|
| 69 |
} else { |
|---|
| 70 |
$rows = 5; |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
$config = paging_get_pagingconfig($xtn); |
|---|
| 74 |
|
|---|
| 75 |
$force_page = $config['force_page']; |
|---|
| 76 |
|
|---|
| 77 |
echo "<form name='page_edit' action='".$_SERVER['PHP_SELF']."' method='post' onsubmit='return page_edit_onsubmit();'>\n"; |
|---|
| 78 |
echo "<input type='hidden' name='display' value='${display}'>\n"; |
|---|
| 79 |
echo "<input type='hidden' name='type' value='${type}'>\n"; |
|---|
| 80 |
echo "<input type='hidden' name='pagegrp' value='{$xtn}'>\n"; |
|---|
| 81 |
echo "<input type='hidden' name='action' value='submit'>\n"; |
|---|
| 82 |
echo "<table><tr><td colspan=2><h5>"; |
|---|
| 83 |
echo ($xtn)?_("Modify Paging Group"):_("Add Paging Group")."</h5></td></tr>\n"; ?> |
|---|
| 84 |
<tr><td><a href='#' class='info'><?php echo _("Paging Extension") ?><span> |
|---|
| 85 |
<?php echo _("The number users will dial to page this group") ?></span></a></td> |
|---|
| 86 |
<td><input size='5' type='text' name='pagenbr' value='<?php echo $xtn ?>'></td> |
|---|
| 87 |
</tr> |
|---|
| 88 |
<tr><td valign='top'><a href='#' class='info'><?php echo _("extension list:")."<span><br>"._("Select extension(s)to page. If using users and devices mode, this will be the device number to page, potentially confusing if extension numbers and device numbers don't match. Use Ctrl key to select multiple..") ?> |
|---|
| 89 |
<br><br></span></a></td> |
|---|
| 90 |
<td valign="top"> |
|---|
| 91 |
|
|---|
| 92 |
<select multiple="multiple" name="pagelist[]" id="xtnlist" > |
|---|
| 93 |
<?php |
|---|
| 94 |
$selected = paging_get_devs($xtn); |
|---|
| 95 |
if (is_null($selected)) $selected = array(); |
|---|
| 96 |
foreach (core_devices_list() as $device) { |
|---|
| 97 |
echo '<option value="'.$device[0].'" '; |
|---|
| 98 |
if (array_search($device[0], $selected) !== false) echo ' selected="selected" '; |
|---|
| 99 |
echo '>'.$device[0].' - '.$device[1].'</option>'; |
|---|
| 100 |
} |
|---|
| 101 |
?> |
|---|
| 102 |
</select> |
|---|
| 103 |
|
|---|
| 104 |
<br> |
|---|
| 105 |
</td></tr> |
|---|
| 106 |
|
|---|
| 107 |
<tr><td><label for="force_page"><a href='#' class='info'><?php echo _("Force if busy") ?><span> |
|---|
| 108 |
<?php echo _("If selected, will not check if the device is in use before paging it. This means conversations can be interrupted by a page (depending on how the device handles it). This is useful for \"emergency\" paging groups ") ?></span></a></label></td> |
|---|
| 109 |
<td><input type='checkbox' name='force_page' id="force_page" value='1' <?php if ($force_page) { echo 'CHECKED'; } ?>></td> |
|---|
| 110 |
|
|---|
| 111 |
<tr> |
|---|
| 112 |
<td colspan="2"><br><h6><input type="submit" name="Submit" type="button" value="<?php echo _("Submit Changes")?>"></h6></td> |
|---|
| 113 |
</tr> |
|---|
| 114 |
</table> |
|---|
| 115 |
<script language="javascript"> |
|---|
| 116 |
<!-- |
|---|
| 117 |
var theForm = document.page_edit; |
|---|
| 118 |
theForm.pagenbr.focus(); |
|---|
| 119 |
|
|---|
| 120 |
function page_edit_onsubmit() { |
|---|
| 121 |
var msgInvalidPageExt = "<?php echo _('Please enter a valid Paging Extension'); ?>"; |
|---|
| 122 |
var msgInvalidExtList = "<?php echo _('Please select at least one extension'); ?>"; |
|---|
| 123 |
|
|---|
| 124 |
defaultEmptyOK = false; |
|---|
| 125 |
if (!isInteger(theForm.pagenbr.value)) |
|---|
| 126 |
return warnInvalid(theForm.pagenbr, msgInvalidPageExt); |
|---|
| 127 |
|
|---|
| 128 |
var selected = 0; |
|---|
| 129 |
for (var i=0; i < theForm.xtnlist.options.length; i++) { |
|---|
| 130 |
if (theForm.xtnlist.options[i].selected) selected += 1; |
|---|
| 131 |
} |
|---|
| 132 |
if (selected < 1) { |
|---|
| 133 |
theForm.xtnlist.focus(); |
|---|
| 134 |
alert(msgInvalidExtList); |
|---|
| 135 |
return false; |
|---|
| 136 |
} |
|---|
| 137 |
|
|---|
| 138 |
return true; |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
--> |
|---|
| 142 |
</script> |
|---|
| 143 |
</form> |
|---|
| 144 |
<?php |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
function paging_sidebar($selection, $type, $display) { |
|---|
| 148 |
echo "<div class='rnav'><ul>\n"; |
|---|
| 149 |
echo "<li><a id='".($selection==''?'current':'std')."' "; |
|---|
| 150 |
echo "href='config.php?type=${type}&display=${display}&action=add'>"._("Add Paging Group")."</a></li>"; |
|---|
| 151 |
//get the list of paging groups |
|---|
| 152 |
$presults = paging_list(); |
|---|
| 153 |
if ($presults) { |
|---|
| 154 |
foreach ($presults as $grouparr) { |
|---|
| 155 |
$group = $grouparr[0]; |
|---|
| 156 |
echo "<li><a id=\"".($selection==$group ? 'current':'std'); |
|---|
| 157 |
echo "\" href=\"config.php?type=${type}&display="; |
|---|
| 158 |
echo "${display}&selection=${group}&action=modify\">"; |
|---|
| 159 |
echo _("Page Group")." ${group}</a></li>"; |
|---|
| 160 |
} |
|---|
| 161 |
} |
|---|
| 162 |
echo "</ul></div><div class='content'><h2>"._("Paging and Intercom")."</h2>\n"; |
|---|
| 163 |
} |
|---|
| 164 |
?> |
|---|