示例#1
0
function cache_view_files()
{
    global $xoopsSecurity;
    RMTemplate::get()->set_help('http://redmexico.com.mx/docs/xoops-booster/archivos-del-cache');
    RMTemplate::get()->assign('xoops_pagetitle', __('Booster Zone', 'booster'));
    RMTemplate::get()->add_style('cache.css', 'rmcommon', 'plugins/booster');
    RMFunctions::create_toolbar();
    xoops_cp_header();
    $plugin = RMFunctions::get()->load_plugin('booster');
    // Get files
    $items = XoopsLists::getFileListAsArray(XOOPS_CACHE_PATH . '/booster/files');
    $files = array();
    $count_expired = 0;
    foreach ($items as $file) {
        $tmp = explode('.', $file);
        if ($tmp[1] != 'meta') {
            continue;
        }
        $content = json_decode(file_get_contents(XOOPS_CACHE_PATH . '/booster/files/' . $file), true);
        $files[] = array('id' => $tmp[0], 'url' => $content['uri'], 'date' => formatTimestamp($content['created'], 'l'), 'time' => $content['created'], 'lang' => $content['language'], 'size' => filesize(XOOPS_CACHE_PATH . '/booster/files/' . $tmp[0] . '.html'));
        $count_expired = time() - $content['created'] >= $plugin->get_config('time') ? $count_expired + 1 : $count_expired;
    }
    include RMTemplate::get()->get_template('cache_files.php', 'plugin', 'rmcommon', 'booster');
    xoops_cp_footer();
}
示例#2
0
function show_dashboard()
{
    global $xoopsModule;
    RMFunctions::create_toolbar();
    $db = Database::getInstance();
    $sql = 'SELECT * FROM ' . $db->prefix('modules');
    $result = $db->query($sql);
    $installed_mods = array();
    while ($row = $db->fetchArray($result)) {
        $installed_mods[] = $row['dirname'];
    }
    require_once XOOPS_ROOT_PATH . "/class/xoopslists.php";
    $dirlist = XoopsLists::getModulesList();
    $available_mods = array();
    $module_handler =& xoops_gethandler('module');
    $i = 0;
    foreach ($dirlist as $file) {
        if ($i > 5) {
            break;
        }
        clearstatcache();
        $file = trim($file);
        if (!in_array($file, $installed_mods)) {
            $module =& $module_handler->create();
            if (!$module->loadInfo($file, false)) {
                continue;
            }
            $available_mods[] = $module;
        }
        $i++;
    }
    xoops_cp_header();
    RMTemplate::get()->add_style('dashboard.css', 'rmcommon');
    RMTemplate::get()->add_script(RMCURL . '/include/js/dashboard.js');
    RMTemplate::get()->add_style('pagenav.css', 'rmcommon');
    RMTemplate::get()->set_help('http://redmexico.com.mx/docs/common-utilities');
    include RMTemplate::get()->get_template('rmc_dashboard.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
示例#3
0
function module_update_now()
{
    global $xoopsSecurity, $xoopsConfig;
    $mod = rmc_server_var($_POST, 'module', '');
    if (!$xoopsSecurity->check()) {
        redirectMsg('modules.php', __('Sorry, this operation could not be completed!', 'rmcommon'), 1);
        die;
    }
    $module_handler = xoops_gethandler('module');
    $module = $module_handler->getByDirname($mod);
    if (!$module) {
        redirectMsg('modules.php', sprintf(__('Module %s is not installed yet!', 'rmcommon'), $mod), 1);
        die;
    }
    $file = XOOPS_ROOT_PATH . '/modules/system/language/' . $xoopsConfig['language'] . '/admin/modulesadmin.php';
    if (file_exists($file)) {
        include_once $file;
    } else {
        include_once str_replace($xoopsConfig['language'], 'english', $file);
    }
    include_once XOOPS_ROOT_PATH . '/modules/system/admin/modulesadmin/modulesadmin.php';
    RMEvents::get()->run_event('rmcommon.updating.module', $module);
    $module_log = xoops_module_update($mod);
    $module_log = RMEvents::get()->run_event('rmcommon.module.updated', $module_log, $module_log);
    RMFunctions::create_toolbar();
    RMTemplate::get()->add_style('modules.css', 'rmcommon');
    xoops_cp_header();
    $log_title = sprintf(__('Update log for %s', 'rmcommon'), $module ? $module->getInfo('name') : $mod);
    $action = rmc_server_var($_POST, 'action', '');
    include RMTemplate::get()->get_template('rmc_mod_log.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
示例#4
0
function configure_rm_plugin()
{
    $name = rmc_server_var($_GET, 'plugin', '');
    if ($name == '') {
        redirectMsg('plugins.php', __('You must specify a existing plugin', 'rmcommon'), 1);
        die;
    }
    $plugin = new RMPlugin($name);
    if ($plugin->isNew()) {
        redirectMsg('plugins.php', __('Specified plugin is not installed yet!', 'rmcommon'), 1);
        die;
    }
    if (!$plugin->getVar('status')) {
        redirectMsg('plugins.php', __('Specified plugin is not active!', 'rmcommon'), 1);
        die;
    }
    $rmc_config = RMFunctions::configs();
    $settings = RMFunctions::get()->plugin_settings($name, true);
    $form = new RMForm(sprintf(__('%s configuration', 'rmcommon'), $plugin->getVar('name')), 'frmconfig', 'plugins.php');
    $form->addElement(new RMFormHidden('plugin', $plugin->getVar('dir')));
    $form->addElement(new RMFormHidden('action', 'savesettings'));
    foreach ($plugin->options() as $config => $option) {
        if (isset($settings[$config])) {
            $option['value'] = $settings[$config];
        }
        if (isset($option['separator']) && !empty($option['separator'])) {
            $form->addElement(new RMFormSubTitle($option['separator']['title'], 1, '', $option['separator']['desc']));
            continue;
        }
        switch ($option['fieldtype']) {
            case 'checkbox_groups':
            case 'group_multi':
                $ele = new RMFormGroups($option['caption'], 'conf_' . $config, 1, 1, 3, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'radio_groups':
                $ele = new RMFormGroups($option['caption'], 'conf_' . $config, 0, 1, 3, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'group':
            case 'select_groups':
                $ele = new RMFormGroups($option['caption'], 'conf_' . $config, 0, 0, 3, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_groups_multi':
                $ele = new RMFormGroups($option['caption'], 'conf_' . $config, 1, 0, 3, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'editor':
                if ($rmc_config['editor_type'] == 'tiny') {
                    $tiny = TinyEditor::getInstance();
                    $tiny->add_config('elements', 'conf_' . $config);
                }
                $ele = new RMFormEditor($option['caption'], 'conf_' . $config, is_numeric($option['size']) ? '90%' : $option['size'], '300px', $option['value'], '', 1, array('op'));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'theme':
            case 'select_theme':
                $ele = new RMFormTheme($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'theme_multi':
            case 'select_theme_multi':
                $ele = new RMFormTheme($option['caption'], 'conf_' . $config, 0, 1, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'checkbox_theme':
                $ele = new RMFormTheme($option['caption'], 'conf_' . $config, 1, 1, $option['value'], 4);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_theme_admin':
                $ele = new RMFormTheme($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3, 'GUI');
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'yesno':
                $ele = new RMFormYesNo($option['caption'], 'conf_' . $config, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'email':
                $ele = new RMFormText($option['caption'], 'conf_' . $config, $option['size'] > 0 ? $option['size'] : 50, null, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele, false, 'email');
                break;
            case 'select':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                foreach ($option['options'] as $op => $opvalue) {
                    $ele->addOption($opvalue, $op, $opvalue == $option['value'] ? 1 : 0);
                }
                $form->addElement($ele);
                break;
            case 'select_multi':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config . '[]', 1, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                foreach ($option['options'] as $op => $opvalue) {
                    $ele->addOption($opvalue, $op);
                }
                $form->addElement($ele);
                break;
            case 'language':
            case 'select_language':
                $ele = new RMFormLanguageField($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_language_multi':
                $ele = new RMFormLanguageField($option['caption'], 'conf_' . $config, 1, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'checkbox_language':
                $ele = new RMFormLanguageField($option['caption'], 'conf_' . $config, 1, 1, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'startpage':
            case 'select_modules':
                $ele = new RMFormModules($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3);
                $ele->setInserted(array('--' => __('None', 'rmcommon')));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_modules_multi':
                $ele = new RMFormModules($option['caption'], 'conf_' . $config, 1, 0, $option['value'], 3);
                $ele->setInserted(array('--' => __('None', 'rmcommon')));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'checkbox_modules':
                $ele = new RMFormModules($option['caption'], 'conf_' . $config, 1, 1, $option['value'], 3);
                $ele->setInserted(array('--' => __('None', 'rmcommon')));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'radio_modules':
                $ele = new RMFormModules($option['caption'], 'conf_' . $config, 0, 1, $option['value'], 3);
                $ele->setInserted(array('--' => __('None', 'rmcommon')));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'timezone':
            case 'select_timezone':
                $ele = new RMFormTimeZoneField($option['caption'], 'conf_' . $config, 0, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'select_timezone_multi':
                $ele = new RMFormTimeZoneField($option['caption'], 'conf_' . $config, 0, 1, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'checkbox_timezone':
                $ele = new RMFormTimeZoneField($option['caption'], 'conf_' . $config, 1, 1, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'radio_timezone':
                $ele = new RMFormTimeZoneField($option['caption'], 'conf_' . $config, 1, 0, $option['value'], 3);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'tplset':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config);
                $tplset_handler =& exm_gethandler('tplset');
                $tplsetlist =& $tplset_handler->getList();
                asort($tplsetlist);
                foreach ($tplsetlist as $key => $name) {
                    $ele->addOption($key, $name, $option['value'] == $key ? 1 : 0);
                }
                $form->addElement($ele);
                break;
            case 'textarea':
                $ele = new RMFormTextArea($option['caption'], 'conf_' . $config, 5, $option['size'] > 0 ? $option['size'] : 50, $option['valuetype'] == 'array' ? $cleaner->htmlspecialchars(implode('|', $option['value'])) : $cleaner->htmlspecialchars($option['value']));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'module_cache':
                $ele = new RMFormCacheModuleField($option['caption'], 'conf_' . $config, $option['value']);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'user_select':
                $ele = new RMFormUser($option['caption'], 'conf_' . $config, $form->getName(), $option['value'], 'select', $limit = '300', '');
                $ele->setOnPage("document.forms[0].op.value='config';");
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele);
                break;
            case 'radio':
                $ele = new RMFormRadio($option['caption'], 'conf_' . $config, 1);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                foreach ($option['options'] as $op => $opvalue) {
                    $ele->addOption($op, $opvalue, $opvalue == $option['value'] ? 1 : 0);
                }
                $form->addElement($ele);
                break;
            case 'font_select':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config, 0, array($option['value']));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $fonts = EXMLists::getFileListAsArray(ABSPATH . '/rmcommon/fonts/');
                foreach ($fonts as $font) {
                    $info = pathinfo(ABSPATH . '/rmcommon/fonts/' . $font);
                    if (strtoupper($info['extension']) != 'TTF') {
                        continue;
                    }
                    $ele->addOption($font, $font);
                }
                $form->addElement($ele);
                break;
            case 'select_editor':
                $ele = new RMFormSelect($option['caption'], 'conf_' . $config, 0, array($option['value']));
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $ele->addOption('tiny', __('Visual Editor', 'rmcommon'));
                $ele->addOption('code', __('EXMCode Editor', 'rmcommon'));
                $ele->addOption('textarea', __('Simple Editor', 'rmcommon'));
                $ele->addOption('html', __('HTML Editor', 'rmcommon'));
                $form->addElement($ele);
                break;
            case 'textbox':
            case 'password':
            default:
                $ele = new RMFormText($option['caption'], 'conf_' . $config, $option['size'] > 0 ? $option['size'] : 50, null, $option['valuetype'] == 'array' ? implode('|', $option['value']) : $option['value'], $option['fieldtype'] == 'password' ? 1 : 0);
                if ($option['desc'] != '') {
                    $ele->setDescription($option['desc']);
                }
                $form->addElement($ele, false, $option['valuetype'] == 'int' || $option['valuetype'] == 'float' ? 'num' : '');
                break;
        }
    }
    $ele = new RMFormButtonGroup();
    $ele->addButton('', __('Save Settings', 'rmcommon'), 'submit');
    $ele->addButton('', __('Cancel', 'rmcommon'), 'button', 'onclick="history.go(-1);"');
    $form->addElement($ele);
    // Other components can add items to database
    $form = RMEvents::get()->run_event("rmcommon.settings.form", $form, $plugin);
    RMFunctions::create_toolbar();
    xoops_cp_header();
    $form->display();
    xoops_cp_footer();
}
示例#5
0
/**
* Update image thumbnails
*/
function update_thumbnails()
{
    global $xoopsUser, $xoopsSecurity;
    $cat = new RMImageCategory(rmc_server_var($_POST, 'category', 0));
    $imgs = rmc_server_var($_POST, 'imgs', array());
    $ids = implode(',', $imgs);
    RMTemplate::get()->add_style('imgmgr.css', 'rmcommon');
    RMTemplate::get()->add_script('include/js/images.js');
    xoops_cp_header();
    RMFunctions::create_toolbar();
    $isupdate = true;
    RMTemplate::get()->add_head("<script type='text/javascript'>\n    \$(document).ready(function(){\n        ids = [{$ids}];\n        total = " . count($imgs) . ";\n        \$('#resizer-bar').show('slow');\n        \$('#resizer-bar').effect('highlight',{},1000);\n        \$('#gen-thumbnails').show();\n        \n        var increments = 1/total*100;\n        url = '" . RMCURL . "/images.php';\n            \n        params = '" . TextCleaner::getInstance()->encrypt($xoopsUser->uid() . '|' . RMCURL . '/images.php' . '|' . $xoopsSecurity->createToken(), true) . "';\n        resize_image(params);\n    });</script>");
    include RMTemplate::get()->get_template('images_uploadimages.php', 'module', 'rmcommon');
    xoops_cp_footer();
}
示例#6
0
function edit_comment()
{
    $id = rmc_server_var($_GET, 'id', 0);
    $page = rmc_server_var($_GET, 'page', 1);
    $filter = rmc_server_var($_GET, 'filter', '');
    $w = rmc_server_var($_GET, 'w', '1');
    $qs = "w={$w}&page={$page}&filter={$filter}";
    if ($id <= 0) {
        redirectMsg('comments.php?' . $qs, __('Sorry, comment id is not valid', 'rmcommon'), 1);
        die;
    }
    $comment = new RMComment($id);
    if ($comment->isNew()) {
        redirectMsg('comments.php?' . $qs, __('Sorry, comment does not found', 'rmcommon'), 1);
        die;
    }
    $cpath = XOOPS_ROOT_PATH . '/modules/' . $comment->getVar('id_obj') . '/class/' . $comment->getVar('id_obj') . 'controller.php';
    if (is_file($cpath)) {
        include $cpath;
        $class = ucfirst($comment->getVar('id_obj')) . 'Controller';
        $controller = new $class();
    }
    $form = new RMForm(__('Edit Comment', 'rmcommon'), 'editComment', 'comments.php');
    $form->addElement(new RMFormLabel(__('In reply to', 'rmcommon'), $controller ? $controller->get_item($comment->getVar('params'), $comment) : ''));
    $form->addElement(new RMFormLabel(__('Posted date', 'rmcommon'), formatTimestamp($comment->getVar('posted'), 'mysql')));
    $form->addElement(new RMFormLabel(__('Module', 'rmcommon'), $comment->getVar('id_obj')));
    $form->addElement(new RMFormLabel(__('IP', 'rmcommon'), $comment->getVar('ip')));
    $user = new RMCommentUser($comment->getVar('user'));
    $ele = new RMFormUser(__('Poster', 'rmcommon'), 'user', false, $user->getVar('xuid') > 0 ? $user->getVar('xuid') : 0);
    $form->addElement($ele);
    $ele = new RMFormRadio(__('Status', 'rmcommon'), 'status', 1, 0, 2);
    $ele->addOption(__('Approved', 'rmcommon'), 'approved', $comment->getVar('status') == 'approved' ? 1 : 0);
    $ele->addOption(__('Unapproved', 'rmcommon'), 'waiting', $comment->getVar('status') == 'waiting' ? 1 : 0);
    $form->addElement($ele);
    $form->addElement(new RMFormTextArea(__('Content', 'rmcommon'), 'content', null, null, $comment->getVar('content', 'e'), '100%', '150px'), true);
    $form->addElement(new RMFormHidden('page', $page));
    $form->addElement(new RMFormHidden('filter', $filter));
    $form->addElement(new RMFormHidden('w', $w));
    $form->addElement(new RMFormHidden('id', $id));
    $form->addElement(new RMFormHidden('action', 'save'));
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', __('Update Comment', 'rmcommon'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'rmcommon'), 'button', 'onclick="history.go(-1);"');
    $form->addElement($ele);
    RMFunctions::create_toolbar();
    xoops_cp_header();
    $form->display();
    xoops_cp_footer();
}
示例#7
0
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> &raquo; ' . __('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();
}
示例#8
0
function user_form($edit = false)
{
    global $rmTpl;
    define('RMCSUBLOCATION', 'newuser');
    $query = rmc_server_var($_GET, 'query', '');
    $query = $query == '' ? '' : base64_decode($query);
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    if ($edit) {
        $uid = rmc_server_var($_GET, 'uid', 0);
        if ($uid <= 0) {
            redirectMsg('users.php?' . $query, __('The specified user is not valid!', 'rmcommon'), 1);
        }
        $uh = new XoopsUserHandler($db);
        $user = $uh->get($uid);
        if ($user->isNew()) {
            redirectMsg('users.php?' . $query, __('The specified user does not exists!', 'rmcommon'), 1);
        }
    }
    RMFunctions::create_toolbar();
    RMBreadCrumb::get()->add_crumb(__('Users Management', 'rmcommon'), 'users.php');
    RMBreadCrumb::get()->add_crumb($edit ? __('Edit User', 'rmcommon') : __('Add User', 'rmcommon'));
    $rmTpl->assign('xoops_pagetitle', $edit ? __('Edit User', 'rmcommon') : __('Add User', 'rmcommon'));
    xoops_cp_header();
    $form = new RMForm(__($edit ? 'Editing User' : 'Add new user', 'rmcommon'), 'user_form', 'users.php');
    // Uname
    $form->addElement(new RMFormText(__('Username', 'rmcommon'), 'uname', 50, 50, $edit ? $user->uname() : ''), true);
    $form->element('uname')->setDescription(__("This field also will be the user login name.", 'rmcommon'));
    // Full Name
    $form->addElement(new RMFormText(__('Full name', 'rmcommon'), 'name', 50, 150, $edit ? $user->name() : ''));
    $form->element('name')->setDescription(__("This field must contain firstname and lastname.", 'rmcommon'));
    // Email
    $form->addElement(new RMFormText(__('Email address', 'rmcommon'), 'email', 50, 150, $edit ? $user->email() : ''), true, 'email');
    // Password
    $form->addElement(new RMFormText(__($edit ? 'New password' : 'Password', 'rmcommon'), 'password', 50, 50, '', true), $edit ? false : true);
    $form->element('password')->setDescription(__('The password should be at least eight characters long. To make it stronger, use upper and lower case letters, numbers and symbols like ! " ? $ % ^ &', 'rmcommon'));
    $form->addElement(new RMFormText(__('Repeat Password', 'rmcommon'), 'passwordc', 50, 50, '', true), $edit ? false : true);
    $form->element('passwordc')->setDescription(__('Type password again.', 'rmcommon'));
    // Web
    $form->addElement(new RMFormText(__('URL (Blog or personal website)', 'rmcommon'), 'url', 50, 250, $edit ? $user->getVar('url') : ''));
    // Timezone
    $form->addElement(new RMFormTimeZoneField(__('Time zone', 'rmcommon'), 'timezone', 0, 0, $edit ? $user->getVar('timezone_offset') : ''));
    // Groups
    $form->addElement(new RMFormGroups(__('Assign to groups', 'rmcommon'), 'groups', 1, 1, 3, $edit ? $user->groups() : ''));
    // Other options by API
    $form = RMEvents::get()->run_event('rmcommon.user.form', $form, $edit, isset($user) ? $user : null);
    // Action
    $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save'));
    if ($edit) {
        $form->addElement(new RMFormHidden('uid', $user->uid()));
    }
    // Submit and cancel buttons
    $ele = new RMFormButtonGroup('');
    $ele->addButton('sbt', __($edit ? 'Edit User' : 'Add user', 'rmcommon'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'global'), 'button', 'onclick="history.go(-1);"');
    $form->addElement($ele);
    $form->display();
    xoops_cp_footer();
}