コード例 #1
0
ファイル: post.php プロジェクト: 0hyeah/yurivn
 /**
  * Can the user delete this post?
  *
  * @param vB_Legacy_CurrentUser $user
  * @return boolean
  */
 public function can_delete($user)
 {
     /*
     	There was an inconsistancy in permissions between the display logic
     	and the delete action logic.  The delete logic checks the posts permissions
     	for all posts while the display checks only the thread permissions for
     	first posts.  We're using the more restrictive permissions checked on actual
     	action.
     */
     $is_user_owner = $user->get_field('userid') == $this->record['postid'];
     $forumid = $this->get_thread()->get_field('forumid');
     //we can't delete posts, return false
     if (!$user->canModerateForum($forumid, 'candeleteposts') and !($is_user_owner and $user->hasForumPermission($forumid, 'candeletepost'))) {
         return false;
     }
     //this is the first post and we can't delete threads
     if ($this->is_first()) {
         if (!$user->canModerateForum($forumid, 'canmanagethreads') and !($is_user_owner and $user->hasForumPermission($forumid, 'candeletethread'))) {
             return false;
         }
     }
     return true;
 }