root/modules/branches/2.2/paging/page.paging.php

Revision 3217, 6.2 kB (checked in by gregmac, 6 years ago)

Added a check to not page devices that are in use, as well as option to override. Dropped old paging_config table, and re-purposed it.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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 paging_init();
32
33 switch ($action) {
34     case "add":
35         paging_sidebar($selection, $type, $display);
36         paging_show(null, $display, $type);
37         break;
38     case "delete":
39         paging_del($selection);
40         redirect_standard();
41         break;
42     case "modify":
43         paging_sidebar($selection, $type, $display);
44         paging_show($selection, $display, $type);
45         break;
46     case "submit":
47         paging_modify($pagegrp, $pagenbr, $pagelist, $force_page);
48         redirect_standard();
49         break;
50     default:
51         paging_sidebar($selection, $type, $display);
52         paging_text();
53 }
54
55 function paging_text() {
56 ?>
57 <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>
58 <?php
59 }
60
61 function paging_show($xtn, $display, $type) {
62     if ($xtn) {
63         $rows = count(paging_get_devs($xtn))+1;
64         if ($rows < 5)
65             $rows = 5;
66         if ($rows > 20)
67             $rows = 20;
68         echo "<p><a href='".$_SERVER['PHP_SELF']."?type=${type}&amp;display=${display}&amp;action=delete";
69         echo "&amp;selection=${xtn}'>"._("Delete Group")." $xtn</a></p>";
70     } else {
71         $rows = 5;
72     }
73     
74     $config = paging_get_pagingconfig($xtn);
75     
76     $force_page = $config['force_page'];
77     
78     echo "<form name='page_edit' action='".$_SERVER['PHP_SELF']."' method='post' onsubmit='return page_edit_onsubmit();'>\n";
79     echo "<input type='hidden' name='display' value='${display}'>\n";
80     echo "<input type='hidden' name='type' value='${type}'>\n";
81     echo "<input type='hidden' name='pagegrp' value='{$xtn}'>\n";
82     echo "<input type='hidden' name='action' value='submit'>\n";
83     echo "<table><tr><td colspan=2><h5>";
84     echo ($xtn)?_("Modify Paging Group"):_("Add Paging Group")."</h5></td></tr>\n"?>
85     <tr><td><a href='#' class='info'><?php echo _("Paging Extension") ?><span>
86     <?php echo _("The number users will dial to page this group") ?></span></a></td>
87     <td><input size='5' type='text' name='pagenbr' value='<?php echo $xtn ?>'></td>
88     </tr>
89     <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..") ?>
90     <br><br></span></a></td>
91     <td valign="top">
92    
93     <select multiple="multiple" name="pagelist[]" id="xtnlist" >
94     <?php
95     $selected = paging_get_devs($xtn);
96     if (is_null($selected)) $selected = array();
97     foreach (core_devices_list() as $device) {
98         echo '<option value="'.$device[0].'" ';
99         if (array_search($device[0], $selected) !== false) echo ' selected="selected" ';
100         echo '>'.$device[0].' - '.$device[1].'</option>';
101     }
102     ?>
103     </select>
104        
105         <br>
106     </td></tr>
107
108     <tr><td><label for="force_page"><a href='#' class='info'><?php echo _("Force if busy") ?><span>
109     <?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>
110     <td><input type='checkbox' name='force_page' id="force_page" value='1' <?php if ($force_page) { echo 'CHECKED'; } ?>></td>
111    
112     <tr>
113     <td colspan="2"><br><h6><input type="submit" name="Submit" type="button" value="<?php echo _("Submit Changes")?>"></h6></td>
114     </tr>
115     </table>
116 <script language="javascript">
117 <!--
118 var theForm = document.page_edit;
119 theForm.pagenbr.focus();
120
121 function page_edit_onsubmit() {
122     var msgInvalidPageExt = "<?php echo _('Please enter a valid Paging Extension'); ?>";
123     var msgInvalidExtList = "<?php echo _('Please select at least one extension'); ?>";
124
125     defaultEmptyOK = false;
126     if (!isInteger(theForm.pagenbr.value))
127         return warnInvalid(theForm.pagenbr, msgInvalidPageExt);
128    
129     var selected = 0;
130     for (var i=0; i < theForm.xtnlist.options.length; i++) {
131         if (theForm.xtnlist.options[i].checked) selected += 1;
132     }
133     if (selected < 1) {
134         return warnInvalid(theForm.xtnlist, msgInvalidExtList);
135     }
136        
137     return true;
138 }
139
140 -->
141 </script>
142     </form>
143 <?php
144 }
145
146 function paging_sidebar($selection, $type, $display) {
147     echo "<div class='rnav'><ul>\n";
148     echo "<li><a id='".($selection==''?'current':'std')."' ";
149     echo "href='config.php?type=${type}&amp;display=${display}&amp;action=add'>"._("Add Paging Group")."</a></li>";
150     //get the list of paging groups
151     $presults = paging_list();
152     if ($presults) {
153         foreach ($presults as $grouparr) {
154             $group = $grouparr[0];
155             echo "<li><a id=\"".($selection==$group ? 'current':'std');
156             echo "\" href=\"config.php?type=${type}&amp;display=";
157             echo "${display}&amp;selection=${group}&amp;action=modify\">";
158             echo _("Page Group")." ${group}</a></li>";
159         }
160     }
161     echo "</ul></div><div class='content'><h2>"._("Paging and Intercom")."</h2>\n";
162 }
163 ?>
164
Note: See TracBrowser for help on using the browser.