本文整理汇总了PHP中isguest函数的典型用法代码示例。如果您正苦于以下问题:PHP isguest函数的具体用法?PHP isguest怎么用?PHP isguest使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isguest函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
function get_content()
{
global $THEME, $CFG, $USER;
// only for logged in users!
if (!isloggedin() || isguest()) {
return false;
}
// check for outgoing roaming permission first
if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
return '';
}
if ($this->content !== NULL) {
return $this->content;
}
// TODO: Test this query - it's appropriate? It works?
// get the hosts and whether we are doing SSO with them
$sql = "\n SELECT DISTINCT \n h.id, \n h.name,\n h.wwwroot,\n a.name as application,\n a.display_name\n FROM \n {$CFG->prefix}mnet_host h,\n {$CFG->prefix}mnet_application a,\n {$CFG->prefix}mnet_host2service h2s_IDP,\n {$CFG->prefix}mnet_service s_IDP,\n {$CFG->prefix}mnet_host2service h2s_SP,\n {$CFG->prefix}mnet_service s_SP\n WHERE\n h.id != '{$CFG->mnet_localhost_id}' AND\n h.id = h2s_IDP.hostid AND\n h.applicationid = a.id AND\n h2s_IDP.serviceid = s_IDP.id AND\n s_IDP.name = 'sso_idp' AND\n h2s_IDP.publish = '1' AND\n h.id = h2s_SP.hostid AND\n h2s_SP.serviceid = s_SP.id AND\n s_SP.name = 'sso_idp' AND\n h2s_SP.publish = '1'\n ORDER BY\n a.display_name,\n h.name";
$hosts = get_records_sql($sql);
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if ($hosts) {
foreach ($hosts as $host) {
$icon = '<img src="' . $CFG->pixpath . '/i/' . $host->application . '_host.gif"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" />';
$this->content->icons[] = $icon;
if ($host->id == $USER->mnethostid) {
$this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . s($host->name) . "</a>";
} else {
$this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) . "</a>";
}
}
}
return $this->content;
}
示例2: blog_check_and_install_blocks
/**
* Checks to see if user has visited blogpages before, if not, install 2
* default blocks (blog_menu and blog_tags).
*/
function blog_check_and_install_blocks()
{
global $USER, $DB;
if (isloggedin() && !isguest()) {
// if this user has not visited this page before
if (!get_user_preferences('blogpagesize')) {
// find the correct ids for blog_menu and blog_from blocks
$menublock = $DB->get_record('block', array('name' => 'blog_menu'));
$tagsblock = $DB->get_record('block', array('name' => 'blog_tags'));
// add those 2 into block_instance page
// Commmented out since the block changes broke it. Hopefully nico will fix it ;-)
// // add blog_menu block
// $newblock = new object();
// $newblock->blockid = $menublock->id;
// $newblock->pageid = $USER->id;
// $newblock->pagetype = 'blog-view';
// $newblock->position = 'r';
// $newblock->weight = 0;
// $newblock->visible = 1;
// $DB->insert_record('block_instances', $newblock);
//
// // add blog_tags menu
// $newblock -> blockid = $tagsblock->id;
// $newblock -> weight = 1;
// $DB->insert_record('block_instances', $newblock);
// finally we set the page size pref
set_user_preference('blogpagesize', 10);
}
}
}
示例3: get_content
function get_content()
{
global $USER, $CFG;
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if (empty($this->instance) or empty($USER->id) or isguest() or empty($CFG->messaging)) {
return $this->content;
}
$this->content->footer = '<a href="' . $CFG->wwwroot . '/message/index.php" onclick="this.target=\'message\'; return openpopup(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">' . get_string('messages', 'message') . '</a>...';
$users = get_records_sql("SELECT m.useridfrom as id, COUNT(m.useridfrom) as count,\n u.firstname, u.lastname, u.picture, u.lastaccess\n FROM {$CFG->prefix}user u, \n {$CFG->prefix}message m \n WHERE m.useridto = '{$USER->id}' \n AND u.id = m.useridfrom\n GROUP BY m.useridfrom, u.firstname,u.lastname,u.picture,u.lastaccess");
//Now, we have in users, the list of users to show
//Because they are online
if (!empty($users)) {
$this->content->text .= '<ul class="list">';
foreach ($users as $user) {
$timeago = format_time(time() - $user->lastaccess);
$this->content->text .= '<li class="listentry"><div class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $this->instance->pageid . '" title="' . $timeago . '">';
$this->content->text .= print_user_picture($user->id, $this->instance->pageid, $user->picture, 0, true, false, '', false);
$this->content->text .= fullname($user) . '</a></div>';
$this->content->text .= '<div class="message"><a href="' . $CFG->wwwroot . '/message/discussion.php?id=' . $user->id . '" onclick="this.target=\'message_' . $user->id . '\'; return openpopup(\'/message/discussion.php?id=' . $user->id . '\', \'message_' . $user->id . '\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="' . $CFG->pixpath . '/t/message.gif" alt="" /> ' . $user->count . '</a>';
$this->content->text .= '</div></li>';
}
$this->content->text .= '</ul>';
} else {
$this->content->text .= '<div class="info">';
$this->content->text .= get_string('nomessages', 'message');
$this->content->text .= '</div>';
}
return $this->content;
}
示例4: blog_check_and_install_blocks
/**
* Checks to see if user has visited blogpages before, if not, install 2
* default blocks (blog_menu and blog_tags).
*/
function blog_check_and_install_blocks()
{
global $USER;
if (isloggedin() && !isguest()) {
// if this user has not visited this page before
if (!get_user_preferences('blogpagesize')) {
// find the correct ids for blog_menu and blog_from blocks
$menublock = get_record('block', 'name', 'blog_menu');
$tagsblock = get_record('block', 'name', 'blog_tags');
// add those 2 into block_instance page
// add blog_menu block
$newblock = new object();
$newblock->blockid = $menublock->id;
$newblock->pageid = $USER->id;
$newblock->pagetype = 'blog-view';
$newblock->position = 'r';
$newblock->weight = 0;
$newblock->visible = 1;
insert_record('block_instance', $newblock);
// add blog_tags menu
$newblock->blockid = $tagsblock->id;
$newblock->weight = 1;
insert_record('block_instance', $newblock);
// finally we set the page size pref
set_user_preference('blogpagesize', 10);
}
}
}
示例5: doListAnnotations
function doListAnnotations($url, $username, $block)
{
$query = new AnnotationSummaryQuery($url, $username, null, null);
if ($query->error) {
$this->httpError(400, 'Bad Request', 'Bad URL');
return null;
} elseif (isguest() && ANNOTATION_REQUIRE_USER) {
$this->httpError(403, 'Forbidden', 'Anonymous listing not allowed');
return null;
} else {
$querySql = $query->sql('section_type, section_name, quote_title');
$annotationSet = get_records_sql($querySql);
$annotations = array();
if ($annotationSet) {
$i = 0;
foreach ($annotationSet as $r) {
$annotations[$i++] = AnnotationGlobals::recordToAnnotation($r);
}
}
$format = $this->getQueryParam('format', 'atom');
$logUrl = 'annotate.php?format=' . $format . ($username ? '&user=' . $username : '') . '&url=' . $url;
add_to_log($query->handler->courseId, 'annotation', 'list', $logUrl);
return $annotations;
}
}
示例6: user_is_editing
function user_is_editing()
{
global $SESSION;
if (isloggedin() && !isguest()) {
$this->editing = !empty($SESSION->blog_editing_enabled);
return $this->editing;
}
return false;
}
示例7: print_header
/**
* Prints the page header.
*/
function print_header()
{
global $CFG, $USER, $PAGE;
require_once $CFG->libdir . '/blocklib.php';
require_once $CFG->dirroot . '/course/lib.php';
require_once $CFG->dirroot . '/my/pagelib.php';
/// My Moodle arguments:
$edit = optional_param('edit', -1, PARAM_BOOL);
$blockaction = optional_param('blockaction', '', PARAM_ALPHA);
$mymoodlestr = get_string('mymoodle', 'my');
if (isguest()) {
$wwwroot = $CFG->wwwroot . '/login/index.php';
if (!empty($CFG->loginhttps)) {
$wwwroot = str_replace('http:', 'https:', $wwwroot);
}
print_header($mymoodlestr);
notice_yesno(get_string('noguest', 'my') . '<br /><br />' . get_string('liketologin'), $wwwroot, $CFG->wwwroot);
print_footer();
die;
}
/// Add curriculum stylesheets...
if (file_exists($CFG->dirroot . '/curriculum/styles.css')) {
$CFG->stylesheets[] = $CFG->wwwroot . '/curriculum/styles.css';
}
/// Fool the page library into thinking we're in My Moodle.
$CFG->pagepath = $CFG->wwwroot . '/my/index.php';
$PAGE = page_create_instance($USER->id);
if ($section = optional_param('section', '', PARAM_ALPHAEXT)) {
$PAGE->section = $section;
}
$this->pageblocks = blocks_setup($PAGE, BLOCKS_PINNED_BOTH);
/// Make sure that the curriculum block is actually on this
/// user's My Moodle page instance.
if ($cablockid = get_field('block', 'id', 'name', 'curr_admin')) {
if (!record_exists('block_pinned', 'blockid', $cablockid, 'pagetype', 'my-index')) {
blocks_execute_action($PAGE, $this->pageblocks, 'add', (int) $cablockid, true, false);
}
}
if ($edit != -1 and $PAGE->user_allowed_editing()) {
$USER->editing = $edit;
}
//$PAGE->print_header($mymoodlestr);
$title = $this->get_title();
print_header($title, $title, build_navigation($this->get_navigation()));
echo '<table border="0" cellpadding="3" cellspacing="0" width="100%" id="layout-table">';
echo '<tr valign="top">';
$blocks_preferred_width = bounded_number(180, blocks_preferred_width($this->pageblocks[BLOCK_POS_LEFT]), 210);
if (blocks_have_content($this->pageblocks, BLOCK_POS_LEFT) || $PAGE->user_is_editing()) {
echo '<td style="vertical-align: top; width: ' . $blocks_preferred_width . 'px;" id="left-column">';
blocks_print_group($PAGE, $this->pageblocks, BLOCK_POS_LEFT);
echo '</td>';
}
echo '<td valign="top" id="middle-column">';
if (blocks_have_content($this->pageblocks, BLOCK_POS_CENTRE) || $PAGE->user_is_editing()) {
blocks_print_group($PAGE, $this->pageblocks, BLOCK_POS_CENTRE);
}
}
示例8: get_content
function get_content()
{
global $CFG, $USER, $DB, $OUTPUT;
// only for logged in users!
if (!isloggedin() || isguest()) {
return false;
}
if (!is_enabled_auth('mnet')) {
// no need to query anything remote related
debugging('mnet authentication plugin is not enabled', DEBUG_ALL);
return '';
}
// check for outgoing roaming permission first
if (!has_capability('moodle/site:mnetlogintoremote', get_context_instance(CONTEXT_SYSTEM), NULL, false)) {
return '';
}
if ($this->content !== NULL) {
return $this->content;
}
// TODO: Test this query - it's appropriate? It works?
// get the hosts and whether we are doing SSO with them
$sql = "\n SELECT DISTINCT \n h.id, \n h.name,\n h.wwwroot,\n a.name as application,\n a.display_name\n FROM \n {mnet_host} h,\n {mnet_application} a,\n {mnet_host2service} h2s_IDP,\n {mnet_service} s_IDP,\n {mnet_host2service} h2s_SP,\n {mnet_service} s_SP\n WHERE\n h.id <> ? AND\n h.id = h2s_IDP.hostid AND\n h.deleted = 0 AND\n h.applicationid = a.id AND\n h2s_IDP.serviceid = s_IDP.id AND\n s_IDP.name = 'sso_idp' AND\n h2s_IDP.publish = '1' AND\n h.id = h2s_SP.hostid AND\n h2s_SP.serviceid = s_SP.id AND\n s_SP.name = 'sso_idp' AND\n h2s_SP.publish = '1'\n ORDER BY\n a.display_name,\n h.name";
$hosts = $DB->get_records_sql($sql, array($CFG->mnet_localhost_id));
$this->content = new stdClass();
$this->content->items = array();
$this->content->icons = array();
$this->content->footer = '';
if ($hosts) {
foreach ($hosts as $host) {
$icon = '<img src="' . $OUTPUT->old_icon_url('i/' . $host->application . '_host') . '"' . ' class="icon" alt="' . get_string('server', 'block_mnet_hosts') . '" />';
$this->content->icons[] = $icon;
if ($host->id == $USER->mnethostid) {
$this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$host->wwwroot}\">" . s($host->name) . "</a>";
} else {
$this->content->items[] = "<a title=\"" . s($host->name) . "\" href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$host->id}\">" . s($host->name) . "</a>";
}
}
}
return $this->content;
}
示例9: get_content
function get_content()
{
global $USER, $CFG, $DB, $OUTPUT;
if (!$CFG->messaging) {
return '';
}
if ($this->content !== NULL) {
return $this->content;
}
$this->content = new stdClass();
$this->content->text = '';
$this->content->footer = '';
if (empty($this->instance) or empty($USER->id) or isguest() or empty($CFG->messaging)) {
return $this->content;
}
$this->content->footer = '<a href="' . $CFG->wwwroot . '/message/index.php" onclick="this.target=\'message\'; return openpopup(\'/message/index.php\', \'message\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);">' . get_string('messages', 'message') . '</a>...';
$users = $DB->get_records_sql("SELECT m.useridfrom AS id, COUNT(m.useridfrom) AS count,\n u.firstname, u.lastname, u.picture, u.imagealt, u.lastaccess\n FROM {user} u, {message} m \n WHERE m.useridto = ? AND u.id = m.useridfrom\n GROUP BY m.useridfrom, u.firstname,u.lastname,u.picture,u.lastaccess,u.imagealt", array($USER->id));
//Now, we have in users, the list of users to show
//Because they are online
if (!empty($users)) {
$this->content->text .= '<ul class="list">';
foreach ($users as $user) {
$timeago = format_time(time() - $user->lastaccess);
$this->content->text .= '<li class="listentry"><div class="user"><a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . SITEID . '" title="' . $timeago . '">';
$this->content->text .= $OUTPUT->user_picture(moodle_user_picture::make($user, SITEID));
$this->content->text .= fullname($user) . '</a></div>';
$this->content->text .= '<div class="message"><a href="' . $CFG->wwwroot . '/message/discussion.php?id=' . $user->id . '" onclick="this.target=\'message_' . $user->id . '\'; return openpopup(\'/message/discussion.php?id=' . $user->id . '\', \'message_' . $user->id . '\', \'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500\', 0);"><img class="iconsmall" src="' . $OUTPUT->old_icon_url('t/message') . '" alt="" /> ' . $user->count . '</a>';
$this->content->text .= '</div></li>';
}
$this->content->text .= '</ul>';
} else {
$this->content->text .= '<div class="info">';
$this->content->text .= get_string('nomessages', 'message');
$this->content->text .= '</div>';
}
return $this->content;
}
示例10: calendar_course_filter_selector
function calendar_course_filter_selector($getvars = '')
{
global $USER, $SESSION;
if (empty($USER->id) or isguest()) {
return '';
}
if (has_capability('moodle/calendar:manageentries', get_context_instance(CONTEXT_SYSTEM)) && !empty($CFG->calendar_adminseesall)) {
$courses = get_courses('all', 'c.shortname', 'c.id,c.shortname');
} else {
$courses = get_my_courses($USER->id, 'shortname');
}
unset($courses[SITEID]);
$courseoptions[SITEID] = get_string('fulllistofcourses');
foreach ($courses as $course) {
$courseoptions[$course->id] = format_string($course->shortname);
}
if (is_numeric($SESSION->cal_courses_shown)) {
$selected = $SESSION->cal_courses_shown;
} else {
$selected = '';
}
return popup_form(CALENDAR_URL . 'set.php?var=setcourse&' . $getvars . '&id=', $courseoptions, 'cal_course_flt', $selected, '', '', '', true);
}
示例11: tabobject
$toprow[] = new tabobject('profile', $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $course->id, get_string('profile'));
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
$coursecontext = get_context_instance(CONTEXT_COURSE, $course->id);
$personalcontext = get_context_instance(CONTEXT_USER, $user->id);
/// Can only edit profile if it belongs to user or current user is admin and not editing primary admin
$mainadmin = get_admin();
if (empty($CFG->loginhttps)) {
$wwwroot = $CFG->wwwroot;
} else {
$wwwroot = str_replace('http:', 'https:', $CFG->wwwroot);
}
$edittype = 'none';
if (is_mnet_remote_user($user)) {
// cannot edit remote users
} else {
if (isguest() or !isloggedin()) {
// can not edit guest like accounts - TODO: add capability to edit own profile
} else {
if ($USER->id == $user->id) {
if (has_capability('moodle/user:update', $systemcontext)) {
$edittype = 'advanced';
} else {
$edittype = 'normal';
}
} else {
if ($user->id != $mainadmin->id) {
//no editing of primary admin!
if (has_capability('moodle/user:update', $systemcontext)) {
$edittype = 'advanced';
} else {
if (has_capability('moodle/user:editprofile', $personalcontext)) {
示例12: optional_param
// EntryID
$confirm = optional_param('confirm', 0, PARAM_INT);
// proceed. Edit the edtry
$mode = optional_param('mode', '', PARAM_ALPHA);
// categories if by category?
$hook = optional_param('hook', '', PARAM_ALPHANUM);
// CategoryID
if (!($cm = get_coursemodule_from_id('glossary', $id))) {
error("Course Module ID was incorrect");
}
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!($course = get_record("course", "id", $cm->course))) {
error("Course is misconfigured");
}
require_login($course->id, false, $cm);
if (isguest()) {
error("Guests are not allowed to edit glossaries", $_SERVER["HTTP_REFERER"]);
}
if (!($glossary = get_record("glossary", "id", $cm->instance))) {
error("Course module is incorrect");
}
if ($e) {
// if entry is specified
if (!($entry = get_record("glossary_entries", "id", $e))) {
error("Incorrect entry id");
}
$ineditperiod = time() - $entry->timecreated < $CFG->maxeditingtime || $glossary->editalways;
if (!has_capability('mod/glossary:manageentries', $context) and !($entry->userid == $USER->id and ($ineditperiod and has_capability('mod/glossary:write', $context)))) {
//expired edit time is the most probable cause here
print_error('erredittimeexpired', 'glossary', "view.php?id={$cm->id}&mode=entry&hook={$e}");
}
示例13: get_string
echo "<form id='annotation-search' method='get' action='summary.php'>\n";
echo "<fieldset>\n";
echo "<label for='search-of'>" . get_string('prompt_find', ANNOTATION_STRINGS) . "</label>\n";
if (isguest()) {
echo "<input type='hidden' name='search_of' id='search_of' value='' />\n";
echo get_string('search_of_all', ANNOTATION_STRINGS) . ' ';
} else {
echo "<select name='search-of' id='search-of'>\n";
echo " <option value=''" . ('' == $searchOf ? " selected='selected'" : '') . '>' . get_string('search_of_all', ANNOTATION_STRINGS) . "</option>\n";
echo " <option value='" . htmlspecialchars($USER->username) . "'" . ($searchOf == $USER->username ? " selected='selected'" : '') . '>' . get_string('search_of_self', ANNOTATION_STRINGS) . "</option>\n";
echo "</select>\n";
}
echo "<label for='u'>" . get_string('prompt_by', ANNOTATION_STRINGS) . "</label>\n";
echo "<select name='u' id='u'>\n";
echo " <option value='' " . (!$searchUser ? "selected='selected'" : '') . '>' . get_string('search_by_all', ANNOTATION_STRINGS) . "</option>\n";
if (!isguest()) {
echo " <option value='" . htmlspecialchars($USER->username) . "' " . ($searchUser == $USER->username ? " selected='selected'" : '') . ">" . get_string('search_by_self', ANNOTATION_STRINGS) . "</option>\n";
}
// echo " <option value='*teachers'".('*teachers'==$searchBy?" selected='selected'":'').'>'.get_string( 'search_by_teachers', ANNOTATION_STRINGS )."</option>\n";
// echo " <option value='*students'".('*students'==$searchBy?" selected='selected'":'').'>'.get_string( 'search_by_students', ANNOTATION_STRINGS )."</option>\n";
echo "</select>\n";
echo "<label for='search-text'>" . get_string('search_text', ANNOTATION_STRINGS) . "</label>\n";
echo "<input type='text' id='search-text' name='q' value='" . htmlspecialchars($searchQuery) . "'/>\n";
echo "<input type='submit' value='" . get_string('go') . "'/>\n";
echo "<input type='hidden' name='url' value='" . htmlspecialchars($summaryUrl) . "'/>\n";
echo "</fieldset>\n";
echo "</form>";
// If this page is an error, explain what it's about
if ('range-mismatch' == $errorPage) {
echo "<p class='error'><em class='range-error'>!</em>" . get_string('summary_range_error', ANNOTATION_STRINGS) . "</p>\n";
}
示例14: unset
if (user_not_fully_set_up($USER)) {
$urltogo = $CFG->wwwroot . '/user/edit.php';
// We don't delete $SESSION->wantsurl yet, so we get there later
} else {
if (isset($SESSION->wantsurl) and strpos($SESSION->wantsurl, $CFG->wwwroot) === 0) {
$urltogo = $SESSION->wantsurl;
/// Because it's an address in this site
unset($SESSION->wantsurl);
} else {
// no wantsurl stored or external - go to homepage
$urltogo = $CFG->wwwroot . '/';
unset($SESSION->wantsurl);
}
}
/// Go to my-moodle page instead of homepage if mymoodleredirect enabled
if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !empty($CFG->mymoodleredirect) and !isguest()) {
if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot . '/' or $urltogo == $CFG->wwwroot . '/index.php') {
$urltogo = $CFG->wwwroot . '/my/';
}
}
/// check if user password has expired
/// Currently supported only for ldap-authentication module
if (!empty($userauth->config->expiration) and $userauth->config->expiration == 1) {
$days2expire = $userauth->password_expire($USER->username);
if (intval($days2expire) > 0 && intval($days2expire) < intval($userauth->config->expiration_warning)) {
print_header("{$site->fullname}: {$loginsite}", "{$site->fullname}", $loginsite, $focus, "", true, "<div class=\"langmenu\">{$langmenu}</div>");
notice_yesno(get_string('auth_passwordwillexpire', 'auth', $days2expire), $passwordchangeurl, $urltogo);
print_footer();
exit;
} elseif (intval($days2expire) < 0) {
print_header("{$site->fullname}: {$loginsite}", "{$site->fullname}", $loginsite, $focus, "", true, "<div class=\"langmenu\">{$langmenu}</div>");
示例15: s
echo '<input type="submit" value="' . s(get_string('unenrolme', '', $course->shortname)) . '" />';
echo '</div>';
echo '</form>';
}
}
if (!$user->deleted and $USER->id != $user->id && empty($USER->realuser) && has_capability('moodle/user:loginas', $coursecontext) && !has_capability('moodle/site:doanything', $coursecontext, $user->id, false)) {
echo '<form action="' . $CFG->wwwroot . '/course/loginas.php" method="get">';
echo '<div>';
echo '<input type="hidden" name="id" value="' . $course->id . '" />';
echo '<input type="hidden" name="user" value="' . $user->id . '" />';
echo '<input type="hidden" name="sesskey" value="' . sesskey() . '" />';
echo '<input type="submit" value="' . get_string('loginas') . '" />';
echo '</div>';
echo '</form>';
}
if (!$user->deleted and !empty($CFG->messaging) and !isguest() and has_capability('moodle/site:sendmessage', get_context_instance(CONTEXT_SYSTEM))) {
if (!empty($USER->id) and $USER->id == $user->id) {
if ($countmessages = count_records('message', 'useridto', $user->id)) {
$messagebuttonname = get_string("messages", "message") . "({$countmessages})";
} else {
$messagebuttonname = get_string("messages", "message");
}
echo "<form onclick=\"this.target='message'\" action=\"../message/index.php\" method=\"get\">";
echo "<div>";
echo "<input type=\"submit\" value=\"{$messagebuttonname}\" onclick=\"return openpopup('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\" />";
echo "</div>";
echo "</form>";
} else {
echo "<form onclick=\"this.target='message{$user->id}'\" action=\"../message/discussion.php\" method=\"get\">";
echo "<div>";
echo "<input type=\"hidden\" name=\"id\" value=\"{$user->id}\" />";