Subversion Repositories oidplus

Rev

Rev 148 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
148 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2019 Daniel Marschall, ViaThinkSoft
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
 
20
if (!defined('IN_OIDPLUS')) die();
21
 
22
class OIDplusPageAdminPlugins extends OIDplusPagePlugin {
23
        public function type() {
24
                return 'admin';
25
        }
26
 
27
        public function priority() {
28
                return 800;
29
        }
30
 
31
        public function action(&$handled) {
32
        }
33
 
34
        public function init($html=true) {
35
        }
36
 
37
        public function cfgSetValue($name, $value) {
38
        }
39
 
40
        public function gui($id, &$out, &$handled) {
41
                if ($id == 'oidplus:system_plugins') {
42
                        $handled = true;
43
 
44
                        if (!OIDplus::authUtils()::isAdminLoggedIn()) {
45
                                $out['icon'] = 'img/error_big.png';
46
                                $out['text'] .= '<p>You need to <a '.oidplus_link('oidplus:login').'>log in</a> as administrator.</p>';
47
                                return $out;
48
                        }
49
 
50
                        $out['title'] = "Installed plugins";
51
                        $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/icon_big.png' : '';
52
 
53
                        if (count($plugins = OIDplus::getPagePlugins('public')) > 0) {
54
                                $out['text'] .= '<p><u>Public page plugins:</u></p><ul>';
55
                                foreach ($plugins as $plugin) {
150 daniel-mar 56
                                        $out['text'] .= '<li>'.htmlentities(get_class($plugin)).'</li>'; // TODO: human friendly names
148 daniel-mar 57
                                }
58
                                $out['text'] .= '</ul>';
59
                        }
60
 
61
                        if (count($plugins = OIDplus::getPagePlugins('ra')) > 0) {
62
                                $out['text'] .= '<p><u>RA page plugins:</u></p><ul>';
63
                                foreach ($plugins as $plugin) {
150 daniel-mar 64
                                        $out['text'] .= '<li>'.htmlentities(get_class($plugin)).'</li>'; // TODO: human friendly names
148 daniel-mar 65
                                }
66
                                $out['text'] .= '</ul>';
67
                        }
68
 
69
                        if (count($plugins = OIDplus::getPagePlugins('admin')) > 0) {
70
                                $out['text'] .= '<p><u>Admin page plugins:</u></p><ul>';
71
                                foreach ($plugins as $plugin) {
150 daniel-mar 72
                                        $out['text'] .= '<li>'.htmlentities(get_class($plugin)).'</li>'; // TODO: human friendly names
148 daniel-mar 73
                                }
74
                                $out['text'] .= '</ul>';
75
                        }
76
 
150 daniel-mar 77
                        $enabled = OIDplus::getRegisteredObjectTypes();
78
                        $disabled = OIDplus::getDisabledObjectTypes();
79
                        $plugins = array_merge($enabled, $disabled);
80
                        if (count($plugins) > 0) {
81
                                $out['text'] .= '<p><u>Object types:</u></p><ul>';
148 daniel-mar 82
                                foreach ($plugins as $ot) {
150 daniel-mar 83
                                        if (in_array($ot, $enabled)) {
84
                                                $out['text'] .= '<li>'.htmlentities($ot::objectTypeTitle()).' ('.htmlentities($ot::ns()).')</li>';
85
                                        } else {
86
                                                $out['text'] .= '<li><font color="gray">'.htmlentities($ot::objectTypeTitle()).' ('.htmlentities($ot::ns()).', disabled)</font></li>';
87
                                        }
148 daniel-mar 88
                                }
89
                                $out['text'] .= '</ul>';
90
                        }
91
 
150 daniel-mar 92
                        if (count($plugins = OIDplus::getDatabasePlugins()) > 0) {
93
                                $out['text'] .= '<p><u>Database plugins:</u></p><ul>';
94
                                foreach ($plugins as $plugin) {
95
                                        if ($plugin::name() == OIDPLUS_DATABASE_PLUGIN) {
96
                                                $out['text'] .= '<li><b>'.htmlentities($plugin::name()).'</b></li>';
97
                                        } else {
98
                                                $out['text'] .= '<li>'.htmlentities($plugin::name()).'</li>';
99
                                        }
148 daniel-mar 100
                                }
101
                                $out['text'] .= '</ul>';
102
                        }
103
                }
104
        }
105
 
106
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
107
                if (file_exists(__DIR__.'/treeicon.png')) {
108
                        $tree_icon = 'plugins/'.basename(dirname(__DIR__)).'/'.basename(__DIR__).'/treeicon.png';
109
                } else {
110
                        $tree_icon = null; // default icon (folder)
111
                }
112
 
113
                $json[] = array(
114
                        'id' => 'oidplus:system_plugins',
115
                        'icon' => $tree_icon,
116
                        'text' => 'Plugins'
117
                );
118
 
119
                return true;
120
        }
121
 
122
        public function tree_search($request) {
123
                return false;
124
        }
125
}
126
 
127
OIDplus::registerPagePlugin(new OIDplusPageAdminPlugins());