/** * 添加前台帖子管理的相关日志 * * @param PwUserBo $user 操作者 * @param string $type 操作类型 * @param array $threads 被操作的帖子列表 * @param string $reason 操作原因 * @param string $extends * @param boolean $useReplyMsg 是否使用回复的管理日志格式 */ public function addThreadManageLog(PwUserBo $user, $type, $threads, $reason, $extends = '', $useReplyMsg = false) { if (!$threads) { return false; } $typeid = $this->getOperatTypeid($type); $typeTitle = $this->getOperatTypeTitle($type); $_logDms = $langArgs = array(); $langArgs['{operattype}'] = $typeTitle; $langArgs['{reason}'] = $reason ? $this->_buildSecurity($reason) : '无'; $_logMsg = $useReplyMsg ? 'LOG:thread.reply.message' : 'LOG:thread.manage.message'; Wind::import('SRV:forum.dm.PwTopicDm'); foreach ($threads as $thread) { $langArgs['{title}'] = sprintf('<a href="%s" target="_blank">%s</a>', WindUrlHelper::createUrl('bbs/read/run', array('tid' => $thread['tid'])), $this->_buildSecurity($thread['subject'])); $langArgs['{createdUser}'] = sprintf('<a href="%s" target="_blank">%s</a>', WindUrlHelper::createUrl('space/index/run', array('uid' => $user->uid)), $user->username); $_dm = new PwLogDm(); $_dm->setCreatedTime(Pw::getTime())->setCreatedUser($user->uid, $user->username)->setOperatedUser($thread['created_userid'], $thread['created_username'])->setIp(Wind::getComponent('request')->getClientIp())->setExtends($extends)->setFid($thread['fid'])->setTid($thread['tid'])->setPid(isset($thread['pid']) && $thread['pid'] ? $thread['pid'] : 0)->setTypeid($typeid)->setContent($this->getLogMsg($_logMsg, $langArgs)); if (!isset($thread['pid']) && !Pw::getstatus($thread['tpcstatus'], PwThread::STATUS_OPERATORLOG)) { $topicDm = new PwTopicDm($thread['tid']); $topicDm->setOperatorLog(true); Wekit::load('forum.PwThread')->updateThread($topicDm, PwThread::FETCH_MAIN); } $_logDms[] = $_dm; } $this->_getLogDs()->batchAddLog($_logDms); return true; }
public function deleteAction() { $aid = $this->getInput('aid', 'post'); if (!$aid) { $this->showError('operate.fail'); } if (!($attach = Wekit::load('attach.PwThreadAttach')->getAttach($aid))) { $this->showError('data.error'); } Wind::import('SRV:forum.bo.PwForumBo'); $forum = new PwForumBo($attach['fid']); if (!$forum->isForum()) { $this->showError('data.error'); } if ($this->loginUser->uid != $attach['created_userid']) { if (!$this->loginUser->getPermission('operate_thread.deleteatt', $forum->isBM($this->loginUser->username))) { $this->showError('permission.attach.delete.deny'); } if (!$this->loginUser->comparePermission($attach['created_userid'])) { $this->showError(array('permission.level.deleteatt', array('{grouptitle}' => $this->loginUser->getGroupInfo('name')))); } } Wekit::load('attach.PwThreadAttach')->deleteAttach($aid); Pw::deleteAttach($attach['path'], $attach['ifthumb']); if ($this->loginUser->uid != $attach['created_userid']) { Wekit::load('log.srv.PwLogService')->addDeleteAtachLog($this->loginUser, $attach); } if ($attach['tid']) { if (!$attach['pid']) { $thread = Wekit::load('forum.PwThread')->getThread($attach['tid'], PwThread::FETCH_ALL); Wind::import('SRV:forum.dm.PwTopicDm'); $dm = new PwTopicDm($attach['tid']); if (!Wekit::load('attach.PwThreadAttach')->countType($attach['tid'], 0, $attach['type'])) { $dm->setHasAttach($attach['type'], false); } if (!Pw::getstatus($thread['tpcstatus'], PwThread::STATUS_OPERATORLOG) && $this->loginUser->uid != $attach['created_userid']) { $dm->setOperatorLog(true); } } else { $thread = Wekit::load('forum.PwThread')->getPost($attach['pid']); Wind::import('SRV:forum.dm.PwReplyDm'); $dm = new PwReplyDm($attach['pid']); } if ($thread['aids'] > 0) { $thread['aids']--; } $dm->setAids($thread['aids']); if (($content = str_replace('[attachment=' . $aid . ']', '', $thread['content'])) != $thread['content']) { $dm->setContent($content); } if (!$attach['pid']) { Wekit::load('forum.PwThread')->updateThread($dm); } else { Wekit::load('forum.PwThread')->updatePost($dm); } } $this->showMessage('success'); }