original_string: public function can_edit_post(stdClass $user, discussion_entity $discussion, post_entity $post) : bool {
          global $CFG;
  
          $context = $this->get_context();
          $ownpost = $post->is_owned_by_user($user);
          $ineditingtime = $post->get_age() < $CFG->maxeditingtime;
  
          switch ($this->forum->get_type()) {
              case 'news':
                  // Allow editing of news posts once the discussion has started.
                  $ineditingtime = !$post->has_parent() && $discussion->has_started();
                  break;
              case 'single':
                  return $discussion->is_first_post($post) && has_capability('moodle/course:manageactivities', $context, $user);
          }
  
          return ($ownpost && $ineditingtime) || has_capability('mod/forum:editanypost', $context, $user);
      }
code: public function can_edit_post(stdClass $user, discussion_entity $discussion, post_entity $post) : bool {
          global $CFG;
  
          $context = $this->get_context();
          $ownpost = $post->is_owned_by_user($user);
          $ineditingtime = $post->get_age() < $CFG->maxeditingtime;
  
          switch ($this->forum->get_type()) {
              case 'news':
                  // Allow editing of news posts once the discussion has started.
                  $ineditingtime = !$post->has_parent() && $discussion->has_started();
                  break;
              case 'single':
                  return $discussion->is_first_post($post) && has_capability('moodle/course:manageactivities', $context, $user);
          }
  
          return ($ownpost && $ineditingtime) || has_capability('mod/forum:editanypost', $context, $user);
      }
code_tokens: public function can_edit_post ( stdClass $ user , discussion_entity $ discussion , post_entity $ post ) : bool { global $ CFG ; $ context = $ this -> get_context ( ) ; $ ownpost = $ post -> is_owned_by_user ( $ user ) ; $ ineditingtime = $ post -> get_age ( ) < $ CFG -> maxeditingtime ; switch ( $ this -> forum -> get_type ( ) ) { case 'news' : // Allow editing of news posts once the discussion has started. $ ineditingtime = ! $ post -> has_parent ( ) && $ discussion -> has_started ( ) ; break ; case 'single' : return $ discussion -> is_first_post ( $ post ) && has_capability ( 'moodle/course:manageactivities' , $ context , $ user ) ; } return ( $ ownpost && $ ineditingtime ) || has_capability ( 'mod/forum:editanypost' , $ context , $ user ) ; }
docstring: Can the user edit the post in this discussion?
  
  @param stdClass $user The user to check
  @param discussion_entity $discussion The discussion to check
  @param post_entity $post The post the user wants to edit
  @return bool
docstring_tokens: Can the user edit the post in this discussion?