Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Updates to get the plugin to work side-by-side with the basicLTI plugin

  • Loading branch information...
commit 795dff011f8a671375742df1bbd009be6043d0b8 1 parent 7023b65
scriby authored
6  mod/lti/OAuth.php
@@ -54,13 +54,15 @@
54 54
 // You should have received a copy of the GNU General Public License
55 55
 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
56 56
 
  57
+namespace moodle\mod\lti;//Using a namespace as the basicLTI module imports classes with the same names
  58
+
57 59
 defined('MOODLE_INTERNAL') || die;
58 60
 
59 61
 $oauth_last_computed_signature = false;
60 62
 
61 63
 /* Generic exception class
62 64
  */
63  
-class OAuthException extends Exception {
  65
+class OAuthException extends \Exception {
64 66
     // pass
65 67
 }
66 68
 
@@ -704,7 +706,7 @@ class OAuthUtil {
704 706
     public static function urlencode_rfc3986($input) {
705 707
         if (is_array($input)) {
706 708
             return array_map(array(
707  
-                'OAuthUtil',
  709
+                'moodle\mod\lti\OAuthUtil',
708 710
                 'urlencode_rfc3986'
709 711
             ), $input);
710 712
         } else {
2  mod/lti/OAuthBody.php
@@ -54,6 +54,8 @@
54 54
 // You should have received a copy of the GNU General Public License
55 55
 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
56 56
 
  57
+namespace moodle\mod\lti;//Using a namespace as the basicLTI module imports classes with the same names
  58
+
57 59
 require_once($CFG->dirroot . '/mod/lti/OAuth.php');
58 60
 require_once($CFG->dirroot . '/mod/lti/TrivialStore.php');
59 61
 
2  mod/lti/TrivialStore.php
@@ -58,6 +58,8 @@
58 58
  * @license http://www.apache.org/licenses/LICENSE-2.0
59 59
  */
60 60
 
  61
+namespace moodle\mod\lti;//Using a namespace as the basicLTI module imports classes with the same names
  62
+
61 63
 defined('MOODLE_INTERNAL') || die;
62 64
 
63 65
 /**
89  mod/lti/locallib.php
@@ -47,6 +47,8 @@
47 47
 
48 48
 defined('MOODLE_INTERNAL') || die;
49 49
 
  50
+use moodle\mod\lti as lti;
  51
+
50 52
 require_once($CFG->dirroot.'/mod/lti/OAuth.php');
51 53
 
52 54
 define('LTI_URL_DOMAIN_REGEX', '/(?:https?:\/\/)?(?:www\.)?([^\/]+)(?:\/|$)/i');
@@ -240,6 +242,87 @@ function lti_build_request($instance, $typeconfig, $course) {
240 242
     return $requestparams;
241 243
 }
242 244
 
  245
+function lti_get_tool_table($tools, $id){
  246
+    global $CFG, $USER;
  247
+    $html = '';
  248
+    
  249
+    $typename = get_string('typename', 'lti');
  250
+    $baseurl = get_string('baseurl', 'lti');
  251
+    $action = get_string('action', 'lti');
  252
+    $createdon = get_string('createdon', 'lti');
  253
+    
  254
+    if($id == 'lti_configured'){
  255
+        $html .= '<div><a style="margin-top:.25em" href="'.$CFG->wwwroot.'/mod/lti/typessettings.php?action=add&amp;sesskey='.$USER->sesskey.'">'.get_string('addtype', 'lti').'</a></div>';
  256
+    }
  257
+    
  258
+    if (!empty($tools)) {
  259
+        $html .= <<<HTML
  260
+        <div id="{$id}_container" style="margin-top:.5em;margin-bottom:.5em">
  261
+            <table id="{$id}_tools">
  262
+                <thead>
  263
+                    <tr>
  264
+                        <th>$typename</th>
  265
+                        <th>$baseurl</th>
  266
+                        <th>$createdon</th>
  267
+                        <th>$action</th>
  268
+                    </tr>
  269
+                </thead>
  270
+HTML;
  271
+        
  272
+        foreach ($tools as $type) {
  273
+            $date = userdate($type->timecreated);
  274
+            $accept = get_string('accept', 'lti');
  275
+            $update = get_string('update', 'lti');
  276
+            $delete = get_string('delete', 'lti');
  277
+            
  278
+            $accepthtml = <<<HTML
  279
+                <a class="editing_accept" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=accept&amp;id={$type->id}&amp;sesskey={$USER->sesskey}&amp;tab={$id}" title="{$accept}">
  280
+                    <img class="iconsmall" alt="{$accept}" src="{$CFG->wwwroot}/pix/t/clear.gif"/>
  281
+                </a>
  282
+HTML;
  283
+
  284
+            $deleteaction = 'delete';
  285
+                    
  286
+            if($type->state == LTI_TOOL_STATE_CONFIGURED){
  287
+                $accepthtml = '';
  288
+            }
  289
+            
  290
+            if($type->state != LTI_TOOL_STATE_REJECTED) {
  291
+                $deleteaction = 'reject';
  292
+                $delete = get_string('reject', 'lti');
  293
+            }
  294
+                    
  295
+            $html .= <<<HTML
  296
+            <tr>
  297
+                <td>
  298
+                    {$type->name}
  299
+                </td>
  300
+                <td>
  301
+                    {$type->baseurl}
  302
+                </td>
  303
+                <td>
  304
+                    {$date}
  305
+                </td>
  306
+                <td align="center">
  307
+                    {$accepthtml}
  308
+                    <a class="editing_update" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=update&amp;id={$type->id}&amp;sesskey={$USER->sesskey}&amp;tab={$id}" title="{$update}">
  309
+                        <img class="iconsmall" alt="{$update}" src="{$CFG->wwwroot}/pix/t/edit.gif"/>
  310
+                    </a>
  311
+                    <a class="editing_delete" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action={$deleteaction}&amp;id={$type->id}&amp;sesskey={$USER->sesskey}&amp;tab={$id}" title="{$delete}">
  312
+                        <img class="iconsmall" alt="{$delete}" src="{$CFG->wwwroot}/pix/t/delete.gif"/>
  313
+                    </a>
  314
+                </td>
  315
+            </tr>
  316
+HTML;
  317
+        }
  318
+        $html .= '</table></div>';
  319
+    } else {
  320
+        $html .= get_string('no_' . $id, 'lti');
  321
+    }
  322
+    
  323
+    return $html;
  324
+}
  325
+
243 326
 /**
244 327
  * Splits the custom parameters field to the various parameters
245 328
  *
@@ -823,10 +906,10 @@ function lti_sign_parameters($oldparms, $endpoint, $method, $oauthconsumerkey, $
823 906
 
824 907
     $testtoken = '';
825 908
 
826  
-    $hmacmethod = new OAuthSignatureMethod_HMAC_SHA1();
827  
-    $testconsumer = new OAuthConsumer($oauthconsumerkey, $oauthconsumersecret, null);
  909
+    $hmacmethod = new lti\OAuthSignatureMethod_HMAC_SHA1();
  910
+    $testconsumer = new lti\OAuthConsumer($oauthconsumerkey, $oauthconsumersecret, null);
828 911
 
829  
-    $accreq = OAuthRequest::from_consumer_and_token($testconsumer, $testtoken, $method, $endpoint, $parms);
  912
+    $accreq = lti\OAuthRequest::from_consumer_and_token($testconsumer, $testtoken, $method, $endpoint, $parms);
830 913
     $accreq->sign_request($hmacmethod, $testconsumer, $testtoken);
831 914
 
832 915
     // Pass this back up "out of band" for debugging
4  mod/lti/servicelib.php
@@ -2,6 +2,8 @@
2 2
 
3 3
 require_once($CFG->dirroot.'/mod/lti/OAuthBody.php');
4 4
 
  5
+use moodle\mod\lti as lti;
  6
+
5 7
 define('LTI_ITEM_TYPE', 'mod');
6 8
 define('LTI_ITEM_MODULE', 'lti');
7 9
 define('LTI_SOURCE', 'mod/lti');
@@ -150,7 +152,7 @@ function lti_verify_message($ltiinstance, $body, $headers = null){
150 152
         $secret = $ltiinstance->password;
151 153
     }
152 154
     
153  
-    handleOAuthBodyPOST($key, $secret, $body, $headers);
  155
+    lti\handleOAuthBodyPOST($key, $secret, $body, $headers);
154 156
 }
155 157
 
156 158
 function lti_verify_sourcedid($ltiinstance, $parsed){
81  mod/lti/settings.php
@@ -51,87 +51,6 @@
51 51
 
52 52
 require_once($CFG->dirroot.'/mod/lti/locallib.php');
53 53
 
54  
-function lti_get_tool_table($tools, $id){
55  
-    global $CFG, $USER;
56  
-    $html = '';
57  
-    
58  
-    $typename = get_string('typename', 'lti');
59  
-    $baseurl = get_string('baseurl', 'lti');
60  
-    $action = get_string('action', 'lti');
61  
-    $createdon = get_string('createdon', 'lti');
62  
-    
63  
-    if($id == 'lti_configured'){
64  
-        $html .= '<div><a style="margin-top:.25em" href="'.$CFG->wwwroot.'/mod/lti/typessettings.php?action=add&amp;sesskey='.$USER->sesskey.'">'.get_string('addtype', 'lti').'</a></div>';
65  
-    }
66  
-    
67  
-    if (!empty($tools)) {
68  
-        $html .= <<<HTML
69  
-        <div id="{$id}_container" style="margin-top:.5em;margin-bottom:.5em">
70  
-            <table id="{$id}_tools">
71  
-                <thead>
72  
-                    <tr>
73  
-                        <th>$typename</th>
74  
-                        <th>$baseurl</th>
75  
-                        <th>$createdon</th>
76  
-                        <th>$action</th>
77  
-                    </tr>
78  
-                </thead>
79  
-HTML;
80  
-        
81  
-        foreach ($tools as $type) {
82  
-            $date = userdate($type->timecreated);
83  
-            $accept = get_string('accept', 'lti');
84  
-            $update = get_string('update', 'lti');
85  
-            $delete = get_string('delete', 'lti');
86  
-            
87  
-            $accepthtml = <<<HTML
88  
-                <a class="editing_accept" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=accept&amp;id={$type->id}&amp;sesskey={$USER->sesskey}&amp;tab={$id}" title="{$accept}">
89  
-                    <img class="iconsmall" alt="{$accept}" src="{$CFG->wwwroot}/pix/t/clear.gif"/>
90  
-                </a>
91  
-HTML;
92  
-
93  
-            $deleteaction = 'delete';
94  
-                    
95  
-            if($type->state == LTI_TOOL_STATE_CONFIGURED){
96  
-                $accepthtml = '';
97  
-            }
98  
-            
99  
-            if($type->state != LTI_TOOL_STATE_REJECTED) {
100  
-                $deleteaction = 'reject';
101  
-                $delete = get_string('reject', 'lti');
102  
-            }
103  
-                    
104  
-            $html .= <<<HTML
105  
-            <tr>
106  
-                <td>
107  
-                    {$type->name}
108  
-                </td>
109  
-                <td>
110  
-                    {$type->baseurl}
111  
-                </td>
112  
-                <td>
113  
-                    {$date}
114  
-                </td>
115  
-                <td align="center">
116  
-                    {$accepthtml}
117  
-                    <a class="editing_update" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action=update&amp;id={$type->id}&amp;sesskey={$USER->sesskey}&amp;tab={$id}" title="{$update}">
118  
-                        <img class="iconsmall" alt="{$update}" src="{$CFG->wwwroot}/pix/t/edit.gif"/>
119  
-                    </a>
120  
-                    <a class="editing_delete" href="{$CFG->wwwroot}/mod/lti/typessettings.php?action={$deleteaction}&amp;id={$type->id}&amp;sesskey={$USER->sesskey}&amp;tab={$id}" title="{$delete}">
121  
-                        <img class="iconsmall" alt="{$delete}" src="{$CFG->wwwroot}/pix/t/delete.gif"/>
122  
-                    </a>
123  
-                </td>
124  
-            </tr>
125  
-HTML;
126  
-        }
127  
-        $html .= '</table></div>';
128  
-    } else {
129  
-        $html .= get_string('no_' . $id, 'lti');
130  
-    }
131  
-    
132  
-    return $html;
133  
-}
134  
-
135 54
 if ($ADMIN->fulltree) {
136 55
     $configuredtoolshtml = '';
137 56
     $pendingtoolshtml = '';

0 notes on commit 795dff0

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