Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-31365 Fix for safebrowser and securewindow

  • Loading branch information...
commit 2d0e682d8bd71ec954c4b765a2b2a76c3b59f6fa 1 parent 569f1ad
@birdy1976 birdy1976 authored
View
45 lib/outputrenderers.php
@@ -508,23 +508,32 @@ public function standard_end_of_body_html() {
/**
* 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 @@ public function login_info() {
$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 @@ public function login_info() {
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>)';
}
}
View
3  mod/quiz/accessrule/safebrowser/rule.php
@@ -61,6 +61,9 @@ public function description() {
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');
}
/**
View
2  mod/quiz/accessrule/securewindow/rule.php
@@ -73,7 +73,7 @@ public function setup_attempt_page($page) {
$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;
View
8 theme/base/config.php
@@ -153,12 +153,18 @@
'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
View
7 theme/upgrade.txt
@@ -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-"
Please sign in to comment.
Something went wrong with that request. Please try again.