public function run($ids)
 {
     if ($this->srv->isRecycle || !($attachs = Wekit::load('attach.PwThreadAttach')->fetchAttachByTidAndPid(array_keys($this->tids), $ids))) {
         return;
     }
     $aids = array();
     foreach ($attachs as $key => $value) {
         Pw::deleteAttach($value['path'], $value['ifthumb']);
         $aids[] = $key;
     }
     Wekit::load('attach.PwThreadAttach')->batchDeleteAttach($aids);
 }
 public function deleteAction()
 {
     $portalid = (int) $this->getInput('id', 'get');
     $portal = $this->_getPortalDs()->getPortal($portalid);
     $pageInfo = $this->_getPageDs()->getPageByTypeAndUnique(PwDesignPage::PORTAL, $portalid);
     Wind::import('SRV:design.bo.PwDesignPageBo');
     $pageBo = new PwDesignPageBo($pageInfo['page_id']);
     if ($pageInfo) {
         $ids = explode(',', $pageInfo['module_ids']);
         $names = explode(',', $pageInfo['module_names']);
         $moduleDs = $this->_getModuleDs();
         $bakDs = $this->_getBakDs();
         $dataDs = $this->_getDataDs();
         $pushDs = $this->_getPushDs();
         $imageSrv = Wekit::load('design.srv.PwDesignImage');
         $moduleDs->deleteByPageId($pageInfo['page_id']);
         // module&& data && push
         $list = Wekit::load('design.PwDesignModule')->getByPageid($this->pageid);
         foreach ($list as $id => $v) {
             $dataDs->deleteByModuleId($id);
             $pushDs->deleteByModuleId($id);
             $imageSrv->clearFolder($id);
         }
         //structure
         $ds = $this->_getStructureDs();
         foreach ($names as $name) {
             $ds->deleteStruct($name);
         }
         //segment
         $this->_getSegmentDs()->deleteSegmentByPageid($pageInfo['page_id']);
         $this->_getPageDs()->deletePage($pageInfo['page_id']);
         $this->_getPermissionsDs()->deleteByTypeAndDesignId(PwDesignPermissions::TYPE_PAGE, $pageInfo['page_id']);
     }
     $this->_getDesignService()->clearTemplate($pageBo->pageid, $pageBo->getTplPath());
     if ($this->_getPortalDs()->deletePortal($portalid)) {
         if ($portal['cover']) {
             $ext = strrchr($portal['cover'], ".");
             $filename = 'portal/' . $portalid . $ext;
             Pw::deleteAttach($filename);
         }
         $this->showMessage("operate.success");
     }
     $this->showMessage("operate.fail");
 }
 /**
  * 批量删除话题 -- 只供管理话题删除接口
  *
  * @param array $tagIds
  * @return bool
  */
 public function deleteByTagIds($tagIds)
 {
     $result = $this->_getTagDs()->fetchTag($tagIds);
     if (!$result) {
         return false;
     }
     foreach ($result as $tag) {
         $tag['tag_logo'] && Pw::deleteAttach($tag['tag_logo']);
     }
     $tagIds = array_keys($result);
     // 删除热门话题排行
     $this->_getTagDs()->deleteTagRecords($tagIds);
     // 删除分类关系
     $this->_getTagCateGoryDs()->deleteCateGoryRelations($tagIds);
     // 删除关注
     $this->_getTagAttentionDs()->deleteAttentions($tagIds);
     // 删除内容关系
     $this->_getTagDs()->deleteRelations($tagIds);
     $this->clearTagsByParentIds($tagIds);
     //TODO
     // 删除话题
     $this->_getTagDs()->batchDelete($tagIds);
     return true;
 }
 /**
  * 删除一条任务
  * 1:任务信息表
  * 2:任务-用户组 关系表
  * 3:任务-用户 关系表
  *
  * @param int $id 任务ID
  * @return PwError|boolean
  */
 public function deleteTask($id)
 {
     $task = $this->_taskDs()->get($id);
     if (!$task) {
         return true;
     }
     Pw::deleteAttach($task['icon']);
     $this->_taskUserDs()->delete($id);
     $r = $this->_taskDs()->deleteTask($id);
     if ($r instanceof PwError) {
         return $r;
     }
     return true;
 }
 /**
  * 勋章删除处理
  *
  */
 public function doDelAction()
 {
     $medalId = (int) $this->getInput('id', 'post');
     if ($medalId < 1) {
         $this->showError('MEDAL:fail');
     }
     $info = $this->_getMedalDs()->getMedalInfo($medalId);
     if ($info['medal_type'] == 1) {
         $this->showError('MEDAL:fail');
     }
     //系统勋章不能删除
     $this->_getMedalDs()->deleteInfo($medalId);
     if ($info['path']) {
         Pw::deleteAttach($info['path'] . $info['image']);
         Pw::deleteAttach($info['path'] . $info['icon']);
     }
     $this->_getMedalLogDs()->deleteInfoByMedalId($medalId);
     $this->_getMedalService()->updateCache();
     $this->showMessage("MEDAL:success");
 }
 /**
  * 删除板块icon
  */
 public function deleteiconAction()
 {
     $fid = $this->getInput('fid');
     Wind::import('SRV:forum.bo.PwForumBo');
     $forum = new PwForumBo($fid, true);
     if (!$forum->isForum(true)) {
         $this->showMessage('版块不存在', 'bbs/setforum/run', true);
     }
     Wind::import('SRV:forum.dm.PwForumDm');
     $dm = new PwForumDm($fid);
     $dm->setIcon('');
     $pwforum = Wekit::load('forum.PwForum');
     $pwforum->updateForum($dm);
     Pw::deleteAttach($forum->foruminfo['icon']);
     $this->showMessage('success');
 }
 /**
  * @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');
 }
 /**
  * 
  * 保存话题
  */
 public function doeditAction()
 {
     $tag = $this->getInput('tag');
     if (!$tag['name']) {
         $this->showError('Tag:tagname.empty');
     }
     $tagInfo = $this->_getTagDs()->getTag($tag['tag_id']);
     if (!$tagInfo) {
         $this->showError('话题不存在!');
     }
     $logo = $this->uploadLogo();
     $dm = new PwTagDm($tag['tag_id']);
     $dm->setName($tag['name'])->setExcerpt($tag['excerpt'])->setSeoTitle($tag['seo_title'])->setSeoDescript($tag['seo_description'])->setSeoKeywords($tag['seo_keywords']);
     if ($logo) {
         $dm->setTagLogo($logo)->setIflogo(1);
     }
     if ($logo && $logo != $tagInfo['tag_logo']) {
         Pw::deleteAttach($tagInfo['tag_logo']);
     }
     //取消原关联话题
     $this->_getTagService()->removeRelatedTopic($tag['tag_id']);
     if ($tag['relate_tags']) {
         $tagInfo = $this->_getTagDs()->getTag($tag['tag_id']);
         $tagInfo['parent_tag_id'] && $this->showError(sprintf('话题"%s"已经有关联话题,不允许再合并关联', $tagInfo['tag_name']));
         $tagNames = explode(',', $tag['relate_tags']);
         foreach ($tagNames as $v) {
             $mergeTag = $this->_getTagDs()->getTagByName($v);
             if ($mergeTag['parent_tag_id']) {
                 $parentTag = $this->_getTagDs()->getTag($mergeTag['parent_tag_id']);
                 $this->showError(sprintf('话题"%s"的关联话题为%s,不允许再合并关联', $mergeTag['tag_name'], $parentTag['tag_name']));
             }
             $this->_addRelateTag($tag['tag_id'], $v);
         }
     }
     $this->_getTagCateGoryDs()->updateCategoryRelations($tag['tag_id'], $tag['category']);
     $result = $this->_getTagDs()->updateTag($dm);
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     }
     $this->_deleteHotTagCache();
     $this->showMessage('话题编辑成功!');
 }
 public function removeImg($path, $ifthumb = 1)
 {
     Pw::deleteAttach($path, $ifthumb);
 }
 /**
  * 删除一个发现 
  * 
  * @access public
  * @return void
  */
 public function delAction()
 {
     $fid = $this->getInput('fid');
     $banner = $this->_getDao()->getOneBanner($fid);
     if ($this->_getDao()->delete((int) $fid)) {
         Pw::deleteAttach($banner['img'], 0);
     }
     $this->showMessage('success', 'native/Fresh/run', true);
 }
Exemple #12
0
 public function transfer()
 {
     if (empty($this->flashatt)) {
         return false;
     }
     $deltmp = array();
     $attach = $this->_getService()->getTmpAttachByUserid($this->user->uid);
     foreach ($attach as $rt) {
         $aid = $rt['aid'];
         if (!isset($this->flashatt[$aid])) {
             Pw::deleteAttach($rt['path'], $rt['ifthumb']);
             $deltmp[] = $aid;
             continue;
         }
         $value = $this->flashatt[$aid];
         $dm = new PwThreadAttachDm($aid);
         $dm->setDescrip($value['desc']);
         if ($value['cost'] > 0 && $this->forum->forumset['allowsell'] && $this->user->getPermission('allow_thread_extend.sell')) {
             if (($max = $this->user->getPermission('sell_credit_range.maxprice')) > 0 && $value['cost'] > $max) {
                 $value['cost'] = $max;
             }
             if (!in_array($value['ctype'], $this->user->getPermission('sell_credits', false, array()))) {
                 Wind::import('SRV:credit.bo.PwCreditBo');
                 $value['ctype'] = key(PwCreditBo::getInstance()->cType);
             }
             $dm->setSpecial(2)->setCost($value['cost'])->setCtype($value['ctype']);
         }
         $this->_getService()->updateAttach($dm);
         $this->attachs[$aid] = array('aid' => $aid, 'name' => $rt['name'], 'type' => $rt['type'], 'path' => $rt['fileuploadurl'], 'size' => $rt['size'], 'descrip' => $value['desc'], 'ifthumb' => $rt['ifthumb']);
     }
     if ($deltmp) {
         $this->_getService()->batchDeleteAttach($deltmp);
     }
     return true;
 }
 /**
  * 删除图标,logo
  */
 public function deleteAction()
 {
     list($type, $path) = $this->getInput(array('type', 'path'));
     Pw::deleteAttach($path);
     Wekit::C()->setConfig('css', $type, '');
     $this->_compilerService()->doCompile();
     $this->showMessage('success');
 }
 /**
  * 编辑任务提交
  *
  */
 public function doEditAction()
 {
     $id = $this->getTaskId();
     $task = $this->_taskDs()->get($id);
     if (!$task) {
         $this->showError('TASK:id.illegal');
     }
     $dm = $this->setDm($id);
     $dm->setIsOpen($task['is_open']);
     if (($r = $this->_taskDs()->updateTask($dm)) instanceof PwError) {
         $this->showError($r->getError());
     }
     if ($dm->getField('icon') != $task['icon'] && $task['icon']) {
         Pw::deleteAttach($task['icon']);
     }
     $this->showMessage('TASK:edittask.success', 'task/manage/run');
 }