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; }
/** * 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); } } }
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; }
/** * 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); } } }
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='******'') . '&url=' . $url; add_to_log($query->handler->courseId, 'annotation', 'list', $logUrl); return $annotations; } }
function user_is_editing() { global $SESSION; if (isloggedin() && !isguest()) { $this->editing = !empty($SESSION->blog_editing_enabled); return $this->editing; } return false; }
/** * 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); } }
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; }
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; }
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); }
$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)) {
// 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}"); }
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"; }
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>");
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}\" />";
/** * Prints a summary of a user in a nice little box. * * @uses $CFG * @uses $USER * @param user $user A {@link $USER} object representing a user * @param course $course A {@link $COURSE} object representing a course */ function print_user($user, $course, $messageselect = false, $return = false) { global $CFG, $USER; $output = ''; static $string; static $datestring; static $countries; $context = get_context_instance(CONTEXT_COURSE, $course->id); if (isset($user->context->id)) { $usercontext = $user->context; } else { $usercontext = get_context_instance(CONTEXT_USER, $user->id); } if (empty($string)) { // Cache all the strings for the rest of the page $string->email = get_string('email'); $string->city = get_string('city'); $string->lastaccess = get_string('lastaccess'); $string->activity = get_string('activity'); $string->unenrol = get_string('unenrol'); $string->loginas = get_string('loginas'); $string->fullprofile = get_string('fullprofile'); $string->role = get_string('role'); $string->name = get_string('name'); $string->never = get_string('never'); $datestring->day = get_string('day'); $datestring->days = get_string('days'); $datestring->hour = get_string('hour'); $datestring->hours = get_string('hours'); $datestring->min = get_string('min'); $datestring->mins = get_string('mins'); $datestring->sec = get_string('sec'); $datestring->secs = get_string('secs'); $datestring->year = get_string('year'); $datestring->years = get_string('years'); $countries = get_list_of_countries(); } /// Get the hidden field list if (has_capability('moodle/course:viewhiddenuserfields', $context)) { $hiddenfields = array(); } else { $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields)); } $output .= '<table class="userinfobox">'; $output .= '<tr>'; $output .= '<td class="left side">'; $output .= print_user_picture($user, $course->id, $user->picture, true, true); $output .= '</td>'; $output .= '<td class="content">'; $output .= '<div class="username">' . fullname($user, has_capability('moodle/site:viewfullnames', $context)) . '</div>'; $output .= '<div class="info">'; if (!empty($user->role)) { $output .= $string->role . ': ' . $user->role . '<br />'; } if ($user->maildisplay == 1 or $user->maildisplay == 2 and $course->id != SITEID and !isguest() or has_capability('moodle/course:viewhiddenuserfields', $context)) { $output .= $string->email . ': <a href="mailto:' . $user->email . '">' . $user->email . '</a><br />'; } if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) { $output .= $string->city . ': '; if ($user->city && !isset($hiddenfields['city'])) { $output .= $user->city; } if (!empty($countries[$user->country]) && !isset($hiddenfields['country'])) { if ($user->city && !isset($hiddenfields['city'])) { $output .= ', '; } $output .= $countries[$user->country]; } $output .= '<br />'; } if (!isset($hiddenfields['lastaccess'])) { if ($user->lastaccess) { $output .= $string->lastaccess . ': ' . userdate($user->lastaccess); $output .= ' (' . format_time(time() - $user->lastaccess, $datestring) . ')'; } else { $output .= $string->lastaccess . ': ' . $string->never; } } $output .= '</div></td><td class="links">'; //link to blogs if ($CFG->bloglevel > 0) { $output .= '<a href="' . $CFG->wwwroot . '/blog/index.php?userid=' . $user->id . '">' . get_string('blogs', 'blog') . '</a><br />'; } //link to notes if (!empty($CFG->enablenotes) and has_capability('moodle/notes:manage', $context) || has_capability('moodle/notes:view', $context)) { $output .= '<a href="' . $CFG->wwwroot . '/notes/index.php?course=' . $course->id . '&user='******'">' . get_string('notes', 'notes') . '</a><br />'; } if (has_capability('moodle/site:viewreports', $context) or has_capability('moodle/user:viewuseractivitiesreport', $usercontext)) { $output .= '<a href="' . $CFG->wwwroot . '/course/user.php?id=' . $course->id . '&user='******'">' . $string->activity . '</a><br />'; } if (has_capability('moodle/role:assign', $context) and get_user_roles($context, $user->id, false)) { // I can unassing and user has some role $output .= '<a href="' . $CFG->wwwroot . '/course/unenrol.php?id=' . $course->id . '&user='******'">' . $string->unenrol . '</a><br />'; } if ($USER->id != $user->id && !session_is_loggedinas() && has_capability('moodle/user:loginas', $context) && !has_capability('moodle/site:doanything', $context, $user->id, false)) { $output .= '<a href="' . $CFG->wwwroot . '/course/loginas.php?id=' . $course->id . '&user='******'&sesskey=' . sesskey() . '">' . $string->loginas . '</a><br />'; } $output .= '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&course=' . $course->id . '">' . $string->fullprofile . '...</a>'; if (!empty($messageselect)) { $output .= '<br /><input type="checkbox" name="user' . $user->id . '" /> '; } $output .= '</td></tr></table>'; if ($return) { return $output; } else { echo $output; } }
<?php // $Id: enrol.php,v 1.50.2.1 2008/03/03 05:27:36 moodler Exp $ // Depending on the current enrolment method, this page // presents the user with whatever they need to know when // they try to enrol in a course. require_once "../config.php"; require_once "lib.php"; require_once "{$CFG->dirroot}/enrol/enrol.class.php"; if (isloggedin() and !isguest()) { if (!iscreator() and !isteacherinanycourse()) { redirect($CFG->wwwroot . '/index.php'); } } else { redirect($CFG->wwwroot . '/index.php'); } $id = required_param('id', PARAM_INT); // Masoud Sadjadi: PARAM_ALPHANUM changed to PARAM_RAW to support emails being passed as user names. // $username = required_param('username', PARAM_ALPHANUM); $username = required_param('username', PARAM_RAW); $loginasguest = optional_param('loginasguest', 0, PARAM_BOOL); // hmm, is this still needed? if (!isloggedin()) { // do not use require_login here because we are usually comming from it redirect(get_login_url()); } if (!($course = get_record('course', 'id', $id))) { print_error("That's an invalid course id"); } if (!($context = get_context_instance(CONTEXT_COURSE, $course->id))) { print_error("That's an invalid course id");
function data_print_comments($data, $record, $page = 0, $mform = false) { global $CFG; $cm = get_coursemodule_from_instance('data', $data->id); $context = get_context_instance(CONTEXT_MODULE, $cm->id); $cancomment = has_capability('mod/data:comment', $context); echo '<a name="comments"></a>'; if ($comments = get_records('data_comments', 'recordid', $record->id)) { foreach ($comments as $comment) { data_print_comment($data, $comment, $page); } echo '<br />'; } if (!isloggedin() or isguest() or !$cancomment) { return; } $editor = optional_param('addcomment', 0, PARAM_BOOL); if (!$mform and !$editor) { echo '<div class="newcomment" style="text-align:center">'; echo '<a href="view.php?d=' . $data->id . '&rid=' . $record->id . '&mode=single&addcomment=1">' . get_string('addcomment', 'data') . '</a>'; echo '</div>'; } else { if (!$mform) { require_once 'comment_form.php'; $mform = new mod_data_comment_form('comment.php'); $mform->set_data(array('mode' => 'add', 'page' => $page, 'rid' => $record->id)); } echo '<div class="newcomment" style="text-align:center">'; $mform->display(); echo '</div>'; } }
if (!($data = get_record('data', 'id', $cm->instance))) { error('Course module is incorrect'); } } else { if (!($data = get_record('data', 'id', $d))) { error('Data ID is incorrect'); } if (!($course = get_record('course', 'id', $data->course))) { error('Course is misconfigured'); } if (!($cm = get_coursemodule_from_instance('data', $data->id, $course->id))) { error('Course Module ID was incorrect'); } } require_login($course->id, false, $cm); if (!isloggedin() or isguest()) { redirect('view.php?d=' . $data->id); } $context = get_context_instance(CONTEXT_MODULE, $cm->id); /// If it's hidden then it doesn't show anything. :) if (empty($cm->visible) and !has_capability('moodle/course:viewhiddenactivities', $context)) { $strdatabases = get_string("modulenameplural", "data"); $navlinks = array(); $navlinks[] = array('name' => $strdatabases, 'link' => "index.php?id={$course->id}", 'type' => 'activity'); $navlinks[] = array('name' => format_string($data->name), 'link' => '', 'type' => 'activityinstance'); $navigation = build_navigation($navlinks); print_header_simple(format_string($data->name), "", $navigation, "", "", true, '', navmenu($course, $cm)); notice(get_string("activityiscurrentlyhidden")); } /// Can't use this if there are no fields if (has_capability('mod/data:managetemplates', $context)) {
$navlinks[] = array('name' => get_string('calendar', 'calendar'), 'link' => calendar_get_link_href(CALENDAR_URL . 'view.php?view=upcoming&course=' . $courseid . '&', $now['mday'], $now['mon'], $now['year']), 'type' => 'misc'); $navlinks[] = array('name' => $pagetitle, 'link' => null, 'type' => 'misc'); $navigation = build_navigation($navlinks); if (!checkdate($mon, $day, $yr)) { $day = intval($now['mday']); $mon = intval($now['mon']); $yr = intval($now['year']); } $time = make_timestamp($yr, $mon, $day); if (empty($USER->id) or isguest()) { $defaultcourses = calendar_get_default_courses(); calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses); } else { calendar_set_filters($courses, $groups, $users); } if (empty($USER->id) or isguest()) { $defaultcourses = calendar_get_default_courses(); calendar_set_filters($courses, $groups, $users, $defaultcourses, $defaultcourses); } else { calendar_set_filters($courses, $groups, $users); } $strcalendar = get_string('calendar', 'calendar'); $prefsbutton = calendar_preferences_button(); // Print title and header print_header("{$site->shortname}: {$strcalendar}: {$pagetitle}", $strcalendar, $navigation, '', '', true, $prefsbutton, user_login_string($site)); echo calendar_overlib_html(); // Layout the whole page as three big columns. echo '<table id="calendar">'; echo '<tr>'; // START: Main column echo '<td class="maincalendar">';
redirect($url, get_string("messagedeleted", "nanogong")); } else { if ($error == null) { $error = get_string("deletefailed", "nanogong"); } error($error, $url); } } // Edit message if ($action === "edit") { $messageid = required_param('messageid', PARAM_INT); // Message Id if ($nanogong_message = get_record("nanogong_message", "id", $messageid)) { nanogong_print_edit_message_form($id, $nanogong, $nanogong_message); } else { error(get_string("messagenotfound", "nanogong"), $url); } } else { nanogong_print_message_list($course, $id, $nanogong, $groupid); } } else { nanogong_print_message_list($course, $id, $nanogong, $groupid, true, isguest()); } } ?> </tbody> </table> </center> <?php // Finish the page print_footer($course);
if (user_not_fully_set_up($USER)) { $urltogo = $CFG->wwwroot . '/user/edit.php?id=' . $USER->id . '&course=' . SITEID; // 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 (!isadmin() and !empty($CFG->mymoodleredirect) and !isguest()) { if ($urltogo == $CFG->wwwroot or $urltogo == $CFG->wwwroot . '/' or $urltogo == $CFG->wwwroot . '/index.php') { $urltogo = $CFG->wwwroot . '/my/'; } } reset_login_count(); //$urltogo = $CFG->wwwroot."/mod/quiz/view.php?id=$module_id"; $urltogo = $CFG->wwwroot . '/course/view.php?id=' . $moodle_site_id; //$urltogo = $CFG->wwwroot; if ($_REQUEST[mod]) { $module_url = $CFG->wwwroot . "/mod/" . $_REQUEST[mod] . "/view.php?id=" . $module_id; // print $module_url; header("Location: " . $module_url); } else { //print "<hr>Go to: <a href='".$CFG->wwwroot."/mod/".$_REQUEST[mod]."/view.php?id=$module_id'>module id= ".$module_id."</a> | "; // print "<a href='".$urltogo."'>Moodle Home</a><hr>";
$start = optional_param('formstart', 0, PARAM_INT); $userid = optional_param('userid', 0, PARAM_INT); $tag = optional_param('tag', '', PARAM_NOTAGS); $tagid = optional_param('tagid', 0, PARAM_INT); $postid = optional_param('postid', 0, PARAM_INT); $filtertype = optional_param('filtertype', '', PARAM_ALPHA); $filterselect = optional_param('filterselect', 0, PARAM_INT); $edit = optional_param('edit', -1, PARAM_BOOL); $courseid = optional_param('courseid', 0, PARAM_INT); // needed for user tabs and course tracking if (empty($CFG->bloglevel)) { print_error('blogdisable', 'blog'); } $sitecontext = get_context_instance(CONTEXT_SYSTEM); // change block edit staus if not guest and logged in if (isloggedin() and !isguest() and $edit != -1) { $USER->editing = $edit; } if (empty($filtertype)) { if ($userid) { // default to user if specified $filtertype = 'user'; $filterselect = $userid; } else { if (has_capability('moodle/blog:view', $sitecontext) and $CFG->bloglevel > BLOG_USER_LEVEL) { if ($postid) { $filtertype = 'user'; if (!($postobject = $DB->get_record('post', array('module' => 'blog', 'id' => $postid)))) { print_error('nosuchentry', 'blog'); } $filterselect = $postobject->userid;
function get_content() { global $CFG, $USER; if (empty($CFG->bloglevel)) { $this->content->text = ''; return $this->content; } // don't display menu block if block is set at site level, and user is not logged in if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL && !(isloggedin() && !isguest())) { $this->content->text = ''; return $this->content; } if (!isset($userBlog)) { $userBlog->userid = 0; } if (!empty($USER->id)) { $userBlog->userid = $USER->id; } //what is $userBlog anyway if ($this->content !== NULL) { return $this->content; } $output = ''; $this->content = new stdClass(); $this->content->footer = ''; //if ( blog_isLoggedIn() && !isguest() ) { $courseviewlink = ''; $addentrylink = ''; $coursearg = ''; $sitecontext = get_context_instance(CONTEXT_SYSTEM); if ($this->page->course->id != SITEID) { $incoursecontext = true; $curcontext = get_context_instance(CONTEXT_COURSE, $this->page->course->id); } else { $incoursecontext = false; $curcontext = $sitecontext; } $canviewblogs = has_capability('moodle/blog:view', $curcontext); /// Accessibility: markup as a list. if (isloggedin() && !isguest() && $incoursecontext && $CFG->bloglevel >= BLOG_COURSE_LEVEL && $canviewblogs) { $coursearg = '&courseid=' . $this->page->course->id; // a course is specified $courseviewlink = '<li><a href="' . $CFG->wwwroot . '/blog/index.php?filtertype=course&filterselect=' . $this->page->course->id . '">'; $courseviewlink .= get_string('viewcourseentries', 'blog') . "</a></li>\n"; } $blogmodon = false; if (isloggedin() && !isguest() && (!$blogmodon || $blogmodon && $coursearg != '') && $CFG->bloglevel >= BLOG_USER_LEVEL) { // show Add entry link if (has_capability('moodle/blog:create', $sitecontext)) { $addentrylink = '<li><a href="' . $CFG->wwwroot . '/blog/edit.php?action=add' . $coursearg . '">' . get_string('addnewentry', 'blog') . "</a></li>\n"; } // show View my entries link $addentrylink .= '<li><a href="' . $CFG->wwwroot . '/blog/index.php?userid=' . $userBlog->userid . '">' . get_string('viewmyentries', 'blog') . "</a></li>\n"; // show link to manage blog prefs $addentrylink .= '<li><a href="' . $CFG->wwwroot . '/blog/preferences.php?userid=' . $userBlog->userid . $coursearg . '">' . get_string('blogpreferences', 'blog') . "</a></li>\n"; $output = $addentrylink; $output .= $courseviewlink; } // show View site entries link if ($CFG->bloglevel >= BLOG_SITE_LEVEL && $canviewblogs) { $output .= '<li><a href="' . $CFG->wwwroot . '/blog/index.php?filtertype=site&">'; $output .= get_string('viewsiteentries', 'blog') . "</a></li>\n"; } // took out tag management interface/link, should use tag/manage.php // show Help with blogging link //$output .= '<li><a href="'. $CFG->wwwroot .'/help.php?module=blog&file=user.html">'; //$output .= get_string('helpblogging', 'blog') ."</a></li>\n"; //} else { // $output = ''; //guest users and users who are not logged in do not get menus //} $this->content->text = '<ul class="list">' . $output . "</ul>\n"; return $this->content; }
function calendar_preferences_button() { global $CFG, $USER; // Guests have no preferences if (empty($USER->id) || isguest()) { return ''; } return "<form {$CFG->frametarget} method=\"get\" " . " action=\"{$CFG->wwwroot}/calendar/preferences.php\">" . "<div><input type=\"submit\" value=\"" . get_string("preferences", "calendar") . " ...\" /></div></form>"; }
require_once 'config.php'; require_once $CFG->dirroot . '/course/lib.php'; require_once $CFG->dirroot . '/lib/blocklib.php'; if (isloggedin() and !isguest()) { if (!iscreator() and !isteacherinanycourse()) { redirect($CFG->wwwroot . '/index.php'); } } else { redirect($CFG->wwwroot . '/index.php'); } // get values from form for actions on this page $param = new stdClass(); // Parameters: create a URL that displays the last (largest) quiz id and name. (eg. 2 Test Exam) $param->course = optional_param('id', 0, PARAM_INT); $param->visible = optional_param('visible', 0, PARAM_INT); if (isloggedin() and !isguest() and isset($CFG->frontpageloggedin)) { // Logged-In } $navlinks = array(array('name' => "Available Courses", 'link' => null, 'type' => 'misc')); $navigation = build_navigation($navlinks); print_header($SITE->fullname, $SITE->fullname, $navigation, '', '<meta name="description" content="' . strip_tags(format_text($SITE->summary, FORMAT_HTML)) . '" />', true, '', user_login_string($SITE) . $langmenu); // Change the Status of the Course (visible) if (!empty($param->course) && $param->course > 0 && !empty($param->visible)) { if ($param->visible == 1) { $visible = 1; } else { if ($param->visible == 2) { $visible = 0; } } $course = get_record('course', 'id', $param->course);
function taoview_print_artefacts($artefacts, $viewtype, $tagfilter, $userfilter, $sort, $page, $perpage) { global $CFG, $USER; //get scale $scale = get_record("scale", "name", 'TAO: Stars'); $artefacts = taoview_get_paginated_results($artefacts, $page, $perpage); foreach ($artefacts as $artefact) { if ($perpage <= 0) { //not a great way to paginate. break; } echo '<div class="taoview">'; if (!empty($artefact['thumbnail'])) { echo '<div class="taoview-thumb"><img src="' . $artefact['thumbnail'] . '"></div>'; } echo '<div class="taoview-download"><a href="' . $artefact['download'] . '" target="_blank">' . $artefact['name'] . '</a></div>'; if (!empty($artefact['uploader'])) { $user = get_record('user', 'username', $artefact['uploader']); if (!empty($user)) { echo '<div class="taoview-user">' . get_string('submittedby', 'local') . ': <a href="' . $CFG->wwwroot . '/local/mahara/taoview' . $viewtype . '.php?tag=' . $tagfilter . '&filteruser='******'uploader'] . '&sort=' . $sort . '">' . fullname($user) . '</a></div>'; } } if (!empty($artefact['ctime'])) { echo '<div class="taoview-date">' . $artefact['ctime'] . '</div>'; } if (!empty($artefact['description'])) { echo '<div class="taoview-desc">' . $artefact['description'] . '</div>'; } if (!empty($artefact['tags']) && is_array($artefact['tags'])) { echo '<div class="taoview-tags">' . get_string('tags') . ': '; foreach ($artefact['tags'] as $tag) { echo '<a href="' . $CFG->wwwroot . '/local/mahara/taoview' . $viewtype . '.php?tag=' . $tag . '&sort=' . $sort . '">' . $tag . '</a>, '; } echo '</div>'; } //now do ratings stuff echo '<div class="ratings">'; $possiblevalues = make_grades_menu(-$scale->id); echo '<span class="taoviewratingtext">'; tao_print_ratings($artefact['id'], $possiblevalues); echo '</span>'; if (!empty($user) && $user->id != $USER->id && !isguest()) { tao_print_rating_menu($artefact['id'], $USER->id, $possiblevalues); } echo '</div>'; //end of ratings stuff if (!empty($artefact['page'])) { echo '<div class="taoview-page"><a href="' . $artefact['page'] . '">' . get_string('moreinfo', 'local') . '</a></div>'; } echo '</div>'; $perpage--; } if (!empty($artefacts) && !isguest()) { echo "<div class=\"boxaligncenter\"><input id=\"taoviewratingsubmit\" type=\"submit\" value=\"" . get_string("sendinratings", "local") . "\" />"; if (ajaxenabled()) { /// AJAX enabled, standard submission form $rate_ajax_config_settings = array("pixpath" => $CFG->pixpath, "wwwroot" => $CFG->wwwroot, "sesskey" => sesskey()); echo "<script type=\"text/javascript\">//<![CDATA[\n" . "var rate_ajax_config = " . json_encode($rate_ajax_config_settings) . ";\n" . "init_rate_ajax();\n" . "//]]></script>\n"; } //print_scale_menu_helpbutton(SITEID, $scale); //no help file written yet. echo "</div>"; } }
/** * Post authentication hook. * This method is called from authenticate_user_login() for all enabled auth plugins. * * @param object $user user object, later used for $USER * @param string $username (with system magic quotes) * @param string $password plain text password (with system magic quotes) */ function user_authenticated_hook(&$user, $username, $password) { global $SESSION; global $CFG; global $DB; $record = $DB->get_record('block_gdata_gapps', array('userid' => $user->id)); if (empty($record) || !empty($record->remove)) { return true; } // Shouldn't need due to Gmail using OAuth // // TODO: IMPORTANT user_auth hook gets called for all plugins so // setting user to gsaml auth may override all moodle user auth plugins. // auth_gsaml still needs to run the update password code somehow. // if there was another way to test for it.... as compare if password is diff // and then set the google user to the new password. :/ // Verify that user has a google account. If not create one for them. if (!file_exists($CFG->dirroot . '/blocks/gdata/gapps.php')) { debugging('gdata block is not installed'); } else { require_once $CFG->dirroot . '/blocks/gdata/gapps.php'; try { $g = new blocks_gdata_gapps(); try { $g_user = $g->gapps_get_user($username); if (empty($g_user)) { /* * MOODLE must enforce the above minium 6 char passwords! * http://www.google.com/support/a/bin/answer.py?answer=33386 */ // Create Moodle User in the Gsync system $g->moodle_create_user($user); // Create google user $m_user = $g->moodle_get_user($user->id); $g->create_user($m_user); } } catch (blocks_gdata_exception $e) { // TODO: catch and inform of this common error //if (stripos($e->getMessage(),'Error 1100: UserDeletedRecently') ) { // notice('Error 1100: UserDeletedRecently.<br/> Google does not allow a user to be created after deletion until at least 5 days have passed.'); //} if (method_exists($e, 'getErrors')) { $errors = $e->getErrors(); foreach ($errors as $errorcode => $error) { debugging("Error({$errorcode}): {$error}", DEBUG_NORMAL, true); } } else { debugging($e, DEBUG_DEVELOPER); } } } catch (blocks_gdata_exception $e) { //'Authentication with Google Apps failed. Please check your credentials. ->getMessage() ? // if Authentication with Google Apps failed. Please check your credentials. // print $e->getMessage(); // TODO: catch and inform of this Error debugging($e, DEBUG_DEVELOPER); } } // We are Succesfully logged in and we have a SAML Request // So we want to process the rest of the log in and redirect // to the Service that the SAML Request is asking for. // // All this code essentialy makes up for the fact that // we have to exit the login page prematurely. if (isset($SESSION->samlrequest)) { $SESSION->samlrequest = false; if (!($user = $DB->get_record('user', array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id)))) { // User could not be logged in error(get_string('errusernotloggedin', 'auth_gsaml')); } if (!validate_internal_user_password($user, $password)) { // Password not valid error(get_string('pwdnotvalid', 'auth_gsaml')); } // Added to fix navigation $navlinks = array(array('name' => 'test', 'link' => null, 'type' => 'misc')); $navigation = build_navigation($navlinks); update_login_count(); if ($user) { // language setup if ($user->username == 'guest') { // no predefined language for guests - use existing session or default site lang unset($user->lang); } else { if (!empty($user->lang)) { // unset previous session language - use user preference instead unset($SESSION->lang); } } if (empty($user->confirmed)) { // This account was never confirmed print_header(get_string("mustconfirm"), get_string("mustconfirm")); print_heading(get_string("mustconfirm")); print_simple_box(get_string("emailconfirmsent", "", $user->email), "center"); print_footer(); die; } // TODO : Fix this bug frm isn't on this page here if (isset($frm)) { // if isset placed here for now if ($frm->password == 'changeme') { //force the change set_user_preference('auth_forcepasswordchange', true, $user->id); } } // end of if issuet /// Let's get them all set up. add_to_log(SITEID, 'user', 'login', "view.php?id={$USER->id}&course=" . SITEID, $user->id, 0, $user->id); $USER = complete_user_login($user); /// Prepare redirection 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 $userauth = get_auth_plugin($USER->auth); if (!empty($userauth->config->expiration) and $userauth->config->expiration == 1) { if ($userauth->can_change_password()) { $passwordchangeurl = $userauth->change_password_url(); } else { $passwordchangeurl = $CFG->httpswwwroot . '/login/change_password.php'; } $days2expire = $userauth->password_expire($USER->username); if (intval($days2expire) > 0 && intval($days2expire) < intval($userauth->config->expiration_warning)) { print_header("{$site->fullname}: {$loginsite}", "{$site->fullname}", $navigation, '', '', 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}", $navigation, '', '', true, "<div class=\"langmenu\">{$langmenu}</div>"); notice_yesno(get_string('auth_passwordisexpired', 'auth'), $passwordchangeurl, $urltogo); print_footer(); exit; } } reset_login_count(); // END of the regular Moodle Login Procedures // Process the SAML Request and redirect to the Service // it is asking for. // This function should never return unless there's an error. if (!gsaml_send_auth_response($SESSION->samlrequestdata)) { // SAML code failed turn debugging on error(get_string('samlcodefailed', 'auth_gsaml')); } } else { if (empty($errormsg)) { $errormsg = get_string("invalidlogin"); $errorcode = 3; } // TODO: if the user failed to authenticate, check if the username corresponds to a remote mnet user if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode === 'strict' && is_enabled_auth('mnet')) { $errormsg .= get_string('loginlinkmnetuser', 'mnet', "mnet_email.php?u={$frm->username}"); } } } // else if NO SAML request is made we don't do anything but log in normally }
$subtext = get_string('subscribe', 'forum'); } print_heading_block($newsforum->name); echo '<div class="subscribelink"><a href="mod/forum/subscribe.php?id=' . $newsforum->id . '">' . $subtext . '</a></div>'; } else { print_heading_block($newsforum->name); } forum_print_latest_discussions($SITE, $newsforum, $SITE->newsitems, 'plain', 'p.modified DESC'); } break; case FRONTPAGECOURSELIST: if (isloggedin() and !has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() and empty($CFG->disablemycourses)) { print_heading_block(get_string('mycourses')); print_my_moodle(); } else { if (!has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM)) and !isguest() or count_records('course') <= FRONTPAGECOURSELIMIT) { // admin should not see list of courses when there are too many of them print_heading_block(get_string('availablecourses')); print_courses(0); } } break; case FRONTPAGECATEGORYNAMES: print_heading_block(get_string('categories')); print_box_start('generalbox categorybox'); print_whole_category_list(NULL, NULL, NULL, -1, false); print_box_end(); print_course_search('', false, 'short'); break; case FRONTPAGECATEGORYCOMBO: print_heading_block(get_string('categories'));
function get_remote_courses() { global $THEME, $CFG, $USER; $icon = '<img src="' . $CFG->pixpath . '/i/mnethost.gif" class="icon" alt="' . get_string('course') . '" />'; // only for logged in users! if (!isloggedin() || isguest()) { return false; } if ($courses = get_my_remotecourses()) { $this->content->items[] = get_string('remotecourses', 'mnet'); $this->content->icons[] = ''; foreach ($courses as $course) { $this->content->items[] = "<a title=\"" . format_string($course->shortname) . "\" " . "href=\"{$CFG->wwwroot}/auth/mnet/jump.php?hostid={$course->hostid}&wantsurl=/course/view.php?id={$course->remoteid}\">" . format_string($course->fullname) . "</a>"; $this->content->icons[] = $icon; } // if we listed courses, we are done return true; } if ($hosts = get_my_remotehosts()) { $this->content->items[] = get_string('remotemoodles', 'mnet'); $this->content->icons[] = ''; foreach ($USER->mnet_foreign_host_array as $somehost) { $this->content->items[] = $somehost['count'] . get_string('courseson', 'mnet') . '<a title="' . $somehost['name'] . '" href="' . $somehost['url'] . '">' . $somehost['name'] . '</a>'; $this->content->icons[] = $icon; } // if we listed hosts, done return true; } return false; }