public function run($ids)
 {
     $ds = Wekit::load('tag.PwTag');
     $tags = $ds->fetchByTypeIdAndParamIds(PwTag::TYPE_THREAD_TOPIC, $ids);
     $tagIds = array_keys($tags);
     if (!$tagIds) {
         return false;
     }
     $ds->batchDeleteRelation(PwTag::TYPE_THREAD_TOPIC, $ids);
     Wind::import('SRV:tag.dm.PwTagDm');
     $dm = new PwTagDm();
     $dm->addContentCount(-1);
     $ds->updateTags($tagIds, $dm);
 }
Beispiel #2
0
 /**
  * 
  * 取消某话题的关联话题
  * @param int $tagId
  */
 public function removeRelatedTopic($tagId)
 {
     $tagId = intval($tagId);
     $childTags = $this->_getTagDs()->getTagByParent($tagId);
     if (!$childTags) {
         return true;
     }
     $childTagIds = array();
     foreach ($childTags as $tag) {
         $childTagIds[] = $tag['tag_id'];
         $this->_getTagDs()->updateTagRelationByTagId($tagId, $tag['tag_id']);
     }
     Wind::import('SRV:tag.dm.PwTagDm');
     $dm = new PwTagDm();
     $dm->setParent(0);
     $this->_getTagDs()->updateTags($childTagIds, $dm);
 }
Beispiel #3
0
	/**
	 * 编辑帖子阅读页话题
	 *
	 * @return void
	 */
	public function editReadTagAction(){
		// 是否登录
		if ($this->loginUser->uid < 1) {
			$this->showError('USER:user.not.login');
		}
		list($tid,$tagnames) = $this->getInput(array('tid','tagnames'));
		$tagnames = $tagnames ? $tagnames : array();
		// 是否有权限
		if ($this->_checkAllowEdit($tid) !== true) {
			$this->showError('TAG:right.tag_allow_edit.error');
		}
		$count = count($tagnames);
		$count > 5 && $this->showError("Tag:tagnum.exceed");
		Wind::import('SRV:tag.dm.PwTagDm');
		if ($count == 1) {
			$dm = new PwTagDm();
			$dm->setName($tagnames['0']);
			if(($result = $dm->beforeUpdate()) instanceof PwError) {
				$this->showError($result->getError());
			}
		}
		// 敏感词
		$content = implode(' ', $tagnames);
		$wordFilter = Wekit::load('SRV:word.srv.PwWordFilter');
		list($type, $words) = $wordFilter->filterWord($content);
		if ($type) {
			$this->showError("WORD:content.error");
		}
		$typeId = $this->_getTagService()->getTypeIdByTypeName($this->defaultType);
		$dmArray = array();
		foreach ((array)$tagnames as $value) {
			$value = trim($value);
			if(Pw::strlen($value) > 15) {
				continue;
			}
			$dm = new PwTagDm();
			if (($result = $dm->checkTagName($value)) instanceof PwError) {
				$this->showError($result->getError());
			}
			$dmArray[$value] =
				$dm->setName($value)
					->setTypeId($typeId)
					->setParamId($tid)
					->setIfHot(1)
					->setCreatedTime(Pw::getTime())
					->setCreateUid($this->loginUser->uid)
			;
		}
		$result = $this->_getTagService()->updateTags($typeId,$tid,$dmArray);
		if ($result instanceof PwError) {
			$this->showError($result->getError());
		}
		$this->showMessage('success');
	}
Beispiel #4
0
 /**
  * 
  * 批量修改话题
  * @param array $tagIds
  * @param PwTagDm $dm
  */
 public function updateTags($tagIds, PwTagDm $dm)
 {
     if (!is_array($tagIds) || !count($tagIds)) {
         return new PwError('TAG:data_error');
     }
     return $this->_getTagDao()->batchUpdate($tagIds, $dm->getData(), $dm->getIncreaseData());
 }
 /**
  * 添加关联话题
  * 
  * @param int $tagId 关联到哪个话题Id
  * @param string $tagName 话题名称
  */
 private function _addRelateTag($tagId, $tagName)
 {
     $tagId = intval($tagId);
     if ($tagId < 1 || !$tagName) {
         return false;
     }
     $tag = $this->_getTagDs()->getTag($tagId);
     if (!$tag) {
         return false;
     }
     $relateTag = $this->_getTagDs()->getTagByName($tagName);
     if (!$relateTag) {
         $dm = new PwTagDm();
         $dm->setName($tagName)->setCreateUid($this->loginUser->uid)->setParent($tagId);
         $this->_getTagDs()->addTag($dm);
     } else {
         if ($relateTag['tag_id'] == $tagId) {
             return false;
         }
         //检查被关联的话题是否存在子话题
         if ($this->_getTagDs()->getTagByParent($relateTag['tag_id'])) {
             return false;
         }
         $dm = new PwTagDm($relateTag['tag_id']);
         $dm->setParent($tagId);
         $this->_getTagDs()->updateTag($dm);
     }
     return true;
 }
Beispiel #6
0
 /**
  * 批量添加分类
  *
  * @param array $data
  * @return int
  */
 public function addTagCategory(PwTagDm $dm)
 {
     if (!$dm->getField('category_name')) {
         return new PwError('TAG:category.name.empty');
     }
     return $this->_getTagCategoryDao()->addTagCategory($dm->getData());
 }
Beispiel #7
0
 /**
  * 批量添加分类
  *
  * @param array $data
  * @return int
  */
 public function addTagCategory(PwTagDm $dm)
 {
     return $this->_getTagCategoryDao()->addTagCategory($dm->getData());
 }