本文整理汇总了PHP中get_login_url函数的典型用法代码示例。如果您正苦于以下问题:PHP get_login_url函数的具体用法?PHP get_login_url怎么用?PHP get_login_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_login_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_content
function get_content()
{
global $USER, $CFG, $SESSION;
$wwwroot = '';
$signup = '';
if ($this->content !== NULL) {
return $this->content;
}
if (empty($CFG->loginhttps)) {
$wwwroot = $CFG->wwwroot;
} else {
// This actually is not so secure ;-), 'cause we're
// in unencrypted connection...
$wwwroot = str_replace("http://", "https://", $CFG->wwwroot);
}
if (!empty($CFG->registerauth)) {
$authplugin = get_auth_plugin($CFG->registerauth);
if ($authplugin->can_signup()) {
$signup = $wwwroot . '/login/signup.php';
}
}
// TODO: now that we have multiauth it is hard to find out if there is a way to change password
$forgot = $wwwroot . '/login/forgot_password.php';
if (!empty($CFG->loginpasswordautocomplete)) {
$autocomplete = 'autocomplete="off"';
} else {
$autocomplete = '';
}
$username = get_moodle_cookie();
$this->content = new stdClass();
$this->content->footer = '';
$this->content->text = '';
if (!isloggedin() or isguestuser()) {
// Show the block
if (empty($CFG->authloginviaemail)) {
$strusername = get_string('username');
} else {
$strusername = get_string('usernameemail');
}
$this->content->text .= "\n" . '<form class="loginform" id="login" method="post" action="' . get_login_url() . '" ' . $autocomplete . '>';
$this->content->text .= '<div class="c1 fld username"><label for="login_username">' . $strusername . '</label>';
$this->content->text .= '<input type="text" name="username" id="login_username" value="' . s($username) . '" /></div>';
$this->content->text .= '<div class="c1 fld password"><label for="login_password">' . get_string('password') . '</label>';
$this->content->text .= '<input type="password" name="password" id="login_password" value="" ' . $autocomplete . ' /></div>';
if (isset($CFG->rememberusername) and $CFG->rememberusername == 2) {
$checked = $username ? 'checked="checked"' : '';
$this->content->text .= '<div class="c1 rememberusername"><input type="checkbox" name="rememberusername" id="rememberusername" value="1" ' . $checked . '/>';
$this->content->text .= ' <label for="rememberusername">' . get_string('rememberusername', 'admin') . '</label></div>';
}
$this->content->text .= '<div class="c1 btn"><input type="submit" value="' . get_string('login') . '" /></div>';
$this->content->text .= "</form>\n";
if (!empty($signup)) {
$this->content->footer .= '<div><a href="' . $signup . '">' . get_string('startsignup') . '</a></div>';
}
if (!empty($forgot)) {
$this->content->footer .= '<div><a href="' . $forgot . '">' . get_string('forgotaccount') . '</a></div>';
}
}
return $this->content;
}
示例2: execute
function execute($requests)
{
$url = get_login_url();
if ($requests['login_params']) {
if (strrpos($url, '?') !== false) {
$url .= '&';
} else {
$url .= '?';
}
$url .= 'login_params=' . urlencode($requests['login_params']);
}
// リダイレクト
header('Refresh: 3; URL=' . $url);
//---- inc_ テンプレート用 変数 ----//
$this->set('inc_page_header', fetch_inc_page_header('public'));
$msg = '';
switch ($requests['msg_code']) {
case 'login_failed':
$msg = 'ログインに失敗しました。再度、ログイン操作を行ってください。';
break;
case 'logout':
$msg = 'ログアウトしました。';
break;
case 'password_reset_timeout':
$msg = 'パスワード再設定の有効期限が過ぎています。';
break;
case 'change_mailaddress':
$msg = 'メールアドレスが変更されました。';
break;
case 'change_password':
$msg = 'パスワードを変更しました。新しいパスワードで再ログインしてください。';
break;
case 'taikai':
$msg = '退会完了しました。ご利用ありがとうございました。';
break;
case 'invalid_url':
$msg = 'このURLは既に無効になっています。';
break;
case 'regist_mail':
$msg = 'メールアドレスを登録しました。';
break;
case 'login_rejected':
$msg = 'ログインできませんでした。';
break;
}
$this->set('msg', $msg);
$this->set('login_url', $url);
return 'success';
}
示例3: execute
function execute($requests)
{
//<PCKTAI
if (OPENPNE_AUTH_MODE == 'slavepne' || !(OPENPNE_REGIST_FROM & OPENPNE_REGIST_FROM_PC)) {
client_redirect_login();
}
//>
//---- inc_ テンプレート用 変数 ----//
$this->set('inc_page_header', fetch_inc_page_header('regist'));
//アフィリエイトタグ用変数
$aftag = str_replace(array('({$ID})', '({$DATETIME})'), array($requests['c_member_id'], date("YmdHis")), AFFILIATE_TAG);
$this->set('aftag', $aftag);
$this->set('login_url', get_login_url());
return 'success';
}
示例4: do_save
protected function do_save($action)
{
global $user;
if (!$user->is_logged_in()) {
if (VISIBILITY == 'private') {
header('Location: ' . get_login_url($action->page));
} else {
header('Location: ' . get_base_url($action->page));
}
exit;
}
$this->file = new File($this->format_page_name($action->page, true));
if ($_POST['updated'] == $this->file->time) {
$this->file->save($_POST['text']);
} else {
header('Location: ' . $this->get_base_url(str_replace(DOC, '', rtrim($action->page, '/')) . '/edit/'));
exit;
}
header('Location: ' . $this->get_base_url(str_replace(DOC, '', $action->page)));
exit;
}
示例5: default_exception_handler
/**
* Default exception handler, uncaught exceptions are equivalent to error() in 1.9 and earlier
*
* @param Exception $ex
* @return void -does not return. Terminates execution!
*/
function default_exception_handler($ex)
{
global $CFG, $DB, $OUTPUT, $USER, $FULLME, $SESSION, $PAGE;
// detect active db transactions, rollback and log as error
abort_all_db_transactions();
if ($ex instanceof required_capability_exception && !CLI_SCRIPT && !AJAX_SCRIPT && !empty($CFG->autologinguests) && !empty($USER->autologinguest)) {
$SESSION->wantsurl = qualified_me();
redirect(get_login_url());
}
$info = get_exception_info($ex);
if (debugging('', DEBUG_MINIMAL)) {
$logerrmsg = "Default exception handler: " . $info->message . ' Debug: ' . $info->debuginfo . "\n" . format_backtrace($info->backtrace, true);
error_log($logerrmsg);
}
if (is_early_init($info->backtrace)) {
echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo, $info->errorcode);
} else {
try {
if ($DB) {
// If you enable db debugging and exception is thrown, the print footer prints a lot of rubbish
$DB->set_debug(0);
}
echo $OUTPUT->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
} catch (Exception $out_ex) {
// default exception handler MUST not throw any exceptions!!
// the problem here is we do not know if page already started or not, we only know that somebody messed up in outputlib or theme
// so we just print at least something instead of "Exception thrown without a stack frame in Unknown on line 0":-(
if (CLI_SCRIPT or AJAX_SCRIPT) {
// just ignore the error and send something back using the safest method
echo bootstrap_renderer::early_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo, $info->errorcode);
} else {
echo bootstrap_renderer::early_error_content($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo);
$outinfo = get_exception_info($out_ex);
echo bootstrap_renderer::early_error_content($outinfo->message, $outinfo->moreinfourl, $outinfo->link, $outinfo->backtrace, $outinfo->debuginfo);
}
}
}
exit(1);
// General error code
}
示例6: view_page_guest
/**
* Outputs an error message for any guests accessing the quiz
*
* @param int $course The course ID
* @param array $quiz Array contingin quiz data
* @param int $cm Course Module ID
* @param int $context The page contect ID
* @param array $messages Array containing any messages
*/
public function view_page_guest($course, $quiz, $cm, $context, $messages) {
$output = '';
$output .= $this->view_information($quiz, $cm, $context, $messages);
$guestno = html_writer::tag('p', get_string('guestsno', 'quiz'));
$liketologin = html_writer::tag('p', get_string('liketologin'));
$output .= $this->confirm($guestno."\n\n".$liketologin."\n", get_login_url(),
get_referer(false));
return $output;
}
示例7: login_info
/**
* Return the standard string that says whether you are logged in (and switched
* roles/logged in as another user).
* @param bool $withlinks if false, then don't include any links in the HTML produced.
* If not set, the default is the nologinlinks option from the theme config.php file,
* and if that is not set, then links are included.
* @return string HTML fragment.
*/
public function login_info($withlinks = null)
{
global $USER, $CFG, $DB, $SESSION;
if (during_initial_install()) {
return '';
}
if (is_null($withlinks)) {
$withlinks = empty($this->page->layout_options['nologinlinks']);
}
$loginpage = (string) $this->page->url === get_login_url();
$course = $this->page->course;
if (\core\session\manager::is_loggedinas()) {
$realuser = \core\session\manager::get_realuser();
$fullname = fullname($realuser, true);
if ($withlinks) {
$loginastitle = get_string('loginas');
$realuserinfo = " [<a href=\"{$CFG->wwwroot}/course/loginas.php?id={$course->id}&sesskey=" . sesskey() . "\"";
$realuserinfo .= "title =\"" . $loginastitle . "\">{$fullname}</a>] ";
} else {
$realuserinfo = " [{$fullname}] ";
}
} else {
$realuserinfo = '';
}
$loginurl = get_login_url();
if (empty($course->id)) {
// $course->id is not defined during installation
return '';
} else {
if (isloggedin()) {
$context = context_course::instance($course->id);
$fullname = fullname($USER, true);
// Since Moodle 2.0 this link always goes to the public profile page (not the course profile page)
if ($withlinks) {
$linktitle = get_string('viewprofile');
$username = "<a href=\"{$CFG->wwwroot}/user/profile.php?id={$USER->id}\" title=\"{$linktitle}\">{$fullname}</a>";
} else {
$username = $fullname;
}
if (is_mnet_remote_user($USER) and $idprovider = $DB->get_record('mnet_host', array('id' => $USER->mnethostid))) {
if ($withlinks) {
$username .= " from <a href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
} else {
$username .= " from {$idprovider->name}";
}
}
if (isguestuser()) {
$loggedinas = $realuserinfo . get_string('loggedinasguest');
if (!$loginpage && $withlinks) {
$loggedinas .= " (<a href=\"{$loginurl}\">" . get_string('login') . '</a>)';
}
} else {
if (is_role_switched($course->id)) {
// Has switched roles
$rolename = '';
if ($role = $DB->get_record('role', array('id' => $USER->access['rsw'][$context->path]))) {
$rolename = ': ' . role_get_name($role, $context);
}
$loggedinas = get_string('loggedinas', 'moodle', $username) . $rolename;
if ($withlinks) {
$url = new moodle_url('/course/switchrole.php', array('id' => $course->id, 'sesskey' => sesskey(), 'switchrole' => 0, 'returnurl' => $this->page->url->out_as_local_url(false)));
$loggedinas .= '(' . html_writer::tag('a', get_string('switchrolereturn'), array('href' => $url)) . ')';
}
} else {
$loggedinas = $realuserinfo . get_string('loggedinas', 'moodle', $username);
if ($withlinks) {
echo "<i class='fa fa-user hide979 mywhite'></i> ";
//****************$loggedinas .= " (<a href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
$loggedinas .= " <span class=\"line-trans\">|</span><a class=\"logtop\" href=\"{$CFG->wwwroot}/login/logout.php?sesskey=" . sesskey() . "\"> " . get_string('logout') . '</a><span class="line-trans"> |</span>';
}
}
}
} else {
$loggedinas = get_string('loggedinnot', 'moodle');
if (!$loginpage && $withlinks) {
//****************$loggedinas $loggedinas .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
echo "<i class='fa fa-lock hide979 mywhite'></i> ";
$loggedinas .= " | <a href=\"{$loginurl}\">" . get_string('login') . '</a> |';
}
}
}
$loggedinas = '<div class="logininfo">' . $loggedinas . '</div>';
if (isset($SESSION->justloggedin)) {
unset($SESSION->justloggedin);
if (!empty($CFG->displayloginfailures)) {
if (!isguestuser()) {
if ($count = count_login_failures($CFG->displayloginfailures, $USER->username, $USER->lastlogin)) {
$loggedinas .= ' <div class="loginfailures">';
if (empty($count->accounts)) {
$loggedinas .= get_string('failedloginattempts', '', $count);
} else {
$loggedinas .= get_string('failedloginattemptsall', '', $count);
//.........这里部分代码省略.........
示例8: optional_param
if (user_has_role_assignment($USER->id,5) ) {
$PAGE->requires->css('/student/custom.css');
}
$userid = optional_param('id', 0, PARAM_INT);
$edit = optional_param('edit', null, PARAM_BOOL); // Turn editing on and off.
$reset = optional_param('reset', null, PARAM_BOOL);
$PAGE->set_url('/user/profile.php', array('id' => $userid));
if (!empty($CFG->forceloginforprofiles)) {
require_login();
if (isguestuser()) {
$PAGE->set_context(context_system::instance());
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('guestcantaccessprofiles', 'error'),
get_login_url(),
$CFG->wwwroot);
echo $OUTPUT->footer();
die;
}
} else if (!empty($CFG->forcelogin)) {
require_login();
}
$userid = $userid ? $userid : $USER->id; // Owner of the page.
if ((!$user = $DB->get_record('user', array('id' => $userid))) || ($user->deleted)) {
$PAGE->set_context(context_system::instance());
echo $OUTPUT->header();
if (!$user) {
echo $OUTPUT->notification(get_string('invaliduser', 'error'));
} else {
示例9: unset
unset($SESSION->info);
}
if (isset($SESSION->backupprefs)) {
unset($SESSION->backupprefs);
}
if (isset($SESSION->restore)) {
unset($SESSION->restore);
}
if (isset($SESSION->import_preferences)) {
unset($SESSION->import_preferences);
}
}
if (!$to && isset($SESSION->restore->restoreto) && isset($SESSION->restore->importing) && isset($SESSION->restore->course_id)) {
$to = $SESSION->restore->course_id;
}
$loginurl = get_login_url();
if (!empty($id)) {
require_login($id);
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $id))) {
if (empty($to)) {
print_error("cannotuseadminadminorteacher", '', $loginurl);
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_COURSE, $to)) && !has_capability('moodle/site:import', get_context_instance(CONTEXT_COURSE, $to))) {
print_error("cannotuseadminadminorteacher", '', $loginurl);
}
}
}
} else {
if (!has_capability('moodle/site:restore', get_context_instance(CONTEXT_SYSTEM))) {
print_error("cannotuseadmin", '', $loginurl);
}
示例10: print_error
if (! $cm = get_coursemodule_from_instance('chat', $chat->id, $course->id)) {
print_error('invalidcoursemodule');
}
}
require_course_login($course, true, $cm);
$context = context_module::instance($cm->id);
$PAGE->set_context($context);
// show some info for guests
if (isguestuser()) {
$PAGE->set_title(format_string($chat->name));
echo $OUTPUT->header();
echo $OUTPUT->confirm('<p>'.get_string('noguests', 'chat').'</p>'.get_string('liketologin'),
get_login_url(), $CFG->wwwroot.'/course/view.php?id='.$course->id);
echo $OUTPUT->footer();
exit;
}
add_to_log($course->id, 'chat', 'view', "view.php?id=$cm->id", $chat->id, $cm->id);
$strenterchat = get_string('enterchat', 'chat');
$stridle = get_string('idle', 'chat');
$strcurrentusers = get_string('currentusers', 'chat');
$strnextsession = get_string('nextsession', 'chat');
$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$title = $courseshortname . ': ' . format_string($chat->name);
示例11: custom_menu_user
/**
* Outputs the user menu.
* @return custom_menu object
*/
public function custom_menu_user()
{
// Die if executed during install.
if (during_initial_install()) {
return false;
}
global $USER, $CFG, $DB;
$loginurl = get_login_url();
$usermenu = html_writer::start_tag('ul', array('class' => 'nav'));
$usermenu .= html_writer::start_tag('li', array('class' => 'dropdown'));
if (!isloggedin()) {
if ($this->page->pagelayout != 'login') {
$userpic = '<em><i class="fa fa-sign-in"></i>' . get_string('login') . '</em>';
$usermenu .= html_writer::link($loginurl, $userpic, array('class' => 'loginurl'));
}
} else {
if (isguestuser()) {
$userurl = new moodle_url('#');
$userpic = parent::user_picture($USER, array('link' => false));
$caret = '<i class="fa fa-caret-right"></i>';
$userclass = array('class' => 'dropdown-toggle', 'data-toggle' => 'dropdown');
$usermenu .= html_writer::link($userurl, $userpic . get_string('guest') . $caret, $userclass);
// Render direct logout link.
$usermenu .= html_writer::start_tag('ul', array('class' => 'dropdown-menu pull-right'));
$branchlabel = '<em><i class="fa fa-sign-out"></i>' . get_string('logout') . '</em>';
$branchurl = new moodle_url('/login/logout.php');
$branchurl->param('sesskey', sesskey());
$usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel));
// Render Help Link.
$usermenu .= $this->theme_essential_render_helplink();
$usermenu .= html_writer::end_tag('ul');
} else {
$course = $this->page->course;
$context = context_course::instance($course->id);
// Output Profile link.
$userurl = new moodle_url('#');
$userpic = parent::user_picture($USER, array('link' => false));
$caret = '<i class="fa fa-caret-right"></i>';
$userclass = array('class' => 'dropdown-toggle', 'data-toggle' => 'dropdown');
if (!empty($USER->alternatename)) {
$usermenu .= html_writer::link($userurl, $userpic . $USER->alternatename . $caret, $userclass);
} else {
$usermenu .= html_writer::link($userurl, $userpic . $USER->firstname . $caret, $userclass);
}
// Start dropdown menu items.
$usermenu .= html_writer::start_tag('ul', array('class' => 'dropdown-menu pull-right'));
if (\core\session\manager::is_loggedinas()) {
$realuser = \core\session\manager::get_realuser();
$branchlabel = '<em><i class="fa fa-key"></i>' . fullname($realuser, true) . get_string('loggedinas', 'theme_essential') . fullname($USER, true) . '</em>';
} else {
$branchlabel = '<em><i class="fa fa-user"></i>' . fullname($USER, true) . '</em>';
}
$branchurl = new moodle_url('/user/profile.php', array('id' => $USER->id));
$usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel));
if (is_mnet_remote_user($USER) && ($idprovider = $DB->get_record('mnet_host', array('id' => $USER->mnethostid)))) {
$branchlabel = '<em><i class="fa fa-users"></i>' . get_string('loggedinfrom', 'theme_essential') . $idprovider->name . '</em>';
$branchurl = new moodle_url($idprovider->wwwroot);
$usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel));
}
if (is_role_switched($course->id)) {
// Has switched roles.
$branchlabel = '<em><i class="fa fa-users"></i>' . get_string('switchrolereturn') . '</em>';
$branchurl = new moodle_url('/course/switchrole.php', array('id' => $course->id, 'sesskey' => sesskey(), 'switchrole' => 0, 'returnurl' => $this->page->url->out_as_local_url(false)));
$usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel));
}
// Add preferences submenu.
$usermenu .= $this->theme_essential_render_preferences($context);
$usermenu .= html_writer::empty_tag('hr', array('class' => 'sep'));
// Output Calendar link if user is allowed to edit own calendar entries.
if (has_capability('moodle/calendar:manageownentries', $context)) {
$branchlabel = '<em><i class="fa fa-calendar"></i>' . get_string('pluginname', 'block_calendar_month') . '</em>';
$branchurl = new moodle_url('/calendar/view.php');
$usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel));
}
// Check if messaging is enabled.
if (!empty($CFG->messaging)) {
$branchlabel = '<em><i class="fa fa-envelope"></i>' . get_string('pluginname', 'block_messages') . '</em>';
$branchurl = new moodle_url('/message/index.php');
$usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel));
}
// Check if user is allowed to manage files.
if (has_capability('moodle/user:manageownfiles', $context)) {
$branchlabel = '<em><i class="fa fa-file"></i>' . get_string('privatefiles', 'block_private_files') . '</em>';
$branchurl = new moodle_url('/user/files.php');
$usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel));
}
// Check if user is allowed to view discussions.
if (has_capability('mod/forum:viewdiscussion', $context)) {
$branchlabel = '<em><i class="fa fa-list-alt"></i>' . get_string('forumposts', 'mod_forum') . '</em>';
$branchurl = new moodle_url('/mod/forum/user.php', array('id' => $USER->id));
$usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel));
$branchlabel = '<em><i class="fa fa-list"></i>' . get_string('discussions', 'mod_forum') . '</em>';
$branchurl = new moodle_url('/mod/forum/user.php', array('id' => $USER->id, 'mode' => 'discussions'));
$usermenu .= html_writer::tag('li', html_writer::link($branchurl, $branchlabel));
$usermenu .= html_writer::empty_tag('hr', array('class' => 'sep'));
}
//.........这里部分代码省略.........
示例12: user_login_string
/**
* Returns text to be displayed to the user which reflects their login status
*
* @uses $CFG
* @uses $USER
* @param course $course {@link $COURSE} object containing course information
* @param user $user {@link $USER} object containing user information
* @return string
*/
function user_login_string($course = NULL, $user = NULL)
{
global $USER, $CFG, $SITE, $DB;
if (empty($user) and !empty($USER->id)) {
$user = $USER;
}
if (empty($course)) {
$course = $SITE;
}
if (session_is_loggedinas()) {
$realuser = session_get_realuser();
$fullname = fullname($realuser, true);
$realuserinfo = " [<a {$CFG->frametarget}\n href=\"{$CFG->wwwroot}/course/loginas.php?id={$course->id}&return=1&sesskey=" . sesskey() . "\">{$fullname}</a>] ";
} else {
$realuserinfo = '';
}
$loginurl = get_login_url();
if (empty($course->id)) {
// $course->id is not defined during installation
return '';
} else {
if (!empty($user->id)) {
$context = get_context_instance(CONTEXT_COURSE, $course->id);
$fullname = fullname($user, true);
$username = "<a {$CFG->frametarget} href=\"{$CFG->wwwroot}/user/view.php?id={$user->id}&course={$course->id}\">{$fullname}</a>";
if (is_mnet_remote_user($user) and $idprovider = $DB->get_record('mnet_host', array('id' => $user->mnethostid))) {
$username .= " from <a {$CFG->frametarget} href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
}
if (isset($user->username) && $user->username == 'guest') {
$loggedinas = $realuserinfo . get_string('loggedinasguest') . " (<a {$CFG->frametarget} href=\"{$loginurl}\">" . get_string('login') . '</a>)';
} else {
if (!empty($user->access['rsw'][$context->path])) {
$rolename = '';
if ($role = $DB->get_record('role', array('id' => $user->access['rsw'][$context->path]))) {
$rolename = ': ' . format_string($role->name);
}
$loggedinas = get_string('loggedinas', 'moodle', $username) . $rolename . " (<a {$CFG->frametarget}\n href=\"{$CFG->wwwroot}/course/view.php?id={$course->id}&switchrole=0&sesskey=" . sesskey() . "\">" . get_string('switchrolereturn') . '</a>)';
} else {
$loggedinas = $realuserinfo . get_string('loggedinas', 'moodle', $username) . ' ' . " (<a {$CFG->frametarget} href=\"{$CFG->wwwroot}/login/logout.php?sesskey=" . sesskey() . "\">" . get_string('logout') . '</a>)';
}
}
} else {
$loggedinas = get_string('loggedinnot', 'moodle') . " (<a {$CFG->frametarget} href=\"{$loginurl}\">" . get_string('login') . '</a>)';
}
}
return '<div class="logininfo">' . $loggedinas . '</div>';
}
示例13: print_error
if (!($cm = get_coursemodule_from_instance("quora", $quora->id, $course->id))) {
print_error('invalidcoursemodule');
}
$user = $USER;
require_login($course, false, $cm);
if ($returnpage == 'index.php') {
$returnto = quora_go_back_to($returnpage . '?id=' . $course->id);
} else {
$returnto = quora_go_back_to($returnpage . '?f=' . $quora->id);
}
if (isguestuser()) {
// Guests can't change quora
$PAGE->set_title($course->shortname);
$PAGE->set_heading($course->fullname);
echo $OUTPUT->header();
echo $OUTPUT->confirm(get_string('noguesttracking', 'quora') . '<br /><br />' . get_string('liketologin'), get_login_url(), $returnto);
echo $OUTPUT->footer();
exit;
}
$info = new stdClass();
$info->name = fullname($user);
$info->quora = format_string($quora->name);
if ($mark == 'read') {
if (!empty($d)) {
if (!($discussion = $DB->get_record('quora_discussions', array('id' => $d, 'quora' => $quora->id)))) {
print_error('invaliddiscussionid', 'quora');
}
quora_tp_mark_discussion_read($user, $d);
} else {
// Mark all messages read in current group
$currentgroup = groups_get_activity_group($cm);
示例14: get_string
$messages = $accessmanager->describe_rules();
if ($quiz->attempts != 1) {
$messages[] = get_string('gradingmethod', 'quiz', quiz_get_grading_option_name($quiz->grademethod));
}
echo $OUTPUT->box_start('quizinfo');
$accessmanager->print_messages($messages);
echo $OUTPUT->box_end();
/// Show number of attempts summary to those who can view reports.
if (has_capability('mod/quiz:viewreports', $context)) {
if ($strattemptnum = quiz_num_attempt_summary($quiz, $cm)) {
echo '<div class="quizattemptcounts"><a href="report.php?mode=overview&id=' . $cm->id . '">' . $strattemptnum . "</a></div>\n";
}
}
/// Guests can't do a quiz, so offer them a choice of logging in or going back.
if (isguestuser()) {
echo $OUTPUT->confirm('<p>' . get_string('guestsno', 'quiz') . "</p>\n\n<p>" . get_string('liketologin') . "</p>\n", get_login_url(), get_referer(false));
echo $OUTPUT->footer();
exit;
}
/// If they are not enrolled in this course in a good enough role, tell them to enrol.
if (!($canattempt || $canpreview || $canreviewmine)) {
echo $OUTPUT->box('<p>' . get_string('youneedtoenrol', 'quiz') . "</p>\n\n<p>" . $OUTPUT->continue_button($CFG->wwwroot . '/course/view.php?id=' . $course->id) . "</p>\n", 'generalbox', 'notice');
echo $OUTPUT->footer();
exit;
}
/// Get this user's attempts.
$attempts = quiz_get_user_attempts($quiz->id, $USER->id);
$lastfinishedattempt = end($attempts);
$unfinished = false;
if ($unfinishedattempt = quiz_get_user_attempt_unfinished($quiz->id, $USER->id)) {
$attempts[] = $unfinishedattempt;
示例15: core_login_process_password_reset_request
/**
* Processes a user's request to set a new password in the event they forgot the old one.
* If no user identifier has been supplied, it displays a form where they can submit their identifier.
* Where they have supplied identifier, the function will check their status, and send email as appropriate.
*/
function core_login_process_password_reset_request()
{
global $DB, $OUTPUT, $CFG, $PAGE;
$systemcontext = context_system::instance();
$mform = new login_forgot_password_form();
if ($mform->is_cancelled()) {
redirect(get_login_url());
} else {
if ($data = $mform->get_data()) {
// Requesting user has submitted form data.
// Next find the user account in the database which the requesting user claims to own.
if (!empty($data->username)) {
// Username has been specified - load the user record based on that.
$username = core_text::strtolower($data->username);
// Mimic the login page process.
$userparams = array('username' => $username, 'mnethostid' => $CFG->mnet_localhost_id, 'deleted' => 0, 'suspended' => 0);
$user = $DB->get_record('user', $userparams);
} else {
// Try to load the user record based on email address.
// this is tricky because
// 1/ the email is not guaranteed to be unique - TODO: send email with all usernames to select the account for pw reset
// 2/ mailbox may be case sensitive, the email domain is case insensitive - let's pretend it is all case-insensitive.
$select = $DB->sql_like('email', ':email', false, true, false, '|') . " AND mnethostid = :mnethostid AND deleted=0 AND suspended=0";
$params = array('email' => $DB->sql_like_escape($data->email, '|'), 'mnethostid' => $CFG->mnet_localhost_id);
$user = $DB->get_record_select('user', $select, $params, '*', IGNORE_MULTIPLE);
}
// Target user details have now been identified, or we know that there is no such account.
// Send email address to account's email address if appropriate.
$pwresetstatus = PWRESET_STATUS_NOEMAILSENT;
if ($user and !empty($user->confirmed)) {
$userauth = get_auth_plugin($user->auth);
if (!$userauth->can_reset_password() or !is_enabled_auth($user->auth) or !has_capability('moodle/user:changeownpassword', $systemcontext, $user->id)) {
if (send_password_change_info($user)) {
$pwresetstatus = PWRESET_STATUS_OTHEREMAILSENT;
} else {
print_error('cannotmailconfirm');
}
} else {
// The account the requesting user claims to be is entitled to change their password.
// Next, check if they have an existing password reset in progress.
$resetinprogress = $DB->get_record('user_password_resets', array('userid' => $user->id));
if (empty($resetinprogress)) {
// Completely new reset request - common case.
$resetrecord = core_login_generate_password_reset($user);
$sendemail = true;
} else {
if ($resetinprogress->timerequested < time() - $CFG->pwresettime) {
// Preexisting, but expired request - delete old record & create new one.
// Uncommon case - expired requests are cleaned up by cron.
$DB->delete_records('user_password_resets', array('id' => $resetinprogress->id));
$resetrecord = core_login_generate_password_reset($user);
$sendemail = true;
} else {
if (empty($resetinprogress->timererequested)) {
// Preexisting, valid request. This is the first time user has re-requested the reset.
// Re-sending the same email once can actually help in certain circumstances
// eg by reducing the delay caused by greylisting.
$resetinprogress->timererequested = time();
$DB->update_record('user_password_resets', $resetinprogress);
$resetrecord = $resetinprogress;
$sendemail = true;
} else {
// Preexisting, valid request. User has already re-requested email.
$pwresetstatus = PWRESET_STATUS_ALREADYSENT;
$sendemail = false;
}
}
}
if ($sendemail) {
$sendresult = send_password_change_confirmation_email($user, $resetrecord);
if ($sendresult) {
$pwresetstatus = PWRESET_STATUS_TOKENSENT;
} else {
print_error('cannotmailconfirm');
}
}
}
}
// Any email has now been sent.
// Next display results to requesting user if settings permit.
echo $OUTPUT->header();
if (!empty($CFG->protectusernames)) {
// Neither confirm, nor deny existance of any username or email address in database.
// Print general (non-commital) message.
notice(get_string('emailpasswordconfirmmaybesent'), $CFG->wwwroot . '/index.php');
die;
// Never reached.
} else {
if (empty($user)) {
// Protect usernames is off, and we couldn't find the user with details specified.
// Print failure advice.
notice(get_string('emailpasswordconfirmnotsent'), $CFG->wwwroot . '/forgot_password.php');
die;
// Never reached.
} else {
//.........这里部分代码省略.........