Ejemplo n.º 1
0
function plugin_init_themes()
{
    global $PLUGIN_HOOKS;
    $PLUGIN_HOOKS['csrf_compliant']['themes'] = true;
    $PLUGIN_HOOKS['change_profile']['themes'] = array('PluginThemesProfile', 'changeProfile');
    $plugin = new Plugin();
    if ($plugin->isInstalled("themes") && $plugin->isActivated("themes")) {
        Plugin::registerClass('PluginThemesProfile', array('addtabon' => 'Profile'));
        Plugin::registerClass('PluginThemesTheme', array('addtabon' => 'Preference'));
        // Default new css and js file.
        if (plugin_themes_haveRight('themes', 'w')) {
            $PLUGIN_HOOKS['menu_entry']["themes"] = "front/themes.php";
            $PLUGIN_HOOKS['submenu_entry']['themes']['search'] = 'front/themes.php';
            $PLUGIN_HOOKS['submenu_entry']['themes']['add'] = 'front/themes.form.php';
        }
        /*** Search for a default theme to display***/
        $activeTheme = new PluginThemesTheme();
        $activeTheme->getFromDB(PluginThemesTheme::getUserTheme());
        if ($activeTheme->fields['name'] != "GLPI") {
            $PLUGIN_HOOKS['add_css']['themes'] = 'front/getfile.php?theme_id=' . $activeTheme->fields['id'] . '&type=css&file=' . $activeTheme->fields['name'] . '.css';
            $PLUGIN_HOOKS['add_javascript']['themes'] = 'front/getfile.php?theme_id=' . $activeTheme->fields['id'] . '&type=js&file=' . $activeTheme->fields['name'] . '.js';
        }
    }
}
Ejemplo n.º 2
0
    $t->getFromDB($_GET['activate']);
    PluginThemesTheme::resetActiveTheme();
    $values = array('id' => $_GET['activate'], 'active_theme' => '1');
    $t->update($values);
    header('location:' . $CFG_GLPI['root_doc'] . '/plugins/themes/front/themes.php');
}
if (isset($_GET['delete']) && PluginThemesTheme::canCreate()) {
    if (!$t->getFromDB($_GET['delete'])) {
        global $CFG_GLPI;
        Session::addMessageAfterRedirect(__('Error while deleting', 'themes'), false, ERROR);
        header('location:' . $CFG_GLPI['root_doc'] . '/plugins/themes/front/themes.php');
    }
    if ($t->fields['active_theme'] == "1") {
        $DB->query("UPDATE glpi_plugin_themes_themes SET active_theme = 1 WHERE name = 'GLPI'");
    }
    if (is_dir(PLUGIN_THEMES_UPLOAD_DIR . "/" . $t->fields['name'])) {
        Toolbox::deleteDir(PLUGIN_THEMES_UPLOAD_DIR . "/" . $t->fields['name']);
    }
    $DB->query("DELETE FROM glpi_plugin_themes_per_user WHERE theme_id = {$t->fields['id']};");
    $DB->query("DELETE FROM glpi_plugin_themes_themes WHERE id = {$_GET['delete']};");
    Session::addMessageAfterRedirect(__('Theme deleted', 'themes'), false, INFO);
    header('location:' . $CFG_GLPI['root_doc'] . '/plugins/themes/front/themes.php');
}
$plugin = new Plugin();
Html::header(__('Themes manager', 'themes'), '', "plugins", "themes");
if (plugin_themes_haveRight('themes', 'r')) {
    PluginThemesTheme::showAllThemes();
} else {
    Html::displayRightError();
}
Html::footer();