| 1 | <?php
|
|---|
| 2 | // $Id: system_blocks.php,v 1.42.2.2 2004/10/13 13:07:53 mithyt2 Exp $
|
|---|
| 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'].'">'.$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 | if (isset($_COOKIE[$xoopsConfig['usercookie']])) {
|
|---|
| 91 | $block['unamevalue'] = $_COOKIE[$xoopsConfig['usercookie']];
|
|---|
| 92 | }
|
|---|
| 93 | $block['lang_password'] = _PASSWORD;
|
|---|
| 94 | $block['lang_login'] = _LOGIN;
|
|---|
| 95 | $block['lang_lostpass'] = _MB_SYSTEM_LPASS;
|
|---|
| 96 | $block['lang_registernow'] = _MB_SYSTEM_RNOW;
|
|---|
| 97 | $block['lang_rememberme'] = _REMEMBERME; // autologin hack
|
|---|
| 98 | if ($xoopsConfig['use_ssl'] == 1 && $xoopsConfig['sslloginlink'] != '') {
|
|---|
| 99 | $block['sslloginlink'] = "<a href=\"javascript:openWithSelfMain('".$xoopsConfig['sslloginlink']."', 'ssllogin', 300, 200);\">"._MB_SYSTEM_SECURE."</a>";
|
|---|
| 100 | }
|
|---|
| 101 | return $block;
|
|---|
| 102 | }
|
|---|
| 103 | return false;
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | function b_system_main_show()
|
|---|
| 107 | {
|
|---|
| 108 | global $xoopsUser,$xoopsModule;
|
|---|
| 109 | $block = array();
|
|---|
| 110 | $block['lang_home'] = _MB_SYSTEM_HOME;
|
|---|
| 111 | $block['lang_close'] = _CLOSE;
|
|---|
| 112 | $module_handler =& xoops_gethandler('module');
|
|---|
| 113 | $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
|
|---|
| 114 | $criteria->add(new Criteria('isactive', 1));
|
|---|
| 115 | $criteria->add(new Criteria('weight', 0, '>'));
|
|---|
| 116 | $modules =& $module_handler->getObjects($criteria, true);
|
|---|
| 117 | $moduleperm_handler =& xoops_gethandler('groupperm');
|
|---|
| 118 | $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
|
|---|
| 119 | $read_allowed =& $moduleperm_handler->getItemIds('module_read', $groups);
|
|---|
| 120 | foreach (array_keys($modules) as $i) {
|
|---|
| 121 | if (in_array($i, $read_allowed)) {
|
|---|
| 122 | $block['modules'][$i]['name'] = $modules[$i]->getVar('name');
|
|---|
| 123 | $block['modules'][$i]['directory'] = $modules[$i]->getVar('dirname');
|
|---|
| 124 | $sublinks =& $modules[$i]->subLink();
|
|---|
| 125 | if ((count($sublinks) > 0) && (!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) {
|
|---|
| 126 | foreach($sublinks as $sublink){
|
|---|
| 127 | $block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => XOOPS_URL.'/modules/'.$modules[$i]->getVar('dirname').'/'.$sublink['url']);
|
|---|
| 128 | }
|
|---|
| 129 | } else {
|
|---|
| 130 | $block['modules'][$i]['sublinks'] = array();
|
|---|
| 131 | }
|
|---|
| 132 | }
|
|---|
| 133 | }
|
|---|
| 134 | return $block;
|
|---|
| 135 | }
|
|---|
| 136 |
|
|---|
| 137 | function b_system_search_show()
|
|---|
| 138 | {
|
|---|
| 139 | $block = array();
|
|---|
| 140 | $block['lang_search'] = _MB_SYSTEM_SEARCH;
|
|---|
| 141 | $block['lang_advsearch'] = _MB_SYSTEM_ADVS;
|
|---|
| 142 | return $block;
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | function b_system_user_show()
|
|---|
| 146 | {
|
|---|
| 147 | global $xoopsUser;
|
|---|
| 148 | if (is_object($xoopsUser)) {
|
|---|
| 149 | $pm_handler =& xoops_gethandler('privmessage');
|
|---|
| 150 | $block = array();
|
|---|
| 151 | $block['lang_youraccount'] = _MB_SYSTEM_VACNT;
|
|---|
| 152 | $block['lang_editaccount'] = _MB_SYSTEM_EACNT;
|
|---|
| 153 | $block['lang_notifications'] = _MB_SYSTEM_NOTIF;
|
|---|
| 154 | $block['uid'] = $xoopsUser->getVar('uid');
|
|---|
| 155 | $block['lang_logout'] = _MB_SYSTEM_LOUT;
|
|---|
| 156 | $criteria = new CriteriaCompo(new Criteria('read_msg', 0));
|
|---|
| 157 | $criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid')));
|
|---|
| 158 | $block['new_messages'] = $pm_handler->getCount($criteria);
|
|---|
| 159 | $block['lang_inbox'] = _MB_SYSTEM_INBOX;
|
|---|
| 160 | $block['lang_adminmenu'] = _MB_SYSTEM_ADMENU;
|
|---|
| 161 | return $block;
|
|---|
| 162 | }
|
|---|
| 163 | return false;
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | // this block is deprecated
|
|---|
| 167 | function b_system_waiting_show()
|
|---|
| 168 | {
|
|---|
| 169 | global $xoopsUser;
|
|---|
| 170 | $xoopsDB =& Database::getInstance();
|
|---|
| 171 | $module_handler =& xoops_gethandler('module');
|
|---|
| 172 | $block = array();
|
|---|
| 173 | if ($module_handler->getCount(new Criteria('dirname', 'news'))) {
|
|---|
| 174 | $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("stories")." WHERE published=0");
|
|---|
| 175 | if ( $result ) {
|
|---|
| 176 | $block['modules'][0]['adminlink'] = XOOPS_URL."/modules/news/admin/index.php?op=newarticle";
|
|---|
| 177 | list($block['modules'][0]['pendingnum']) = $xoopsDB->fetchRow($result);
|
|---|
| 178 | $block['modules'][0]['lang_linkname'] = _MB_SYSTEM_SUBMS;
|
|---|
| 179 | }
|
|---|
| 180 | }
|
|---|
| 181 | if ($module_handler->getCount(new Criteria('dirname', 'mylinks'))) {
|
|---|
| 182 | $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mylinks_links")." WHERE status=0");
|
|---|
| 183 | if ( $result ) {
|
|---|
| 184 | $block['modules'][1]['adminlink'] = XOOPS_URL."/modules/mylinks/admin/index.php?op=listNewLinks";
|
|---|
| 185 | list($block['modules'][1]['pendingnum']) = $xoopsDB->fetchRow($result);
|
|---|
| 186 | $block['modules'][1]['lang_linkname'] = _MB_SYSTEM_WLNKS;
|
|---|
| 187 | }
|
|---|
| 188 | $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mylinks_broken"));
|
|---|
| 189 | if ( $result ) {
|
|---|
| 190 | $block['modules'][2]['adminlink'] = XOOPS_URL."/modules/mylinks/admin/index.php?op=listBrokenLinks";
|
|---|
| 191 | list($block['modules'][2]['pendingnum']) = $xoopsDB->fetchRow($result);
|
|---|
| 192 | $block['modules'][2]['lang_linkname'] = _MB_SYSTEM_BLNK;
|
|---|
| 193 | }
|
|---|
| 194 | $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mylinks_mod"));
|
|---|
| 195 | if ( $result ) {
|
|---|
| 196 | $block['modules'][3]['adminlink'] = XOOPS_URL."/modules/mylinks/admin/index.php?op=listModReq";
|
|---|
| 197 | list($block['modules'][3]['pendingnum']) = $xoopsDB->fetchRow($result);
|
|---|
| 198 | $block['modules'][3]['lang_linkname'] = _MB_SYSTEM_MLNKS;
|
|---|
| 199 | }
|
|---|
| 200 | }
|
|---|
| 201 | if ($module_handler->getCount(new Criteria('dirname', 'mydownloads'))) {
|
|---|
| 202 | $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_downloads")." WHERE status=0");
|
|---|
| 203 | if ( $result ) {
|
|---|
| 204 | $block['modules'][4]['adminlink'] = XOOPS_URL."/modules/mydownloads/admin/index.php?op=listNewDownloads";
|
|---|
| 205 | list($block['modules'][4]['pendingnum']) = $xoopsDB->fetchRow($result);
|
|---|
| 206 | $block['modules'][4]['lang_linkname'] = _MB_SYSTEM_WDLS;
|
|---|
| 207 | }
|
|---|
| 208 | $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_broken")."");
|
|---|
| 209 | if ( $result ) {
|
|---|
| 210 | $block['modules'][5]['adminlink'] = XOOPS_URL."/modules/mydownloads/admin/index.php?op=listBrokenDownloads";
|
|---|
| 211 | list($block['modules'][5]['pendingnum']) = $xoopsDB->fetchRow($result);
|
|---|
| 212 | $block['modules'][5]['lang_linkname'] = _MB_SYSTEM_BFLS;
|
|---|
| 213 | }
|
|---|
| 214 | $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_mod")."");
|
|---|
| 215 | if ( $result ) {
|
|---|
| 216 | $block['modules'][6]['adminlink'] = XOOPS_URL."/modules/mydownloads/admin/index.php?op=listModReq";
|
|---|
| 217 | list($block['modules'][6]['pendingnum']) = $xoopsDB->fetchRow($result);
|
|---|
| 218 | $block['modules'][6]['lang_linkname'] = _MB_SYSTEM_MFLS;
|
|---|
| 219 | }
|
|---|
| 220 | }
|
|---|
| 221 | $result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("xoopscomments")." WHERE com_status=1");
|
|---|
| 222 | if ( $result ) {
|
|---|
| 223 | $block['modules'][7]['adminlink'] = XOOPS_URL."/modules/system/admin.php?module=0&status=1&fct=comments";
|
|---|
| 224 | list($block['modules'][7]['pendingnum']) = $xoopsDB->fetchRow($result);
|
|---|
| 225 | $block['modules'][7]['lang_linkname'] =_MB_SYSTEM_COMPEND;
|
|---|
| 226 | }
|
|---|
| 227 | return $block;
|
|---|
| 228 | }
|
|---|
| 229 |
|
|---|
| 230 | function b_system_info_show($options)
|
|---|
| 231 | {
|
|---|
| 232 | global $xoopsConfig, $xoopsUser;
|
|---|
| 233 | $xoopsDB =& Database::getInstance();
|
|---|
| 234 | $myts =& MyTextSanitizer::getInstance();
|
|---|
| 235 | $block = array();
|
|---|
| 236 | if (!empty($options[3])) {
|
|---|
| 237 | $block['showgroups'] = true;
|
|---|
| 238 | $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");
|
|---|
| 239 | if ($xoopsDB->getRowsNum($result) > 0) {
|
|---|
| 240 | $prev_caption = "";
|
|---|
| 241 | $i = 0;
|
|---|
| 242 | while ($userinfo = $xoopsDB->fetchArray($result)) {
|
|---|
| 243 | if ($prev_caption != $userinfo['groupname']) {
|
|---|
| 244 | $prev_caption = $userinfo['groupname'];
|
|---|
| 245 | $block['groups'][$i]['name'] = $myts->htmlSpecialChars($userinfo['groupname']);
|
|---|
| 246 | }
|
|---|
| 247 | if ($xoopsUser != '') {
|
|---|
| 248 | $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']);
|
|---|
| 249 | } else {
|
|---|
| 250 | if ($userinfo['user_viewemail']) {
|
|---|
| 251 | $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']);
|
|---|
| 252 | } else {
|
|---|
| 253 | $block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlspecialchars($userinfo['uname']), 'msglink' => ' ', 'avatar' => XOOPS_UPLOAD_URL.'/'.$userinfo['user_avatar']);
|
|---|
| 254 | }
|
|---|
| 255 | }
|
|---|
| 256 | $i++;
|
|---|
| 257 | }
|
|---|
| 258 | }
|
|---|
| 259 | } else {
|
|---|
| 260 | $block['showgroups'] = false;
|
|---|
| 261 | }
|
|---|
| 262 | $block['logourl'] = XOOPS_URL.'/images/'.$options[2];
|
|---|
| 263 | $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>";
|
|---|
| 264 | return $block;
|
|---|
| 265 | }
|
|---|
| 266 |
|
|---|
| 267 | function b_system_newmembers_show($options)
|
|---|
| 268 | {
|
|---|
| 269 | $block = array();
|
|---|
| 270 | $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
|
|---|
| 271 | $limit = (!empty($options[0])) ? $options[0] : 10;
|
|---|
| 272 | $criteria->setOrder('DESC');
|
|---|
| 273 | $criteria->setSort('user_regdate');
|
|---|
| 274 | $criteria->setLimit($limit);
|
|---|
| 275 | $member_handler =& xoops_gethandler('member');
|
|---|
| 276 | $newmembers =& $member_handler->getUsers($criteria);
|
|---|
| 277 | $count = count($newmembers);
|
|---|
| 278 | for ($i = 0; $i < $count; $i++) {
|
|---|
| 279 | if ( $options[1] == 1 ) {
|
|---|
| 280 | $block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL.'/'.$newmembers[$i]->getVar('user_avatar') : '';
|
|---|
| 281 | } else {
|
|---|
| 282 | $block['users'][$i]['avatar'] = '';
|
|---|
| 283 | }
|
|---|
| 284 | $block['users'][$i]['id'] = $newmembers[$i]->getVar('uid');
|
|---|
| 285 | $block['users'][$i]['name'] = $newmembers[$i]->getVar('uname');
|
|---|
| 286 | $block['users'][$i]['joindate'] = formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's');
|
|---|
| 287 | }
|
|---|
| 288 | return $block;
|
|---|
| 289 | }
|
|---|
| 290 |
|
|---|
| 291 | function b_system_topposters_show($options)
|
|---|
| 292 | {
|
|---|
| 293 | $block = array();
|
|---|
| 294 | $criteria = new CriteriaCompo(new Criteria('level', 0, '>'));
|
|---|
| 295 | $limit = (!empty($options[0])) ? $options[0] : 10;
|
|---|
| 296 | $size = count($options);
|
|---|
| 297 | for ( $i = 2; $i < $size; $i++) {
|
|---|
| 298 | $criteria->add(new Criteria('rank', $options[$i], '<>'));
|
|---|
| 299 | }
|
|---|
| 300 | $criteria->setOrder('DESC');
|
|---|
| 301 | $criteria->setSort('posts');
|
|---|
| 302 | $criteria->setLimit($limit);
|
|---|
| 303 | $member_handler =& xoops_gethandler('member');
|
|---|
| 304 | $topposters =& $member_handler->getUsers($criteria);
|
|---|
| 305 | $count = count($topposters);
|
|---|
| 306 | for ($i = 0; $i < $count; $i++) {
|
|---|
| 307 | $block['users'][$i]['rank'] = $i+1;
|
|---|
| 308 | if ( $options[1] == 1 ) {
|
|---|
| 309 | $block['users'][$i]['avatar'] = $topposters[$i]->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL.'/'.$topposters[$i]->getVar('user_avatar') : '';
|
|---|
| 310 | } else {
|
|---|
| 311 | $block['users'][$i]['avatar'] = '';
|
|---|
| 312 | }
|
|---|
| 313 | $block['users'][$i]['id'] = $topposters[$i]->getVar('uid');
|
|---|
| 314 | $block['users'][$i]['name'] = $topposters[$i]->getVar('uname');
|
|---|
| 315 | $block['users'][$i]['posts'] = $topposters[$i]->getVar('posts');
|
|---|
| 316 | }
|
|---|
| 317 | return $block;
|
|---|
| 318 | }
|
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 | function b_system_comments_show($options)
|
|---|
| 322 | {
|
|---|
| 323 | $block = array();
|
|---|
| 324 | include_once XOOPS_ROOT_PATH.'/include/comment_constants.php';
|
|---|
| 325 | $comment_handler =& xoops_gethandler('comment');
|
|---|
| 326 | $criteria = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE));
|
|---|
| 327 | $criteria->setLimit(intval($options[0]));
|
|---|
| 328 | $criteria->setSort('com_created');
|
|---|
| 329 | $criteria->setOrder('DESC');
|
|---|
| 330 | $comments =& $comment_handler->getObjects($criteria, true);
|
|---|
| 331 | $member_handler =& xoops_gethandler('member');
|
|---|
| 332 | $module_handler =& xoops_gethandler('module');
|
|---|
| 333 | $modules =& $module_handler->getObjects(new Criteria('hascomments', 1), true);
|
|---|
| 334 | $comment_config = array();
|
|---|
| 335 | foreach (array_keys($comments) as $i) {
|
|---|
| 336 | $mid = $comments[$i]->getVar('com_modid');
|
|---|
| 337 | $com['module'] = '<a href="'.XOOPS_URL.'/modules/'.$modules[$mid]->getVar('dirname').'/">'.$modules[$mid]->getVar('name').'</a>';
|
|---|
| 338 | if (!isset($comment_config[$mid])) {
|
|---|
| 339 | $comment_config[$mid] = $modules[$mid]->getInfo('comments');
|
|---|
| 340 | }
|
|---|
| 341 | $com['id'] = $i;
|
|---|
| 342 | $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').'&'.$comments[$i]->getVar('com_exparams').'#comment'.$i.'">'.$comments[$i]->getVar('com_title').'</a>';
|
|---|
| 343 | $com['icon'] = $comments[$i]->getVar('com_icon');
|
|---|
| 344 | $com['icon'] = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif';
|
|---|
| 345 | $com['time'] = formatTimestamp($comments[$i]->getVar('com_created'),'m');
|
|---|
| 346 | if ($comments[$i]->getVar('com_uid') > 0) {
|
|---|
| 347 | $poster =& $member_handler->getUser($comments[$i]->getVar('com_uid'));
|
|---|
| 348 | if (is_object($poster)) {
|
|---|
| 349 | $com['poster'] = '<a href="'.XOOPS_URL.'/userinfo.php?uid='.$comments[$i]->getVar('com_uid').'">'.$poster->getVar('uname').'</a>';
|
|---|
| 350 | } else {
|
|---|
| 351 | $com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
|
|---|
| 352 | }
|
|---|
| 353 | } else {
|
|---|
| 354 | $com['poster'] = $GLOBALS['xoopsConfig']['anonymous'];
|
|---|
| 355 | }
|
|---|
| 356 | $block['comments'][] =& $com;
|
|---|
| 357 | unset($com);
|
|---|
| 358 | }
|
|---|
| 359 | return $block;
|
|---|
| 360 | }
|
|---|
| 361 |
|
|---|
| 362 | // RMV-NOTIFY
|
|---|
| 363 | function b_system_notification_show()
|
|---|
| 364 | {
|
|---|
| 365 | global $xoopsConfig, $xoopsUser, $xoopsModule;
|
|---|
| 366 | include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
|
|---|
| 367 | include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php';
|
|---|
| 368 | // Notification must be enabled, and user must be logged in
|
|---|
| 369 | if (empty($xoopsUser) || !notificationEnabled('block')) {
|
|---|
| 370 | return false; // do not display block
|
|---|
| 371 | }
|
|---|
| 372 | $notification_handler =& xoops_gethandler('notification');
|
|---|
| 373 | // Now build the a nested associative array of info to pass
|
|---|
| 374 | // to the block template.
|
|---|
| 375 | $block = array();
|
|---|
| 376 | $categories =& notificationSubscribableCategoryInfo();
|
|---|
| 377 | if (empty($categories)) {
|
|---|
| 378 | return false;
|
|---|
| 379 | }
|
|---|
| 380 | foreach ($categories as $category) {
|
|---|
| 381 | $section['name'] = $category['name'];
|
|---|
| 382 | $section['title'] = $category['title'];
|
|---|
| 383 | $section['description'] = $category['description'];
|
|---|
| 384 | $section['itemid'] = $category['item_id'];
|
|---|
| 385 | $section['events'] = array();
|
|---|
| 386 | $subscribed_events =& $notification_handler->getSubscribedEvents ($category['name'], $category['item_id'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid'));
|
|---|
| 387 | foreach (notificationEvents($category['name'], true) as $event) {
|
|---|
| 388 | if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) {
|
|---|
| 389 | continue;
|
|---|
| 390 | }
|
|---|
| 391 | $subscribed = in_array($event['name'], $subscribed_events) ? 1 : 0;
|
|---|
| 392 | $section['events'][$event['name']] = array ('name'=>$event['name'], 'title'=>$event['title'], 'caption'=>$event['caption'], 'description'=>$event['description'], 'subscribed'=>$subscribed);
|
|---|
| 393 | }
|
|---|
| 394 | $block['categories'][$category['name']] = $section;
|
|---|
| 395 | }
|
|---|
| 396 | // Additional form data
|
|---|
| 397 | $block['target_page'] = "notification_update.php";
|
|---|
| 398 | // FIXME: better or more standardized way to do this?
|
|---|
| 399 | $script_url = explode('/', $_SERVER['PHP_SELF']);
|
|---|
| 400 | $script_name = $script_url[count($script_url)-1];
|
|---|
| 401 | $block['redirect_script'] = $script_name;
|
|---|
| 402 | $block['submit_button'] = _NOT_UPDATENOW;
|
|---|
| 403 | return $block;
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | function b_system_comments_edit($options)
|
|---|
| 407 | {
|
|---|
| 408 | $inputtag = "<input type='text' name='options[]' value='".intval($options[0])."' />";
|
|---|
| 409 | $form = sprintf(_MB_SYSTEM_DISPLAYC, $inputtag);
|
|---|
| 410 | return $form;
|
|---|
| 411 | }
|
|---|
| 412 |
|
|---|
| 413 | function b_system_topposters_edit($options)
|
|---|
| 414 | {
|
|---|
| 415 | include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
|
|---|
| 416 | $inputtag = "<input type='text' name='options[]' value='".intval($options[0])."' />";
|
|---|
| 417 | $form = sprintf(_MB_SYSTEM_DISPLAY,$inputtag);
|
|---|
| 418 | $form .= "<br />"._MB_SYSTEM_DISPLAYA." <input type='radio' id='options[]' name='options[]' value='1'";
|
|---|
| 419 | if ( $options[1] == 1 ) {
|
|---|
| 420 | $form .= " checked='checked'";
|
|---|
| 421 | }
|
|---|
| 422 | $form .= " /> "._YES."<input type='radio' id='options[]' name='options[]' value='0'";
|
|---|
| 423 | if ( $options[1] == 0 ) {
|
|---|
| 424 | $form .= " checked='checked'";
|
|---|
| 425 | }
|
|---|
| 426 | $form .= " /> "._NO."";
|
|---|
| 427 | $form .= "<br />"._MB_SYSTEM_NODISPGR."<br /><select id='options[]' name='options[]' multiple='multiple'>";
|
|---|
| 428 | $ranks =& XoopsLists::getUserRankList();
|
|---|
| 429 | $size = count($options);
|
|---|
| 430 | foreach ($ranks as $k => $v) {
|
|---|
| 431 | $sel = "";
|
|---|
| 432 | for ( $i = 2; $i < $size; $i++ ) {
|
|---|
| 433 | if ($k == $options[$i]) {
|
|---|
| 434 | $sel = " selected='selected'";
|
|---|
| 435 | }
|
|---|
| 436 | }
|
|---|
| 437 | $form .= "<option value='$k'$sel>$v</option>";
|
|---|
| 438 | }
|
|---|
| 439 | $form .= "</select>";
|
|---|
| 440 | return $form;
|
|---|
| 441 | }
|
|---|
| 442 |
|
|---|
| 443 | function b_system_newmembers_edit($options)
|
|---|
| 444 | {
|
|---|
| 445 | $inputtag = "<input type='text' name='options[]' value='".$options[0]."' />";
|
|---|
| 446 | $form = sprintf(_MB_SYSTEM_DISPLAY,$inputtag);
|
|---|
| 447 | $form .= "<br />"._MB_SYSTEM_DISPLAYA." <input type='radio' id='options[]' name='options[]' value='1'";
|
|---|
| 448 | if ( $options[1] == 1 ) {
|
|---|
| 449 | $form .= " checked='checked'";
|
|---|
| 450 | }
|
|---|
| 451 | $form .= " /> "._YES."<input type='radio' id='options[]' name='options[]' value='0'";
|
|---|
| 452 | if ( $options[1] == 0 ) {
|
|---|
| 453 | $form .= " checked='checked'";
|
|---|
| 454 | }
|
|---|
| 455 | $form .= " /> "._NO."";
|
|---|
| 456 | return $form;
|
|---|
| 457 | }
|
|---|
| 458 |
|
|---|
| 459 | function b_system_info_edit($options)
|
|---|
| 460 | {
|
|---|
| 461 | $form = _MB_SYSTEM_PWWIDTH." ";
|
|---|
| 462 | $form .= "<input type='text' name='options[]' value='".$options[0]."' />";
|
|---|
| 463 | $form .= "<br />"._MB_SYSTEM_PWHEIGHT." ";
|
|---|
| 464 | $form .= "<input type='text' name='options[]' value='".$options[1]."' />";
|
|---|
| 465 | $form .= "<br />".sprintf(_MB_SYSTEM_LOGO,XOOPS_URL."/images/")." ";
|
|---|
| 466 | $form .= "<input type='text' name='options[]' value='".$options[2]."' />";
|
|---|
| 467 | $chk = "";
|
|---|
| 468 | $form .= "<br />"._MB_SYSTEM_SADMIN." ";
|
|---|
| 469 | if ( $options[3] == 1 ) {
|
|---|
| 470 | $chk = " checked='checked'";
|
|---|
| 471 | }
|
|---|
| 472 | $form .= "<input type='radio' name='options[3]' value='1'".$chk." /> "._YES."";
|
|---|
| 473 | $chk = "";
|
|---|
| 474 | if ( $options[3] == 0 ) {
|
|---|
| 475 | $chk = " checked=\"checked\"";
|
|---|
| 476 | }
|
|---|
| 477 | $form .= " <input type='radio' name='options[3]' value='0'".$chk." />"._NO."";
|
|---|
| 478 | return $form;
|
|---|
| 479 | }
|
|---|
| 480 |
|
|---|
| 481 | function b_system_themes_show($options)
|
|---|
| 482 | {
|
|---|
| 483 | global $xoopsConfig;
|
|---|
| 484 | $theme_options = '';
|
|---|
| 485 | foreach ($xoopsConfig['theme_set_allowed'] as $theme) {
|
|---|
| 486 | $theme_options .= '<option value="'.$theme.'"';
|
|---|
| 487 | if ($theme == $xoopsConfig['theme_set']) {
|
|---|
| 488 | $theme_options .= ' selected="selected"';
|
|---|
| 489 | }
|
|---|
| 490 | $theme_options .= '>'.$theme.'</option>';
|
|---|
| 491 | }
|
|---|
| 492 | $block = array();
|
|---|
| 493 | if ($options[0] == 1) {
|
|---|
| 494 | $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."\" />";
|
|---|
| 495 | } else {
|
|---|
| 496 | $block['theme_select'] = '<select name="xoops_theme_select" onchange="submit();" size="3">'.$theme_options.'</select>';
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 | $block['theme_select'] .= '<br />('.sprintf(_MB_SYSTEM_NUMTHEME, '<b>'.count($xoopsConfig['theme_set_allowed']).'</b>').')<br />';
|
|---|
| 500 | return $block;
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | function b_system_themes_edit($options)
|
|---|
| 504 | {
|
|---|
| 505 |
|
|---|
| 506 | $chk = "";
|
|---|
| 507 | $form = _MB_SYSTEM_THSHOW." ";
|
|---|
| 508 | if ( $options[0] == 1 ) {
|
|---|
| 509 | $chk = " checked='checked'";
|
|---|
| 510 | }
|
|---|
| 511 | $form .= "<input type='radio' name='options[0]' value='1'".$chk." /> "._YES;
|
|---|
| 512 | $chk = "";
|
|---|
| 513 | if ( $options[0] == 0 ) {
|
|---|
| 514 | $chk = ' checked="checked"';
|
|---|
| 515 | }
|
|---|
| 516 | $form .= ' <input type="radio" name="options[0]" value="0"'.$chk.' />'._NO;
|
|---|
| 517 | $form .= '<br />'._MB_SYSTEM_THWIDTH.' ';
|
|---|
| 518 | $form .= "<input type='text' name='options[1]' value='".$options[1]."' />";
|
|---|
| 519 | return $form;
|
|---|
| 520 | }
|
|---|
| 521 |
|
|---|
| 522 | ?> |
|---|