original_string: public function course_enrolments($courseid, $roles=null) {
          global $DB, $CFG;
  
          if (!$client = get_mnet_remote_client()) {
              die('Callable via XML-RPC only');
          }
  
          $sql = "SELECT u.username, r.shortname, r.name, e.enrol, ue.timemodified
                    FROM {user_enrolments} ue
                    JOIN {user} u ON ue.userid = u.id
                    JOIN {enrol} e ON ue.enrolid = e.id
                    JOIN {role} r ON e.roleid = r.id
                   WHERE u.mnethostid = :mnethostid
                         AND e.courseid = :courseid
                         AND u.id <> :guestid
                         AND u.confirmed = 1
                         AND u.deleted = 0";
          $params['mnethostid'] = $client->id;
          $params['courseid'] = $courseid;
          $params['guestid'] = $CFG->siteguest;
  
          if (!is_null($roles)) {
              if (!is_array($roles)) {
                  $roles = explode(',', $roles);
              }
              $roles = array_map('trim', $roles);
              list($rsql, $rparams) = $DB->get_in_or_equal($roles, SQL_PARAMS_NAMED);
              $sql .= " AND r.shortname $rsql";
              $params = array_merge($params, $rparams);
          }
  
          list($sort, $sortparams) = users_order_by_sql('u');
          $sql .= " ORDER BY $sort";
  
          $rs = $DB->get_recordset_sql($sql, array_merge($params, $sortparams));
          $list = array();
          foreach ($rs as $record) {
              $list[] = $record;
          }
          $rs->close();
  
          return $list;
      }
code: public function course_enrolments($courseid, $roles=null) {
          global $DB, $CFG;
  
          if (!$client = get_mnet_remote_client()) {
              die('Callable via XML-RPC only');
          }
  
          $sql = "SELECT u.username, r.shortname, r.name, e.enrol, ue.timemodified
                    FROM {user_enrolments} ue
                    JOIN {user} u ON ue.userid = u.id
                    JOIN {enrol} e ON ue.enrolid = e.id
                    JOIN {role} r ON e.roleid = r.id
                   WHERE u.mnethostid = :mnethostid
                         AND e.courseid = :courseid
                         AND u.id <> :guestid
                         AND u.confirmed = 1
                         AND u.deleted = 0";
          $params['mnethostid'] = $client->id;
          $params['courseid'] = $courseid;
          $params['guestid'] = $CFG->siteguest;
  
          if (!is_null($roles)) {
              if (!is_array($roles)) {
                  $roles = explode(',', $roles);
              }
              $roles = array_map('trim', $roles);
              list($rsql, $rparams) = $DB->get_in_or_equal($roles, SQL_PARAMS_NAMED);
              $sql .= " AND r.shortname $rsql";
              $params = array_merge($params, $rparams);
          }
  
          list($sort, $sortparams) = users_order_by_sql('u');
          $sql .= " ORDER BY $sort";
  
          $rs = $DB->get_recordset_sql($sql, array_merge($params, $sortparams));
          $list = array();
          foreach ($rs as $record) {
              $list[] = $record;
          }
          $rs->close();
  
          return $list;
      }
code_tokens: public function course_enrolments ( $ courseid , $ roles = null ) { global $ DB , $ CFG ; if ( ! $ client = get_mnet_remote_client ( ) ) { die ( 'Callable via XML-RPC only' ) ; } $ sql = "SELECT u.username, r.shortname, r.name, e.enrol, ue.timemodified
                    FROM {user_enrolments} ue
                    JOIN {user} u ON ue.userid = u.id
                    JOIN {enrol} e ON ue.enrolid = e.id
                    JOIN {role} r ON e.roleid = r.id
                   WHERE u.mnethostid = :mnethostid
                         AND e.courseid = :courseid
                         AND u.id <> :guestid
                         AND u.confirmed = 1
                         AND u.deleted = 0" ; $ params [ 'mnethostid' ] = $ client -> id ; $ params [ 'courseid' ] = $ courseid ; $ params [ 'guestid' ] = $ CFG -> siteguest ; if ( ! is_null ( $ roles ) ) { if ( ! is_array ( $ roles ) ) { $ roles = explode ( ',' , $ roles ) ; } $ roles = array_map ( 'trim' , $ roles ) ; list ( $ rsql , $ rparams ) = $ DB -> get_in_or_equal ( $ roles , SQL_PARAMS_NAMED ) ; $ sql .= " AND r.shortname $rsql" ; $ params = array_merge ( $ params , $ rparams ) ; } list ( $ sort , $ sortparams ) = users_order_by_sql ( 'u' ) ; $ sql .= " ORDER BY $sort" ; $ rs = $ DB -> get_recordset_sql ( $ sql , array_merge ( $ params , $ sortparams ) ) ; $ list = array ( ) ; foreach ( $ rs as $ record ) { $ list [ ] = $ record ; } $ rs -> close ( ) ; return $ list ; }
docstring: Returns a list of users from the client server who are enrolled in our course
  
  Suitable instance of enrol_mnet must be created in the course. This method will not
  return any information about the enrolments in courses that are not available for
  remote enrolment, even if their users are enrolled into them via other plugin
  (note the difference from {@link self::user_enrolments()}).
  
  This method will return enrolment information for users from hosts regardless
  the enrolment plugin. It does not matter if the user was enrolled remotely by
  their admin or locally. Once the course is available for remote enrolments, we
  will tell them everything about their users.
  
  In Moodle 1.x the returned array used to be indexed by username. The side effect
  of MDL-19219 fix is that we do not need to use such index and therefore we can
  return all enrolment records. MNet clients 1.x will only use the last record for
  the student, if she is enrolled via multiple plugins.
  
  @uses mnet_remote_client Callable via XML-RPC only
  @param int $courseid ID of our course
  @param string|array $roles comma separated list of role shortnames (or array of them)
  @return array
docstring_tokens: Returns a list of users from the client server who are enrolled in our course