1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10:
11:
12: 13: 14: 15: 16: 17: 18:
19:
20: include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
21:
22: 23: 24:
25: function b_system_online_show()
26: {
27: global $xoopsUser, $xoopsModule;
28:
29: $online_handler = xoops_getHandler('online');
30: mt_srand((double)microtime() * 1000000);
31:
32: if (mt_rand(1, 100) < 11) {
33: $online_handler->gc(300);
34: }
35: if (is_object($xoopsUser)) {
36: $uid = $xoopsUser->getVar('uid');
37: $uname = $xoopsUser->getVar('uname');
38: } else {
39: $uid = 0;
40: $uname = '';
41: }
42: $requestIp = \Xmf\IPAddress::fromRequest()->asReadable();
43: $requestIp = (false === $requestIp) ? '0.0.0.0' : $requestIp;
44: if (is_object($xoopsModule)) {
45: $online_handler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), $requestIp);
46: } else {
47: $online_handler->write($uid, $uname, time(), 0, $requestIp);
48: }
49: $onlines = $online_handler->getAll();
50: if (!empty($onlines)) {
51: $total = count($onlines);
52: $block = array();
53: $guests = 0;
54: $members = '';
55: for ($i = 0; $i < $total; ++$i) {
56: if ($onlines[$i]['online_uid'] > 0) {
57: $members .= ' <a href="' . XOOPS_URL . '/userinfo.php?uid=' . $onlines[$i]['online_uid'] . '" title="' . $onlines[$i]['online_uname'] . '">' . $onlines[$i]['online_uname'] . '</a>,';
58: } else {
59: ++$guests;
60: }
61: }
62: $block['online_total'] = sprintf(_ONLINEPHRASE, $total);
63: if (is_object($xoopsModule)) {
64: $mytotal = $online_handler->getCount(new Criteria('online_module', $xoopsModule->getVar('mid')));
65: $block['online_total'] .= ' (' . sprintf(_ONLINEPHRASEX, $mytotal, $xoopsModule->getVar('name')) . ')';
66: }
67: $block['lang_members'] = _MEMBERS;
68: $block['lang_guests'] = _GUESTS;
69: $block['online_names'] = $members;
70: $block['online_members'] = $total - $guests;
71: $block['online_guests'] = $guests;
72: $block['lang_more'] = _MORE;
73:
74: return $block;
75: } else {
76: return false;
77: }
78: }
79:
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:
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 ($GLOBALS['xoopsConfig']['usercookie']) {
98: $block['lang_rememberme'] = _MB_SYSTEM_REMEMBERME;
99: }
100:
101: return $block;
102: }
103:
104: return false;
105: }
106:
107: 108: 109:
110: function b_system_main_show()
111: {
112: global $xoopsUser, $xoopsModule;
113: $block = array();
114: $block['lang_home'] = _MB_SYSTEM_HOME;
115: $block['lang_close'] = _CLOSE;
116: $module_handler = xoops_getHandler('module');
117: $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
118: $criteria->add(new Criteria('isactive', 1));
119: $criteria->add(new Criteria('weight', 0, '>'));
120: $modules = $module_handler->getObjects($criteria, true);
121:
122: $moduleperm_handler = xoops_getHandler('groupperm');
123: $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
124: $read_allowed = $moduleperm_handler->getItemIds('module_read', $groups);
125: foreach (array_keys($modules) as $i) {
126: if (in_array($i, $read_allowed)) {
127: $block['modules'][$i]['name'] = $modules[$i]->getVar('name');
128: $block['modules'][$i]['directory'] = $modules[$i]->getVar('dirname');
129: $sublinks = $modules[$i]->subLink();
130: if ((!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) {
131: $block['modules'][$i]['highlight'] = true;
132: $block['nothome'] = true;
133: }
134: if ((!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) {
135: $block['modules'][$i]['highlight'] = true;
136: $block['nothome'] = true;
137: }
138: if ((count($sublinks) > 0) && (!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) {
139: foreach ($sublinks as $sublink) {
140: $block['modules'][$i]['sublinks'][] = array(
141: 'name' => $sublink['name'],
142: 'url' => XOOPS_URL . '/modules/' . $modules[$i]->getVar('dirname') . '/' . $sublink['url']);
143: }
144: } else {
145: $block['modules'][$i]['sublinks'] = array();
146: }
147: }
148: }
149:
150: return $block;
151: }
152:
153: 154: 155:
156: function b_system_search_show()
157: {
158: $block = array();
159: $block['lang_search'] = _MB_SYSTEM_SEARCH;
160: $block['lang_advsearch'] = _MB_SYSTEM_ADVS;
161:
162: return $block;
163: }
164:
165: 166: 167:
168: function b_system_user_show()
169: {
170: global $xoopsUser;
171: if (!is_object($xoopsUser)) {
172: return false;
173: }
174: $block = array();
175: $block['lang_youraccount'] = _MB_SYSTEM_VACNT;
176: $block['lang_editaccount'] = _MB_SYSTEM_EACNT;
177: $block['lang_notifications'] = _MB_SYSTEM_NOTIF;
178: $block['uid'] = $xoopsUser->getVar('uid');
179: $block['lang_logout'] = _MB_SYSTEM_LOUT;
180: $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
181: $criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid')));
182:
183: $pm_handler = xoops_getHandler('privmessage');
184:
185: $xoopsPreload = XoopsPreload::getInstance();
186: $xoopsPreload->triggerEvent('system.blocks.system_blocks.usershow', array(&$pm_handler));
187:
188: $block['user_avatar'] = $xoopsUser->getVar('user_avatar');
189: $block['uname'] = $xoopsUser->getVar('uname');
190: $block['new_messages'] = $pm_handler->getCount($criteria);
191: $block['lang_inbox'] = _MB_SYSTEM_INBOX;
192: $block['lang_adminmenu'] = _MB_SYSTEM_ADMENU;
193:
194: return $block;
195: }
196:
197:
198: 199: 200:
201: function b_system_waiting_show()
202: {
203: global $xoopsUser;
204: $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
205:
206: $module_handler = xoops_getHandler('module');
207: $block = array();
208:
209:
210: if (xoops_isActiveModule('news') && $module_handler->getCount(new Criteria('dirname', 'news'))) {
211: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('stories') . ' WHERE published=0');
212: if ($result) {
213: $block['modules'][0]['adminlink'] = XOOPS_URL . '/modules/news/admin/index.php?op=newarticle';
214: list($block['modules'][0]['pendingnum']) = $xoopsDB->fetchRow($result);
215: $block['modules'][0]['lang_linkname'] = _MB_SYSTEM_SUBMS;
216: }
217: }
218:
219:
220: if (xoops_isActiveModule('mylinks') && $module_handler->getCount(new Criteria('dirname', 'mylinks'))) {
221: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_links') . ' WHERE status=0');
222: if ($result) {
223: $block['modules'][1]['adminlink'] = XOOPS_URL . '/modules/mylinks/admin/index.php?op=listNewLinks';
224: list($block['modules'][1]['pendingnum']) = $xoopsDB->fetchRow($result);
225: $block['modules'][1]['lang_linkname'] = _MB_SYSTEM_WLNKS;
226: }
227: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_broken'));
228: if ($result) {
229: $block['modules'][2]['adminlink'] = XOOPS_URL . '/modules/mylinks/admin/index.php?op=listBrokenLinks';
230: list($block['modules'][2]['pendingnum']) = $xoopsDB->fetchRow($result);
231: $block['modules'][2]['lang_linkname'] = _MB_SYSTEM_BLNK;
232: }
233: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_mod'));
234: if ($result) {
235: $block['modules'][3]['adminlink'] = XOOPS_URL . '/modules/mylinks/admin/index.php?op=listModReq';
236: list($block['modules'][3]['pendingnum']) = $xoopsDB->fetchRow($result);
237: $block['modules'][3]['lang_linkname'] = _MB_SYSTEM_MLNKS;
238: }
239: }
240:
241:
242: if (xoops_isActiveModule('mydownloads') && $module_handler->getCount(new Criteria('dirname', 'mydownloads'))) {
243: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_downloads') . ' WHERE status=0');
244: if ($result) {
245: $block['modules'][4]['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listNewDownloads';
246: list($block['modules'][4]['pendingnum']) = $xoopsDB->fetchRow($result);
247: $block['modules'][4]['lang_linkname'] = _MB_SYSTEM_WDLS;
248: }
249: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_broken') . '');
250: if ($result) {
251: $block['modules'][5]['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listBrokenDownloads';
252: list($block['modules'][5]['pendingnum']) = $xoopsDB->fetchRow($result);
253: $block['modules'][5]['lang_linkname'] = _MB_SYSTEM_BFLS;
254: }
255: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_mod') . '');
256: if ($result) {
257: $block['modules'][6]['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listModReq';
258: list($block['modules'][6]['pendingnum']) = $xoopsDB->fetchRow($result);
259: $block['modules'][6]['lang_linkname'] = _MB_SYSTEM_MFLS;
260: }
261: }
262:
263:
264: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xoopscomments') . ' WHERE com_status=1');
265: if ($result) {
266: $block['modules'][7]['adminlink'] = XOOPS_URL . '/modules/system/admin.php?module=0&status=1&fct=comments';
267: list($block['modules'][7]['pendingnum']) = $xoopsDB->fetchRow($result);
268: $block['modules'][7]['lang_linkname'] = _MB_SYSTEM_COMPEND;
269: }
270:
271:
272: if (xoops_isActiveModule('TDMdownloads') && $module_handler->getCount(new Criteria('dirname', 'TDMDownloads'))) {
273: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status=0');
274: if ($result) {
275: $block['modules'][8]['adminlink'] = XOOPS_URL . '/modules/TDMDownloads/admin/downloads.php?op=list&statut_display=0';
276: list($block['modules'][8]['pendingnum']) = $xoopsDB->fetchRow($result);
277: $block['modules'][8]['lang_linkname'] = _MB_SYSTEM_TDMDOWNLOADS;
278: }
279: }
280:
281:
282: if (xoops_isActiveModule('extgallery') && $module_handler->getCount(new Criteria('dirname', 'extgallery'))) {
283: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('extgallery_publicphoto') . ' WHERE photo_approved=0');
284: if ($result) {
285: $block['modules'][9]['adminlink'] = XOOPS_URL . '/modules/extgallery/admin/photo.php#pending-photo';
286: list($block['modules'][9]['pendingnum']) = $xoopsDB->fetchRow($result);
287: $block['modules'][9]['lang_linkname'] = _MB_SYSTEM_EXTGALLERY;
288: }
289: }
290:
291:
292: if (xoops_isActiveModule('smartsection') && $module_handler->getCount(new Criteria('dirname', 'smartsection'))) {
293: $result = $xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('smartsection_items') . ' WHERE status=1');
294: if ($result) {
295: $block['modules'][10]['adminlink'] = XOOPS_URL . '/modules/smartsection/admin/item.php';
296: list($block['modules'][10]['pendingnum']) = $xoopsDB->fetchRow($result);
297: $block['modules'][10]['lang_linkname'] = _MB_SYSTEM_SMARTSECTION;
298: }
299: }
300:
301: return $block;
302: }
303:
304: 305: 306: 307: 308:
309: function b_system_info_show($options)
310: {
311: global $xoopsConfig, $xoopsUser;
312: $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection();
313: $myts = MyTextSanitizer::getInstance();
314: $block = array();
315: if (!empty($options[3])) {
316: $block['showgroups'] = true;
317: $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");
318: if ($xoopsDB->getRowsNum($result) > 0) {
319: $prev_caption = '';
320: $i = 0;
321: while ($userinfo = $xoopsDB->fetchArray($result)) {
322: if ($prev_caption != $userinfo['groupname']) {
323: $prev_caption = $userinfo['groupname'];
324: $block['groups'][$i]['name'] = $myts->htmlSpecialChars($userinfo['groupname']);
325: }
326: if (isset($xoopsUser) && is_object($xoopsUser)) {
327: $block['groups'][$i]['users'][] = array(
328: 'id' => $userinfo['uid'],
329: 'name' => $myts->htmlspecialchars($userinfo['uname']),
330: 'msglink' => "<a href=\"javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userinfo['uid'] . "','pmlite',565,500);\"><img src=\"" . XOOPS_URL . "/images/icons/pm_small.gif\" border=\"0\" width=\"27\" height=\"17\" alt=\"\" /></a>",
331: 'avatar' => XOOPS_UPLOAD_URL . '/' . $userinfo['user_avatar']);
332: } else {
333: if ($userinfo['user_viewemail']) {
334: $block['groups'][$i]['users'][] = array(
335: 'id' => $userinfo['uid'],
336: 'name' => $myts->htmlspecialchars($userinfo['uname']),
337: 'msglink' => '<a href="mailto:' . $userinfo['email'] . '"><img src="' . XOOPS_URL . '/images/icons/em_small.gif" border="0" width="16" height="14" alt="" /></a>',
338: 'avatar' => XOOPS_UPLOAD_URL . '/' . $userinfo['user_avatar']);
339: } else {
340: $block['groups'][$i]['users'][] = array(
341: 'id' => $userinfo['uid'],
342: 'name' => $myts->htmlspecialchars($userinfo['uname']),
343: 'msglink' => ' ',
344: 'avatar' => XOOPS_UPLOAD_URL . '/' . $userinfo['user_avatar']);
345: }
346: }
347: ++$i;
348: }
349: }
350: } else {
351: $block['showgroups'] = false;
352: }
353: $block['logourl'] = XOOPS_URL . '/images/' . $options[2];
354: $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>';
355:
356: return $block;
357: }
358:
359: 360: 361: 362: 363:
364: function b_system_newmembers_show($options)
365: {
366: $block = array();
367: $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
368: $limit = (!empty($options[0])) ? $options[0] : 10;
369: $criteria->setOrder('DESC');
370: $criteria->setSort('user_regdate');
371: $criteria->setLimit($limit);
372:
373: $member_handler = xoops_getHandler('member');
374: $newmembers = $member_handler->getUsers($criteria);
375: $count = count($newmembers);
376: for ($i = 0; $i < $count; ++$i) {
377: if ($options[1] == 1) {
378: $block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') !== 'blank.gif' ? XOOPS_UPLOAD_URL . '/' . $newmembers[$i]->getVar('user_avatar') : '';
379: } else {
380: $block['users'][$i]['avatar'] = '';
381: }
382: $block['users'][$i]['id'] = $newmembers[$i]->getVar('uid');
383: $block['users'][$i]['name'] = $newmembers[$i]->getVar('uname');
384: $block['users'][$i]['joindate'] = formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's');
385: }
386:
387: return $block;
388: }
389:
390: 391: 392: 393: 394:
395: function b_system_topposters_show($options)
396: {
397: $block = array();
398: $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
399: $criteria->add(new Criteria('posts', 0, '>'));
400: $limit = (!empty($options[0])) ? $options[0] : 10;
401: $size = count($options);
402: for ($i = 2; $i < $size; ++$i) {
403: $criteria->add(new Criteria('rank', $options[$i], '<>'));
404: }
405: $criteria->setOrder('DESC');
406: $criteria->setSort('posts');
407: $criteria->setLimit($limit);
408:
409: $member_handler = xoops_getHandler('member');
410: $topposters = $member_handler->getUsers($criteria);
411: $count = count($topposters);
412: for ($i = 0; $i < $count; ++$i) {
413: $block['users'][$i]['rank'] = $i + 1;
414: if ($options[1] == 1) {
415: $block['users'][$i]['avatar'] = $topposters[$i]->getVar('user_avatar') !== 'blank.gif' ? XOOPS_UPLOAD_URL . '/' . $topposters[$i]->getVar('user_avatar') : '';
416: } else {
417: $block['users'][$i]['avatar'] = '';
418: }
419: $block['users'][$i]['id'] = $topposters[$i]->getVar('uid');
420: $block['users'][$i]['name'] = $topposters[$i]->getVar('uname');
421: $block['users'][$i]['posts'] = $topposters[$i]->getVar('posts');
422: }
423:
424: return $block;
425: }
426:
427: 428: 429: 430: 431:
432: function b_system_comments_show($options)
433: {
434: $block = array();
435: include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
436: $comment_handler = xoops_getHandler('comment');
437: $criteria = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
438: $criteria->setLimit((int)$options[0]);
439: $criteria->setSort('com_created');
440: $criteria->setOrder('DESC');
441:
442:
443: global $xoopsUser;
444: $moduleperm_handler = xoops_getHandler('groupperm');
445: $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
446: $criteria1 = new CriteriaCompo(new Criteria('gperm_name', 'module_read', '='));
447: $criteria1->add(new Criteria('gperm_groupid', '(' . implode(',', $gperm_groupid) . ')', 'IN'));
448: $perms = $moduleperm_handler->getObjects($criteria1, true);
449: $modIds = array();
450: foreach ($perms as $item) {
451: $modIds[] = $item->getVar('gperm_itemid');
452: }
453: if (count($modIds) > 0) {
454: $modIds = array_unique($modIds);
455: $criteria->add(new Criteria('com_modid', '(' . implode(',', $modIds) . ')', 'IN'));
456: }
457:
458:
459: $comments = $comment_handler->getObjects($criteria, true);
460:
461: $member_handler = xoops_getHandler('member');
462:
463: $module_handler = xoops_getHandler('module');
464: $modules = $module_handler->getObjects(new Criteria('hascomments', 1), true);
465: $comment_config = array();
466: foreach (array_keys($comments) as $i) {
467: $mid = $comments[$i]->getVar('com_modid');
468: $com['module'] = '<a href="' . XOOPS_URL . '/modules/' . $modules[$mid]->getVar('dirname') . '/">' . $modules[$mid]->getVar('name') . '</a>';
469: if (!isset($comment_config[$mid])) {
470: $comment_config[$mid] = $modules[$mid]->getInfo('comments');
471: }
472: $com['id'] = $i;
473: $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>';
474: $com['icon'] = htmlspecialchars($comments[$i]->getVar('com_icon'), ENT_QUOTES);
475: $com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif';
476: $com['time'] = formatTimestamp($comments[$i]->getVar('com_created'), 'm');
477: if ($comments[$i]->getVar('com_uid') > 0) {
478: $poster = $member_handler->getUser($comments[$i]->getVar('com_uid'));
479: if (is_object($poster)) {
480: $com['poster'] = '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $comments[$i]->getVar('com_uid') . '">' . $poster->getVar('uname') . '</a>';
481: } else {
482: $com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
483: }
484: } else {
485: $com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
486: }
487: $block['comments'][] =& $com;
488: unset($com);
489: }
490:
491: return $block;
492: }
493:
494:
495: 496: 497:
498: function b_system_notification_show()
499: {
500: global $xoopsConfig, $xoopsUser, $xoopsModule;
501: include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
502: include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php';
503:
504: if (empty($xoopsUser) || !notificationEnabled('block')) {
505: return false;
506: }
507: $notification_handler = xoops_getHandler('notification');
508:
509:
510: $block = array();
511: $categories =& notificationSubscribableCategoryInfo();
512: if (empty($categories)) {
513: return false;
514: }
515: foreach ($categories as $category) {
516: $section['name'] = $category['name'];
517: $section['title'] = $category['title'];
518: $section['description'] = $category['description'];
519: $section['itemid'] = $category['item_id'];
520: $section['events'] = array();
521: $subscribed_events = $notification_handler->getSubscribedEvents($category['name'], $category['item_id'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid'));
522: foreach (notificationEvents($category['name'], true) as $event) {
523: if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
524: continue;
525: }
526: $subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0;
527: $section['events'][$event['name']] = array(
528: 'name' => $event['name'],
529: 'title' => $event['title'],
530: 'caption' => $event['caption'],
531: 'description' => $event['description'],
532: 'subscribed' => $subscribed);
533: }
534: $block['categories'][$category['name']] = $section;
535: }
536:
537: $block['target_page'] = 'notification_update.php';
538:
539: $script_url = explode('/', $_SERVER['PHP_SELF']);
540: $script_name = $script_url[count($script_url) - 1];
541: $block['redirect_script'] = $script_name;
542: $block['submit_button'] = _NOT_UPDATENOW;
543: $block['notification_token'] = $GLOBALS['xoopsSecurity']->createToken();
544:
545: return $block;
546: }
547:
548: 549: 550: 551: 552:
553: function b_system_comments_edit($options)
554: {
555: $inputtag = "<input type='text' name='options[]' value='" . (int)$options[0] . "' />";
556: $form = sprintf(_MB_SYSTEM_DISPLAYC, $inputtag);
557:
558: return $form;
559: }
560:
561: 562: 563: 564: 565:
566: function b_system_topposters_edit($options)
567: {
568: include_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
569: $inputtag = "<input type='text' name='options[]' value='" . (int)$options[0] . "' />";
570: $form = sprintf(_MB_SYSTEM_DISPLAY, $inputtag);
571: $form .= '<br>' . _MB_SYSTEM_DISPLAYA . " <input type='radio' id='options[]' name='options[]' value='1'";
572: if ($options[1] == 1) {
573: $form .= " checked";
574: }
575: $form .= ' /> ' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'";
576: if ($options[1] == 0) {
577: $form .= " checked";
578: }
579: $form .= ' /> ' . _NO . '';
580: $form .= '<br>' . _MB_SYSTEM_NODISPGR . "<br><select id='options[]' name='options[]' multiple='multiple'>";
581: $ranks = XoopsLists::getUserRankList();
582: $size = count($options);
583: foreach ($ranks as $k => $v) {
584: $sel = '';
585: for ($i = 2; $i < $size; ++$i) {
586: if ($k == $options[$i]) {
587: $sel = " selected";
588: }
589: }
590: $form .= "<option value='$k'$sel>$v</option>";
591: }
592: $form .= '</select>';
593:
594: return $form;
595: }
596:
597: 598: 599: 600: 601:
602: function b_system_newmembers_edit($options)
603: {
604: $inputtag = "<input type='text' name='options[]' value='" . $options[0] . "' />";
605: $form = sprintf(_MB_SYSTEM_DISPLAY, $inputtag);
606: $form .= '<br>' . _MB_SYSTEM_DISPLAYA . " <input type='radio' id='options[]' name='options[]' value='1'";
607: if ($options[1] == 1) {
608: $form .= " checked";
609: }
610: $form .= ' /> ' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'";
611: if ($options[1] == 0) {
612: $form .= " checked";
613: }
614: $form .= ' /> ' . _NO . '';
615:
616: return $form;
617: }
618:
619: 620: 621: 622: 623:
624: function b_system_info_edit($options)
625: {
626: $form = _MB_SYSTEM_PWWIDTH . ' ';
627: $form .= "<input type='text' name='options[]' value='" . $options[0] . "' />";
628: $form .= '<br>' . _MB_SYSTEM_PWHEIGHT . ' ';
629: $form .= "<input type='text' name='options[]' value='" . $options[1] . "' />";
630: $form .= '<br>' . sprintf(_MB_SYSTEM_LOGO, XOOPS_URL . '/images/') . ' ';
631: $form .= "<input type='text' name='options[]' value='" . $options[2] . "' />";
632: $chk = '';
633: $form .= '<br>' . _MB_SYSTEM_SADMIN . ' ';
634: if ($options[3] == 1) {
635: $chk = " checked";
636: }
637: $form .= "<input type='radio' name='options[3]' value='1'" . $chk . ' /> ' . _YES . '';
638: $chk = '';
639: if ($options[3] == 0) {
640: $chk = " checked";
641: }
642: $form .= " <input type='radio' name='options[3]' value='0'" . $chk . ' />' . _NO . '';
643:
644: return $form;
645: }
646:
647: 648: 649: 650: 651:
652: function b_system_themes_show($options)
653: {
654: global $xoopsConfig;
655: $block = array();
656:
657: if (!isset($options[2])) {
658: $options[2] = 3;
659: }
660: $selectSize = ($options[0] == 1) ? 1 : (int) $options[2];
661: $select = new XoopsFormSelect('', 'xoops_theme_select', $xoopsConfig['theme_set'], $selectSize);
662: foreach ($xoopsConfig['theme_set_allowed'] as $theme) {
663: $select->addOption($theme, $theme);
664: }
665:
666: if ($options[0] == 1) {
667: $themeSelect = '<img vspace="2" id="xoops_theme_img" src="'
668: . XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/shot.gif" '
669: . ' alt="screenshot" width="' . (int)$options[1] . '" />'
670: . '<br>';
671: $select->setExtra(' onchange="showImgSelected(\'xoops_theme_img\', \'xoops_theme_select\', \'themes\', \'/shot.gif\', '
672: . '\'' . XOOPS_URL . '\');" ');
673: $selectTray = new XoopsFormElementTray('');
674: $selectTray->addElement($select);
675: $selectTray->addElement(new XoopsFormButton('', 'submit', _GO, 'submit'));
676: $themeSelect .= '<div class="form-inline">';
677: $themeSelect .= $selectTray->render();
678: $themeSelect .= '</div>';
679: } else {
680: $select->setExtra(' onchange="submit();" ');
681: $themeSelect = $select->render();
682: }
683:
684: $block['theme_select'] = $themeSelect . '<br>(' . sprintf(_MB_SYSTEM_NUMTHEME, '<strong>'
685: . count($xoopsConfig['theme_set_allowed']) . '</strong>') . ')<br>';
686:
687: return $block;
688: }
689:
690: 691: 692: 693: 694:
695: function b_system_themes_edit($options)
696: {
697: $chk = '';
698: $form = _MB_SYSTEM_THSHOW . ' ';
699: if (!isset($options[2])) {
700: $options[2] = 3;
701: }
702: if ($options[0] == 1) {
703: $chk = " checked";
704: }
705: $form .= "<input type='radio' name='options[0]' value='1'" . $chk . ' /> ' . _YES;
706: $chk = '';
707: if ($options[0] == 0) {
708: $chk = ' checked';
709: }
710: $form .= ' <input type="radio" name="options[0]" value="0"' . $chk . ' />' . _NO;
711: $form .= '<br>' . _MB_SYSTEM_THWIDTH . ' ';
712: $form .= "<input type='text' name='options[1]' value='" . $options[1] . "' />";
713: $form .= '<br>' . _MB_SYSTEM_BLOCK_HEIGHT . ' ';
714: $form .= "<input type='text' name='options[2]' value='" . $options[2] . "' />";
715:
716: return $form;
717: }
718: