root/freepbx/branches/2.2/amp_conf/htdocs/admin/config.php

Revision 3432, 13.4 kB (checked in by qldrob, 6 years ago)

Remove 'This is beta code' warning from 2.2 branch.

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
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 $title = "freePBX administration";
15
16 $type = isset($_REQUEST['type'])?$_REQUEST['type']:'setup';
17 $display = isset($_REQUEST['display'])?$_REQUEST['display']:'';
18 $extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null;
19 $skip = isset($_REQUEST['skip'])?$_REQUEST['skip']:0;
20 $action = isset($_REQUEST['action'])?$_REQUEST['action']:null;
21 $quietmode = isset($_REQUEST['quietmode'])?$_REQUEST['quietmode']:'';
22
23 // determine module type to show, default to 'setup'
24 if($type == "tool") {
25   $message = "Tools";
26   $fpbx_menu = array(
27     'modules' => array('category' => 'System Administration', 'name' => 'Module Admin', 'sort' => 0)
28   );
29 } elseif($type == "cdrcost") {
30   $message = "Call Cost";
31 } else {
32   $message = "Setup";
33 }
34
35 require_once('common/php-asmanager.php');
36 require_once('functions.inc.php');
37
38 // get settings
39 $amp_conf = parse_amportal_conf("/etc/amportal.conf");
40 $asterisk_conf  = parse_asterisk_conf("/etc/asterisk/asterisk.conf");
41 $astman   = new AGI_AsteriskManager();
42 if (! $res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) {
43   unset( $astman );
44 }
45
46 include 'header_auth.php';
47
48 // get all enabled modules
49 // active_modules array used below and in drawselects function and genConf function
50 $active_modules = module_getinfo(false, MODULE_STATUS_ENABLED);
51
52 // include any module global functions
53 // add module sections to $fpbx_menu
54 if(is_array($active_modules)){
55   foreach($active_modules as $key => $module) {
56     //include module functions
57     if (is_file("modules/{$key}/functions.inc.php")) {
58       require_once("modules/{$key}/functions.inc.php");
59     }
60     //create an array of module sections to display
61     // only of the type we are displaying though
62     
63     // stored as [items][$type][$category][$name] = $displayvalue
64     if (isset($module['items']) && is_array($module['items'])) {
65       // loop through the types
66       foreach($module['items'] as $itemKey => $item) {
67         if ($item['type'] == $type) {
68           // item is an assoc array, with at least array(name=>, category=>, type=>)
69           $fpbx_menu[$itemKey] = $item;
70         }
71       }
72     
73     }
74     
75   }
76 }
77
78 // new gui hooks
79 if(is_array($active_modules)){
80   foreach($active_modules as $key => $module) {
81     if (isset($module['items']) && is_array($module['items'])) {
82       foreach($module['items'] as $itemKey => $itemName) {
83         //list of potential _configpageinit functions
84         $initfuncname = $key . '_' . $itemKey . '_configpageinit';
85         if ( function_exists($initfuncname) ) {
86           $configpageinits[] = $initfuncname;
87         }
88       }
89     }
90     //check for module level (rather than item as above) _configpageinit function
91     $initfuncname = $key . '_configpageinit';
92     if ( function_exists($initfuncname) ) {
93       $configpageinits[] = $initfuncname;
94     }
95   }
96 }
97
98
99 // extensions vs device/users ... this is a bad design, but hey, it works
100 if (isset($amp_conf["AMPEXTENSIONS"]) && ($amp_conf["AMPEXTENSIONS"] == "deviceanduser")) {
101   unset($fpbx_menu["extensions"]);
102 } else {
103   unset($fpbx_menu["devices"]);
104   unset($fpbx_menu["users"]);
105 }
106
107 if (is_array($fpbx_menu)) {
108   foreach ($fpbx_menu as $key => $value) {
109     // check access
110     if ($_SESSION["AMP_user"]->checkSection($key)) {
111       // if the module has it's own translations, use them for displaying menu item
112       if (extension_loaded('gettext')) {
113         if (is_dir("modules/{$key}/i18n")) {
114           bindtextdomain($key,"modules/{$key}/i18n");
115           bind_textdomain_codeset($key, 'utf8');
116           textdomain($key);
117         } else {
118           bindtextdomain('amp','./i18n');
119           textdomain('amp');
120         }
121       }
122     } else {
123       // they don't have access to this, remove it completely
124       unset($fpbx_menu[$key]);
125     }
126   }
127 }
128
129 if (!$quietmode) {
130   if (is_array($fpbx_menu)) {
131     $category = Array();
132     $sort = Array();
133     $name = Array();
134     // Sorting menu by category and name
135     foreach ($fpbx_menu as $key => $row) {
136       $category[$key] = $row['category'];
137       $sort[$key] = $row['sort'];
138       $name[$key] = $row['name'];
139     }
140     
141     if ($amp_conf['USECATEGORIES']) {
142       array_multisort(
143         $category, SORT_ASC,
144         $sort, SORT_ASC, SORT_NUMERIC,
145         $name, SORT_ASC,
146         $fpbx_menu
147       );
148     } else {
149       array_multisort(
150         $sort, SORT_ASC, SORT_NUMERIC,
151         $name, SORT_ASC,
152         $fpbx_menu
153       );
154     }
155     
156     // Printing menu
157     echo "<div id=\"nav\"><ul>\n";
158     
159     $prev_category = '';
160     
161     foreach ($fpbx_menu as $key => $row) {
162       if ($amp_conf['USECATEGORIES'] && ($row['category'] != $prev_category)) {
163         echo "\t\t<li>"._($row['category'])."</li>\n";
164         $prev_category = $row['category'];
165       }
166       
167       $href = isset($row['href']) ? $row['href'] : "config.php?type=".$type."&amp;display=".$key;
168       $extra_attributes = '';
169       if (isset($row['target'])) {
170         $extra_attributes .= ' target="'.$row['target'].'"';
171       }
172       
173       echo "\t<li" .
174         (($display==$key) ? ' class="current"':'') .
175         '><a href="'.$href.'" '.$extra_attributes.' >'._($row['name'])."</a></li>\n";
176       
177     }
178     echo "</ul></div>\n\n";
179   }
180
181   echo "<div id=\"wrapper\"><div id=\"background-wrapper\">\n";
182  
183   echo "<div id=\"left-corner\"></div>\n";
184   echo "<div id=\"right-corner\"></div>\n";
185  
186   echo "<div class=\"content\">\n";
187
188
189   echo "<noscript><div class=\"attention\">"._("WARNING: Javascript is disabled in your browser. The freePBX administration interface requires Javascript to run properly. Please enable javascript or switch to another  browser that supports it.")."</div></noscript>";
190 }
191
192
193
194 // check access
195 if ( ($display != '') && !isset($fpbx_menu[$display]) ) {
196   $display = "noaccess";
197 }
198
199 // load the component from the loaded modules
200 if ( $display != '' && isset($configpageinits) && is_array($configpageinits) ) {
201
202   $currentcomponent = new component($display,$type);
203
204   // call every modules _configpageinit function which should just
205   // register the gui and process functions for each module, if relevent
206   // for this $display
207   foreach ($configpageinits as $func) {
208     $func($display);
209   }
210  
211   // now run each 'process' function and 'gui' function
212   $currentcomponent->processconfigpage();
213   $currentcomponent->buildconfigpage();
214 }
215
216 // show the appropriate page
217 switch($display) {
218   default:
219     //display the appropriate module page
220     if (!isset($active_modules) || (isset($active_modules) && !is_array($active_modules))) {
221       break;
222     }
223     
224     foreach ($active_modules as $modkey => $module) {
225       if (!isset($module['items']) || (isset($module['items']) && !is_array($module['items']))){
226         continue;
227       }
228       
229       foreach (array_keys($module['items']) as $item){
230         if ($display != $item)  {
231           continue;
232         }
233         
234         // modules can use their own translation files
235         if (extension_loaded('gettext')) {
236           if(is_dir("./modules/{$modkey}/i18n")) {
237             bindtextdomain($modkey,"./modules/{$modkey}/i18n");
238             bind_textdomain_codeset($modkey, 'utf8');
239             textdomain($modkey);
240           }
241         }
242         
243         //TODO Determine which item is this module displaying. Currently this is over the place, we should standarize on a "itemid" request var for now, we'll just cover all possibilities :-(
244         $possibilites = array(
245           'userdisplay',
246           'extdisplay',
247           'id',
248           'itemid',
249           'category',
250           'selection'
251         );
252         $itemid = '';
253         foreach($possibilites as $possibility) {
254           if ( isset($_REQUEST[$possibility]) && $_REQUEST[$possibility] != '' )
255             $itemid = $_REQUEST[$possibility];
256         }
257
258         // create a module_hook object for this module's page
259         $module_hook = new moduleHook;
260         
261         // populate object variables
262         $module_hook->install_hooks($itemid,$modkey,$item);
263
264         // let hooking modules process the $_REQUEST
265         $module_hook->process_hooks($itemid,$modkey,$item,$_REQUEST);
266         
267         // include the module page
268         include "modules/{$modkey}/page.{$item}.php";
269
270         // global component
271         if ( isset($currentcomponent) ) {
272           echo $currentcomponent->generateconfigpage();
273         }
274
275       }
276     }
277   break;
278   case 'noaccess':
279     echo "<h2>"._("Not found")."</h2>";
280     echo "<p>"._("The section you requested does not exist or you do not have access to it.")."</p>";
281   break;
282   case 'modules':
283     include 'page.modules.php';
284   break;
285   case '':
286     if ($astman) {
287       printf( "<h2>%s</h2>", dgettext("welcome page", "Welcome to freePBX.") );
288
289       $modules_needup = module_getinfo(false, MODULE_STATUS_NEEDUPGRADE);
290       $modules_broken = module_getinfo(false, MODULE_STATUS_BROKEN);
291       if (count($modules_needup) || count($modules_broken)) {
292         echo "<div class=\"warning\">";
293         if (count($modules_needup)) {
294           echo "<p>"._("Warning: The following modules are disabled because they need upgrading: ");
295           echo implode(", ",array_keys($modules_needup));
296           echo "</p>";
297         }
298         if (count($modules_broken)) {
299           echo "<p>"._("Warning: The following modules are disabled because they are broken: ");
300           echo implode(", ",array_keys($modules_broken));
301           echo "</p>";
302         }
303         echo "<p>", sprintf(dgettext("welcome page","You should go to the <a href='%s'>Module Admin</a> page to fix these.</p>"), "config.php?display=modules&amp;type=tool");
304         echo "</div>";
305       }
306       
307 // BETA code - remove later.
308 //      echo "<div class=\"warning\">";
309 //      printf( "<p>%s</p>", dgettext("welcome page", "You are running Release Candidate 1 of freePBX. This release is a final test before we make the official 2.2.0 freePBX release. We are unaware of any major bugs in this release, and urge users to report any that they find.") );
310       
311 //      printf( "<p>%s</p>"  , dgettext("welcome page", "Currently known bugs are maintained on <a href='http://www.freepbx.org/trac/wiki/2.2Beta'>this TRAC page</a>. If you find a bug, please <a href='http://www.freepbx.org/trac/newticket'>create a bug report</a> (you need to create an account - this is to avoid spammers) and the bug report will immediately appear on the <a href='http://www.freepbx.org/trac/wiki/2.2Beta'>TRAC page</a> so that it can be easily tracked by other users.") );
312 //      echo "</div>";
313
314       printf( "<!--[if IE]><p>%s</p><![endif]-->"  , dgettext("welcome page", "Note, presently, Microsoft's Internet Explorer is <b>not</b> a supported web browser, and you must use a standards compliant browser, such as Firefox. There is a link on the <a href='http://www.freepbx.org'>right hand side of freePBX.org</a> that will allow you to download Firefox easily. By using that link, Google will donate US$1 to the freePBX project.") );
315       
316       if ($amp_conf['AMPMGRPASS'] == 'amp111') {
317         printf( "<div class=\"warning\"><p>%s</p></div>", dgettext("welcome text", "Warning: You are running freePBX and ").$amp_conf['AMPENGINE'].dgettext("welcome page", " with the default manager pass. You should consider changing this to something else.") );
318       }
319       if ($amp_conf['AMPDBPASS'] == 'amp109') {
320         printf( "<div class=\"warning\"><p>%s</p></div>", dgettext("welcome text", "Warning: You are running freePBX and ").$amp_conf['AMPDBENGINE'].dgettext("welcome page", " with the default password ") );
321       }
322
323
324
325       printf( "<p>%s</p>"  , dgettext("welcome page", "If you're new to freePBX, Welcome. Here are some quick instructions to get you started") );
326       
327       echo "<p>";
328       printf( dgettext("welcome page",
329 "There are a large number of Plug-in modules available from the Online Repository. This is
330 available by clicking on the <a href='%s'>Tools menu</a> up the top, then
331 <a href='%s'>Module Admin</a>, then
332 <a href='%s'>Check for updates online</a>.
333 Modules are updated and patched often, so if you are having a problem, it's worth checking there to see if there's
334 a new version of the module available."),
335         "config.php?type=tool",
336         "config.php?display=modules&amp;type=tool",
337         "config.php?display=modules&amp;type=tool&amp;extdisplay=online"
338       );
339       echo "</p>\n";
340
341       echo "<p>";
342       printf( dgettext( "welcome page",
343 "If you're having any problems, you can also use the <a href='%s'>Online Support</a>
344 module (<b>you need to install this through the <a href='%s'>Module Repository</a> first</b>)
345 to talk to other users and the devlopers in real time. Click on <a href='%s'>Start IRC</a>,
346 when the module is installed, to start a Java IRC client." ),
347         "config.php?type=tool&amp;display=irc",
348         "config.php?display=modules&amp;type=tool&amp;extdisplay=online",
349         "config.php?type=tool&amp;display=irc&amp;action=start"
350       );
351       echo "</p>\n";
352
353       echo "<p>";
354       printf( dgettext( "welcome page",
355 "There is also a community based <a href='%s' target='_new'>freePBX Web Forum</a> where you can post
356 questions and search for answers for any problems you may be having."),
357 "http://forums.freepbx.org"  );
358       echo "</p>\n";
359
360       print( "<p>" . _("We hope you enjoy using freePBX!") . "</p>\n" );
361     } // no manager, no connection to asterisk
362     else {
363       echo "<p><div class='clsError'>\n";
364       echo "<b>" . _("Warning:") . "</b>\n";
365       echo "<br>";
366       echo "<br>\n";
367       echo _("Cannot connect to Asterisk Manager with "). "<i>" .$amp_conf["AMPMGRUSER"] . "</i>";
368       echo "<br>";
369       echo _("Asterisk may not be running.");
370       echo "</div></p>\n";
371     }
372   break;
373  
374 }
375
376 if (!$quietmode) {
377   echo "\t</div> <!-- /content -->\n";
378  
379   include('footer.php');
380   echo "</div></div> <!-- /background-wrapper, /wrapper -->\n";
381
382   echo "</div> <!-- /page -->\n";
383   echo "</body>\n";
384   echo "</html>\n";
385 }
386 ?>
Note: See TracBrowser for help on using the browser.