1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* You may not change or alter any portion of this comment or credits |
5
|
|
|
* of supporting developers from this source code or any supporting source code |
6
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
7
|
|
|
* |
8
|
|
|
* This program is distributed in the hope that it will be useful, |
9
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
10
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
15
|
|
|
* @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @package |
17
|
|
|
* @since |
18
|
|
|
* @author XOOPS Development Team |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use Xmf\Module\Admin; |
22
|
|
|
use Xmf\Request; |
23
|
|
|
use Xmf\Yaml; |
24
|
|
|
use XoopsModules\Xfguestbook\Common; |
25
|
|
|
|
26
|
|
|
require_once __DIR__ . '/admin_header.php'; |
27
|
|
|
xoops_cp_header(); |
28
|
|
|
|
29
|
|
|
$adminObject = Admin::getInstance(); |
30
|
|
|
|
31
|
|
|
$folder[] = '/uploads/xfguestbook/'; |
32
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xfguestbook_msg') . ' WHERE moderate>0'); |
33
|
|
|
[$totalWaitingMsgs] = $xoopsDB->fetchRow($result); |
34
|
|
|
|
35
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xfguestbook_msg') . ' WHERE moderate=0'); |
36
|
|
|
[$totalModerateMsgs] = $xoopsDB->fetchRow($result); |
37
|
|
|
|
38
|
|
|
$adminObject->addInfoBox(MD_XFGUESTBOOK_MSGCONF); |
39
|
|
|
|
40
|
|
|
if (0 == $totalWaitingMsgs) { |
41
|
|
|
//$adminObject->addLineLabel(MD_XFGUESTBOOK_MSGCONF, MD_XFGUESTBOOK_MSGWAITING, $totalNewMsg, 'Green'); |
42
|
|
|
$adminObject->addInfoBoxLine(sprintf(MD_XFGUESTBOOK_MSGWAITING, "<span style='color: #008012; font-weight: bold;'>" . $totalWaitingMsgs . '</span>'), '', 'green'); |
43
|
|
|
} else { |
44
|
|
|
$adminObject->addInfoBoxLine(sprintf(MD_XFGUESTBOOK_MSGWAITING, "<span style='color: #cb000b; font-weight: bold;'>" . $totalWaitingMsgs . '</span>'), '', 'red'); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
if (0 < $totalModerateMsgs) { |
48
|
|
|
//$adminObject->addLineLabel(MD_XFGUESTBOOK_MSGWAITING, $totalNewMsg, 'Green'); |
49
|
|
|
$adminObject->addInfoBoxLine(sprintf(MD_XFGUESTBOOK_MSGMODERATE, "<span style='color: #008012; font-weight: bold;'>" . $totalModerateMsgs . '</span>'), '', 'green'); |
50
|
|
|
} else { |
51
|
|
|
$adminObject->addInfoBoxLine(sprintf(MD_XFGUESTBOOK_MSGMODERATE, "<span style='color: #cb000b; font-weight: bold;'>" . $totalModerateMsgs . '</span>'), '', 'red'); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
//check or upload folders |
55
|
|
|
$configurator = new Common\Configurator(); |
56
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
57
|
|
|
$utility::createFolder($configurator->uploadFolders[$i]); |
58
|
|
|
$adminObject->addConfigBoxLine($configurator->uploadFolders[$i], 'folder'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
62
|
|
|
|
63
|
|
|
//check for latest release |
64
|
|
|
$newRelease = $utility->checkVerModule($helper); |
65
|
|
|
if (!empty($newRelease)) { |
66
|
|
|
$adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
//------------- Test Data ---------------------------- |
70
|
|
|
|
71
|
|
|
if ($helper->getConfig('displaySampleButton')) { |
72
|
|
|
$yamlFile = dirname(__DIR__) . '/config/admin.yml'; |
73
|
|
|
$config = loadAdminConfig($yamlFile); |
74
|
|
|
$displaySampleButton = $config['displaySampleButton']; |
75
|
|
|
|
76
|
|
|
if (1 == $displaySampleButton) { |
77
|
|
|
xoops_loadLanguage('admin/modulesadmin', 'system'); |
78
|
|
|
require dirname(__DIR__) . '/testdata/index.php'; |
79
|
|
|
|
80
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
81
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); |
82
|
|
|
// $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); |
83
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
84
|
|
|
} else { |
85
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
86
|
|
|
$displaySampleButton = $config['displaySampleButton']; |
87
|
|
|
} |
88
|
|
|
$adminObject->displayButton('left', ''); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
//------------- End Test Data ---------------------------- |
92
|
|
|
|
93
|
|
|
$adminObject->displayIndex(); |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param $yamlFile |
97
|
|
|
* @return array|bool |
98
|
|
|
*/ |
99
|
|
|
function loadAdminConfig($yamlFile) |
100
|
|
|
{ |
101
|
|
|
$config = Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps |
102
|
|
|
return $config; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @param $yamlFile |
107
|
|
|
*/ |
108
|
|
|
function hideButtons($yamlFile) |
109
|
|
|
{ |
110
|
|
|
$app['displaySampleButton'] = 0; |
|
|
|
|
111
|
|
|
Yaml::save($app, $yamlFile); |
112
|
|
|
redirect_header('index.php', 0, ''); |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param $yamlFile |
117
|
|
|
*/ |
118
|
|
|
function showButtons($yamlFile) |
119
|
|
|
{ |
120
|
|
|
$app['displaySampleButton'] = 1; |
|
|
|
|
121
|
|
|
Yaml::save($app, $yamlFile); |
122
|
|
|
redirect_header('index.php', 0, ''); |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
$op = Request::getString('op', 0, 'GET'); |
126
|
|
|
|
127
|
|
|
switch ($op) { |
128
|
|
|
case 'hide_buttons': |
129
|
|
|
hideButtons($yamlFile); |
130
|
|
|
break; |
131
|
|
|
case 'show_buttons': |
132
|
|
|
showButtons($yamlFile); |
133
|
|
|
break; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
echo $utility::getServerStats(); |
137
|
|
|
|
138
|
|
|
require __DIR__ . '/admin_footer.php'; |
139
|
|
|
|
140
|
|
|
|