本文整理汇总了PHP中core_user类的典型用法代码示例。如果您正苦于以下问题:PHP core_user类的具体用法?PHP core_user怎么用?PHP core_user使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了core_user类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: reset_all_data
/**
* Reset contents of all database tables to initial values, reset caches, etc.
*
* Note: this is relatively slow (cca 2 seconds for pg and 7 for mysql) - please use with care!
*
* @static
* @param bool $detectchanges
* true - changes in global state and database are reported as errors
* false - no errors reported
* null - only critical problems are reported as errors
* @return void
*/
public static function reset_all_data($detectchanges = false)
{
global $DB, $CFG, $USER, $SITE, $COURSE, $PAGE, $OUTPUT, $SESSION;
// Stop any message redirection.
phpunit_util::stop_message_redirection();
// Stop any message redirection.
phpunit_util::stop_phpmailer_redirection();
// Stop any message redirection.
phpunit_util::stop_event_redirection();
// We used to call gc_collect_cycles here to ensure desctructors were called between tests.
// This accounted for 25% of the total time running phpunit - so we removed it.
// Show any unhandled debugging messages, the runbare() could already reset it.
self::display_debugging_messages();
self::reset_debugging();
// reset global $DB in case somebody mocked it
$DB = self::get_global_backup('DB');
if ($DB->is_transaction_started()) {
// we can not reset inside transaction
$DB->force_transaction_rollback();
}
$resetdb = self::reset_database();
$warnings = array();
if ($detectchanges === true) {
if ($resetdb) {
$warnings[] = 'Warning: unexpected database modification, resetting DB state';
}
$oldcfg = self::get_global_backup('CFG');
$oldsite = self::get_global_backup('SITE');
foreach ($CFG as $k => $v) {
if (!property_exists($oldcfg, $k)) {
$warnings[] = 'Warning: unexpected new $CFG->' . $k . ' value';
} else {
if ($oldcfg->{$k} !== $CFG->{$k}) {
$warnings[] = 'Warning: unexpected change of $CFG->' . $k . ' value';
}
}
unset($oldcfg->{$k});
}
if ($oldcfg) {
foreach ($oldcfg as $k => $v) {
$warnings[] = 'Warning: unexpected removal of $CFG->' . $k;
}
}
if ($USER->id != 0) {
$warnings[] = 'Warning: unexpected change of $USER';
}
if ($COURSE->id != $oldsite->id) {
$warnings[] = 'Warning: unexpected change of $COURSE';
}
}
if (ini_get('max_execution_time') != 0) {
// This is special warning for all resets because we do not want any
// libraries to mess with timeouts unintentionally.
// Our PHPUnit integration is not supposed to change it either.
if ($detectchanges !== false) {
$warnings[] = 'Warning: max_execution_time was changed to ' . ini_get('max_execution_time');
}
set_time_limit(0);
}
// restore original globals
$_SERVER = self::get_global_backup('_SERVER');
$CFG = self::get_global_backup('CFG');
$SITE = self::get_global_backup('SITE');
$_GET = array();
$_POST = array();
$_FILES = array();
$_REQUEST = array();
$COURSE = $SITE;
// reinitialise following globals
$OUTPUT = new bootstrap_renderer();
$PAGE = new moodle_page();
$FULLME = null;
$ME = null;
$SCRIPT = null;
// Empty sessison and set fresh new not-logged-in user.
\core\session\manager::init_empty_session();
// reset all static caches
\core\event\manager::phpunit_reset();
accesslib_clear_all_caches(true);
get_string_manager()->reset_caches(true);
reset_text_filters_cache(true);
events_get_handlers('reset');
core_text::reset_caches();
get_message_processors(false, true);
filter_manager::reset_caches();
// Reset internal users.
core_user::reset_internal_users();
//TODO MDL-25290: add more resets here and probably refactor them to new core function
//.........这里部分代码省略.........
开发者ID:sumitnegi933,项目名称:Moodle_lms_New,代码行数:101,代码来源:util.php
示例2: local_sandbox_inform_admin
/**
* Helper function for sending notification mails
*
* @param string $message The message
* @param int $level Notification level
* @return
*/
function local_sandbox_inform_admin($message, $level = SANDBOX_LEVEL_NOTICE)
{
// Get recipients
$recipients = get_users_from_config(get_config('local_sandbox', 'notifyonerrors'), 'moodle/site:config');
// If there are no recipients, don't execute.
if (!is_array($recipients) || count($recipients) <= 0) {
return false;
}
// If message level is below configured notice level, don't execute
if ($level < get_config('local_sandbox', 'notifylevel')) {
return false;
}
// Get subject
if ($level > SANDBOX_LEVEL_WARNING) {
$subject = get_string('emailsubjecterror', 'local_sandbox');
} else {
if ($level > SANDBOX_LEVEL_NOTICE) {
$subject = get_string('emailsubjectwarning', 'local_sandbox');
} else {
$subject = get_string('emailsubjectnotice', 'local_sandbox');
}
}
// Send mail
foreach ($recipients as $r) {
// Email the admin directly rather than putting these through the messaging system
email_to_user($r, core_user::get_support_user(), $subject, $message);
}
}
开发者ID:andrewhancox,项目名称:moodle-local_sandbox,代码行数:35,代码来源:lib.php
示例3: generate_message
/**
* Generates the message object for a give subscription and event.
*
* @param int $subscriptionid Subscription instance
* @param \stdClass $eventobj Event data
*
* @return false|\stdClass message object
*/
protected function generate_message($subscriptionid, \stdClass $eventobj)
{
try {
$subscription = subscription_manager::get_subscription($subscriptionid);
} catch (\dml_exception $e) {
// Race condition, someone deleted the subscription.
return false;
}
$user = \core_user::get_user($subscription->userid);
$context = \context_user::instance($user->id, IGNORE_MISSING);
if ($context === false) {
// User context doesn't exist. Should never happen, nothing to do return.
return false;
}
$template = $subscription->template;
$template = $this->replace_placeholders($template, $subscription, $eventobj, $context);
$msgdata = new \stdClass();
$msgdata->component = 'tool_monitor';
// Your component name.
$msgdata->name = 'notification';
// This is the message name from messages.php.
$msgdata->userfrom = \core_user::get_noreply_user();
$msgdata->userto = $user;
$msgdata->subject = $subscription->get_name($context);
$msgdata->fullmessage = format_text($template, $subscription->templateformat, array('context' => $context));
$msgdata->fullmessageformat = $subscription->templateformat;
$msgdata->fullmessagehtml = format_text($template, $subscription->templateformat, array('context' => $context));
$msgdata->smallmessage = '';
$msgdata->notification = 1;
// This is only set to 0 for personal messages between users.
return $msgdata;
}
开发者ID:HuiChangZhai,项目名称:moodle,代码行数:40,代码来源:notification_task.php
示例4: definition
/**
* Define the form.
*/
public function definition()
{
global $CFG, $COURSE;
$mform = $this->_form;
$choices = array();
$choices['0'] = get_string('emaildigestoff');
$choices['1'] = get_string('emaildigestcomplete');
$choices['2'] = get_string('emaildigestsubjects');
$mform->addElement('select', 'maildigest', get_string('emaildigest'), $choices);
$mform->setDefault('maildigest', core_user::get_property_default('maildigest'));
$mform->addHelpButton('maildigest', 'emaildigest');
$choices = array();
$choices['1'] = get_string('autosubscribeyes');
$choices['0'] = get_string('autosubscribeno');
$mform->addElement('select', 'autosubscribe', get_string('autosubscribe'), $choices);
$mform->setDefault('autosubscribe', core_user::get_property_default('autosubscribe'));
if (!empty($CFG->forum_trackreadposts)) {
$choices = array();
$choices['0'] = get_string('trackforumsno');
$choices['1'] = get_string('trackforumsyes');
$mform->addElement('select', 'trackforums', get_string('trackforums'), $choices);
$mform->setDefault('trackforums', core_user::get_property_default('trackforums'));
}
// Add some extra hidden fields.
$mform->addElement('hidden', 'id');
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'course', $COURSE->id);
$mform->setType('course', PARAM_INT);
$this->add_action_buttons(true, get_string('savechanges'));
}
开发者ID:evltuma,项目名称:moodle,代码行数:33,代码来源:forum_form.php
示例5: export_for_template
public function export_for_template(\renderer_base $output)
{
$data = new \stdClass();
$data->contacts = array();
$userids = array();
foreach ($this->contacts as $contact) {
$contact = new contact($contact);
$contactdata = $contact->export_for_template($output);
$userids[$contactdata->userid] = $contactdata->userid;
// Check if the contact was selected.
if ($this->contactuserid == $contactdata->userid) {
$contactdata->selected = true;
}
$data->contacts[] = $contactdata;
}
// Check if the other user is not part of the contacts. We may be sending a message to someone
// we have not had a conversation with, so we want to add a new item to the contacts array.
if ($this->contactuserid && !isset($userids[$this->contactuserid])) {
$user = \core_user::get_user($this->contactuserid);
// Set an empty message so that we know we are messaging the user, and not viewing their profile.
$user->smallmessage = '';
$user->useridfrom = $user->id;
$contact = \core_message\helper::create_contact($user);
$contact = new contact($contact);
$contactdata = $contact->export_for_template($output);
$contactdata->selected = true;
// Put the contact at the front.
array_unshift($data->contacts, $contactdata);
}
return $data;
}
开发者ID:dg711,项目名称:moodle,代码行数:31,代码来源:contacts.php
示例6: get_popup_notifications
/**
* Get popup notifications for the specified users. Nothing is returned if notifications are disabled.
*
* @param int $useridto the user id who received the notification
* @param string $sort the column name to order by including optionally direction
* @param int $limit limit the number of result returned
* @param int $offset offset the result set by this amount
* @return array notification records
* @throws \moodle_exception
* @since 3.2
*/
public static function get_popup_notifications($useridto = 0, $sort = 'DESC', $limit = 0, $offset = 0)
{
global $DB, $USER;
$sort = strtoupper($sort);
if ($sort != 'DESC' && $sort != 'ASC') {
throw new \moodle_exception('invalid parameter: sort: must be "DESC" or "ASC"');
}
if (empty($useridto)) {
$useridto = $USER->id;
}
$params = ['useridto1' => $useridto, 'useridto2' => $useridto];
// Is notification enabled ?
if ($useridto == $USER->id) {
$disabled = $USER->emailstop;
} else {
$user = \core_user::get_user($useridto, "emailstop", MUST_EXIST);
$disabled = $user->emailstop;
}
if ($disabled) {
// Notifications are disabled, no need to run giant queries.
return array();
}
$sql = "SELECT * FROM (\n SELECT concat('r', r.id) as uniqueid, r.id, r.useridfrom, r.useridto,\n r.subject, r.fullmessage, r.fullmessageformat,\n r.fullmessagehtml, r.smallmessage, r.notification, r.contexturl,\n r.contexturlname, r.timecreated, r.timeuserfromdeleted, r.timeusertodeleted,\n r.component, r.eventtype, r.timeread\n FROM {message_read} r\n WHERE r.notification = 1\n AND r.id IN (SELECT messageid FROM {message_popup} WHERE isread = 1)\n AND r.useridto = :useridto1\n UNION ALL\n SELECT concat('u', u.id) as uniqueid, u.id, u.useridfrom, u.useridto,\n u.subject, u.fullmessage, u.fullmessageformat,\n u.fullmessagehtml, u.smallmessage, u.notification, u.contexturl,\n u.contexturlname, u.timecreated, u.timeuserfromdeleted, u.timeusertodeleted,\n u.component, u.eventtype, 0 as timeread\n FROM {message} u\n WHERE u.notification = 1\n AND u.id IN (SELECT messageid FROM {message_popup} WHERE isread = 0)\n AND u.useridto = :useridto2\n ) f ORDER BY timecreated {$sort}, timeread {$sort}, id {$sort}";
return array_values($DB->get_records_sql($sql, $params, $offset, $limit));
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:36,代码来源:api.php
示例7: __construct
/**
* Constructor.
*
* @param int $currentuserid The current user we are wanting to view messages for
* @param int $otheruserid The other user we are wanting to view messages for
* @param array $messages
*/
public function __construct($currentuserid, $otheruserid, $messages)
{
$ufields = 'id, ' . get_all_user_name_fields(true) . ', lastaccess';
$this->currentuserid = $currentuserid;
if ($otheruserid) {
$this->otheruserid = $otheruserid;
$this->otheruser = \core_user::get_user($otheruserid, $ufields, MUST_EXIST);
}
$this->messages = $messages;
}
开发者ID:Chocolate-lightning,项目名称:moodle,代码行数:17,代码来源:messages.php
示例8: definition_after_data
/**
* Extend the form definition after the data has been parsed.
*/
public function definition_after_data()
{
global $CFG, $DB, $OUTPUT;
$mform = $this->_form;
// If language does not exist, use site default lang.
if ($langsel = $mform->getElementValue('lang')) {
$lang = reset($langsel);
// Check lang exists.
if (!get_string_manager()->translation_exists($lang, false)) {
$langel =& $mform->getElement('lang');
$langel->setValue(core_user::get_property_default('lang'));
}
}
}
开发者ID:evltuma,项目名称:moodle,代码行数:17,代码来源:language_form.php
示例9: test_create_user
public function test_create_user()
{
global $DB, $CFG;
require_once $CFG->dirroot . '/user/lib.php';
$this->resetAfterTest(true);
$generator = $this->getDataGenerator();
$count = $DB->count_records('user');
$this->setCurrentTimeStart();
$user = $generator->create_user();
$this->assertEquals($count + 1, $DB->count_records('user'));
$this->assertSame($user->username, core_user::clean_field($user->username, 'username'));
$this->assertSame($user->email, core_user::clean_field($user->email, 'email'));
$this->assertSame(AUTH_PASSWORD_NOT_CACHED, $user->password);
$this->assertNotEmpty($user->firstnamephonetic);
$this->assertNotEmpty($user->lastnamephonetic);
$this->assertNotEmpty($user->alternatename);
$this->assertNotEmpty($user->middlename);
$this->assertSame('manual', $user->auth);
$this->assertSame('en', $user->lang);
$this->assertSame('1', $user->confirmed);
$this->assertSame('0', $user->deleted);
$this->assertTimeCurrent($user->timecreated);
$this->assertSame($user->timecreated, $user->timemodified);
$this->assertSame('0.0.0.0', $user->lastip);
$record = array('auth' => 'email', 'firstname' => 'Žluťoučký', 'lastname' => 'Koníček', 'firstnamephonetic' => 'Zhlutyoucky', 'lastnamephonetic' => 'Koniiczek', 'middlename' => 'Hopper', 'alternatename' => 'horse', 'idnumber' => 'abc1', 'mnethostid' => (string) $CFG->mnet_localhost_id, 'username' => 'konic666', 'password' => 'password1', 'email' => '[email protected]', 'confirmed' => '1', 'lang' => 'cs', 'maildisplay' => '1', 'mailformat' => '0', 'maildigest' => '1', 'autosubscribe' => '0', 'trackforums' => '0', 'deleted' => '0', 'timecreated' => '666');
$user = $generator->create_user($record);
$this->assertEquals($count + 2, $DB->count_records('user'));
foreach ($record as $k => $v) {
if ($k === 'password') {
$this->assertTrue(password_verify($v, $user->password));
} else {
$this->assertSame($v, $user->{$k});
}
}
$record = array('firstname' => 'Some', 'lastname' => 'User', 'idnumber' => 'def', 'username' => 'user666', 'email' => '[email protected]', 'deleted' => '1');
$user = $generator->create_user($record);
$this->assertEquals($count + 3, $DB->count_records('user'));
$this->assertSame('', $user->idnumber);
$this->assertSame(md5($record['username']), $user->email);
$this->assertFalse(context_user::instance($user->id, IGNORE_MISSING));
// Test generating user with interests.
$user = $generator->create_user(array('interests' => 'Cats, Dogs'));
$userdetails = user_get_user_details($user);
$this->assertSame('Cats, Dogs', $userdetails['interests']);
}
开发者ID:IFPBMoodle,项目名称:moodle,代码行数:45,代码来源:generator_test.php
示例10: send_message
/**
* Send non-submitters message to students.
*
* @param string $message
* @return void
*/
public function send_message($userid, $subject, $message)
{
$eventdata = new stdClass();
$eventdata->component = 'mod_turnitintooltwo';
//your component name
$eventdata->name = 'nonsubmitters';
//this is the message name from messages.php
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->userto = $userid;
$eventdata->subject = $subject;
$eventdata->fullmessage = $message;
$eventdata->fullmessageformat = FORMAT_HTML;
$eventdata->fullmessagehtml = $message;
$eventdata->smallmessage = '';
$eventdata->notification = 1;
//this is only set to 0 for personal messages between users
message_send($eventdata);
}
开发者ID:uofr,项目名称:moodle-mod_turnitintooltwo,代码行数:24,代码来源:nonsubmitters_message.php
示例11: report_log_print_graph
/**
* This function is used to generate and display the log activity graph
*
* @global stdClass $CFG
* @param stdClass $course course instance
* @param int|stdClass $user id/object of the user whose logs are needed
* @param string $typeormode type of logs graph needed (usercourse.png/userday.png) or the mode (today, all).
* @param int $date timestamp in GMT (seconds since epoch)
* @param string $logreader Log reader.
* @return void
*/
function report_log_print_graph($course, $user, $typeormode, $date = 0, $logreader = '')
{
global $CFG, $OUTPUT;
if (!is_object($user)) {
$user = core_user::get_user($user);
}
$logmanager = get_log_manager();
$readers = $logmanager->get_readers();
if (empty($logreader)) {
$reader = reset($readers);
} else {
$reader = $readers[$logreader];
}
// If reader is not a sql_internal_table_reader and not legacy store then don't show graph.
if (!$reader instanceof \core\log\sql_internal_table_reader && !$reader instanceof logstore_legacy\log\store) {
return array();
}
$coursecontext = context_course::instance($course->id);
$a = new stdClass();
$a->coursename = format_string($course->shortname, true, array('context' => $coursecontext));
$a->username = fullname($user, true);
if ($typeormode == 'today' || $typeormode == 'userday.png') {
$logs = report_log_usertoday_data($course, $user, $date, $logreader);
$title = get_string("hitsoncoursetoday", "", $a);
} else {
if ($typeormode == 'all' || $typeormode == 'usercourse.png') {
$logs = report_log_userall_data($course, $user, $logreader);
$title = get_string("hitsoncourse", "", $a);
}
}
if (!empty($CFG->preferlinegraphs)) {
$chart = new \core\chart_line();
} else {
$chart = new \core\chart_bar();
}
$series = new \core\chart_series(get_string("hits"), $logs['series']);
$chart->add_series($series);
$chart->set_title($title);
$chart->set_labels($logs['labels']);
$yaxis = $chart->get_yaxis(0, true);
$yaxis->set_label(get_string("hits"));
$yaxis->set_stepsize(max(1, round(max($logs['series']) / 10)));
echo $OUTPUT->render($chart);
}
开发者ID:gabrielrosset,项目名称:moodle,代码行数:55,代码来源:locallib.php
示例12: get_user_badges
/**
* Returns the list of badges awarded to a user.
*
* @param int $userid user id
* @param int $courseid course id
* @param int $page page of records to return
* @param int $perpage number of records to return per page
* @param string $search a simple string to search for
* @param bool $onlypublic whether to return only public badges
* @return array array containing warnings and the awarded badges
* @since Moodle 3.1
* @throws moodle_exception
*/
public static function get_user_badges($userid = 0, $courseid = 0, $page = 0, $perpage = 0, $search = '', $onlypublic = false)
{
global $CFG, $USER;
$warnings = array();
$params = array('userid' => $userid, 'courseid' => $courseid, 'page' => $page, 'perpage' => $perpage, 'search' => $search, 'onlypublic' => $onlypublic);
$params = self::validate_parameters(self::get_user_badges_parameters(), $params);
if (empty($CFG->enablebadges)) {
throw new moodle_exception('badgesdisabled', 'badges');
}
if (empty($CFG->badges_allowcoursebadges) && $params['courseid'] != 0) {
throw new moodle_exception('coursebadgesdisabled', 'badges');
}
// Default value for userid.
if (empty($params['userid'])) {
$params['userid'] = $USER->id;
}
// Validate the user.
$user = core_user::get_user($params['userid'], '*', MUST_EXIST);
core_user::require_active_user($user);
$usercontext = context_user::instance($user->id);
self::validate_context($usercontext);
if ($USER->id != $user->id) {
require_capability('moodle/badges:viewotherbadges', $usercontext);
// We are looking other user's badges, we must retrieve only public badges.
$params['onlypublic'] = true;
}
$userbadges = badges_get_user_badges($user->id, $params['courseid'], $params['page'], $params['perpage'], $params['search'], $params['onlypublic']);
$result = array();
$result['badges'] = array();
$result['warnings'] = $warnings;
foreach ($userbadges as $badge) {
$context = $badge->type == BADGE_TYPE_SITE ? context_system::instance() : context_course::instance($badge->courseid);
$badge->badgeurl = moodle_url::make_webservice_pluginfile_url($context->id, 'badges', 'badgeimage', $badge->id, '/', 'f1')->out(false);
// Return all the information if we are requesting our own badges.
// Or, if we have permissions for configuring badges in the badge context.
if ($USER->id == $user->id or has_capability('moodle/badges:configuredetails', $context)) {
$result['badges'][] = (array) $badge;
} else {
$result['badges'][] = array('name' => $badge->name, 'description' => $badge->description, 'badgeurl' => $badge->badgeurl, 'issuername' => $badge->issuername, 'issuerurl' => $badge->issuerurl, 'issuercontact' => $badge->issuercontact, 'uniquehash' => $badge->uniquehash, 'dateissued' => $badge->dateissued, 'dateexpire' => $badge->dateexpire);
}
}
return $result;
}
开发者ID:evltuma,项目名称:moodle,代码行数:56,代码来源:external.php
示例13: test_get_user
public function test_get_user()
{
global $CFG;
$this->resetAfterTest(true);
// Create user and try fetach it with api.
$user = $this->getDataGenerator()->create_user();
$this->assertEquals($user, core_user::get_user($user->id, '*', MUST_EXIST));
// Test noreply user.
$CFG->noreplyuserid = null;
$noreplyuser = core_user::get_noreply_user();
$this->assertEquals(1, $noreplyuser->emailstop);
$this->assertFalse(core_user::is_real_user($noreplyuser->id));
$this->assertEquals($CFG->noreplyaddress, $noreplyuser->email);
$this->assertEquals(get_string('noreplyname'), $noreplyuser->firstname);
// Set user as noreply user and make sure noreply propery is set.
core_user::reset_internal_users();
$CFG->noreplyuserid = $user->id;
$noreplyuser = core_user::get_noreply_user();
$this->assertEquals(1, $noreplyuser->emailstop);
$this->assertTrue(core_user::is_real_user($noreplyuser->id));
// Test support user.
core_user::reset_internal_users();
$CFG->supportemail = null;
$CFG->noreplyuserid = null;
$supportuser = core_user::get_support_user();
$adminuser = get_admin();
$this->assertEquals($adminuser, $supportuser);
$this->assertTrue(core_user::is_real_user($supportuser->id));
// When supportemail is set.
core_user::reset_internal_users();
$CFG->supportemail = '[email protected]';
$supportuser = core_user::get_support_user();
$this->assertEquals(core_user::SUPPORT_USER, $supportuser->id);
$this->assertFalse(core_user::is_real_user($supportuser->id));
// Set user as support user and make sure noreply propery is set.
core_user::reset_internal_users();
$CFG->supportuserid = $user->id;
$supportuser = core_user::get_support_user();
$this->assertEquals($user, $supportuser);
$this->assertTrue(core_user::is_real_user($supportuser->id));
}
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:41,代码来源:user_test.php
示例14: activenotification
function activenotification($id){
global $DB, $USER, $CFG,$COURSE,$PAGE,$OUTPUT;
//Batch Name
$batchname=$DB->get_field('facetoface','name',array('id'=>$id));
//getting batch users
$batch_users=$DB->get_records_sql("select * from {local_batch_users} where f2fid=$id");
//getting session details
$session_details=$DB->get_records_sql("select * from {facetoface_sessions} where facetoface=$id");
$sessionsingle="<table border='1' style='text-align:center;'><tr><th>Serial</th><th>Startdate</th><th>Enddate</th><th>Classroom</th></tr>";
$n=1;
foreach($session_details as $session_detail){
//session dates
$startdateunix=$DB->get_field('facetoface_sessions_dates','timestart',array('sessionid'=>$session_detail->id));
$enddateuinx=$DB->get_field('facetoface_sessions_dates','timefinish',array('sessionid'=>$session_detail->id));
//converting dates
$statrtdate=date('d M Y H:i:s',$startdateunix);
$enddate=date('d M Y H:i:s',$enddateuinx);
//session room
$sessionroom=$DB->get_field('facetoface_room','name',array('id'=>$session_detail->roomid));
$sessionsingle .="<tr><td>$n</td><td>$statrtdate</td><td>$enddate</td><td>$sessionroom</td></tr>";
$n++;
}
// sending email to each users
foreach($batch_users as $batch_user){
$user_active_details=$DB->get_record_sql("select * from {user} where id=$batch_user->userid");
// Course Name
$coursename=$DB->get_field('course','fullname',array('id'=>$batch_user->courseid));
$from = core_user::get_support_user();
$subject =get_string('activenotification', 'facetoface');
$usermail=new stdClass();
$usermail->fullname=fullname($batch_user->userid);
$usermail->batchname=$batchname;
$usermail->coursename=$coursename;
$usermail->session=$sessionsingle;
$messagetext=get_string('activenotificationmsg', 'facetoface',$usermail);
$email=email_to_user($user_active_details,$from,$subject,$messagetext);
//print_object(email_to_user($user_active_details,$from,$subject,$messagetext));
}
}
开发者ID:narasimhaeabyas,项目名称:tataaiapro,代码行数:40,代码来源:notifications.php
示例15: execute
/**
* Run the deletion task.
*
* @throws \coding_exception if the module could not be removed.
*/
public function execute()
{
global $CFG;
require_once $CFG->dirroot . '/course/lib.php';
// Set the proper user.
if ($this->get_custom_data()->userid !== $this->get_custom_data()->realuserid) {
$realuser = \core_user::get_user($this->get_custom_data()->realuserid, '*', MUST_EXIST);
cron_setup_user($realuser);
\core\session\manager::loginas($this->get_custom_data()->userid, \context_system::instance(), false);
} else {
$user = \core_user::get_user($this->get_custom_data()->userid, '*', MUST_EXIST);
cron_setup_user($user);
}
$cms = $this->get_custom_data()->cms;
foreach ($cms as $cm) {
try {
course_delete_module($cm->id);
} catch (\Exception $e) {
throw new \coding_exception("The course module {$cm->id} could not be deleted. {$e->getTraceAsString()}");
}
}
}
开发者ID:lucaboesch,项目名称:moodle,代码行数:27,代码来源:course_delete_modules.php
示例16: send_instructor_message
/**
* Send instructor message to instructors on course.
*
* @param array $instructors
* @param string $message
* @return void
*/
public function send_instructor_message($instructors, $message)
{
$subject = get_string('receipt_instructor_copy_subject', 'turnitintooltwo');
$eventdata = new stdClass();
$eventdata->component = 'mod_turnitintooltwo';
//your component name
$eventdata->name = 'submission';
//this is the message name from messages.php
$eventdata->userfrom = \core_user::get_noreply_user();
$eventdata->subject = $subject;
$eventdata->fullmessage = $message;
$eventdata->fullmessageformat = FORMAT_HTML;
$eventdata->fullmessagehtml = $message;
$eventdata->smallmessage = '';
$eventdata->notification = 1;
//this is only set to 0 for personal messages between users
foreach ($instructors as $instructor) {
$eventdata->userto = $instructor->id;
message_send($eventdata);
}
unset($instructor);
}
开发者ID:unikent,项目名称:moodle-mod_turnitintooltwo,代码行数:29,代码来源:instructor_message.php
示例17: check_access
/**
* Whether the user can access the document or not.
*
* @param int $id The message instance id.
* @return int
*/
public function check_access($id)
{
global $CFG, $DB, $USER;
if (!$CFG->messaging) {
return \core_search\manager::ACCESS_DENIED;
}
$message = $DB->get_record('message_read', array('id' => $id));
if (!$message) {
return \core_search\manager::ACCESS_DELETED;
}
$userfrom = \core_user::get_user($message->useridfrom, 'id, deleted');
$userto = \core_user::get_user($message->useridto, 'id, deleted');
if (!$userfrom || !$userto || $userfrom->deleted || $userto->deleted) {
return \core_search\manager::ACCESS_DELETED;
}
if ($USER->id != $userto->id) {
return \core_search\manager::ACCESS_DENIED;
}
if ($message->timeusertodeleted != 0) {
return \core_search\manager::ACCESS_DELETED;
}
return \core_search\manager::ACCESS_GRANTED;
}
开发者ID:evltuma,项目名称:moodle,代码行数:29,代码来源:message_received.php
示例18: mod_assignment_pending_upgrades_notification
/**
* Inform admins about assignments that still need upgrading.
*/
function mod_assignment_pending_upgrades_notification($count)
{
$admins = get_admins();
if (empty($admins)) {
return;
}
$a = new stdClass();
$a->count = $count;
$a->docsurl = get_docs_url('Assignment_upgrade_tool');
foreach ($admins as $admin) {
$message = new stdClass();
$message->component = 'moodle';
$message->name = 'notices';
$message->userfrom = \core_user::get_noreply_user();
$message->userto = $admin;
$message->smallmessage = get_string('pendingupgrades_message_small', 'mod_assignment');
$message->subject = get_string('pendingupgrades_message_subject', 'mod_assignment');
$message->fullmessage = get_string('pendingupgrades_message_content', 'mod_assignment', $a);
$message->fullmessagehtml = get_string('pendingupgrades_message_content', 'mod_assignment', $a);
$message->fullmessageformat = FORMAT_PLAIN;
$message->notification = 1;
message_send($message);
}
}
开发者ID:alanaipe2015,项目名称:moodle,代码行数:27,代码来源:upgradelib.php
示例19: moodle_exception
throw new moodle_exception('disabled', 'core_message');
}
$PAGE->set_context(null);
require_sesskey();
$action = optional_param('action', null, PARAM_ALPHA);
$response = null;
switch ($action) {
// Sending a message.
case 'sendmessage':
$userid = required_param('userid', PARAM_INT);
if (empty($userid) || isguestuser($userid) || $userid == $USER->id) {
// Cannot send messags to self, nobody or a guest.
throw new coding_exception('Invalid user to send the message to');
}
$message = required_param('message', PARAM_RAW);
$user2 = core_user::get_user($userid);
// Only attempt to send the message if we have permission to message
// the recipient.
if (message_can_post_message($user2, $USER)) {
$messageid = message_post_message($USER, $user2, $message, FORMAT_MOODLE);
if (!$messageid) {
throw new moodle_exception('errorwhilesendingmessage', 'core_message');
}
} else {
throw new moodle_exception('unabletomessageuser', 'core_message');
}
$response = array();
break;
}
if ($response !== null) {
echo json_encode($response);
开发者ID:evltuma,项目名称:moodle,代码行数:31,代码来源:ajax.php
示例20: profile_save_data
// Save custom profile fields data.
profile_save_data($usernew);
// Trigger event.
\core\event\user_updated::create_from_userid($user->id)->trigger();
// If email was changed and confirmation is required, send confirmation email now to the new address.
if ($emailchanged && $CFG->emailchangeconfirmation) {
$tempuser = $DB->get_record('user', array('id' => $user->id), '*', MUST_EXIST);
$tempuser->email = $usernew->preference_newemail;
$a = new stdClass();
$a->url = $CFG->wwwroot . '/user/emailupdate.php?key=' . $usernew->preference_newemailkey . '&id=' . $user->id;
$a->site = format_string($SITE->fullname, true, array('context' => context_course::instance(SITEID)));
$a->fullname = fullname($tempuser, true);
$emailupdatemessage = get_string('emailupdatemessage', 'auth', $a);
$emailupdatetitle = get_string('emailupdatetitle', 'auth', $a);
// Email confirmation directly rather than using messaging so they will definitely get an email.
$supportuser = core_user::get_support_user();
if (!($mailresults = email_to_user($tempuser, $supportuser, $emailupdatetitle, $emailupdatemessage))) {
die("could not send email!");
}
}
// Reload from db, we need new full name on this page if we do not redirect.
$user = $DB->get_record('user', array('id' => $user->id), '*', MUST_EXIST);
if ($USER->id == $user->id) {
// Override old $USER session variable if needed.
foreach ((array) $user as $variable => $value) {
if ($variable === 'description' or $variable === 'password') {
// These are not set for security nad perf reasons.
continue;
}
$USER->{$variable} = $value;
}
开发者ID:ket-ed,项目名称:ketmoodle-core-changes,代码行数:31,代码来源:edit.php
注:本文中的core_user类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论