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

Revision 5300, 7.2 kB (checked in by p_lindheimer, 4 years ago)

formatting changes

  • 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 $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.");
98
99
100  
101     if ($extdisplay){ ?>
102   <h2><?php echo _("Misc Destination:")." ". $description; ?></h2>
103   <a href="<?php echo $delURL ?>"><?php echo _("Delete Misc Destination")?> '<?php echo $description; ?>'</a>
104
105 <?php
106       $usage_list = framework_display_destination_usage(miscdests_getdest($extdisplay));
107       if (!empty($usage_list)) {
108 ?>
109         <br /><a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a>
110 <?php
111       }
112     } else {
113       echo "<h2>"._("Add Misc Destination")."</h2>";
114       echo $helptext;
115     }
116 ?>
117   <form autocomplete="off" name="editMD" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return editMD_onsubmit();">
118   <input type="hidden" name="display" value="<?php echo $dispnum?>">
119   <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add') ?>">
120   <table>
121   <tr><td colspan="2"><h5><?php echo ($extdisplay ? _("Edit Misc Destination") : _("Add Misc Destination")) ?><hr></h5></td></tr>
122 <?php   if ($extdisplay){ ?>
123     <tr><td><input type="hidden" name="id" value="<?php echo $extdisplay; ?>"></td></tr>
124 <?php   } ?>
125   <tr>
126     <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>
127     <td><input type="text" name="description" value="<?php echo (isset($description) ? $description : ''); ?>"></td>
128   </tr>
129   <tr>
130     <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>
131     <td>
132       <input type="text" name="destdial" value="<?php echo (isset($destdial) ? $destdial : ''); ?>">&nbsp;&nbsp;
133       <?php if (isset($fclist)) { ?>
134       <select id="fc" onchange="fc_onchange();">
135       <option value="">--<?php echo _("featurecode shortcuts"); ?>--</option>
136       <?php
137       foreach ($fclist as $fckey => $fcdesc) {
138         ?>
139         <option value="{<?php echo $fckey; ?>}"><?php echo _($fcdesc); ?></option>
140         <?php
141       }
142       ?>
143       </select>
144       <?php } ?>
145     </td>
146   </tr>
147
148  
149   <tr>
150     <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>"></h6>
151     </td>
152   </tr>
153   </table>
154 <script language="javascript">
155 <!--
156
157 var theForm = document.editMD;
158
159 if (theForm.description.value == "") {
160   theForm.description.focus();
161 } else {
162   theForm.destdial.focus();
163 }
164
165 function editMD_onsubmit()
166 {
167   var msgInvalidDescription = "<?php echo _('Please enter a valid Description'); ?>";
168   var msgInvalidDial = "<?php echo _('Please enter a valid Dial string'); ?>";
169  
170   defaultEmptyOK = false;
171   if (!isAlphanumeric(theForm.description.value))
172     return warnInvalid(theForm.description, msgInvalidDescription);
173
174   // go thru text and remove the {} bits so we only check the actual dial digits
175   var fldText = theForm.destdial.value;
176   var chkText = "";
177  
178   if ( (fldText.indexOf("{") > -1) && (fldText.indexOf("}") > -1) ) { // has one or more sets of {mod:fc}
179    
180     var inbraces = false;
181     for (var i=0; i<fldText.length; i++) {
182       if ( (fldText.charAt(i) == "{") && (inbraces == false) ) {
183         inbraces = true;
184       } else if ( (fldText.charAt(i) == "}") && (inbraces == true) ) {
185         inbraces = false;
186       } else if ( inbraces == false ) {
187         chkText += fldText.charAt(i);
188       }
189     }
190    
191     // if there is nothing in chkText but something in fldText
192     // then the field must contain a featurecode only, therefore
193     // there really is something in thre!
194     if ( (chkText == "") & (fldText != "") )
195       chkText = "0";
196      
197   } else {
198     chkText = fldText;
199   }
200   // now do the check using the chkText var made above
201   if (!isDialDigits(chkText))
202     return warnInvalid(theForm.destdial, msgInvalidDial);
203  
204   return true;
205 }
206
207 function fc_onchange() {
208   theForm.destdial.value = theForm.fc.value;
209   theForm.fc.selectedIndex = 0;
210 }
211 //-->
212 </script>
213   </form>
214 <?php   
215 } //end if action == delGRP
216 ?>
Note: See TracBrowser for help on using the browser.