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
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 themes is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with themes. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
// Original Author of file: Jérôme Ansel <*****@*****.**>
// ----------------------------------------------------------------------
include "../../../inc/includes.php";
if (!isset($_GET['theme_id'])) {
    die;
}
$t = new PluginThemesTheme();
$t->getFromDB($_GET['theme_id']);
if (!isset($_GET['type'])) {
    $_GET['type'] = 'css';
}
if (!isset($_GET['file'])) {
    die;
}
if (PluginThemesTheme::canView()) {
    $t->getFileContent($_GET['type'], $_GET['file']);
} else {
    die;
}
Ejemplo n.º 3
0
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 themes is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with themes. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
*/
// Original Author of file: Jérôme Ansel <*****@*****.**>
// ----------------------------------------------------------------------
include "../../../inc/includes.php";
if (!Session::getLoginUserID()) {
    die('You need to be logged to use this file.');
} else {
    if (!isset($_POST['theme_user_selection']) || $_POST['plugin_themes_themes_id'] == 0) {
        Session::addMessageAfterRedirect(__('You need to choose a theme.', 'themes'), false, ERROR);
    } else {
        $choosenTheme = new PluginThemesTheme();
        $choosenTheme->getFromDB($_POST['plugin_themes_themes_id']);
        if ($choosenTheme->setAsUserTheme()) {
            Session::addMessageAfterRedirect(__('New theme set. You should see it now. Please empty your browser cache.', 'themes'), false, INFO);
        } else {
            Session::addMessageAfterRedirect(__('You need to choose a theme.', 'themes'), false, ERROR);
        }
    }
    Html::back();
}
Ejemplo n.º 4
0
            $result = PluginThemesTheme::installThemes("{$uploads_dir}/", $_FILES['themeFile']['name']);
            if ($result === true) {
                Session::addMessageAfterRedirect(__('Theme added', themes), false, INFO);
            } else {
                Session::addMessageAfterRedirect($result, false, ERROR);
            }
            unlink("{$uploads_dir}/{$_FILES['themeFile']['name']}");
        }
    } else {
        Session::addMessageAfterRedirect(__('Theme already exist', 'themes'), false, ERROR);
    }
    header('location:' . $CFG_GLPI['root_doc'] . '/plugins/themes/front/themes.php');
    die;
}
if (isset($_GET['activate']) && PluginThemesTheme::canCreate()) {
    $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'])) {