/** * 关闭这个主题 * @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); }
/** * 关闭这个主题 * @param: NULL * @return: NULL * @access: public */ public function run() { //取回用户需要关闭的帖子id $id = $this->getParameterFromGET('id'); if (!$id) { $this->AlertAndBack(CT_ID_IS_EMPTY); return; } //验证主题是否存在 if (!TopicUtil::isExists($this->db, $id)) { $this->AlertAndBack(CT_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(CT_USER_HAVE_NO_PRIVILEGES); return; } if ($user_group == 3) { //如果用户是版主 //则查看用户是否是本版的版主 //或者是其父版版主 $layout_id = TopicUtil::getLayoutId($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(CT_USER_HAVE_NO_PRIVILEGES); return; } } //其他的情况中用户是可以关闭这个主题的。 //用户是这个版块的版主 //用户是超级版主 //用户是系统管理员 $sql = 'update bbs_subject set subject_status=2 where id=?'; $sth = $this->db->prepare($sql); $this->db->Execute($sth, array($id)); if ($this->db->ErrorNo()) { $this->AlertAndBack($this->db->ErrorMsg()); return; } $this->TipsAndForward(TAF_CLOSE_TOPIC_SUCCESS, 'index.php?module=bbs&action=viewtopic&id=' . $id); return; }
/** * 关闭这个主题 * @param: NULL * @return: NULL * @access: public */ public function run() { //取回用户需要删除的帖子id $id = $this->getParameterFromGET('id'); if (!$id) { $this->AlertAndBack(ST_ID_IS_EMPTY); return; } //验证主题是否存在 if (!TopicUtil::isExists($this->db, $id)) { $this->AlertAndBack(ST_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(ST_USER_HAVE_NO_PRIVILEGES); return; } if ($user_group == 3) { //如果用户是版主 //则查看用户是否是本版的版主 $layout_id = TopicUtil::getLayoutId($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(ST_USER_HAVE_NO_PRIVILEGES); return; } } //其他的情况中用户是可以关闭这个主题的。 //用户是这个版块的版主 //用户是超级版主 //用户是系统管理员 $smarty = $this->getSmarty(); $smarty->assign('clone_title', ST_DELETE_TOPIC); $smarty->assign('id', $id); $smarty->display('deltopic.tmpl'); }
/** * 判断用户是否是本版的版主 * @param: &$db, * @param: $id 帖子的id * @param: $user_name 用户的名字 * @return: $is_admin boolean * @access: pulic * @static */ public static function isThisLayoutAdmin(&$db, $id, $layout_id, $user_name) { /*{{{*/ //取得帖子的版块 $user_id = self::getUserId($db, $user_name); $temp_array = array(); LayoutUtil::getParentId($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 = $db->prepare($sql); $res = $db->Execute($sth, array($user_id)); $rows = $res->FetchRow(); if ($rows['num']) { return 1; } else { return 0; } }