MDL-31365 Fix for safebrowser and securewindow

This commit is contained in:
Martin Vögeli
2012-09-03 07:25:30 +02:00
parent 569f1ad63b
commit 2d0e682d8b
5 changed files with 50 additions and 15 deletions
+33 -12
View File
@@ -508,23 +508,32 @@ class core_renderer extends renderer_base {
/**
* 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() {
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 (session_is_loggedinas()) {
$realuser = session_get_realuser();
$fullname = fullname($realuser, true);
$realuserinfo = " [<a href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&amp;sesskey=".sesskey()."\">$fullname</a>] ";
if ($withlinks) {
$realuserinfo = " [<a href=\"$CFG->wwwroot/course/loginas.php?id=$course->id&amp;sesskey=".sesskey()."\">$fullname</a>] ";
} else {
$realuserinfo = " [$fullname] ";
}
} else {
$realuserinfo = '';
}
@@ -539,13 +548,21 @@ class core_renderer extends renderer_base {
$fullname = fullname($USER, true);
// Since Moodle 2.0 this link always goes to the public profile page (not the course profile page)
$username = "<a href=\"$CFG->wwwroot/user/profile.php?id=$USER->id\">$fullname</a>";
if ($withlinks) {
$username = "<a href=\"$CFG->wwwroot/user/profile.php?id=$USER->id\">$fullname</a>";
} else {
$username = $fullname;
}
if (is_mnet_remote_user($USER) and $idprovider = $DB->get_record('mnet_host', array('id'=>$USER->mnethostid))) {
$username .= " from <a href=\"{$idprovider->wwwroot}\">{$idprovider->name}</a>";
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) {
if (!$loginpage && $withlinks) {
$loggedinas .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
}
} else if (is_role_switched($course->id)) { // Has switched roles
@@ -553,15 +570,19 @@ class core_renderer extends renderer_base {
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 href=\"$CFG->wwwroot/course/view.php?id=$course->id&amp;switchrole=0&amp;sesskey=".sesskey()."\">".get_string('switchrolereturn').'</a>)';
$loggedinas = get_string('loggedinas', 'moodle', $username).$rolename;
if ($withlinks) {
$loggedinas .= " (<a href=\"$CFG->wwwroot/course/view.php?id=$course->id&amp;switchrole=0&amp;sesskey=".sesskey()."\">".get_string('switchrolereturn').'</a>)';
}
} else {
$loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username).' '.
" (<a href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
$loggedinas = $realuserinfo.get_string('loggedinas', 'moodle', $username);
if ($withlinks) {
$loggedinas .= " (<a href=\"$CFG->wwwroot/login/logout.php?sesskey=".sesskey()."\">".get_string('logout').'</a>)';
}
}
} else {
$loggedinas = get_string('loggedinnot', 'moodle');
if (!$loginpage) {
if (!$loginpage && $withlinks) {
$loggedinas .= " (<a href=\"$loginurl\">".get_string('login').'</a>)';
}
}
+3
View File
@@ -61,6 +61,9 @@ class quizaccess_safebrowser extends quiz_access_rule_base {
public function setup_attempt_page($page) {
$page->set_title($this->quizobj->get_course()->shortname . ': ' . $page->title);
$page->set_cacheable(false);
$page->set_popup_notification_allowed(false); // Prevent message notifications.
$page->set_heading($page->title);
$page->set_pagelayout('secure');
}
/**
+1 -1
View File
@@ -73,7 +73,7 @@ class quizaccess_securewindow extends quiz_access_rule_base {
$page->set_popup_notification_allowed(false); // Prevent message notifications.
$page->set_title($this->quizobj->get_course()->shortname . ': ' . $page->title);
$page->set_cacheable(false);
$page->set_pagelayout('popup');
$page->set_pagelayout('secure');
if ($this->quizobj->is_preview_user()) {
return;
+7 -1
View File
@@ -153,12 +153,18 @@ $THEME->layouts = array(
'regions' => array(),
'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true),
),
// The pagelayout used for reports
// The pagelayout used for reports.
'report' => array(
'file' => 'report.php',
'regions' => array('side-pre'),
'defaultregion' => 'side-pre',
),
// The pagelayout used for safebrowser and securewindow.
'secure' => array(
'file' => 'general.php',
'regions' => array(),
'options' => array('nofooter'=>true, 'nonavbar'=>true, 'nocustommenu'=>true, 'nologinlinks'=>true),
),
);
// We don't want the base theme to be shown on the theme selection screen, by setting
+6 -1
View File
@@ -1,6 +1,11 @@
This files describes API changes in /theme/* themes,
information provided here is intended especially for theme designer.
=== 2.4 ===
optional changes:
* new optional boolean parameter $withlinks for public function login_info() in lib/outputrenderers.php (MDL-31365)
* new layout option "nologinlinks" and new page layout "secure" e.g. for safebrowser and securewindow (MDL-31365)
=== 2.3 ===
@@ -12,4 +17,4 @@ optional changes:
required changes:
* use new page content placeholder "echo $OUTPUT->main_content()" instead of "echo core_renderer::MAIN_CONTENT_TOKEN"
see git commit: 3b3f302855d7621405a8b93e49bd399d67a998d7
* upgrade report selectors: search for "-course-report-" and replace with "-report-"
* upgrade report selectors: search for "-course-report-" and replace with "-report-"