Exemplo n.º 1
0
 /**
  * 更新一条话题
  *
  * @param PwTagDao $dm 
  * return bool
  */
 public function updateTag(PwTagDm $dm)
 {
     if (!$dm instanceof PwTagDm) {
         return new PwError('TAG:data_error');
     }
     if (($result = $dm->beforeUpdate()) !== true) {
         return $result;
     }
     return $this->_getTagDao()->update($dm->tag_id, $dm->getData(), $dm->getIncreaseData());
 }
Exemplo n.º 2
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');
	}