root/modules/branches/2.9/extensionsettings/page.extensionsettings.php

Revision 10775, 6.1 kB (checked in by mickecarlsson, 2 years ago)

Extension Settings: more tweaks

Line 
1 <?php /* $Id */
2 // Copyright (C) 2008 Philippe Lindheimer & Bandwidth.com (plindheimer at bandwidth dot com)
3 // Copyright (C) 2010 Mikael Carlsson (mickecarlsson at gmail dot com)
4 //
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, version 2
8 // of the License.
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 // TODO:
16 // Localization
17 // get all settings from astdb for extensions
18 // make all toggles clickable so they can be changed here
19 // like, click on CW ON or OFF to toggle state, perhaps an image?
20 // same for VmX, enable or disable, or if time permits, change destinations, who knows, time is the linit
21 // Change the table so it has colors, perhaps make it scrollable with the headers intact??
22 // and a dozen other things that I can think of.
23 //
24
25 $dispnum = 'extensionsettings';
26 global $active_modules;
27
28 $html_txt = '<div class="content">';
29
30 if (!$extdisplay) {
31     $html_txt .= '<br><h2>'._("FreePBX Extension Settings").'</h2>';
32 }
33
34 $full_list = framework_check_extension_usage(true);
35 foreach ($full_list as $key => $value) {
36
37     $sub_heading_id = $txtdom = $active_modules[$key]['rawname'];
38     if ($active_modules[$key]['rawname'] != 'core' || ($quietmode && !isset($_REQUEST[$sub_heading_id]))) {
39         continue; // we just want core
40     }
41     if ($txtdom == 'core') {
42         $txtdom = 'amp';
43         $active_modules[$key]['name'] = 'Extensions';
44         $core_heading = $sub_heading dgettext($txtdom,$active_modules[$key]['name']);
45     } else {
46         $sub_heading dgettext($txtdom,$active_modules[$key]['name']);
47     }
48     $module_select[$sub_heading_id] = $sub_heading;
49     $html_txt_arr[$sub_heading] =   "<div class=\"$sub_heading_id\"><table id=\"set_table\" border=\"0\" width=\"85%\"><tr>";
50     $html_txt_arr[$sub_heading] .=  "<tr><td><strong>Extension</strong></td>";
51     $html_txt_arr[$sub_heading] .=  "<td colspan=\"5\" align=\"center\"><strong>VmX Locator</strong></td>";
52     $html_txt_arr[$sub_heading] .=  "<td colspan=\"2\" align=\"center\"><strong>Follow-Me</strong></td>";
53     $html_txt_arr[$sub_heading] .=  "<td colspan=\"4\" align=\"center\"><strong>Call status</strong></td>";
54     $html_txt_arr[$sub_heading] .=  "</tr><td></td>";
55     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>Status</strong></td>";   
56     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>1 Busy</strong></td>";
57     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>1 Unavailable</strong></td>";
58     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>2 Busy</strong></td>";
59     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>2 Unavailable</strong></td>";
60     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>FM</strong></td>";
61     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>FM-list</strong></td>";
62     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>CW</strong></td>";
63     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>CF</strong></td>";
64     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>CFB</strong></td>";
65     $html_txt_arr[$sub_heading] .=  "<td align=\"center\"><strong>CFU</strong></td></tr>\n";
66
67     foreach ($value as $exten => $item) {
68         $description = explode(":",$item['description'],2);   
69         $html_txt_arr[$sub_heading] .= "<tr><td><a href=\"".$item['edit_url']."\" class=\"info\">".$exten."<span>".(trim($description[1])==''?$exten:$description[1])."</span></a></td>";
70         // Is VmX enabled?
71         if ( $astman->database_get("AMPUSER",$exten."/vmx/busy/state") == "enabled" ) {
72             $color = "\"BLACK\"";
73             $vmxstate = "On";
74         } else {
75             $color = "\"GREY\"";
76             $vmxstate = "Off";
77         } ;
78         $html_txt_arr[$sub_heading] .= "<td align=\"center\">".$vmxstate."</td>";
79         $html_txt_arr[$sub_heading] .= "<td><font color=".$color.">".$astman->database_get("AMPUSER",$exten."/vmx/busy/1/ext")."</font></td>";
80         $html_txt_arr[$sub_heading] .= "<td><font color=".$color.">".$astman->database_get("AMPUSER",$exten."/vmx/unavail/1/ext")."</font></td>";
81         $html_txt_arr[$sub_heading] .= "<td><font color=".$color.">".$astman->database_get("AMPUSER",$exten."/vmx/busy/2/ext")."</font></td>";
82         $html_txt_arr[$sub_heading] .= "<td><font color=".$color.">".$astman->database_get("AMPUSER",$exten."/vmx/unavail/2/ext")."</font></td>";
83         // Has the exten followme enabled?
84         $followme = $astman->database_get("AMPUSER",$exten."/followme/ddial");
85         if( isset($followme)) {
86             if($followme == "DIRECT" || $followme == "EXTENSION") {
87             $fm = "On";
88             } else {
89             $fm = "Off";
90             }
91         } // end isset
92         $html_txt_arr[$sub_heading] .= "<td align=\"center\">".$fm."</td>";
93         // If follow-me is enabled, get the follow-me list
94         if($fm == "On") {
95             $fmlist = $astman->database_get("AMPUSER",$exten."/followme/grplist");
96             $fmlist = str_replace("-","<br>",$fmlist);
97             } else {
98             $fmlist = "";
99             }
100         $html_txt_arr[$sub_heading] .= "<td align=\"center\">".$fmlist."</td>";
101         $fmlist = ""; // Empty the list
102         if( $astman->database_get("CW",$exten) == "ENABLED" ) {
103             $cw = "On";
104             } else {
105             $cw = "Off";
106         };
107         $html_txt_arr[$sub_heading] .= "<td align=\"center\">".$cw."</td>";
108         $html_txt_arr[$sub_heading] .= "<td align=\"center\">".$astman->database_get("CF",$exten)."</td>";
109         $html_txt_arr[$sub_heading] .= "<td align=\"center\">".$astman->database_get("CFB",$exten)."</td>";
110         $html_txt_arr[$sub_heading] .= "<td align=\"center\">".$astman->database_get("CFU",$exten)."</td>";
111         $html_txt_arr[$sub_heading] .= "</tr>\n";
112     }
113     $html_txt_arr[$sub_heading] .= "</table></div>";
114 }
115
116 function core_top($a, $b) {
117     global $core_heading;
118
119     if ($a == $core_heading) {
120         return -1;
121     } elseif ($b == $core_heading) {
122         return 1;
123     } elseif ($a != $b) {
124         return $a < $b ? -1 : 1;
125     } else {
126         return 0;
127     }
128 }
129
130 uksort($html_txt_arr, 'core_top');
131 if (!$quietmode) {
132     //asort($module_select);
133     uasort($module_select, 'core_top');
134 }
135
136 $html_txt_arr[$sub_heading] .= "</table></div>";
137 $html_txt .= implode("\n",$html_txt_arr);
138 echo $html_txt."</div>";
139 ?>
140
Note: See TracBrowser for help on using the browser.