Subversion Repositories oidplus

Rev

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

Rev Author Line No. Line
61 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
class OIDplusPageAdminOIDInfoExport extends OIDplusPagePlugin {
21
        public function type() {
22
                return 'admin';
23
        }
24
 
25
        public function priority() {
26
                return 400;
27
        }
28
 
29
        public function action(&$handled) {
30
                // Nothing
31
        }
32
 
75 daniel-mar 33
        public function init($html=true) {
34
                OIDplus::config()->prepareConfigKey('oidinfo_export_protected', 'OID-info.com export interface protected (requires admin log in), values 0/1', '1', 0, 1);
61 daniel-mar 35
        }
36
 
37
        public function cfgSetValue($name, $value) {
38
                if ($name == 'oidinfo_export_protected') {
39
                        if (($value != '0') && ($value != '1')) {
40
                                throw new Exception("Please enter either 0 or 1.");
41
                        }
42
                }
43
        }
44
 
45
        public function gui($id, &$out, &$handled) {
46
                if ($id === 'oidplus:export') {
47
                        $handled = true;
48
                        $out['title'] = 'Data export';
49
                        $out['icon'] = file_exists(__DIR__.'/icon_big.png') ? 'plugins/adminPages/'.basename(__DIR__).'/icon_big.png' : '';
50
 
51
                        if (!OIDplus::authUtils()::isAdminLoggedIn()) {
52
                                $out['icon'] = 'img/error_big.png';
53
                                $out['text'] .= '<p>You need to <a href="?goto=oidplus:login">log in</a> as administrator.</p>';
54
                        } else {
55
                                $out['text'] = '<p>Here you can prepare the data export to <b>oid-info.com</b>.</p>'.
56
                                               '<p><a href="plugins/adminPages/'.basename(__DIR__).'/oidinfo_export.php">Generate XML (all)</a></p>'.
57
                                               '<p><a href="plugins/adminPages/'.basename(__DIR__).'/oidinfo_export.php?online=1">Generate XML (only non-existing)</a></p>'.
58
                                               '<p><a href="http://www.oid-info.com/submit.htm">Upload to oid-info.com</a></p>';
59
                        }
60
                }
61
        }
62
 
106 daniel-mar 63
        public function tree(&$json, $ra_email=null, $nonjs=false, $req_goto='') {
61 daniel-mar 64
                if (file_exists(__DIR__.'/treeicon.png')) {
65
                        $tree_icon = 'plugins/adminPages/'.basename(__DIR__).'/treeicon.png';
66
                } else {
67
                        $tree_icon = null; // default icon (folder)
68
                }
69
 
70
                $json[] = array(
71
                        'id' => 'oidplus:export',
72
                        'icon' => $tree_icon,
73
                        'text' => 'Data export'
74
                );
104 daniel-mar 75
 
76
                return true;
61 daniel-mar 77
        }
78
}
79
 
80
OIDplus::registerPagePlugin(new OIDplusPageAdminOIDInfoExport());