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 (http://www.gnu.org/licenses/gpl-2.0.html) |
16
|
|
|
* @package |
17
|
|
|
* @since |
18
|
|
|
* @author XOOPS Development Team |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
use XoopsModules\Xfguestbook\Common; |
22
|
|
|
|
23
|
|
|
require_once __DIR__ . '/admin_header.php'; |
24
|
|
|
xoops_cp_header(); |
25
|
|
|
|
26
|
|
|
$adminObject = \Xmf\Module\Admin::getInstance(); |
27
|
|
|
|
28
|
|
|
$folder[] = '/uploads/xfguestbook/'; |
29
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xfguestbook_msg') . ' WHERE moderate>0'); |
30
|
|
|
list($totalWaitingMsgs) = $xoopsDB->fetchRow($result); |
31
|
|
|
|
32
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xfguestbook_msg') . ' WHERE moderate=0'); |
33
|
|
|
list($totalModerateMsgs) = $xoopsDB->fetchRow($result); |
34
|
|
|
|
35
|
|
|
$adminObject->addInfoBox(MD_XFGUESTBOOK_MSGCONF); |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
if (0 == $totalWaitingMsgs) { |
39
|
|
|
//$adminObject->addLineLabel(MD_XFGUESTBOOK_MSGCONF, MD_XFGUESTBOOK_MSGWAITING, $totalNewMsg, 'Green'); |
40
|
|
|
$adminObject->addInfoBoxLine(sprintf(MD_XFGUESTBOOK_MSGWAITING, "<span style='color: #008012; font-weight: bold;'>" . $totalWaitingMsgs . '</span>'), '', 'green'); |
41
|
|
|
} else { |
42
|
|
|
$adminObject->addInfoBoxLine(sprintf(MD_XFGUESTBOOK_MSGWAITING, "<span style='color: #cb000b; font-weight: bold;'>" . $totalWaitingMsgs . '</span>'), '', 'red'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
if (0 < $totalModerateMsgs) { |
46
|
|
|
//$adminObject->addLineLabel(MD_XFGUESTBOOK_MSGWAITING, $totalNewMsg, 'Green'); |
47
|
|
|
$adminObject->addInfoBoxLine(sprintf(MD_XFGUESTBOOK_MSGMODERATE, "<span style='color: #008012; font-weight: bold;'>" . $totalModerateMsgs . '</span>'), '', 'green'); |
48
|
|
|
} else { |
49
|
|
|
$adminObject->addInfoBoxLine(sprintf(MD_XFGUESTBOOK_MSGMODERATE, "<span style='color: #cb000b; font-weight: bold;'>" . $totalModerateMsgs . '</span>'), '', 'red'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
//check or upload folders |
53
|
|
|
$configurator = new Common\Configurator(); |
54
|
|
|
foreach (array_keys($configurator->uploadFolders) as $i) { |
55
|
|
|
$utility::createFolder($configurator->uploadFolders[$i]); |
56
|
|
|
$adminObject->addConfigBoxLine($configurator->uploadFolders[$i], 'folder'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$adminObject->displayNavigation(basename(__FILE__)); |
60
|
|
|
|
61
|
|
|
//check for latest release |
62
|
|
|
$newRelease = $utility->checkVerModule($helper); |
63
|
|
|
if (!empty($newRelease)) { |
64
|
|
|
$adminObject->addItemButton($newRelease[0], $newRelease[1], 'download', 'style="color : Red"'); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
//------------- Test Data ---------------------------- |
68
|
|
|
|
69
|
|
|
if ($helper->getConfig('displaySampleButton')) { |
70
|
|
|
$yamlFile = dirname(__DIR__) . '/config/admin.yml'; |
71
|
|
|
$config = loadAdminConfig($yamlFile); |
72
|
|
|
$displaySampleButton = $config['displaySampleButton']; |
73
|
|
|
|
74
|
|
|
if (1 == $displaySampleButton) { |
75
|
|
|
xoops_loadLanguage('admin/modulesadmin', 'system'); |
76
|
|
|
require __DIR__ . '/../testdata/index.php'; |
77
|
|
|
|
78
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'ADD_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=load', 'add'); |
79
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SAVE_SAMPLEDATA'), '__DIR__ . /../../testdata/index.php?op=save', 'add'); |
80
|
|
|
// $adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA'), '__DIR__ . /../../testdata/index.php?op=exportschema', 'add'); |
81
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'HIDE_SAMPLEDATA_BUTTONS'), '?op=hide_buttons', 'delete'); |
82
|
|
|
} else { |
83
|
|
|
$adminObject->addItemButton(constant('CO_' . $moduleDirNameUpper . '_' . 'SHOW_SAMPLEDATA_BUTTONS'), '?op=show_buttons', 'add'); |
84
|
|
|
$displaySampleButton = $config['displaySampleButton']; |
85
|
|
|
} |
86
|
|
|
$adminObject->displayButton('left', ''); |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
//------------- End Test Data ---------------------------- |
90
|
|
|
|
91
|
|
|
$adminObject->displayIndex(); |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param $yamlFile |
95
|
|
|
* @return array|bool |
96
|
|
|
*/ |
97
|
|
|
function loadAdminConfig($yamlFile) |
98
|
|
|
{ |
99
|
|
|
$config = \Xmf\Yaml::readWrapped($yamlFile); // work with phpmyadmin YAML dumps |
100
|
|
|
return $config; |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @param $yamlFile |
105
|
|
|
*/ |
106
|
|
|
function hideButtons($yamlFile) |
107
|
|
|
{ |
108
|
|
|
$app['displaySampleButton'] = 0; |
|
|
|
|
109
|
|
|
\Xmf\Yaml::save($app, $yamlFile); |
110
|
|
|
redirect_header('index.php', 0, ''); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param $yamlFile |
115
|
|
|
*/ |
116
|
|
|
function showButtons($yamlFile) |
117
|
|
|
{ |
118
|
|
|
$app['displaySampleButton'] = 1; |
|
|
|
|
119
|
|
|
\Xmf\Yaml::save($app, $yamlFile); |
120
|
|
|
redirect_header('index.php', 0, ''); |
121
|
|
|
} |
122
|
|
|
|
123
|
|
|
$op = \Xmf\Request::getString('op', 0, 'GET'); |
124
|
|
|
|
125
|
|
|
switch ($op) { |
126
|
|
|
case 'hide_buttons': |
127
|
|
|
hideButtons($yamlFile); |
128
|
|
|
break; |
129
|
|
|
case 'show_buttons': |
130
|
|
|
showButtons($yamlFile); |
131
|
|
|
break; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
echo $utility::getServerStats(); |
135
|
|
|
|
136
|
|
|
require __DIR__ . '/admin_footer.php'; |
137
|
|
|
|
138
|
|
|
|