本文整理汇总了PHP中core_date类的典型用法代码示例。如果您正苦于以下问题:PHP core_date类的具体用法?PHP core_date怎么用?PHP core_date使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了core_date类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_postdate
/**
* Test for the forum email renderable postdate.
*
* @dataProvider postdate_provider
*
* @param array $globalconfig The configuration to set on $CFG
* @param array $forumconfig The configuration for this forum
* @param array $postconfig The configuration for this post
* @param array $discussionconfig The configuration for this discussion
* @param string $expectation The expected date
*/
public function test_postdate($globalconfig, $forumconfig, $postconfig, $discussionconfig, $expectation)
{
global $CFG, $DB;
$this->resetAfterTest(true);
// Apply the global configuration.
foreach ($globalconfig as $key => $value) {
$CFG->{$key} = $value;
}
// Create the fixture.
$user = $this->getDataGenerator()->create_user();
$course = $this->getDataGenerator()->create_course();
$forum = $this->getDataGenerator()->create_module('forum', (object) array('course' => $course->id));
$cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
$this->getDataGenerator()->enrol_user($user->id, $course->id);
// Create a new discussion.
$discussion = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion((object) array_merge($discussionconfig, array('course' => $course->id, 'forum' => $forum->id, 'userid' => $user->id)));
// Apply the discussion configuration.
// Some settings are ignored by the generator and must be set manually.
$discussion = $DB->get_record('forum_discussions', array('id' => $discussion->id));
foreach ($discussionconfig as $key => $value) {
$discussion->{$key} = $value;
}
$DB->update_record('forum_discussions', $discussion);
// Apply the post configuration.
// Some settings are ignored by the generator and must be set manually.
$post = $DB->get_record('forum_posts', array('discussion' => $discussion->id));
foreach ($postconfig as $key => $value) {
$post->{$key} = $value;
}
$DB->update_record('forum_posts', $post);
// Create the renderable.
$renderable = new mod_forum\output\forum_post_email($course, $cm, $forum, $discussion, $post, $user, $user, true);
// Check the postdate matches our expectations.
$this->assertEquals(userdate($expectation, "", \core_date::get_user_timezone($user)), $renderable->get_postdate());
}
示例2: date
public function date($message, $viewmail = false) {
$tz = core_date::get_user_timezone();
$date = new DateTime('now', new DateTimeZone($tz));
$offset = ($date->getOffset() - dst_offset_on(time(), $tz)) / (3600.0);
$time = ($offset < 13) ? $message->time() + $offset : $message->time();
$now = ($offset < 13) ? time() + $offset : time();
$daysago = floor($now / 86400) - floor($time / 86400);
$yearsago = (int) date('Y', $now) - (int) date('Y', $time);
$tooltip = userdate($time, get_string('strftimedatetime'));
if ($viewmail) {
$content = userdate($time, get_string('strftimedatetime'));
$tooltip = '';
} else if ($daysago == 0) {
$content = userdate($time, get_string('strftimetime'));
} else if ($yearsago == 0) {
$content = userdate($time, get_string('strftimedateshort'));
} else {
$content = userdate($time, get_string('strftimedate'));
}
return html_writer::tag('span', s($content), array('class' => 'mail_date', 'title' => $tooltip));
}
示例3: scheduler_get_mail_variables
/**
* Construct an array with subtitution rules for mail templates, relating to
* a single appointment. Any of the parameters can be null.
* @param scheduler_instance $scheduler The scheduler instance
* @param scheduler_slot $slot The slot data as an MVC object
* @param user $attendant A {@link $USER} object describing the attendant (teacher)
* @param user $attendee A {@link $USER} object describing the attendee (student)
* @param object $course A course object relating to the ontext of the message
* @param object $recipient A {@link $USER} object describing the recipient of the message (used for determining the message language)
* @return array A hash with mail template substitutions
*/
function scheduler_get_mail_variables(scheduler_instance $scheduler, scheduler_slot $slot, $attendant, $attendee, $course, $recipient)
{
global $CFG;
$lang = scheduler_get_message_language($recipient, $course);
// Force any string formatting to happen in the target language.
$oldlang = force_current_language($lang);
$tz = core_date::get_user_timezone($recipient);
$vars = array();
if ($scheduler) {
$vars['MODULE'] = $scheduler->name;
$vars['STAFFROLE'] = $scheduler->get_teacher_name();
$vars['SCHEDULER_URL'] = $CFG->wwwroot . '/mod/scheduler/view.php?id=' . $scheduler->cmid;
}
if ($slot) {
$vars['DATE'] = userdate($slot->starttime, get_string('strftimedate'), $tz);
$vars['TIME'] = userdate($slot->starttime, get_string('strftimetime'), $tz);
$vars['ENDTIME'] = userdate($slot->endtime, get_string('strftimetime'), $tz);
$vars['LOCATION'] = format_string($slot->appointmentlocation);
}
if ($attendant) {
$vars['ATTENDANT'] = fullname($attendant);
$vars['ATTENDANT_URL'] = $CFG->wwwroot . '/user/view.php?id=' . $attendant->id . '&course=' . $scheduler->course;
}
if ($attendee) {
$vars['ATTENDEE'] = fullname($attendee);
$vars['ATTENDEE_URL'] = $CFG->wwwroot . '/user/view.php?id=' . $attendee->id . '&course=' . $scheduler->course;
}
// Reset language settings.
force_current_language($oldlang);
return $vars;
}
示例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;
}
}
// Find the correct timezone for displaying this message.
$tz = core_date::get_user_timezone($currentuser);
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}&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 . '&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) {
case 'me':
//.........这里部分代码省略.........
示例5: dst_offset_on
/**
* Calculates the Daylight Saving Offset for a given date/time (timestamp)
* - Note: Daylight saving only works for string timezones and not for float.
*
* @package core
* @category time
* @param int $time must NOT be compensated at all, it has to be a pure timestamp
* @param int|float|string $strtimezone user timezone
* @return int
*/
function dst_offset_on($time, $strtimezone = null)
{
$tz = core_date::get_user_timezone($strtimezone);
$date = new DateTime('@' . $time);
$date->setTimezone(new DateTimeZone($tz));
if ($date->format('I') == '1') {
if ($tz === 'Australia/Lord_Howe') {
return 1800;
}
return 3600;
}
return 0;
}
示例6: useredit_shared_definition
/**
* Powerful function that is used by edit and editadvanced to add common form elements/rules/etc.
*
* @param moodleform $mform
* @param array $editoroptions
* @param array $filemanageroptions
* @param stdClass $user
*/
function useredit_shared_definition(&$mform, $editoroptions, $filemanageroptions, $user)
{
global $CFG, $USER, $DB;
if ($user->id > 0) {
useredit_load_preferences($user, false);
}
$strrequired = get_string('required');
$stringman = get_string_manager();
// Add the necessary names.
foreach (useredit_get_required_name_fields() as $fullname) {
$mform->addElement('text', $fullname, get_string($fullname), 'maxlength="100" size="30"');
if ($stringman->string_exists('missing' . $fullname, 'core')) {
$strmissingfield = get_string('missing' . $fullname, 'core');
} else {
$strmissingfield = $strrequired;
}
$mform->addRule($fullname, $strmissingfield, 'required', null, 'client');
$mform->setType($fullname, PARAM_NOTAGS);
}
$enabledusernamefields = useredit_get_enabled_name_fields();
// Add the enabled additional name fields.
foreach ($enabledusernamefields as $addname) {
$mform->addElement('text', $addname, get_string($addname), 'maxlength="100" size="30"');
$mform->setType($addname, PARAM_NOTAGS);
}
// Do not show email field if change confirmation is pending.
if ($user->id > 0 and !empty($CFG->emailchangeconfirmation) and !empty($user->preference_newemail)) {
$notice = get_string('emailchangepending', 'auth', $user);
$notice .= '<br /><a href="edit.php?cancelemailchange=1&id=' . $user->id . '">' . get_string('emailchangecancel', 'auth') . '</a>';
$mform->addElement('static', 'emailpending', get_string('email'), $notice);
} else {
$mform->addElement('text', 'email', get_string('email'), 'maxlength="100" size="30"');
$mform->addRule('email', $strrequired, 'required', null, 'client');
$mform->setType('email', PARAM_RAW_TRIMMED);
}
$choices = array();
$choices['0'] = get_string('emaildisplayno');
$choices['1'] = get_string('emaildisplayyes');
$choices['2'] = get_string('emaildisplaycourse');
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', core_user::get_property_default('maildisplay'));
$mform->addElement('text', 'city', get_string('city'), 'maxlength="120" size="21"');
$mform->setType('city', PARAM_TEXT);
if (!empty($CFG->defaultcity)) {
$mform->setDefault('city', $CFG->defaultcity);
}
$choices = get_string_manager()->get_list_of_countries();
$choices = array('' => get_string('selectacountry') . '...') + $choices;
$mform->addElement('select', 'country', get_string('selectacountry'), $choices);
if (!empty($CFG->country)) {
$mform->setDefault('country', core_user::get_property_default('country'));
}
if (isset($CFG->forcetimezone) and $CFG->forcetimezone != 99) {
$choices = core_date::get_list_of_timezones($CFG->forcetimezone);
$mform->addElement('static', 'forcedtimezone', get_string('timezone'), $choices[$CFG->forcetimezone]);
$mform->addElement('hidden', 'timezone');
$mform->setType('timezone', core_user::get_property_type('timezone'));
} else {
$choices = core_date::get_list_of_timezones($user->timezone, true);
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
}
if (!empty($CFG->allowuserthemes)) {
$choices = array();
$choices[''] = get_string('default');
$themes = get_list_of_themes();
foreach ($themes as $key => $theme) {
if (empty($theme->hidefromselector)) {
$choices[$key] = get_string('pluginname', 'theme_' . $theme->name);
}
}
$mform->addElement('select', 'theme', get_string('preferredtheme'), $choices);
}
$mform->addElement('editor', 'description_editor', get_string('userdescription'), null, $editoroptions);
$mform->setType('description_editor', PARAM_CLEANHTML);
$mform->addHelpButton('description_editor', 'userdescription');
if (empty($USER->newadminuser)) {
$mform->addElement('header', 'moodle_picture', get_string('pictureofuser'));
$mform->setExpanded('moodle_picture', true);
if (!empty($CFG->enablegravatar)) {
$mform->addElement('html', html_writer::tag('p', get_string('gravatarenabled')));
}
$mform->addElement('static', 'currentpicture', get_string('currentpicture'));
$mform->addElement('checkbox', 'deletepicture', get_string('delete'));
$mform->setDefault('deletepicture', 0);
$mform->addElement('filemanager', 'imagefile', get_string('newpicture'), '', $filemanageroptions);
$mform->addHelpButton('imagefile', 'newpicture');
$mform->addElement('text', 'imagealt', get_string('imagealt'), 'maxlength="100" size="30"');
$mform->setType('imagealt', PARAM_TEXT);
}
// Display user name fields that are not currenlty enabled here if there are any.
$disabledusernamefields = useredit_get_disabled_name_fields($enabledusernamefields);
if (count($disabledusernamefields) > 0) {
//.........这里部分代码省略.........
示例7: ini_set
$CFG->ostype = 'WINDOWS';
} else {
$CFG->ostype = 'UNIX';
}
$CFG->os = PHP_OS;
// Configure ampersands in URLs
ini_set('arg_separator.output', '&');
// Work around for a PHP bug see MDL-11237
ini_set('pcre.backtrack_limit', 20971520);
// 20 MB
// Work around for PHP7 bug #70110. See MDL-52475 .
if (ini_get('pcre.jit')) {
ini_set('pcre.jit', 0);
}
// Set PHP default timezone to server timezone.
core_date::set_default_server_timezone();
// Location of standard files
$CFG->wordlist = $CFG->libdir . '/wordlist.txt';
$CFG->moddata = 'moddata';
// neutralise nasty chars in PHP_SELF
if (isset($_SERVER['PHP_SELF'])) {
$phppos = strpos($_SERVER['PHP_SELF'], '.php');
if ($phppos !== false) {
$_SERVER['PHP_SELF'] = substr($_SERVER['PHP_SELF'], 0, $phppos + 4);
}
unset($phppos);
}
// initialise ME's - this must be done BEFORE starting of session!
initialise_fullme();
// define SYSCONTEXTID in config.php if you want to save some queries,
// after install it must match the system context record id.
示例8: get_file_list
/**
* Returns a list of files the user has formated for files api
*
* @param string $search A search string to do full text search on the documents
* @return mixed Array of files formated for fileapoi
*/
public function get_file_list($search = '')
{
global $CFG, $OUTPUT;
$url = self::DOCUMENTFEED_URL;
if ($search) {
$url .= '?q=' . urlencode($search);
}
$files = array();
$content = $this->googleoauth->get($url);
try {
if (strpos($content, '<?xml') !== 0) {
throw new moodle_exception('invalidxmlresponse');
}
$xml = new SimpleXMLElement($content);
} catch (Exception $e) {
// An error occured while trying to parse the XML, let's just return nothing. SimpleXML does not
// return a more specific Exception, that's why the global Exception class is caught here.
return $files;
}
date_default_timezone_set(core_date::get_user_timezone());
foreach ($xml->entry as $gdoc) {
$docid = (string) $gdoc->children('http://schemas.google.com/g/2005')->resourceId;
list($type, $docid) = explode(':', $docid);
$title = '';
$source = '';
// FIXME: We're making hard-coded choices about format here.
// If the repo api can support it, we could let the user
// chose.
switch ($type) {
case 'document':
$title = $gdoc->title . '.rtf';
$source = 'https://docs.google.com/feeds/download/documents/Export?id=' . $docid . '&exportFormat=rtf';
break;
case 'presentation':
$title = $gdoc->title . '.ppt';
$source = 'https://docs.google.com/feeds/download/presentations/Export?id=' . $docid . '&exportFormat=ppt';
break;
case 'spreadsheet':
$title = $gdoc->title . '.xls';
$source = 'https://spreadsheets.google.com/feeds/download/spreadsheets/Export?key=' . $docid . '&exportFormat=xls';
break;
case 'pdf':
case 'file':
$title = (string) $gdoc->title;
// Some files don't have a content probably because the download has been restricted.
if (isset($gdoc->content)) {
$source = (string) $gdoc->content[0]->attributes()->src;
}
break;
}
$files[] = array('title' => $title, 'url' => "{$gdoc->link[0]->attributes()->href}", 'source' => $source, 'date' => strtotime($gdoc->updated), 'thumbnail' => (string) $OUTPUT->pix_url(file_extension_icon($title, 32)));
}
core_date::set_default_server_timezone();
return $files;
}
示例9: stats_get_base_monthly
/**
* Start of month
* @param int $time timestamp
* @return int start of month
*/
function stats_get_base_monthly($time = 0)
{
if (empty($time)) {
$time = time();
}
core_date::set_default_server_timezone();
$return = strtotime(date('1-M-Y', $time));
return $return;
}
示例10: calculate_next_automated_backup
/**
* Works out the next time the automated backup should be run.
*
* @param mixed $ignoredtimezone all settings are in server timezone!
* @param int $now timestamp, should not be in the past, most likely time()
* @return int timestamp of the next execution at server time
*/
public static function calculate_next_automated_backup($ignoredtimezone, $now)
{
$config = get_config('backup');
$backuptime = new DateTime('@' . $now);
$backuptime->setTimezone(core_date::get_server_timezone_object());
$backuptime->setTime($config->backup_auto_hour, $config->backup_auto_minute);
while ($backuptime->getTimestamp() < $now) {
$backuptime->add(new DateInterval('P1D'));
}
// Get number of days from backup date to execute backups.
$automateddays = substr($config->backup_auto_weekdays, $backuptime->format('w')) . $config->backup_auto_weekdays;
$daysfromnow = strpos($automateddays, "1");
// Error, there are no days to schedule the backup for.
if ($daysfromnow === false) {
return 0;
}
if ($daysfromnow > 0) {
$backuptime->add(new DateInterval('P' . $daysfromnow . 'D'));
}
return $backuptime->getTimestamp();
}
示例11: prepare_post
/**
* this is a very cut down version of what is in forum_make_mail_post
*
* @global object
* @param int $post
* @return string
*/
private function prepare_post($post, $fileoutputextras = null)
{
global $DB;
static $users;
if (empty($users)) {
$users = array($this->user->id => $this->user);
}
if (!array_key_exists($post->userid, $users)) {
$users[$post->userid] = $DB->get_record('user', array('id' => $post->userid));
}
// add the user object on to the post so we can pass it to the leap writer if necessary
$post->author = $users[$post->userid];
$viewfullnames = true;
// format the post body
$options = portfolio_format_text_options();
$format = $this->get('exporter')->get('format');
$formattedtext = format_text($post->message, $post->messageformat, $options, $this->get('course')->id);
$formattedtext = portfolio_rewrite_pluginfile_urls($formattedtext, $this->modcontext->id, 'mod_forum', 'post', $post->id, $format);
$output = '<table border="0" cellpadding="3" cellspacing="0" class="forumpost">';
$output .= '<tr class="header"><td>';
// can't print picture.
$output .= '</td>';
if ($post->parent) {
$output .= '<td class="topic">';
} else {
$output .= '<td class="topic starter">';
}
$output .= '<div class="subject">' . format_string($post->subject) . '</div>';
$fullname = fullname($users[$post->userid], $viewfullnames);
$by = new stdClass();
$by->name = $fullname;
$by->date = userdate($post->modified, '', core_date::get_user_timezone($this->user));
$output .= '<div class="author">' . get_string('bynameondate', 'forum', $by) . '</div>';
$output .= '</td></tr>';
$output .= '<tr><td class="left side" valign="top">';
$output .= '</td><td class="content">';
$output .= $formattedtext;
if (is_array($this->keyedfiles) && array_key_exists($post->id, $this->keyedfiles) && is_array($this->keyedfiles[$post->id]) && count($this->keyedfiles[$post->id]) > 0) {
$output .= '<div class="attachments">';
$output .= '<br /><b>' . get_string('attachments', 'forum') . '</b>:<br /><br />';
foreach ($this->keyedfiles[$post->id] as $file) {
$output .= $format->file_output($file) . '<br/ >';
}
$output .= "</div>";
}
$output .= '</td></tr></table>' . "\n\n";
return $output;
}
示例12: 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;
}
示例13: defined
*/
defined('MOODLE_INTERNAL') || die;
if ($ADMIN->fulltree) {
$settings->add(new admin_setting_heading('enrol_lti_settings', '', get_string('pluginname_desc', 'enrol_lti')));
if (!is_enabled_auth('lti')) {
$notify = new \core\output\notification(get_string('authltimustbeenabled', 'enrol_lti'), \core\output\notification::NOTIFY_WARNING);
$settings->add(new admin_setting_heading('enrol_lti_enable_auth_lti', '', $OUTPUT->render($notify)));
}
if (empty($CFG->allowframembedding)) {
$notify = new \core\output\notification(get_string('allowframeembedding', 'enrol_lti'), \core\output\notification::NOTIFY_WARNING);
$settings->add(new admin_setting_heading('enrol_lti_enable_embedding', '', $OUTPUT->render($notify)));
}
$settings->add(new admin_setting_heading('enrol_lti_user_default_values', get_string('userdefaultvalues', 'enrol_lti'), ''));
$choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
$maildisplay = isset($CFG->defaultpreference_maildisplay) ? $CFG->defaultpreference_maildisplay : 2;
$settings->add(new admin_setting_configselect('enrol_lti/emaildisplay', get_string('emaildisplay'), '', $maildisplay, $choices));
$city = '';
if (!empty($CFG->defaultcity)) {
$city = $CFG->defaultcity;
}
$settings->add(new admin_setting_configtext('enrol_lti/city', get_string('city'), '', $city));
$country = '';
if (!empty($CFG->country)) {
$country = $CFG->country;
}
$countries = array('' => get_string('selectacountry') . '...') + get_string_manager()->get_list_of_countries();
$settings->add(new admin_setting_configselect('enrol_lti/country', get_string('selectacountry'), '', $country, $countries));
$settings->add(new admin_setting_configselect('enrol_lti/timezone', get_string('timezone'), '', 99, core_date::get_list_of_timezones(null, true)));
$settings->add(new admin_setting_configselect('enrol_lti/lang', get_string('preferredlanguage'), '', $CFG->lang, get_string_manager()->get_list_of_translations()));
$settings->add(new admin_setting_configtext('enrol_lti/institution', get_string('institution'), '', ''));
}
示例14: definition
public function definition()
{
global $USER, $CFG, $COURSE;
$mform =& $this->_form;
$templateuser = $USER;
$context = $this->_customdata['context'];
$mform->addElement('header', 'settingsheader', get_string('toolsettings', 'local_ltiprovider'));
$tools = array();
$tools[$context->id] = get_string('course');
$modinfo = get_fast_modinfo($this->_customdata['courseid']);
$mods = $modinfo->get_cms();
foreach ($mods as $mod) {
$tools[$mod->context->id] = format_string($mod->name);
}
$mform->addElement('select', 'contextid', get_string('tooltobeprovide', 'local_ltiprovider'), $tools);
$mform->setDefault('contextid', $context->id);
$mform->addElement('checkbox', 'sendgrades', null, get_string('sendgrades', 'local_ltiprovider'));
$mform->setDefault('sendgrades', 1);
$mform->addElement('checkbox', 'requirecompletion', null, get_string('requirecompletion', 'local_ltiprovider'));
$mform->setDefault('requirecompletion', 0);
$mform->disabledIf('requirecompletion', 'sendgrades');
$mform->addElement('checkbox', 'forcenavigation', null, get_string('forcenavigation', 'local_ltiprovider'));
$mform->setDefault('forcenavigation', 1);
$mform->addElement('duration', 'enrolperiod', get_string('enrolperiod', 'local_ltiprovider'), array('optional' => true, 'defaultunit' => 86400));
$mform->setDefault('enrolperiod', 0);
$mform->addHelpButton('enrolperiod', 'enrolperiod', 'local_ltiprovider');
$mform->addElement('date_selector', 'enrolstartdate', get_string('enrolstartdate', 'local_ltiprovider'), array('optional' => true));
$mform->setDefault('enrolstartdate', 0);
$mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'local_ltiprovider');
$mform->addElement('date_selector', 'enrolenddate', get_string('enrolenddate', 'local_ltiprovider'), array('optional' => true));
$mform->setDefault('enrolenddate', 0);
$mform->addHelpButton('enrolenddate', 'enrolenddate', 'local_ltiprovider');
$mform->addElement('text', 'maxenrolled', get_string('maxenrolled', 'local_ltiprovider'));
$mform->setDefault('maxenrolled', 0);
$mform->addHelpButton('maxenrolled', 'maxenrolled', 'local_ltiprovider');
$mform->setType('maxenrolled', PARAM_INT);
$assignableroles = get_assignable_roles($context);
$mform->addElement('checkbox', 'enrolinst', null, get_string('enrolinst', 'local_ltiprovider'));
$mform->setDefault('enrolinst', 1);
$mform->addHelpButton('enrolinst', 'enrolinst', 'local_ltiprovider');
$mform->setAdvanced('enrolinst');
$mform->addElement('checkbox', 'enrollearn', null, get_string('enrollearn', 'local_ltiprovider'));
$mform->setDefault('enrollearn', 1);
$mform->addHelpButton('enrollearn', 'enrollearn', 'local_ltiprovider');
$mform->setAdvanced('enrollearn');
$mform->addElement('select', 'croleinst', get_string('courseroleinstructor', 'local_ltiprovider'), $assignableroles);
$mform->setDefault('croleinst', '3');
$mform->setAdvanced('croleinst');
$mform->addElement('select', 'crolelearn', get_string('courserolelearner', 'local_ltiprovider'), $assignableroles);
$mform->setDefault('crolelearn', '5');
$mform->setAdvanced('crolelearn');
$mform->addElement('select', 'aroleinst', get_string('activityroleinstructor', 'local_ltiprovider'), $assignableroles);
$mform->disabledIf('aroleinst', 'contextid', 'eq', $context->id);
$mform->setDefault('aroleinst', '3');
$mform->setAdvanced('aroleinst');
$mform->addElement('select', 'arolelearn', get_string('activityrolelearner', 'local_ltiprovider'), $assignableroles);
$mform->disabledIf('arolelearn', 'contextid', 'eq', $context->id);
$mform->setDefault('arolelearn', '5');
$mform->setAdvanced('arolelearn');
$mform->addElement('header', 'remotesystem', get_string('remotesystem', 'local_ltiprovider'));
$mform->addElement('text', 'secret', get_string('secret', 'local_ltiprovider'), 'maxlength="64" size="25"');
$mform->setType('secret', PARAM_MULTILANG);
$mform->setDefault('secret', md5(uniqid(rand(), 1)));
$mform->addRule('secret', get_string('required'), 'required');
$choices = core_text::get_encodings();
$mform->addElement('select', 'encoding', get_string('remoteencoding', 'local_ltiprovider'), $choices);
$mform->setDefault('encoding', 'UTF-8');
$mform->addElement('header', 'defaultheader', get_string('userdefaultvalues', 'local_ltiprovider'));
$choices = array(0 => get_string('never'), 1 => get_string('always'));
$mform->addElement('select', 'userprofileupdate', get_string('userprofileupdate', 'local_ltiprovider'), $choices);
$userprofileupdate = get_config('local_ltiprovider', 'userprofileupdate');
if ($userprofileupdate != -1) {
$mform->setDefault('userprofileupdate', $userprofileupdate);
$mform->freeze('userprofileupdate');
} else {
$mform->setDefault('userprofileupdate', 1);
}
$choices = array(0 => get_string('emaildisplayno'), 1 => get_string('emaildisplayyes'), 2 => get_string('emaildisplaycourse'));
$mform->addElement('select', 'maildisplay', get_string('emaildisplay'), $choices);
$mform->setDefault('maildisplay', 2);
$mform->addElement('text', 'city', get_string('city'), 'maxlength="100" size="25"');
$mform->setType('city', PARAM_MULTILANG);
if (empty($CFG->defaultcity)) {
$mform->setDefault('city', $templateuser->city);
} else {
$mform->setDefault('city', $CFG->defaultcity);
}
$mform->addElement('select', 'country', get_string('selectacountry'), get_string_manager()->get_list_of_countries());
if (empty($CFG->country)) {
$mform->setDefault('country', $templateuser->country);
} else {
$mform->setDefault('country', $CFG->country);
}
$mform->setAdvanced('country');
$choices = core_date::get_list_of_timezones();
$choices['99'] = get_string('serverlocaltime');
$mform->addElement('select', 'timezone', get_string('timezone'), $choices);
$mform->setDefault('timezone', $templateuser->timezone);
$mform->setAdvanced('timezone');
$mform->addElement('select', 'lang', get_string('preferredlanguage'), get_string_manager()->get_list_of_translations());
//.........这里部分代码省略.........
示例15: get_content
/**
* Creates the block's main content
*
* @return string
*/
public function get_content()
{
global $USER, $OUTPUT, $CFG;
if (isset($this->content)) {
return $this->content;
}
// Establish settings variables based on instance config.
$showserverclock = !isset($this->config->show_clocks) || $this->config->show_clocks == B_SIMPLE_CLOCK_SHOW_BOTH || $this->config->show_clocks == B_SIMPLE_CLOCK_SHOW_SERVER_ONLY;
$showuserclock = !isset($this->config->show_clocks) || $this->config->show_clocks == B_SIMPLE_CLOCK_SHOW_BOTH || $this->config->show_clocks == B_SIMPLE_CLOCK_SHOW_USER_ONLY;
$showicons = !isset($this->config->show_icons) || $this->config->show_icons == 1;
$showseconds = isset($this->config->show_seconds) && $this->config->show_seconds == 1;
$showday = isset($this->config->show_day) && $this->config->show_day == 1;
$show24hrtime = isset($this->config->twenty_four_hour_time) && $this->config->twenty_four_hour_time == 1;
// Start the content, which is primarily a table.
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
$table = new html_table();
$table->attributes = array('class' => 'clockTable');
// First item added is the server's clock.
if ($showserverclock) {
$row = array();
if ($showicons) {
$alt = get_string('server', 'block_simple_clock');
$usingie = false;
if (class_exists('core_useragent')) {
$usingie = core_useragent::is_ie();
} else {
$usingie = check_browser_version('MSIE');
}
if ($usingie) {
$servericon = $OUTPUT->pix_icon('server', $alt, 'block_simple_clock');
} else {
$servericon = $OUTPUT->pix_icon('favicon', $alt, 'theme');
}
$row[] = $servericon;
}
$row[] = get_string('server', 'block_simple_clock') . ':';
$attributes = array();
$attributes['class'] = 'clock';
$attributes['id'] = 'block_progress_serverTime';
$attributes['value'] = get_string('loading', 'block_simple_clock');
$row[] = HTML_WRITER::empty_tag('input', $attributes);
$table->data[] = $row;
}
// Next item is the user's clock.
if ($showuserclock) {
$row = array();
if ($showicons) {
if ($USER->id != 0) {
$userpictureparams = array('size' => 16, 'link' => false, 'alt' => 'User');
$userpicture = $OUTPUT->user_picture($USER, $userpictureparams);
$row[] = $userpicture;
} else {
$row[] = '';
}
}
$row[] = get_string('you', 'block_simple_clock') . ':';
$attributes = array();
$attributes['class'] = 'clock';
$attributes['id'] = 'block_progress_youTime';
$attributes['value'] = get_string('loading', 'block_simple_clock');
$row[] = HTML_WRITER::empty_tag('input', $attributes);
$table->data[] = $row;
}
$this->content->text .= HTML_WRITER::table($table);
// Set up JavaScript code needed to keep the clock going.
$noscriptstring = get_string('javascript_disabled', 'block_simple_clock');
$this->content->text .= HTML_WRITER::tag('noscript', $noscriptstring);
if ($CFG->timezone != 99) {
// Ensure that the Moodle timezone is set correctly.
$date = new DateTime('now', new DateTimeZone(core_date::normalise_timezone($CFG->timezone)));
$moodletimeoffset = $date->getOffset();
// + dst_offset_on(time(), $CFG->timezone);
$servertimeoffset = date_offset_get(new DateTime());
$timearray = localtime(time() + $moodletimeoffset - $servertimeoffset, true);
} else {
// Ensure that the server timezone is set.
// From 2.9 onwards, this should never happen.
$timearray = localtime(time(), true);
}
$arguments = array($showserverclock, $showuserclock, $showseconds, $showday, $show24hrtime, $timearray['tm_year'] + 1900, $timearray['tm_mon'], $timearray['tm_mday'], $timearray['tm_hour'], $timearray['tm_min'], $timearray['tm_sec'] + 2);
$jsmodule = array('name' => 'block_simple_clock', 'fullpath' => '/blocks/simple_clock/module.js', 'requires' => array(), 'strings' => array(array('clock_separator', 'block_simple_clock'), array('before_noon', 'block_simple_clock'), array('after_noon', 'block_simple_clock'), array('day_names', 'block_simple_clock')));
$this->page->requires->js_init_call('M.block_simple_clock.initSimpleClock', $arguments, false, $jsmodule);
$this->content->footer = '';
return $this->content;
}