Beispiel #1
0
 /**
  * 关闭这个主题
  * @param:  NULL
  * @return: NULL
  * @access: public
  */
 public function run()
 {
     //取回用户需要设置帖子id
     $id = $this->getParameterFromGET('id');
     if (!$id) {
         $this->AlertAndBack(CR_ID_IS_EMPTY);
         return;
     }
     //验证主题是否存在
     if (!TopicUtil::replyIsExists($this->db, $id)) {
         $this->AlertAndBack(CR_ID_IS_NOT_EXISTS);
         return;
     }
     //验证用户的身份
     $sql = 'select id, group_dep from base_user_info where lower(user_name) =?';
     $sth = $this->db->prepare($sql);
     $res = $this->db->Execute($sth, array(strtolower($_SESSION['user']['name'])));
     $rows = $res->FetchRow();
     $user_id = $rows['id'];
     $user_group = $rows['group_dep'];
     if ($user_group != 1 && $user_group != 2 && $user_group != 3) {
         //用户没有权限锁定回复
         $this->AlertAndBack(CR_USER_HAVE_NO_PRIVILEGES);
         return;
     }
     if ($user_group == 3) {
         //如果用户是版主
         //则查看用户是否是本版的版主
         $layout_id = TopicUtil::getLayoutFromReplyId($this->db, $id);
         $temp_array = array();
         LayoutUtil::getParentId($this->db, $layout_id, $temp_array);
         array_push($temp_array, $layout_id);
         $sql = 'select count(*) as num from bbs_layout_manager where user_id=? and ' . ' layout_id in (' . implode(',', $temp_array) . ')';
         $sth = $this->db->prepare($sql);
         $res = $this->db->Execute($sth, array($user_id));
         $rows = $res->FetchRow();
         if (!$rows['num']) {
             $this->AlertAndBack(CR_USER_HAVE_NO_PRIVILEGES);
             return;
         }
     }
     //其他的情况中用户是可以解锁这个回复的
     //用户是这个版块的版主
     //用户是超级版主
     //用户是系统管理员
     $sql = 'update bbs_reply set reply_status=1 where id=?';
     $sth = $this->db->Prepare($sql);
     $this->db->Execute($sth, array($id));
     //成功后,则转向
     //求这个回帖的位置所在的位置
     $sql = 'select subject_id from bbs_reply where id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($id));
     $rows = $res->FetchRow();
     $topic_id = $rows['subject_id'];
     $sort_number = TopicUtil::getSortNumber($this->db, $topic_id, $id);
     $page = ceil($sort_number / 10);
     //这里还有很多的工作需要做
     $this->forward('index.php?module=bbs&action=viewtopic&id=' . $topic_id . '&page=' . $page . '#topic' . $sort_number);
 }