XOOPS 2.5.6  Final
 All Classes Namespaces Files Functions Variables Pages
system_blocks.php
Go to the documentation of this file.
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 
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 
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 
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 
144 {
145  $block = array();
146  $block['lang_search'] = _MB_SYSTEM_SEARCH;
147  $block['lang_advsearch'] = _MB_SYSTEM_ADVS;
148  return $block;
149 }
150 
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 
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
179 {
180  global $xoopsUser;
182  $module_handler =& xoops_gethandler('module');
183  $block = array();
184 
185  // waiting content for news
186  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  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mylinks_links")." WHERE status=0");
198  if ( $result ) {
199  $block['modules'][1]['adminlink'] = XOOPS_URL."/modules/mylinks/admin/index.php?op=listNewLinks";
200  list($block['modules'][1]['pendingnum']) = $xoopsDB->fetchRow($result);
201  $block['modules'][1]['lang_linkname'] = _MB_SYSTEM_WLNKS;
202  }
203  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mylinks_broken"));
204  if ( $result ) {
205  $block['modules'][2]['adminlink'] = XOOPS_URL."/modules/mylinks/admin/index.php?op=listBrokenLinks";
206  list($block['modules'][2]['pendingnum']) = $xoopsDB->fetchRow($result);
207  $block['modules'][2]['lang_linkname'] = _MB_SYSTEM_BLNK;
208  }
209  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mylinks_mod"));
210  if ( $result ) {
211  $block['modules'][3]['adminlink'] = XOOPS_URL."/modules/mylinks/admin/index.php?op=listModReq";
212  list($block['modules'][3]['pendingnum']) = $xoopsDB->fetchRow($result);
213  $block['modules'][3]['lang_linkname'] = _MB_SYSTEM_MLNKS;
214  }
215  }
216 
217  // waiting content for mydownloads
218  if (xoops_isActiveModule('mydownloads') && $module_handler->getCount(new Criteria('dirname', 'mydownloads'))) {
219  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_downloads")." WHERE status=0");
220  if ( $result ) {
221  $block['modules'][4]['adminlink'] = XOOPS_URL."/modules/mydownloads/admin/index.php?op=listNewDownloads";
222  list($block['modules'][4]['pendingnum']) = $xoopsDB->fetchRow($result);
223  $block['modules'][4]['lang_linkname'] = _MB_SYSTEM_WDLS;
224  }
225  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_broken")."");
226  if ( $result ) {
227  $block['modules'][5]['adminlink'] = XOOPS_URL."/modules/mydownloads/admin/index.php?op=listBrokenDownloads";
228  list($block['modules'][5]['pendingnum']) = $xoopsDB->fetchRow($result);
229  $block['modules'][5]['lang_linkname'] = _MB_SYSTEM_BFLS;
230  }
231  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_mod")."");
232  if ( $result ) {
233  $block['modules'][6]['adminlink'] = XOOPS_URL."/modules/mydownloads/admin/index.php?op=listModReq";
234  list($block['modules'][6]['pendingnum']) = $xoopsDB->fetchRow($result);
235  $block['modules'][6]['lang_linkname'] = _MB_SYSTEM_MFLS;
236  }
237  }
238 
239  // waiting content for xoops comments
240  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("xoopscomments")." WHERE com_status=1");
241  if ( $result ) {
242  $block['modules'][7]['adminlink'] = XOOPS_URL."/modules/system/admin.php?module=0&amp;status=1&amp;fct=comments";
243  list($block['modules'][7]['pendingnum']) = $xoopsDB->fetchRow($result);
244  $block['modules'][7]['lang_linkname'] =_MB_SYSTEM_COMPEND;
245  }
246 
247  // waiting content for TDMDownloads
248  if (xoops_isActiveModule('TDMdownloads') && $module_handler->getCount(new Criteria('dirname', 'TDMDownloads'))) {
249  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("tdmdownloads_downloads")." WHERE status=0");
250  if ( $result ) {
251  $block['modules'][8]['adminlink'] = XOOPS_URL."/modules/TDMDownloads/admin/downloads.php?op=list&statut_display=0";
252  list($block['modules'][8]['pendingnum']) = $xoopsDB->fetchRow($result);
253  $block['modules'][8]['lang_linkname'] = _MB_SYSTEM_TDMDOWNLOADS;
254  }
255  }
256 
257  // waiting content for extgallery
258  if (xoops_isActiveModule('extgallery') && $module_handler->getCount(new Criteria('dirname', 'extgallery'))) {
259  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("extgallery_publicphoto")." WHERE photo_approved=0");
260  if ( $result ) {
261  $block['modules'][9]['adminlink'] = XOOPS_URL."/modules/extgallery/admin/photo.php#pending-photo";
262  list($block['modules'][9]['pendingnum']) = $xoopsDB->fetchRow($result);
263  $block['modules'][9]['lang_linkname'] = _MB_SYSTEM_EXTGALLERY;
264  }
265  }
266 
267  // waiting content for smartsection
268  if (xoops_isActiveModule('smartsection') && $module_handler->getCount(new Criteria('dirname', 'smartsection'))) {
269  $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("smartsection_items")." WHERE status=1");
270  if ( $result ) {
271  $block['modules'][10]['adminlink'] = XOOPS_URL."/modules/smartsection/admin/item.php";
272  list($block['modules'][10]['pendingnum']) = $xoopsDB->fetchRow($result);
273  $block['modules'][10]['lang_linkname'] = _MB_SYSTEM_SMARTSECTION;
274  }
275  }
276 
277  return $block;
278 }
279 
281 {
282  global $xoopsConfig, $xoopsUser;
285  $block = array();
286  if (!empty($options[3])) {
287  $block['showgroups'] = true;
288  $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");
289  if ($xoopsDB->getRowsNum($result) > 0) {
290  $prev_caption = "";
291  $i = 0;
292  while ($userinfo = $xoopsDB->fetchArray($result)) {
293  if ($prev_caption != $userinfo['groupname']) {
294  $prev_caption = $userinfo['groupname'];
295  $block['groups'][$i]['name'] = $myts->htmlSpecialChars($userinfo['groupname']);
296  }
297  if (isset($xoopsUser) && is_object($xoopsUser)) {
298  $block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlspecialchars($userinfo['uname']), 'msglink' => "<a href=\"javascript:openWithSelfMain('".XOOPS_URL."/pmlite.php?send2=1&amp;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']);
299  } else {
300  if ($userinfo['user_viewemail']) {
301  $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']);
302  } else {
303  $block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlspecialchars($userinfo['uname']), 'msglink' => '&nbsp;', 'avatar' => XOOPS_UPLOAD_URL.'/'.$userinfo['user_avatar']);
304  }
305  }
306  $i++;
307  }
308  }
309  } else {
310  $block['showgroups'] = false;
311  }
312  $block['logourl'] = XOOPS_URL.'/images/'.$options[2];
313  $block['recommendlink'] = "<a href=\"javascript:openWithSelfMain('".XOOPS_URL."/misc.php?action=showpopups&amp;type=friend&amp;op=sendform&amp;t=".time()."','friend',".$options[0].",".$options[1].")\">"._MB_SYSTEM_RECO."</a>";
314  return $block;
315 }
316 
318 {
319  $block = array();
320  $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
321  $limit = (!empty($options[0])) ? $options[0] : 10;
322  $criteria->setOrder('DESC');
323  $criteria->setSort('user_regdate');
324  $criteria->setLimit($limit);
325  $member_handler =& xoops_gethandler('member');
326  $newmembers = $member_handler->getUsers($criteria);
327  $count = count($newmembers);
328  for ($i = 0; $i < $count; $i++) {
329  if ( $options[1] == 1 ) {
330  $block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL.'/'.$newmembers[$i]->getVar('user_avatar') : '';
331  } else {
332  $block['users'][$i]['avatar'] = '';
333  }
334  $block['users'][$i]['id'] = $newmembers[$i]->getVar('uid');
335  $block['users'][$i]['name'] = $newmembers[$i]->getVar('uname');
336  $block['users'][$i]['joindate'] = formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's');
337  }
338  return $block;
339 }
340 
342 {
343  $block = array();
344  $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
345  $limit = (!empty($options[0])) ? $options[0] : 10;
346  $size = count($options);
347  for ( $i = 2; $i < $size; $i++) {
348  $criteria->add(new Criteria('rank', $options[$i], '<>'));
349  }
350  $criteria->setOrder('DESC');
351  $criteria->setSort('posts');
352  $criteria->setLimit($limit);
353  $member_handler =& xoops_gethandler('member');
354  $topposters = $member_handler->getUsers($criteria);
355  $count = count($topposters);
356  for ($i = 0; $i < $count; $i++) {
357  $block['users'][$i]['rank'] = $i+1;
358  if ( $options[1] == 1 ) {
359  $block['users'][$i]['avatar'] = $topposters[$i]->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL.'/'.$topposters[$i]->getVar('user_avatar') : '';
360  } else {
361  $block['users'][$i]['avatar'] = '';
362  }
363  $block['users'][$i]['id'] = $topposters[$i]->getVar('uid');
364  $block['users'][$i]['name'] = $topposters[$i]->getVar('uname');
365  $block['users'][$i]['posts'] = $topposters[$i]->getVar('posts');
366  }
367  return $block;
368 }
369 
370 
372 {
373  $block = array();
374  include_once XOOPS_ROOT_PATH.'/include/comment_constants.php';
375  $comment_handler =& xoops_gethandler('comment');
376  $criteria = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
377  $criteria->setLimit(intval($options[0]));
378  $criteria->setSort('com_created');
379  $criteria->setOrder('DESC');
380 
381  // Check modules permissions
382  global $xoopsUser;
383  $moduleperm_handler =& xoops_gethandler('groupperm');
384  $gperm_groupid = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
385  $criteria1 = new CriteriaCompo(new Criteria('gperm_name','module_read','='));
386  $criteria1->add(new Criteria('gperm_groupid', '('.implode(',', $gperm_groupid).')', 'IN'));
387  $perms = $moduleperm_handler->getObjects($criteria1, true);
388  $modIds = array();
389  foreach($perms as $item) {
390  $modIds[] = $item->getVar('gperm_itemid');
391  }
392  if(count($modIds) > 0 ) {
393  $modIds = array_unique($modIds);
394  $criteria->add(new Criteria('com_modid', '('.implode(',', $modIds).')', 'IN'));
395  }
396  // Check modules permissions
397 
398  $comments = $comment_handler->getObjects($criteria, true);
399  $member_handler =& xoops_gethandler('member');
400  $module_handler =& xoops_gethandler('module');
401  $modules = $module_handler->getObjects(new Criteria('hascomments', 1), true);
402  $comment_config = array();
403  foreach (array_keys($comments) as $i) {
404  $mid = $comments[$i]->getVar('com_modid');
405  $com['module'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'</a>';
406  if (!isset($comment_config[$mid])) {
407  $comment_config[$mid] = $modules[$mid]->getInfo('comments');
408  }
409  $com['id'] = $i;
410  $com['title'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/'.$comment_config[$mid]['pageName'].'?'.$comment_config[$mid]['itemName'].'='.$comments[$i]->getVar('com_itemid').'&amp;com_id='.$i.'&amp;com_rootid='.$comments[$i]->getVar('com_rootid').'&amp;'.htmlspecialchars($comments[$i]->getVar('com_exparams')).'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'</a>';
411  $com['icon'] = htmlspecialchars( $comments[$i]->getVar('com_icon'), ENT_QUOTES );
412  $com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif';
413  $com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m');
414  if ($comments[$i]->getVar('com_uid') > 0) {
415  $poster = $member_handler->getUser($comments[$i]->getVar('com_uid'));
416  if (is_object($poster)) {
417  $com['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>';
418  } else {
419  $com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
420  }
421  } else {
422  $com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
423  }
424  $block['comments'][] =& $com;
425  unset($com);
426  }
427  return $block;
428 }
429 
430 // RMV-NOTIFY
432 {
434  include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
435  include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php';
436  // Notification must be enabled, and user must be logged in
437  if (empty($xoopsUser) || !notificationEnabled('block')) {
438  return false; // do not display block
439  }
440  $notification_handler =& xoops_gethandler('notification');
441  // Now build the a nested associative array of info to pass
442  // to the block template.
443  $block = array();
444  $categories =& notificationSubscribableCategoryInfo();
445  if (empty($categories)) {
446  return false;
447  }
448  foreach ($categories as $category) {
449  $section['name'] = $category['name'];
450  $section['title'] = $category['title'];
451  $section['description'] = $category['description'];
452  $section['itemid'] = $category['item_id'];
453  $section['events'] = array();
454  $subscribed_events = $notification_handler->getSubscribedEvents ($category['name'], $category['item_id'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid'));
455  foreach (notificationEvents($category['name'], true) as $event) {
456  if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
457  continue;
458  }
459  $subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0;
460  $section['events'][$event['name']] = array ('name'=>$event['name'], 'title'=>$event['title'], 'caption'=>$event['caption'], 'description'=>$event['description'], 'subscribed'=>$subscribed);
461  }
462  $block['categories'][$category['name']] = $section;
463  }
464  // Additional form data
465  $block['target_page'] = "notification_update.php";
466  // FIXME: better or more standardized way to do this?
467  $script_url = explode('/', $_SERVER['PHP_SELF']);
468  $script_name = $script_url[count($script_url)-1];
469  $block['redirect_script'] = $script_name;
470  $block['submit_button'] = _NOT_UPDATENOW;
471  $block['notification_token'] = $GLOBALS['xoopsSecurity']->createToken();
472  return $block;
473 }
474 
476 {
477  $inputtag = "<input type='text' name='options[]' value='".intval($options[0])."' />";
478  $form = sprintf(_MB_SYSTEM_DISPLAYC, $inputtag);
479  return $form;
480 }
481 
483 {
484  include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
485  $inputtag = "<input type='text' name='options[]' value='".intval($options[0])."' />";
486  $form = sprintf(_MB_SYSTEM_DISPLAY,$inputtag);
487  $form .= "<br />"._MB_SYSTEM_DISPLAYA."&nbsp;<input type='radio' id='options[]' name='options[]' value='1'";
488  if ( $options[1] == 1 ) {
489  $form .= " checked='checked'";
490  }
491  $form .= " />&nbsp;"._YES."<input type='radio' id='options[]' name='options[]' value='0'";
492  if ( $options[1] == 0 ) {
493  $form .= " checked='checked'";
494  }
495  $form .= " />&nbsp;"._NO."";
496  $form .= "<br />"._MB_SYSTEM_NODISPGR."<br /><select id='options[]' name='options[]' multiple='multiple'>";
497  $ranks = XoopsLists::getUserRankList();
498  $size = count($options);
499  foreach ($ranks as $k => $v) {
500  $sel = "";
501  for ( $i = 2; $i < $size; $i++ ) {
502  if ($k == $options[$i]) {
503  $sel = " selected='selected'";
504  }
505  }
506  $form .= "<option value='$k'$sel>$v</option>";
507  }
508  $form .= "</select>";
509  return $form;
510 }
511 
513 {
514  $inputtag = "<input type='text' name='options[]' value='".$options[0]."' />";
515  $form = sprintf(_MB_SYSTEM_DISPLAY,$inputtag);
516  $form .= "<br />"._MB_SYSTEM_DISPLAYA."&nbsp;<input type='radio' id='options[]' name='options[]' value='1'";
517  if ( $options[1] == 1 ) {
518  $form .= " checked='checked'";
519  }
520  $form .= " />&nbsp;"._YES."<input type='radio' id='options[]' name='options[]' value='0'";
521  if ( $options[1] == 0 ) {
522  $form .= " checked='checked'";
523  }
524  $form .= " />&nbsp;"._NO."";
525  return $form;
526 }
527 
529 {
530  $form = _MB_SYSTEM_PWWIDTH."&nbsp;";
531  $form .= "<input type='text' name='options[]' value='".$options[0]."' />";
532  $form .= "<br />"._MB_SYSTEM_PWHEIGHT."&nbsp;";
533  $form .= "<input type='text' name='options[]' value='".$options[1]."' />";
534  $form .= "<br />".sprintf(_MB_SYSTEM_LOGO,XOOPS_URL."/images/")."&nbsp;";
535  $form .= "<input type='text' name='options[]' value='".$options[2]."' />";
536  $chk = "";
537  $form .= "<br />"._MB_SYSTEM_SADMIN."&nbsp;";
538  if ( $options[3] == 1 ) {
539  $chk = " checked='checked'";
540  }
541  $form .= "<input type='radio' name='options[3]' value='1'".$chk." />&nbsp;"._YES."";
542  $chk = "";
543  if ( $options[3] == 0 ) {
544  $chk = " checked=\"checked\"";
545  }
546  $form .= "&nbsp;<input type='radio' name='options[3]' value='0'".$chk." />"._NO."";
547  return $form;
548 }
549 
551 {
552  global $xoopsConfig;
553  $theme_options = '';
554  foreach ($xoopsConfig['theme_set_allowed'] as $theme) {
555  $theme_options .= '<option value="'.$theme.'"';
556  if ($theme == $xoopsConfig['theme_set']) {
557  $theme_options .= ' selected="selected"';
558  }
559  $theme_options .= '>'.$theme.'</option>';
560  }
561  $block = array();
562  if ($options[0] == 1) {
563  $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."\" />";
564  } else {
565  $block['theme_select'] = '<select name="xoops_theme_select" onchange="submit();" size="3">'.$theme_options.'</select>';
566  }
567 
568  $block['theme_select'] .= '<br />('.sprintf(_MB_SYSTEM_NUMTHEME, '<strong>'.count($xoopsConfig['theme_set_allowed']).'</strong>').')<br />';
569  return $block;
570 }
571 
573 {
574 
575  $chk = "";
576  $form = _MB_SYSTEM_THSHOW."&nbsp;";
577  if ( $options[0] == 1 ) {
578  $chk = " checked='checked'";
579  }
580  $form .= "<input type='radio' name='options[0]' value='1'".$chk." />&nbsp;"._YES;
581  $chk = "";
582  if ( $options[0] == 0 ) {
583  $chk = ' checked="checked"';
584  }
585  $form .= '&nbsp;<input type="radio" name="options[0]" value="0"'.$chk.' />'._NO;
586  $form .= '<br />'._MB_SYSTEM_THWIDTH.'&nbsp;';
587  $form .= "<input type='text' name='options[1]' value='".$options[1]."' />";
588  return $form;
589 }
590 
591 ?>