original_string: protected function load_user_settings($courseid = SITEID) {
          global $USER, $CFG;
  
          if (isguestuser() || !isloggedin()) {
              return false;
          }
  
          $navusers = $this->page->navigation->get_extending_users();
  
          if (count($this->userstoextendfor) > 0 || count($navusers) > 0) {
              $usernode = null;
              foreach ($this->userstoextendfor as $userid) {
                  if ($userid == $USER->id) {
                      continue;
                  }
                  $node = $this->generate_user_settings($courseid, $userid, 'userviewingsettings');
                  if (is_null($usernode)) {
                      $usernode = $node;
                  }
              }
              foreach ($navusers as $user) {
                  if ($user->id == $USER->id) {
                      continue;
                  }
                  $node = $this->generate_user_settings($courseid, $user->id, 'userviewingsettings');
                  if (is_null($usernode)) {
                      $usernode = $node;
                  }
              }
              $this->generate_user_settings($courseid, $USER->id);
          } else {
              $usernode = $this->generate_user_settings($courseid, $USER->id);
          }
          return $usernode;
      }
code: protected function load_user_settings($courseid = SITEID) {
          global $USER, $CFG;
  
          if (isguestuser() || !isloggedin()) {
              return false;
          }
  
          $navusers = $this->page->navigation->get_extending_users();
  
          if (count($this->userstoextendfor) > 0 || count($navusers) > 0) {
              $usernode = null;
              foreach ($this->userstoextendfor as $userid) {
                  if ($userid == $USER->id) {
                      continue;
                  }
                  $node = $this->generate_user_settings($courseid, $userid, 'userviewingsettings');
                  if (is_null($usernode)) {
                      $usernode = $node;
                  }
              }
              foreach ($navusers as $user) {
                  if ($user->id == $USER->id) {
                      continue;
                  }
                  $node = $this->generate_user_settings($courseid, $user->id, 'userviewingsettings');
                  if (is_null($usernode)) {
                      $usernode = $node;
                  }
              }
              $this->generate_user_settings($courseid, $USER->id);
          } else {
              $usernode = $this->generate_user_settings($courseid, $USER->id);
          }
          return $usernode;
      }
code_tokens: protected function load_user_settings ( $ courseid = SITEID ) { global $ USER , $ CFG ; if ( isguestuser ( ) || ! isloggedin ( ) ) { return false ; } $ navusers = $ this -> page -> navigation -> get_extending_users ( ) ; if ( count ( $ this -> userstoextendfor ) > 0 || count ( $ navusers ) > 0 ) { $ usernode = null ; foreach ( $ this -> userstoextendfor as $ userid ) { if ( $ userid == $ USER -> id ) { continue ; } $ node = $ this -> generate_user_settings ( $ courseid , $ userid , 'userviewingsettings' ) ; if ( is_null ( $ usernode ) ) { $ usernode = $ node ; } } foreach ( $ navusers as $ user ) { if ( $ user -> id == $ USER -> id ) { continue ; } $ node = $ this -> generate_user_settings ( $ courseid , $ user -> id , 'userviewingsettings' ) ; if ( is_null ( $ usernode ) ) { $ usernode = $ node ; } } $ this -> generate_user_settings ( $ courseid , $ USER -> id ) ; } else { $ usernode = $ this -> generate_user_settings ( $ courseid , $ USER -> id ) ; } return $ usernode ; }
docstring: Loads the user settings block of the settings nav
  
  This function is simply works out the userid and whether we need to load
  just the current users profile settings, or the current user and the user the
  current user is viewing.
  
  This function has some very ugly code to work out the user, if anyone has
  any bright ideas please feel free to intervene.
  
  @param int $courseid The course id of the current course
  @return navigation_node|false
docstring_tokens: Loads the user settings block of the settings nav