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

Revision 5919, 19.6 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

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
1 <?php /* $Id: page.findmefollow.php 1197 2006-03-19 17:59:02Z mheydon1973 $ */
2 //Copyright (C) 2006 Philippe Lindheimer (p_lindheimer at yahoo dot com)
3 //
4 //This program is free software; you can redistribute it and/or
5 //modify it under the terms of the GNU General Public License
6 //as published by the Free Software Foundation; either version 2
7 //of the License, or (at your option) any later version.
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 $dispnum = 'findmefollow'; //used for switch on config.php
15
16 isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action='';
17 //the extension we are currently displaying
18 isset($_REQUEST['extdisplay'])?$extdisplay=$_REQUEST['extdisplay']:$extdisplay='';
19 isset($_REQUEST['account'])?$account = $_REQUEST['account']:$account='';
20 isset($_REQUEST['grptime'])?$grptime = $_REQUEST['grptime']:$grptime='';
21 isset($_REQUEST['grppre'])?$grppre = $_REQUEST['grppre']:$grppre='';
22 isset($_REQUEST['strategy'])?$strategy = $_REQUEST['strategy']:$strategy='';
23 isset($_REQUEST['annmsg'])?$annmsg = $_REQUEST['annmsg']:$annmsg='';
24 isset($_REQUEST['dring'])?$dring = $_REQUEST['dring']:$dring='';
25 isset($_REQUEST['needsconf'])?$needsconf = $_REQUEST['needsconf']:$needsconf='';
26 isset($_REQUEST['remotealert'])?$remotealert = $_REQUEST['remotealert']:$remotealert='';
27 isset($_REQUEST['toolate'])?$toolate = $_REQUEST['toolate']:$toolate='';
28 isset($_REQUEST['ringing'])?$ringing = $_REQUEST['ringing']:$ringing='';
29 isset($_REQUEST['pre_ring'])?$pre_ring = $_REQUEST['pre_ring']:$pre_ring='0';
30 isset($_REQUEST['ddial'])?$ddial = $_REQUEST['ddial']:$ddial='';
31
32
33 if (isset($_REQUEST['goto0']) && isset($_REQUEST[$_REQUEST['goto0']."0"])) {
34         $goto = $_REQUEST[$_REQUEST['goto0']."0"];
35 } else {
36         $goto = '';
37 }
38
39
40 if (isset($_REQUEST["grplist"])) {
41   $grplist = explode("\n",$_REQUEST["grplist"]);
42
43   if (!$grplist) {
44     $grplist = null;
45   }
46  
47   foreach (array_keys($grplist) as $key) {
48     //trim it
49     $grplist[$key] = trim($grplist[$key]);
50     
51     // remove invalid chars
52     $grplist[$key] = preg_replace("/[^0-9#*]/", "", $grplist[$key]);
53
54     if ($grplist[$key] == ltrim($extdisplay,'GRP-').'#')
55       $grplist[$key] = rtrim($grplist[$key],'#');
56     
57     // remove blanks
58     if ($grplist[$key] == "") unset($grplist[$key]);
59   }
60  
61   // check for duplicates, and re-sequence
62   $grplist = array_values(array_unique($grplist));
63 }
64
65 // do if we are submitting a form
66 if(isset($_POST['action'])){
67   //check if the extension is within range for this user
68   if (isset($account) && !checkRange($account)){
69     echo "<script>javascript:alert('". _("Warning! Extension")." ".$account." "._("is not allowed for your account").".');</script>";
70   } else {
71     //add group
72     if ($action == 'addGRP') {
73       findmefollow_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$grppre,$annmsg,$dring,$needsconf,$remotealert,$toolate,$ringing,$pre_ring,$ddial);
74
75       needreload();
76       redirect_standard();
77     }
78     
79     //del group
80     if ($action == 'delGRP') {
81       findmefollow_del($account);
82       needreload();
83       redirect_standard();
84     }
85     
86     //edit group - just delete and then re-add the extension
87     if ($action == 'edtGRP') {
88       findmefollow_del($account);
89       findmefollow_add($account,$strategy,$grptime,implode("-",$grplist),$goto,$grppre,$annmsg,$dring,$needsconf,$remotealert,$toolate,$ringing,$pre_ring,$ddial);
90
91       needreload();
92       redirect_standard('extdisplay');
93     }
94   }
95 }
96 ?>
97 </div>
98
99 <div class="rnav"><ul>
100 <?php
101 //get unique ring groups
102 $gresults = findmefollow_allusers();
103 $set_users = findmefollow_list();
104
105 if (isset($gresults)) {
106   foreach ($gresults as $gresult) {
107     $defined = is_array($set_users) ? (in_array($gresult[0], $set_users) ? "(edit)" : "(add)") : "add";
108                 echo "<li><a id=\"".($extdisplay=='GRP-'.$gresult[0] ? 'current':'')."\" href=\"config.php?display=".urlencode($dispnum)."&extdisplay=".urlencode("GRP-".$gresult[0])."\">"._("$gresult[1]")." <{$gresult[0]}> $defined  </a></li>";
109
110   }
111 }
112 ?>
113 </ul></div>
114
115 <div class="content">
116 <?php
117
118 if (!$extdisplay) {
119   echo '<br><h2>'._("Follow Me").'</h2><br><h3>'._('Choose a user/extension:').'</h3><br><br><br><br><br><br><br>';
120   }
121 elseif ($action == 'delGRP') {
122   echo '<br><h3>'._("Follow Me").' '.$account.' '._("deleted").'!</h3><br><br><br><br><br><br><br><br>';
123 } else {
124   if ($extdisplay) {
125     // We need to populate grplist with the existing extension list.
126     $thisgrp = findmefollow_get(ltrim($extdisplay,'GRP-'), 1);
127     $grpliststr = isset($thisgrp['grplist']) ? $thisgrp['grplist'] : '';
128     $grplist = explode("-", $grpliststr);
129
130     $strategy    = isset($thisgrp['strategy'])    ? $thisgrp['strategy']    : '';
131     $grppre      = isset($thisgrp['grppre'])      ? $thisgrp['grppre']      : '';
132     $grptime     = isset($thisgrp['grptime'])     ? $thisgrp['grptime']     : '';
133     $goto        = isset($thisgrp['postdest'])    ? $thisgrp['postdest']    : '';
134     $annmsg      = isset($thisgrp['annmsg'])      ? $thisgrp['annmsg']      : '';
135     $dring       = isset($thisgrp['dring'])       ? $thisgrp['dring']       : '';
136     $remotealert = isset($thisgrp['remotealert']) ? $thisgrp['remotealert'] : '';
137     $needsconf   = isset($thisgrp['needsconf'])   ? $thisgrp['needsconf']   : '';
138     $toolate     = isset($thisgrp['toolate'])     ? $thisgrp['toolate']     : '';
139     $ringing     = isset($thisgrp['ringing'])     ? $thisgrp['ringing']     : '';
140     $pre_ring    = isset($thisgrp['pre_ring'])    ? $thisgrp['pre_ring']    : '';
141     $ddial       = isset($thisgrp['ddial'])       ? $thisgrp['ddial']       : '';
142     unset($grpliststr);
143     unset($thisgrp);
144     
145     $delButton = "
146       <form name=delete action=\"{$_SERVER['PHP_SELF']}\" method=POST>
147         <input type=\"hidden\" name=\"display\" value=\"{$dispnum}\">
148         <input type=\"hidden\" name=\"account\" value=\"".ltrim($extdisplay,'GRP-')."\">
149         <input type=\"hidden\" name=\"action\" value=\"delGRP\">
150         <input type=submit value=\""._("Delete Entries")."\">
151       </form>";
152       
153     echo "<h2>"._("Follow Me").": ".ltrim($extdisplay,'GRP-')."</h2>";
154
155
156     // Copied straight out of old code,let's see if it works?
157     //
158     if (isset($amp_conf["AMPEXTENSIONS"]) && ($amp_conf["AMPEXTENSIONS"] == "deviceanduser")) {
159       $editURL = $_SERVER['PHP_SELF'].'?display=users&extdisplay='.ltrim($extdisplay,'GRP-');
160       $EXTorUSER = "User";
161     }
162     else {
163       $editURL = $_SERVER['PHP_SELF'].'?display=extensions&extdisplay='.ltrim($extdisplay,'GRP-');
164       $EXTorUSER = "Extension";
165     }
166
167     echo "<p><a href=".$editURL."> Edit ".$EXTorUSER." ".ltrim($extdisplay,'GRP-')."</a></p>";
168     echo "<p>".$delButton."</p>";
169   }
170   ?>
171       <form name="editGRP" action="<?php  $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkGRP(editGRP);">
172       <input type="hidden" name="display" value="<?php echo $dispnum?>">
173       <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edtGRP' : 'addGRP'); ?>">
174       <table>
175       <tr><td colspan="2"><h5><?php  echo ($extdisplay ? _("Edit Follow Me") : _("Add Follow Me")) ?><hr></h5></td></tr>
176       <tr>
177 <?php
178   if ($extdisplay) {
179
180 ?>
181         <input size="5" type="hidden" name="account" value="<?php  echo ltrim($extdisplay,'GRP-'); ?>">
182 <?php     } else { ?>
183         <td><a href="#" class="info"><?php echo _("group number")?>:<span><?php echo _("The number users will dial to ring extensions in this ring group")?></span></a></td>
184         <td><input size="5" type="text" name="account" value="<?php  echo $gresult[0] + 1; ?>"></td>
185 <?php     } ?>
186       </tr>
187
188       <tr>
189         <td><a href="#" class="info"><?php echo _("Disable")?><span><?php echo _('By default (not checked) any call to this extension will go to this Follow-Me instead, including directory calls by name from IVRs. If checked, calls will go only to the extension.<BR>However, destinations that specify FollowMe will come here.<BR>Checking this box is often used in conjunction with VmX Locater, where you want a call to ring the extension, and then only if the caller chooses to find you do you want it to come here.')?></span></a>:</td>
190         <td><input type="checkbox" name="ddial" value="CHECKED" <?php echo $ddial ?>   tabindex="<?php echo ++$tabindex;?>"/></td>
191       </tr>
192
193       <tr>
194         <td><a href="#" class="info"><?php echo _("Initial Ring Time:")?>
195         <span><?php echo _("This is the number of seconds to ring the primary extension prior to proceeding to the follow-me list. The extension can also be included in the follow-me list. A 0 setting will bypass this.")?>
196         </span></a>
197         </td>
198         <td>
199           <select name="pre_ring" tabindex="<?php echo ++$tabindex;?>">
200           <?php
201             $default = (isset($pre_ring) ? $pre_ring : 0);
202             for ($i=0; $i <= 60; $i++) {
203               echo '<option value="'.$i.'" '.($i == $default ? 'SELECTED' : '').'>'.$i.'</option>';
204             }
205           ?>
206           </select>
207         </td>
208       </tr>
209
210       <tr>
211         <td>
212         <a href="#" class="info"><?php echo _("Ring Strategy:")?>
213         <span>
214           <b><?php echo _("ringallv2")?></b><?php echo _("ring primary extension for initial ring time followed by all additional extensions until one answers")?><br>
215           <b><?php echo _("ringall")?></b><?php echo _("ring all available channels until one answers (default)")?><br>
216           <b><?php echo _("hunt")?></b>: <?php echo _("take turns ringing each available extension")?><br>
217           <b><?php echo _("memoryhunt")?></b>: <?php echo _("ring first extension in the list, then ring the 1st and 2nd extension, then ring 1st 2nd and 3rd extension in the list.... etc.")?><br>
218           <b><?php echo _("*-prim")?></b><?php echo _("these modes act as described above. However, if the primary extension (first in list) is occupied, the other extensions will not be rung. If the primary is freepbx DND, it won't be run. If the primary is freepbx CF unconditional, then all will be rung")?><br>
219           <b><?php echo _("firstavailable")?></b><?php echo _("ring only the first available channel")?><br>
220           <b><?php echo _("firstnotonphone")?></b><?php echo _("ring only the first channel which is not offhook - ignore CW")?><br>
221         </span>
222         </a>
223         </td>
224         <td>
225           <select name="strategy" tabindex="<?php echo ++$tabindex;?>">
226           <?php
227             $default = (isset($strategy) ? $strategy : 'ringall');
228                                                 $items = array('ringallv2','ringallv2-prim','ringall','ringall-prim','hunt','hunt-prim','memoryhunt','memoryhunt-prim','firstavailable','firstnotonphone');
229             foreach ($items as $item) {
230               echo '<option value="'.$item.'" '.($default == $item ? 'SELECTED' : '').'>'._($item);
231             }
232           ?>   
233           </select>
234         </td>
235       </tr>
236
237       <tr>
238         <td>
239           <a href=# class="info"><?php echo _("Ring Time (max 60 sec)")?>
240             <span>
241               <?php echo _("Time in seconds that the phones will ring. For all hunt style ring strategies, this is the time for each iteration of phone(s) that are rung")?>
242             </span>
243           </a>
244         </td>
245         <td><input size="4" type="text" name="grptime" value="<?php  echo $grptime?$grptime:20 ?>" tabindex="<?php echo ++$tabindex;?>"></td>
246       </tr>
247
248       <tr>
249         <td valign="top"><a href="#" class="info"><?php echo _("Follow-Me List")?>:<span><br><?php echo _("List extensions to ring, one per line, or use the Extension Quick Pick below.<br><br>You can include an extension on a remote system, or an external number by suffixing a number with a pound (#).  ex:  2448089# would dial 2448089 on the appropriate trunk (see Outbound Routing).")?><br><br></span></a></td>
250         <td valign="top">
251 <?php
252     $rows = count($grplist)+1;
253     if ($rows <= 2 && trim($grplist[0]) == "") {
254       $grplist[0] = ltrim($extdisplay,'GRP-');
255     }
256     ($rows < 5) ? 5 : (($rows > 20) ? 20 : $rows);
257 ?>
258           <textarea id="grplist" cols="15" rows="<?php  echo $rows ?>" name="grplist" tabindex="<?php echo ++$tabindex;?>"><?php echo implode("\n",$grplist);?></textarea>
259         </td>
260       </tr>
261
262       <tr>
263         <td>
264         <a href=# class="info"><?php echo _("Extension Quick Pick")?>
265           <span>
266             <?php echo _("Choose an extension to append to the end of the extension list above.")?>
267           </span>
268         </a>
269         </td>
270         <td>
271           <select onChange="insertExten();" id="insexten" tabindex="<?php echo ++$tabindex;?>">
272             <option value=""><?php echo _("(pick extension)")?></option>
273   <?php
274             $results = core_users_list();
275             foreach ($results as $result) {
276               echo "<option value='".$result[0]."'>".$result[0]." (".$result[1].")</option>\n";
277             }
278   ?>
279           </select>
280         </td>
281       </tr>
282
283 <?php if(function_exists('recordings_list')) { //only include if recordings is enabled?>
284       <tr>
285         <td><a href="#" class="info"><?php echo _("Announcement:")?><span><?php echo _("Message to be played to the caller before dialing this group.<br><br>To add additional recordings please use the \"System Recordings\" MENU to the left")?></span></a></td>
286         <td>
287           <select name="annmsg" tabindex="<?php echo ++$tabindex;?>">
288           <?php
289             $tresults = recordings_list();
290             $default = (isset($annmsg) ? $annmsg : '');
291             echo '<option value="">'._("None");
292             if (isset($tresults)) {
293               foreach ($tresults as $tresult) {
294                 echo '<option value="'.$tresult[2].'"'.($tresult[2] == $default ? ' SELECTED' : '').'>'.$tresult[1];
295               }
296             }
297           ?>   
298           </select>   
299         </td>
300       </tr>
301 <?php } else { ?>
302       <tr>
303         <td><a href="#" class="info"><?php echo _("Announcement:")?><span><?php echo _("Message to be played to the caller before dialing this group.<br><br>You must install and enable the \"Systems Recordings\" Module to edit this option")?></span></a></td>
304         <td>
305           <?php
306             $default = (isset($annmsg) ? $annmsg : '');
307           ?>
308           <input type="hidden" name="annmsg" value="<?php echo $default; ?>"><?php echo ($default != '' ? $default : 'None'); ?>
309         </td>
310       </tr>
311
312 <?php } if (function_exists('music_list')) { ?>
313       <tr>
314         <td><a href="#" class="info"><?php echo _("Play Music On Hold?")?><span><?php echo _("If you select a Music on Hold class to play, instead of 'Ring', they will hear that instead of Ringing while they are waiting for someone to pick up.")?></span></a></td>
315         <td>
316           <select name="ringing" tabindex="<?php echo ++$tabindex;?>">
317           <?php
318             $tresults = music_list($amp_conf['ASTVARLIBDIR']."/mohmp3");
319             $cur = (isset($ringing) ? $ringing : 'Ring');
320             echo '<option value="Ring">'._("Ring")."</option>";
321             if (isset($tresults[0])) {
322               foreach ($tresults as $tresult) {
323                 echo '<option value="'.$tresult.'"'.($tresult == $cur ? ' SELECTED' : '').'>'.$tresult."</option>\n";
324               }
325             }
326           ?>
327           </select>
328           </td>
329         </tr>
330 <?php } ?>
331
332       <tr>
333         <td><a href="#" class="info"><?php echo _("CID Name Prefix")?>:<span><?php echo _('You can optionally prefix the Caller ID name when ringing extensions in this group. ie: If you prefix with "Sales:", a call from John Doe would display as "Sales:John Doe" on the extensions that ring.')?></span></a></td>
334         <td><input size="4" type="text" name="grppre" value="<?php  echo $grppre ?>" tabindex="<?php echo ++$tabindex;?>"></td>
335       </tr>
336
337       <tr>
338         <td><a href="#" class="info"><?php echo _("Alert Info")?>:<span><?php echo _('You can optionally include an Alert Info which can create distinctive rings on SIP phones.')?></span></a></td>
339         <td><input size="18" type="text" name="dring" value="<?php  echo $dring ?>" tabindex="<?php echo ++$tabindex;?>"></td>
340       </tr>
341
342       <tr>
343         <td><a href="#" class="info"><?php echo _("Confirm Calls")?><span><?php echo _('Enable this if you\'re calling external numbers that need confirmation - eg, a mobile phone may go to voicemail which will pick up the call. Enabling this requires the remote side push 1 on their phone before the call is put through. This feature only works with the ringall/ringall-prim  ring strategy')?></span></a>:</td>
344         <td>
345           <input type="checkbox" name="needsconf" value="CHECKED" <?php echo $needsconf ?>   tabindex="<?php echo ++$tabindex;?>"/>
346         </td>
347       </tr>
348
349 <?php if(function_exists('recordings_list')) { //only include if recordings is enabled?>
350       <tr>
351         <td><a href="#" class="info"><?php echo _("Remote Announce:")?><span><?php echo _("Message to be played to the person RECEIVING the call, if 'Confirm Calls' is enabled.<br><br>To add additional recordings use the \"System Recordings\" MENU to the left")?></span></a></td>
352         <td>
353           <select name="remotealert" tabindex="<?php echo ++$tabindex;?>">
354           <?php
355             $tresults = recordings_list();
356             $default = (isset($remotealert) ? $remotealert : '');
357             echo '<option value="">'._("Default")."</option>";
358             if (isset($tresults[0])) {
359               foreach ($tresults as $tresult) {
360                 echo '<option value="'.$tresult[2].'"'.($tresult[2] == $default ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n";
361               }
362             }
363           ?>
364           </select>
365         </td>
366       </tr>
367       <tr>
368         <td><a href="#" class="info"><?php echo _("Too-Late Announce:")?><span><?php echo _("Message to be played to the person RECEIVING the call, if the call has already been accepted before they push 1.<br><br>To add additional recordings use the \"System Recordings\" MENU to the left")?></span></a></td>
369         <td>
370         <select name="toolate" tabindex="<?php echo ++$tabindex;?>">
371           <?php
372             $tresults = recordings_list();
373             $default = (isset($toolate) ? $toolate : '');
374             echo '<option value="">'._("Default")."</option>";
375             if (isset($tresults[0])) {
376               foreach ($tresults as $tresult) {
377                 echo '<option value="'.$tresult[2].'"'.($tresult[2] == $default ? ' SELECTED' : '').'>'.$tresult[1]."</option>\n";
378               }
379             }
380           ?>
381           </select>
382         </td>
383       </tr>
384 <?php } ?>
385      
386       <tr><td colspan="2"><br><h5><?php echo _("Destination if no answer")?>:<hr></h5></td></tr>
387
388 <?php
389 //draw goto selects
390 echo drawselects($goto,0);
391 ?>
392      
393       <tr>
394       <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>"></h6></td>   
395      
396       </tr>
397       </table>
398       </form>
399 <?php     
400     } //end if action == delGRP
401     
402 ?>
403 <script language="javascript">
404 <!--
405
406 function insertExten() {
407   exten = document.getElementById('insexten').value;
408
409   grpList=document.getElementById('grplist');
410   if (grpList.value[ grpList.value.length - 1 ] == "\n") {
411     grpList.value = grpList.value + exten;
412   } else {
413     grpList.value = grpList.value + '\n' + exten;
414   }
415
416   // reset element
417   document.getElementById('insexten').value = '';
418 }
419
420 function checkGRP(theForm) {
421   var msgInvalidGrpNum = "<?php echo _('Invalid Group Number specified'); ?>";
422   var msgInvalidExtList = "<?php echo _('Please enter an extension list.'); ?>";
423   var msgInvalidGrpPrefix = "<?php echo _('Invalid prefix. Valid characters: a-z A-Z 0-9 : _ -'); ?>";
424   var msgInvalidTime = "<?php echo _('Invalid time specified'); ?>";
425   var msgInvalidGrpTimeRange = "<?php echo _('Time must be between 1 and 60 seconds'); ?>";
426   var msgInvalidRingStrategy = "<?php echo _('Only ringall, ringallv2, hunt and the respective -prim versions are supported when confirmation is checked'); ?>";
427
428
429
430   // set up the Destination stuff
431   setDestinations(theForm, 1);
432
433   // form validation
434   defaultEmptyOK = false;
435   if (isEmpty(theForm.grplist.value))
436     return warnInvalid(theForm.grplist, msgInvalidExtList);
437
438   defaultEmptyOK = false;
439   if (!isInteger(theForm.grptime.value)) {
440     return warnInvalid(theForm.grptime, msgInvalidTime);
441   } else {
442     var grptimeVal = theForm.grptime.value;
443     if (grptimeVal < 1 || grptimeVal > 60)
444       return warnInvalid(theForm.grptime, msgInvalidGrpTimeRange);
445   }
446
447   if (theForm.needsconf.checked && (theForm.strategy.value.substring(0,7) != "ringall" && theForm.strategy.value.substring(0,4) != "hunt")) {
448     return warnInvalid(theForm.needsconf, msgInvalidRingStrategy);
449   }
450
451   defaultEmptyOK = true;
452   if (!isPrefix(theForm.grppre.value))
453     return warnInvalid(theForm.grppre, msgInvalidGrpPrefix);
454
455   if (!validateDestinations(theForm, 1, true))
456     return false;
457
458   return true;
459 }
460 //-->
461 </script>
Note: See TracBrowser for help on using the browser.