Changeset 4707
- Timestamp:
- 08/05/07 16:33:46 (6 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
freepbx/branches/2.3/amp_conf/htdocs/admin/config.php
r4700 r4707 124 124 } 125 125 126 127 // if the module has it's own translations, use them for displaying menu item128 if (extension_loaded('gettext')) {129 if (is_dir("modules/{$key}/i18n")) {130 bindtextdomain($key,"modules/{$key}/i18n");131 bind_textdomain_codeset($key, 'utf8');132 textdomain($key);133 } else {134 bindtextdomain('amp','./i18n');135 textdomain('amp');136 }137 }138 139 126 //create an array of module sections to display 140 127 // stored as [items][$type][$category][$name] = $displayvalue … … 143 130 foreach($module['items'] as $itemKey => $item) { 144 131 145 // check access 146 // TODO : do we always include functions.inc (like it is now), or do we put this check first? 147 if (!$_SESSION["AMP_user"]->checkSection($itemKey)) { 148 // no access, skip to the next 149 continue; 132 // check access, unless module.xml defines all have access 133 if (!isset($item['access']) || strtolower($item['access']) != 'all') { 134 if (!$_SESSION["AMP_user"]->checkSection($itemKey)) { 135 // no access, skip to the next 136 continue; 137 } 150 138 } 151 139 … … 246 234 247 235 ob_start(); 236 237 $module_name = ""; 238 $module_page = ""; 239 $module_file = ""; 248 240 249 241 // show the appropriate page … … 285 277 break; // we break here to avoid the generateconfigpage() below 286 278 } else if (file_exists($module_file)) { 279 // load language info if available 280 if (extension_loaded('gettext')) { 281 if (is_dir("modules/{$module_name}/i18n")) { 282 bindtextdomain($module_name,"modules/{$module_name}/i18n"); 283 bind_textdomain_codeset($module_name, 'utf8'); 284 textdomain($module_name); 285 } 286 } 287 287 include($module_file); 288 288 } else { … … 306 306 case '': 307 307 if ($astman) { 308 /*309 printf( "<h2>%s</h2>", dgettext("welcome page", "Welcome to FreePBX.") );310 311 $modules_needup = module_getinfo(false, MODULE_STATUS_NEEDUPGRADE);312 $modules_broken = module_getinfo(false, MODULE_STATUS_BROKEN);313 if (count($modules_needup) || count($modules_broken)) {314 echo "<div class=\"warning\">";315 if (count($modules_needup)) {316 echo "<p>"._("Warning: The following modules are disabled because they need upgrading: ");317 echo implode(", ",array_keys($modules_needup));318 echo "</p>";319 }320 if (count($modules_broken)) {321 echo "<p>"._("Warning: The following modules are disabled because they are broken: ");322 echo implode(", ",array_keys($modules_broken));323 echo "</p>";324 }325 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&type=tool");326 echo "</div>";327 }328 329 // BETA code - remove later.330 echo "<div class=\"warning\">";331 printf( "<p>%s</p>", dgettext("welcome page", "You are FreePBX 2.3 Beta 1. This release is the first release in prepartation for FreePBX Version 2.3.0.") );332 333 printf( "<p>%s</p>" , dgettext("welcome page", "Currently known bugs are maintained on <a href='http://www.freepbx.org/trac/wiki/2.3Beta'>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.3Beta'>TRAC page</a> so that it can be easily tracked by other users.") );334 echo "</div>";335 336 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.") );337 338 if ($amp_conf['AMPMGRPASS'] == 'amp111') {339 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.")." ".sprintf('(<a href="http://aussievoip.com/wiki/index.php?page=FreePBX-ManagerPass" target="_new">%s</a>)', _("Help")) );340 }341 342 if ( ($amp_conf["AMPDBENGINE"] == "mysql") || ($amp_conf["AMPDBENGINE"] == "pgsql")) {343 if ($amp_conf['AMPDBPASS'] == 'amp109') {344 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 ")." ".sprintf('(<a href="http://aussievoip.com/wiki/index.php?page=FreePBX-MysqlPass" target="_new">%s</a>)', _("Help")) );345 }346 }347 348 349 350 printf( "<p>%s</p>" , dgettext("welcome page", "If you're new to FreePBX, Welcome. Here are some quick instructions to get you started") );351 352 echo "<p>";353 printf( dgettext("welcome page",354 "There are a large number of Plug-in modules available from the Online Repository. This is355 available by clicking on the <a href='%s'>Tools menu</a> up the top, then356 <a href='%s'>Module Admin</a>, then357 <a href='%s'>Check for updates online</a>.358 Modules are updated and patched often, so if you are having a problem, it's worth checking there to see if there's359 a new version of the module available."),360 "config.php?type=tool",361 "config.php?display=modules&type=tool",362 "config.php?display=modules&type=tool&extdisplay=online"363 );364 echo "</p>\n";365 366 echo "<p>";367 printf( dgettext( "welcome page",368 "If you're having any problems, you can also use the <a href='%s'>Online Support</a>369 module (<b>you need to install this through the <a href='%s'>Module Repository</a> first</b>)370 to talk to other users and the devlopers in real time. Click on <a href='%s'>Start IRC</a>,371 when the module is installed, to start a Java IRC client." ),372 "config.php?type=tool&display=irc",373 "config.php?display=modules&type=tool&extdisplay=online",374 "config.php?type=tool&display=irc&action=start"375 );376 echo "</p>\n";377 378 echo "<p>";379 printf( dgettext( "welcome page",380 "There is also a community based <a href='%s' target='_new'>FreePBX Web Forum</a> where you can post381 questions and search for answers for any problems you may be having."),382 "http://forums.freepbx.org" );383 echo "</p>\n";384 385 print( "<p>" . _("We hope you enjoy using FreePBX!") . "</p>\n" );386 } // no manager, no connection to asterisk387 else {388 echo "<p><div class='clsError'>\n";389 echo "<b>" . _("Warning:") . "</b>\n";390 echo "<br>";391 echo "<br>\n";392 echo _("Cannot connect to Asterisk Manager with "). "<i>" .$amp_conf["AMPMGRUSER"] . "</i>";393 echo "<br>";394 echo _("Asterisk may not be running.");395 echo "</div></p>\n";396 */397 308 showview('welcome', array('AMP_CONF' => &$amp_conf)); 398 309 } else { … … 419 330 $admin_template['display'] = $display; 420 331 332 // set the language so local module languages take 333 set_language(); 334 421 335 // then load it and put it into the main freepbx interface 422 336 $template['content'] = loadview('freepbx_admin', $admin_template); freepbx/branches/2.3/amp_conf/htdocs/admin/functions.inc.php
r4701 r4707 1626 1626 1627 1627 1628 1629 /*1630 // just for testing hooks, i'll delete it later1631 function queues_hook_core($viewing_itemid, $target_menuid) {1632 switch ($target_menuid) {1633 case 'did':1634 //get the current setting for this display (if any)1635 $alertinfo = $viewing_itemid;1636 return '1637 <tr>1638 <td><a href="#" class="info">'._("Alert Info").'<span>'._('ALERT_INFO can be used for distinctive ring with SIP devices.').'</span></a>:</td>1639 <td><input type="text" name="alertinfo" size="10" value="'.(($alertinfo) ? $alertinfo : "") .'"></td>1640 </tr>1641 ';1642 break;1643 default:1644 return false;1645 break;1646 }1647 }1648 1649 function queues_hookProcess_core($viewing_itemid, $request) {1650 switch ($request['action']) {1651 case 'edtIncoming':1652 echo "<h1>HI</h1>";1653 return '1654 <tr>1655 <td><a href="#" class="info">'._("Alert Info").'<span>'._('ALERT_INFO can be used for distinctive ring with SIP devices.').'</span></a>:</td>1656 <td><input type="text" name="alertinfo" size="10" value="'.(($alertinfo) ? $alertinfo : "") .'"></td>1657 </tr>1658 ';1659 break;1660 default:1661 return false;1662 break;1663 }1664 }1665 */1666 1667 1628 /** Replaces variables in a string with the values from ampconf 1668 1629 * eg, "%AMPWEBROOT%/admin" => "/var/www/html/admin" … … 2694 2655 'needsenginedb', // set to true if engine db access required (e.g. astman access) 2695 2656 'needsenginerunning', // set to true if required to run 2657 'access', // set to all if all users should always have access 2696 2658 ); 2697 2659 foreach ($optional_attribs as $attrib) { … … 2963 2925 } 2964 2926 } 2965 2966 2967 /*2968 function installModule($modname,$modversion)2969 {2970 global $db;2971 global $amp_conf;2972 2973 switch ($amp_conf["AMPDBENGINE"])2974 {2975 case "sqlite":2976 // to support sqlite2, we are not using autoincrement. we need to find the2977 // max ID available, and then insert it2978 $sql = "SELECT max(id) FROM modules;";2979 $results = $db->getRow($sql);2980 $new_id = $results[0];2981 $new_id ++;2982 $sql = "INSERT INTO modules (id,modulename, version,enabled) values ('{$new_id}','{$modname}','{$modversion}','0' );";2983 break;2984 2985 default:2986 $sql = "INSERT INTO modules (modulename, version) values ('{$modname}','{$modversion}');";2987 break;2988 }2989 2990 $results = $db->query($sql);2991 if(DB::IsError($results)) {2992 die($results->getMessage());2993 }2994 }2995 2996 function uninstallModule($modname) {2997 global $db;2998 $sql = "DELETE FROM modules WHERE modulename = '{$modname}'";2999 $results = $db->query($sql);3000 if(DB::IsError($results)) {3001 die($results->getMessage());3002 }3003 }3004 3005 /** downloads a module, and extracts it into the module dir3006 * /3007 function module_fetch($name) { // was fetchModule3008 global $amp_conf;3009 $res = module_getonlinexml($modulename);3010 if (!isset($res)) {3011 echo "<div class=\"error\">"._("Unaware of module")." {$name}</div>";3012 return false;3013 }3014 $file = basename($res['location']);3015 $filename = $amp_conf['AMPWEBROOT']."/admin/modules/_cache/".$file;3016 if(file_exists($filename)) {3017 // We might already have it! Let's check the MD5.3018 $filedata = "";3019 $fh = @fopen($filename, "r");3020 while (!feof($fh)) {3021 $filedata .= fread($fh, 8192);3022 }3023 if (isset($res['md5sum']) && $res['md5sum'] == md5 ($filedata)) {3024 // Note, if there's no MD5 information, it will redownload3025 // every time. Otherwise theres no way to avoid a corrupt3026 // download3027 3028 return verifyAndInstall($filename);3029 } else {3030 unlink($filename);3031 }3032 }3033 3034 $url = "http://mirror.freepbx.org/modules/".$res['location'];3035 3036 $fp = @fopen($filename,"w");3037 $filedata = file_get_contents($url);3038 fwrite($fp,$filedata);3039 fclose($fp);3040 if (is_readable($filename) !== TRUE ) {3041 echo "<div class=\"error\">"._("Unable to save")." {$filename} - Check file/directory permissions</div>";3042 return false;3043 }3044 // Check the MD5 info against what's in the module's XML3045 if (!isset($res['md5sum']) || empty($res['md5sum'])) {3046 echo "<div class=\"error\">"._("Unable to Locate Integrity information for")." {$filename} - "._("Continuing Anyway")."</div>";3047 } elseif ($res['md5sum'] != md5 ($filedata)) {3048 echo "<div class=\"error\">"._("File Integrity FAILED for")." {$filename} - "._("Aborting")."</div>";3049 unlink($filename);3050 return false;3051 }3052 // verifyAndInstall does the untar, and will do the signed-package check.3053 return verifyAndInstall($filename);3054 3055 }3056 3057 function upgradeModule($module, $allmods = NULL) {3058 if($allmods === NULL)3059 $allmods = find_allmodules();3060 // the install.php can set this to false if the upgrade fails.3061 $success = true;3062 if(is_file("modules/$module/install.php"))3063 include "modules/$module/install.php";3064 if ($success) {3065 sql('UPDATE modules SET version = "'.$allmods[$module]['version'].'" WHERE modulename = "'.$module.'"');3066 needreload();3067 }3068 }3069 3070 function rmModule($module) {3071 global $amp_conf;3072 if($module != 'core') {3073 if (is_dir($amp_conf['AMPWEBROOT'].'/admin/modules/'.$module) && strstr($module, '.') === FALSE ) {3074 exec('/bin/rm -rf '.$amp_conf['AMPWEBROOT'].'/admin/modules/'.$module);3075 }3076 } else {3077 echo "<script language=\"Javascript\">alert('"._("You cannot delete the Core module")."');</script>";3078 }3079 }3080 3081 */3082 2927 3083 2928 function module_run_notification_checks() { freepbx/branches/2.3/amp_conf/htdocs/admin/header.php
r4701 r4707 68 68 69 69 // setup locale 70 if (extension_loaded('gettext')) { 71 if (isset($_COOKIE['lang'])) { 72 setlocale(LC_ALL, $_COOKIE['lang']); 73 putenv("LANGUAGE=".$_COOKIE['lang']); 74 } else { 75 setlocale(LC_ALL, 'en_US'); 70 function set_language() { 71 if (extension_loaded('gettext')) { 72 if (isset($_COOKIE['lang'])) { 73 setlocale(LC_ALL, $_COOKIE['lang']); 74 putenv("LANGUAGE=".$_COOKIE['lang']); 75 } else { 76 setlocale(LC_ALL, 'en_US'); 77 } 78 bindtextdomain('amp','./i18n'); 79 bind_textdomain_codeset('amp', 'utf8'); 80 textdomain('amp'); 76 81 } 77 bindtextdomain('amp','./i18n');78 bind_textdomain_codeset('amp', 'utf8');79 textdomain('amp');80 82 } 83 set_language(); 81 84 82 85 … … 105 108 // get settings 106 109 $amp_conf = parse_amportal_conf("/etc/amportal.conf"); 107 $asterisk_conf = parse_asterisk_conf( rtrim($amp_conf["ASTETCDIR"],"/")."/asterisk.conf");110 $asterisk_conf = parse_asterisk_conf($amp_conf["ASTETCDIR"]."/asterisk.conf"); 108 111 $astman = new AGI_AsteriskManager(); 109 112
