Ejemplo n.º 1
0
 /**
  * 修改内容
  * 
  * @param int $tagid
  * @param PwLikeTagDm $dm
  */
 public function updateInfo(PwLikeTagDm $dm)
 {
     $resource = $dm->beforeUpdate();
     if ($resource instanceof PwError) {
         return $resource;
     }
     return $this->_getLikeTagDao()->updateInfo($dm->tagid, $dm->getData());
 }
Ejemplo n.º 2
0
 /**
  * 新增分类
  * Enter description here ...
  * @param int $logid
  * @param string $tagname
  */
 public function addTag($uid, $tagname)
 {
     if (Pw::strlen($tagname) < 2) {
         return new PwError('BBS:like.tagname.is.short');
     }
     if (Pw::strlen($tagname) > 10) {
         return new PwError('BBS:like.tagname.is.lenth');
     }
     $tagInfos = $this->_getLikeTagDs()->getInfoByUid($uid);
     foreach ($tagInfos as $info) {
         if ($tagname == $info['tagname']) {
             return new PwError('BBS:like.tagname.is.already');
         }
     }
     Wind::import('SRV:like.dm.PwLikeTagDm');
     $dm = new PwLikeTagDm();
     $dm->setTagname($tagname)->setUid($uid)->setNumber(0);
     return $this->_getLikeTagDs()->addInfo($dm);
 }
Ejemplo n.º 3
0
 /**
  * 编辑分类
  *
  */
 public function doEditTagAction()
 {
     $tagid = (int) $this->getInput('tag', 'post');
     $tagname = trim($this->getInput('tagname', 'post'));
     if (Pw::strlen($tagname) < 2) {
         $this->showError('BBS:like.tagname.is.short');
     }
     if (Pw::strlen($tagname) > 10) {
         $this->showError('BBS:like.tagname.is.lenth');
     }
     $tags = $this->_getLikeTagService()->getInfoByUid($this->loginUser->uid);
     $allow = false;
     foreach ($tags as $tag) {
         if ($tag['tagid'] == $tagid) {
             $allow = true;
         }
         if ($tag['tagname'] == $tagname) {
             $this->showError('BBS:like.fail.already.tagname');
         }
     }
     if (!$allow) {
         $this->showError('BBS:like.fail');
     }
     Wind::import('SRV:like.dm.PwLikeTagDm');
     $dm = new PwLikeTagDm($tagid);
     $dm->setTagname($tagname);
     $resource = $this->_getLikeTagService()->updateInfo($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     $this->setOutput(array('id' => $tagid, 'name' => $tagname), 'data');
     $this->showMessage('BBS:like.success');
 }