original_string: public function get_user_summaries($courseid) {
          global $DB;
  
          $usersummaries = array();
  
          // Get other groups user already belongs to.
          $usergroups = array();
          $potentialmembersids = $this->potentialmembersids;
          if (empty($potentialmembersids) == false) {
              list($membersidsclause, $params) = $DB->get_in_or_equal($potentialmembersids, SQL_PARAMS_NAMED, 'pm');
              $sql = "SELECT u.id AS userid, g.*
                      FROM {user} u
                      JOIN {groups_members} gm ON u.id = gm.userid
                      JOIN {groups} g ON gm.groupid = g.id
                      WHERE u.id $membersidsclause AND g.courseid = :courseid ";
              $params['courseid'] = $courseid;
              $rs = $DB->get_recordset_sql($sql, $params);
              foreach ($rs as $usergroup) {
                  $usergroups[$usergroup->userid][$usergroup->id] = $usergroup;
              }
              $rs->close();
  
              foreach ($potentialmembersids as $userid) {
                  if (isset($usergroups[$userid])) {
                      $usergrouplist = html_writer::start_tag('ul');
                      foreach ($usergroups[$userid] as $groupitem) {
                          $usergrouplist .= html_writer::tag('li', format_string($groupitem->name));
                      }
                      $usergrouplist .= html_writer::end_tag('ul');
                  } else {
                      $usergrouplist = '';
                  }
                  $usersummaries[] = $usergrouplist;
              }
          }
          return $usersummaries;
      }
code: public function get_user_summaries($courseid) {
          global $DB;
  
          $usersummaries = array();
  
          // Get other groups user already belongs to.
          $usergroups = array();
          $potentialmembersids = $this->potentialmembersids;
          if (empty($potentialmembersids) == false) {
              list($membersidsclause, $params) = $DB->get_in_or_equal($potentialmembersids, SQL_PARAMS_NAMED, 'pm');
              $sql = "SELECT u.id AS userid, g.*
                      FROM {user} u
                      JOIN {groups_members} gm ON u.id = gm.userid
                      JOIN {groups} g ON gm.groupid = g.id
                      WHERE u.id $membersidsclause AND g.courseid = :courseid ";
              $params['courseid'] = $courseid;
              $rs = $DB->get_recordset_sql($sql, $params);
              foreach ($rs as $usergroup) {
                  $usergroups[$usergroup->userid][$usergroup->id] = $usergroup;
              }
              $rs->close();
  
              foreach ($potentialmembersids as $userid) {
                  if (isset($usergroups[$userid])) {
                      $usergrouplist = html_writer::start_tag('ul');
                      foreach ($usergroups[$userid] as $groupitem) {
                          $usergrouplist .= html_writer::tag('li', format_string($groupitem->name));
                      }
                      $usergrouplist .= html_writer::end_tag('ul');
                  } else {
                      $usergrouplist = '';
                  }
                  $usersummaries[] = $usergrouplist;
              }
          }
          return $usersummaries;
      }
code_tokens: public function get_user_summaries ( $ courseid ) { global $ DB ; $ usersummaries = array ( ) ; // Get other groups user already belongs to. $ usergroups = array ( ) ; $ potentialmembersids = $ this -> potentialmembersids ; if ( empty ( $ potentialmembersids ) == false ) { list ( $ membersidsclause , $ params ) = $ DB -> get_in_or_equal ( $ potentialmembersids , SQL_PARAMS_NAMED , 'pm' ) ; $ sql = "SELECT u.id AS userid, g.*
                      FROM {user} u
                      JOIN {groups_members} gm ON u.id = gm.userid
                      JOIN {groups} g ON gm.groupid = g.id
                      WHERE u.id $membersidsclause AND g.courseid = :courseid " ; $ params [ 'courseid' ] = $ courseid ; $ rs = $ DB -> get_recordset_sql ( $ sql , $ params ) ; foreach ( $ rs as $ usergroup ) { $ usergroups [ $ usergroup -> userid ] [ $ usergroup -> id ] = $ usergroup ; } $ rs -> close ( ) ; foreach ( $ potentialmembersids as $ userid ) { if ( isset ( $ usergroups [ $ userid ] ) ) { $ usergrouplist = html_writer :: start_tag ( 'ul' ) ; foreach ( $ usergroups [ $ userid ] as $ groupitem ) { $ usergrouplist .= html_writer :: tag ( 'li' , format_string ( $ groupitem -> name ) ) ; } $ usergrouplist .= html_writer :: end_tag ( 'ul' ) ; } else { $ usergrouplist = '' ; } $ usersummaries [ ] = $ usergrouplist ; } } return $ usersummaries ; }
docstring: Construct HTML lists of group-memberships of the current set of users.
  
  Used in user/selector/search.php to repopulate the userSummaries JS global
  that is created in self::print_user_summaries() above.
  
  @param int $courseid The course
  @return string[] Array of HTML lists of groups.
docstring_tokens: Construct HTML lists of group - memberships of the current set of users .