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


PHP core_date::get_server_timezone方法代码示例

本文整理汇总了PHP中core_date::get_server_timezone方法的典型用法代码示例。如果您正苦于以下问题:PHP core_date::get_server_timezone方法的具体用法?PHP core_date::get_server_timezone怎么用?PHP core_date::get_server_timezone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在core_date的用法示例。


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

示例1: forum_cron


//.........这里部分代码省略.........
                $mailresult = message_send($eventdata);
                if (!$mailresult) {
                    mtrace("Error: mod/forum/lib.php forum_cron(): Could not send out mail for id {$post->id} to user {$userto->id}" . " ({$userto->email}) .. not trying again.");
                    $errorcount[$post->id]++;
                } else {
                    $mailcount[$post->id]++;
                    // Mark post as read if forum_usermarksread is set off.
                    if (!$CFG->forum_usermarksread) {
                        $userto->markposts[$post->id] = $post->id;
                    }
                }
                mtrace('post ' . $post->id . ': ' . $post->subject);
            }
            // Mark processed posts as read.
            if (get_user_preferences('forum_markasreadonnotification', 1, $userto->id) == 1) {
                forum_tp_mark_posts_read($userto, $userto->markposts);
            }
            unset($userto);
        }
    }
    if ($posts) {
        foreach ($posts as $post) {
            mtrace($mailcount[$post->id] . " users were sent post {$post->id}, '{$post->subject}'");
            if ($errorcount[$post->id]) {
                $DB->set_field('forum_posts', 'mailed', FORUM_MAILED_ERROR, array('id' => $post->id));
            }
        }
    }
    // release some memory
    unset($subscribedusers);
    unset($mailcount);
    unset($errorcount);
    cron_setup_user();
    $sitetimezone = core_date::get_server_timezone();
    // Now see if there are any digest mails waiting to be sent, and if we should send them
    mtrace('Starting digest processing...');
    core_php_time_limit::raise(300);
    // terminate if not able to fetch all digests in 5 minutes
    if (!isset($CFG->digestmailtimelast)) {
        // To catch the first time
        set_config('digestmailtimelast', 0);
    }
    $timenow = time();
    $digesttime = usergetmidnight($timenow, $sitetimezone) + $CFG->digestmailtime * 3600;
    // Delete any really old ones (normally there shouldn't be any)
    $weekago = $timenow - 7 * 24 * 3600;
    $DB->delete_records_select('forum_queue', "timemodified < ?", array($weekago));
    mtrace('Cleaned old digest records');
    if ($CFG->digestmailtimelast < $digesttime and $timenow > $digesttime) {
        mtrace('Sending forum digests: ' . userdate($timenow, '', $sitetimezone));
        $digestposts_rs = $DB->get_recordset_select('forum_queue', "timemodified < ?", array($digesttime));
        if ($digestposts_rs->valid()) {
            // We have work to do
            $usermailcount = 0;
            //caches - reuse the those filled before too
            $discussionposts = array();
            $userdiscussions = array();
            foreach ($digestposts_rs as $digestpost) {
                if (!isset($posts[$digestpost->postid])) {
                    if ($post = $DB->get_record('forum_posts', array('id' => $digestpost->postid))) {
                        $posts[$digestpost->postid] = $post;
                    } else {
                        continue;
                    }
                }
                $discussionid = $digestpost->discussionid;
开发者ID:rezaies,项目名称:moodle,代码行数:67,代码来源:lib.php

示例2: scorm_cron

/**
 * Function to be run periodically according to the moodle cron
 * This function searches for things that need to be done, such
 * as sending out mail, toggling flags etc ...
 *
 * @global stdClass
 * @global object
 * @return boolean
 */
function scorm_cron()
{
    global $CFG, $DB;
    require_once $CFG->dirroot . '/mod/scorm/locallib.php';
    $sitetimezone = core_date::get_server_timezone();
    // Now see if there are any scorm updates to be done.
    if (!isset($CFG->scorm_updatetimelast)) {
        // To catch the first time.
        set_config('scorm_updatetimelast', 0);
    }
    $timenow = time();
    $updatetime = usergetmidnight($timenow, $sitetimezone);
    if ($CFG->scorm_updatetimelast < $updatetime and $timenow > $updatetime) {
        set_config('scorm_updatetimelast', $timenow);
        mtrace('Updating scorm packages which require daily update');
        // We are updating.
        $scormsupdate = $DB->get_records('scorm', array('updatefreq' => SCORM_UPDATE_EVERYDAY));
        foreach ($scormsupdate as $scormupdate) {
            scorm_parse($scormupdate, true);
        }
        // Now clear out AICC session table with old session data.
        $cfgscorm = get_config('scorm');
        if (!empty($cfgscorm->allowaicchacp)) {
            $expiretime = time() - $cfgscorm->aicchacpkeepsessiondata * 24 * 60 * 60;
            $DB->delete_records_select('scorm_aicc_session', 'timemodified < ?', array($expiretime));
        }
    }
    return true;
}
开发者ID:dg711,项目名称:moodle,代码行数:38,代码来源:lib.php

示例3: helper_force_digest_mail_times

 /**
  * Helper to falsify all forum post records for a digest run.
  */
 protected function helper_force_digest_mail_times()
 {
     global $CFG, $DB;
     // Fake all of the post editing times because digests aren't sent until
     // the start of an hour where the modification time on the message is before
     // the start of that hour
     $sitetimezone = core_date::get_server_timezone();
     $digesttime = usergetmidnight(time(), $sitetimezone) + $CFG->digestmailtime * 3600 - 60 * 60;
     $DB->set_field('forum_posts', 'modified', $digesttime, array('mailed' => 0));
     $DB->set_field('forum_posts', 'created', $digesttime, array('mailed' => 0));
 }
开发者ID:alanaipe2015,项目名称:moodle,代码行数:14,代码来源:maildigest_test.php

示例4: test_get_server_timezone

 public function test_get_server_timezone()
 {
     global $CFG;
     $this->resetAfterTest();
     $this->setTimezone('Pacific/Auckland', 'Pacific/Auckland');
     $this->assertSame('Pacific/Auckland', core_date::get_server_timezone());
     $this->setTimezone('Pacific/Auckland', 'Europe/Prague');
     $this->assertSame('Pacific/Auckland', core_date::get_server_timezone());
     $this->setTimezone('99', 'Pacific/Auckland');
     $this->assertSame('Pacific/Auckland', core_date::get_server_timezone());
     $this->setTimezone(99, 'Pacific/Auckland');
     $this->assertSame('Pacific/Auckland', core_date::get_server_timezone());
     $this->setTimezone('Pacific/Auckland', 'Pacific/Auckland');
     unset($CFG->timezone);
     $this->assertSame('Pacific/Auckland', core_date::get_server_timezone());
     // Admin should fix the settings.
     $this->setTimezone('xxx/zzzz', 'Europe/Prague');
     $this->assertSame('Europe/Prague', core_date::get_server_timezone());
 }
开发者ID:evltuma,项目名称:moodle,代码行数:19,代码来源:date_test.php

示例5: fill_properties_cache

 /**
  * Definition of user profile fields and the expected parameter type for data validation.
  *
  * array(
  *     'property_name' => array(       // The user property to be checked. Should match the field on the user table.
  *          'null' => NULL_ALLOWED,    // Defaults to NULL_NOT_ALLOWED. Takes NULL_NOT_ALLOWED or NULL_ALLOWED.
  *          'type' => PARAM_TYPE,      // Expected parameter type of the user field.
  *          'choices' => array(1, 2..) // An array of accepted values of the user field.
  *          'default' => $CFG->setting // An default value for the field.
  *     )
  * )
  *
  * The fields choices and default are optional.
  *
  * @return void
  */
 protected static function fill_properties_cache()
 {
     global $CFG;
     if (self::$propertiescache !== null) {
         return;
     }
     // Array of user fields properties and expected parameters.
     // Every new field on the user table should be added here otherwise it won't be validated.
     $fields = array();
     $fields['id'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['auth'] = array('type' => PARAM_AUTH, 'null' => NULL_NOT_ALLOWED);
     $fields['confirmed'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
     $fields['policyagreed'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
     $fields['deleted'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
     $fields['suspended'] = array('type' => PARAM_BOOL, 'null' => NULL_NOT_ALLOWED);
     $fields['mnethostid'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['username'] = array('type' => PARAM_USERNAME, 'null' => NULL_NOT_ALLOWED);
     $fields['password'] = array('type' => PARAM_RAW, 'null' => NULL_NOT_ALLOWED);
     $fields['idnumber'] = array('type' => PARAM_RAW, 'null' => NULL_NOT_ALLOWED);
     $fields['firstname'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['lastname'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['surname'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['email'] = array('type' => PARAM_RAW_TRIMMED, 'null' => NULL_NOT_ALLOWED);
     $fields['emailstop'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['icq'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['skype'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     $fields['aim'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['yahoo'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['msn'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['phone1'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['phone2'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['institution'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED);
     $fields['department'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED);
     $fields['address'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED);
     $fields['city'] = array('type' => PARAM_TEXT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultcity);
     $fields['country'] = array('type' => PARAM_ALPHA, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->country, 'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_countries(true, true)));
     $fields['lang'] = array('type' => PARAM_LANG, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->lang, 'choices' => array_merge(array('' => ''), get_string_manager()->get_list_of_translations(false)));
     $fields['calendartype'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->calendartype, 'choices' => array_merge(array('' => ''), \core_calendar\type_factory::get_list_of_calendar_types()));
     $fields['theme'] = array('type' => PARAM_THEME, 'null' => NULL_NOT_ALLOWED, 'default' => theme_config::DEFAULT_THEME, 'choices' => array_merge(array('' => ''), get_list_of_themes()));
     $fields['timezone'] = array('type' => PARAM_TIMEZONE, 'null' => NULL_NOT_ALLOWED, 'default' => core_date::get_server_timezone());
     // Must not use choices here: timezones can come and go.
     $fields['firstaccess'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['lastaccess'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['lastlogin'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['currentlogin'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['lastip'] = array('type' => PARAM_NOTAGS, 'null' => NULL_NOT_ALLOWED);
     $fields['secret'] = array('type' => PARAM_RAW, 'null' => NULL_NOT_ALLOWED);
     $fields['picture'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['url'] = array('type' => PARAM_URL, 'null' => NULL_NOT_ALLOWED);
     $fields['description'] = array('type' => PARAM_RAW, 'null' => NULL_ALLOWED);
     $fields['descriptionformat'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['mailformat'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_mailformat);
     $fields['maildigest'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_maildigest);
     $fields['maildisplay'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_maildisplay);
     $fields['autosubscribe'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_autosubscribe);
     $fields['trackforums'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED, 'default' => $CFG->defaultpreference_trackforums);
     $fields['timecreated'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['timemodified'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['trustbitmask'] = array('type' => PARAM_INT, 'null' => NULL_NOT_ALLOWED);
     $fields['imagealt'] = array('type' => PARAM_TEXT, 'null' => NULL_ALLOWED);
     $fields['lastnamephonetic'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     $fields['firstnamephonetic'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     $fields['middlename'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     $fields['alternatename'] = array('type' => PARAM_NOTAGS, 'null' => NULL_ALLOWED);
     self::$propertiescache = $fields;
 }
开发者ID:sirromas,项目名称:lms,代码行数:82,代码来源:user.php


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