Ejemplo n.º 1
0
function plugin_timezones_MassiveActionsFieldsDisplay($options = array())
{
    //$type,$table,$field,$linkfield
    $table = $options['options']['table'];
    $field = $options['options']['field'];
    $linkfield = $options['options']['linkfield'];
    if ($options['itemtype'] == 'User') {
        // Table fields
        switch ($table . "." . $field) {
            case 'glpi_plugin_timezones_users.timezone':
                $timezones = PluginTimezonesUser::getTimezones();
                // default timezone is the one of PHP
                Dropdown::showFromArray('plugin_timezones_users_timezone', $timezones, array('value' => ini_get('date.timezone')));
                // Need to return true if specific display
                return true;
        }
    }
    // Need to return false on non display item
    return false;
}
<?php

define('GLPI_ROOT', '../../..');
include GLPI_ROOT . "/inc/includes.php";
$pref = new PluginTimezonesUser();
if (isset($_POST["update"])) {
    if ($pref->update($_POST) && $_POST['users_id'] == Session::getLoginUserID()) {
        setTimeZone($_POST['timezone']);
        // to reset timezone for current session
    }
    Html::back();
}
Html::redirect($CFG_GLPI["root_doc"] . "/front/preference.php?forcetab=" . urlencode('PluginTimezonesUser$1'));