1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
/* |
3
|
|
|
You may not change or alter any portion of this comment or credits |
4
|
|
|
of supporting developers from this source code or any supporting source code |
5
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
|
7
|
|
|
This program is distributed in the hope that it will be useful, |
8
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Module: Waiting |
14
|
|
|
* |
15
|
|
|
* @category Module |
16
|
|
|
* @author Kazumi Ono (AKA onokazu) |
17
|
|
|
* @author XOOPS Module Development Team |
18
|
|
|
* @copyright {@link https://xoops.org 2001-2016 XOOPS Project} |
19
|
|
|
* @license {@link https://www.fsf.org/copyleft/gpl.html GNU public license} |
20
|
|
|
* @link https://www.myweb.ne.jp/ |
21
|
|
|
* @link https://xoops.org XOOPS |
22
|
|
|
* @since 2.00 |
23
|
|
|
*/ |
24
|
|
|
|
25
|
|
|
use XoopsModules\Waiting\Helper; |
26
|
|
|
|
27
|
|
|
/** @var Helper $helper */ |
28
|
|
|
|
29
|
|
|
// EXTENSIBLE "waiting block" by plugins in both waiting and modules |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @param $options |
33
|
|
|
* @return array |
34
|
|
|
*/ |
35
|
|
|
function b_waiting_waiting_show($options) |
36
|
|
|
{ |
37
|
|
|
$userLang = $GLOBALS['xoopsConfig']['language']; |
38
|
|
|
|
39
|
|
|
$sql_cache_min = empty($options[1]) ? 0 : (int)$options[1]; |
40
|
|
|
$sql_cache_file = XOOPS_CACHE_PATH . '/waiting_touch'; |
41
|
|
|
|
42
|
|
|
// SQL cache check (you have to use this cache with block's cache by system) |
43
|
|
|
if (is_file($sql_cache_file)) { |
44
|
|
|
$sql_cache_mtime = filemtime($sql_cache_file); |
45
|
|
|
if (time() < $sql_cache_mtime + $sql_cache_min * 60) { |
46
|
|
|
return []; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
unlink($sql_cache_file); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
require_once \dirname(__DIR__) . '/include/functions.php'; |
53
|
|
|
|
54
|
|
|
$helper = Helper::getInstance(); |
55
|
|
|
// read language files for plugins |
56
|
|
|
$helper->loadLanguage('plugins'); |
57
|
|
|
|
58
|
|
|
$plugins_path = XOOPS_ROOT_PATH . '/modules/waiting/plugins'; |
|
|
|
|
59
|
|
|
/** @var \XoopsMySQLDatabase $xoopsDB */ |
60
|
|
|
$xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection(); |
|
|
|
|
61
|
|
|
/** @var \XoopsModuleHandler $moduleHandler */ |
62
|
|
|
$moduleHandler = xoops_getHandler('module'); |
63
|
|
|
$block = []; |
64
|
|
|
|
65
|
|
|
// get module's list installed |
66
|
|
|
$mod_lists = $moduleHandler->getList(new \Criteria(''), true); |
67
|
|
|
foreach ($mod_lists as $dirname => $name) { |
68
|
|
|
$plugin_info = waiting_get_plugin_info($dirname, $userLang); |
69
|
|
|
if (empty($plugin_info) || empty($plugin_info['plugin_path'])) { |
70
|
|
|
continue; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
if (!empty($plugin_info['langfile_path'])) { |
74
|
|
|
require_once $plugin_info['langfile_path']; |
75
|
|
|
} |
76
|
|
|
require_once $plugin_info['plugin_path']; |
77
|
|
|
|
78
|
|
|
// call the plugin |
79
|
|
|
if (function_exists(@$plugin_info['func'])) { |
80
|
|
|
// get the list of waitings |
81
|
|
|
$_tmp = call_user_func($plugin_info['func'], $dirname); |
82
|
|
|
if (isset($_tmp['lang_linkname'])) { |
83
|
|
|
if (@$_tmp['pendingnum'] > 0// || $options[0] > 0 |
84
|
|
|
) { |
85
|
|
|
$block['modules'][$dirname]['pending'][] = $_tmp; |
86
|
|
|
} |
87
|
|
|
unset($_tmp); |
88
|
|
|
} else { |
89
|
|
|
// Judging the plugin returns multiple items |
90
|
|
|
// if lang_linkname does not exist |
91
|
|
|
if (is_array($_tmp)) { |
92
|
|
|
foreach ($_tmp as $_one) { |
93
|
|
|
if (isset($_one['pendingnum']) && (int)$_one['pendingnum'] > 0 // || (int)$options[0] > 0 |
94
|
|
|
) { |
95
|
|
|
$block['modules'][$dirname]['pending'][] = $_one; |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
// for older compatibilities |
103
|
|
|
// Hacked by GIJOE |
104
|
|
|
|
105
|
|
|
// $i = 0; |
106
|
|
|
// while (1) { |
107
|
|
|
// $function_name = "b_waiting_{$dirname}_$i"; |
108
|
|
|
// if (function_exists($function_name)) { |
109
|
|
|
// $_tmp = call_user_func($function_name); |
110
|
|
|
// ++$i; |
111
|
|
|
// if ((int)$_tmp['pendingnum'] > 0 || $options[0] > 0) { |
112
|
|
|
// $block['modules'][$dirname]['pending'][] = $_tmp; |
113
|
|
|
// } |
114
|
|
|
// unset($_tmp); |
115
|
|
|
// } else { |
116
|
|
|
// break; |
117
|
|
|
// } |
118
|
|
|
// } |
119
|
|
|
|
120
|
|
|
// End of Hack |
121
|
|
|
|
122
|
|
|
// if(count($block["modules"][$dirname]) > 0){ |
123
|
|
|
if (!empty($block['modules'][$dirname])) { |
124
|
|
|
$block['modules'][$dirname]['name'] = $name; |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
// print_r($block); |
128
|
|
|
// var_dump($block); |
129
|
|
|
|
130
|
|
|
// SQL cache touch (you have to use this cache with block's cache by system) |
131
|
|
|
if (empty($block) && $sql_cache_min > 0) { |
132
|
|
|
$fp = fopen($sql_cache_file, 'wb'); |
133
|
|
|
fclose($fp); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
return $block; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param $options |
141
|
|
|
* @return string |
142
|
|
|
*/ |
143
|
|
|
function b_waiting_waiting_edit($options) |
144
|
|
|
{ |
145
|
|
|
$mod_url = XOOPS_URL . '/modules/waiting'; |
146
|
|
|
|
147
|
|
|
$sql_cache_min = empty($options[1]) ? 0 : (int)$options[1]; |
148
|
|
|
|
149
|
|
|
$form = _MB_WAITING_NOWAITING_DISPLAY . ": <input type='radio' name='options[0]' value='1'"; |
150
|
|
|
if (1 == $options[0]) { |
151
|
|
|
$form .= ' checked'; |
152
|
|
|
} |
153
|
|
|
$form .= '> ' . _YES . "<input type='radio' name='options[0]' value='0'"; |
154
|
|
|
if (0 == $options[0]) { |
155
|
|
|
$form .= ' checked'; |
156
|
|
|
} |
157
|
|
|
$form .= '> ' . _NO . "<br>\n"; |
158
|
|
|
$form .= sprintf(_MINUTES, _MB_WAITING_SQL_CACHE . ": <input type='text' name='options[1]' value='{$sql_cache_min}' size='2'>"); |
159
|
|
|
$form .= "<br>\n<br>\n<a href='{$mod_url}/admin/index.php'><img src='{$mod_url}/assets/images/folder16.gif'>" . _MB_WAITING_LINKTOPLUGINCHECK . '</a>'; |
160
|
|
|
|
161
|
|
|
return $form; |
162
|
|
|
} |
163
|
|
|
|