From 3cd9c557ab385e03298d8712415da21554945144 Mon Sep 17 00:00:00 2001 From: Johannes Burk Date: Thu, 10 Jul 2014 21:09:10 +0200 Subject: [PATCH 1/2] Replaced deprecated function get_context_instance() with context_XXX::instance() --- apply.php | 4 ++-- edit.php | 2 +- enroluser.php | 2 +- lib.php | 6 +++--- manage.php | 2 +- unenroluser.php | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apply.php b/apply.php index 0781f38..303ce7e 100644 --- a/apply.php +++ b/apply.php @@ -16,11 +16,11 @@ require_once($CFG->dirroot.'/lib/outputcomponents.php'); require_once ('lib.php'); $site = get_site (); -$systemcontext = get_context_instance ( CONTEXT_SYSTEM ); +$systemcontext = context_system::instance(); $id = required_param ( 'id', PARAM_INT ); // course id $course = $DB->get_record ( 'course', array ('id' => $id ), '*', MUST_EXIST ); -$context = get_context_instance ( CONTEXT_COURSE, $course->id, MUST_EXIST ); +$context = context_course::instance($course->id, MUST_EXIST); require_login ( $course ); require_capability ( 'moodle/course:enrolreview', $context ); diff --git a/edit.php b/edit.php index 2f0b7ee..18c78a9 100644 --- a/edit.php +++ b/edit.php @@ -17,7 +17,7 @@ $courseid = required_param('courseid', PARAM_INT); $instanceid = optional_param('id', 0, PARAM_INT); // instanceid $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST); -$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST); +$context = context_course::instance($course->id, MUST_EXIST); require_login($course); require_capability('enrol/self:config', $context); diff --git a/enroluser.php b/enroluser.php index 32f8392..379208a 100644 --- a/enroluser.php +++ b/enroluser.php @@ -20,7 +20,7 @@ $extendbase = optional_param('extendbase', 3, PARAM_INT); $instance = $DB->get_record('enrol', array('id'=>$enrolid, 'enrol'=>'apply'), '*', MUST_EXIST); $course = $DB->get_record('course', array('id'=>$instance->courseid), '*', MUST_EXIST); -$context = get_context_instance(CONTEXT_COURSE, $course->id, MUST_EXIST); +$context = context_course::instance($course->id, MUST_EXIST); require_login($course); //require_capability('enrol/manual:enrol', $context); diff --git a/lib.php b/lib.php index 187c91e..ba6fdd3 100644 --- a/lib.php +++ b/lib.php @@ -17,7 +17,7 @@ class enrol_apply_plugin extends enrol_plugin { } public function get_newinstance_link($courseid) { - $context = get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST); + $context = context_course::instance($courseid, MUST_EXIST); if (!has_capability('moodle/course:enrolconfig', $context) or !has_capability('enrol/manual:config', $context)) { return NULL; @@ -101,7 +101,7 @@ class enrol_apply_plugin extends enrol_plugin { if ($instance->enrol !== 'apply') { throw new coding_exception('invalid enrol instance!'); } - $context = get_context_instance(CONTEXT_COURSE, $instance->courseid); + $context = context_course::instance($instance->courseid); $icons = array(); @@ -216,7 +216,7 @@ function sendConfirmMailToTeachers($courseid,$desc){ if($apply_setting['sendmailtoteacher']->value == 1){ $course = $DB->get_record('course',array('id'=>$courseid)); - $context = get_context_instance(CONTEXT_COURSE, $courseid, MUST_EXIST); + $context = context_course::instance($courseid, MUST_EXIST); $teacherType = $DB->get_record('role',array("shortname"=>"editingteacher")); $teachers = $DB->get_records('role_assignments', array('contextid'=>$context->id,'roleid'=>$teacherType->id)); foreach($teachers as $teacher){ diff --git a/manage.php b/manage.php index e27ae78..2153518 100644 --- a/manage.php +++ b/manage.php @@ -15,7 +15,7 @@ require_login(); require_capability('enrol/apply:manage', context_system::instance()); $site = get_site (); -$systemcontext = get_context_instance ( CONTEXT_SYSTEM ); +$systemcontext = context_system::instance(); $PAGE->set_url ( '/enrol/manage.php'); $PAGE->set_context($systemcontext); diff --git a/unenroluser.php b/unenroluser.php index c219321..a8ec0ab 100644 --- a/unenroluser.php +++ b/unenroluser.php @@ -50,7 +50,7 @@ if ($course->id == SITEID) { // Obviously require_login($course); // Make sure the user can unenrol self enrolled users. -require_capability("enrol/self:unenrol", get_context_instance(CONTEXT_COURSE, $course->id)); +require_capability("enrol/self:unenrol", context_course::instance($course->id)); // Get the enrolment manager for this course $manager = new course_enrolment_manager($PAGE, $course, $filter); From a952ab653afdbaca3108112ee2c0d39a2d1b9092 Mon Sep 17 00:00:00 2001 From: Flottertotte Date: Fri, 8 Aug 2014 17:43:44 +0800 Subject: [PATCH 2/2] Add more placeholders Added more placeholders to confirmation/ cancellation email --- lang/en/enrol_apply.php | 4 ++-- lib.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lang/en/enrol_apply.php b/lang/en/enrol_apply.php index 0c1d356..e369443 100644 --- a/lang/en/enrol_apply.php +++ b/lang/en/enrol_apply.php @@ -18,8 +18,8 @@ $string['confirmmailsubject'] = 'Confirm mail subject'; $string['confirmmailcontent'] = 'Confirm mail content'; $string['cancelmailsubject'] = 'Cancel mail subject'; $string['cancelmailcontent'] = 'Cancel mail sontent'; -$string['confirmmailcontent_desc'] = 'Please use special marks designated email content replaced.
{firstname}:Registration name; {content}:Course name'; -$string['cancelmailcontent_desc'] = 'Please use special marks designated email content replaced.
{firstname}:Registration name; {content}:Course name'; +$string['confirmmailcontent_desc'] = 'Please use special marks designated email content replaced.
{firstname}:Registration name; {content}:Course name;{lastname}:The last name of the user;{username}:Registration name'; +$string['cancelmailcontent_desc'] = 'Please use special marks designated email content replaced.
{firstname}:Registration name; {content}:Course name;{lastname}:The last name of the user;{username}:Registration name'; $string['confirmusers'] = 'Enrol Confirm'; diff --git a/lib.php b/lib.php index 49280f4..65f0dc2 100644 --- a/lib.php +++ b/lib.php @@ -202,7 +202,7 @@ function sendCancelMail($info){ global $CFG; $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'"); - $replace = array('firstname'=>$info->firstname,'content'=>$info->coursename); + $replace = array('firstname'=>$info->firstname,'content'=>$info->coursename,'lastname'=>$info->lastname,'username'=>$info->username); $body = $apply_setting['cancelmailcontent']->value; $body = updateMailContent($body,$replace); $contact = get_admin(); @@ -214,7 +214,7 @@ function sendConfirmMail($info){ global $CFG; $apply_setting = $DB->get_records_sql("select name,value from ".$CFG->prefix."config_plugins where plugin='enrol_apply'"); - $replace = array('firstname'=>$info->firstname,'content'=>$info->coursename); + $replace = array('firstname'=>$info->firstname,'content'=>$info->coursename,'lastname'=>$info->lastname,'username'=>$info->username); $body = $apply_setting['confirmmailcontent']->value; $body = updateMailContent($body,$replace); $contact = get_admin();