当前位置: 首页>>代码示例>>PHP>>正文


PHP get_user_timezone函数代码示例

本文整理汇总了PHP中get_user_timezone函数的典型用法代码示例。如果您正苦于以下问题:PHP get_user_timezone函数的具体用法?PHP get_user_timezone怎么用?PHP get_user_timezone使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get_user_timezone函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getValue

 /**
  * @return string
  */
 public function getValue()
 {
     $value = $this->fetchRawValueFromDataSource();
     if (empty($value)) {
         return null;
     }
     if (function_exists('get_user_timezone')) {
         $timezone = get_user_timezone();
         if (!$timezone instanceof \DateTimeZone) {
             return $value;
         }
         if ($value instanceof \DateTime) {
             $value->setTimezone($timezone);
             return $value->format($this->format);
         }
     }
     try {
         $date = new \DateTime($value);
         return $date->format($this->format);
     } catch (\Exception $e) {
         return $e->getMessage();
     }
 }
开发者ID:nsbucky,项目名称:resultset-table,代码行数:26,代码来源:DateTime.php

示例2: date

    vertical-align: middle;
    width: 100%;
}
</style>
<!-- End of the page scripts --

<script type="text/javascript">
// Current Server Time script (SSI or PHP)- By JavaScriptKit.com (http://www.javascriptkit.com)
// For this and over 400+ free scripts, visit JavaScript Kit- http://www.javascriptkit.com/
// This notice must stay intact for use.

//Depending on whether your page supports SSI (.shtml) or PHP (.php), UNCOMMENT the line below your page supports and COMMENT the one it does not:
//Default is that SSI method is uncommented, and PHP is commented:

var currenttime = '<?php 
echo date("F d, Y H:i:s", get_user_time(local_to_gmt(), get_user_timezone()));
?>
' //PHP method of getting server date

///////////Stop editting here/////////////////////////////////

var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December")
var serverdate=new Date(currenttime)

function padlength(what){
var output=(what.toString().length==1)? "0"+what : what
return output
}

function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
开发者ID:BersnardC,项目名称:DROPINN,代码行数:31,代码来源:view_edit_profile.php

示例3: word_limiter

        ?>
</td>
			  <td><?php 
        echo word_limiter($city->known, 4);
        ?>
</td>
			  <td><?php 
        if ($city->is_home == 0) {
            echo translate_admin('No');
        } else {
            echo translate_admin('Yes');
        }
        ?>
</td>
			  <td><?php 
        echo get_user_times($city->created, get_user_timezone());
        ?>
</td>
			  <td><a href="<?php 
        echo admin_url('neighbourhoods/editcity/' . $city->id);
        ?>
">
                <img src="<?php 
        echo base_url();
        ?>
images/edit-new.png" alt="Edit" title="Edit" /></a>
			      <a href="<?php 
        echo admin_url('neighbourhoods/deletecity/' . $city->id);
        ?>
" onclick="return confirm('Are you sure want to delete??');"><img src="<?php 
        echo base_url();
开发者ID:BersnardC,项目名称:DROPINN,代码行数:31,代码来源:viewcity.php

示例4: chat_format_message_theme

/**
 * @global object
 * @param object $message message to be displayed.
 * @param mixed $chatuser user chat data
 * @param object $currentuser current user for whom the message should be displayed.
 * @param int $groupingid course module grouping id
 * @param string $theme name of the chat theme.
 * @return bool|string Returns HTML or false
 */
function chat_format_message_theme($message, $chatuser, $currentuser, $groupingid, $theme = 'bubble')
{
    global $CFG, $USER, $OUTPUT, $COURSE, $DB, $PAGE;
    require_once $CFG->dirroot . '/mod/chat/locallib.php';
    static $users;
    // Cache user lookups
    $result = new stdClass();
    if (file_exists($CFG->dirroot . '/mod/chat/gui_ajax/theme/' . $theme . '/config.php')) {
        include $CFG->dirroot . '/mod/chat/gui_ajax/theme/' . $theme . '/config.php';
    }
    if (isset($users[$message->userid])) {
        $sender = $users[$message->userid];
    } else {
        if ($sender = $DB->get_record('user', array('id' => $message->userid), user_picture::fields())) {
            $users[$message->userid] = $sender;
        } else {
            return NULL;
        }
    }
    $USER->timezone = 99;
    $tz = get_user_timezone($currentuser->timezone);
    $USER->timezone = $tz;
    if (empty($chatuser->course)) {
        $courseid = $COURSE->id;
    } else {
        $courseid = $chatuser->course;
    }
    $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'chat'), $tz);
    $message->picture = $OUTPUT->user_picture($sender, array('courseid' => $courseid));
    $message->picture = "<a target='_blank' href=\"{$CFG->wwwroot}/user/view.php?id={$sender->id}&amp;course={$courseid}\">{$message->picture}</a>";
    // Start processing the message
    if (!empty($message->system)) {
        $result->type = 'system';
        $senderprofile = $CFG->wwwroot . '/user/view.php?id=' . $sender->id . '&amp;course=' . $courseid;
        $event = get_string('message' . $message->message, 'chat', fullname($sender));
        $eventmessage = new event_message($senderprofile, fullname($sender), $message->strtime, $event, $theme);
        $output = $PAGE->get_renderer('mod_chat');
        $result->html = $output->render($eventmessage);
        return $result;
    }
    // It's not a system event
    $text = trim($message->message);
    /// Parse the text to clean and filter it
    $options = new stdClass();
    $options->para = false;
    $text = format_text($text, FORMAT_MOODLE, $options, $courseid);
    // And now check for special cases
    $special = false;
    $outtime = $message->strtime;
    // Initialise variables.
    $outmain = '';
    $patternTo = '#^\\s*To\\s([^:]+):(.*)#';
    if (substr($text, 0, 5) == 'beep ') {
        $special = true;
        /// It's a beep!
        $result->type = 'beep';
        $beepwho = trim(substr($text, 5));
        if ($beepwho == 'all') {
            // everyone
            $outmain = get_string('messagebeepseveryone', 'chat', fullname($sender));
        } else {
            if ($beepwho == $currentuser->id) {
                // current user
                $outmain = get_string('messagebeepsyou', 'chat', fullname($sender));
            } else {
                if ($sender->id == $currentuser->id) {
                    //something is not caught?
                    //allow beep for a active chat user only, else user can beep anyone and get fullname
                    if (!empty($chatuser) && is_numeric($beepwho)) {
                        $chatusers = chat_get_users($chatuser->chatid, $chatuser->groupid, $groupingid);
                        if (array_key_exists($beepwho, $chatusers)) {
                            $outmain = get_string('messageyoubeep', 'chat', fullname($chatusers[$beepwho]));
                        } else {
                            $outmain = get_string('messageyoubeep', 'chat', $beepwho);
                        }
                    } else {
                        $outmain = get_string('messageyoubeep', 'chat', $beepwho);
                    }
                }
            }
        }
    } else {
        if (substr($text, 0, 1) == '/') {
            /// It's a user command
            $special = true;
            $result->type = 'command';
            $pattern = '#(^\\/)(\\w+).*#';
            preg_match($pattern, $text, $matches);
            $command = isset($matches[2]) ? $matches[2] : false;
            // Support some IRC commands.
            switch ($command) {
//.........这里部分代码省略.........
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:101,代码来源:lib.php

示例5: calculate_user_dst_table

/**
 * Build and store the users Daylight Saving Time (DST) table
 *
 * @package core
 * @param int $fromyear Start year for the table, defaults to 1971
 * @param int $toyear End year for the table, defaults to 2035
 * @param int|float|string $strtimezone timezone to check if dst should be applied.
 * @return bool
 */
function calculate_user_dst_table($fromyear = null, $toyear = null, $strtimezone = null) {
    global $SESSION, $DB;

    $usertz = get_user_timezone($strtimezone);

    if (is_float($usertz)) {
        // Trivial timezone, no DST.
        return false;
    }

    if (!empty($SESSION->dst_offsettz) && $SESSION->dst_offsettz != $usertz) {
        // We have pre-calculated values, but the user's effective TZ has changed in the meantime, so reset.
        unset($SESSION->dst_offsets);
        unset($SESSION->dst_range);
    }

    if (!empty($SESSION->dst_offsets) && empty($fromyear) && empty($toyear)) {
        // Repeat calls which do not request specific year ranges stop here, we have already calculated the table.
        // This will be the return path most of the time, pretty light computationally.
        return true;
    }

    // Reaching here means we either need to extend our table or create it from scratch.

    // Remember which TZ we calculated these changes for.
    $SESSION->dst_offsettz = $usertz;

    if (empty($SESSION->dst_offsets)) {
        // If we 're creating from scratch, put the two guard elements in there.
        $SESSION->dst_offsets = array(1 => null, 0 => null);
    }
    if (empty($SESSION->dst_range)) {
        // If creating from scratch.
        $from = max((empty($fromyear) ? intval(date('Y')) - 3 : $fromyear), 1971);
        $to   = min((empty($toyear)   ? intval(date('Y')) + 3 : $toyear),   2035);

        // Fill in the array with the extra years we need to process.
        $yearstoprocess = array();
        for ($i = $from; $i <= $to; ++$i) {
            $yearstoprocess[] = $i;
        }

        // Take note of which years we have processed for future calls.
        $SESSION->dst_range = array($from, $to);
    } else {
        // If needing to extend the table, do the same.
        $yearstoprocess = array();

        $from = max((empty($fromyear) ? $SESSION->dst_range[0] : $fromyear), 1971);
        $to   = min((empty($toyear)   ? $SESSION->dst_range[1] : $toyear),   2035);

        if ($from < $SESSION->dst_range[0]) {
            // Take note of which years we need to process and then note that we have processed them for future calls.
            for ($i = $from; $i < $SESSION->dst_range[0]; ++$i) {
                $yearstoprocess[] = $i;
            }
            $SESSION->dst_range[0] = $from;
        }
        if ($to > $SESSION->dst_range[1]) {
            // Take note of which years we need to process and then note that we have processed them for future calls.
            for ($i = $SESSION->dst_range[1] + 1; $i <= $to; ++$i) {
                $yearstoprocess[] = $i;
            }
            $SESSION->dst_range[1] = $to;
        }
    }

    if (empty($yearstoprocess)) {
        // This means that there was a call requesting a SMALLER range than we have already calculated.
        return true;
    }

    // From now on, we know that the array has at least the two guard elements, and $yearstoprocess has the years we need
    // Also, the array is sorted in descending timestamp order!

    // Get DB data.

    static $presetscache = array();
    if (!isset($presetscache[$usertz])) {
        $presetscache[$usertz] = $DB->get_records('timezone', array('name' => $usertz),
            'year DESC', 'year, gmtoff, dstoff, dst_month, dst_startday, dst_weekday, dst_skipweeks, dst_time, std_month, '.
            'std_startday, std_weekday, std_skipweeks, std_time');
    }
    if (empty($presetscache[$usertz])) {
        return false;
    }

    // Remove ending guard (first element of the array).
    reset($SESSION->dst_offsets);
    unset($SESSION->dst_offsets[key($SESSION->dst_offsets)]);

//.........这里部分代码省略.........
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:101,代码来源:moodlelib.php

示例6: translate

    echo translate("Details");
    ?>
 </th>
                        </tr>

        <?php 
    foreach ($result->result() as $row) {
        ?>
                            <tr>
                                <td width="15%"> <p class="View_my_Accept_Bg"><span><?php 
        echo $row->name;
        ?>
</span></p> </td>
                                <td width="30%">
                                    <p> <?php 
        echo get_user_times($row->checkin, get_user_timezone()) . ' - ' . get_user_times($row->checkout, get_user_timezone());
        ?>
 </p> <br />
                                    <p class="clsBold"> <?php 
        echo anchor('rooms/' . $row->list_id, get_list_by_id($row->list_id)->title);
        ?>
 </p> 
                                    <p> <?php 
        echo get_list_by_id($row->list_id)->address;
        ?>
 </p> 
                                </td>
                                <td width="25%">
                                    <p> <img height="50" width="50" alt="image" style="float:left; margin:0 10px 10px 0;" src="<?php 
        echo $this->Gallery->profilepic($row->userby, 2);
        ?>
开发者ID:empotix,项目名称:travelo,代码行数:31,代码来源:view_myreservation.php

示例7: test_get_user_timezone

 public function test_get_user_timezone()
 {
     global $CFG, $USER;
     $this->resetAfterTest();
     $user = $this->getDataGenerator()->create_user();
     $this->setUser($user);
     // All set to something.
     $this->setTimezone('Pacific/Auckland', 'Pacific/Auckland');
     $USER->timezone = 'Europe/Prague';
     $tz = get_user_timezone();
     $this->assertSame('Europe/Prague', $tz);
     $tz = get_user_timezone(99);
     $this->assertSame('Europe/Prague', $tz);
     $tz = get_user_timezone('99');
     $this->assertSame('Europe/Prague', $tz);
     $tz = get_user_timezone('Europe/Berlin');
     $this->assertSame('Europe/Berlin', $tz);
     // User timezone not set.
     $this->setTimezone('Pacific/Auckland', 'Pacific/Auckland');
     $USER->timezone = '99';
     $tz = get_user_timezone();
     $this->assertSame('Pacific/Auckland', $tz);
     $tz = get_user_timezone(99);
     $this->assertSame('Pacific/Auckland', $tz);
     $tz = get_user_timezone('99');
     $this->assertSame('Pacific/Auckland', $tz);
     $tz = get_user_timezone('Europe/Berlin');
     $this->assertSame('Europe/Berlin', $tz);
     // Server timezone not set.
     $this->setTimezone('99', 'Pacific/Auckland');
     $USER->timezone = 'Europe/Prague';
     $tz = get_user_timezone();
     $this->assertSame('Europe/Prague', $tz);
     $tz = get_user_timezone(99);
     $this->assertSame('Europe/Prague', $tz);
     $tz = get_user_timezone('99');
     $this->assertSame('Europe/Prague', $tz);
     $tz = get_user_timezone('Europe/Berlin');
     $this->assertSame('Europe/Berlin', $tz);
     // Server and user timezone not set.
     $this->setTimezone('99', 'Pacific/Auckland');
     $USER->timezone = '99';
     $tz = get_user_timezone();
     $this->assertSame(99.0, $tz);
     $tz = get_user_timezone(99);
     $this->assertSame(99.0, $tz);
     $tz = get_user_timezone('99');
     $this->assertSame(99.0, $tz);
     $tz = get_user_timezone('Europe/Berlin');
     $this->assertSame('Europe/Berlin', $tz);
 }
开发者ID:Keneth1212,项目名称:moodle,代码行数:51,代码来源:date_legacy_test.php

示例8: ucfirst

        <div>
            <div class="clsH1_long_Border">
                <?php 
//print_r($user->username);exit;
?>
                <h1> <?php 
echo ucfirst($user->username);
?>
                    <?php 
if ($this->dx_auth->is_logged_in() || $this->facebook_lib->logged_in()) {
    ?>
                            <span style="float:right;"><?php 
    echo translate("Member from");
    ?>
 <?php 
    echo get_user_times($user->created, get_user_timezone());
    ?>
</span> 
    <?php 
}
?>
                </h1>
            </div>
            <div style="clear:both"></div>
        </div>
        <div style="clear:both"></div>
        <div id="left">
            <div id="user_box" class="Box">
                <div class="Box_Content">
                    <div id="user_pic" onClick="show_ajax_image_box();" style="text-align:center; padding:0 0 10px 0;"> 
开发者ID:empotix,项目名称:travelo,代码行数:30,代码来源:view_vouch.php

示例9: translate

    echo translate("Decline");
    ?>
</a>
                                                <div id="expired" style="display: none"><?php 
    echo translate('Expired');
    ?>
</div>
                                                <div id="accept" style="display:none">
                                                    <form name="accept_req" action="<?php 
    echo site_url('trips/accept');
    ?>
" method="post">
                                                        <p>
                                                            <input type="checkbox" id="block_date" name="block_date" />
        <?php 
    echo translate("Block my calendar from") . " " . get_user_times($result->checkin, get_user_timezone()) . " " . translate("through") . " " . get_user_times($result->checkout, get_user_timezone());
    ?>
                                                        </p>

                                                        <p><?php 
    echo translate("Type optional message to guest") . "...";
    ?>
</p>

                                                        <p><textarea name="comment" id="comment"></textarea></p>

                                                        <p>
                                                            <input type="hidden" id="checkout" name="reservation_id" value="<?php 
    echo $result->id;
    ?>
" />
开发者ID:empotix,项目名称:travelo,代码行数:31,代码来源:request.php

示例10: get_user_times

        ?>
 </td>
                                    <td><?php 
        echo $booker_name;
        ?>
 </td>
                                    <td><?php 
        echo $hotelier_name;
        ?>
 </td>
                                    <td><?php 
        echo get_user_times($row->checkin, get_user_timezone());
        ?>
 </td>
                                    <td><?php 
        echo get_user_times($row->checkout, get_user_timezone());
        ?>
 </td>
                                    <td><?php 
        echo get_currency_symbol($row->list_id) . get_currency_value1($row->list_id, $row->price);
        ?>
 </td>
                                    <td><?php 
        echo $row->name;
        ?>
                                </tr>
        <?php 
    }
    ?>

                        </tbody>
开发者ID:empotix,项目名称:travelo,代码行数:31,代码来源:view_transaction.php

示例11: header

// @NOTE: if the user doesn't have permission to view users
// it should be log out
// see: https://github.com/directus/directus/issues/1268
if (!$users) {
    AuthProvider::logout();
    $_SESSION['error_message'] = 'Your user doesn\'t have permission to log in';
    header('Location: ' . DIRECTUS_PATH . 'login.php');
    exit;
}
$currentUserInfo = getCurrentUserInfo($users);
// Cache buster
$git = __DIR__ . '/.git';
$cacheBuster = Directus\Util\Git::getCloneHash($git);
$tableSchema = TableSchema::getAllSchemas($currentUserInfo['group']['id'], $cacheBuster);
// $tabPrivileges = getTabPrivileges(($currentUserInfo['group']['id']));
$groupId = $currentUserInfo['group']['id'];
$groups = getGroups();
$currentUserGroup = [];
if (isset($groups['rows']) && count($groups['rows'] > 0)) {
    foreach ($groups['rows'] as $group) {
        if ($group['id'] === $groupId) {
            $currentUserGroup = $group;
            break;
        }
    }
}
$statusMapping = ['active_num' => STATUS_ACTIVE_NUM, 'deleted_num' => STATUS_DELETED_NUM, 'status_name' => STATUS_COLUMN_NAME];
$statusMapping['mapping'] = $config['statusMapping'];
$data = ['cacheBuster' => $cacheBuster, 'nonces' => getNonces(), 'storage_adapters' => getStorageAdapters(), 'path' => DIRECTUS_PATH, 'page' => '#tables', 'tables' => parseTables($tableSchema), 'preferences' => parsePreferences($tableSchema), 'users' => $users, 'groups' => $groups, 'settings' => getSettings(), 'active_files' => getActiveFiles(), 'authenticatedUser' => $authenticatedUser, 'extensions' => getExtensions($currentUserGroup), 'privileges' => getPrivileges($groupId), 'ui' => getUI(), 'locale' => get_user_locale(), 'localesAvailable' => parseLocalesAvailable(get_locales_available()), 'phrases' => get_phrases(get_user_locale()), 'timezone' => get_user_timezone(), 'timezones' => get_timezone_list(), 'listViews' => getListViews(), 'messages' => getInbox(), 'user_notifications' => getLoginNotification(), 'bookmarks' => getBookmarks(), 'extendedUserColumns' => getExtendedUserColumns($tableSchema), 'statusMapping' => $statusMapping];
$templateVars = ['cacheBuster' => $cacheBuster, 'data' => json_encode($data), 'path' => DIRECTUS_PATH, 'locale' => get_user_locale(), 'dir' => 'ltr', 'customFooterHTML' => getCusomFooterHTML(), 'cssFilePath' => getCSSFilePath()];
echo template(file_get_contents('main.html'), $templateVars);
开发者ID:jel-massih,项目名称:directus,代码行数:31,代码来源:index.php

示例12: anchor

         <td width="17%">-->

            <?php 
            if (date('m/d/Y', get_user_time($row->checkin, get_user_timezone())) == date('m/d/Y', get_user_time(local_to_gmt(), get_user_timezone()))) {
                ?>
             <p class="clsBold"><?php 
                if ($row->status == 3) {
                    echo anchor('travelling/checkin/' . $row->id, translate("Checkin"), array('id' => 'checkin'));
                }
                ?>
</p>
            <?php 
            }
            ?>
                <?php 
            if (date('m/d/Y', get_user_time($row->checkout, get_user_timezone())) <= date('m/d/Y', get_user_time(local_to_gmt(), get_user_timezone()))) {
                ?>
				 <p class="clsBold"><?php 
                if ($row->status == 7) {
                    echo anchor('travelling/checkout/' . $row->id, translate("Checkout"), array('id' => 'checkout'));
                }
                ?>
</p>
				<?php 
            }
            ?>
                <p class="clsBold"><?php 
            echo anchor('travelling/billing/' . $row->id, translate("View Billing"));
            ?>
</p>
                <?php 
开发者ID:BersnardC,项目名称:DROPINN,代码行数:31,代码来源:view_upcomming_trips.php

示例13: validation_errors

    echo $reset_message;
}
// Show error
echo validation_errors();
$tmpl = array('table_open' => '<table class="table" border="0" cellpadding="4" cellspacing="0">', 'heading_row_start' => '<tr>', 'heading_row_end' => '</tr>', 'heading_cell_start' => '<th>', 'heading_cell_end' => '</th>', 'row_start' => '<tr>', 'row_end' => '</tr>', 'cell_start' => '<td>', 'cell_end' => '</td>', 'row_alt_start' => '<tr>', 'row_alt_end' => '</tr>', 'cell_alt_start' => '<td>', 'cell_alt_end' => '</td>', 'table_close' => '</table>');
$this->table->set_template($tmpl);
$this->table->set_heading('', translate_admin('Username'), translate_admin('Email'), translate_admin('Role'), translate_admin('Banned'), translate_admin('Last IP'), translate_admin('Last login'), translate_admin('Created'), translate_admin('Edit'), translate_admin('Change Password'));
foreach ($users as $user) {
    if ($this->db->where('id', $user->id)->get('profiles')->num_rows() != 0) {
        if ($user->role_id == 2) {
            $role = 'admin';
        } else {
            $role = 'user';
        }
        $banned = $user->banned == 1 ? 'Yes' : 'No';
        $this->table->add_row(form_checkbox('checkbox_' . $user->id, $user->id), $user->username, $user->email, $role, $banned, $user->last_ip, get_user_times($user->last_login, get_user_timezone()), get_user_times($user->created, get_user_timezone()), anchor('administrator/members/edit/' . $user->id, translate_admin('Edit')), anchor('administrator/members/changepassword/' . $user->id, translate_admin('change passwords')));
    }
}
echo '<div class="clsFloatRight">';
echo '<form name="myform" action="' . site_url('administrator/members/getusers') . '" method="post">';
?>
                <!-- //echo '<b>Search Username / Email</b><input type="text" name="usersearch" id="usersearch" style="margin:0 10px; height:23px;">'; -->		
<b><?php 
echo translate_admin('Search Username / Email');
?>
</b><input type="text" name="usersearch" id="usersearch" style="margin:0 10px; height:23px;">

        <!--  echo '<input type="submit" name="search" value="Search">'; -->
<input type="submit" name="search" value="<?php 
echo translate_admin('Search');
?>
开发者ID:empotix,项目名称:travelo,代码行数:31,代码来源:view_users.php

示例14: get_clean_timezone

    /**
     * @method get_clean_timezone
     * @todo Gets a clean timezone attempting to compensate for some Moodle 'special' timezones
     *       where the returned zone is compatible with PHP DateTime, DateTimeZone etc functions
     * @param string/float $tz either a location identifier string or, in some Moodle special cases, a number
     * @return string a clean timezone that can be used safely
     */
    function get_clean_timezone($tz = null) {
        global $CFG, $DB;

        $cleanzones = DateTimeZone::listIdentifiers();
        if (empty($tz)) {
            $tz = get_user_timezone();
        }

        //if already a good zone, return
        if (in_array($tz, $cleanzones, true)) {
            return $tz;
        }
        //for when all else fails
        $default = 'Europe/London';
        //try to handle UTC offsets, and numbers including '99' (server local time)
        //note: some old versions of moodle had GMT offsets stored as floats
        if (is_numeric($tz)) {
            if (intval($tz) == 99) {
                //check various config settings to try and resolve to something useful
                if (isset($CFG->forcetimezone) && $CFG->forcetimezone != 99) {
                    $tz = $CFG->forcetimezone;
                } else if (isset($CFG->timezone) && $CFG->timezone != 99) {
                    $tz = $CFG->timezone;
                }
            }
            if (intval($tz) == 99) {
                //no useful CFG settings, try a system call
                $tz = date_default_timezone_get();
            }
            //do we have something useful yet?
            if (in_array($tz, $cleanzones, true)) {
                return $tz;
            }
            //check the bad timezone replacement list
            if (is_float($tz)) {
                $tz = number_format($tz, 1);
            }
            $badzones = $this->get_bad_timezone_list();
            //does this exist in our replacement list?
            if (in_array($tz, array_keys($badzones))) {
                return $badzones[$tz];
            }
        }
        //everything has failed, set to London
        return $default;
    }
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:53,代码来源:lib.php

示例15: dimdim_format_message_manually

function dimdim_format_message_manually($message, $courseid, $sender, $currentuser, $dimdim_lastrow = NULL)
{
    global $CFG, $USER;
    $output = new stdClass();
    $output->beep = false;
    // by default
    $output->refreshusers = false;
    // by default
    // Use get_user_timezone() to find the correct timezone for displaying this message:
    // It's either the current user's timezone or else decided by some Moodle config setting
    // First, "reset" $USER->timezone (which could have been set by a previous call to here)
    // because otherwise the value for the previous $currentuser will take precedence over $CFG->timezone
    $USER->timezone = 99;
    $tz = get_user_timezone($currentuser->timezone);
    // Before formatting the message time string, set $USER->timezone to the above.
    // This will allow dst_offset_on (called by userdate) to work correctly, otherwise the
    // message times appear off because DST is not taken into account when it should be.
    $USER->timezone = $tz;
    $message->strtime = userdate($message->timestamp, get_string('strftimemessage', 'dimdim'), $tz);
    $message->picture = print_user_picture($sender->id, 0, $sender->picture, false, true, false);
    if ($courseid) {
        $message->picture = "<a target=\"_new\" href=\"{$CFG->wwwroot}/user/view.php?id={$sender->id}&amp;course={$courseid}\">{$message->picture}</a>";
    }
    //Calculate the row class
    if ($dimdim_lastrow !== NULL) {
        $rowclass = ' class="r' . $dimdim_lastrow . '" ';
    } else {
        $rowclass = '';
    }
    // Start processing the message
    if (!empty($message->system)) {
        // System event
        $output->text = $message->strtime . ': ' . get_string('message' . $message->message, 'dimdim', fullname($sender));
        $output->html = '<table class="dimdim-event"><tr' . $rowclass . '><td class="picture">' . $message->picture . '</td><td class="text">';
        $output->html .= '<span class="event">' . $output->text . '</span></td></tr></table>';
        if ($message->message == 'exit' or $message->message == 'enter') {
            $output->refreshusers = true;
            //force user panel refresh ASAP
        }
        return $output;
    }
    // It's not a system event
    $text = $message->message;
    /// Parse the text to clean and filter it
    $options->para = false;
    $text = format_text($text, FORMAT_MOODLE, $options, $courseid);
    // And now check for special cases
    if (substr($text, 0, 5) == 'beep ') {
        /// It's a beep!
        $beepwho = trim(substr($text, 5));
        if ($beepwho == 'all') {
            // everyone
            $outinfo = $message->strtime . ': ' . get_string('messagebeepseveryone', 'dimdim', fullname($sender));
            $outmain = '';
            $output->beep = true;
            // (eventually this should be set to
            //  to a filename uploaded by the user)
        } else {
            if ($beepwho == $currentuser->id) {
                // current user
                $outinfo = $message->strtime . ': ' . get_string('messagebeepsyou', 'dimdim', fullname($sender));
                $outmain = '';
                $output->beep = true;
            } else {
                return false;
            }
        }
    } else {
        if (substr($text, 0, 1) == ':') {
            /// It's an MOO emote
            $outinfo = $message->strtime;
            $outmain = $sender->firstname . ' ' . substr($text, 1);
        } else {
            if (substr($text, 0, 1) == '/') {
                /// It's a user command
                if (substr($text, 0, 4) == "/me ") {
                    $outinfo = $message->strtime;
                    $outmain = $sender->firstname . ' ' . substr($text, 4);
                } else {
                    $outinfo = $message->strtime;
                    $outmain = $text;
                }
            } else {
                /// It's a normal message
                $outinfo = $message->strtime . ' ' . $sender->firstname;
                $outmain = $text;
            }
        }
    }
    /// Format the message as a small table
    $output->text = strip_tags($outinfo . ': ' . $outmain);
    $output->html = "<table class=\"dimdim-message\"><tr{$rowclass}><td class=\"picture\">{$message->picture}</td><td class=\"text\">";
    $output->html .= "<span class=\"title\">{$outinfo}</span>";
    if ($outmain) {
        $output->html .= ": {$outmain}";
    }
    $output->html .= "</td></tr></table>";
    return $output;
}
开发者ID:kai707,项目名称:ITSA-backup,代码行数:99,代码来源:lib.php


注:本文中的get_user_timezone函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。