root/modules/branches/2.5/vmblast/page.vmblast.php

Revision 5919, 10.9 kB (checked in by mbrevda, 5 years ago)

#2845 add tabindex to all items except those called via drawlistmenu or drawselect or other hooks. also missed page.routing.php

Line 
1 <?php
2 //This program is free software; you can redistribute it and/or
3 //modify it under the terms of the GNU General Public License
4 //as published by the Free Software Foundation; either version 2
5 //of the License, or (at your option) any later version.
6 //
7 //This program is distributed in the hope that it will be useful,
8 //but WITHOUT ANY WARRANTY; without even the implied warranty of
9 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 //GNU General Public License for more details.
11
12 $dispnum = 'vmblast'; //used for switch on config.php
13
14 $action         = isset($_REQUEST['action'])        ? $_REQUEST['action']      : '';
15
16 //the extension we are currently displaying
17 $account        = isset($_REQUEST['account'])       ? $_REQUEST['account']     : '';
18 $extdisplay     = isset($_REQUEST['extdisplay'])    ? $_REQUEST['extdisplay']  : (($account != '')?'GRP-'.$account:'');
19 $description    = isset($_REQUEST['description'])   ? $_REQUEST['description'] : '';
20 $audio_label    = isset($_REQUEST['audio_label'])   ? $_REQUEST['audio_label'] : -1;
21 $password       = isset($_REQUEST['password'])      ? $_REQUEST['password']    : '';
22 $default_group  = isset($_REQUEST['default_group']) ? $_REQUEST['default_group'] : '0';
23 $vmblast_list   = isset($_REQUEST['vmblast_list'])  ? $_REQUEST['vmblast_list']  : '';
24
25 // do if we are submitting a form
26 if(isset($_REQUEST['action'])){
27     //check if the extension is within range for this user
28     if (isset($account) && !checkRange($account)){
29         echo "<script>javascript:alert('". _("Warning! Extension")." ".$account." "._("is not allowed for your account").".');</script>";
30     } else {
31         //add group
32         if ($action == 'addGRP') {
33
34             $conflict_url = array();
35             $usage_arr = framework_check_extension_usage($account);
36             if (!empty($usage_arr)) {
37                 $conflict_url = framework_display_extension_usage_alert($usage_arr);
38             } else if (vmblast_add($account,$vmblast_list,$description,$audio_label,$password,$default_group)) {
39                 $_REQUEST['action'] = 'delGRP';
40                 needreload();
41                 redirect_standard('extdisplay');
42             }
43         }
44         
45         //del group
46         if ($action == 'delGRP') {
47             vmblast_del($account);
48             needreload();
49             redirect_standard();
50         }
51         
52         //edit group - just delete and then re-add the extension
53         if ($action == 'editGRP') {
54             vmblast_del($account);   
55             vmblast_add($account,$vmblast_list,$description,$audio_label,$password,$default_group);
56             needreload();
57             redirect_standard('extdisplay');
58         }
59     }
60 }
61 ?>
62 </div>
63
64 <div class="rnav"><ul>
65     <li><a id="<?php  echo ($extdisplay=='' ? 'current':'') ?>" href="config.php?display=<?php echo urlencode($dispnum)?>"><?php echo _("Add VMBlast Group")?></a></li> <?php
66 //get unique ring groups
67 $gresults = vmblast_list();
68
69 if (isset($gresults)) {
70     foreach ($gresults as $gresult) {
71         echo "<li><a id=\"".($extdisplay=='GRP-'.$gresult[0] ? 'current':'')."\" href=\"config.php?display=".urlencode($dispnum)."&extdisplay=".urlencode("GRP-".$gresult[0])."\">".$gresult[1]." ({$gresult[0]})</a></li>";
72     }
73 }
74 ?>
75 </ul></div>
76
77 <div class="content">
78 <?php
79 if ($action == 'delGRP') {
80     echo '<br><h3>'._("VMBlast Group").' '.$account.' '._("deleted").'!</h3><br><br><br><br><br><br><br><br>';
81 } else {
82     if ($extdisplay) {
83         // We need to populate grplist with the existing extension list.
84         $thisgrp = vmblast_get(ltrim($extdisplay,'GRP-'));
85         $grplist     = $thisgrp['grplist'];
86         $description = $thisgrp['description'];
87         $audio_label = $thisgrp['audio_label'];
88         $password    = $thisgrp['password'];
89         $default_group = $thisgrp['default_group'];
90         unset($thisgrp);
91         
92         $delButton = "
93             <form name=delete action=\"{$_SERVER['PHP_SELF']}\" method=POST>
94                 <input type=\"hidden\" name=\"display\" value=\"{$dispnum}\">
95                 <input type=\"hidden\" name=\"account\" value=\"".ltrim($extdisplay,'GRP-')."\">
96                 <input type=\"hidden\" name=\"action\" value=\"delGRP\">
97                 <input type=submit value=\""._("Delete Group")."\">
98             </form>";
99             
100         echo "<h2>"._("VMBlast Group").": ".ltrim($extdisplay,'GRP-')."</h2>";
101         echo "<p>".$delButton."</p>";
102
103         $usage_list = framework_display_destination_usage(vmblast_getdest(ltrim($extdisplay,'GRP-')));
104         if (!empty($usage_list)) {
105         ?>
106             <a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a>
107         <?php
108         }
109
110     } else {
111         $grplist = array();
112         $strategy = '';
113         $ringing = '';
114
115         if (!empty($conflict_url)) {
116             echo "<h5>"._("Conflicting Extensions")."</h5>";
117             echo implode('<br .>',$conflict_url);
118         }
119         echo "<h2>"._("Add VMBlast Group")."</h2>";
120     }
121     ?>
122             <form name="editGRP" action="<?php  $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkGRP(editGRP);">
123             <input type="hidden" name="display" value="<?php echo $dispnum?>">
124             <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'editGRP' : 'addGRP'); ?>">
125             <table>
126             <tr>
127                 <td colspan="2"><h5><?php  echo ($extdisplay ? _("Edit VMBlast Group") : _("Add VMBlast Group")) ?><hr></h5>
128                 </td>
129             </tr>
130             <tr>
131 <?php
132                 if ($extdisplay) {
133
134 ?>
135                 <input size="5" type="hidden" name="account" value="<?php  echo ltrim($extdisplay,'GRP-'); ?>" tabindex="<?php echo ++$tabindex;?>">
136 <?php     } else { ?>
137                 <td><a href="#" class="info"><?php echo _("VMBlast Number")?>:<span><?php echo _("The number users will dial to voicemail boxes in this VMBlast group")?></span></a></td>
138                 <td><input size="5" type="text" name="account" value="<?php  if ($gresult[0]==0) { echo "500"; } else { echo $gresult[0] + 1; } ?>" tabindex="<?php echo ++$tabindex;?>"></td>
139 <?php         } ?>
140             </tr>
141
142             <tr>
143                 <td> <a href="#" class="info"><?php echo _("Group Description:")?>:<span><?php echo _("Provide a descriptive title for this VMBlast Group.")?></span></a></td>
144                 <td><input size="20" maxlength="35" type="text" name="description" value="<?php echo htmlspecialchars($description); ?>" tabindex="<?php echo ++$tabindex;?>"></td>
145             </tr>
146
147 <?php if(function_exists('recordings_list')) { //only include if recordings is enabled?>
148             <tr>
149                 <td><a href="#" class="info"><?php echo _("Audio Label:")?><span><?php echo _("Play this message to the caller so they can confirm they have dialed the proper voice mail group number, or have the system simply read the group number.")?></span></a></td>
150                 <td>
151                     <select name="audio_label" tabindex="<?php echo ++$tabindex;?>"/>
152                     <?php
153                         $tresults = recordings_list();
154                         $default = (isset($audio_label) ? $audio_label : -1);
155                         echo '<option value="-1">'._("Read Group Number")."</option>";
156                         echo '<option value="-2"'.(($default == -2) ? ' SELECTED':'').'>'._("Beep Only - No Confirmation")."</option>";
157                         if (isset($tresults[0])) {
158                             foreach ($tresults as $tresult) {
159                                 echo '<option value="'.$tresult[0].'"'.($tresult[0] == $default ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n";
160                             }
161                         }
162                     ?>       
163                     </select>       
164                 </td>
165             </tr>
166 <?php }    else { ?>
167             <tr>
168                 <td><a href="#" class="info"><?php echo _("Audio Label:")?><span><?php echo _("The group number will be played to the caller so they can confirm they have dialed the proper voice mail group number.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option and choose from recordings.")?></span></a></td>
169                 <td>
170                     <?php
171                         $default = (isset($audio_label) ? $audio_label : -1);
172                     ?>
173                     <input type="hidden" name="audio_label" value="<?php echo $default; ?>"><?php echo ($default != -1 ? $default : _('Read Group Number')); ?>
174                 </td>
175             </tr>
176 <?php }
177 ?>
178             <tr>
179                 <td><a href="#" class="info"><?php echo _("Optional Password")?>:<span><?php echo _('You can optionally include a password to authenticate before providing access to this group voicemail list.')?></span></a></td>
180                 <td><input size="12" type="text" name="password" value="<?php  echo $password ?>" tabindex="<?php echo ++$tabindex;?>">
181                 </td>
182             </tr>
183
184             <tr>
185                 <td valign='top'><a href='#' class='info'><?php echo _("Voicemail Box List:")."<span><br>"._("Select voice mail boxes to add to this group. Use Ctrl key to select multiple..") ?>
186     <br><br></span></a>
187                 </td>
188                 <td valign="top">
189                     <select multiple="multiple" name="vmblast_list[]" id="xtnlist"  tabindex="<?php echo ++$tabindex;?>">
190                         <?php
191                         $results = core_users_list();
192                         if (!is_array($results)) $results = array();
193                         foreach ($results as $result) {
194                             if ($result[2] != 'novm') {
195                                 echo '<option value="'.$result[0].'" ';
196                                 if (array_search($result[0], $grplist) !== false) echo ' selected="selected" ';
197                                 echo '>'.$result[0].' ('.$result[1].')</option>';
198                             }
199                         }
200                         ?>
201                     </select>
202                 <br>
203                 </td>
204             </tr>
205
206             <tr>
207                 <td>
208                     <a href='#' class='info'><?php echo _("Default VMBlast Group") ?>
209                         <span> <?php echo _("Each PBX system can have a single Default Voicemail Blast Group. If specified, extensions can be automatically added (or removed) from this default group in the Extensions (or Users) tab.<br />Making this group the default will uncheck the option from the current default group if specified.") ?> </span>
210                     </a>
211                 </td>
212                 <td>
213                     <input type='checkbox' name='default_group' id="default_group" value='1' <?php if ($default_group) { echo 'CHECKED'; } ?> tabindex="<?php echo ++$tabindex;?>">
214                 </td>
215             </tr>
216
217 <?php
218             // implementation of module hook
219             // object was initialized in config.php
220             echo $module_hook->hookHtml;
221 ?>
222             <tr>
223             <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>"></h6></td>       
224            
225             </tr>
226             </table>
227             </form>
228 <?php         
229         } //end if action == delGRP
230         
231
232 ?>
233 <script language="javascript">
234 <!--
235
236 function checkGRP(theForm) {
237     var msgInvalidGrpNum = "<?php echo _('Invalid Group Number specified'); ?>";
238     var msgInvalidGrpNumStartWithZero = "<?php echo _('Group numbers with more than one digit cannot begin with 0'); ?>";
239     var msgInvalidExtList = "<?php echo _('Please enter an extension list.'); ?>";
240     var msgInvalidDescription = "<?php echo _('Please enter a valid Group Description'); ?>";
241     var msgInvalidPassword = "<?php echo _('Please enter a valid numeric password, only numbers are allowed'); ?>";
242     var msgInvalidExtList = "<?php echo _('Please select at least one extension'); ?>";
243
244     // form validation
245     defaultEmptyOK = false;
246     if (!isInteger(theForm.account.value)) {
247         return warnInvalid(theForm.account, msgInvalidGrpNum);
248     } else if (theForm.account.value.indexOf('0') == 0 && theForm.account.value.length > 1) {
249         return warnInvalid(theForm.account, msgInvalidGrpNumStartWithZero);
250     }
251
252     defaultEmptyOK = true;
253     if (!isInteger(theForm.password.value))
254         return warnInvalid(theForm.password, msgInvalidPassword);
255    
256     defaultEmptyOK = false;   
257     if (!isAlphanumeric(theForm.description.value))
258         return warnInvalid(theForm.description, msgInvalidDescription);
259    
260     var selected = 0;
261     for (var i=0; i < theForm.xtnlist.options.length; i++) {
262         if (theForm.xtnlist.options[i].selected) selected += 1;
263     }
264     if (selected < 1) {
265     theForm.xtnlist.focus();
266         alert(msgInvalidExtList);
267         return false;
268     }
269
270     return true;       
271 }
272
273 //-->
274 </script>
275
276
Note: See TracBrowser for help on using the browser.