function plugin_xoopsblock_convert() { if ($this->root->module['platform'] !== "xoops") { return ''; } static $css_show = FALSE; list($tgt, $option1, $option2) = array_pad(func_get_args(), 3, ""); $tgt_bids = array(); if (!$tgt || $tgt === "?") { $tgt = "?"; } else { foreach (explode(",", $tgt) as $_bid) { if (preg_match("/^\\d+\$/", $_bid) && $_bid > 0) { $tgt_bids[] = $_bid; } } } $align = "left"; $around = false; $width = ""; $arg = array(); if (preg_match("/^(left|center|right)\$/i", $option2, $arg)) { $align = $arg[1]; } if (preg_match("/^(left|center|right)\$/i", $option1, $arg)) { $align = $arg[1]; } if (preg_match("/^(around|float|width)(:?w?([\\d]+%?)(?:px)?)?\$/i", $option2, $arg)) { if ($arg[1]) { $around = true; } $width = !strstr($arg[3], "%") ? $arg[3] . "px" : $arg[3]; $width = "width:" . $width . ";"; } if (preg_match("/^(around|float|width)(:?w?([\\d]+%?)(?:px)?)?\$/i", $option1, $arg)) { if ($arg[1]) { $around = true; } $width = !strstr($arg[3], "%") ? $arg[3] . "px" : $arg[3]; $width = "width:" . $width . ";"; } if ($align === 'center') { if (!$width) { $width = 'width:auto;'; } $style = ' style="margin-left:auto;margin-right:auto;' . $width . '"'; $around = false; } else { $style = ' style="float:' . $align . ';' . $width . '"'; } $clear = $around ? '' : '<div style="clear:both;"></div>'; global $xoopsUser; $xoopsblock = new XoopsBlock(); $xoopsgroup = new XoopsGroup(); $arr = array(); $side = null; if ($this->root->userinfo['admin']) { $arr = $xoopsblock->getAllBlocks(); } else { if ($xoopsUser) { $arr = $xoopsblock->getAllBlocksByGroup($xoopsUser->groups()); } else { $arr = $xoopsblock->getAllBlocksByGroup($this->plugin_xoopsblock_getByType("Anonymous")); } } $ret = ""; if ($tgt == "?") { foreach ($arr as $myblock) { $block = array(); $block_type = @$myblock->getVar("type") ? $myblock->getVar("type") : $myblock->getVar("block_type"); $name = @$myblock->getVar("title") ? $myblock->getVar("title") : $myblock->getVar("name"); $bid = $myblock->getVar('bid'); $ret .= "<li>(" . $bid . ")" . $name . "</li>"; } } else { global $xoopsTpl; require_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); if (is_object($xoopsUser)) { $xoopsTpl->assign(array('xoops_isuser' => true, 'xoops_userid' => $xoopsUser->getVar('uid'), 'xoops_uname' => $xoopsUser->getVar('uname'), 'xoops_isadmin' => $xoopsUser->isAdmin())); } $xoopsTpl->assign('xoops_requesturi', htmlspecialchars($GLOBALS['xoopsRequestUri'], ENT_QUOTES)); foreach ($tgt_bids as $bid) { $myblock = new XoopsBlock($bid); $_bid = $myblock->getVar('bid'); if (!empty($_bid)) { $bcachetime = $myblock->getVar('bcachetime'); // Only a guest enable cache. by nao-pon //if (empty($bcachetime)) { if ($bcachetime % 10 == 1) { $bcachetime_guest = TRUE; $bcachetime = $bcachetime - 1; } else { $bcachetime_guest = FALSE; } if (empty($bcachetime) || is_object($xoopsUser) && $bcachetime_guest) { //if (empty($bcachetime)) { $xoopsTpl->xoops_setCaching(0); } else { $xoopsTpl->xoops_setCaching(2); $xoopsTpl->xoops_setCacheTime($bcachetime); } $btpl = $myblock->getVar('template'); if ($btpl != '') { if (empty($bcachetime) || !$xoopsTpl->is_cached('db:' . $btpl, 'blk_' . $myblock->getVar('bid'))) { //$xoopsLogger->addBlock($myblock->getVar('name')); $bresult = $myblock->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('block', $bresult); $bcontent = $xoopsTpl->fetch('db:' . $btpl, 'blk_' . $myblock->getVar('bid')); $xoopsTpl->clear_assign('block'); } else { //$xoopsLogger->addBlock($myblock->getVar('name'), true, $bcachetime); $bcontent = $xoopsTpl->fetch('db:' . $btpl, 'blk_' . $myblock->getVar('bid')); } } else { //$bid = $myblock->getVar('bid'); if (empty($bcachetime) || !$xoopsTpl->is_cached('db:system_dummy.html', 'blk_' . $bid)) { //$xoopsLogger->addBlock($myblock->getVar('name')); $bresult = $myblock->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('dummy_content', $bresult['content']); $bcontent = $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); $xoopsTpl->clear_assign('block'); } else { //$xoopsLogger->addBlock($myblock->getVar('name'), true, $bcachetime); $bcontent = $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); } } $btitle = $myblock->getVar('title'); } else { $btitle = "Block({$bid})"; $bcontent = "Block({$bid}) is not found."; } if ($bcontent) { $ret .= "<h5>" . $btitle . "</h5>\n"; $ret .= $bcontent; foreach (explode("\n", $xoopsTpl->get_template_vars('xoops_block_header')) as $str) { $this->root->head_tags[] = rtrim($str); } foreach (explode("\n", $xoopsTpl->get_template_vars('xoops_module_header')) as $str) { $this->root->head_tags[] = rtrim($str); } $this->root->head_tags = array_unique($this->root->head_tags); } } unset($myblock); } if (!$css_show) { $css_show = true; $this->root->head_pre_tags[] = "<link rel=\"stylesheet\" type=\"text/css\" media=\"all\" href=\"" . XOOPS_URL . "/xoops.css\" />"; } if ($tgt == "?") { $ret = "<ul>{$ret}</ul>"; } unset($xoopsblock, $xoopsgroup); return "<div{$style}>{$ret}</div>{$clear}"; }
function modifyGroup($g_id) { global $HTTP_GET_VARS, $HTTP_POST_VARS; $userstart = $memstart = 0; if (!empty($HTTP_POST_VARS['userstart'])) { $userstart = intval($HTTP_POST_VARS['userstart']); } elseif (!empty($HTTP_GET_VARS['userstart'])) { $userstart = intval($HTTP_GET_VARS['userstart']); } if (!empty($HTTP_POST_VARS['memstart'])) { $memstart = intval($HTTP_POST_VARS['memstart']); } elseif (!empty($HTTP_GET_VARS['memstart'])) { $memstart = intval($HTTP_GET_VARS['memstart']); } xoops_cp_header(); //OpenTable(); echo '<a href="admin.php?fct=groups">' . _AM_GROUPSMAIN . '</a> <span style="font-weight:bold;">»»</span> ' . _AM_MODIFYADG . '<br /><br />'; $member_handler =& xoops_gethandler('member'); $thisgroup =& $member_handler->getGroup($g_id); $name_value = $thisgroup->getVar("name", "E"); $desc_value = $thisgroup->getVar("description", "E"); $moduleperm_handler =& xoops_gethandler('groupperm'); $a_mod_value =& $moduleperm_handler->getItemIds('module_admin', $thisgroup->getVar('groupid')); $r_mod_value =& $moduleperm_handler->getItemIds('module_read', $thisgroup->getVar('groupid')); $r_block_value =& XoopsBlock::getAllBlocksByGroup($thisgroup->getVar("groupid"), false); $op_value = "update"; $submit_value = _AM_UPDATEADG; $g_id_value = $thisgroup->getVar("groupid"); $type_value = $thisgroup->getVar("group_type", "E"); $form_title = _AM_MODIFYADG; if (XOOPS_GROUP_ADMIN == $g_id) { $s_cat_disable = true; } $sysperm_handler =& xoops_gethandler('groupperm'); $s_cat_value =& $sysperm_handler->getItemIds('system_admin', $g_id); include XOOPS_ROOT_PATH . "/modules/system/admin/groups/groupform.php"; echo "<br /><h4 style='text-align:left'>" . _AM_EDITMEMBER . "</h4>"; $usercount = $member_handler->getUserCount(new Criteria('level', 0, '>')); $member_handler =& xoops_gethandler('member'); $membercount = $member_handler->getUserCountByGroup($g_id); if ($usercount < 200 && $membercount < 200) { // do the old way only when counts are small $members =& $member_handler->getUsersByGroup($g_id, true); $mlist = array(); $mcount = count($members); for ($i = 0; $i < $mcount; $i++) { $mlist[$members[$i]->getVar('uid')] = $members[$i]->getVar('uname'); } $criteria = new Criteria('level', 0, '>'); $criteria->setSort('uname'); $userslist =& $member_handler->getUserList($criteria); $users =& array_diff($userslist, $mlist); echo '<table class="outer"> <tr><th align="center">' . _AM_NONMEMBERS . '<br />'; echo '</th><th></th><th align="center">' . _AM_MEMBERS . '<br />'; echo '</th></tr> <tr><td class="even"> <form action="admin.php" method="post"> <select name="uids[]" size="10" multiple="multiple">' . "\n"; $size = sizeof($userids); foreach ($users as $u_id => $u_name) { echo '<option value="' . $u_id . '">' . $u_name . '</option>' . "\n"; } echo '</select>'; echo "</td><td align='center' class='odd'>\r\n\t\t<input type='hidden' name='op' value='addUser' />\r\n\t\t<input type='hidden' name='fct' value='groups' />\r\n\t\t<input type='hidden' name='groupid' value='" . $thisgroup->getVar("groupid") . "' />\r\n\t\t<input type='submit' name='submit' value='" . _AM_ADDBUTTON . "' />\r\n\t\t</form><br />\r\n\t\t<form action='admin.php' method='post' />\r\n\t\t<input type='hidden' name='op' value='delUser' />\r\n\t\t<input type='hidden' name='fct' value='groups' />\r\n\t\t<input type='hidden' name='groupid' value='" . $thisgroup->getVar("groupid") . "' />\r\n\t\t<input type='submit' name='submit' value='" . _AM_DELBUTTON . "' />\r\n\t\t</td>\r\n\t\t<td class='even'>"; echo "<select name='uids[]' size='10' multiple='multiple'>"; foreach ($mlist as $m_id => $m_name) { echo '<option value="' . $m_id . '">' . $m_name . '</option>' . "\n"; } echo "</select>"; echo '</td></tr> </form> </table>'; } else { $members =& $member_handler->getUsersByGroup($g_id, true, 200, $memstart); $mlist = array(); $mcount = count($members); for ($i = 0; $i < $mcount; $i++) { $mlist[$members[$i]->getVar('uid')] = $members[$i]->getVar('uname'); } echo '<a href="' . XOOPS_URL . '/modules/system/admin.php?fct=findusers&group=' . $g_id . '">' . _AM_FINDU4GROUP . '</a><br />'; echo '<form action="admin.php" method="post"> <table class="outer"> <tr><th align="center">' . _AM_MEMBERS . '<br />'; $nav = new XoopsPageNav($membercount, 200, $memstart, "memstart", "fct=groups&op=modify&g_id=" . $g_id); echo $nav->renderNav(4); echo "</th></tr>\r\n\t\t<tr><td class='even' align='center'>\r\n\t\t<input type='hidden' name='op' value='delUser' />\r\n\t\t<input type='hidden' name='fct' value='groups' />\r\n\t\t<input type='hidden' name='groupid' value='" . $thisgroup->getVar("groupid") . "' />\r\n\t\t<input type='hidden' name='memstart' value='" . $memstart . "' />\r\n\t\t<select name='uids[]' size='10' multiple='multiple'>"; foreach ($mlist as $m_id => $m_name) { echo '<option value="' . $m_id . '">' . $m_name . '</option>' . "\n"; } echo "</select><br />\r\n\t\t<input type='submit' name='submit' value='" . _DELETE . "' />\r\n\t\t</td></tr>\r\n\t\t</table>\r\n\t\t</form>"; } //CloseTable(); xoops_cp_footer(); }
function smarty_function_block($params, &$smarty) { if (!isset($params['id'])) { return; } $display_title = isset($params['display']) && $params['display'] == 'title' ? true : false; $display_none = isset($params['display']) && $params['display'] == 'none' ? true : false; $options = isset($params['options']) ? $params['options'] : false; $groups = isset($params['groups']) ? explode('|', $params['groups']) : false; $cache = isset($params['cache']) ? intval($params['cache']) : false; $block_id = intval($params['id']); static $block_objs; if (!isset($block_objs[$block_id])) { include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php'; $blockObj = new XoopsBlock($block_id); if (!is_object($blockObj)) { return; } $block_objs[$block_id] = $blockObj; } else { $blockObj = $block_objs[$block_id]; } $user_groups = $GLOBALS['xoopsUser'] ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS); static $allowed_blocks; if (count($allowed_blocks) == 0) { $allowed_blocks = XoopsBlock::getAllBlocksByGroup($user_groups, false); } if ($groups) { if (!array_intersect($user_groups, $groups)) { return; } } else { if (!in_array($block_id, $allowed_blocks)) { return; } } if ($options) { $blockObj->setVar('options', $options); } if ($cache) { $blockObj->setVar('bcachetime', $cache); } if ($display_title) { return $blockObj->getVar('title'); } $xoopsLogger =& XoopsLogger::instance(); $template =& $GLOBALS['xoopsTpl']; $bcachetime = intval($blockObj->getVar('bcachetime')); if (empty($bcachetime)) { $template->caching = 0; } else { $template->caching = 2; $template->cache_lifetime = $bcachetime; } $template->setCompileId($blockObj->getVar('dirname', 'n')); $tplName = ($tplName = $blockObj->getVar('template')) ? "db:{$tplName}" : "db:system_block_dummy.html"; $cacheid = 'blk_' . $block_id; if (!$bcachetime || !$template->is_cached($tplName, $cacheid)) { $xoopsLogger->addBlock($blockObj->getVar('name')); if (!($bresult = $blockObj->buildBlock())) { return; } if (!$display_none) { $template->assign('block', $bresult); $template->display($tplName, $cacheid); } } else { $xoopsLogger->addBlock($blockObj->getVar('name'), true, $bcachetime); if (!$display_none) { $template->display($tplName, $cacheid); } } $template->setCompileId($blockObj->getVar('dirname', 'n')); }
function make_cblock() { global $xoopsUser, $xoopsOption; $xoopsblock = new XoopsBlock(); $cc_block = $cl_block = $cr_block = ""; $arr = array(); if ($xoopsOption['theme_use_smarty'] == 0) { if (!isset($GLOBALS['xoopsTpl']) || !is_object($GLOBALS['xoopsTpl'])) { include_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); } else { $xoopsTpl =& $GLOBALS['xoopsTpl']; } if (is_object($xoopsUser)) { $block_arr = $xoopsblock->getAllBlocksByGroup($xoopsUser->getGroups(), true, XOOPS_CENTERBLOCK_ALL, XOOPS_BLOCK_VISIBLE); } else { $block_arr = $xoopsblock->getAllBlocksByGroup(XOOPS_GROUP_ANONYMOUS, true, XOOPS_CENTERBLOCK_ALL, XOOPS_BLOCK_VISIBLE); } $block_count = count($block_arr); $xoopsLogger =& XoopsLogger::instance(); for ($i = 0; $i < $block_count; $i++) { $bcachetime = intval($block_arr[$i]->getVar('bcachetime')); if (empty($bcachetime)) { $xoopsTpl->xoops_setCaching(0); } else { $xoopsTpl->xoops_setCaching(2); $xoopsTpl->xoops_setCacheTime($bcachetime); } $btpl = $block_arr[$i]->getVar('template'); if ($btpl != '') { if (empty($bcachetime) || !$xoopsTpl->is_cached('db:' . $btpl)) { $xoopsLogger->addBlock($block_arr[$i]->getVar('name')); $bresult =& $block_arr[$i]->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('block', $bresult); $bcontent =& $xoopsTpl->fetch('db:' . $btpl); $xoopsTpl->clear_assign('block'); } else { $xoopsLogger->addBlock($block_arr[$i]->getVar('name'), true, $bcachetime); $bcontent =& $xoopsTpl->fetch('db:' . $btpl); } } else { $bid = $block_arr[$i]->getVar('bid'); if (empty($bcachetime) || !$xoopsTpl->is_cached('db:system_dummy.html', 'blk_' . $bid)) { $xoopsLogger->addBlock($block_arr[$i]->getVar('name')); $bresult =& $block_arr[$i]->buildBlock(); if (!$bresult) { continue; } $xoopsTpl->assign_by_ref('dummy_content', $bresult['content']); $bcontent =& $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); $xoopsTpl->clear_assign('block'); } else { $xoopsLogger->addBlock($block_arr[$i]->getVar('name'), true, $bcachetime); $bcontent =& $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); } } $title = $block_arr[$i]->getVar('title'); switch ($block_arr[$i]->getVar('side')) { case XOOPS_CENTERBLOCK_CENTER: if ($title != "") { $cc_block .= '<tr valign="top"><td colspan="2"><strong>' . $title . '</strong><hr />' . $bcontent . '<br /><br /></td></tr>' . "\n"; } else { $cc_block .= '<tr><td colspan="2">' . $bcontent . '<br /><br /></td></tr>' . "\n"; } break; case XOOPS_CENTERBLOCK_LEFT: if ($title != "") { $cl_block .= '<p><strong>' . $title . '</strong><hr />' . $bcontent . '</p>' . "\n"; } else { $cl_block .= '<p>' . $bcontent . '</p>' . "\n"; } break; case XOOPS_CENTERBLOCK_RIGHT: if ($title != "") { $cr_block .= '<p><strong>' . $title . '</strong><hr />' . $bcontent . '</p>' . "\n"; } else { $cr_block .= '<p>' . $bcontent . '</p>' . "\n"; } break; default: break; } unset($bcontent, $title); } echo '<table width="100%">' . $cc_block . '<tr valign="top"><td width="50%">' . $cl_block . '</td><td width="50%">' . $cr_block . '</td></tr></table>' . "\n"; } }
function plugin_xoopsblock_convert() { if (!defined('XOOPS_ROOT_PATH')) { //XOOPS環境下で無い場合用 return ''; } $old_errrpt = error_reporting(0); list($tgt, $option1, $option2) = func_get_args(); unset($tgt_bid); if (preg_match("/^\\d+\$/", $tgt)) { $tgt_bid = $tgt; } $align = "left"; $around = false; $width = ""; if (preg_match("/^(left|center|right)\$/i", $option2, $arg)) { $align = $arg[1]; } if (preg_match("/^(left|center|right)\$/i", $option1, $arg)) { $align = $arg[1]; } if (preg_match("/^(around|float)(:?w?([\\d]+%?))?\$/i", $option2, $arg)) { if ($arg[1]) { $around = true; } $width = !strstr($arg[3], "%") ? $arg[3] . "px" : $arg[3]; $width = ",width:" . $arg[3] . ";"; } if (preg_match("/^(around|float)(:?w?([\\d]+%?))?\$/i", $option1, $arg)) { if ($arg[1]) { $around = true; } $width = !strstr($arg[3], "%") ? $arg[3] . "px" : $arg[3]; $width = " width:" . $width . ";"; } $style = " style='float:{$align};{$width}'"; $clear = $around ? "" : "<div style='clear:both;'></div>"; global $xoopsUser; $xoopsblock = new XoopsBlock(); $xoopsgroup = new XoopsGroup(); $arr = array(); $side = null; if ($xoopsUser) { //$arr = $xoopsblock->getAllBlocksByGroup($xoopsUser->groups(), true, $side, XOOPS_BLOCK_VISIBLE); $arr = $xoopsblock->getAllBlocksByGroup($xoopsUser->groups()); } else { if (method_exists($xoopsgroup, "getByType")) { //XOOPS 1.3 //$arr = $xoopsblock->getAllBlocksByGroup($xoopsgroup->getByType("Anonymous"), true, $side, XOOPS_BLOCK_VISIBLE); $arr = $xoopsblock->getAllBlocksByGroup($xoopsgroup->getByType("Anonymous")); } else { //XOOPS 2 //$arr = $xoopsblock->getAllBlocksByGroup(plugin_xoopsblock_getByType("Anonymous"), true, $side, XOOPS_BLOCK_VISIBLE); $arr = $xoopsblock->getAllBlocksByGroup(plugin_xoopsblock_getByType("Anonymous")); } } $ret = ""; if (file_exists(XOOPS_ROOT_PATH . '/class/template.php')) { // XOOPS 2 系用 require_once XOOPS_ROOT_PATH . '/class/template.php'; $xoopsTpl = new XoopsTpl(); } foreach ($arr as $myblock) { $block = array(); $block_type = $myblock->getVar("type") ? $myblock->getVar("type") : $myblock->getVar("block_type"); //$name = ($myblock->getVar("type") != "C") ? $myblock->getVar("name") : $myblock->getVar("title"); $name = $block_type != "C" ? $myblock->getVar("name") : $myblock->getVar("title"); $bid = $myblock->getVar('bid'); if ($tgt == "?") { $ret .= "<li>(" . $bid . ")" . $name . "</li>"; } else { if ($tgt_bid === $bid || $tgt == $name) { $block = $myblock->buildBlock(); if (!is_object($xoopsTpl)) { // XOOPS 1 系用 $ret = $block['content']; } else { // XOOPS 2 系用 $bcachetime = $myblock->getVar('bcachetime'); if (empty($bcachetime)) { $xoopsTpl->xoops_setCaching(0); } else { $xoopsTpl->xoops_setCaching(2); $xoopsTpl->xoops_setCacheTime($bcachetime); } $btpl = $myblock->getVar('template'); if ($btpl != '') { if (empty($bcachetime) || !$xoopsTpl->is_cached('db:' . $btpl)) { if (!$block) { $ret = ""; } $xoopsTpl->assign_by_ref('block', $block); $bcontent =& $xoopsTpl->fetch('db:' . $btpl); $xoopsTpl->clear_assign('block'); } else { $bcontent =& $xoopsTpl->fetch('db:' . $btpl); } } else { if (empty($bcachetime) || !$xoopsTpl->is_cached('db:system_dummy.html', 'blk_' . $bid)) { if (!$block) { $ret = ""; } $xoopsTpl->assign_by_ref('dummy_content', $block['content']); $bcontent =& $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); $xoopsTpl->clear_assign('block'); } else { $bcontent =& $xoopsTpl->fetch('db:system_dummy.html', 'blk_' . $bid); } } $ret = $bcontent; } unset($myblock); unset($block); break; } } unset($myblock); unset($block); } if ($tgt == "?") { $ret = "<ul>{$ret}</ul>"; } unset($xoopsblock, $xoopsgroup); error_reporting($old_errrpt); return "<div{$style}>{$ret}</div>{$clear}"; }