Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-34467 lti: Repalce all instances of get_context_instanc() with re…

…spective context_XXX::instance()
  • Loading branch information...
commit c288a3dbf8a4254ab798836ab3fe9448c9fc4c6c 1 parent 5918e37
Ankit Agarwal authored July 27, 2012
2  mod/lti/grade.php
@@ -68,7 +68,7 @@
68 68
 $course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
69 69
 
70 70
 require_login($course, false, $cm);
71  
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
  71
+$context = context_module::instance($cm->id);
72 72
 require_capability('mod/lti:grade', $context);
73 73
 
74 74
 $url = new moodle_url('/mod/lti/grade.php', array('id' => $cm->id));
2  mod/lti/instructor_edit_tool_type.php
@@ -37,7 +37,7 @@
37 37
 $action = optional_param('action', null, PARAM_TEXT);
38 38
 $typeid = optional_param('typeid', null, PARAM_INT);
39 39
 
40  
-require_capability('mod/lti:addcoursetool', get_context_instance(CONTEXT_COURSE, $courseid));
  40
+require_capability('mod/lti:addcoursetool', context_course::instance($courseid));
41 41
 
42 42
 if (!empty($typeid)) {
43 43
     $type = lti_get_type($typeid);
2  mod/lti/lib.php
@@ -395,7 +395,7 @@ function lti_grade_item_delete($basiclti) {
395 395
 function lti_extend_settings_navigation($settings, $parentnode) {
396 396
     global $PAGE;
397 397
 
398  
-    if (has_capability('mod/lti:grade', get_context_instance(CONTEXT_MODULE, $PAGE->cm->id))) {
  398
+    if (has_capability('mod/lti:grade', context_module::instance($PAGE->cm->id))) {
399 399
         $keys = $parentnode->get_children_key_list();
400 400
 
401 401
         $node = navigation_node::create('Submissions',
4  mod/lti/locallib.php
@@ -462,7 +462,7 @@ function lti_get_ims_role($user, $cmid, $courseid) {
462 462
         //If no cmid is passed, check if the user is a teacher in the course
463 463
         //This allows other modules to programmatically "fake" a launch without
464 464
         //a real LTI instance
465  
-        $coursecontext = get_context_instance(CONTEXT_COURSE, $courseid);
  465
+        $coursecontext = context_course::instance($courseid);
466 466
 
467 467
         if (has_capability('moodle/course:manageactivities', $coursecontext)) {
468 468
             array_push($roles, 'Instructor');
@@ -470,7 +470,7 @@ function lti_get_ims_role($user, $cmid, $courseid) {
470 470
             array_push($roles, 'Learner');
471 471
         }
472 472
     } else {
473  
-        $context = get_context_instance(CONTEXT_MODULE, $cmid);
  473
+        $context = context_module::instance($cmid);
474 474
 
475 475
         if (has_capability('mod/lti:manage', $context)) {
476 476
             array_push($roles, 'Instructor');
2  mod/lti/request_tool.php
@@ -35,7 +35,7 @@
35 35
 
36 36
 require_login($course);
37 37
 
38  
-require_capability('mod/lti:requesttooladd', get_context_instance(CONTEXT_COURSE, $lti->course));
  38
+require_capability('mod/lti:requesttooladd', context_course::instance($lti->course));
39 39
 
40 40
 $baseurl = lti_get_domain_from_url($lti->toolurl);
41 41
 
2  mod/lti/return.php
@@ -61,7 +61,7 @@
61 61
 
62 62
     echo htmlspecialchars($errormsg);
63 63
 
64  
-    $canaddtools = has_capability('mod/lti:addcoursetool', get_context_instance(CONTEXT_COURSE, $courseid));
  64
+    $canaddtools = has_capability('mod/lti:addcoursetool', context_course::instance($courseid));
65 65
 
66 66
     if ($unsigned == 1 && $canaddtools) {
67 67
         echo '<br /><br />';
2  mod/lti/service.php
@@ -98,7 +98,7 @@
98 98
         $ltiinstance = $DB->get_record('lti', array('id' => $parsed->instanceid));
99 99
 
100 100
         //Getting the grade requires the context is set
101  
-        $context = get_context_instance(CONTEXT_COURSE, $ltiinstance->course);
  101
+        $context = context_course::instance($ltiinstance->course);
102 102
         $PAGE->set_context($context);
103 103
 
104 104
         lti_verify_sourcedid($ltiinstance, $parsed);
2  mod/lti/view.php
@@ -73,7 +73,7 @@
73 73
 }
74 74
 
75 75
 $PAGE->set_cm($cm, $course); // set's up global $COURSE
76  
-$context = get_context_instance(CONTEXT_MODULE, $cm->id);
  76
+$context = context_module::instance($cm->id);
77 77
 $PAGE->set_context($context);
78 78
 
79 79
 $url = new moodle_url('/mod/lti/view.php', array('id'=>$cm->id));

0 notes on commit c288a3d

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