original_string: public function is_visible() {
          global $USER;
  
          $context = ($this->userid > 0) ? context_user::instance($this->userid) : context_system::instance();
  
          switch ($this->field->visible) {
              case PROFILE_VISIBLE_ALL:
                  return true;
              case PROFILE_VISIBLE_PRIVATE:
                  if ($this->is_signup_field() && (empty($this->userid) || isguestuser($this->userid))) {
                      return true;
                  } else if ($this->userid == $USER->id) {
                      return true;
                  } else {
                      return has_capability('moodle/user:viewalldetails', $context);
                  }
              default:
                  return has_capability('moodle/user:viewalldetails', $context);
          }
      }
code: public function is_visible() {
          global $USER;
  
          $context = ($this->userid > 0) ? context_user::instance($this->userid) : context_system::instance();
  
          switch ($this->field->visible) {
              case PROFILE_VISIBLE_ALL:
                  return true;
              case PROFILE_VISIBLE_PRIVATE:
                  if ($this->is_signup_field() && (empty($this->userid) || isguestuser($this->userid))) {
                      return true;
                  } else if ($this->userid == $USER->id) {
                      return true;
                  } else {
                      return has_capability('moodle/user:viewalldetails', $context);
                  }
              default:
                  return has_capability('moodle/user:viewalldetails', $context);
          }
      }
code_tokens: public function is_visible ( ) { global $ USER ; $ context = ( $ this -> userid > 0 ) ? context_user :: instance ( $ this -> userid ) : context_system :: instance ( ) ; switch ( $ this -> field -> visible ) { case PROFILE_VISIBLE_ALL : return true ; case PROFILE_VISIBLE_PRIVATE : if ( $ this -> is_signup_field ( ) && ( empty ( $ this -> userid ) || isguestuser ( $ this -> userid ) ) ) { return true ; } else if ( $ this -> userid == $ USER -> id ) { return true ; } else { return has_capability ( 'moodle/user:viewalldetails' , $ context ) ; } default : return has_capability ( 'moodle/user:viewalldetails' , $ context ) ; } }
docstring: Check if the field data is visible to the current user
  @internal This method should not generally be overwritten by child classes.
  @return bool
docstring_tokens: Check if the field data is visible to the current user