예제 #1
0
function asb_build_cache(&$asb)
{
    global $db;
    // fresh start
    $asb['custom'] = $asb['sideboxes'] = $asb['scripts'] = $asb['all_scripts'] = array();
    // update the run time and changed flag before we even start
    $asb['last_run'] = TIME_NOW;
    $asb['has_changed'] = false;
    // all the general side box related objects
    require_once MYBB_ROOT . 'inc/plugins/asb/classes/forum.php';
    // get all the active scripts' info
    $all_scripts = asb_get_all_scripts();
    // no scripts, no work to do
    if (!is_array($all_scripts) || empty($all_scripts)) {
        return;
    }
    // store the script definitions and a master list
    foreach ($all_scripts as $filename => $script) {
        $asb['scripts'][$filename] = $script;
    }
    $asb['all_scripts'] = array_keys($all_scripts);
    // load all detected modules
    $addons = asb_get_all_modules();
    // get any custom boxes
    $custom = asb_get_all_custom();
    // get any sideboxes
    $sideboxes = asb_get_all_sideboxes();
    if (!is_array($sideboxes) || empty($sideboxes)) {
        return;
    }
    foreach ($sideboxes as $sidebox) {
        // build basic data
        $scripts = $sidebox->get('scripts');
        $id = (int) $sidebox->get('id');
        $pos = $sidebox->get('position') ? 1 : 0;
        $asb['sideboxes'][$id] = $sidebox->get('data');
        $module = $sidebox->get('box_type');
        // no scripts == all scripts
        if (empty($scripts)) {
            // add this side box to the 'global' set (to be merged with the current script when applicable)
            $scripts = array('global');
        }
        // for each script in which the side box is used, add a pointer and if it is a custom box, cache its contents
        foreach ($scripts as $filename) {
            // side box from a module?
            if (isset($addons[$module]) && $addons[$module] instanceof Addon_type) {
                // store the module name and all the template vars used
                $asb['scripts'][$filename]['sideboxes'][$pos][$id] = $module;
                $asb['scripts'][$filename]['template_vars'][$id] = "{$module}_{$id}";
                // if there are any templates get their names so we can cache them
                $templates = $addons[$module]->get('templates');
                if (is_array($templates) && !empty($templates)) {
                    foreach ($templates as $template) {
                        $asb['scripts'][$filename]['templates'][] = $template['title'];
                    }
                }
                // AJAX?
                if ($addons[$module]->xmlhttp && $sidebox->has_settings) {
                    $settings = $sidebox->get('settings');
                    // again, default here is off if anything goes wrong
                    if ($settings['xmlhttp_on']) {
                        // if all is good add the script building info
                        $asb['scripts'][$filename]['extra_scripts'][$id]['position'] = $pos;
                        $asb['scripts'][$filename]['extra_scripts'][$id]['module'] = $module;
                        $asb['scripts'][$filename]['extra_scripts'][$id]['rate'] = $settings['xmlhttp_on'];
                    }
                }
                if ($addons[$module]->has_scripts) {
                    foreach ($addons[$module]->get('scripts') as $script) {
                        $asb['scripts'][$filename]['js'][$script] = $script;
                    }
                }
            } else {
                if (isset($custom[$module]) && $custom[$module] instanceof Custom_type) {
                    // store the pointer
                    $asb['scripts'][$filename]['sideboxes'][$pos][$id] = $module;
                    $asb['scripts'][$filename]['template_vars'][$id] = "{$module}_{$id}";
                    // and cache the contents
                    $asb['custom'][$module] = $custom[$module]->get('data');
                }
            }
        }
    }
}
예제 #2
0
function asb_admin_manage_modules()
{
    global $lang, $mybb, $db, $page, $html, $min;
    $page->extra_header .= <<<EOF
\t<link rel="stylesheet" type="text/css" href="styles/asb_acp.css" media="screen" />
\t<script src="jscripts/asb/asb{$min}.js" type="text/javascript"></script>

EOF;
    $page->add_breadcrumb_item($lang->asb, $html->url());
    $page->add_breadcrumb_item($lang->asb_manage_modules);
    $page->output_header("{$lang->asb} - {$lang->asb_manage_modules}");
    asb_output_tabs('asb_modules');
    $table = new Table();
    $table->construct_header($lang->asb_name, array("width" => '22%'));
    $table->construct_header($lang->asb_description, array("width" => '55%'));
    $table->construct_header($lang->asb_modules_author, array("width" => '15%'));
    $table->construct_header($lang->asb_controls, array("width" => '8%'));
    $addons = asb_get_all_modules();
    // if there are installed modules display them
    if (!empty($addons) && is_array($addons)) {
        foreach ($addons as $this_module) {
            $data = $this_module->get(array('title', 'description', 'base_name', 'author', 'author_site', 'module_site', 'version', 'public_version', 'compatibility'));
            $out_of_date = '';
            if (!$data['compatibility'] || version_compare('2.1', $data['compatibility'], '<')) {
                $out_of_date = <<<EOF
<br /><span style="color: red;">{$lang->asb_module_out_of_date}</span>
EOF;
            }
            $version = $data['version'];
            if ($data['public_version']) {
                $version = $data['public_version'];
            }
            // title
            $table->construct_cell($html->link($data['module_site'], $data['title'], array("style" => 'font-weight: bold;')) . " ({$version})");
            // description
            $table->construct_cell($data['description'] . $out_of_date);
            if ($data['author'] == 'Wildcard') {
                $data['author'] = 'default';
            }
            $author = $data['author'];
            if ($data['author_site']) {
                $author = $html->link($data['author_site'], $data['author'], array("style" => 'font-weight: bold;'));
            }
            // author
            $table->construct_cell($author);
            // options pop-up
            $popup = new PopupMenu('module_' . $data['base_name'], $lang->asb_options);
            // delete
            $popup->add_item($lang->asb_delete, $html->url(array("action" => 'delete_addon', "addon" => $data['base_name'])), "return confirm('{$lang->asb_modules_del_warning}');");
            // pop-up cell
            $table->construct_cell($popup->fetch(), array("width" => '10%'));
            // finish row
            $table->construct_row();
        }
    } else {
        $table->construct_cell("<span style=\"color: gray;\">{$lang->asb_no_modules_detected}</span>", array("colspan" => 3));
        $table->construct_row();
    }
    $table->output($lang->asb_addon_modules);
    // build link bar and ACP footer
    asb_output_footer('addons');
}
예제 #3
0
function asb_uninstall()
{
    if (!defined('IN_ASB_UNINSTALL')) {
        define('IN_ASB_UNINSTALL', true);
    }
    global $mybb;
    require_once MYBB_ROOT . 'inc/plugins/asb/classes/module.php';
    // remove the modules first
    $addons = asb_get_all_modules();
    // if there are add-on modules installed
    if (is_array($addons)) {
        // uninstall them
        foreach ($addons as $addon) {
            $addon->uninstall();
        }
    }
    require_once MYBB_ROOT . 'inc/plugins/asb/functions_install.php';
    if (!class_exists('WildcardPluginInstaller')) {
        require_once MYBB_ROOT . 'inc/plugins/asb/classes/installer.php';
    }
    $installer = new WildcardPluginInstaller(MYBB_ROOT . 'inc/plugins/asb/install_data.php');
    $installer->uninstall();
    // delete our cached version
    asb_unset_cache_version();
}