Merge branch 'MDL-59490' of https://github.com/spvickers/moodle
authorAndrew Nicols <andrew@nicols.co.uk>
Mon, 24 Jul 2017 04:42:34 +0000 (12:42 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Mon, 24 Jul 2017 04:42:34 +0000 (12:42 +0800)
1  2 
mod/lti/locallib.php

diff --combined mod/lti/locallib.php
@@@ -386,11 -386,11 +386,11 @@@ function lti_build_request($instance, $
          'lis_person_sourcedid' => $USER->idnumber,
          'roles' => $role,
          'context_id' => $course->id,
-         'context_label' => trim(html_to_text($course->shortname)),
-         'context_title' => trim(html_to_text($course->fullname)),
+         'context_label' => trim(html_to_text($course->shortname, 0)),
+         'context_title' => trim(html_to_text($course->fullname, 0)),
      );
      if (!empty($instance->name)) {
-         $requestparams['resource_link_title'] = trim(html_to_text($instance->name));
+         $requestparams['resource_link_title'] = trim(html_to_text($instance->name, 0));
      }
      if (!empty($instance->cmid)) {
          $intro = format_module_intro('lti', $instance, $instance->cmid);
@@@ -531,11 -531,11 +531,11 @@@ function lti_build_standard_request($in
          $requestparams["tool_consumer_instance_guid"] = $orgid;
      }
      if (!empty($CFG->mod_lti_institution_name)) {
-         $requestparams['tool_consumer_instance_name'] = trim(html_to_text($CFG->mod_lti_institution_name));
+         $requestparams['tool_consumer_instance_name'] = trim(html_to_text($CFG->mod_lti_institution_name, 0));
      } else {
          $requestparams['tool_consumer_instance_name'] = get_site()->shortname;
      }
-     $requestparams['tool_consumer_instance_description'] = trim(html_to_text(get_site()->fullname));
+     $requestparams['tool_consumer_instance_description'] = trim(html_to_text(get_site()->fullname, 0));
  
      return $requestparams;
  }
@@@ -1302,9 -1302,9 +1302,9 @@@ function lti_get_ims_role($user, $cmid
          // If no cmid is passed, check if the user is a teacher in the course
          // This allows other modules to programmatically "fake" a launch without
          // a real LTI instance.
 -        $coursecontext = context_course::instance($courseid);
 +        $context = context_course::instance($courseid);
  
 -        if (has_capability('moodle/course:manageactivities', $coursecontext, $user)) {
 +        if (has_capability('moodle/course:manageactivities', $context, $user)) {
              array_push($roles, 'Instructor');
          } else {
              array_push($roles, 'Learner');
          }
      }
  
 -    if (is_siteadmin($user)) {
 +    if (is_siteadmin($user) || has_capability('mod/lti:admin', $context)) {
 +        // Make sure admins do not have the Learner role, then set admin role.
 +        $roles = array_diff($roles, array('Learner'));
          if (!$islti2) {
              array_push($roles, 'urn:lti:sysrole:ims/lis/Administrator', 'urn:lti:instrole:ims/lis/Administrator');
          } else {