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

Revision 4921, 4.6 kB (checked in by p_lindheimer, 5 years ago)

#2305: Feature status reproting wrong status and inoperative

  • 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     miscapps_add($description, $ext, $dest);
33     needreload();
34     redirect_standard();
35   break;
36   case 'edit':
37     miscapps_edit($miscapp_id, $description, $ext, $dest, $enabled);
38     needreload();
39     redirect_standard('extdisplay');
40   break;
41   case 'delete':
42     miscapps_delete($miscapp_id);
43     needreload();
44     redirect_standard();
45   break;
46 }
47
48
49 ?> 
50 </div>
51
52 <div class="rnav"><ul>
53 <?php 
54
55 echo '<li><a href="config.php?display=miscapps&amp;type=setup">'._('Add Misc. Application').'</a></li>';
56
57 foreach (miscapps_list() as $row) {
58   echo '<li><a href="config.php?display=miscapps&amp;type=setup&amp;extdisplay='.$row['miscapps_id'].'" class="">'.$row['description'].'</a></li>';
59 }
60
61 ?>
62 </ul></div>
63
64 <div class="content">
65
66 <?php
67
68 if ($extdisplay) {
69   // load
70   $row = miscapps_get($extdisplay);
71  
72   $description = $row['description'];
73   $ext = $row['ext'];
74   $dest = $row['dest'];
75   $enabled = $row['enabled'];
76
77 }
78
79 $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.");
80 echo "<p>".$helptext."</p>\n";
81 ?>
82
83 <form name="editMiscapp" action="<?php  $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkMiscapp(editMiscapp);">
84   <input type="hidden" name="extdisplay" value="<?php echo $extdisplay; ?>">
85   <input type="hidden" name="miscapp_id" value="<?php echo $extdisplay; ?>">
86   <input type="hidden" name="action" value="<?php echo ($extdisplay ? 'edit' : 'add'); ?>">
87   <table>
88   <tr><td colspan="2"><h5><?php  echo ($extdisplay ? _("Edit Misc Application") : _("Add Misc Application")) ?><hr></h5></td></tr>
89   <tr>
90     <td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("The name of this application")?></span></a></td>
91     <td><input size="15" type="text" name="description" value="<?php  echo $description; ?>"></td>
92   </tr>
93   <tr>
94     <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>
95     <td><input type="text" name="ext" value="<?php echo $ext; ?>" /></td>
96   </tr>
97   <tr>
98     <td><a href="#" class="info"><?php echo _("Feature Status")?>:<span><?php echo _("If this code is enabled or not.")?></span></a></td>
99     <td><select name="enabled">
100       <option value="1" <?php if ($enabled) echo "SELECTED"; ?>>Enabled</option>
101       <option value="0" <?php if (!$enabled) echo "SELECTED"; ?>>Disabled</option>
102     </select></td>
103   </tr>
104  
105   <tr><td colspan="2"><br><h5><?php echo _("Destination")?>:<hr></h5></td></tr>
106
107 <?php 
108 //draw goto selects
109 echo drawselects($dest,0);
110 ?>
111       
112       <tr>
113       <td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>">
114       <?php if ($extdisplay) { echo '&nbsp;<input name="delete" type="submit" value="'._("Delete").'">'; } ?>
115       </td>   
116       
117       </tr>
118       </table>
119       </form>
120       
121       
122 <script language="javascript">
123 <!--
124
125 function checkMiscapp(theForm) {
126   var msgInvalidDescription = "<?php echo _('Invalid description specified'); ?>";
127
128   // set up the Destination stuff
129   setDestinations(theForm, '_post_dest');
130
131   // form validation
132   defaultEmptyOK = false;
133   if (isEmpty(theForm.description.value))
134     return warnInvalid(theForm.description, msgInvalidDescription);
135
136   if (!validateDestinations(theForm, 1, true))
137     return false;
138
139   return true;
140 }
141 //-->
142 </script>
Note: See TracBrowser for help on using the browser.