/** * @see PwUploadAction.update */ public function update($uploaddb) { $srv = Wekit::load('attach.PwThreadAttach'); foreach ($uploaddb as $key => $value) { Pw::deleteAttach($this->attach['path'], $this->attach['ifthumb']); $att = new PwThreadAttachDm($this->aid); $att->setName($value['name']); $att->setType($value['type']); $att->setSize($value['size']); $att->setPath($value['fileuploadurl']); $att->setIfthumb($value['ifthumb']); $att->setCreatedUser($this->user->uid); $att->setCreatedTime(Pw::getTime()); $att->setApp('thread'); $srv->updateAttach($att); if ($this->attach['tid'] && $this->attach['pid'] == 0 && $this->attach['type'] != $value['type']) { Wind::import('SRV:forum.dm.PwTopicDm'); $dm = new PwTopicDm($this->attach['tid']); $dm->setHasAttach($value['type'], true); if (!Wekit::load('attach.PwThreadAttach')->countType($this->attach['tid'], 0, $this->attach['type'])) { $dm->setHasAttach($this->attach['type'], false); } Wekit::load('forum.PwThread')->updateThread($dm); } $this->attachs[$this->aid] = array('aid' => $this->aid, 'name' => $value['name'], 'type' => $value['type'], 'path' => $value['fileuploadurl'], 'size' => $value['size'], 'descrip' => $value['descrip'], 'ifthumb' => $value['ifthumb']); break; } 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'); }