From 1a198dde7db7ddee6e3bbeabdddfb2cc145069ab Mon Sep 17 00:00:00 2001 From: samhemelryk Date: Fri, 25 Sep 2009 06:17:38 +0000 Subject: [PATCH] core MDL-19791 Replaced deprecated functions, added set_url calls --- lib/form/editorhelp.php | 3 +++ lib/moodlelib.php | 7 ++++++- lib/session-test.php | 8 ++++++-- lib/simpletest/filtersettingsperformancetester.php | 1 + lib/statslib.php | 2 +- lib/weblib.php | 4 ++-- lib/womenslib.php | 8 +++++--- my/index.php | 2 +- 8 files changed, 25 insertions(+), 10 deletions(-) diff --git a/lib/form/editorhelp.php b/lib/form/editorhelp.php index 509462281a..b43273f2e1 100644 --- a/lib/form/editorhelp.php +++ b/lib/form/editorhelp.php @@ -1,5 +1,8 @@ set_url(new moodle_url($CFG->wwwroot.'/lib/form/editorhelp.php')); + $topics = array(); $titles = array(); for ($i=1; ; $i++){ diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 903ec010ba..d9f8842315 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5010,7 +5010,12 @@ function email_welcome_message_to_user($course, $user=NULL) { if (!empty($message)) { $subject = get_string('welcometocourse', '', format_string($course->fullname)); - if (! $teacher = get_teacher($course->id)) { + $context = get_context_instance(CONTEXT_COURSE, $course->id); + // Pass $view=true to filter hidden caps if the user cannot see them + if ($users = get_users_by_capability($context, 'moodle/course:update', 'u.*', 'u.id ASC','', '', '', '', false, true)) { + $users = sort_by_roleassignment_authority($users, $context); + $teacher = array_shift($users); + } else { $teacher = get_admin(); } email_to_user($user, $teacher, $subject, $message); diff --git a/lib/session-test.php b/lib/session-test.php index 01fcd659c0..edfb7a2810 100644 --- a/lib/session-test.php +++ b/lib/session-test.php @@ -32,8 +32,12 @@ /** Include config {@see config.php} */ require '../config.php'; -error('session test not reimplemented yet'); +$PAGE->set_url(new moodle_url($CFG->wwwroot.'/lib/session-test.php')); +$PAGE->set_generaltype('form'); +list($message, $moreinfourl, $link) = prepare_error_message('notlocalisederrormessage', 'error', '', 'session test not reimplemented yet'); +echo $OUTPUT->fatal_error($message, $moreinfourl, $link, debug_backtrace()); +// //TODO: add code that actually tests moodle sessions, the old one only tested PHP sessions used from installer, not the real moodle sessions -?> +?> \ No newline at end of file diff --git a/lib/simpletest/filtersettingsperformancetester.php b/lib/simpletest/filtersettingsperformancetester.php index 99aa691807..149b7a91af 100644 --- a/lib/simpletest/filtersettingsperformancetester.php +++ b/lib/simpletest/filtersettingsperformancetester.php @@ -41,6 +41,7 @@ require_capability('moodle/site:config', $syscontext); $baseurl = $CFG->wwwroot . '/lib/simpletest/filtersettingsperformancetester.php'; $title = 'filter_get_active_in_context performance test'; +$PAGE->set_url(new moodle_url($CFG->wwwroot.'/lib/simpletest/filtersettingsperformancetester.php')); $PAGE->navbar->add($title); $PAGE->set_title($title); $PAGE->set_heading($title); diff --git a/lib/statslib.php b/lib/statslib.php index 9f00f648da..4b16a31484 100644 --- a/lib/statslib.php +++ b/lib/statslib.php @@ -145,7 +145,7 @@ function stats_cron_daily($maxdays=1) { $viewactions = implode(',', stats_get_action_names('view')); $postactions = implode(',', stats_get_action_names('post')); - $guest = get_guest(); + $guest = get_complete_user_data('username', 'guest'); $guestrole = get_guest_role(); list($enroljoin, $enrolwhere, $enrolparams) = stats_get_enrolled_sql($CFG->statscatdepth, true); diff --git a/lib/weblib.php b/lib/weblib.php index d26cc22365..cce26eb0bb 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -2164,11 +2164,11 @@ function open_containers() { * @return mixed string or void */ function print_container_end_all($return=false, $keep=0) { + global $OUTPUT; $output = ''; while (open_containers() > $keep) { - $output .= print_container_end($return); + $output .= $OUTPUT->container_end(); } - if ($return) { return $output; } else { diff --git a/lib/womenslib.php b/lib/womenslib.php index 1118cf2e24..b22710dcb4 100644 --- a/lib/womenslib.php +++ b/lib/womenslib.php @@ -22,6 +22,8 @@ */ /** Include config.pgp */ - include('../config.php'); - redirect('http://en.wikipedia.org/wiki/Women%27s_liberation'); -?> +include('../config.php'); + +$PAGE->set_url(new moodle_url($CFG->wwwroot.'/lib/womenslib.php')); + +redirect('http://en.wikipedia.org/wiki/Women%27s_liberation'); \ No newline at end of file diff --git a/my/index.php b/my/index.php index 43641c909b..ebdd718503 100644 --- a/my/index.php +++ b/my/index.php @@ -9,7 +9,7 @@ $strmymoodle = get_string('mymoodle','my'); - if (isguest()) { + if (has_capability('moodle/legacy:guest', get_context_instance(CONTEXT_SYSTEM), 0, false)) { $PAGE->set_title($strmymoodle); echo $OUTPUT->header(); echo $OUTPUT->confirm(get_string('noguest', 'my') . '

' . get_string('liketologin'), get_login_url(), $CFG->wwwroot); -- 2.39.5