本文整理汇总了PHP中get_admin函数的典型用法代码示例。如果您正苦于以下问题:PHP get_admin函数的具体用法?PHP get_admin怎么用?PHP get_admin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_admin函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute()
{
global $USER;
// Check to make sure external communications hasn't been disabled
$extcom = !!get_config('mod_hvp', 'external_communication');
$extcomnotify = !!get_config('mod_hvp', 'external_communication_notify');
if ($extcom || !$extcomnotify) {
$core = \mod_hvp\framework::instance();
$core->fetchLibrariesMetadata(!$extcom);
set_config('external_communication_notify', $extcom ? false : time(), 'mod_hvp');
// Notify admin if there are updates available!
$update_available = \get_config('mod_hvp', 'update_available');
$current_update = \get_config('mod_hvp', 'current_update');
$admin_notified = \get_config('mod_hvp', 'admin_notified');
if ($admin_notified !== $update_available && $update_available !== false && $current_update !== false && $current_update < $update_available) {
// New update is available
// Send message
$updatesurl = new \moodle_url('/mod/hvp/library_list.php');
$message = new \stdClass();
$message->component = 'mod_hvp';
$message->name = 'updates';
$message->userfrom = $USER;
$message->userto = get_admin();
$message->subject = get_string('updatesavailabletitle', 'mod_hvp');
$message->fullmessage = get_string('updatesavailablemsgpt1', 'mod_hvp') . ' ' . get_string('updatesavailablemsgpt2', 'mod_hvp') . "\n\n" . get_string('updatesavailablemsgpt3', 'mod_hvp', date('Y-m-d', $update_available)) . "\n" . get_string('updatesavailablemsgpt4', 'mod_hvp', date('Y-m-d', $current_update)) . "\n\n" . $updatesurl;
$message->fullmessageformat = FORMAT_PLAIN;
$message->fullmessagehtml = '<p>' . get_string('updatesavailablemsgpt1', 'mod_hvp') . '<br/>' . get_string('updatesavailablemsgpt2', 'mod_hvp') . '</p>' . '<p>' . get_string('updatesavailablemsgpt3', 'mod_hvp', '<b>' . date('Y-m-d', $update_available) . '</b>') . '<br/>' . get_string('updatesavailablemsgpt4', 'mod_hvp', '<b>' . date('Y-m-d', $current_update) . '</b>') . '</p>' . '<a href="' . $updatesurl . '" target="_blank">' . $updatesurl . '</a>';
$message->smallmessage = '';
$message->notification = 1;
message_send($message);
// Keep track of which version we've notfied about
\set_config('admin_notified', $update_available, 'mod_hvp');
}
}
}
示例2: facetoface_send_admin_upgrade_msg
/**
*
* Sends message to administrator listing all updated
* duplicate custom fields
* @param array $data
*/
function facetoface_send_admin_upgrade_msg($data)
{
global $SITE;
// No data - no need to send email.
if (empty($data)) {
return;
}
$table = new html_table();
$table->head = array('Custom field ID', 'Custom field original shortname', 'Custom field new shortname');
$table->data = $data;
$table->align = array('center', 'center', 'center');
$title = "{$SITE->fullname}: Face to Face upgrade info";
$note = 'During the last site upgrade the face-to-face module has been modified. It now
requires session custom fields to have unique shortnames. Since some of your
custom fields had duplicate shortnames, they have been renamed to remove
duplicates (see table below). This could impact on your email messages if you
reference those custom fields in the message templates.';
$message = html_writer::start_tag('html');
$message .= html_writer::start_tag('head') . html_writer::tag('title', $title) . html_writer::end_tag('head');
$message .= html_writer::start_tag('body');
$message .= html_writer::tag('p', $note) . html_writer::table($table, true);
$message .= html_writer::end_tag('body');
$message .= html_writer::end_tag('html');
$admin = get_admin();
email_to_user($admin, $admin, $title, '', $message);
}
示例3: xmldb_assignfeedback_editpdf_upgrade
/**
* EditPDF upgrade code
* @param int $oldversion
* @return bool
*/
function xmldb_assignfeedback_editpdf_upgrade($oldversion)
{
global $CFG;
if ($oldversion < 2013110800) {
// Check that no stamps where uploaded.
$fs = get_file_storage();
$stamps = $fs->get_area_files(context_system::instance()->id, 'assignfeedback_editpdf', 'stamps', 0, "filename", false);
// Add default stamps.
if (empty($stamps)) {
// List of default stamps.
$defaultstamps = array('smile.png', 'sad.png', 'tick.png', 'cross.png');
// Stamp file object.
$filerecord = new stdClass();
$filerecord->component = 'assignfeedback_editpdf';
$filerecord->contextid = context_system::instance()->id;
$filerecord->userid = get_admin()->id;
$filerecord->filearea = 'stamps';
$filerecord->filepath = '/';
$filerecord->itemid = 0;
// Add all default stamps.
foreach ($defaultstamps as $stamp) {
$filerecord->filename = $stamp;
$fs->create_file_from_pathname($filerecord, $CFG->dirroot . '/mod/assign/feedback/editpdf/pix/' . $filerecord->filename);
}
}
upgrade_plugin_savepoint(true, 2013110800, 'assignfeedback', 'editpdf');
}
// Moodle v2.6.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.7.0 release upgrade line.
// Put any upgrade step following this.
// Moodle v2.8.0 release upgrade line.
// Put any upgrade step following this.
return true;
}
示例4: notify_user
function notify_user($user, $subject, $a)
{
if (!$user) {
return false;
}
$body = get_string('virusfoundlater', 'moodle', $a);
email_to_user($user, get_admin(), $subject, $body);
}
示例5: is_valid_admin_login
function is_valid_admin_login($username, $password)
{
$token = get_admin($username);
if ($token['password'] == $password) {
return TRUE;
} else {
return FALSE;
}
}
示例6: execute
public function execute()
{
global $CFG, $DB;
require_once $CFG->dirroot . "/mod/turnitintooltwo/lib.php";
require_once $CFG->dirroot . "/mod/turnitintooltwo/turnitintooltwo_view.class.php";
$data = (array) $this->get_custom_data();
// Make sure we are still wanted.
$submission = $DB->get_record('turnitintooltwo_submissions', array('id' => $data['submissionid']));
if (!$submission) {
return true;
}
cli_writeln("Processing Turnitintooltwo submission: " . $data['submissionid']);
$user = $DB->get_record('user', array('id' => $data['userid']));
\core\session\manager::set_user($user);
$turnitintooltwo = $DB->get_record('turnitintooltwo', array('id' => $data['tiiid']));
list($course, $cm) = get_course_and_cm_from_instance($turnitintooltwo, 'turnitintooltwo');
try {
$turnitintooltwoassignment = new \turnitintooltwo_assignment($turnitintooltwo->id, $turnitintooltwo);
$turnitintooltwosubmission = new \turnitintooltwo_submission($data['submissionid'], "moodle", $turnitintooltwoassignment);
$parts = $turnitintooltwoassignment->get_parts();
$tiisubmission = $turnitintooltwosubmission->do_tii_submission($cm, $turnitintooltwoassignment);
// Update submission.
$DB->update_record('turnitintooltwo_submissions', array('id' => $data['submissionid'], 'submission_modified' => $data['subtime']));
} catch (\Exception $e) {
$tiisubmission = array('success' => false, 'message' => $e->getMessage());
cli_writeln($e->getMessage());
}
$digitalreceipt = $tiisubmission;
$digitalreceipt['is_manual'] = 0;
$digitalreceipt = json_encode($digitalreceipt);
$this->update_sub_status($data['submissionid'], $tiisubmission['success'], $digitalreceipt);
if ($tiisubmission['success'] === true) {
$lockedassignment = new \stdClass();
$lockedassignment->id = $turnitintooltwoassignment->turnitintooltwo->id;
$lockedassignment->submitted = 1;
$DB->update_record('turnitintooltwo', $lockedassignment);
$lockedpart = new \stdClass();
$lockedpart->id = $data['submissionpart'];
$lockedpart->submitted = 1;
// Disable anonymous marking if post date has passed.
if ($parts[$data['submissionpart']]->dtpost <= time()) {
$lockedpart->unanon = 1;
}
$DB->update_record('turnitintooltwo_parts', $lockedpart);
cli_writeln("Finished processing successful submission: " . $data['submissionid']);
} else {
turnitintooltwo_add_to_log($course->id, "errored submission", 'view.php?id=' . $cm->id, "Failed to submit '" . $turnitintooltwosubmission->submission_title . "'", $cm->id, $user->id, array('submissionid' => $data['submissionid']));
cli_writeln("Finished processing unsuccessful submission: " . $data['submissionid']);
}
\core\session\manager::set_user(get_admin());
return $tiisubmission['success'];
}
示例7: rss_get_link
/**
* This function returns the icon (from theme) with the link to rss/file.php
*
* @global object
* @global object
*/
function rss_get_link($courseid, $userid, $modulename, $id, $tooltiptext = '')
{
global $OUTPUT;
static $rsspath = '';
//In site course, if no logged (userid), use admin->id. Bug 2048.
if ($courseid == SITEID and empty($userid)) {
$admin = get_admin();
$userid = $admin->id;
}
$rsspath = rss_get_url($courseid, $userid, $modulename, $id);
$rsspix = $OUTPUT->old_icon_url('i/rss');
return '<a href="' . $rsspath . '"><img src="' . $rsspix . '" title="' . strip_tags($tooltiptext) . '" alt="' . get_string('rss') . '" /></a>';
}
示例8: notification_definition
/**
*
*/
public static function notification_definition($mform, $dataformid, $prefix = null)
{
global $DB;
$paramtext = !empty($CFG->formatstringstriptags) ? PARAM_TEXT : PARAM_CLEAN;
$mform->addElement('header', 'messagehdr', get_string('message', 'message'));
$mform->setExpanded('messagehdr');
// Message type.
$options = array(0 => get_string('notification', 'dataform'), 1 => get_string('conversation', 'dataform'));
$mform->addElement('select', $prefix . 'messagetype', get_string('type', 'dataform'), $options);
// Subject.
$mform->addElement('text', $prefix . 'subject', get_string('subject', 'dataform'));
$mform->setType($prefix . 'subject', $paramtext);
// Content.
$mform->addElement('textarea', $prefix . 'contenttext', get_string('content'));
$mform->setType($prefix . 'contenttext', $paramtext);
// Content from view.
$options = array('' => get_string('choosedots'));
if ($items = \mod_dataform_view_manager::instance($dataformid)->views_menu) {
$items = array_combine($items, $items);
$options = array_merge($options, $items);
}
$label = get_string('contentview', 'mod_dataform');
$mform->addElement('select', $prefix . 'contentview', $label, $options);
// Format.
$options = array(FORMAT_PLAIN => get_string('formatplain'), FORMAT_HTML => get_string('formathtml'));
$mform->addElement('select', $prefix . 'messageformat', get_string('format'), $options);
// Sender: Entry author, manager.
$mform->addElement('header', 'senderhdr', get_string('sender', 'mod_dataform'));
$mform->setExpanded('senderhdr');
$admin = get_admin();
$options = array(\core_user::NOREPLY_USER => get_string('noreply', 'dataform'), \core_user::SUPPORT_USER => get_string('supportcontact', 'admin'), $admin->id => get_string('admin'), 'author' => get_string('author', 'dataform'), 'event' => get_string('event', 'dataform'));
$mform->addElement('select', $prefix . 'sender', get_string('from'), $options);
// Recipient.
$mform->addElement('header', 'recipientshdr', get_string('recipient', 'mod_dataform'));
$mform->setExpanded('recipientshdr');
// Admin.
$mform->addElement('advcheckbox', $prefix . 'recipient[admin]', get_string('admin'));
// Support.
$mform->addElement('advcheckbox', $prefix . 'recipient[support]', get_string('supportcontact', 'admin'));
// Entry author.
$mform->addElement('advcheckbox', $prefix . 'recipient[author]', get_string('author', 'dataform'));
// Role (mod/dataform:notification permission in context).
$mform->addElement('advcheckbox', $prefix . 'recipient[role]', get_string('role'));
// Username (comma delimited).
$mform->addElement('text', $prefix . 'recipient[username]', get_string('username'));
$mform->setType($prefix . 'recipient[username]', $paramtext);
// Email (comma delimited).
$mform->addElement('text', $prefix . 'recipient[email]', get_string('email'));
$mform->setType($prefix . 'recipient[email]', $paramtext);
}
示例9: xmldb_theme_evolved_install
/**
* Theme_mimoodle install function.
*
* @return void
*/
function xmldb_theme_evolved_install()
{
global $CFG;
// Set the default background.
$fs = get_file_storage();
$filerecord = new stdClass();
$filerecord->component = 'theme_evolved';
$filerecord->contextid = context_system::instance()->id;
$filerecord->userid = get_admin()->id;
$filerecord->filearea = 'backgroundimage';
$filerecord->filepath = '/';
$filerecord->itemid = 0;
$filerecord->filename = 'background.png';
$fs->create_file_from_pathname($filerecord, $CFG->dirroot . '/theme/evolved/pix/background.png');
}
示例10: local_enrolmentreminder_send_messages
function local_enrolmentreminder_send_messages($events)
{
global $DB;
global $CFG;
require_once $CFG->libdir . '/completionlib.php';
$eventdata = new stdClass();
$eventdata->component = 'local_enrolmentreminder';
// plugin name
$eventdata->name = 'enrolmentending';
// message interface name
$eventdata->userfrom = get_admin();
$dateformat = '%b %e';
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$dateformat = '%b %#d';
}
foreach ($events as $event) {
$course = $DB->get_record('course', array('id' => $event->courseid));
$user = $DB->get_record('user', array('id' => $event->userid));
if (empty($completioninfo[$event->courseid])) {
$completioninfo[$event->courseid] = new completion_info($course);
}
if ($completioninfo[$event->courseid]->is_course_complete($event->userid)) {
mtrace("user {$event->userid} has completed course {$event->courseid}");
continue;
}
// use timeend for enrolments, timestart for events.
$ending = userdate($event->timeend, $dateformat);
$eventdata->fullmessage = local_enrolmentreminder_get_message_plaintext($course, $user, $ending, $event->reminderid);
if (empty($eventdata->fullmessage)) {
mtrace("eventdata->fullmessage is empty");
}
if (!empty($eventdata->fullmessage)) {
$eventdata->subject = $course->shortname . ' ending ' . $ending;
$eventdata->smallmessage = $course->fullname . ' ending ' . $ending;
$eventdata->fullmessagehtml = '';
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->notification = 1;
$eventdata->userto = $user;
// $eventdata->userto = get_admin();
$mailresult = message_send($eventdata);
mtrace("sent message with result {$mailresult}: " . print_r($eventdata, true));
$params = array('context' => context_course::instance($event->courseid), 'objectid' => $course->id, 'relateduserid' => $event->userid);
$msg_event = \local_enrolmentreminder\event\message_sent::create($params);
$msg_event->trigger();
}
}
}
示例11: notify_user
function notify_user($user, $subject, $a)
{
if (!$user) {
return false;
}
$body = get_string('virusfoundlater', 'moodle', $a);
$eventdata = new stdClass();
$eventdata->modulename = 'moodle';
$eventdata->userfrom = get_admin();
$eventdata->userto = $user;
$eventdata->subject = $subject;
$eventdata->fullmessage = $body;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
message_send($eventdata);
}
示例12: send_welcome
/**
* This plugin sends users a welcome message after logging in
* and notify a moderator a new user has been added
* it has a settings page that allow you to configure the messages
* send.
*
* @package local
* @subpackage welcome
* @copyright 2014 Bas Brands, basbrands.nl, bas@sonsbeekmedia.nl
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function send_welcome($user)
{
global $CFG, $SITE;
$moderator = get_admin();
$sender = get_admin();
if (!empty($user->email)) {
$config = get_config('local_welcome');
if (!empty($config->auth_plugins)) {
$auths = explode(',', $config->auth_plugins);
if (!in_array($user->auth, $auths)) {
return '';
}
} else {
return '';
}
$moderator->email = $config->moderator_email;
$sender->email = $config->sender_email;
$sender->firstname = $config->sender_firstname;
$sender->lastname = $config->sender_lastname;
$message_user_enabled = $config->message_user_enabled;
$message_user = $config->message_user;
$message_user_subject = $config->message_user_subject;
$message_moderator_enabled = $config->message_moderator_enabled;
$message_moderator = $config->message_moderator;
$message_moderator_subject = $config->message_moderator_subject;
if (!empty($user->country)) {
$user->country = get_string($user->country, 'countries');
} else {
$user->country = '';
}
$sitelink = html_writer::link(new moodle_url('/'), $SITE->fullname);
$resetpasswordlink = html_writer::link(new moodle_url('/login/forgot_password.php'), get_string('resetpass', 'local_welcome'));
$fields = array('[[fullname]]', '[[username]]', '[[firstname]]', '[[lastname]]', '[[email]]', '[[city]]', '[[country]]', '[[sitelink]]', '[[sitename]]', '[[resetpasswordlink]]');
$values = array(fullname($user), $user->username, $user->firstname, $user->lastname, $user->email, $user->city, $user->country, $sitelink, $SITE->fullname, $resetpasswordlink);
$message_user = str_replace($fields, $values, $message_user);
$message_user_subject = str_replace($fields, $values, $message_user_subject);
$message_moderator = str_replace($fields, $values, $message_moderator);
$message_moderator_subject = str_replace($fields, $values, $message_moderator_subject);
if (!empty($message_user) && !empty($sender->email) && $message_user_enabled) {
email_to_user($user, $sender, $message_user_subject, html_to_text($message_user), $message_user);
}
if (!empty($message_moderator) && !empty($sender->email) && $message_moderator_enabled) {
email_to_user($moderator, $sender, $message_moderator_subject, html_to_text($message_moderator), $message_moderator);
}
}
}
示例13: execute
public function execute()
{
global $CFG;
require_once "{$CFG->libdir}/datalib.php";
$user = get_admin();
if (!$user) {
cli_error("Unable to find admin user in DB.");
}
$auth = empty($user->auth) ? 'manual' : $user->auth;
if ($auth == 'nologin' or !is_enabled_auth($auth)) {
cli_error(sprintf("User authentication is either 'nologin' or disabled. Check Moodle authentication method for '%s'", $user->username));
}
$authplugin = get_auth_plugin($auth);
$authplugin->sync_roles($user);
login_attempt_valid($user);
complete_user_login($user);
printf("%s:%s\n", session_name(), session_id());
}
示例14: 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 = get_admin();
$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);
}
示例15: clam_message_admins
/**
* Emails admins about a clam outcome
*
* @param string $notice The body of the email to be sent.
*/
function clam_message_admins($notice)
{
$site = get_site();
$subject = get_string('clamemailsubject', 'moodle', format_string($site->fullname));
$admins = get_admins();
foreach ($admins as $admin) {
$eventdata = new stdClass();
$eventdata->component = 'moodle';
$eventdata->name = 'errors';
$eventdata->userfrom = get_admin();
$eventdata->userto = $admin;
$eventdata->subject = $subject;
$eventdata->fullmessage = $notice;
$eventdata->fullmessageformat = FORMAT_PLAIN;
$eventdata->fullmessagehtml = '';
$eventdata->smallmessage = '';
message_send($eventdata);
}
}