/**
  * 根据标签ID更新这些标签被使用次数
  *
  * @param array $tag_ids
  * @param PwUserTagRelation $bp
  * @return boolean
  */
 public function batchDeleteRelation($tag_ids, PwUserTagRelation $bp)
 {
     foreach ($tag_ids as $_tid) {
         $tagDm = new PwUserTagDm();
         $tagDm->setTagid($_tid)->increaseCount(-1);
         $this->_getTagDs()->updateTag($tagDm);
     }
     return true;
 }
Example #2
0
 /**
  * 更新标签
  *
  * @param PwUserTagDm $tagDm
  * @return boolean
  */
 public function updateTag(PwUserTagDm $tagDm)
 {
     if (true !== ($r = $tagDm->beforeUpdate())) {
         return $r;
     }
     return $this->_getDao()->updateTag($tagDm->tag_id, $tagDm->getData(), $tagDm->getIncreaseData());
 }
 /**
  * 将用户和用户标签添加关联
  *
  * @param int $uid
  * @param int $tag_id
  * @param int $time
  * @return array
  */
 public function addTagRelationWithTagid($uid, $tag_id, $time)
 {
     if ($uid < 1) {
         return new PwError('USER:tag.uid.require');
     }
     if (1 > ($tag_id = intval($tag_id))) {
         return new PwError('USER:tag.id.require');
     }
     if (($r = $this->allowAdd($uid)) instanceof PwError) {
         return $r;
     }
     $info = $this->_getTagDs()->getTag($tag_id);
     if (!$info) {
         return new PwError('USER:tag.id.require');
     }
     $r = $this->_getTagRelationDs()->getRelationByUidAndTagid($uid, $info['tag_id']);
     if ($r) {
         return new PwError('USER:tag.relation.exists');
     }
     $tagDm = new PwUserTagDm();
     $tagDm->setTagid($tag_id)->increaseCount(1);
     if (($r = $this->_getTagDs()->updateTag($tagDm)) instanceof PwError) {
         return $r;
     }
     return $this->_getTagRelationDs()->addRelation($uid, $tag_id, $time ? intval($time) : Pw::getTime());
 }