root/modules/branches/2.10/customappsreg/page.customextens.php

Revision 13091, 6.3 kB (checked in by p_lindheimer, 1 year ago)

adds FREEPBX_IS_AUTH checking to most module files re #5478

Line 
1 <?php
2 if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
3 /** Custom Extensions Display for FreePBX 2.4
4  * Copyright 2006 Philippe Lindheimer - Astrogen LLC
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  */
15
16 $tabindex = 0;
17 $display = 'customextens';
18
19 $type   = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'tool';
20 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
21 if (isset($_REQUEST['delete'])) $action = 'delete';
22
23 $custom_exten = preg_replace("/[^0-9*#]/" ,"", trim($custom_exten));
24
25 $old_custom_exten = isset($_REQUEST['old_custom_exten']) ? preg_replace("/[^0-9*#]/" ,"",$_REQUEST['old_custom_exten']) :  '';
26 $custom_exten     = isset($_REQUEST['extdisplay']) ? preg_replace("/[^0-9*#]/" ,"",$_REQUEST['extdisplay']) :  '';
27 $description     = isset($_REQUEST['description']) ? htmlentities($_REQUEST['description']) :  '';
28 $notes           = isset($_REQUEST['notes']) ? htmlentities($_REQUEST['notes']) :  '';
29
30 switch ($action) {
31     case 'add':
32         $conflict_url = array();
33         $usage_arr = framework_check_extension_usage($custom_exten);
34         if (!empty($usage_arr)) {
35             $conflict_url = framework_display_extension_usage_alert($usage_arr);
36             $custom_exten='';
37         } else {
38             if (customappsreg_customextens_add($custom_exten, $description, $notes)) {
39                 needreload();
40                 redirect_standard();
41             } else {
42                 $custom_exten='';
43             }
44         }
45     break;
46     case 'edit':
47         $conflict_url = array();
48         if ($old_custom_exten != $custom_exten) {
49             $usage_arr = framework_check_extension_usage($custom_exten);
50             if (!empty($usage_arr)) {
51                 $conflict_url = framework_display_extension_usage_alert($usage_arr);
52             }
53         }
54         if (empty($conflict_url)) {
55             if (customappsreg_customextens_edit($old_custom_exten, $custom_exten, $description, $notes)) {
56                 needreload();
57                 redirect_standard('extdisplay');
58             }
59         }
60     break;
61     case 'delete':
62         customappsreg_customextens_delete($custom_exten);
63         needreload();
64         redirect_standard();
65     break;
66 }
67
68 ?> 
69
70 <div class="rnav"><ul>
71 <?php
72
73 echo '<li><a href="config.php?display='.$display.'&amp;type='.$type.'">'._('Add Custom Extension').'</a></li>';
74
75 foreach (customappsreg_customextens_list() as $row) {
76     $descr = $row['description'] != '' ? $row['description'] : '('.$row['custom_exten'].')';
77     echo '<li><a href="config.php?display='.$display.'&amp;type='.$type.'&amp;extdisplay='.$row['custom_exten'].'" class="">'.$descr.'</a></li>';
78 }
79
80 ?>
81 </ul></div>
82
83 <?php
84
85 if ($custom_exten != '') {
86     // load
87     $row = customappsreg_customextens_get($custom_exten);
88     
89     $description = $row['description'];
90     $notes       = $row['notes'];
91
92     $disp_description = $row['description'] != '' ? '('.$row['custom_exten'].') '.$row['description'] : '('.$row['custom_exten'].')';
93     echo "<h2>"._("Edit: ")."$disp_description"."</h2>";
94 } else {
95     echo "<h2>"._("Add Custom Extension")."</h2>";
96 }
97
98 $helptext = _("Custom Extensions provides you with a facility to register any custom extensions or feature codes that you have created in a custom file and FreePBX doesn't otherwise know about them. This allows the Extension Registry to be aware of your own extensions so that it can detect conflicts or report back information about your custom extensions to other modules that may make use of the information. You should not put extensions that you create in the Misc Apps Module as those are not custom.");
99 echo $helptext;
100
101 if (!empty($conflict_url)) {
102     echo "<h5>"._("Conflicting Extensions")."</h5>";
103     echo implode('<br .>',$conflict_url);
104 }
105 ?>
106
107 <form name="editCustomExten" action="<?php  $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkCustomExten(editCustomExten);">
108     <input type="hidden" name="extdisplay" value="<?php echo $custom_exten; ?>">
109     <input type="hidden" name="old_custom_exten" value="<?php echo $custom_exten; ?>">
110     <input type="hidden" name="action" value="<?php echo ($custom_exten != '' ? 'edit' : 'add'); ?>">
111     <table>
112     <tr><td colspan="2"><h5><?php  echo ($custom_exten ? _("Edit Custom Extension") : _("Add Custom Extension")) ?><hr></h5></td></tr>
113     <tr>
114         <td><a href="#" class="info"><?php echo _("Custom Extension")?>:<span><?php echo _("This is the Extension or Feature Code you are using in your dialplan that you want the FreePBX Extension Registry to be aware of.")?></span></a></td>
115         <td><input size="10" type="text" name="extdisplay" id="extdisplay" value="<?php  echo $custom_exten; ?>" tabindex="<?php echo ++$tabindex;?>"></td>
116     </tr>
117
118     <tr>
119         <td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("Brief description that will be published in the Extension Registry about this extension")?></span></a></td>
120         <td><input size="30" type="text" name="description" value="<?php  echo $description; ?>" tabindex="<?php echo ++$tabindex;?>"></td>
121     </tr>
122     <tr>
123         <td valign="top"><a href="#" class="info"><?php echo _("Notes")?>:<span><?php echo _("More detailed notes about this extension to help document it. This field is not used elsewhere.")?></span></a></td>
124         <td><textarea name="notes" cols="23" rows="6" tabindex="<?php echo ++$tabindex;?>"><?php echo $notes; ?></textarea></td>
125     </tr>
126
127     <tr>
128         <td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>">
129         <?php if ($custom_exten != '') { echo '&nbsp;<input name="delete" type="submit" value="'._("Delete").'">'; } ?>
130         </td>       
131     </tr>
132     </table>
133     </form>
134            
135 <script language="javascript">
136 <!--
137
138 function checkCustomExten(theForm) {
139
140     var msgInvalidCustomExten = "<?php echo _('Invalid Extension, must not be blank'); ?>";
141     var msgInvalidDescription = "<?php echo _('Invalid description specified, must not be blank'); ?>";
142
143     // form validation
144     defaultEmptyOK = false;   
145
146     if (isEmpty(theForm.extdisplay.value)) {
147         return warnInvalid(theForm.extdisplay, msgInvalidCustomExten);
148     }
149     if (isEmpty(theForm.description.value)) {
150         return warnInvalid(theForm.description, msgInvalidDescription);
151     }
152
153     return true;
154 }
155 //-->
156 </script>
157
Note: See TracBrowser for help on using the browser.