root/modules/branches/2.3/miscdests/page.miscdests.php

Revision 4169, 7.1 kB (checked in by fool4kate, 5 years ago)

Swapped freePBX to FreePBX

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
Line 
1 <?php /* $Id: $ */
2 //Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
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
15 isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action='';
16 isset($_REQUEST['id'])?$extdisplay = $_REQUEST['id']:$extdisplay='';
17
18 $dispnum = "miscdests"; //used for switch on config.php
19
20 switch ($action) {
21   case "add":
22     miscdests_add($_REQUEST['description'],$_REQUEST['destdial']);
23     needreload();
24     redirect_standard();
25   break;
26   case "delete":
27     miscdests_del($extdisplay);
28     needreload();
29     redirect_standard();
30   break;
31   case "edit":  //just delete and re-add
32     miscdests_update($extdisplay,$_REQUEST['description'],$_REQUEST['destdial']);
33     needreload();
34     redirect_standard('id');
35   break;
36 }
37
38 $miscdests = miscdests_list();
39
40 // Make array of feature code for <SELECT> list
41 $featurecodes = featurecodes_getAllFeaturesDetailed();
42 if (isset($featurecodes)) {
43   foreach ($featurecodes as $item) {
44     $moduledesc =isset($item['moduledescription'])?_($item['moduledescription']):null;
45     $moduleena = ($item['moduleenabled'] == 1 ? true : false);
46     if ($moduleena) {
47       $featureena = ($item['featureenabled'] == 1 ? true : false);
48       if ($featureena) {
49         $featureid = $item['modulename'] . ':' . $item['featurename'];
50         $featuredesc = _($item['featuredescription']);
51         
52         $featurecodedefault = (isset($item['defaultcode']) ? $item['defaultcode'] : '');
53         $featurecodecustom = (isset($item['customcode']) ? $item['customcode'] : '');
54         $featureactualcode = ($featurecodecustom != '' ? $featurecodecustom : $featurecodedefault);
55         
56         $fclist[$featureid] = $featuredesc." ($featureactualcode)";
57       }
58     }
59   }
60   asort($fclist);
61 }
62
63 ?>
64
65 </div>
66
67 <!-- right side menu -->
68 <div class="rnav"><ul>
69     <li><a id="<?php echo ($extdisplay=='' ? 'current':'') ?>" href="config.php?display=<?php echo urlencode($dispnum)?>"><?php echo _("Add Misc Destination")?></a></li>
70 <?php
71 if (isset($miscdests)) {
72   foreach ($miscdests as $miscdest) {
73     echo "<li><a id=\"".($extdisplay==$miscdest[0] ? 'current':'')."\" href=\"config.php?display=".urlencode($dispnum)."&id=".urlencode($miscdest[0])."\">{$miscdest[1]}</a></li>";
74   }
75 }
76 ?>
77 </ul></div>
78
79
80 <div class="content">
81 <?php
82 if ($action == 'delete') {
83   echo '<br><h3>'._("Misc Destination").' '.$extdisplay.' '._("deleted").'!</h3><br><br><br><br><br><br><br><br>';
84 } else {
85   if ($extdisplay){
86     //get details for this meetme
87     $thisMiscDest = miscdests_get($extdisplay);
88     //create variables
89     $description = "";
90     $destdial = "";
91     extract($thisMiscDest);
92   }
93
94   $delURL = $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'].'&action=delete';
95
96
97 echo "<h2>"._("Misc Destinations")."</h2>";
98 echo "<h3>"._("Instructions")."</h3>";
99 $helptext = _("Misc Destinations are for adding destinations that can be used by other FreePBX modules, generally used to route incoming calls. If you want to create feature codes that can be dialed by internal users and go to various destinations, please see the <strong>Misc Applications</strong> module.");
100
101
102  
103     if ($extdisplay){ ?>
104   <h2><?php echo _("Misc Destination:")." ". $description; ?></h2>
105   <p><a href="<?php echo $delURL ?>"><?php echo _("Delete Misc Destination")?> '<?php echo $description; ?>'</a></p>
106 <?php   } else {
107       echo "<h2>"._("Misc Destinations")."</h2>";
108       echo "<p>".$helptext."</p>\n"; ?>
109   <h2><?php echo _("Add Misc Destination"); ?></h2>
110 <?php   }
111 ?>
112   <form autocomplete="off" name="editMD" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return editMD_onsubmit();">
113   <input type="hidden" name="display" value="<?php echo $dispnum?>">
114   <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add') ?>">
115   <table>
116   <tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit Misc Destination") : _("Add Misc Destination")) ?><hr></h5></td></tr>
117 <?php   if ($extdisplay){ ?>
118     <tr><td><input type="hidden" name="id" value="<?php echo $extdisplay; ?>"></td></tr>
119 <?php   } ?>
120   <tr>
121     <td><a href="#" class="info"><?php echo _("description:")?><span><?php echo _("Give this Misc Destination a brief name to help you identify it.")?></span></a></td>
122     <td><input type="text" name="description" value="<?php echo (isset($description) ? $description : ''); ?>"></td>
123   </tr>
124   <tr>
125     <td><a href="#" class="info"><?php echo _("dial:")?><span><?php echo _("Enter the number this destination will simulate dialing, exactly as you would dial it from an internal phone. When you route a call to this destination, it will be as if the caller dialed this number from an internal phone.") ?></span></a></td>
126     <td>
127       <input type="text" name="destdial" value="<?php echo (isset($destdial) ? $destdial : ''); ?>">&nbsp;&nbsp;
128       <?php if (isset($fclist)) { ?>
129       <select id="fc" onchange="fc_onchange();">
130       <option value="">--<?php echo _("featurecode shortcuts"); ?>--</option>
131       <?php
132       foreach ($fclist as $fckey => $fcdesc) {
133         ?>
134         <option value="{<?php echo $fckey; ?>}"><?php echo _($fcdesc); ?></option>
135         <?php
136       }
137       ?>
138       </select>
139       <?php } ?>
140     </td>
141   </tr>
142
143  
144   <tr>
145     <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6>
146     </td>
147   </tr>
148   </table>
149 <script language="javascript">
150 <!--
151
152 var theForm = document.editMD;
153
154 if (theForm.description.value == "") {
155   theForm.description.focus();
156 } else {
157   theForm.destdial.focus();
158 }
159
160 function editMD_onsubmit()
161 {
162   var msgInvalidDescription = "<?php echo _('Please enter a valid Description'); ?>";
163   var msgInvalidDial = "<?php echo _('Please enter a valid Dial string'); ?>";
164  
165   defaultEmptyOK = false;
166   if (!isAlphanumeric(theForm.description.value))
167     return warnInvalid(theForm.description, msgInvalidDescription);
168
169   // go thru text and remove the {} bits so we only check the actual dial digits
170   var fldText = theForm.destdial.value;
171   var chkText = "";
172  
173   if ( (fldText.indexOf("{") > -1) && (fldText.indexOf("}") > -1) ) { // has one or more sets of {mod:fc}
174    
175     var inbraces = false;
176     for (var i=0; i<fldText.length; i++) {
177       if ( (fldText.charAt(i) == "{") && (inbraces == false) ) {
178         inbraces = true;
179       } else if ( (fldText.charAt(i) == "}") && (inbraces == true) ) {
180         inbraces = false;
181       } else if ( inbraces == false ) {
182         chkText += fldText.charAt(i);
183       }
184     }
185    
186     // if there is nothing in chkText but something in fldText
187     // then the field must contain a featurecode only, therefore
188     // there really is something in thre!
189     if ( (chkText == "") & (fldText != "") )
190       chkText = "0";
191      
192   } else {
193     chkText = fldText;
194   }
195   // now do the check using the chkText var made above
196   if (!isDialDigits(chkText))
197     return warnInvalid(theForm.destdial, msgInvalidDial);
198  
199   return true;
200 }
201
202 function fc_onchange() {
203   theForm.destdial.value = theForm.fc.value;
204   theForm.fc.selectedIndex = 0;
205 }
206 //-->
207 </script>
208   </form>
209 <?php   
210 } //end if action == delGRP
211 ?>
Note: See TracBrowser for help on using the browser.