Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-34470 wiki: Replace all instances of get_context_instance() with …

…context_xxx::instance() in mod/wiki
  • Loading branch information...
commit 1df236266955d0ecf9ac5f33dae5280c6912885c 1 parent 6fd7b70
@ankitagarwal ankitagarwal authored
View
2  mod/wiki/admin.php
@@ -56,7 +56,7 @@
require_login($course, true, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_capability('mod/wiki:managewiki', $context);
add_to_log($course->id, "wiki", "admin", "admin.php?pageid=".$page->id, $page->id, $cm->id);
View
2  mod/wiki/create.php
@@ -64,7 +64,7 @@
$groups = new stdClass();
if (groups_get_activity_groupmode($cm)) {
- $modulecontext = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $modulecontext = context_module::instance($cm->id);
$canaccessgroups = has_capability('moodle/site:accessallgroups', $modulecontext);
if ($canaccessgroups) {
$groups->availablegroups = groups_get_all_groups($cm->course);
View
2  mod/wiki/edit.php
@@ -74,7 +74,7 @@
require_login($course, true, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_capability('mod/wiki:editpage', $context);
if ($option == get_string('save', 'wiki')) {
View
2  mod/wiki/files.php
@@ -73,7 +73,7 @@
// Checking course instance
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
$PAGE->set_url('/mod/wiki/files.php', array('pageid'=>$pageid));
View
2  mod/wiki/filesedit.php
@@ -50,7 +50,7 @@
// Checking course instance
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_login($course, true, $cm);
require_capability('mod/wiki:managefiles', $context);
View
2  mod/wiki/history.php
@@ -59,7 +59,7 @@
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
require_login($course, true, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_capability('mod/wiki:viewpage', $context);
add_to_log($course->id, 'wiki', 'history', "history.php?pageid=".$pageid, $pageid, $cm->id);
View
2  mod/wiki/index.php
@@ -43,7 +43,7 @@
require_login($course, true);
$PAGE->set_pagelayout('incourse');
-$context = get_context_instance(CONTEXT_COURSE, $course->id);
+$context = context_course::instance($course->id);
add_to_log($course->id, 'wiki', 'view', "index.php?id=".$id, "");
View
8 mod/wiki/lib.php
@@ -161,7 +161,7 @@ function wiki_reset_userdata($data) {
if (!$cm = get_coursemodule_from_instance('wiki', $wiki->id)) {
continue;
}
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$DB->delete_records_select('comments', "contextid = ? AND commentarea='wiki_page'", array($context->id));
$status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallcomments'), 'error'=>false);
}
@@ -303,7 +303,7 @@ function wiki_print_recent_activity($course, $viewfullnames, $timestart) {
if (!$cm->uservisible) {
continue;
}
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
if (!has_capability('mod/wiki:viewpage', $context)) {
continue;
@@ -490,7 +490,7 @@ function wiki_extend_navigation(navigation_node $navref, $course, $module, $cm)
require_once($CFG->dirroot . '/mod/wiki/locallib.php');
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$url = $PAGE->url;
$userid = 0;
if ($module->wikimode == 'individual') {
@@ -633,7 +633,7 @@ function wiki_comment_validate($comment_param) {
if (!$cm = get_coursemodule_from_instance('wiki', $wiki->id, $course->id)) {
throw new comment_exception('invalidcoursemodule');
}
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
// group access
if ($subwiki->groupid) {
$groupmode = groups_get_activity_groupmode($cm, $course);
View
16 mod/wiki/locallib.php
@@ -213,7 +213,7 @@ function wiki_save_section($wikipage, $sectiontitle, $sectioncontent, $userid) {
$wiki = wiki_get_wiki_from_pageid($wikipage->id);
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
if (has_capability('mod/wiki:editpage', $context)) {
$version = wiki_get_current_version($wikipage->id);
@@ -238,7 +238,7 @@ function wiki_save_page($wikipage, $newcontent, $userid) {
$wiki = wiki_get_wiki_from_pageid($wikipage->id);
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
if (has_capability('mod/wiki:editpage', $context)) {
$version = wiki_get_current_version($wikipage->id);
@@ -324,7 +324,7 @@ function wiki_create_page($swid, $title, $format, $userid) {
global $DB;
$subwiki = wiki_get_subwiki($swid);
$cm = get_coursemodule_from_instance('wiki', $subwiki->wikiid);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
require_capability('mod/wiki:editpage', $context);
// if page exists
if ($page = wiki_get_page_by_title($swid, $title)) {
@@ -577,7 +577,7 @@ function wiki_parse_content($markup, $pagecontent, $options = array()) {
$subwiki = wiki_get_subwiki($options['swid']);
$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$parser_options = array(
'link_callback' => '/mod/wiki/locallib.php:wiki_parser_link',
@@ -726,7 +726,7 @@ function wiki_user_can_view($subwiki) {
$wiki = wiki_get_wiki($subwiki->wikiid);
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
// Working depending on activity groupmode
switch (groups_get_activity_groupmode($cm)) {
@@ -818,7 +818,7 @@ function wiki_user_can_edit($subwiki) {
$wiki = wiki_get_wiki($subwiki->wikiid);
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
// Working depending on activity groupmode
switch (groups_get_activity_groupmode($cm)) {
@@ -1232,7 +1232,7 @@ function wiki_delete_comments_wiki() {
global $PAGE, $DB;
$cm = $PAGE->cm;
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$table = 'comments';
$select = 'contextid = ?';
@@ -1345,7 +1345,7 @@ function wiki_print_edit_form_default_fields($format, $pageid, $version = -1, $u
echo $OUTPUT->container_end();
$cm = $PAGE->cm;
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
echo $OUTPUT->container_start('mdl-align wiki-form-center wiki-upload-table');
wiki_print_upload_table($context, 'wiki_upload', $pageid, $deleteuploads);
View
2  mod/wiki/lock.php
@@ -68,7 +68,7 @@
require_login($course, false, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_capability('mod/wiki:editpage', $context);
$wikipage = new page_wiki_lock($wiki, $subwiki, $cm);
View
2  mod/wiki/map.php
@@ -54,7 +54,7 @@
}
require_login($course, true, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_capability('mod/wiki:viewpage', $context);
$wikipage = new page_wiki_map($wiki, $subwiki, $cm);
View
2  mod/wiki/overridelocks.php
@@ -64,7 +64,7 @@
require_login($course, true, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_capability('mod/wiki:overridelock', $context);
if (!confirm_sesskey()) {
View
6 mod/wiki/pagelib.php
@@ -97,7 +97,7 @@
function __construct($wiki, $subwiki, $cm) {
global $PAGE, $CFG;
$this->subwiki = $subwiki;
- $this->modcontext = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id);
+ $this->modcontext = context_module::instance($PAGE->cm->id);
// initialise wiki renderer
$this->wikioutput = $PAGE->get_renderer('mod_wiki');
@@ -638,7 +638,7 @@ function print_content() {
$user = wiki_get_user_info($comment->userid);
- $fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
+ $fullname = fullname($user, has_capability('moodle/site:viewfullnames', context_course::instance($course->id)));
$by = new stdclass();
$by->name = '<a href="' . $CFG->wwwroot . '/user/view.php?id=' . $user->id . '&amp;course=' . $course->id . '">' . $fullname . '</a>';
$by->date = userdate($comment->timecreated);
@@ -1995,7 +1995,7 @@ function print_header() {
function print_content() {
global $PAGE;
- $context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id);
+ $context = context_module::instance($PAGE->cm->id);
require_capability('mod/wiki:editpage', $context, NULL, true, 'noeditpermission', 'wiki');
$this->print_save();
View
2  mod/wiki/prettyview.php
@@ -53,7 +53,7 @@
require_login($course, true, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_capability('mod/wiki:viewpage', $context);
$wikipage = new page_wiki_prettyview($wiki, $subwiki, $cm);
View
6 mod/wiki/renderer.php
@@ -55,7 +55,7 @@ public function page_index() {
public function search_result($records, $subwiki) {
global $CFG, $PAGE;
$table = new html_table();
- $context = get_context_instance(CONTEXT_MODULE, $PAGE->cm->id);
+ $context = context_module::instance($PAGE->cm->id);
$strsearchresults = get_string('searchresult', 'wiki');
$totalcount = count($records);
$html = $this->output->heading("$strsearchresults $totalcount");
@@ -243,7 +243,7 @@ public function tabs($page, $tabitems, $options) {
global $CFG;
$tabs = array();
$baseurl = $CFG->wwwroot . '/mod/wiki/';
- $context = get_context_instance(CONTEXT_MODULE, $this->page->cm->id);
+ $context = context_module::instance($this->page->cm->id);
$pageid = null;
if (!empty($page)) {
@@ -315,7 +315,7 @@ public function wiki_print_subwiki_selector($wiki, $subwiki, $page, $pagetype =
}
$cm = get_coursemodule_from_instance('wiki', $wiki->id);
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
// @TODO: A plenty of duplicated code below this lines.
// Create private functions.
switch (groups_get_activity_groupmode($cm)) {
View
4 mod/wiki/view.php
@@ -187,7 +187,7 @@
// Getting subwiki instance. If it does not exists, redirect to create page
if (!$subwiki = wiki_get_subwiki_by_group($wiki->id, $gid, $uid)) {
- $context = get_context_instance(CONTEXT_MODULE, $cm->id);
+ $context = context_module::instance($cm->id);
$modeanduser = $wiki->wikimode == 'individual' && $uid != $USER->id;
$modeandgroupmember = $wiki->wikimode == 'collaborative' && !groups_is_member($gid);
@@ -269,7 +269,7 @@
}
require_login($course, true, $cm);
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
+$context = context_module::instance($cm->id);
require_capability('mod/wiki:viewpage', $context);
// Update 'viewed' state if required by completion system
Please sign in to comment.
Something went wrong with that request. Please try again.