Permalink
Browse files

MDL-34466 mod_chat Replace all instances of get_context_instance() wi…

…th respective context_XXXX class in mod/chat
  • Loading branch information...
1 parent 01a6710 commit 6536217c781bf70f68fdaffd0f60e853ac6391d4 @dmonllao dmonllao committed Jul 26, 2012
@@ -17,7 +17,7 @@
$course = $DB->get_record('course', array('id'=>$chat->course), '*', MUST_EXIST);
$cm = get_coursemodule_from_instance('chat', $chat->id, $course->id, false, MUST_EXIST);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_login($course, false, $cm);
require_capability('mod/chat:chat', $context);
@@ -45,7 +45,7 @@
if (!$chat_sid = chat_login_user($chat->id, 'ajax', $groupid, $course)) {
print_error('cantlogin', 'chat');
}
-$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
+$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$module = array(
'name' => 'mod_chat_ajax', // chat gui's are not real plugins, we have to break the naming standards for JS modules here :-(
'fullpath' => '/mod/chat/gui_ajax/module.js',
@@ -40,7 +40,7 @@
print_error('invalidcoursemodule');
}
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_login($course, false, $cm);
require_capability('mod/chat:chat', $context);
$PAGE->set_pagelayout('base');
@@ -25,8 +25,6 @@
$PAGE->set_url('/mod/chat/gui_header_js/chatinput.php', array('chat_sid'=>$chat_sid, 'chat_id'=>$chatid));
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
-
//Get the user theme
$USER = $DB->get_record('user', array('id'=>$chatuser->userid));
@@ -24,7 +24,7 @@
print_error('invalidcoursemodule');
}
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_login($course, false, $cm);
@@ -59,7 +59,7 @@
$updatemode = $CFG->chat_normal_updatemode;
}
-$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
+$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
@@ -25,7 +25,7 @@
}
require_login($course, false, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
if (isguestuser()) {
print_error('noguests', 'chat');
@@ -53,7 +53,7 @@
}
$params = "chat_sid=$chat_sid";
-$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
+$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
View
@@ -280,7 +280,7 @@ function chat_print_recent_activity($course, $viewfullnames, $timestart) {
}
if (groups_get_activity_groupmode($cm) != SEPARATEGROUPS
- or has_capability('moodle/site:accessallgroups', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+ or has_capability('moodle/site:accessallgroups', context_module::instance($cm->id))) {
if ($timeout > time() - $cm->lasttime) {
$current[] = $cm;
} else {
@@ -1218,7 +1218,7 @@ function chat_extend_navigation($navigation, $course, $module, $cm) {
$currentgroup = groups_get_activity_group($cm, true);
- if (has_capability('mod/chat:chat', get_context_instance(CONTEXT_MODULE, $cm->id))) {
+ if (has_capability('mod/chat:chat', context_module::instance($cm->id))) {
$strenterchat = get_string('enterchat', 'chat');
$target = $CFG->wwwroot.'/mod/chat/';
@@ -103,7 +103,7 @@ public function get_sha1() {
* @return bool
*/
public function check_permissions() {
- $context = get_context_instance(CONTEXT_MODULE, $this->cm->id);
+ $context = context_module::instance($this->cm->id);
return has_capability('mod/chat:exportsession', $context)
|| ($this->participated
&& has_capability('mod/chat:exportparticipatedsession', $context));
View
@@ -37,7 +37,7 @@
print_error('coursemisconf');
}
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$PAGE->set_context($context);
$PAGE->set_heading($course->fullname);
View
@@ -56,7 +56,7 @@
require_course_login($course, true, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
$PAGE->set_context($context);
// show some info for guests
@@ -77,7 +77,7 @@
$strcurrentusers = get_string('currentusers', 'chat');
$strnextsession = get_string('nextsession', 'chat');
-$courseshortname = format_string($course->shortname, true, array('context' => get_context_instance(CONTEXT_COURSE, $course->id)));
+$courseshortname = format_string($course->shortname, true, array('context' => context_course::instance($course->id)));
$title = $courseshortname . ': ' . format_string($chat->name);
// Mark viewed by user (if required)

0 comments on commit 6536217

Please sign in to comment.