1
|
|
|
<?php |
2
|
|
|
// $Id: system_blocks.php 8066 2011-11-06 05:09:33Z beckmi $ |
3
|
|
|
// ------------------------------------------------------------------------ // |
4
|
|
|
// XOOPS - PHP Content Management System // |
5
|
|
|
// Copyright (c) 2000 XOOPS.org // |
6
|
|
|
// <http://www.xoops.org/> // |
7
|
|
|
// ------------------------------------------------------------------------ // |
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
11
|
|
|
// (at your option) any later version. // |
12
|
|
|
// // |
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
14
|
|
|
// of supporting developers from this source code or any supporting // |
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
16
|
|
|
// original comment or credit authors. // |
17
|
|
|
// // |
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
21
|
|
|
// GNU General Public License for more details. // |
22
|
|
|
// // |
23
|
|
|
// You should have received a copy of the GNU General Public License // |
24
|
|
|
// along with this program; if not, write to the Free Software // |
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
26
|
|
|
// ------------------------------------------------------------------------ // |
27
|
|
|
// Author: Kazumi Ono (AKA onokazu) // |
28
|
|
|
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ // |
29
|
|
|
// Project: The XOOPS Project // |
30
|
|
|
// ------------------------------------------------------------------------- // |
31
|
|
|
|
32
|
|
|
function b_system_online_show() |
|
|
|
|
33
|
|
|
{ |
34
|
|
|
global $xoopsUser, $xoopsModule; |
|
|
|
|
35
|
|
|
$online_handler =& xoops_getHandler('online'); |
36
|
|
|
mt_srand((double)microtime()*1000000); |
37
|
|
|
// set gc probabillity to 10% for now.. |
38
|
|
|
if (mt_rand(1, 100) < 11) { |
39
|
|
|
$online_handler->gc(300); |
40
|
|
|
} |
41
|
|
|
if (is_object($xoopsUser)) { |
42
|
|
|
$uid = $xoopsUser->getVar('uid'); |
43
|
|
|
$uname = $xoopsUser->getVar('uname'); |
44
|
|
|
} else { |
45
|
|
|
$uid = 0; |
46
|
|
|
$uname = ''; |
47
|
|
|
} |
48
|
|
|
if (is_object($xoopsModule)) { |
49
|
|
|
$online_handler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), $_SERVER['REMOTE_ADDR']); |
50
|
|
|
} else { |
51
|
|
|
$online_handler->write($uid, $uname, time(), 0, $_SERVER['REMOTE_ADDR']); |
52
|
|
|
} |
53
|
|
|
$onlines = $online_handler->getAll(); |
54
|
|
|
if (false != $onlines) { |
55
|
|
|
$total = count($onlines); |
56
|
|
|
$block = array(); |
57
|
|
|
$guests = 0; |
58
|
|
|
$members = ''; |
59
|
|
|
for ($i = 0; $i < $total; $i++) { |
60
|
|
|
if ($onlines[$i]['online_uid'] > 0) { |
61
|
|
|
$members .= ' <a href="' . XOOPS_URL . '/userinfo.php?uid=' . $onlines[$i]['online_uid'] . '" title="' . $onlines[$i]['online_uname'] . '">' . $onlines[$i]['online_uname'] . '</a>,'; |
62
|
|
|
} else { |
63
|
|
|
$guests++; |
64
|
|
|
} |
65
|
|
|
} |
66
|
|
|
$block['online_total'] = sprintf(_ONLINEPHRASE, $total); |
67
|
|
|
if (is_object($xoopsModule)) { |
68
|
|
|
$mytotal = $online_handler->getCount(new Criteria('online_module', $xoopsModule->getVar('mid'))); |
69
|
|
|
$block['online_total'] .= ' ('.sprintf(_ONLINEPHRASEX, $mytotal, $xoopsModule->getVar('name')).')'; |
70
|
|
|
} |
71
|
|
|
$block['lang_members'] = _MEMBERS; |
72
|
|
|
$block['lang_guests'] = _GUESTS; |
73
|
|
|
$block['online_names'] = $members; |
74
|
|
|
$block['online_members'] = $total - $guests; |
75
|
|
|
$block['online_guests'] = $guests; |
76
|
|
|
$block['lang_more'] = _MORE; |
77
|
|
|
return $block; |
78
|
|
|
} else { |
79
|
|
|
return false; |
80
|
|
|
} |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
function b_system_login_show() |
84
|
|
|
{ |
85
|
|
|
global $xoopsUser, $xoopsConfig; |
|
|
|
|
86
|
|
|
if (!$xoopsUser) { |
87
|
|
|
$block = array(); |
88
|
|
|
$block['lang_username'] = _USERNAME; |
89
|
|
|
$block['unamevalue'] = ''; |
90
|
|
|
$block['lang_password'] = _PASSWORD; |
91
|
|
|
$block['lang_login'] = _LOGIN; |
92
|
|
|
$block['lang_lostpass'] = _MB_SYSTEM_LPASS; |
93
|
|
|
$block['lang_registernow'] = _MB_SYSTEM_RNOW; |
94
|
|
|
//$block['lang_rememberme'] = _MB_SYSTEM_REMEMBERME; |
|
|
|
|
95
|
|
|
if ($xoopsConfig['use_ssl'] == 1 && $xoopsConfig['sslloginlink'] != '') { |
96
|
|
|
$block['sslloginlink'] = "<a href=\"javascript:openWithSelfMain('".$xoopsConfig['sslloginlink']."', 'ssllogin', 300, 200);\">"._MB_SYSTEM_SECURE . '</a>'; |
97
|
|
|
} elseif ($xoopsConfig['usercookie']) { |
98
|
|
|
$block['lang_rememberme'] = _MB_SYSTEM_REMEMBERME; |
99
|
|
|
} |
100
|
|
|
return $block; |
101
|
|
|
} |
102
|
|
|
return false; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
function b_system_main_show() |
106
|
|
|
{ |
107
|
|
|
global $xoopsUser,$xoopsModule; |
|
|
|
|
108
|
|
|
$block = array(); |
109
|
|
|
$block['lang_home'] = _MB_SYSTEM_HOME; |
110
|
|
|
$block['lang_close'] = _CLOSE; |
111
|
|
|
$module_handler =& xoops_getHandler('module'); |
112
|
|
|
$criteria = new CriteriaCompo(new Criteria('hasmain', 1)); |
113
|
|
|
$criteria->add(new Criteria('isactive', 1)); |
114
|
|
|
$criteria->add(new Criteria('weight', 0, '>')); |
115
|
|
|
$modules = $module_handler->getObjects($criteria, true); |
116
|
|
|
$moduleperm_handler =& xoops_getHandler('groupperm'); |
117
|
|
|
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
118
|
|
|
$read_allowed = $moduleperm_handler->getItemIds('module_read', $groups); |
119
|
|
|
foreach (array_keys($modules) as $i) { |
120
|
|
|
if (in_array($i, $read_allowed)) { |
121
|
|
|
$block['modules'][$i]['name'] = $modules[$i]->getVar('name'); |
122
|
|
|
$block['modules'][$i]['directory'] = $modules[$i]->getVar('dirname'); |
123
|
|
|
$sublinks = $modules[$i]->subLink(); |
124
|
|
|
if ((!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) { |
125
|
|
|
$block['modules'][$i]['highlight'] = true; |
126
|
|
|
$block['nothome'] = true; |
127
|
|
|
}if ((!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) { |
128
|
|
|
$block['modules'][$i]['highlight'] = true; |
129
|
|
|
$block['nothome'] = true; |
130
|
|
|
} |
131
|
|
|
if ((count($sublinks) > 0) && (!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) { |
132
|
|
|
foreach($sublinks as $sublink){ |
133
|
|
|
$block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => XOOPS_URL.'/modules/'.$modules[$i]->getVar('dirname').'/'.$sublink['url']); |
134
|
|
|
} |
135
|
|
|
} else { |
136
|
|
|
$block['modules'][$i]['sublinks'] = array(); |
137
|
|
|
} |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
return $block; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
function b_system_search_show() |
144
|
|
|
{ |
145
|
|
|
$block = array(); |
146
|
|
|
$block['lang_search'] = _MB_SYSTEM_SEARCH; |
147
|
|
|
$block['lang_advsearch'] = _MB_SYSTEM_ADVS; |
148
|
|
|
return $block; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
function b_system_user_show() |
152
|
|
|
{ |
153
|
|
|
global $xoopsUser; |
|
|
|
|
154
|
|
|
if (!is_object($xoopsUser)) { |
155
|
|
|
return false; |
156
|
|
|
} |
157
|
|
|
$block = array(); |
158
|
|
|
$block['lang_youraccount'] = _MB_SYSTEM_VACNT; |
159
|
|
|
$block['lang_editaccount'] = _MB_SYSTEM_EACNT; |
160
|
|
|
$block['lang_notifications'] = _MB_SYSTEM_NOTIF; |
161
|
|
|
$block['uid'] = $xoopsUser->getVar('uid'); |
162
|
|
|
$block['lang_logout'] = _MB_SYSTEM_LOUT; |
163
|
|
|
$criteria = new CriteriaCompo(new Criteria('read_msg', 0)); |
164
|
|
|
$criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid'))); |
165
|
|
|
|
166
|
|
|
$pm_handler =& xoops_getHandler('privmessage'); |
167
|
|
|
|
168
|
|
|
$xoopsPreload =& XoopsPreload::getInstance(); |
169
|
|
|
$xoopsPreload->triggerEvent('system.blocks.system_blocks.usershow', array(&$pm_handler)); |
170
|
|
|
|
171
|
|
|
$block['new_messages'] = $pm_handler->getCount($criteria); |
172
|
|
|
$block['lang_inbox'] = _MB_SYSTEM_INBOX; |
173
|
|
|
$block['lang_adminmenu'] = _MB_SYSTEM_ADMENU; |
174
|
|
|
return $block; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
// this block is deprecated |
178
|
|
|
function b_system_waiting_show() |
179
|
|
|
{ |
180
|
|
|
global $xoopsUser; |
|
|
|
|
181
|
|
|
$xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); |
182
|
|
|
$module_handler =& xoops_getHandler('module'); |
183
|
|
|
$block = array(); |
184
|
|
|
|
185
|
|
|
// waiting content for news |
186
|
|
View Code Duplication |
if (xoops_isActiveModule('news') && $module_handler->getCount(new Criteria('dirname', 'news'))) { |
|
|
|
|
187
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('stories') . ' WHERE published=0'); |
188
|
|
|
if ( $result ) { |
189
|
|
|
$block['modules'][0]['adminlink'] = XOOPS_URL . '/modules/news/admin/index.php?op=newarticle'; |
190
|
|
|
list($block['modules'][0]['pendingnum']) = $xoopsDB->fetchRow($result); |
191
|
|
|
$block['modules'][0]['lang_linkname'] = _MB_SYSTEM_SUBMS; |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
// waiting content for mylinks |
196
|
|
|
if (xoops_isActiveModule('mylinks') && $module_handler->getCount(new Criteria('dirname', 'mylinks'))) { |
197
|
|
|
$mlMod = $module_handler->getByDirName('mylinks'); |
198
|
|
|
$tbl_prefix = ($mlMod->version() < 312) ? '' : 'mod_'; |
|
|
|
|
199
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix("{$table_prefix}mylinks_links") . ' WHERE status=0'); |
|
|
|
|
200
|
|
|
if ( $result ) { |
201
|
|
|
$block['modules'][1]['adminlink'] = XOOPS_URL . '/modules/mylinks/admin/main.php?op=listNewLinks'; |
202
|
|
|
list($block['modules'][1]['pendingnum']) = $xoopsDB->fetchRow($result); |
203
|
|
|
$block['modules'][1]['lang_linkname'] = _MB_SYSTEM_WLNKS; |
204
|
|
|
} |
205
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix("{$table_prefix}mylinks_broken")); |
|
|
|
|
206
|
|
|
if ( $result ) { |
207
|
|
|
$block['modules'][2]['adminlink'] = XOOPS_URL . '/modules/mylinks/admin/main.php?op=listBrokenLinks'; |
208
|
|
|
list($block['modules'][2]['pendingnum']) = $xoopsDB->fetchRow($result); |
209
|
|
|
$block['modules'][2]['lang_linkname'] = _MB_SYSTEM_BLNK; |
210
|
|
|
} |
211
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix("{$table_prefix}mylinks_mod")); |
|
|
|
|
212
|
|
|
if ( $result ) { |
213
|
|
|
$block['modules'][3]['adminlink'] = XOOPS_URL . '/modules/mylinks/admin/main.php?op=listModReq'; |
214
|
|
|
list($block['modules'][3]['pendingnum']) = $xoopsDB->fetchRow($result); |
215
|
|
|
$block['modules'][3]['lang_linkname'] = _MB_SYSTEM_MLNKS; |
216
|
|
|
} |
217
|
|
|
unset($mlMod, $result); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
// waiting content for mydownloads |
221
|
|
|
if (xoops_isActiveModule('mydownloads') && $module_handler->getCount(new Criteria('dirname', 'mydownloads'))) { |
222
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_downloads') . ' WHERE status=0'); |
223
|
|
|
if ( $result ) { |
224
|
|
|
$block['modules'][4]['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listNewDownloads'; |
225
|
|
|
list($block['modules'][4]['pendingnum']) = $xoopsDB->fetchRow($result); |
226
|
|
|
$block['modules'][4]['lang_linkname'] = _MB_SYSTEM_WDLS; |
227
|
|
|
} |
228
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_broken') . ''); |
229
|
|
|
if ( $result ) { |
230
|
|
|
$block['modules'][5]['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listBrokenDownloads'; |
231
|
|
|
list($block['modules'][5]['pendingnum']) = $xoopsDB->fetchRow($result); |
232
|
|
|
$block['modules'][5]['lang_linkname'] = _MB_SYSTEM_BFLS; |
233
|
|
|
} |
234
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_mod') . ''); |
235
|
|
|
if ( $result ) { |
236
|
|
|
$block['modules'][6]['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listModReq'; |
237
|
|
|
list($block['modules'][6]['pendingnum']) = $xoopsDB->fetchRow($result); |
238
|
|
|
$block['modules'][6]['lang_linkname'] = _MB_SYSTEM_MFLS; |
239
|
|
|
} |
240
|
|
|
} |
241
|
|
|
|
242
|
|
|
// waiting content for xoops comments |
243
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xoopscomments') . ' WHERE com_status=1'); |
244
|
|
|
if ( $result ) { |
245
|
|
|
$block['modules'][7]['adminlink'] = XOOPS_URL . '/modules/system/admin.php?module=0&status=1&fct=comments'; |
246
|
|
|
list($block['modules'][7]['pendingnum']) = $xoopsDB->fetchRow($result); |
247
|
|
|
$block['modules'][7]['lang_linkname'] =_MB_SYSTEM_COMPEND; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
// waiting content for TDMDownloads |
251
|
|
View Code Duplication |
if (xoops_isActiveModule('TDMdownloads') && $module_handler->getCount(new Criteria('dirname', 'TDMDownloads'))) { |
|
|
|
|
252
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status=0'); |
253
|
|
|
if ( $result ) { |
254
|
|
|
$block['modules'][8]['adminlink'] = XOOPS_URL . '/modules/TDMDownloads/admin/downloads.php?op=list&statut_display=0'; |
255
|
|
|
list($block['modules'][8]['pendingnum']) = $xoopsDB->fetchRow($result); |
256
|
|
|
$block['modules'][8]['lang_linkname'] = _MB_SYSTEM_TDMDOWNLOADS; |
257
|
|
|
} |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
// waiting content for extgallery |
261
|
|
View Code Duplication |
if (xoops_isActiveModule('extgallery') && $module_handler->getCount(new Criteria('dirname', 'extgallery'))) { |
|
|
|
|
262
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('extgallery_publicphoto') . ' WHERE photo_approved=0'); |
263
|
|
|
if ( $result ) { |
264
|
|
|
$block['modules'][9]['adminlink'] = XOOPS_URL . '/modules/extgallery/admin/photo.php#pending-photo'; |
265
|
|
|
list($block['modules'][9]['pendingnum']) = $xoopsDB->fetchRow($result); |
266
|
|
|
$block['modules'][9]['lang_linkname'] = _MB_SYSTEM_EXTGALLERY; |
267
|
|
|
} |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
// waiting content for smartsection |
271
|
|
View Code Duplication |
if (xoops_isActiveModule('smartsection') && $module_handler->getCount(new Criteria('dirname', 'smartsection'))) { |
|
|
|
|
272
|
|
|
$result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('smartsection_items') . ' WHERE status=1'); |
273
|
|
|
if ( $result ) { |
274
|
|
|
$block['modules'][10]['adminlink'] = XOOPS_URL . '/modules/smartsection/admin/item.php'; |
275
|
|
|
list($block['modules'][10]['pendingnum']) = $xoopsDB->fetchRow($result); |
276
|
|
|
$block['modules'][10]['lang_linkname'] = _MB_SYSTEM_SMARTSECTION; |
277
|
|
|
} |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
return $block; |
281
|
|
|
} |
282
|
|
|
|
283
|
|
|
function b_system_info_show($options) |
284
|
|
|
{ |
285
|
|
|
global $xoopsConfig, $xoopsUser; |
|
|
|
|
286
|
|
|
$xoopsDB =& XoopsDatabaseFactory::getDatabaseConnection(); |
287
|
|
|
$myts =& MyTextSanitizer::getInstance(); |
288
|
|
|
$block = array(); |
289
|
|
|
if (!empty($options[3])) { |
290
|
|
|
$block['showgroups'] = true; |
291
|
|
|
$result = $xoopsDB->query('SELECT u.uid, u.uname, u.email, u.user_viewemail, u.user_avatar, g.name AS groupname FROM ' . $xoopsDB->prefix('groups_users_link') . ' l LEFT JOIN ' . $xoopsDB->prefix('users') . ' u ON l.uid=u.uid LEFT JOIN ' . $xoopsDB->prefix('groups') . " g ON l.groupid=g.groupid WHERE g.group_type='Admin' ORDER BY l.groupid, u.uid"); |
292
|
|
|
if ($xoopsDB->getRowsNum($result) > 0) { |
293
|
|
|
$prev_caption = ''; |
294
|
|
|
$i = 0; |
295
|
|
|
while ($userinfo = $xoopsDB->fetchArray($result)) { |
296
|
|
|
if ($prev_caption != $userinfo['groupname']) { |
297
|
|
|
$prev_caption = $userinfo['groupname']; |
298
|
|
|
$block['groups'][$i]['name'] = $myts->htmlSpecialChars($userinfo['groupname']); |
299
|
|
|
} |
300
|
|
|
if (isset($xoopsUser) && is_object($xoopsUser)) { |
301
|
|
|
$block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlspecialchars($userinfo['uname']), 'msglink' => "<a href=\"javascript:openWithSelfMain('".XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userinfo['uid'] . "','pmlite',450,370);\"><img src=\"" . XOOPS_URL . "/images/icons/pm_small.gif\" border=\"0\" width=\"27\" height=\"17\" alt=\"\"></a>", 'avatar' => XOOPS_UPLOAD_URL . '/' . $userinfo['user_avatar']); |
302
|
|
|
} else { |
303
|
|
|
if ($userinfo['user_viewemail']) { |
304
|
|
|
$block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlspecialchars($userinfo['uname']), 'msglink' => '<a href="mailto:'.$userinfo['email'].'"><img src="'.XOOPS_URL.'/images/icons/em_small.gif" border="0" width="16" height="14" alt=""></a>', 'avatar' => XOOPS_UPLOAD_URL.'/'.$userinfo['user_avatar']); |
305
|
|
|
} else { |
306
|
|
|
$block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlspecialchars($userinfo['uname']), 'msglink' => ' ', 'avatar' => XOOPS_UPLOAD_URL.'/'.$userinfo['user_avatar']); |
307
|
|
|
} |
308
|
|
|
} |
309
|
|
|
$i++; |
310
|
|
|
} |
311
|
|
|
} |
312
|
|
|
} else { |
313
|
|
|
$block['showgroups'] = false; |
314
|
|
|
} |
315
|
|
|
$block['logourl'] = XOOPS_URL.'/images/'.$options[2]; |
316
|
|
|
$block['recommendlink'] = "<a href=\"javascript:openWithSelfMain('".XOOPS_URL . '/misc.php?action=showpopups&type=friend&op=sendform&t=' . time() . "','friend'," . $options[0] . ',' . $options[1] . ")\">" . _MB_SYSTEM_RECO . '</a>'; |
317
|
|
|
return $block; |
318
|
|
|
} |
319
|
|
|
|
320
|
|
|
function b_system_newmembers_show($options) |
321
|
|
|
{ |
322
|
|
|
$block = array(); |
323
|
|
|
$criteria = new CriteriaCompo(new Criteria('level', 0, '>')); |
324
|
|
|
$limit = (!empty($options[0])) ? $options[0] : 10; |
325
|
|
|
$criteria->setOrder('DESC'); |
326
|
|
|
$criteria->setSort('user_regdate'); |
327
|
|
|
$criteria->setLimit($limit); |
328
|
|
|
$member_handler =& xoops_getHandler('member'); |
329
|
|
|
$newmembers = $member_handler->getUsers($criteria); |
330
|
|
|
$count = count($newmembers); |
331
|
|
|
for ($i = 0; $i < $count; $i++) { |
332
|
|
View Code Duplication |
if ( $options[1] == 1 ) { |
|
|
|
|
333
|
|
|
$block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL.'/'.$newmembers[$i]->getVar('user_avatar') : ''; |
334
|
|
|
} else { |
335
|
|
|
$block['users'][$i]['avatar'] = ''; |
336
|
|
|
} |
337
|
|
|
$block['users'][$i]['id'] = $newmembers[$i]->getVar('uid'); |
338
|
|
|
$block['users'][$i]['name'] = $newmembers[$i]->getVar('uname'); |
339
|
|
|
$block['users'][$i]['joindate'] = formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's'); |
340
|
|
|
} |
341
|
|
|
return $block; |
342
|
|
|
} |
343
|
|
|
|
344
|
|
|
function b_system_topposters_show($options) |
345
|
|
|
{ |
346
|
|
|
$block = array(); |
347
|
|
|
$criteria = new CriteriaCompo(new Criteria('level', 0, '>')); |
348
|
|
|
$limit = (!empty($options[0])) ? $options[0] : 10; |
349
|
|
|
$size = count($options); |
350
|
|
|
for ( $i = 2; $i < $size; $i++) { |
351
|
|
|
$criteria->add(new Criteria('rank', $options[$i], '<>')); |
352
|
|
|
} |
353
|
|
|
$criteria->setOrder('DESC'); |
354
|
|
|
$criteria->setSort('posts'); |
355
|
|
|
$criteria->setLimit($limit); |
356
|
|
|
$member_handler =& xoops_getHandler('member'); |
357
|
|
|
$topposters = $member_handler->getUsers($criteria); |
358
|
|
|
$count = count($topposters); |
359
|
|
|
for ($i = 0; $i < $count; $i++) { |
360
|
|
|
$block['users'][$i]['rank'] = $i+1; |
361
|
|
View Code Duplication |
if ( $options[1] == 1 ) { |
|
|
|
|
362
|
|
|
$block['users'][$i]['avatar'] = $topposters[$i]->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL.'/'.$topposters[$i]->getVar('user_avatar') : ''; |
363
|
|
|
} else { |
364
|
|
|
$block['users'][$i]['avatar'] = ''; |
365
|
|
|
} |
366
|
|
|
$block['users'][$i]['id'] = $topposters[$i]->getVar('uid'); |
367
|
|
|
$block['users'][$i]['name'] = $topposters[$i]->getVar('uname'); |
368
|
|
|
$block['users'][$i]['posts'] = $topposters[$i]->getVar('posts'); |
369
|
|
|
} |
370
|
|
|
return $block; |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
|
374
|
|
|
function b_system_comments_show($options) |
|
|
|
|
375
|
|
|
{ |
376
|
|
|
$block = array(); |
377
|
|
|
include_once XOOPS_ROOT_PATH.'/include/comment_constants.php'; |
378
|
|
|
$comment_handler =& xoops_getHandler('comment'); |
379
|
|
|
$criteria = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE)); |
380
|
|
|
$criteria->setLimit(intval($options[0])); |
381
|
|
|
$criteria->setSort('com_created'); |
382
|
|
|
$criteria->setOrder('DESC'); |
383
|
|
|
|
384
|
|
|
// Check modules permissions |
385
|
|
|
global $xoopsUser; |
|
|
|
|
386
|
|
|
$moduleperm_handler =& xoops_getHandler('groupperm'); |
387
|
|
|
$gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); |
388
|
|
|
$criteria1 = new CriteriaCompo(new Criteria('gperm_name','module_read','=')); |
389
|
|
|
$criteria1->add(new Criteria('gperm_groupid', '('.implode(',', $gperm_groupid).')', 'IN')); |
390
|
|
|
$perms = $moduleperm_handler->getObjects($criteria1, true); |
391
|
|
|
$modIds = array(); |
392
|
|
|
foreach($perms as $item) { |
393
|
|
|
$modIds[] = $item->getVar('gperm_itemid'); |
394
|
|
|
} |
395
|
|
|
if(count($modIds) > 0 ) { |
396
|
|
|
$modIds = array_unique($modIds); |
397
|
|
|
$criteria->add(new Criteria('com_modid', '('.implode(',', $modIds).')', 'IN')); |
398
|
|
|
} |
399
|
|
|
// Check modules permissions |
400
|
|
|
|
401
|
|
|
$comments = $comment_handler->getObjects($criteria, true); |
402
|
|
|
$member_handler =& xoops_getHandler('member'); |
403
|
|
|
$module_handler =& xoops_getHandler('module'); |
404
|
|
|
$modules = $module_handler->getObjects(new Criteria('hascomments', 1), true); |
405
|
|
|
$comment_config = array(); |
406
|
|
|
foreach (array_keys($comments) as $i) { |
407
|
|
|
$mid = $comments[$i]->getVar('com_modid'); |
408
|
|
|
$com['module'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'</a>'; |
|
|
|
|
409
|
|
|
if (!isset($comment_config[$mid])) { |
410
|
|
|
$comment_config[$mid] = $modules[$mid]->getInfo('comments'); |
411
|
|
|
} |
412
|
|
|
$com['id'] = $i; |
|
|
|
|
413
|
|
|
$com['title'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&com_id='.$i.'&com_rootid='.$comments[$i]->getVar('com_rootid').'&'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'</a>'; |
414
|
|
|
$com['icon'] = htmlspecialchars( $comments[$i]->getVar('com_icon'), ENT_QUOTES ); |
415
|
|
|
$com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif'; |
416
|
|
|
$com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m'); |
417
|
|
|
if ($comments[$i]->getVar('com_uid') > 0) { |
418
|
|
|
$poster = $member_handler->getUser($comments[$i]->getVar('com_uid')); |
419
|
|
|
if (is_object($poster)) { |
420
|
|
|
$com['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>'; |
421
|
|
|
} else { |
422
|
|
|
$com['poster'] = $GLOBALS['xoopsConfig']['anonymous']; |
423
|
|
|
} |
424
|
|
|
} else { |
425
|
|
|
$com['poster'] = $GLOBALS['xoopsConfig']['anonymous']; |
426
|
|
|
} |
427
|
|
|
$block['comments'][] =& $com; |
428
|
|
|
unset($com); |
429
|
|
|
} |
430
|
|
|
return $block; |
431
|
|
|
} |
432
|
|
|
|
433
|
|
|
// RMV-NOTIFY |
434
|
|
|
function b_system_notification_show() |
|
|
|
|
435
|
|
|
{ |
436
|
|
|
global $xoopsConfig, $xoopsUser, $xoopsModule; |
|
|
|
|
437
|
|
|
include_once XOOPS_ROOT_PATH . '/include/notification_functions.php'; |
438
|
|
|
include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php'; |
439
|
|
|
// Notification must be enabled, and user must be logged in |
440
|
|
|
if (empty($xoopsUser) || !notificationEnabled('block')) { |
441
|
|
|
return false; // do not display block |
442
|
|
|
} |
443
|
|
|
$notification_handler =& xoops_getHandler('notification'); |
444
|
|
|
// Now build the a nested associative array of info to pass |
445
|
|
|
// to the block template. |
446
|
|
|
$block = array(); |
447
|
|
|
$categories =& notificationSubscribableCategoryInfo(); |
448
|
|
|
if (empty($categories)) { |
449
|
|
|
return false; |
450
|
|
|
} |
451
|
|
|
foreach ($categories as $category) { |
452
|
|
|
$section['name'] = $category['name']; |
|
|
|
|
453
|
|
|
$section['title'] = $category['title']; |
|
|
|
|
454
|
|
|
$section['description'] = $category['description']; |
455
|
|
|
$section['itemid'] = $category['item_id']; |
456
|
|
|
$section['events'] = array(); |
457
|
|
|
$subscribed_events = $notification_handler->getSubscribedEvents ($category['name'], $category['item_id'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid')); |
458
|
|
|
foreach (notificationEvents($category['name'], true) as $event) { |
459
|
|
|
if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { |
460
|
|
|
continue; |
461
|
|
|
} |
462
|
|
|
$subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0; |
463
|
|
|
$section['events'][$event['name']] = array ('name'=>$event['name'], 'title'=>$event['title'], 'caption'=>$event['caption'], 'description'=>$event['description'], 'subscribed'=>$subscribed); |
464
|
|
|
} |
465
|
|
|
$block['categories'][$category['name']] = $section; |
466
|
|
|
} |
467
|
|
|
// Additional form data |
468
|
|
|
$block['target_page'] = 'notification_update.php'; |
469
|
|
|
// FIXME: better or more standardized way to do this? |
470
|
|
|
$script_url = explode('/', $_SERVER['PHP_SELF']); |
471
|
|
|
$script_name = $script_url[count($script_url)-1]; |
472
|
|
|
$block['redirect_script'] = $script_name; |
473
|
|
|
$block['submit_button'] = _NOT_UPDATENOW; |
474
|
|
|
$block['notification_token'] = $GLOBALS['xoopsSecurity']->createToken(); |
475
|
|
|
return $block; |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
function b_system_comments_edit($options) |
479
|
|
|
{ |
480
|
|
|
$inputtag = "<input type='text' name='options[]' value='".intval($options[0])."'>"; |
481
|
|
|
$form = sprintf(_MB_SYSTEM_DISPLAYC, $inputtag); |
482
|
|
|
return $form; |
483
|
|
|
} |
484
|
|
|
|
485
|
|
|
function b_system_topposters_edit($options) |
486
|
|
|
{ |
487
|
|
|
include_once XOOPS_ROOT_PATH.'/class/xoopslists.php'; |
488
|
|
|
$inputtag = "<input type='text' name='options[]' value='".intval($options[0])."'>"; |
489
|
|
|
$form = sprintf(_MB_SYSTEM_DISPLAY,$inputtag); |
490
|
|
|
$form .= '<br>' . _MB_SYSTEM_DISPLAYA . " <input type='radio' id='options[]' name='options[]' value='1'"; |
491
|
|
|
if ( $options[1] == 1 ) { |
492
|
|
|
$form .= " checked='checked'"; |
493
|
|
|
} |
494
|
|
|
$form .= '> ' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'"; |
495
|
|
|
if ( $options[1] == 0 ) { |
496
|
|
|
$form .= " checked='checked'"; |
497
|
|
|
} |
498
|
|
|
$form .= '> ' . _NO . ''; |
499
|
|
|
$form .= '<br>' . _MB_SYSTEM_NODISPGR . "<br><select id='options[]' name='options[]' multiple='multiple'>"; |
500
|
|
|
$ranks = XoopsLists::getUserRankList(); |
501
|
|
|
$size = count($options); |
502
|
|
|
foreach ($ranks as $k => $v) { |
503
|
|
|
$sel = ''; |
504
|
|
|
for ( $i = 2; $i < $size; $i++ ) { |
505
|
|
|
if ($k == $options[$i]) { |
506
|
|
|
$sel = " selected='selected'"; |
507
|
|
|
} |
508
|
|
|
} |
509
|
|
|
$form .= "<option value='$k'$sel>$v</option>"; |
510
|
|
|
} |
511
|
|
|
$form .= '</select>'; |
512
|
|
|
return $form; |
513
|
|
|
} |
514
|
|
|
|
515
|
|
|
function b_system_newmembers_edit($options) |
516
|
|
|
{ |
517
|
|
|
$inputtag = "<input type='text' name='options[]' value='".$options[0]."'>"; |
518
|
|
|
$form = sprintf(_MB_SYSTEM_DISPLAY,$inputtag); |
519
|
|
|
$form .= '<br>' . _MB_SYSTEM_DISPLAYA . " <input type='radio' id='options[]' name='options[]' value='1'"; |
520
|
|
|
if ( $options[1] == 1 ) { |
521
|
|
|
$form .= " checked='checked'"; |
522
|
|
|
} |
523
|
|
|
$form .= '> ' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'"; |
524
|
|
|
if ( $options[1] == 0 ) { |
525
|
|
|
$form .= " checked='checked'"; |
526
|
|
|
} |
527
|
|
|
$form .= '> ' . _NO . ''; |
528
|
|
|
return $form; |
529
|
|
|
} |
530
|
|
|
|
531
|
|
|
function b_system_info_edit($options) |
532
|
|
|
{ |
533
|
|
|
$form = _MB_SYSTEM_PWWIDTH . ' '; |
534
|
|
|
$form .= "<input type='text' name='options[]' value='".$options[0]."'>"; |
535
|
|
|
$form .= '<br>' . _MB_SYSTEM_PWHEIGHT . ' '; |
536
|
|
|
$form .= "<input type='text' name='options[]' value='".$options[1]."'>"; |
537
|
|
|
$form .= '<br>' . sprintf(_MB_SYSTEM_LOGO, XOOPS_URL . '/images/') . ' '; |
538
|
|
|
$form .= "<input type='text' name='options[]' value='".$options[2]."'>"; |
539
|
|
|
$chk = ''; |
540
|
|
|
$form .= '<br>' . _MB_SYSTEM_SADMIN . ' '; |
541
|
|
|
if ( $options[3] == 1 ) { |
542
|
|
|
$chk = " checked='checked'"; |
543
|
|
|
} |
544
|
|
|
$form .= "<input type='radio' name='options[3]' value='1'".$chk . '> ' . _YES . ''; |
545
|
|
|
$chk = ''; |
546
|
|
|
if ( $options[3] == 0 ) { |
547
|
|
|
$chk = " checked=\"checked\""; |
548
|
|
|
} |
549
|
|
|
$form .= " <input type='radio' name='options[3]' value='0'".$chk . '>' . _NO . ''; |
550
|
|
|
return $form; |
551
|
|
|
} |
552
|
|
|
|
553
|
|
|
function b_system_themes_show($options) |
554
|
|
|
{ |
555
|
|
|
global $xoopsConfig; |
|
|
|
|
556
|
|
|
$theme_options = ''; |
557
|
|
|
foreach ($xoopsConfig['theme_set_allowed'] as $theme) { |
558
|
|
|
$theme_options .= '<option value="'.$theme.'"'; |
559
|
|
|
if ($theme == $xoopsConfig['theme_set']) { |
560
|
|
|
$theme_options .= ' selected="selected"'; |
561
|
|
|
} |
562
|
|
|
$theme_options .= '>'.$theme.'</option>'; |
563
|
|
|
} |
564
|
|
|
$block = array(); |
565
|
|
|
if ($options[0] == 1) { |
566
|
|
|
$block['theme_select'] = "<img vspace=\"2\" id=\"xoops_theme_img\" src=\"".XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . "/shot.gif\" alt=\"screenshot\" width=\"" . intval($options[1]) . "\"><br><select id=\"xoops_theme_select\" name=\"xoops_theme_select\" onchange=\"showImgSelected('xoops_theme_img', 'xoops_theme_select', 'themes', '/shot.gif', '" . XOOPS_URL . "');\">" . $theme_options . "</select><input type=\"submit\" value=\"" . _GO . "\">"; |
567
|
|
|
} else { |
568
|
|
|
$block['theme_select'] = '<select name="xoops_theme_select" onchange="submit();" size="3">'.$theme_options.'</select>'; |
569
|
|
|
} |
570
|
|
|
|
571
|
|
|
$block['theme_select'] .= '<br>('.sprintf(_MB_SYSTEM_NUMTHEME, '<strong>'.count($xoopsConfig['theme_set_allowed']).'</strong>').')<br>'; |
572
|
|
|
return $block; |
573
|
|
|
} |
574
|
|
|
|
575
|
|
|
function b_system_themes_edit($options) |
576
|
|
|
{ |
577
|
|
|
|
578
|
|
|
$chk = ''; |
579
|
|
|
$form = _MB_SYSTEM_THSHOW . ' '; |
580
|
|
|
if (1 == $options[0]) { |
581
|
|
|
$chk = " checked='checked'"; |
582
|
|
|
} |
583
|
|
|
$form .= "<input type='radio' name='options[0]' value='1'{$chk}> " . _YES; |
584
|
|
|
$chk = ''; |
585
|
|
|
if (0 == $options[0]) { |
586
|
|
|
$chk = ' checked="checked"'; |
587
|
|
|
} |
588
|
|
|
$form .= " <input type='radio' name='options[0]' value='0'{$chk}'>" . _NO; |
589
|
|
|
$form .= '<br>'._MB_SYSTEM_THWIDTH.' '; |
590
|
|
|
$form .= "<input type='text' name='options[1]' value='{$options[1]}'>"; |
591
|
|
|
return $form; |
592
|
|
|
} |
593
|
|
|
|
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: