Subversion Repositories oidplus

Rev

Rev 328 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 328 Rev 360
Line 20... Line 20...
20
class OIDplusPageAdminSystemConfig extends OIDplusPagePluginAdmin {
20
class OIDplusPageAdminSystemConfig extends OIDplusPagePluginAdmin {
21
 
21
 
22
        public function action($actionID, $params) {
22
        public function action($actionID, $params) {
23
                if ($actionID == 'config_update') {
23
                if ($actionID == 'config_update') {
24
                        if (!OIDplus::authUtils()::isAdminLoggedIn()) {
24
                        if (!OIDplus::authUtils()::isAdminLoggedIn()) {
25
                                throw new OIDplusException('You need to log in as administrator.');
25
                                throw new OIDplusException(_L('You need to log in as administrator.'));
26
                        }
26
                        }
27
 
27
 
28
                        $name = $params['name'];
28
                        $name = $params['name'];
29
                        $value = $params['value'];
29
                        $value = $params['value'];
30
 
30
 
31
                        $res = OIDplus::db()->query("select protected, visible from ###config where name = ?", array($name));
31
                        $res = OIDplus::db()->query("select protected, visible from ###config where name = ?", array($name));
32
                        if ($res->num_rows() == 0) {
32
                        if ($res->num_rows() == 0) {
33
                                throw new OIDplusException('Setting does not exist');
33
                                throw new OIDplusException(_L('Setting does not exist'));
34
                        }
34
                        }
35
                        $row = $res->fetch_array();
35
                        $row = $res->fetch_array();
36
                        if (($row['protected'] == 1) || ($row['visible'] == 0)) {
36
                        if (($row['protected'] == 1) || ($row['visible'] == 0)) {
37
                                throw new OIDplusException("Setting '$name' is read-only");
37
                                throw new OIDplusException(_L("Setting %1 is read-only",$name));
38
                        }
38
                        }
39
 
39
 
40
                        OIDplus::config()->setValue($name, $value);
40
                        OIDplus::config()->setValue($name, $value);
41
                        OIDplus::logger()->log("[OK]A?", "Changed system config setting '$name' to '$value'");
41
                        OIDplus::logger()->log("[OK]A?", "Changed system config setting '$name' to '$value'");
42
 
42
 
43
                        return array("status" => 0);
43
                        return array("status" => 0);
44
                } else {
44
                } else {
45
                        throw new OIDplusException("Unknown action ID");
45
                        throw new OIDplusException(_L('Unknown action ID'));
46
                }
46
                }
47
        }
47
        }
48
 
48
 
49
        public function init($html=true) {
49
        public function init($html=true) {
50
                // Nothing
50
                // Nothing
51
        }
51
        }
52
 
52
 
53
        public function gui($id, &$out, &$handled) {
53
        public function gui($id, &$out, &$handled) {
54
                if (explode('$',$id)[0] == 'oidplus:edit_config') {
54
                if (explode('$',$id)[0] == 'oidplus:edit_config') {
55
                        $handled = true;
55
                        $handled = true;
56
                        $out['title'] = 'System configuration';
56
                        $out['title'] = _L('System configuration');
57
                        $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
57
                        $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? OIDplus::webpath(__DIR__).'icon_big.png' : '';
58
 
58
 
59
                        if (!OIDplus::authUtils()::isAdminLoggedIn()) {
59
                        if (!OIDplus::authUtils()::isAdminLoggedIn()) {
60
                                $out['icon'] = 'img/error_big.png';
60
                                $out['icon'] = 'img/error_big.png';
61
                                $out['text'] = '<p>You need to <a '.OIDplus::gui()->link('oidplus:login').'>log in</a> as administrator.</p>';
61
                                $out['text'] = '<p>'._L('You need to <a %1>log in</a> as administrator.',OIDplus::gui()->link('oidplus:login')).'</p>';
62
                                return;
62
                                return;
63
                        }
63
                        }
64
                       
64
 
65
                        $output = '';
65
                        $output = '';
66
                        $output .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
66
                        $output .= '<div class="container box"><div id="suboid_table" class="table-responsive">';
67
                        $output .= '<table class="table table-bordered table-striped">';
67
                        $output .= '<table class="table table-bordered table-striped">';
68
                        $output .= '    <tr>';
68
                        $output .= '    <tr>';
69
                        $output .= '         <th>Setting</th>';
69
                        $output .= '         <th>'._L('Setting').'</th>';
70
                        $output .= '         <th>Description</th>';
70
                        $output .= '         <th>'._L('Description').'</th>';
71
                        $output .= '         <th>Value</th>';
71
                        $output .= '         <th>'._L('Value').'</th>';
72
                        $output .= '         <th>Update</th>';
72
                        $output .= '         <th>'._L('Update').'</th>';
73
                        $output .= '    </tr>';
73
                        $output .= '    </tr>';
74
 
74
 
75
                        OIDplus::config(); // <-- make sure that the config table is loaded/filled correctly before we do a select
75
                        OIDplus::config(); // <-- make sure that the config table is loaded/filled correctly before we do a select
76
 
76
 
77
                        $result = OIDplus::db()->query("select * from ###config where visible = ? order by name", array(true));
77
                        $result = OIDplus::db()->query("select * from ###config where visible = ? order by name", array(true));
Line 84... Line 84...
84
                                        if (strlen($desc) > 100) $desc = substr($desc, 0, 100) . '...';
84
                                        if (strlen($desc) > 100) $desc = substr($desc, 0, 100) . '...';
85
                                        $output .= '     <td style="word-break: break-all;">'.htmlentities($desc).'</td>';
85
                                        $output .= '     <td style="word-break: break-all;">'.htmlentities($desc).'</td>';
86
                                        $output .= '     <td>&nbsp;</td>';
86
                                        $output .= '     <td>&nbsp;</td>';
87
                                } else {
87
                                } else {
88
                                        $output .= '     <td><input type="text" id="config_'.$row->name.'" value="'.htmlentities($row->value).'"></td>';
88
                                        $output .= '     <td><input type="text" id="config_'.$row->name.'" value="'.htmlentities($row->value).'"></td>';
89
                                        $output .= '     <td><button type="button" name="config_update_'.$row->name.'" id="config_update_'.$row->name.'" class="btn btn-success btn-xs update" onclick="crudActionConfigUpdate('.js_escape($row->name).')">Update</button></td>';
89
                                        $output .= '     <td><button type="button" name="config_update_'.$row->name.'" id="config_update_'.$row->name.'" class="btn btn-success btn-xs update" onclick="crudActionConfigUpdate('.js_escape($row->name).')">'._L('Update').'</button></td>';
90
                                }
90
                                }
91
                                $output .= '</tr>';
91
                                $output .= '</tr>';
92
                        }
92
                        }
93
 
93
 
94
                        $output .= '</table>';
94
                        $output .= '</table>';
95
                        $output .= '</div></div>';
95
                        $output .= '</div></div>';
96
 
96
 
97
                        $output .= '<br><p>See also:</p>';
97
                        $output .= '<br><p>'._L('See also').':</p>';
98
                        $output .= '<ul>';
98
                        $output .= '<ul>';
99
                        $output .= '<li><a href="'.OIDplus::getSystemUrl().'setup/">Setup part 1: Create config.php (contains database settings, ReCAPTCHA, admin password and SSL enforcement)</a></li>';
99
                        $output .= '<li><a href="'.OIDplus::getSystemUrl().'setup/">'._L('Setup part 1: Create %1 (contains database settings, ReCAPTCHA, admin password and SSL enforcement)','userdata/baseconfig/config.inc.php').'</a></li>';
100
                        if (class_exists('OIDplusPageAdminOOBE')) {
100
                        if (class_exists('OIDplusPageAdminOOBE')) {
101
                                $reflector = new \ReflectionClass('OIDplusPageAdminOOBE');
101
                                $reflector = new \ReflectionClass('OIDplusPageAdminOOBE');
102
                                $path = dirname($reflector->getFilename());
102
                                $path = dirname($reflector->getFilename());
103
                                $output .= '<li><a href="'.OIDplus::webpath($path).'oobe.php">Setup part 2: Basic settings (they are all available above, too)</a></li>';
103
                                $output .= '<li><a href="'.OIDplus::webpath($path).'oobe.php">'._L('Setup part 2: Basic settings (they are all available above, too)').'</a></li>';
104
                        } else {
104
                        } else {
105
                                $output .= '<li>Setup part 2 requires plugin OIDplusPageAdminOOBE (the basic settings are all available above, too)</a></li>';
105
                                $output .= '<li>'._L('Setup part 2 requires plugin %1 (the basic settings are all available above, too)','OIDplusPageAdminOOBE').'</a></li>';
106
                        }
106
                        }
107
                        $output .= '</ul>';
107
                        $output .= '</ul>';
108
 
108
 
109
                        $out['text'] = $output;
109
                        $out['text'] = $output;
110
                }
110
                }
Line 120... Line 120...
120
                }
120
                }
121
 
121
 
122
                $json[] = array(
122
                $json[] = array(
123
                        'id' => 'oidplus:edit_config',
123
                        'id' => 'oidplus:edit_config',
124
                        'icon' => $tree_icon,
124
                        'icon' => $tree_icon,
125
                        'text' => 'System config'
125
                        'text' => _L('System configuration')
126
                );
126
                );
127
 
127
 
128
                return true;
128
                return true;
129
        }
129
        }
130
 
130