Skip to content
Browse files

ForumNG: Email did not work with 2.2 (Now requires 2.2+!)

In order to make email work correctly in 2.2, I had to remove 2.1 compatibility.
Anyone requiring 2.0/2.1 support should ensure they use a version that does not
include this commit.
  • Loading branch information...
1 parent a9f0696 commit 6176cf96beb67f1956fe963b2b84721362655c9d @sammarshallou sammarshallou committed Mar 2, 2012
View
2 advancedsearch.php
@@ -172,7 +172,7 @@ public function validation($data, $files) {
if ($courseid) {
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
require_login($course);
- $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
+ $coursecontext = context_course::instance($courseid);
mod_forumng::search_installed();
$allforums = true;
}
View
2 attachments.php
@@ -53,7 +53,7 @@
// Get the files and count
$options = file_get_drafarea_files($draftitemid, '/');
-$usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+$usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$files = $fs->get_area_files($usercontext->id, 'user', 'draft', $options->itemid, 'id', false);
$filecount = count($files);
View
2 convert.php
@@ -63,7 +63,7 @@ function definition() {
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
require_login($course);
require_capability('moodle/course:manageactivities',
- get_context_instance(CONTEXT_COURSE, $courseid));
+ context_course::instance($courseid));
$pagename = get_string('convert_title', 'forumng');
$navigation = array();
View
6 dev/makebig.php
@@ -29,7 +29,7 @@
require_once($CFG->dirroot.'/mod/forumng/mod_forumng.php');
require_once($CFG->dirroot.'/mod/forumng/mod_forumng_exception.php');
require_login();
-require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
+require_capability('moodle/site:config', context_system::instance());
if (!debugging('', DEBUG_DEVELOPER)) {
error('Available only in debug mode');
}
@@ -222,7 +222,7 @@ function make_forums($courseid, $count, $discussions, $posts,
$DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
// Get all course users
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ $context = context_course::instance($courseid);
$rs = $DB->get_recordset_sql("
SELECT
DISTINCT userid
@@ -304,7 +304,7 @@ function make_student($courseid, $username) {
$user->id = $DB->insert_record('user', $user);
// Assign to course
- $context = get_context_instance(CONTEXT_COURSE, $courseid);
+ $context = context_course::instance($courseid);
static $roleid;
if (!$roleid) {
$roleid = $DB->get_field('role', 'id', array('shortname' => 'student'));
View
2 editpost.php
@@ -273,7 +273,7 @@ function finish($postid, $cloneid, $url, $fromform, $ajaxdata='') {
$hasattachments = false;
if (isset($fromform->attachments)) {
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$hasattachments = count($fs->get_area_files($usercontext->id, 'user', 'draft',
$fromform->attachments, 'id'));
View
4 feature/export/portfoliolib.php
@@ -57,7 +57,7 @@ protected function load_base_data($forumngid) {
throw new portfolio_caller_exception('error_export', 'forumng');
}
$this->cm = $instances[$this->forumng->id];
- $this->modcontext = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ $this->modcontext = context_module::instance($this->cm->id);
}
/**
@@ -139,7 +139,7 @@ public function expected_time() {
}
public function check_permissions() {
- $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ $context = context_module::instance($this->cm->id);
return (has_capability('mod/forumng:view', $context));
}
View
2 feature/move/forumngfeature_move.php
@@ -58,7 +58,7 @@ public function display($discussion) {
$other->id == $discussion->get_forum()->get_course_module_id()) {
continue;
}
- $othercontext = get_context_instance(CONTEXT_MODULE, $other->id);
+ $othercontext = context_module::instance($other->id);
if (has_capability('mod/forumng:movediscussions', $othercontext)) {
$results[$other->id] = $other->name;
}
View
2 index.php
@@ -48,7 +48,7 @@
$strweek = get_string('week');
$strsection = get_string('section');
-$coursecontext = get_context_instance(CONTEXT_COURSE, $id);
+$coursecontext = context_course::instance($id);
$canmaybesubscribe = (!isguestuser()
&& has_capability('moodle/course:view', $coursecontext));
View
2 lib.php
@@ -443,7 +443,7 @@ function mod_forumng_cm_info_view(cm_info $cm) {
*/
function mod_forumng_cm_info_dynamic(cm_info $cm) {
if (!has_capability('mod/forumng:view',
- get_context_instance(CONTEXT_MODULE,$cm->id))) {
+ context_module::instance($cm->id))) {
$cm->uservisible = false;
$cm->set_available(false);
}
View
2 mod_form.php
@@ -32,7 +32,7 @@ function definition() {
global $CFG, $COURSE, $DB;
$mform =& $this->_form;
- $coursecontext = get_context_instance(CONTEXT_COURSE, $COURSE->id);
+ $coursecontext = context_course::instance($COURSE->id);
$forumng = $this->_instance
? $DB->get_record('forumng', array('id' => $this->_instance)) : null;
$this->clone = $forumng ? $forumng->originalcmid : 0;
View
19 mod_forumng.php
@@ -604,13 +604,12 @@ private static function get_modinfo_cm($cmid, $course=null) {
* original forum.
* @param bool $forcereal If set, always returns the context of the
* original forum and not of any clone
- * @return object Context object
+ * @return context Context object
*/
public function get_context($forcereal = false) {
if ($this->is_shared() && !$forcereal) {
if (!$this->clonecontext) {
- $this->clonecontext = get_context_instance(CONTEXT_MODULE,
- $this->get_course_module_id());
+ $this->clonecontext = context_module::instance($this->get_course_module_id());
}
return $this->clonecontext;
}
@@ -927,7 +926,7 @@ public static function get_from_id($id, $cloneid, $requirecm=true, $passcm=null)
// Get context
$context = null;
if ($cm) {
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
}
// Construct forum
@@ -991,7 +990,7 @@ public static function get_from_cmid($cmid, $cloneid) {
$forumfields = $DB->get_record('forumng', array('id' => $cm->instance));
// Get context
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
// Construct forum
$result = new mod_forumng($course, $cm, $context, $forumfields);
@@ -2844,7 +2843,7 @@ public static function get_course_forums($course, $userid = 0,
if (count($specificids) && !in_array($cmid, $specificids)) {
continue;
}
- $context = get_context_instance(CONTEXT_MODULE, $cmid);
+ $context = context_module::instance($cmid);
if ($cm->modname == 'forumng') {
if (has_capability(
'moodle/site:accessallgroups', $context, $userid)) {
@@ -2905,7 +2904,7 @@ public static function get_course_forums($course, $userid = 0,
// Create a new forum object from the database details
$forumfields = mod_forumng_utils::extract_subobject($rec, 'f_');
$forum = new mod_forumng($course, $cm,
- get_context_instance(CONTEXT_MODULE, $cm->id), $forumfields);
+ context_module::instance($cm->id), $forumfields);
$result[$forumfields->id] = $forum;
if ($forum->is_shared()) {
$forum->set_clone_reference(self::CLONE_DIRECT);
@@ -4499,8 +4498,8 @@ public static function create_from_old_forum($course, $forumcmid, $progress, $hi
}
// Transfer role assignments
- $oldcontext = get_context_instance(CONTEXT_MODULE, $cm->id);
- $newcontext = get_context_instance(CONTEXT_MODULE, $newcm->id);
+ $oldcontext = context_module::instance($cm->id);
+ $newcontext = context_module::instance($newcm->id);
$roles = $DB->get_records('role_assignments', array('contextid' => $oldcontext->id));
if ($roles) {
if ($progress) {
@@ -4895,7 +4894,7 @@ public function group_subscription_update($moodleupdate=false, $cmid=0) {
print "Updating the subscriptions $forumcount/$totalforumcount
(current cmid:$rec->cmid) <br />";
}
- $context = get_context_instance(CONTEXT_MODULE, $rec->cmid);
+ $context = context_module::instance($rec->cmid);
$aagusers = get_users_by_capability($context,
'moodle/site:accessallgroups', 'u.id');
$aagusers = $aagusers ? $aagusers : array();
View
2 mod_forumng_draft.php
@@ -387,7 +387,7 @@ public function prepare_edit_js($forum) {
// Get list of files for main attachment area
$options = file_get_drafarea_files($draftitemid, '/');
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$files = $fs->get_area_files($usercontext->id, 'user', 'draft',
$options->itemid, 'id', false);
View
4 mod_forumng_mail_list.php
@@ -248,7 +248,9 @@ function next_forum(&$forum, &$cm, &$context, &$course) {
$this->storedrecord = clone($record);
$cm = mod_forumng_utils::extract_subobject($record, 'cm_');
$course = mod_forumng_utils::extract_subobject($record, 'c_');
- $context = mod_forumng_utils::extract_subobject($record, 'x_');
+ context_helper::preload_from_record(
+ mod_forumng_utils::extract_subobject($record, 'x_'));
+ $context = context_module::instance($cm->id);
$forum = new mod_forumng($course, $cm, $context,
mod_forumng_utils::extract_subobject($record, 'f_'));
if ($forum->is_shared()) {
View
4 mod_forumng_post.php
@@ -724,7 +724,7 @@ static function search_get_page($document) {
$now = time();
if ($now < $result->timestart || ($result->timeend && $now>=$result->timeend) &&
!has_capability('mod/forumng:viewallposts',
- get_context_instance(CONTEXT_MODULE, $result->cmid))) {
+ context_module::instance($result->cmid))) {
$result->hide = true;
}
@@ -2244,7 +2244,7 @@ function prepare_edit_json() {
// Get list of files for main attachment area
$options = file_get_drafarea_files($draftitemid, '/');
- $usercontext = get_context_instance(CONTEXT_USER, $USER->id);
+ $usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$files = $fs->get_area_files($usercontext->id, 'user', 'draft',
$options->itemid, 'id', false);
View
2 rebuildsearchindex.php
@@ -27,7 +27,7 @@
require_once('../../config.php');
require_once($CFG->dirroot . '/mod/forumng/mod_forumng.php');
-require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
+require_capability('moodle/site:config', context_system::instance());
$cmid = required_param('id', PARAM_INT);
$cloneid = optional_param('clone', 0, PARAM_INT);
View
4 subscribe.php
@@ -173,7 +173,7 @@ function get_group_list($userid, $forumngid) {
$forum->require_view($groupid);
} else {
// If it is a separate groups forum and current user does not have access all groups
- $context = get_context_instance(CONTEXT_MODULE, $cmid);
+ $context = context_module::instance($cmid);
$aaguser = has_capability('moodle/site:accessallgroups', $context);
if ($forum->get_group_mode() == SEPARATEGROUPS && !$aaguser) {
$grouplist = get_group_list($userid, $forumngid);
@@ -400,7 +400,7 @@ function get_group_list($userid, $forumngid) {
} else {
$backurl = $CFG->wwwroot . '/course/view.php?id=' . $courseid;
$PAGE->set_url($pageurl);
- $PAGE->set_context(get_context_instance(CONTEXT_COURSE, $courseid));
+ $PAGE->set_context(context_course::instance($courseid));
$PAGE->set_heading($COURSE->fullname);
$PAGE->set_title($COURSE->shortname);
$out = forum_utils::get_renderer();
View
2 version.php
@@ -23,7 +23,7 @@
*/
$module->version = 2012021700;
-$module->requires = 2011022100; // 2.0.2
+$module->requires = 2011120500; // 2.2.0
$module->cron = 60;
// Note: we haven't really sorted out how/if to use this string yet...

0 comments on commit 6176cf9

Please sign in to comment.
Something went wrong with that request. Please try again.