/** * Get blocks */ public function construct_blocks() { global $xoopsConfig, $xoopsModule, $xoopsUser, $xoopsOption; $sides = array(); foreach (self::block_positions() as $id => $row) { $sides[$id] = $row['tag']; $blocks[$row['tag']] = array(); } $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 { $sys = RMFunctions::load_module('system'); list($mid, $dirname) = array($sys->getVar('mid'), 'system'); $isStart = !@empty($GLOBALS['xoopsOption']['show_cblock']); } $groups = @is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); $subpage = isset($xoopsOption['module_subpage']) ? $xoopsOption['module_subpage'] : ''; $barray = array(); // Array of retrieved blocks $barray = self::get_blocks($groups, $mid, $isStart, XOOPS_BLOCK_VISIBLE, '', 1, $subpage); foreach ($barray as $block) { $side = $sides[$block->getVar('canvas')]; if ($content = self::buildBlock($block)) { $blocks[$side][$content['id']] = $content; } } unset($side, $sides, $content, $subpage, $barray, $groups, $startMod); return $blocks; }
public function eventRmcommonGetFeedsList($feeds) { load_mod_locale('galleries'); include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php'; $module = RMFunctions::load_module('galleries'); $config = RMUtilities::module_config('galleries'); $data = array('title' => $module->name(), 'url' => GSFunctions::get_url(), 'module' => 'galleries'); $options[] = array('title' => __('All Recent Pictures', 'galleries'), 'params' => 'show=pictures', 'description' => __('Show all recent pictures', 'galleries')); $options[] = array('title' => __('All Recent Albums', 'galleries'), 'params' => 'show=albums', 'description' => __('Show all recent albums', 'galleries')); $feed = array('data' => $data, 'options' => $options); $feeds[] = $feed; return $feeds; }
function show_rm_blocks() { global $xoopsModule, $xoopsConfig, $wid_globals, $xoopsSecurity; $db = Database::getInstance(); $modules = RMFunctions::get_modules_list(1); // ** API Event ** // Allows other methods to add o modify the list of available widgets $modules = RMEvents::get()->run_event('rmcommon.blocks.modules', $modules); // Cargamos los grupos $sql = "SELECT groupid, name FROM " . $db->prefix("groups") . " ORDER BY name"; $result = $db->query($sql); $groups = array(); while ($row = $db->fetchArray($result)) { $groups[] = array('id' => $row['groupid'], 'name' => $row['name']); } // Cargamos las posiciones de bloques $bpos = RMBlocksFunctions::block_positions(); $sql = createSQL(); $result = $db->query($sql); $blocks = array(); $used_blocks = array(); while ($row = $db->fetchArray($result)) { $mod = RMFunctions::load_module($row['element']); if (!$mod) { continue; } $used_blocks[] = array('id' => $row['bid'], 'title' => $row['name'], 'module' => array('id' => $mod->mid(), 'dir' => $mod->dirname(), 'name' => $mod->name()), 'canvas' => $bpos[$row['canvas']], 'weight' => $row['weight'], 'visible' => $row['visible'], 'type' => $row['type'], 'options' => $row['edit_func'] != '' ? 1 : 0, 'description' => $row['description']); } // ** API ** // Event for manege the used widgets list $used_blocks = RMEvents::get()->run_event('rmcommon.used.blocks.list', $used_blocks); $positions = array(); foreach ($bpos as $row) { $positions[] = array('id' => $row['id_position'], 'name' => $row['name']); } $positions = RMEvents::get()->run_event('rmcommon.block.positions.list', $positions); xoops_cp_location('<a href="./">' . $xoopsModule->getVar('name') . '</a> » ' . __('Blocks', 'rmcommon')); RMTemplate::get()->add_style('blocks.css', 'rmcommon'); RMTemplate::get()->add_local_script('blocks.js', 'rmcommon', 'include'); RMTemplate::get()->add_local_script('jkmenu.js', 'rmcommon', 'include'); RMTemplate::get()->add_style('forms.css', 'rmcommon'); RMTemplate::get()->add_local_script('jquery-ui.min.js', 'rmcommon', 'include'); xoops_cp_header(); // Available Widgets $blocks = RMBlocksFunctions::get_available_list($modules); // Position $the_position = isset($_GET['pos']) ? intval($_GET['pos']) : ''; include RMTemplate::get()->get_template("rmc_blocks.php", 'module', 'rmcommon'); xoops_cp_footer(); }
// $Id: rss.php 824 2011-12-08 23:50:30Z i.bitcero $ // -------------------------------------------------------------- // MyWords // Complete Blogging System // Author: BitC3R0 <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- if (!defined('XOOPS_MAINFILE_INCLUDED')) { header('Location: ../../backend.php'); die; } load_mod_locale("mywords"); $show = rmc_server_var($_GET, 'show', 'all'); $xoopsModule = RMFunctions::load_module('mywords'); $config = RMSettings::module_settings('mywords'); include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwfunctions.php'; $rss_channel = array(); switch ($show) { case 'cat': include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwcategory.class.php'; $id = rmc_server_var($_GET, 'cat', 0); if ($id <= 0) { redirect_header('backend.php', 1, __('Sorry, specified category was not foud!', 'mywords')); die; } $cat = new MWCategory($id); if ($cat->isNew()) { redirect_header('backend.php', 1, __('Sorry, specified category was not foud!', 'mywords')); die;
function rmc_bkcomments_show($options) { $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("rmc_comments") . " ORDER BY id_com DESC"; $limit = $options[0] > 0 ? $options[0] : 10; $sql .= " LIMIT 0,{$limit}"; $result = $db->query($sql); $comments = array(); $ucache = array(); $ecache = array(); $mods = array(); while ($row = $db->fetchArray($result)) { $com = new RMComment(); $com->assignVars($row); if ($options[3]) { // Editor data if (!isset($ecache[$com->getVar('user')])) { $ecache[$com->getVar('user')] = new RMCommentUser($com->getVar('user')); } $editor = $ecache[$com->getVar('user')]; if ($editor->getVar('xuid') > 0) { if (!isset($ucache[$editor->getVar('xuid')])) { $ucache[$editor->getVar('xuid')] = new XoopsUser($editor->getVar('xuid')); } $user = $ucache[$editor->getVar('xuid')]; $poster = array('id' => $user->getVar('uid'), 'name' => $user->getVar('uname'), 'email' => $user->getVar('email'), 'posts' => $user->getVar('posts'), 'avatar' => $user->getVar('user_avatar') != '' && $user->getVar('user_avatar') != 'blank.gif' ? XOOPS_UPLOAD_URL . '/' . $user->getVar('user_avatar') : RMCURL . '/images/avatar.gif', 'rank' => $user->rank()); } else { $poster = array('id' => 0, 'name' => $editor->getVar('name'), 'email' => $editor->getVar('email'), 'posts' => 0, 'avatar' => RMCURL . '/images/avatar.gif', 'rank' => ''); } } // Get item $cpath = XOOPS_ROOT_PATH . '/modules/' . $row['id_obj'] . '/class/' . $row['id_obj'] . 'controller.php'; if (is_file($cpath)) { if (!class_exists(ucfirst($row['id_obj']) . 'Controller')) { include_once $cpath; } $class = ucfirst($row['id_obj']) . 'Controller'; $controller = new $class(); $item = $controller->get_item($row['params'], $com); $item_url = $controller->get_item_url($row['params'], $com); } else { $item = __('Unknow', 'rmcommon'); $item_url = ''; } if (isset($mods[$row['id_obj']])) { $mod = $mods[$row['id_obj']]; } else { $m = RMFunctions::load_module($row['id_obj']); $mod = $m->getVar('name'); $mods[$row['id_obj']] = $mod; } $comments[] = array('id' => $row['id_com'], 'text' => TextCleaner::truncate(TextCleaner::getInstance()->clean_disabled_tags(TextCleaner::getInstance()->popuplinks(TextCleaner::getInstance()->nofollow($com->getVar('content')))), 50), 'poster' => isset($poster) ? $poster : null, 'posted' => formatTimestamp($com->getVar('posted'), 'l'), 'item' => $item, 'item_url' => $item_url, 'module' => $row['id_obj'], 'status' => $com->getVar('status'), 'module' => $mod); } $comments = RMEvents::get()->run_event('rmcommon.loading.block.comments', $comments); $block['comments'] = $comments; $block['show_module'] = $options[1]; $block['show_name'] = $options[2]; $block['show_user'] = $options[3]; $block['show_date'] = $options[4]; $num = $options[2] + $options[3] + $options[4]; $block['data_width'] = floor(100 / $num); RMTemplate::get()->add_xoops_style('bk_comments.css', 'rmcommon'); return $block; }
<?php // $Id$ // -------------------------------------------------------------- // MyGalleries // Module for advanced image galleries management // Author: Eduardo Cortés // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- load_mod_locale("galleries"); $show = rmc_server_var($_GET, 'show', 'all'); $xoopsModule = RMFunctions::load_module('galleries'); $config = RMUtilities::module_config('galleries'); include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsfunctions.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsimage.class.php'; include_once XOOPS_ROOT_PATH . '/modules/galleries/class/gsset.class.php'; $rss_channel = array(); $db = XoopsDatabaseFactory::getDatabaseConnection(); switch ($show) { case 'pictures': $sql = "SELECT * FROM " . $db->prefix('gs_images') . " WHERE public=2 ORDER BY created DESC LIMIT 0,15"; $result = $db->query($sql); $rss_channel['title'] = $xoopsModule->name(); $rss_channel['link'] = GSFunctions::get_url(); $rss_channel['description'] = __('These are the recent pictures published on our galleries.', 'galleries'); $rss_channel['lastbuild'] = formatTimestamp(time(), 'rss'); $rss_channel['webmaster'] = checkEmail($xoopsConfig['adminmail'], true); $rss_channel['editor'] = checkEmail($xoopsConfig['adminmail'], true); $rss_channel['category'] = __('Pictures', 'galleries'); $rss_channel['generator'] = 'MyGalleries 3';
function render() { $module_handler =& xoops_gethandler('module'); $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); $criteria->add(new Criteria('isactive', 1)); if ($this->subpages) { $criteria->add(new Criteria('dirname', 'system'), 'OR'); } $modules = array(); $modules[0] = __('All', 'rmcommon'); if (is_array($this->inserted)) { $modules = $this->inserted; } foreach ($module_handler->getList($criteria, $this->dirnames) as $k => $v) { $modules[$k] = $v; } if ($this->type) { // Add js script RMTemplate::get()->add_local_script('modules_field.js', 'rmcommon', 'include'); $rtn = '<div class="modules_field">'; $i = 1; foreach ($modules as $k => $v) { $app = RMFunctions::load_module($k); $rtn .= "<div class=\"mod_item\">"; $name = $this->multi ? $this->getName() . "[{$k}]" : $this->getName(); if ($this->multi) { $rtn .= "<label id=\"modlabel-{$k}\" class='field_module_names'><input type='checkbox' value='{$k}' name='" . $name . "' id='" . $this->getName() . "-{$k}'" . (is_array($this->selected) ? in_array($k, $this->selected) ? " checked='checked'" : '' : '') . " /> {$v}</label>"; } else { $rtn .= "<label id=\"modlabel-{$k}\" class=\"field_module_names\"><input type='radio' value='{$k}' name='" . $this->getName() . "' id='" . $this->getName() . "-{$k}'" . (!empty($this->selected) ? $k == $this->selected ? " checked='checked'" : '' : '') . " /> {$v}</label>"; } /** * Mostramos las subpáginas */ if ($this->subpages && $k > 0) { if ($app->dirname() == 'system') { $subpages = array('home-page' => __('Home Page', 'rmcommon'), 'user' => __('User page', 'dtransport'), 'profile' => __('User profile page', 'rmcommon'), 'register' => __('Users registration', 'rmcommon'), 'edit-user' => __('Edit user', 'rmcommon'), 'readpm' => __('Read PM', 'rmcommon'), 'pm' => __('Private messages', 'rmcomon')); } else { $subpages = $app->getInfo('subpages'); } if (!empty($subpages)) { $selected = $this->selectedSubPages; $cr = 0; $rtn .= "<div id=\"subpages-" . $k . "\" class=\"subpages_container\">\n <div class='sp_title'><span id=\"close-{$k}\"></span>" . __('Inner pages', 'rmcommon') . "</div>"; $j = 2; $cr = 2; if (!is_array($subpages)) { $subpages = array(); } foreach ($subpages as $page => $caption) { $rtn .= "<div class=\"sub_item\"><label><input type='checkbox' name='" . $name . "[subpages][{$page}]' id='subpages[{$k}][{$page}]' value='{$page}'" . (is_array($subpages) && @in_array($page, $selected[$k]) ? " checked='checked'" : '') . " onclick=\"checkSubpageClick('subpages[{$k}][{$page}]', {$k});\" /> {$caption}</label></div>"; $j++; $cr++; } $rtn .= '</div>'; } } $rtn .= "</div>"; $i++; } $rtn .= "</div>"; } else { if ($this->multi) { $name = $this->getName() . "[{$k}]"; $rtn = "<select name='" . $name . "' id='" . $name . "' size='{$this->cols}' multiple='multiple'>"; foreach ($modules as $k => $v) { $rtn .= "<option value='{$k}'" . (is_array($this->selected) ? in_array($k, $this->selected) ? " selected='selected'" : '' : '') . ">{$v}</option>"; } $rtn .= "</select>"; } else { $rtn = "<select name='" . $this->getName() . "' id='" . $this->getName() . "'>"; foreach ($modules as $k => $v) { $rtn .= "<option value='{$k}'" . (!empty($this->selected) ? $k == $this->selected ? " selected='selected'" : '' : '') . ">{$v}</option>"; } $rtn .= "</select>"; } } return $rtn; }
<?php // $Id: files.php 819 2011-12-08 23:43:13Z i.bitcero $ // -------------------------------------------------------------- // bXpress Forums // An simple forums module for XOOPS and Common Utilities // Author: Eduardo Cortés <*****@*****.**> // Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- load_mod_locale("dtransport"); $show = rmc_server_var($_GET, 'show', 'all'); $xoopsModule = RMFunctions::load_module('bxpress'); $config = RMSettings::module_settings('bxpress'); include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxforum.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxpost.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxtopic.class.php'; include_once XOOPS_ROOT_PATH . '/modules/bxpress/class/bxfunctions.class.php'; $rss_channel = array(); $rss_items = array(); $bxFunc = new bXFunctions(); $db = XoopsDatabaseFactory::getDatabaseConnection(); $tc = TextCleaner::getInstance(); $tbl1 = $db->prefix('mod_bxpress_posts'); $tbl2 = $db->prefix('mod_bxpress_topics'); $tbl3 = $db->prefix('mod_bxpress_posts_text'); $tbl4 = $db->prefix('mod_bxpress_forums'); switch ($show) { case 'forum': $id = rmc_server_var($_GET, 'forum', 0); if ($id <= 0) {
/** * Get the module icon */ public function module_icon($module, $size = '16') { global $xoopsModule; if (!is_a($xoopsModule, 'XoopsModule')) { return false; } if ($xoopsModule->dirname() != $module) { $mod = RMFunctions::load_module($module); } else { $mod = $xoopsModule; } $icon = $mod->getInfo('icon' . $size); $path = XOOPS_ROOT_PATH . '/modules/' . $mod->dirname() . '/' . $icon; if (!is_file($path)) { return DESIGNIA_URL . '/images/module' . $size . '.png'; } else { return str_replace(XOOPS_ROOT_PATH, XOOPS_URL, $path); } }
/** * Return the feed options to show in RSS Center */ public function eventRmcommonGetFeedsList($feeds) { include_once XOOPS_ROOT_PATH . '/modules/mywords/class/mwfunctions.php'; load_mod_locale('mywords'); $module = RMFunctions::load_module('mywords'); $config = RMUtilities::module_config('mywords'); $data = array('title' => $module->name(), 'url' => XOOPS_URL . $config['basepath'], 'module' => 'mywords'); $options[] = array('title' => __('All Recent Posts', 'mywords'), 'params' => 'show=all', 'description' => __('Show all recent posts', 'mywords')); $categories = array(); MWFunctions::categos_list($categories); $table = '<table cellpadding="2" cellspacing="2" width="100%"><tr class="even">'; $count = 0; foreach ($categories as $cat) { if ($count >= 3) { $count = 0; $table .= '</tr><tr class="' . tpl_cycle("odd,even") . '">'; } $table .= '<td width="33%"><a href="' . XOOPS_URL . '/backend.php?action=showfeed&mod=mywords&show=cat&cat=' . $cat['id_cat'] . '">' . $cat['name'] . '</a></td>'; $count++; } $table .= '</tr></table>'; $options[] = array('title' => __('Posts by category', 'mywords'), 'description' => __('Select a category to see the posts published recently.', 'mywords') . ' <a href="javascript:;" onclick="$(\'#categories-feed\').slideToggle(\'slow\');">Show Categories</a> <div id="categories-feed" style="padding: 10px; display: none;">' . $table . '</div>'); unset($categories); $tags = MWFunctions::get_tags("*", '', '', 99); $table = '<table cellpadding="2" cellspacing="2" width="100%"><tr class="even">'; $count = 0; foreach ($tags as $tag) { if ($count >= 3) { $count = 0; $table .= '</tr><tr class="' . tpl_cycle("odd,even") . '">'; } $table .= '<td width="33%"><a href="' . XOOPS_URL . '/backend.php?action=showfeed&mod=mywords&show=tag&tag=' . $tag['id_tag'] . '">' . $tag['tag'] . '</a></td>'; $count++; } $table .= '</tr></table>'; $options[] = array('title' => __('Show posts by tag', 'mywords'), 'description' => __('Select a tag to see the posts published recently.', 'mywords') . ' <a href="javascript:;" onclick="$(\'#tags-feed\').slideToggle(\'slow\');">Show Tags</a> <div id="tags-feed" style="padding: 10px; display: none;">' . $table . '</div>'); unset($tags); $db = XoopsDatabaseFactory::getDatabaseConnection(); $sql = "SELECT * FROM " . $db->prefix("mw_editors") . " ORDER BY name"; $result = $db->query($sql); $editors = array(); while ($row = $db->fetchArray($result)) { $editors[] = $row; } asort($editors); $table = '<table cellpadding="2" cellspacing="2" width="100%"><tr class="even">'; $count = 0; foreach ($editors as $ed) { if ($count >= 3) { $count = 0; $table .= '</tr><tr class="' . tpl_cycle("odd,even") . '">'; } $table .= '<td width="33%"><a href="' . XOOPS_URL . '/backend.php?action=showfeed&mod=mywords&show=author&author=' . $ed['id_editor'] . '">' . $ed['name'] . '</a></td>'; $count++; } $table .= '</tr></table>'; $options[] = array('title' => __('Show posts by author', 'mywords'), 'description' => __('Select an author to see the posts published recently.', 'mywords') . ' <a href="javascript:;" onclick="$(\'#editor-feed\').slideToggle(\'slow\');">Show Authors</a> <div id="editor-feed" style="padding: 10px; display: none;">' . $table . '</div>'); unset($editors); unset($table); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.min.js'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery-ui.min.js'); $feed = array('data' => $data, 'options' => $options); $feeds[] = $feed; return $feeds; }
function show_rm_blocks() { global $xoopsModule, $xoopsConfig, $wid_globals, $xoopsSecurity, $rmc_config; define('RMCSUBLOCATION', 'blocks'); $db = XoopsDatabaseFactory::getDatabaseConnection(); $modules = RMFunctions::get_modules_list(1); // ** API Event ** // Allows other methods to add o modify the list of available widgets $modules = RMEvents::get()->run_event('rmcommon.blocks.modules', $modules); // Cargamos los grupos $sql = "SELECT groupid, name FROM " . $db->prefix("groups") . " ORDER BY name"; $result = $db->query($sql); $groups = array(); while ($row = $db->fetchArray($result)) { $groups[] = array('id' => $row['groupid'], 'name' => $row['name']); } // Cargamos las posiciones de bloques $bpos = RMBlocksFunctions::block_positions(); $sql = createSQL(); $result = $db->query($sql); $blocks = array(); $used_blocks = array(); while ($row = $db->fetchArray($result)) { $mod = RMFunctions::load_module($row['element']); if (!$mod) { continue; } $used_blocks[] = array('id' => $row['bid'], 'title' => $row['name'], 'module' => array('id' => $mod->mid(), 'dir' => $mod->dirname(), 'name' => $mod->name()), 'canvas' => $bpos[$row['canvas']], 'weight' => $row['weight'], 'visible' => $row['visible'], 'active' => $row['isactive'], 'type' => $row['type'], 'options' => $row['edit_func'] != '' ? 1 : 0, 'description' => $row['description']); } // ** API ** // Event for manege the used widgets list $used_blocks = RMEvents::get()->run_event('rmcommon.used.blocks.list', $used_blocks); $positions = array(); foreach ($bpos as $row) { $positions[] = array('id' => $row['id_position'], 'name' => $row['name'], 'tag' => $row['tag'], 'active' => $row['active']); } $positions = RMEvents::get()->run_event('rmcommon.block.positions.list', $positions); if (rmc_server_var($_REQUEST, 'pos', '') != '') { RMTemplate::get()->add_local_script('jquery.sort.js', 'rmcommon', 'include'); } xoops_cp_location('<a href="./">' . $xoopsModule->getVar('name') . '</a> » ' . __('Blocks', 'rmcommon')); RMTemplate::get()->add_style('blocks.css', 'rmcommon'); RMTemplate::get()->add_local_script('blocks.js', 'rmcommon', 'include'); RMTemplate::get()->add_local_script('jkmenu.js', 'rmcommon', 'include'); RMTemplate::get()->add_style('forms.css', 'rmcommon'); RMTemplate::get()->add_local_script('jquery-ui.min.js', 'rmcommon', 'include'); if (!$rmc_config['blocks_enable']) { showMessage(__('Internal blocks manager is currenlty disabled!', 'rmcommon'), 0); } RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include'); RMTemplate::get()->add_head('<script type="text/javascript">var bks_message = "' . __('Do you really wish to delete selected items?', 'rmcommon') . '"; var bks_select_message = "' . __('Select at least one item to delete it!', 'rmcommon') . '"; var lang_save = "' . __('Save', 'rmcommon') . '"; var lang_cancel = "' . __('Cancel', 'rmcommon') . '"; var lang_positions = "' . __('Show Positions', 'rmcommon') . '"; var lang_blocks = "' . __('Show Blocks', 'rmcommon') . '";</script>'); RMFunctions::create_toolbar(); xoops_cp_header(); // Available Widgets $blocks = RMBlocksFunctions::get_available_list($modules); foreach ($blocks as $id => $block) { if (empty($block['blocks'])) { continue; } foreach ($block['blocks'] as $bid => $val) { $str = isset($val['show_func']) ? $val['show_func'] : ''; $str .= isset($val['edit_func']) ? $val['edit_func'] : ''; $str .= isset($val['dir']) ? $val['dir'] : $id; $val['id'] = md5($str); $blocks[$id]['blocks'][$bid] = $val; } } // Position $the_position = isset($_GET['pos']) ? intval($_GET['pos']) : ''; // Parameters $mid = rmc_server_var($_GET, 'mid', 0); $subpage = isset($_GET['subpage']) ? $_GET['subpage'] : ''; $group = isset($_GET['group']) ? intval($_GET['group']) : 0; $visible = rmc_server_var($_GET, 'visible', -1); $pid = rmc_server_var($_GET, 'pos', 0); include RMTemplate::get()->get_template("rmc_blocks.php", 'module', 'rmcommon'); xoops_cp_footer(); }
/** * This function allos to insert a new block in database */ function insertBlock() { global $xoopsSecurity; $mod = rmc_server_var($_POST, 'module', ''); $id = rmc_server_var($_POST, 'block', ''); $token = rmc_server_var($_POST, 'XOOPS_TOKEN_REQUEST', ''); $canvas = rmc_server_var($_POST, 'canvas', ''); if (!$xoopsSecurity->check()) { response(array('message' => __('Sorry, you are not allowed to view this page', 'rmcommon')), 1, 0); die; } if ($mod == '' || $id == '') { $data = array('message' => __('The block specified seems to be invalid. Please try again.', 'rmcommon')); response($data, 1, 0); } $module = RMFunctions::load_module($mod); if (!$module) { response(array('message' => __('The specified module does not exists!', 'rmcommon')), 1, 0); } $module->loadInfoAsVar($mod); $blocks = $module->getInfo('blocks'); $ms = $module->name() . '<br />'; $found = false; foreach ($blocks as $bk) { $str = isset($bk['show_func']) ? $bk['show_func'] : ''; $str .= isset($bk['edit_func']) ? $bk['edit_func'] : ''; $str .= isset($bk['dir']) ? $bk['dir'] : $mod; $idb = md5($str); if ($idb == $id) { $found = true; break; } } if (!$found) { response(array('message' => __('The specified block does not exists, please verify your selection.', 'rmcommon')), 1, 1); } $block = new RMInternalBlock(); if ($canvas <= 0) { $db = XoopsDatabaseFactory::getDatabaseConnection(); // Get a default side $sql = "SELECT id_position, name FROM " . $db->prefix("rmc_blocks_positions") . " ORDER BY id_position LIMIT 0, 1"; $result = $db->query($sql); if ($result) { list($canvas, $canvas_name) = $db->fetchRow($result); } } $block->setReadGroups(array(0)); $block->setVar('name', $bk['name']); $block->setVar('element', $mod); $block->setVar('element_type', $bk['plugin'] == 1 ? 'plugin' : 'module'); $block->setVar('canvas', $canvas); $block->setVar('visible', 0); $block->setVar('type', $bk['type']); $block->setVar('isactive', 1); $block->setVar('dirname', isset($bk['dir']) ? $bk['dir'] : $mod); $block->setVar('file', $bk['file']); $block->setVar('show_func', $bk['show_func']); $block->setVar('edit_func', $bk['edit_func']); $block->setVar('description', $bk['description']); $block->setVar('widget', $id); $block->setVar('options', is_array($bk['options']) ? serialize($bk['options']) : serialize(explode("|", $bk['options']))); $block->setVar('template', $bk['template']); $block->sections(array(0)); if (!$block->save()) { response(array('message' => sprintf(__('Block could not be created due to: %s. Please try again!', 'rmcommon'), $block->errors())), 1, 1); } RMEvents::get()->run_event('rmcommon.block.added', $block); $pos = RMBlocksFunctions::block_positions(); $ret = array('id' => $block->id(), 'name' => $block->getVar('name'), 'module' => $block->getVar('element'), 'description' => $block->getVar('description'), 'canvas' => $pos[$canvas], 'weight' => $block->getVar('weight'), 'message' => __('Block added successfully! Please configure it.', 'rmcommon')); response($ret, 0, 1); die; }