예제 #1
0
 /**
  * 检查主题分类
  * 
  * @param PwPostDm $postDm
  * @return bool|PwError
  */
 public function checkTopictype(PwPostDm $postDm)
 {
     $topicType = $postDm->getTopictype();
     if ($topicType && !$this->forum->forumset['topic_type']) {
         return new PwError('BBS:post.topictype.closed');
     }
     if ($this->forum->forumset['topic_type'] && $this->forum->forumset['force_topic_type'] && !$postDm->getTopictype()) {
         $topicTypes = Wekit::load('SRV:forum.PwTopicType')->getTypesByFid($this->forum->fid);
         if ($topicTypes) {
             return new PwError('BBS:post.topictype.empty');
         }
     }
     $permission = $this->user->getPermission('operate_thread');
     if ($topicType && !$permission['type']) {
         $topicTypes or $topicTypes = Wekit::load('SRV:forum.PwTopicType')->getTypesByFid($this->forum->fid);
         if ($topicTypes[$topicType]['issys']) {
             return new PwError('BBS:post.topictype.admin');
         }
     }
     return true;
 }