Exemplo n.º 1
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);
 }
Exemplo n.º 2
0
 /**
  * 添加关联话题
  * 
  * @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;
 }