コード例 #1
0
 /**
  * get block.
  * 
  * @param Legacy_AbstractBlockProcedure &$obj
  * @param XoopsBlock                    $block
  */
 public static function getBlock(&$obj, $block)
 {
     $moduleHandler =& xoops_gethandler('module');
     $module =& $moduleHandler->get($block->get('mid'));
     if (is_object($module) && $module->getInfo('trust_dirname') == COSMOAPI_TRUST_DIRNAME) {
         require_once XOOPS_TRUST_PATH . '/modules/' . COSMOAPI_TRUST_DIRNAME . '/blocks/' . $block->get('func_file');
         $className = ucfirst(COSMOAPI_TRUST_DIRNAME) . '_' . substr($block->get('show_func'), 4);
         $obj = new $className($block);
     }
 }
コード例 #2
0
ファイル: blockHandlerTest.php プロジェクト: RanLee/XoopsCore
 public function test_insertBlock()
 {
     $block = new XoopsBlock();
     $block->setNew();
     $instance = new XoopsBlockHandler($this->conn);
     $value = $instance->insertBlock($block);
     $bid = $block->bid();
     $this->assertEquals($bid, $value);
     $value = $instance->get($bid);
     $this->assertEquals($bid, $value->bid());
     $value = $instance->deleteBlock($block);
     $this->assertSame(true, $value);
     $value = $instance->get($bid);
     $this->assertSame(null, $value);
 }
コード例 #3
0
function xoops_module_install_sysutil(&$module)
{
    $gperm_handler =& xoops_gethandler('groupperm');
    $mperm =& $gperm_handler->create();
    $mperm->setVar('gperm_groupid', XOOPS_GROUP_ANONYMOUS);
    $mperm->setVar('gperm_itemid', $module->getVar('mid'));
    $mperm->setVar('gperm_name', 'module_read');
    $mperm->setVar('gperm_modid', 1);
    $gperm_handler->insert($mperm);
    unset($mperm);
    $blocks =& XoopsBlock::getByModule($module->getVar('mid'), false);
    foreach ($blocks as $blc) {
        $bperm =& $gperm_handler->create();
        $bperm->setVar('gperm_groupid', XOOPS_GROUP_ANONYMOUS);
        $bperm->setVar('gperm_itemid', $blc);
        $bperm->setVar('gperm_name', 'block_read');
        $bperm->setVar('gperm_modid', 1);
        $gperm_handler->insert($bperm);
        unset($bperm);
    }
    unset($blocks);
    $module_handler =& xoops_gethandler('module');
    $module->setVar('weight', 0);
    $module->unsetNew();
    $module_handler->insert($module);
    return true;
}
コード例 #4
0
function update_block_permissions($old_gid, $new_gid)
{
    // get handlers
    $gperm_handler =& xoops_gethandler('groupperm');
    $module_handler =& xoops_gethandler('module');
    $module =& $module_handler->getByDirname('xoonips');
    $mid = $module->getVar('mid');
    $block_objs =& XoopsBlock::getByModule($mid);
    foreach ($block_objs as $block_obj) {
        // find moderator menu block
        if ($block_obj->getVar('show_func') == 'b_xoonips_moderator_show') {
            $bid = $block_obj->getVar('bid');
            // if old_gid don't have module admin right,
            // delete the right to access from old_gid.
            if (!$gperm_handler->checkRight('module_admin', $mid, $old_gid)) {
                $criteria = new CriteriaCompo();
                $criteria->add(new Criteria('gperm_groupid', $old_gid));
                $criteria->add(new Criteria('gperm_itemid', $bid));
                $criteria->add(new Criteria('gperm_name', 'block_read'));
                $gperm_handler->deleteAll($criteria);
            }
            // if there is no right to access moderator block in new_gid,
            // the right gives new_gid.
            if (!$gperm_handler->checkRight('block_read', $bid, $new_gid)) {
                $gperm_handler->addRight('block_read', $bid, $new_gid);
            }
            break;
        }
    }
}
コード例 #5
0
ファイル: theme_blocks.php プロジェクト: yunsite/xoopsdc
 function retrieveBlocks()
 {
     global $xoopsUser, $xoopsModule, $xoopsConfig;
     $startMod = $xoopsConfig['startpage'] == '--' ? 'system' : $xoopsConfig['startpage'];
     if (@is_object($xoopsModule)) {
         list($mid, $dirname) = array($xoopsModule->getVar('mid'), $xoopsModule->getVar('dirname'));
         $isStart = substr($_SERVER['PHP_SELF'], -9) == 'index.php' && $xoopsConfig['startpage'] == $dirname;
     } else {
         list($mid, $dirname) = array(0, 'system');
         $isStart = !@empty($GLOBALS['xoopsOption']['show_cblock']);
     }
     $groups = @is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
     $oldzones = array(XOOPS_SIDEBLOCK_LEFT => 'canvas_left', XOOPS_SIDEBLOCK_RIGHT => 'canvas_right', XOOPS_CENTERBLOCK_LEFT => 'page_topleft', XOOPS_CENTERBLOCK_CENTER => 'page_topcenter', XOOPS_CENTERBLOCK_RIGHT => 'page_topright', XOOPS_CENTERBLOCK_BOTTOMLEFT => 'page_bottomleft', XOOPS_CENTERBLOCK_BOTTOM => 'page_bottomcenter', XOOPS_CENTERBLOCK_BOTTOMRIGHT => 'page_bottomright');
     foreach ($oldzones as $zone) {
         $this->blocks[$zone] = array();
     }
     if ($this->theme) {
         $template =& $this->theme->template;
         $backup = array($template->caching, $template->cache_lifetime);
     } else {
         $template =& new XoopsTpl();
     }
     $xoopsblock = new XoopsBlock();
     $block_arr = array();
     $block_arr = $xoopsblock->getAllByGroupModule($groups, $mid, $isStart, XOOPS_BLOCK_VISIBLE);
     $template->assign('ezblocks', $block_arr);
     //ezsky hack
     foreach ($block_arr as $block) {
         // ezsky hack start
         if ($block->getVar('side') == XOOPS_BLOCK_CALLBACK) {
             continue;
         }
         // ezsky hack end
         $side = $oldzones[$block->getVar('side')];
         if ($var = $this->buildBlock($block, $template)) {
             $this->blocks[$side][$var["id"]] = $var;
         }
     }
     if ($this->theme) {
         list($template->caching, $template->cache_lifetime) = $backup;
     }
 }
コード例 #6
0
 function retrieveBlocks()
 {
     global $xoopsUser, $xoopsModule, $xoopsConfig;
     if (@is_object($xoopsModule)) {
         list($mid, $dirname) = array($xoopsModule->getVar('mid'), $xoopsModule->getVar('dirname'));
     } else {
         list($mid, $dirname) = array(0, 'system');
     }
     $startMod = $xoopsConfig['startpage'] == '--' ? 'system' : $xoopsConfig['startpage'];
     $isStart = substr($_SERVER['SCRIPT_NAME'], -9) == 'index.php' && $startMod == $dirname;
     $groups = @is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
     $oldzones = array(XOOPS_SIDEBLOCK_LEFT => 'canvas_left', XOOPS_SIDEBLOCK_RIGHT => 'canvas_right', XOOPS_CENTERBLOCK_CENTER => 'page_top', XOOPS_CENTERBLOCK_LEFT => 'page_topleft', XOOPS_CENTERBLOCK_RIGHT => 'page_topright');
     $xoopsblock = new XoopsBlock();
     $block_arr = array();
     $block_arr = $xoopsblock->getAllByGroupModule($groups, $mid, $isStart, XOOPS_BLOCK_VISIBLE);
     foreach ($block_arr as $block) {
         $side = $oldzones[$block->getVar('side')];
         if ($var = $this->buildBlock($block)) {
             $this->blocks[$side][] = $var;
         }
     }
 }
コード例 #7
0
ファイル: admin_func.php プロジェクト: nouphet/rata
function hypconfGetBlocks()
{
    static $ret = null;
    if (!is_null($ret)) {
        return $ret;
    }
    include_once XOOPS_ROOT_PATH . "/class/xoopsblock.php";
    $bobj = new XoopsBlock();
    $blocks = $bobj->getAllBlocks('object', null, true);
    $ret = array();
    if ($blocks) {
        foreach ($blocks as $block) {
            $name = $block->getVar('title') ? $block->getVar('title') : $block->getVar('name');
            $bid = $block->getVar("bid");
            if ($module = hypconfGetModuleName($block->getVar("mid"))) {
                $ret[$module . ':' . $name] = array('confop_value' => $bid, 'confop_name' => $module . ':' . $name);
            }
        }
        ksort($ret);
    }
    return $ret;
}
コード例 #8
0
function get_block_title($mid, $fname, $sfunc)
{
    $block_objs =& XoopsBlock::getByModule($mid);
    $block_title = '';
    foreach ($block_objs as $block_obj) {
        $func_file = $block_obj->getVar('func_file', 'n');
        $show_func = $block_obj->getVar('show_func', 'n');
        if ($func_file == $fname && $show_func == $sfunc) {
            // found
            $block_title = $block_obj->getVar('title', 's');
            break;
        }
    }
    return $block_title;
}
コード例 #9
0
ファイル: main.php プロジェクト: BackupTheBerlios/xoops4-svn
 $myts =& MyTextsanitizer::getInstance();
 $html = $myts->stripSlashesGPC($html);
 $tpltpl_handler =& xoops_gethandler('tplfile');
 $tplfile =& $tpltpl_handler->get($id, true);
 $xoopsTpl = new XoopsTpl();
 if (is_object($tplfile)) {
     $dummylayout = '<html><head><meta http-equiv="content-type" content="text/html; charset=' . _CHARSET . '" /><meta http-equiv="content-language" content="' . _LANGCODE . '" /><title>' . $xoopsConfig['sitename'] . '</title><style type="text/css" media="all">';
     $css =& $tpltpl_handler->find($xoopsConfig['template_set'], 'css', 0, null, null, true);
     $csscount = count($css);
     for ($i = 0; $i < $csscount; $i++) {
         $dummylayout .= "\n" . $css[$i]->getVar('tpl_source');
     }
     $dummylayout .= "\n" . '</style></head><body><{$content}></body></html>';
     if ($tplfile->getVar('tpl_type') == 'block') {
         include_once XOOPS_ROOT_PATH . '/class/xoopsblock.php';
         $block = new XoopsBlock($tplfile->getVar('tpl_refid'));
         $xoopsTpl->assign('block', $block->buildBlock());
     }
     $dummytpl = '_dummytpl_' . time() . '.html';
     $fp = fopen(XOOPS_CACHE_PATH . '/' . $dummytpl, 'w');
     fwrite($fp, $html);
     fclose($fp);
     $xoopsTpl->assign('content', $xoopsTpl->fetch('file:' . XOOPS_CACHE_PATH . '/' . $dummytpl));
     $xoopsTpl->clear_compiled_tpl('file:' . XOOPS_CACHE_PATH . '/' . $dummytpl);
     unlink(XOOPS_CACHE_PATH . '/' . $dummytpl);
     $dummyfile = '_dummy_' . time() . '.html';
     $fp = fopen(XOOPS_CACHE_PATH . '/' . $dummyfile, 'w');
     fwrite($fp, $dummylayout);
     fclose($fp);
     $tplset = $tplfile->getVar('tpl_tplset');
     $tform = array('tpl_tplset' => $tplset, 'tpl_id' => $id, 'tpl_file' => $tplfile->getVar('tpl_file'), 'tpl_desc' => $tplfile->getVar('tpl_desc'), 'tpl_lastmodified' => $tplfile->getVar('tpl_lastmodified'), 'tpl_source' => htmlspecialchars($html, ENT_QUOTES), 'tpl_module' => $moddir);
コード例 #10
0
ファイル: blocksadmin.php プロジェクト: hiro1173/legacy
 function clone_block_ok($bid, $bside, $bweight, $bvisible, $bcachetime, $bmodule, $options)
 {
     global $xoopsUser;
     $block = new XoopsBlock($bid);
     $clone =& $block->xoopsClone();
     if (empty($bmodule)) {
         xoops_cp_header();
         xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
         xoops_cp_footer();
         exit;
     }
     $clone->setVar('side', $bside);
     $clone->setVar('weight', $bweight);
     $clone->setVar('visible', $bvisible);
     $clone->setVar('content', $bcontent);
     //$clone->setVar('title', $btitle);
     $clone->setVar('bcachetime', $bcachetime);
     if (isset($options) && count($options) > 0) {
         $options = implode('|', $options);
         $clone->setVar('options', $options);
     }
     $clone->setVar('bid', 0);
     if ($block->getVar('block_type') == 'C' || $block->getVar('block_type') == 'E') {
         $clone->setVar('block_type', 'E');
     } else {
         $clone->setVar('block_type', 'D');
     }
     $newid = $clone->store();
     if (!$newid) {
         xoops_cp_header();
         $clone->getHtmlErrors();
         xoops_cp_footer();
         exit;
     }
     if ($clone->getVar('template') != '') {
         $tplfile_handler =& xoops_gethandler('tplfile');
         $btemplate =& $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid);
         if (count($btemplate) > 0) {
             $tplclone =& $btemplate[0]->xoopsClone();
             $tplclone->setVar('tpl_id', 0);
             $tplclone->setVar('tpl_refid', $newid);
             $tplman->insert($tplclone);
         }
     }
     $db =& Database::getInstance();
     foreach ($bmodule as $bmid) {
         $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
         $db->query($sql);
     }
     $groups =& $xoopsUser->getGroups();
     $count = count($groups);
     for ($i = 0; $i < $count; $i++) {
         $sql = "INSERT INTO " . $db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES (" . $groups[$i] . ", " . $newid . ", 1, 'block_read')";
         $db->query($sql);
     }
     redirect_header('admin.php?fct=blocksadmin&amp;t=' . time(), 1, _AM_DBUPDATED);
 }
コード例 #11
0
ファイル: index.php プロジェクト: koki-h/xoops_utf8
                         $tplfile->setVar('tpl_lastimported', 0);
                         $tplfile->setVar('tpl_lastmodified', time());
                         $tplfile->setVar('tpl_desc', $blocks[$i]['description'], true);
                         if (!$tplfile_handler->insert($tplfile)) {
                             $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not insert template <b>' . $blocks[$i]['template'] . '</b> to the database.</span>';
                         } else {
                             $msgs[] = '&nbsp;&nbsp;Template <b>' . $blocks[$i]['template'] . '</b> inserted to the database.';
                         }
                     }
                     $msgs[] = '&nbsp;&nbsp;Block <b>' . $blocks[$i]['name'] . '</b> created. Block ID: <b>' . $newbid . '</b>';
                 }
             }
         }
     }
 }
 $block_arr = XoopsBlock::getByModule($mid);
 foreach ($block_arr as $block) {
     if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) {
         $sql = sprintf("DELETE FROM %s WHERE bid = %u", $xoopsDB->prefix('newblocks'), $block->getVar('bid'));
         if (!$xoopsDB->query($sql)) {
             $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">ERROR: Could not delete block <b>' . $block->getVar('name') . '</b>. Block ID: <b>' . $block->getVar('bid') . '</b></span>';
         } else {
             $msgs[] = '&nbsp;&nbsp;Block <b>' . $block->getVar('name') . ' deleted. Block ID: <b>' . $block->getVar('bid') . '</b>';
         }
     }
 }
 $configs = $modules[$mid]->getInfo('config');
 if ($configs != false) {
     if ($modules[$mid]->getVar('hascomments') != 0) {
         include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
         array_push($configs, array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)));
コード例 #12
0
function clone_block_ok($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bcachetime, $bmodule, $options = array(), $bgroups = array())
{
    global $xoopsUser;
    /*
    if (empty($bmodule)) {
        xoops_cp_header();
        xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
        xoops_cp_footer();
        exit();
    }
    */
    $block = new XoopsBlock($bid);
    $clone =& $block->xoopsClone();
    $clone->setVar('side', $bside);
    $clone->setVar('weight', $bweight);
    $clone->setVar('visible', $bvisible);
    $clone->setVar('content', $bcontent);
    $clone->setVar('title', $btitle);
    $clone->setVar('bcachetime', $bcachetime);
    if (isset($options) && count($options) > 0) {
        $options = implode('|', $options);
        $clone->setVar('options', $options);
    }
    $clone->setVar('bid', 0);
    // Custom block
    if ($block->isCustom()) {
        $clone->setVar('block_type', 'C');
        // Clone of system or module block
    } else {
        $clone->setVar('block_type', 'D');
    }
    $newid = $clone->store();
    if (!$newid) {
        xoops_cp_header();
        $clone->getHtmlErrors();
        xoops_cp_footer();
        exit;
    }
    if ($clone->getVar('template') != '') {
        $tplfile_handler =& xoops_gethandler('tplfile');
        $btemplate = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', $bid);
        if (count($btemplate) > 0) {
            $tplclone =& $btemplate[0]->xoopsClone();
            $tplclone->setVar('tpl_id', 0);
            $tplclone->setVar('tpl_refid', $newid);
            $tplfile_handler->insert($tplclone);
        }
    }
    $db =& Database::getInstance();
    foreach (@$bmodule as $bmid) {
        $sql = 'INSERT INTO ' . $db->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newid . ', ' . $bmid . ')';
        $db->query($sql);
    }
    $groupperm_handler =& xoops_gethandler('groupperm');
    foreach ($bgroups as $groupid) {
        $groupperm_handler->addRight("block_read", $newid, $groupid);
    }
    redirect_header('admin.php?fct=blocksadmin&amp;t=' . time(), 1, _AM_DBUPDATED);
}
コード例 #13
0
ファイル: template.php プロジェクト: nouphet/rata
/**
 * Clear the module cache
 * 
 * @deprecated
 *
 * @param   int $mid    Module ID
 * @return 
 **/
function xoops_template_clear_module_cache($mid)
{
    $block_arr =& XoopsBlock::getByModule($mid);
    $count = count($block_arr);
    if ($count > 0) {
        $xoopsTpl = new XoopsTpl();
        $xoopsTpl->xoops_setCaching(2);
        for ($i = 0; $i < $count; $i++) {
            if ($block_arr[$i]->getVar('template') != '') {
                $xoopsTpl->clear_cache('db:' . $block_arr[$i]->getVar('template'), 'blk_' . $block_arr[$i]->getVar('bid'));
            }
        }
    }
}
コード例 #14
0
 $config =& $config_handler->getConfigs($criteria, true);
 foreach (array_keys($config) as $i) {
     // prefix each tag with 'xoops_'
     $xoopsTpl->assign('xoops_' . $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
 }
 //unset($config);
 // show banner?
 if ($xoopsConfig['banners'] == 1) {
     $xoopsTpl->assign('xoops_banner', xoops_getbanner());
 } else {
     $xoopsTpl->assign('xoops_banner', '&nbsp;');
 }
 // Weird, but need extra <script> tags for 2.0.x themes
 $xoopsTpl->assign('xoops_js', '//--></script><script type="text/javascript" src="' . XOOPS_URL . '/include/xoops.js"></script><script type="text/javascript"><!--');
 // get all blocks and assign to smarty
 $xoopsblock = new XoopsBlock();
 $block_arr = array();
 if ($xoopsUser != '') {
     $xoopsTpl->assign(array('xoops_isuser' => true, 'xoops_userid' => $xoopsUser->getVar('uid'), 'xoops_uname' => $xoopsUser->getVar('uname'), 'xoops_isadmin' => $xoopsUserIsAdmin));
     $groups = $xoopsUser->getGroups();
 } else {
     $xoopsTpl->assign(array('xoops_isuser' => false, 'xoops_isadmin' => false));
     $groups = XOOPS_GROUP_ANONYMOUS;
 }
 $toppage = false;
 if (isset($xoopsModule) && is_object($xoopsModule)) {
     // set page title
     $xoopsTpl->assign('xoops_pagetitle', $xoopsModule->getVar('name'));
     $xoopsTpl->assign('xoops_dirname', $xoopsModule->getVar('dirname'));
     $moduleid = $xoopsModule->getVar('mid');
     if (preg_match("/index\\.php\$/i", xoops_getenv('PHP_SELF')) && $xoopsConfig['startpage'] == $xoopsModule->getVar('dirname')) {
コード例 #15
0
ファイル: theme_blocks.php プロジェクト: redmexico/XoopsCore
 /**
  * XoopsThemeBlocksPlugin::buildBlock()
  *
  * @param XoopsBlock $xobject
  * @param XoopsTpl $template
  * @return array|bool
  */
 public function buildBlock($xobject, &$template)
 {
     $xoops = Xoops::getInstance();
     // The lame type workaround will change
     // bid is added temporarily as workaround for specific block manipulation
     $dirname = $xobject->getVar('dirname');
     $block = array('id' => $xobject->getVar('bid'), 'module' => $dirname, 'title' => $xobject->getVar('title'), 'weight' => $xobject->getVar('weight'), 'lastmod' => $xobject->getVar('last_modified'));
     $bcachetime = (int) $xobject->getVar('bcachetime');
     if (empty($bcachetime)) {
         $template->caching = 0;
     } else {
         $template->caching = 2;
         $template->cache_lifetime = $bcachetime;
     }
     $template->setCompileId($dirname);
     $tplName = ($tplName = $xobject->getVar('template')) ? "block:{$dirname}/{$tplName}" : "module:system/system_block_dummy.tpl";
     //$tplName = str_replace('.html', '.tpl', $tplName);
     $cacheid = $this->generateCacheId('blk_' . $xobject->getVar('bid'));
     $xoops->preload()->triggerEvent('core.themeblocks.buildblock.start', array($xobject, $template->isCached($tplName, $cacheid)));
     if (!$bcachetime || !$template->isCached($tplName, $cacheid)) {
         //Get theme metas
         $old = array();
         if ($this->theme && $bcachetime) {
             foreach ($this->theme->metas as $type => $value) {
                 $old[$type] = $this->theme->metas[$type];
             }
         }
         //build block
         if ($bresult = $xobject->buildBlock()) {
             $template->assign('block', $bresult);
             $block['content'] = $template->fetch($tplName, $cacheid);
         } else {
             $block = false;
         }
         //check if theme added new metas
         if ($this->theme && $bcachetime) {
             $metas = array();
             foreach ($this->theme->metas as $type => $value) {
                 $dif = Xoops_Utils::arrayRecursiveDiff($this->theme->metas[$type], $old[$type]);
                 if (count($dif)) {
                     $metas[$type] = $dif;
                 }
             }
             if (count($metas)) {
                 Xoops_Cache::write($cacheid, $metas);
             }
         }
     } else {
         $block['content'] = $template->fetch($tplName, $cacheid);
     }
     //add block cached metas
     if ($this->theme && $bcachetime) {
         if ($metas = Xoops_Cache::read($cacheid)) {
             foreach ($metas as $type => $value) {
                 $this->theme->metas[$type] = array_merge($this->theme->metas[$type], $metas[$type]);
             }
         }
     }
     $template->setCompileId();
     return $block;
 }
コード例 #16
0
 function previewContent($block_data)
 {
     $bid = intval($block_data['bid']);
     if (!$block_data['is_custom']) {
         return '';
     }
     if (empty($this->preview_request)) {
         return '';
     }
     //HACK by domifara
     //TODO : need no hook block at this
     $block = new XoopsBlock($bid);
     if ($block->getVar('mid')) {
         return '';
     }
     $block->setVar('title', $block_data['title']);
     $block->setVar('content', $block_data['content']);
     restore_error_handler();
     $original_level = error_reporting(E_ALL);
     //	$ret = $block->getContent( 'S' , $block_data['ctype'] ) ;
     $c_type = $block_data['ctype'];
     if ($c_type == 'H') {
         $ret = str_replace('{X_SITEURL}', XOOPS_URL . '/', $block->getVar('content', 'N'));
     } else {
         if ($c_type == 'P') {
             ob_start();
             echo eval($block->getVar('content', 'N'));
             $content = ob_get_contents();
             ob_end_clean();
             $ret = str_replace('{X_SITEURL}', XOOPS_URL . '/', $content);
         } else {
             if ($c_type == 'S') {
                 $myts =& MyTextSanitizer::getInstance();
                 $content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $block->getVar('content', 'N'));
                 $ret = $myts->displayTarea($content, 1, 1);
             } else {
                 $myts =& MyTextSanitizer::getInstance();
                 $content = str_replace('{X_SITEURL}', XOOPS_URL . '/', $block->getVar('content', 'N'));
                 $ret = $myts->displayTarea($content, 1, 0);
             }
         }
     }
     error_reporting($original_level);
     return $ret;
 }
コード例 #17
0
ファイル: xoopsblock.inc.php プロジェクト: nouphet/rata
 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}";
 }
コード例 #18
0
ファイル: old_functions.php プロジェクト: yunsite/xoopsdc
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";
    }
}
コード例 #19
0
ファイル: check_blocks_class.php プロジェクト: nouphet/rata
 function &_get_block_object_bymodule_id($mid, $asobject = true)
 {
     if (defined('ICMS_VERSION_BUILD') && ICMS_VERSION_BUILD > 27) {
         /* ImpressCMS 1.2+ */
         $block_handler =& xoops_gethandler('block');
         $objs =& $block_handler->getByModule($mid, $asobject);
     } else {
         /* legacy support */
         $objs =& XoopsBlock::getByModule($mid, $asobject);
         /* from class/xoopsblock.php */
     }
     return $objs;
 }
コード例 #20
0
 /**
  * xos_logos_PageBuilder::retrieveBlocks()
  *
  * @return
  */
 function retrieveBlocks()
 {
     global $xoopsConfig;
     $xoopsPreload =& XoopsPreload::getInstance();
     $startMod = $xoopsConfig['startpage'] == '--' ? 'system' : $xoopsConfig['startpage'];
     if (isset($GLOBALS['xoopsModule']) && is_object($GLOBALS['xoopsModule'])) {
         list($mid, $dirname) = array($GLOBALS['xoopsModule']->getVar('mid'), $GLOBALS['xoopsModule']->getVar('dirname'));
         $isStart = substr($_SERVER['PHP_SELF'], -9) == 'index.php' && $xoopsConfig['startpage'] == $dirname && empty($_SERVER['QUERY_STRING']);
     } else {
         list($mid, $dirname) = array(0, 'system');
         $isStart = !empty($GLOBALS['xoopsOption']['show_cblock']);
     }
     $groups = isset($GLOBALS['xoopsUser']) && is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
     $oldzones = array(XOOPS_SIDEBLOCK_LEFT => 'canvas_left', XOOPS_SIDEBLOCK_RIGHT => 'canvas_right', XOOPS_CENTERBLOCK_LEFT => 'page_topleft', XOOPS_CENTERBLOCK_CENTER => 'page_topcenter', XOOPS_CENTERBLOCK_RIGHT => 'page_topright', XOOPS_CENTERBLOCK_BOTTOMLEFT => 'page_bottomleft', XOOPS_CENTERBLOCK_BOTTOM => 'page_bottomcenter', XOOPS_CENTERBLOCK_BOTTOMRIGHT => 'page_bottomright');
     foreach ($oldzones as $zone) {
         $this->blocks[$zone] = array();
     }
     if ($this->theme) {
         $template =& $this->theme->template;
         $backup = array($template->caching, $template->cache_lifetime);
     } else {
         $template = null;
         $template = new XoopsTpl();
     }
     $xoopsblock = new XoopsBlock();
     $block_arr = array();
     $block_arr = $xoopsblock->getAllByGroupModule($groups, $mid, $isStart, XOOPS_BLOCK_VISIBLE);
     $xoopsPreload->triggerEvent('core.class.theme_blocks.retrieveBlocks', array(&$this, &$template, &$block_arr));
     foreach ($block_arr as $block) {
         $side = $oldzones[$block->getVar('side')];
         if ($var = $this->buildBlock($block, $template)) {
             $this->blocks[$side][$var["id"]] = $var;
         }
     }
     if ($this->theme) {
         list($template->caching, $template->cache_lifetime) = $backup;
     }
 }
コード例 #21
0
 /**
  * getBlock
  * 
  * @param   Legacy_AbstractBlockProcedure  &$obj
  * @param   XoopsBlock  $block
  * 
  * @return  void
  **/
 public static function getBlock(&$obj, $block)
 {
     $moduleHandler =& Xcforum_Utils::getXoopsHandler('module');
     $module =& $moduleHandler->get($block->get('mid'));
     if (is_object($module) && $module->getInfo('trust_dirname') == 'xcforum') {
         require_once XCFORUM_TRUST_PATH . '/blocks/' . $block->get('func_file');
         $className = 'Xcforum_' . substr($block->get('show_func'), 4);
         $obj = new $className($block);
     }
 }
コード例 #22
0
ファイル: modules.php プロジェクト: laiello/bitcero-modules
function xoops_module_update($dirname)
{
    global $xoopsConfig, $xoopsDB;
    $dirname = trim($dirname);
    $module_handler =& xoops_gethandler('module');
    $module =& $module_handler->getByDirname($dirname);
    // Save current version for use in the update function
    $prev_version = $module->getVar('version');
    include_once XOOPS_ROOT_PATH . '/class/template.php';
    $xoopsTpl = new XoopsTpl();
    $xoopsTpl->clearCache($dirname);
    //xoops_template_clear_module_cache($module->getVar('mid'));
    // we dont want to change the module name set by admin
    $temp_name = $module->getVar('name');
    $module->loadInfoAsVar($dirname);
    $module->setVar('name', $temp_name);
    $log = '';
    if (!$module_handler->insert($module)) {
        $log .= sprintf(__('Could not update %s', 'rmcommon'), $module->getVar('name'));
    } else {
        $newmid = $module->getVar('mid');
        $msgs = array();
        $msgs[] = sprintf(__('Updating module %s', 'rmcommon'), $module->getVar('name'));
        $tplfile_handler =& xoops_gethandler('tplfile');
        $deltpl = $tplfile_handler->find('default', 'module', $module->getVar('mid'));
        $delng = array();
        if (is_array($deltpl)) {
            // delete template file entry in db
            $dcount = count($deltpl);
            for ($i = 0; $i < $dcount; $i++) {
                if (!$tplfile_handler->delete($deltpl[$i])) {
                    $delng[] = $deltpl[$i]->getVar('tpl_file');
                }
            }
        }
        $templates = $module->getInfo('templates');
        if ($templates != false) {
            $msgs[] = __('Updating templates...', 'rmcommon');
            foreach ($templates as $tpl) {
                $tpl['file'] = trim($tpl['file']);
                if (!in_array($tpl['file'], $delng)) {
                    $tpldata =& xoops_module_gettemplate($dirname, $tpl['file']);
                    $tplfile =& $tplfile_handler->create();
                    $tplfile->setVar('tpl_refid', $newmid);
                    $tplfile->setVar('tpl_lastimported', 0);
                    $tplfile->setVar('tpl_lastmodified', time());
                    if (preg_match("/\\.css\$/i", $tpl['file'])) {
                        $tplfile->setVar('tpl_type', 'css');
                    } else {
                        $tplfile->setVar('tpl_type', 'module');
                    }
                    $tplfile->setVar('tpl_source', $tpldata, true);
                    $tplfile->setVar('tpl_module', $dirname);
                    $tplfile->setVar('tpl_tplset', 'default');
                    $tplfile->setVar('tpl_file', $tpl['file'], true);
                    $tplfile->setVar('tpl_desc', $tpl['description'], true);
                    if (!$tplfile_handler->insert($tplfile)) {
                        $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(__('Template %s could not be inserted!', 'rmcommon'), "<strong>" . $tpl['file'] . "</strong>") . '</span>';
                    } else {
                        $newid = $tplfile->getVar('tpl_id');
                        $msgs[] = '&nbsp;&nbsp;' . sprintf(__('Template %s inserted to the database.', 'rmcommon'), "<strong>" . $tpl['file'] . "</strong>");
                        if ($xoopsConfig['template_set'] == 'default') {
                            if (!xoops_template_touch($newid)) {
                                $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(__('ERROR: Could not recompile template %s', 'rmcommon'), "<strong>" . $tpl['file'] . "</strong>") . '</span>';
                            } else {
                                $msgs[] = '&nbsp;&nbsp;<span>' . sprintf(__('Template %s recompiled', 'rmcommon'), "<strong>" . $tpl['file'] . "</strong>") . '</span>';
                            }
                        }
                    }
                    unset($tpldata);
                } else {
                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(__('ERROR: Could not delete old template %s. Aborting update of this file.', 'rmcommon'), "<strong>" . $tpl['file'] . "</strong>") . '</span>';
                }
            }
        }
        $blocks = $module->getInfo('blocks');
        $msgs[] = __('Rebuilding blocks...', 'rmcommon');
        if ($blocks != false) {
            $showfuncs = array();
            $funcfiles = array();
            foreach ($blocks as $i => $block) {
                if (isset($block['show_func']) && $block['show_func'] != '' && isset($block['file']) && $block['file'] != '') {
                    $editfunc = isset($block['edit_func']) ? $block['edit_func'] : '';
                    $showfuncs[] = $block['show_func'];
                    $funcfiles[] = $block['file'];
                    $template = '';
                    if (isset($block['template']) && trim($block['template']) != '') {
                        $content = xoops_module_gettemplate($dirname, $block['template'], 'blocks');
                    }
                    if (!$content) {
                        $content = '';
                    } else {
                        $template = $block['template'];
                    }
                    $options = '';
                    if (!empty($block['options'])) {
                        $options = $block['options'];
                    }
                    $sql = "SELECT bid, name FROM " . $xoopsDB->prefix('newblocks') . " WHERE mid=" . $module->getVar('mid') . " AND func_num=" . $i . " AND show_func='" . addslashes($block['show_func']) . "' AND func_file='" . addslashes($block['file']) . "'";
                    $fresult = $xoopsDB->query($sql);
                    $fcount = 0;
                    while ($fblock = $xoopsDB->fetchArray($fresult)) {
                        $fcount++;
                        $sql = "UPDATE " . $xoopsDB->prefix("newblocks") . " SET name='" . addslashes($block['name']) . "', edit_func='" . addslashes($editfunc) . "', content='', template='" . $template . "', last_modified=" . time() . " WHERE bid=" . $fblock['bid'];
                        $result = $xoopsDB->query($sql);
                        if (!$result) {
                            $msgs[] = "&nbsp;&nbsp;" . sprintf(__('ERROR: Could not update %s'), $fblock['name']);
                        } else {
                            $msgs[] = "&nbsp;&nbsp;" . sprintf(__('Block %s updated.', 'rmcommon'), $fblock['name']) . sprintf(__('Block ID: %s', 'rmcommon'), "<strong>" . $fblock['bid'] . "</strong>");
                            if ($template != '') {
                                $tplfile = $tplfile_handler->find('default', 'block', $fblock['bid']);
                                if (count($tplfile) == 0) {
                                    $tplfile_new =& $tplfile_handler->create();
                                    $tplfile_new->setVar('tpl_module', $dirname);
                                    $tplfile_new->setVar('tpl_refid', $fblock['bid']);
                                    $tplfile_new->setVar('tpl_tplset', 'default');
                                    $tplfile_new->setVar('tpl_file', $block['template'], true);
                                    $tplfile_new->setVar('tpl_type', 'block');
                                } else {
                                    $tplfile_new = $tplfile[0];
                                }
                                $tplfile_new->setVar('tpl_source', $content, true);
                                $tplfile_new->setVar('tpl_desc', $block['description'], true);
                                $tplfile_new->setVar('tpl_lastmodified', time());
                                $tplfile_new->setVar('tpl_lastimported', 0);
                                if (!$tplfile_handler->insert($tplfile_new)) {
                                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(__('ERROR: Could not update %s template.', 'rmcommon'), "<strong>" . $block['template'] . "</strong>") . '</span>';
                                } else {
                                    $msgs[] = "&nbsp;&nbsp;" . sprintf(__('Template %s updated.', 'rmcommon'), "<strong>" . $block['template'] . "</strong>");
                                    if ($xoopsConfig['template_set'] == 'default') {
                                        if (!xoops_template_touch($tplfile_new->getVar('tpl_id'))) {
                                            $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(__('ERROR: Could not recompile template %s', 'rmcommon'), "<strong>" . $block['template'] . "</strong>") . '</span>';
                                        } else {
                                            $msgs[] = "&nbsp;&nbsp;" . sprintf(__('Template %s recompiled', 'rmcommon'), "<strong>" . $block['template'] . "</strong>");
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if ($fcount == 0) {
                        $newbid = $xoopsDB->genId($xoopsDB->prefix('newblocks') . '_bid_seq');
                        $block_name = addslashes($block['name']);
                        $block_type = $module->getVar('dirname') == 'system' ? 'S' : 'M';
                        $sql = "INSERT INTO " . $xoopsDB->prefix("newblocks") . " (bid, mid, func_num, options, name, title, content, side, weight, visible, block_type, isactive, dirname, func_file, show_func, edit_func, template, last_modified) VALUES (" . $newbid . ", " . $module->getVar('mid') . ", " . $i . ",'" . addslashes($options) . "','" . $block_name . "', '" . $block_name . "', '', 0, 0, 0, '{$block_type}', 1, '" . addslashes($dirname) . "', '" . addslashes($block['file']) . "', '" . addslashes($block['show_func']) . "', '" . addslashes($editfunc) . "', '" . $template . "', " . time() . ")";
                        $result = $xoopsDB->query($sql);
                        if (!$result) {
                            $msgs[] = '&nbsp;&nbsp;' . sprintf(_('ERROR: Could not create %s', 'rmcommon'), $block['name']);
                            $log .= $sql;
                        } else {
                            if (empty($newbid)) {
                                $newbid = $xoopsDB->getInsertId();
                            }
                            if ($module->getInfo('hasMain')) {
                                $groups = array(XOOPS_GROUP_ADMIN, XOOPS_GROUP_USERS, XOOPS_GROUP_ANONYMOUS);
                            } else {
                                $groups = array(XOOPS_GROUP_ADMIN);
                            }
                            $gperm_handler =& xoops_gethandler('groupperm');
                            foreach ($groups as $mygroup) {
                                $bperm =& $gperm_handler->create();
                                $bperm->setVar('gperm_groupid', $mygroup);
                                $bperm->setVar('gperm_itemid', $newbid);
                                $bperm->setVar('gperm_name', 'block_read');
                                $bperm->setVar('gperm_modid', 1);
                                if (!$gperm_handler->insert($bperm)) {
                                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . __('ERROR: Could not add block access right', 'rmcommon') . ' ' . sprintf(__("Block ID: %s", 'rmcommon'), "<strong>" . $newbid . "</strong>") . ' ' . sprintf(__('Group ID: %s', 'rmcommon'), "<strong>" . $mygroup . "</strong>") . '</span>';
                                } else {
                                    $msgs[] = '&nbsp;&nbsp;' . __('Added block access right', 'rmcommon') . ' ' . sprintf(__("Block ID: %s", 'rmcommon'), "<strong>" . $newbid . "</strong>") . ' ' . sprintf(__('Group ID: %s', 'rmcommon'), "<strong>" . $mygroup . "</strong>");
                                }
                            }
                            if ($template != '') {
                                $tplfile =& $tplfile_handler->create();
                                $tplfile->setVar('tpl_module', $dirname);
                                $tplfile->setVar('tpl_refid', $newbid);
                                $tplfile->setVar('tpl_source', $content, true);
                                $tplfile->setVar('tpl_tplset', 'default');
                                $tplfile->setVar('tpl_file', $block['template'], true);
                                $tplfile->setVar('tpl_type', 'block');
                                $tplfile->setVar('tpl_lastimported', 0);
                                $tplfile->setVar('tpl_lastmodified', time());
                                $tplfile->setVar('tpl_desc', $block['description'], true);
                                if (!$tplfile_handler->insert($tplfile)) {
                                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(__('ERROR: Could not insert template %s to the database.', 'rmcommon'), "<strong>" . $block['template'] . "</strong>") . '</span>';
                                } else {
                                    $newid = $tplfile->getVar('tpl_id');
                                    $msgs[] = '&nbsp;&nbsp;' . sprintf(__('Template %s added to the database', 'rmcommon'), "<strong>" . $block['template'] . "</strong>");
                                    if ($xoopsConfig['template_set'] == 'default') {
                                        if (!xoops_template_touch($newid)) {
                                            $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(__('ERROR: Template %s recompile failed', 'rmcommon'), "<strong>" . $block['template'] . "</strong>") . '</span>';
                                        } else {
                                            $msgs[] = '&nbsp;&nbsp;' . sprintf(__('Template %s recompiled', 'rmcommon'), "<strong>" . $block['template'] . "</strong>");
                                        }
                                    }
                                }
                            }
                            $msgs[] = '&nbsp;&nbsp;' . sprintf(__('Block %s created', 'rmcommon'), "<strong>" . $block['name'] . "</strong>") . sprintf(__("Block ID: %s", 'rmcommon'), "<strong>" . $newbid . "</strong>");
                            $sql = 'INSERT INTO ' . $xoopsDB->prefix('block_module_link') . ' (block_id, module_id) VALUES (' . $newbid . ', -1)';
                            $xoopsDB->query($sql);
                        }
                    }
                }
            }
            $block_arr = XoopsBlock::getByModule($module->getVar('mid'));
            foreach ($block_arr as $block) {
                if (!in_array($block->getVar('show_func'), $showfuncs) || !in_array($block->getVar('func_file'), $funcfiles)) {
                    $sql = sprintf("DELETE FROM %s WHERE bid = %u", $xoopsDB->prefix('newblocks'), $block->getVar('bid'));
                    if (!$xoopsDB->query($sql)) {
                        $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(__('ERROR: Could not delete block %s', 'rmcommon'), "<strong>" . $block->getVar('name') . "</strong>") . sprintf(__("Block ID: %s", 'rmcommon'), "<strong>" . $block->getVar('bid') . "</strong>") . '</span>';
                    } else {
                        $msgs[] = '&nbsp;&nbsp;Block <strong>' . $block->getVar('name') . ' deleted. Block ID: <strong>' . $block->getVar('bid') . '</strong>';
                        if ($block->getVar('template') != '') {
                            $tplfiles = $tplfile_handler->find(null, 'block', $block->getVar('bid'));
                            if (is_array($tplfiles)) {
                                $btcount = count($tplfiles);
                                for ($k = 0; $k < $btcount; $k++) {
                                    if (!$tplfile_handler->delete($tplfiles[$k])) {
                                        $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . __('ERROR: Could not remove deprecated block template.', 'rmcommon') . '(ID: <strong>' . $tplfiles[$k]->getVar('tpl_id') . '</strong>)</span>';
                                    } else {
                                        $msgs[] = '&nbsp;&nbsp;' . sprintf(__('Block template %s deprecated', 'rmcommon'), "<strong>" . $tplfiles[$k]->getVar('tpl_file') . "</strong>");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // reset compile_id
        $xoopsTpl->setCompileId();
        // first delete all config entries
        $config_handler =& xoops_gethandler('config');
        $configs = $config_handler->getConfigs(new Criteria('conf_modid', $module->getVar('mid')));
        $confcount = count($configs);
        $config_delng = array();
        if ($confcount > 0) {
            $msgs[] = __('Deleting module config options...', 'rmcommon');
            for ($i = 0; $i < $confcount; $i++) {
                if (!$config_handler->deleteConfig($configs[$i])) {
                    $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . __('ERROR: Could not delete config data from the database', 'rmcommon') . sprintf(__('Config ID: %s', 'rmcommon'), "<strong>" . $configs[$i]->getvar('conf_id') . "</strong>") . '</span>';
                    // save the name of config failed to delete for later use
                    $config_delng[] = $configs[$i]->getvar('conf_name');
                } else {
                    $config_old[$configs[$i]->getvar('conf_name')]['value'] = $configs[$i]->getvar('conf_value', 'N');
                    $config_old[$configs[$i]->getvar('conf_name')]['formtype'] = $configs[$i]->getvar('conf_formtype');
                    $config_old[$configs[$i]->getvar('conf_name')]['valuetype'] = $configs[$i]->getvar('conf_valuetype');
                    $msgs[] = "&nbsp;&nbsp;" . __('Config data deleted from the database.', 'rmcommon') . ' ' . sprintf(__('Config ID: %s', 'rmcommon'), "<strong>" . $configs[$i]->getVar('conf_id') . "</strong>");
                }
            }
        }
        // now reinsert them with the new settings
        $configs = $module->getInfo('config');
        // Include
        if ($configs != false) {
            if ($module->getVar('hascomments') != 0) {
                include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
                array_push($configs, array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN)));
                array_push($configs, array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0));
            }
        } else {
            if ($module->getVar('hascomments') != 0) {
                $configs = array();
                include_once XOOPS_ROOT_PATH . '/include/comment_constants.php';
                $configs[] = array('name' => 'com_rule', 'title' => '_CM_COMRULES', 'description' => '', 'formtype' => 'select', 'valuetype' => 'int', 'default' => 1, 'options' => array('_CM_COMNOCOM' => XOOPS_COMMENT_APPROVENONE, '_CM_COMAPPROVEALL' => XOOPS_COMMENT_APPROVEALL, '_CM_COMAPPROVEUSER' => XOOPS_COMMENT_APPROVEUSER, '_CM_COMAPPROVEADMIN' => XOOPS_COMMENT_APPROVEADMIN));
                $configs[] = array('name' => 'com_anonpost', 'title' => '_CM_COMANONPOST', 'description' => '', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 0);
            }
        }
        // RMV-NOTIFY
        if ($module->getVar('hasnotification') != 0) {
            if (empty($configs)) {
                $configs = array();
            }
            // Main notification options
            include_once XOOPS_ROOT_PATH . '/include/notification_constants.php';
            include_once XOOPS_ROOT_PATH . '/include/notification_functions.php';
            $options = array();
            $options['_NOT_CONFIG_DISABLE'] = XOOPS_NOTIFICATION_DISABLE;
            $options['_NOT_CONFIG_ENABLEBLOCK'] = XOOPS_NOTIFICATION_ENABLEBLOCK;
            $options['_NOT_CONFIG_ENABLEINLINE'] = XOOPS_NOTIFICATION_ENABLEINLINE;
            $options['_NOT_CONFIG_ENABLEBOTH'] = XOOPS_NOTIFICATION_ENABLEBOTH;
            //$configs[] = array ('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLED', 'description' => '_NOT_CONFIG_ENABLEDDSC', 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1);
            $configs[] = array('name' => 'notification_enabled', 'title' => '_NOT_CONFIG_ENABLE', 'description' => '_NOT_CONFIG_ENABLEDSC', 'formtype' => 'select', 'valuetype' => 'int', 'default' => XOOPS_NOTIFICATION_ENABLEBOTH, 'options' => $options);
            // Event specific notification options
            // FIXME: for some reason the default doesn't come up properly
            //  initially is ok, but not when 'update' module..
            $options = array();
            $categories =& notificationCategoryInfo('', $module->getVar('mid'));
            foreach ($categories as $category) {
                $events =& notificationEvents($category['name'], false, $module->getVar('mid'));
                foreach ($events as $event) {
                    if (!empty($event['invisible'])) {
                        continue;
                    }
                    $option_name = $category['title'] . ' : ' . $event['title'];
                    $option_value = $category['name'] . '-' . $event['name'];
                    $options[$option_name] = $option_value;
                    //$configs[] = array ('name' => notificationGenerateConfig($category,$event,'name'), 'title' => notificationGenerateConfig($category,$event,'title_constant'), 'description' => notificationGenerateConfig($category,$event,'description_constant'), 'formtype' => 'yesno', 'valuetype' => 'int', 'default' => 1);
                }
            }
            $configs[] = array('name' => 'notification_events', 'title' => '_NOT_CONFIG_EVENTS', 'description' => '_NOT_CONFIG_EVENTSDSC', 'formtype' => 'select_multi', 'valuetype' => 'array', 'default' => array_values($options), 'options' => $options);
        }
        if ($configs != false) {
            $msgs[] = 'Adding module config data...';
            $config_handler =& xoops_gethandler('config');
            $order = 0;
            foreach ($configs as $config) {
                // only insert ones that have been deleted previously with success
                if (!in_array($config['name'], $config_delng)) {
                    $confobj =& $config_handler->createConfig();
                    $confobj->setVar('conf_modid', $newmid);
                    $confobj->setVar('conf_catid', 0);
                    $confobj->setVar('conf_name', $config['name']);
                    $confobj->setVar('conf_title', $config['title'], true);
                    $confobj->setVar('conf_desc', $config['description'], true);
                    $confobj->setVar('conf_formtype', $config['formtype']);
                    $confobj->setVar('conf_valuetype', $config['valuetype']);
                    if (isset($config_old[$config['name']]['value']) && $config_old[$config['name']]['formtype'] == $config['formtype'] && $config_old[$config['name']]['valuetype'] == $config['valuetype']) {
                        // preserver the old value if any
                        // form type and value type must be the same
                        $confobj->setVar('conf_value', $config_old[$config['name']]['value'], true);
                    } else {
                        $confobj->setConfValueForInput($config['default'], true);
                        //$confobj->setVar('conf_value', $config['default'], true);
                    }
                    $confobj->setVar('conf_order', $order);
                    $confop_msgs = '';
                    if (isset($config['options']) && is_array($config['options'])) {
                        foreach ($config['options'] as $key => $value) {
                            $confop =& $config_handler->createConfigOption();
                            $confop->setVar('confop_name', $key, true);
                            $confop->setVar('confop_value', $value, true);
                            $confobj->setConfOptions($confop);
                            $confop_msgs .= '<br />&nbsp;&nbsp;&nbsp;&nbsp; ' . __('Config option added', 'rmcommon') . ' ' . __('Name:', 'rmcommon') . ' <strong>' . (defined($key) ? constant($key) : $key) . '</strong> ' . __('Value:', 'rmcommon') . ' <strong>' . $value . '</strong> ';
                            unset($confop);
                        }
                    }
                    $order++;
                    if (false != $config_handler->insertConfig($confobj)) {
                        //$msgs[] = '&nbsp;&nbsp;Config <strong>'.$config['name'].'</strong> added to the database.'.$confop_msgs;
                        $msgs[] = "&nbsp;&nbsp;" . sprintf(__('Config %s added to the database', 'rmcommon'), "<strong>" . $config['name'] . "</strong>") . $confop_msgs;
                    } else {
                        $msgs[] = '&nbsp;&nbsp;<span style="color:#ff0000;">' . sprintf(__('ERROR: Could not insert config %s to the database.', 'rmcommon'), "<strong>" . $config['name'] . "</strong>") . '</span>';
                    }
                    unset($confobj);
                }
            }
            unset($configs);
        }
        // execute module specific update script if any
        $update_script = $module->getInfo('onUpdate');
        if (false != $update_script && trim($update_script) != '') {
            include_once XOOPS_ROOT_PATH . '/modules/' . $dirname . '/' . trim($update_script);
            if (function_exists('xoops_module_update_' . $dirname)) {
                $func = 'xoops_module_update_' . $dirname;
                if (!$func($module, $prev_version)) {
                    $msgs[] = "<p>" . sprintf(__('Failed to execute %s', 'rmcommon'), $func) . "</p>";
                } else {
                    $msgs[] = "<p>" . sprintf(__('%s executed successfully.', 'rmcommon'), "<strong>" . $func . "</strong>") . "</p>";
                }
            }
        }
        foreach ($msgs as $msg) {
            $log .= $msg . '<br />';
        }
        $log .= "<p>" . sprintf(__('Module %s updated successfully!', 'rmcommon'), "<strong>" . $module->getVar('name') . "</strong>") . "</p>";
    }
    // Flush cache files for cpanel GUIs
    xoops_load("cpanel", "system");
    XoopsSystemCpanel::flush();
    return $log;
}
コード例 #23
0
function myblocksadmin_update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $bmodule, $options = array())
{
    global $xoopsConfig;
    if (empty($bmodule)) {
        xoops_cp_header();
        xoops_error(sprintf(_AM_NOTSELNG, _AM_VISIBLEIN));
        xoops_cp_footer();
        exit;
    }
    $myblock = new XoopsBlock($bid);
    // $myblock->setVar('side', $bside); GIJ -
    if ($bside >= 0) {
        $myblock->setVar('side', $bside);
    }
    // GIJ +
    $myblock->setVar('weight', $bweight);
    $myblock->setVar('visible', $bvisible);
    $myblock->setVar('title', $btitle);
    $myblock->setVar('content', $bcontent);
    $myblock->setVar('bcachetime', $bcachetime);
    if (isset($options) && count($options) > 0) {
        $options = implode('|', $options);
        $myblock->setVar('options', $options);
    }
    if ($myblock->getVar('block_type') == 'C') {
        switch ($bctype) {
            case 'H':
                $name = _AM_CUSTOMHTML;
                break;
            case 'P':
                $name = _AM_CUSTOMPHP;
                break;
            case 'S':
                $name = _AM_CUSTOMSMILE;
                break;
            default:
                $name = _AM_CUSTOMNOSMILE;
                break;
        }
        $myblock->setVar('name', $name);
        $myblock->setVar('c_type', $bctype);
    } else {
        $myblock->setVar('c_type', 'H');
    }
    $msg = _AM_DBUPDATED;
    if ($myblock->store() != false) {
        $db =& Database::getInstance();
        $sql = sprintf("DELETE FROM %s WHERE block_id = %u", $db->prefix('block_module_link'), $bid);
        $db->query($sql);
        foreach ($bmodule as $bmid) {
            $sql = sprintf("INSERT INTO %s (block_id, module_id) VALUES (%u, %d)", $db->prefix('block_module_link'), $bid, intval($bmid));
            $db->query($sql);
        }
        include_once XOOPS_ROOT_PATH . '/class/template.php';
        $xoopsTpl = new XoopsTpl();
        $xoopsTpl->xoops_setCaching(2);
        if ($myblock->getVar('template') != '') {
            if ($xoopsTpl->is_cached('db:' . $myblock->getVar('template'))) {
                if (!$xoopsTpl->clear_cache('db:' . $myblock->getVar('template'))) {
                    $msg = 'Unable to clear cache for block ID' . $bid;
                }
            }
        } else {
            if ($xoopsTpl->is_cached('db:system_dummy.html', 'block' . $bid)) {
                if (!$xoopsTpl->clear_cache('db:system_dummy.html', 'block' . $bid)) {
                    $msg = 'Unable to clear cache for block ID' . $bid;
                }
            }
        }
    } else {
        $msg = 'Failed update of block. ID:' . $bid;
    }
    // redirect_header('admin.php?fct=blocksadmin&amp;t='.time(),1,$msg);
    // exit(); GIJ -
    return $msg;
    // GIJ +
}
コード例 #24
0
 /**
  * @private
  * Uninstalls the block template data specified by $block of $module.
  * @param XoopsBlock  $block
  * @param XoopsModule $module This object is must the module which has $block.
  * @param string      $tplset A name of the template set. If this is null, uninstalls
  *                            all templates of any template-sets. 
  * @param $log
  * @remarks
  *     This method users template handlers of the kernel. But, if they are hooked,
  *     they may not do something. So, abstraction mechanism is possible enough.
  */
 function _uninstallBlockTemplate(&$block, &$module, $tplset, &$log)
 {
     $handler =& xoops_gethandler('tplfile');
     $criteria = new CriteriaCompo();
     $criteria->add(new Criteria('tpl_refid', $block->get('bid')));
     $criteria->add(new Criteria('tpl_file', $block->get('template')));
     $criteria->add(new Criteria('tpl_module', $module->get('dirname')));
     $criteria->add(new Criteria('tpl_type', 'block'));
     if ($tplset != null) {
         // See 'FIXME'
         $criteria->add(new Criteria('tpl_tplset', $tplset));
     }
     $handler->deleteAll($criteria);
 }
コード例 #25
0
ファイル: myblocksadmin.php プロジェクト: severnaya99/Sg-2010
foreach ($group_defs as $def) {
    if (strstr($def, '_AM_ACCESSRIGHTS') || strstr($def, '_AM_ACTIVERIGHTS')) {
        eval($def);
    }
}
// check $xoopsModule
if (!is_object($xoopsModule)) {
    redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM);
}
// check access right (needs system_admin of BLOCK)
$sysperm_handler =& xoops_gethandler('groupperm');
if (!$sysperm_handler->checkRight('system_admin', XOOPS_SYSTEM_BLOCK, $xoopsUser->getGroups())) {
    redirect_header(XOOPS_URL . '/user.php', 1, _NOPERM);
}
// get blocks owned by the module
$block_arr =& XoopsBlock::getByModule($xoopsModule->mid());
function list_blocks()
{
    global $block_arr;
    // cachetime options
    $cachetimes = array('0' => _NOCACHE, '30' => sprintf(_SECONDS, 30), '60' => _MINUTE, '300' => sprintf(_MINUTES, 5), '1800' => sprintf(_MINUTES, 30), '3600' => _HOUR, '18000' => sprintf(_HOURS, 5), '86400' => _DAY, '259200' => sprintf(_DAYS, 3), '604800' => _WEEK, '2592000' => _MONTH);
    // displaying TH
    echo "\r\n\t<form action='admin.php' name='blockadmin' method='post'>\r\n\t\t<table width='90%' class='outer' cellpadding='4' cellspacing='1'>\r\n\t\t<tr valign='middle'>\r\n\t\t\t<th>" . _AM_TITLE . "</th>\r\n\t\t\t<th align='center' nowrap='nowrap'>" . _AM_SIDE . "</th>\r\n\t\t\t<th align='center'>" . _AM_WEIGHT . "</th>\r\n\t\t\t<th align='center'>" . _AM_VISIBLEIN . "</th>\r\n\t\t\t<th align='center'>" . _AM_BCACHETIME . "</th>\r\n\t\t\t<th align='right'>" . _AM_ACTION . "</th>\r\n\t\t</tr>\n";
    // blocks displaying loop
    $class = 'even';
    foreach (array_keys($block_arr) as $i) {
        $sseln = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = "";
        $weight = $block_arr[$i]->getVar("weight");
        $title = $block_arr[$i]->getVar("title");
        $name = $block_arr[$i]->getVar("name");
        $bcachetime = $block_arr[$i]->getVar("bcachetime");
コード例 #26
0
ファイル: modulesadmin.php プロジェクト: koki-h/xoops_utf8
function xoops_module_deactivate($mid)
{
    global $xoopsConfig;
    $module_handler =& xoops_gethandler('module');
    $module =& $module_handler->get($mid);
    include_once XOOPS_ROOT_PATH . '/class/template.php';
    xoops_template_clear_module_cache($mid);
    $module->setVar('isactive', 0);
    if ($module->getVar('dirname') == "system") {
        return "<p>" . sprintf(_MD_AM_FAILDEACT, "<b>" . $module->getVar('name') . "</b>") . "&nbsp;" . _MD_AM_ERRORSC . "<br /> - " . _MD_AM_SYSNO . "</p>";
    } elseif ($module->getVar('dirname') == $xoopsConfig['startpage']) {
        return "<p>" . sprintf(_MD_AM_FAILDEACT, "<b>" . $module->getVar('name') . "</b>") . "&nbsp;" . _MD_AM_ERRORSC . "<br /> - " . _MD_AM_STRTNO . "</p>";
    } else {
        if (!$module_handler->insert($module)) {
            $ret = "<p>" . sprintf(_MD_AM_FAILDEACT, "<b>" . $module->getVar('name') . "</b>") . "&nbsp;" . _MD_AM_ERRORSC . "<br />" . $module->getHtmlErrors();
            return $ret . "</p>";
        }
        $blocks =& XoopsBlock::getByModule($module->getVar('mid'));
        $bcount = count($blocks);
        for ($i = 0; $i < $bcount; $i++) {
            $blocks[$i]->setVar('isactive', 0);
            $blocks[$i]->store();
        }
        return "<p>" . sprintf(_MD_AM_OKDEACT, "<b>" . $module->getVar('name') . "</b>") . "</p>";
    }
}
コード例 #27
0
ファイル: xoopsblock.php プロジェクト: yunsite/xoopsdc
 function getAllBlocks($rettype = "object", $side = null, $visible = null, $orderby = "side,weight,bid", $isactive = 1)
 {
     $db = $GLOBALS['xoopsDB'];
     $ret = array();
     $where_query = " WHERE isactive=" . $isactive;
     if (isset($side)) {
         // get both sides in sidebox? (some themes need this)
         if ($side == 2) {
             $side = "(side=0 OR side=1)";
         } elseif ($side == 6) {
             $side = "(side=3 OR side=4 OR side=5 OR side=7 OR side=8 OR side=9)";
         } else {
             $side = "side=" . $side;
         }
         $where_query .= " AND " . $side;
     }
     if (isset($visible)) {
         $where_query .= " AND visible={$visible}";
     }
     $where_query .= " ORDER BY {$orderby}";
     switch ($rettype) {
         case "object":
             $sql = "SELECT * FROM " . $db->prefix("newblocks") . "" . $where_query;
             $result = $db->query($sql);
             while ($myrow = $db->fetchArray($result)) {
                 $ret[] = new XoopsBlock($myrow);
             }
             break;
         case "list":
             $sql = "SELECT * FROM " . $db->prefix("newblocks") . "" . $where_query;
             $result = $db->query($sql);
             while ($myrow = $db->fetchArray($result)) {
                 $block = new XoopsBlock($myrow);
                 //$title = ($block->getVar("block_type") != "C") ? $block->getVar("name") : $block->getVar("title");
                 $title = $block->getVar("title");
                 $title = empty($title) ? $block->getVar("name") : $title;
                 $ret[$block->getVar("bid")] = $title;
             }
             break;
         case "id":
             $sql = "SELECT bid FROM " . $db->prefix("newblocks") . "" . $where_query;
             $result = $db->query($sql);
             while ($myrow = $db->fetchArray($result)) {
                 $ret[] = $myrow['bid'];
             }
             break;
     }
     //echo $sql;
     return $ret;
 }
コード例 #28
0
ファイル: groups.php プロジェクト: amjadtbssm/website
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>&nbsp;<span style="font-weight:bold;">&raquo;&raquo;</span>&nbsp;' . _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&amp;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&amp;op=modify&amp;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();
}
コード例 #29
0
ファイル: block.php プロジェクト: geekwright/XoopsCore25
 /**
  * retrieve array of {@link XoopsBlock}s meeting certain conditions
  * @param  CriteriaElement $criteria  {@link CriteriaElement} with conditions for the blocks
  * @param  bool   $id_as_key should the blocks' bid be the key for the returned array?
  * @return array  {@link XoopsBlock}s matching the conditions
  **/
 public function getObjects(CriteriaElement $criteria = null, $id_as_key = false)
 {
     $ret = array();
     $limit = $start = 0;
     $sql = 'SELECT DISTINCT(b.bid), b.* FROM ' . $this->db->prefix('newblocks') . ' b LEFT JOIN ' . $this->db->prefix('block_module_link') . ' l ON b.bid=l.block_id';
     if (isset($criteria) && is_subclass_of($criteria, 'criteriaelement')) {
         $sql .= ' ' . $criteria->renderWhere();
         $limit = $criteria->getLimit();
         $start = $criteria->getStart();
     }
     $result = $this->db->query($sql, $limit, $start);
     if (!$result) {
         return $ret;
     }
     while ($myrow = $this->db->fetchArray($result)) {
         $block = new XoopsBlock();
         $block->assignVars($myrow);
         if (!$id_as_key) {
             $ret[] =& $block;
         } else {
             $ret[$myrow['bid']] =& $block;
         }
         unset($block);
     }
     return $ret;
 }
コード例 #30
0
ファイル: groupform.php プロジェクト: koki-h/xoops_utf8
$new_blocks_array = array();
$blocks_array = XoopsBlock::getAllBlocks("list", XOOPS_SIDEBLOCK_LEFT);
foreach ($blocks_array as $key => $value) {
    $new_blocks_array[$key] = "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&amp;op=edit&amp;bid=" . $key . "'>" . $value . " (ID: " . $key . ")</a>";
}
$r_lblock_checkbox->addOptionArray($new_blocks_array);
$r_cblock_checkbox = new XoopsFormCheckBox("<b>" . _CENTER . "</b><br />", "read_bids[]", $r_block_value);
$new_blocks_array = array();
$blocks_array = XoopsBlock::getAllBlocks("list", XOOPS_CENTERBLOCK_ALL);
foreach ($blocks_array as $key => $value) {
    $new_blocks_array[$key] = "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&amp;op=edit&amp;bid=" . $key . "'>" . $value . " (ID: " . $key . ")</a>";
}
$r_cblock_checkbox->addOptionArray($new_blocks_array);
$r_rblock_checkbox = new XoopsFormCheckBox("<b>" . _RIGHT . "</b><br />", "read_bids[]", $r_block_value);
$new_blocks_array = array();
$blocks_array = XoopsBlock::getAllBlocks("list", XOOPS_SIDEBLOCK_RIGHT);
foreach ($blocks_array as $key => $value) {
    $new_blocks_array[$key] = "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=blocksadmin&amp;op=edit&amp;bid=" . $key . "'>" . $value . " (ID: " . $key . ")</a>";
}
$r_rblock_checkbox->addOptionArray($new_blocks_array);
$r_block_tray = new XoopsFormElementTray(_AM_BLOCKRIGHTS, "<br /><br />");
$r_block_tray->addElement($r_lblock_checkbox);
$r_block_tray->addElement($r_cblock_checkbox);
$r_block_tray->addElement($r_rblock_checkbox);
$op_hidden = new XoopsFormHidden("op", $op_value);
$fct_hidden = new XoopsFormHidden("fct", "groups");
$submit_button = new XoopsFormButton("", "groupsubmit", $submit_value, "submit");
$form = new XoopsThemeForm($form_title, "groupform", "admin.php");
$form->addElement(new XoopsFormToken(XoopsMultiTokenHandler::quickCreate('groups_' . $op_value)));
$form->addElement($name_text);
$form->addElement($desc_text);