original_string: protected static function determine_group_and_user($cm, $wiki, $groupid = -1, $userid = 0) {
          global $USER;
  
          $currentgroup = groups_get_activity_group($cm);
          if ($currentgroup === false) {
              // Activity doesn't use groups.
              $groupid = 0;
          } else if ($groupid == -1) {
              // Use current group.
              $groupid = !empty($currentgroup) ? $currentgroup : 0;
          }
  
          // Determine user.
          if ($wiki->wikimode == 'collaborative') {
              // Collaborative wikis don't use userid in subwikis.
              $userid = 0;
          } else if (empty($userid)) {
              // Use current user.
              $userid = $USER->id;
          }
  
          return array($groupid, $userid);
      }
code: protected static function determine_group_and_user($cm, $wiki, $groupid = -1, $userid = 0) {
          global $USER;
  
          $currentgroup = groups_get_activity_group($cm);
          if ($currentgroup === false) {
              // Activity doesn't use groups.
              $groupid = 0;
          } else if ($groupid == -1) {
              // Use current group.
              $groupid = !empty($currentgroup) ? $currentgroup : 0;
          }
  
          // Determine user.
          if ($wiki->wikimode == 'collaborative') {
              // Collaborative wikis don't use userid in subwikis.
              $userid = 0;
          } else if (empty($userid)) {
              // Use current user.
              $userid = $USER->id;
          }
  
          return array($groupid, $userid);
      }
code_tokens: protected static function determine_group_and_user ( $ cm , $ wiki , $ groupid = - 1 , $ userid = 0 ) { global $ USER ; $ currentgroup = groups_get_activity_group ( $ cm ) ; if ( $ currentgroup === false ) { // Activity doesn't use groups. $ groupid = 0 ; } else if ( $ groupid == - 1 ) { // Use current group. $ groupid = ! empty ( $ currentgroup ) ? $ currentgroup : 0 ; } // Determine user. if ( $ wiki -> wikimode == 'collaborative' ) { // Collaborative wikis don't use userid in subwikis. $ userid = 0 ; } else if ( empty ( $ userid ) ) { // Use current user. $ userid = $ USER -> id ; } return array ( $ groupid , $ userid ) ; }
docstring: Utility function for determining the groupid and userid to use.
  
  @param stdClass $cm The course module.
  @param stdClass $wiki The wiki.
  @param int $groupid Group ID. If not defined, use current group.
  @param int $userid User ID. If not defined, use current user.
  @return array Array containing the courseid and userid.
  @since  Moodle 3.1
docstring_tokens: Utility function for determining the groupid and userid to use .