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

Revision 5327, 5.5 kB (checked in by p_lindheimer, 4 years ago)

don't show Custom Dest field in miscapps now that there is a customappsreg module

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Rev Date
Line 
1 <?php 
2 /** Misc Applications module for FreePBX 2.2+
3  * Copyright 2006 Greg MacLellan
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 $action = isset($_POST['action']) ? $_POST['action'] :  '';
16 if (isset($_POST['delete'])) $action = 'delete';
17
18
19 $miscapp_id = isset($_POST['miscapp_id']) ? $_POST['miscapp_id'] :  false;
20 $description = isset($_POST['description']) ? $_POST['description'] :  '';
21 $ext = isset($_POST['ext']) ? $_POST['ext'] :  '';
22 $dest = isset($_POST['dest']) ? $_POST['dest'] :  '';
23 $enabled = isset($_POST['enabled']) ? (!empty($_POST['enabled'])) : true;
24
25 if (isset($_POST['goto0']) && $_POST['goto0']) {
26   $dest = $_POST[ $_POST['goto0'].'0' ];
27 }
28
29
30 switch ($action) {
31   case 'add':
32     $conflict_url = array();
33     $usage_arr = framework_check_extension_usage($ext);
34     if (!empty($usage_arr)) {
35       $conflict_url = framework_display_extension_usage_alert($usage_arr);
36     } else {
37       miscapps_add($description, $ext, $dest);
38       needreload();
39       redirect_standard();
40     }
41   break;
42   // TODO: need to lookup the current extension based on the id and if it is changing
43   //       do a check to make sure it doesn't conflict. If not changing, np.
44   //
45   case 'edit':
46     $fc = new featurecode('miscapps', 'miscapp_'.$miscapp_id);
47     $conflict_url = array();
48     if ($fc->getDefault() != $ext) {
49       $usage_arr = framework_check_extension_usage($ext);
50       if (!empty($usage_arr)) {
51         $conflict_url = framework_display_extension_usage_alert($usage_arr);
52       }
53     }
54     if (empty($conflict_url)) {
55       miscapps_edit($miscapp_id, $description, $ext, $dest, $enabled);
56       needreload();
57       redirect_standard('extdisplay');
58     }
59   break;
60   case 'delete':
61     miscapps_delete($miscapp_id);
62     needreload();
63     redirect_standard();
64   break;
65 }
66
67
68 ?> 
69 </div>
70
71 <div class="rnav"><ul>
72 <?php 
73
74 echo '<li><a href="config.php?display=miscapps&amp;type=setup">'._('Add Misc. Application').'</a></li>';
75
76 foreach (miscapps_list() as $row) {
77   echo '<li><a href="config.php?display=miscapps&amp;type=setup&amp;extdisplay='.$row['miscapps_id'].'" class="">'.$row['description'].'</a></li>';
78 }
79
80 ?>
81 </ul></div>
82
83 <div class="content">
84
85 <?php
86
87 if ($extdisplay) {
88   // load
89   $row = miscapps_get($extdisplay);
90  
91   $description = $row['description'];
92   $ext = $row['ext'];
93   $dest = $row['dest'];
94   $enabled = $row['enabled'];
95
96   echo "<h2>"._("Edit Misc Application")."</h2>";
97 } else {
98   echo "<h2>"._("Add MIsc Application")."</h2>";
99 }
100
101 $helptext = _("Misc Applications are for adding feature codes that you can dial from internal phones that go to various destinations available in FreePBX. This is in contrast to the <strong>Misc Destinations</strong> module, which is for creating destinations that can be used by other FreePBX modules to dial internal numbers or feature codes.");
102 echo $helptext;
103 ?>
104
105 <?php if (!empty($conflict_url)) {
106         echo "<h5>"._("Conflicting Extensions")."</h5>";
107         echo implode('<br .>',$conflict_url);
108       }
109 ?>
110
111 <form name="editMiscapp" action="<?php  $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkMiscapp(editMiscapp);">
112   <input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>">
113   <input type="hidden" name="miscapp_id" value="<?php echo $extdisplay; ?>">
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 Application") : _("Add Misc Application")) ?><hr></h5></td></tr>
117   <tr>
118     <td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("The name of this application")?></span></a></td>
119     <td><input size="15" type="text" name="description" value="<?php  echo $description; ?>"></td>
120   </tr>
121   <tr>
122     <td><a href="#" class="info"><?php echo _("Feature Code")?>:<span><?php echo _("The feature code/extension users can dial to access this application. This can also be modified on the Feature Codes page.")?></span></a></td>
123     <td><input type="text" name="ext" value="<?php echo $ext; ?>" /></td>
124   </tr>
125   <tr>
126     <td><a href="#" class="info"><?php echo _("Feature Status")?>:<span><?php echo _("If this code is enabled or not.")?></span></a></td>
127     <td><select name="enabled">
128       <option value="1" <?php if ($enabled) echo "SELECTED"; ?>>Enabled</option>
129       <option value="0" <?php if (!$enabled) echo "SELECTED"; ?>>Disabled</option>
130     </select></td>
131   </tr>
132  
133   <tr><td colspan="2"><br><h5><?php echo _("Destination")?>:<hr></h5></td></tr>
134
135 <?php 
136 //draw goto selects
137 echo drawselects($dest,0);
138 ?>
139       
140       <tr>
141       <td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>">
142       <?php if ($extdisplay) { echo '&nbsp;<input name="delete" type="submit" value="'._("Delete").'">'; } ?>
143       </td>   
144       
145       </tr>
146       </table>
147       </form>
148       
149       
150 <script language="javascript">
151 <!--
152
153 function checkMiscapp(theForm) {
154   var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>";
155
156   // set up the Destination stuff
157   setDestinations(theForm, '_post_dest');
158
159   // form validation
160   defaultEmptyOK = false;
161   if (isEmpty(theForm.description.value))
162     return warnInvalid(theForm.description, msgInvalidDescription);
163
164   if (!validateDestinations(theForm, 1, true))
165     return false;
166
167   return true;
168 }
169 //-->
170 </script>
Note: See TracBrowser for help on using the browser.