Beispiel #1
0
                            if (!$moduleperm_handler->checkRight('module_read', $module->getVar('mid'), $groupid)) {
                                $moduleperm_handler->addRight('module_read', $module->getVar('mid'), $groupid);
                            }
                        }
                        $startmod_updated = true;
                    }
                    $config->setConfValueForInput($new_value);
                    $config_handler->insertConfig($config);
                }
                unset($new_value);
            }
        }
        if (!empty($use_mysession) && $xoopsConfig['use_mysession'] == 0 && $session_name != '') {
            setcookie($session_name, session_id(), time() + 60 * intval($session_expire), '/', '', 0);
        }
        // Clean cached files, may take long time
        // User reigister_shutdown_function to keep running after connection closes so that cleaning cached files can be finished
        // Cache management should be performed on a separate page
        register_shutdown_function(array(&$xoopsTpl, 'clear_all_cache'));
        if ($lang_updated) {
            // Flush cache files for cpanel GUIs
            xoops_load("cpanel", "system");
            XoopsSystemCpanel::flush();
        }
        if (isset($redirect) && $redirect != '') {
            redirect_header($redirect, 2, _MD_AM_DBUPDATED);
        } else {
            redirect_header("admin.php?fct=preferences", 2, _MD_AM_DBUPDATED);
        }
    }
}
/**
 * CP Footer
 *
 */
function xoops_cp_footer()
{
    xoops_load('cpanel', 'system');
    $cpanel =& XoopsSystemCpanel::getInstance();
    $cpanel->gui->footer();
}
Beispiel #3
0
 /**
  * Flush the Xoops Admin Gui
  *
  */
 function flush()
 {
     $guis = XoopsSystemCpanel::getGuis();
     foreach ($guis as $gui) {
         if ($file = XOOPS_ADMINTHEME_PATH . '/' . $gui . '/' . $gui . '.php') {
             include_once $file;
             if (class_exists($class = 'XoopsGui' . ucfirst($gui))) {
                 call_user_func(array($class, 'flush'));
             }
         }
     }
 }
Beispiel #4
0
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;
}
Beispiel #5
0
 /**
  * Flush the Xoops Admin Gui
  *
  */
 function flush()
 {
     $guis = XoopsSystemCpanel::getGuis();
     foreach ($guis as $gui) {
         if ($file = dirname(__FILE__) . '/gui/' . $gui . '/' . $gui . '.php') {
             include_once $file;
             if (class_exists($class = 'XoopsGui' . ucfirst($gui))) {
                 call_user_func(array($class, 'flush'));
             }
         }
     }
 }
Beispiel #6
0
 /**
  * Prepares the form field that will be shown on settings form
  * and returns the HTML code.
  * <br><br>
  * <p><strong>Usage:</strong></p>
  * <code>echo RMSettings::render_field( string 'field_id', array $field );</code>
  *
  * @param stdClass $field <p>An object with all field values, including caption, id, description, type, value, etc.</p>
  * @return string
  */
 public static function render_field($field)
 {
     if (empty($field)) {
         return null;
     }
     $tc = TextCleaner::getInstance();
     switch ($field->field) {
         case 'textarea':
             if ($field->type == 'array') {
                 // this is exceptional.. only when value type is arrayneed a smarter way for this
                 $ele = $field->value != '' ? new RMFormTextArea($field->caption, $field->name, 4, 45, $tc->specialchars(implode('|', $field->value))) : new RMFormTextArea($field->title, $field->name, 4, 45);
             } else {
                 $ele = new RMFormTextArea($field->caption, $field->name, 4, 50, $tc->specialchars($field->value));
             }
             break;
         case 'select':
             $ele = new RMFormSelect($field->caption, $field->name, 0, array($field->value));
             foreach ($field->options as $caption => $value) {
                 $ele->addOption($value, defined($caption) ? constant($caption) : $caption);
             }
             break;
         case 'select_multi':
             $ele = new RMFormSelect($field->caption, $field->name, 1, array($field->value));
             $options = $field->options;
             foreach ($options as $value => $caption) {
                 $value = defined($value) ? constant($value) : $value;
                 $caption = defined($caption) ? constant($caption) : $caption;
                 $ele->addOption($value, $caption);
             }
             break;
         case 'yesno':
             $ele = new RMFormYesNo($field->caption, $field->name, $field->value);
             break;
         case 'theme':
         case 'theme_multi':
             $ele = new RMFormTheme($field->caption, $field->name, $field->field == 'theme_multi' ? 1 : 0, 0, $field->value);
             break;
         case 'cu-theme':
         case 'cu-theme-multi':
             $ele = new RMFormTheme($field->caption, $field->name, $field->field == 'cu-theme-multi' ? 1 : 0, 0, $field->value, 1, 'GUI');
             break;
         case 'tplset':
             $ele = new RMFormSelect($field->caption, $field->name, 0, array($field->value));
             $tplset_handler =& xoops_gethandler('tplset');
             $tplsetlist = $tplset_handler->getList();
             asort($tplsetlist);
             foreach ($tplsetlist as $key => $name) {
                 $ele->addOption($key, $name);
             }
             break;
         case 'cpanel':
             $ele = new RMFormSelect($field->caption, $field->name, 0, array($field->value));
             xoops_load("cpanel", "system");
             $list = XoopsSystemCpanel::getGuis();
             $ele->addOptionArray($list);
             break;
         case 'timezone':
             $ele = new RMFormTimeZoneField($field->caption, $field->name, 0, 0, $field->value);
             break;
         case 'language':
         case 'language_multi':
             $langs = XoopsLists::getLangList();
             $ele = new RMFormSelect($field->caption, $field->name, $field->field == 'language_multi' ? 1 : 0, $field->value);
             foreach ($langs as $caption => $value) {
                 $ele->addOption($value, $caption);
             }
             break;
         case 'cu-language':
         case 'cu-language-multi':
             $ele = new RMFormLanguageField($field->caption, $field->name, $field->field == 'cu-language-multi' ? 1 : 0, 0, $field->value);
             break;
         case 'startpage':
             $ele = new RMFormSelect($field->caption, $field->name, 0, array($field->value));
             $module_handler =& xoops_gethandler('module');
             $criteria = new CriteriaCompo(new Criteria('hasmain', 1));
             $criteria->add(new Criteria('isactive', 1));
             $moduleslist = $module_handler->getList($criteria, true);
             $moduleslist['--'] = _MD_AM_NONE;
             $ele->addOptionsArray($moduleslist);
             break;
         case 'group':
         case 'group_multi':
             $ele = new RMFormGroups($field->caption, $field->name, $field->field == 'group_multi' ? 1 : 0, 0, 1, $field->value);
             break;
         case 'user':
         case 'user_multi':
             $ele = new RMFormUser($field->caption, $field->name, $field->field == 'user_multi' ? 1 : 0, $field->value);
             break;
         case 'module_cache':
             $ele = new RMFormCacheModuleField($field->caption, $field->name, $field->value);
             break;
         case 'site_cache':
             $ele = new RMFormSelect($field->caption, $field->name, 0, $field->value);
             $ele->addOptionArray(array('0' => __('No cache', 'rmcommon'), '30' => sprintf(__('%u seconds', 'rmcommon'), 30), '60' => __('1 minute', 'rmcommon'), '300' => sprintf(__('%u minutes', 'rmcommon'), 5), '1800' => sprintf(__('%u minutes', 'rmcommon'), 30), '3600' => __('One hour', 'rmcommon'), '18000' => sprintf(__('%u hours', 'rmcommon'), 5), '86400' => __('One day', 'rmcommon'), '259200' => sprintf(__('%u days', 'rmcommon'), 3), '604800' => __('One week', 'rmcommon')));
             break;
         case 'password':
             $ele = new RMFormText($field->caption, $field->name, 50, 255, $field->value, true);
             break;
         case 'hidden':
             $ele = new RMFormHidden($field->name, $field->value);
             break;
         case 'modules-rewrite':
             $ele = new RMFormRewrite($field->caption, $field->name, $field->value);
             break;
         case 'textbox':
         default:
             $ele = new RMFormText($field->caption, $field->name, 50, 255, $tc->specialchars($field->value));
             break;
     }
     /**
      * Allow to plugins and other modules create new form
      * elements types in settings form
      */
     $ele = RMEvents::get()->trigger('rmcommon.load.form.field', $ele, $field);
     $ele->set('id', $field->id);
     $ele->add('class', 'form-control');
     return $ele->render();
 }
Beispiel #7
0
function xoops_cp_footer()
{
    xoops_load("cpanel", "system");
    $cpanel =& XoopsSystemCpanel::getInstance();
    $cpanel->gui->footer();
}