Esempio n. 1
0
 public function addAction()
 {
     if ($this->getInput('type', 'post') === 'do') {
         $tagName = $this->getInput('tagname', 'post');
         if (empty($tagName)) {
             $this->showError('请输入Tag名称');
             return;
         } else {
             $hasDuplicate = Wekit::load('EXT:4tschool.service.tag.App_Tag')->checkDuplicateName($tagName);
             if ($hasDuplicate) {
                 $this->showError('Tag:' . '"' . $tagName . '"' . '已存在');
                 return;
             }
             $tagdao = Wekit::load('EXT:4tschool.service.tag.App_Tag');
             $tag['name'] = $tagName;
             $tag['issystem'] = $this->getInput('tagtype');
             $tag['createdate'] = Pw::getTime();
             $tag['lastupdatetime'] = Pw::getTime();
             $dm = new App_Tag_Dm();
             $dm->setTag($tag);
             $tagdao->add($dm);
             $this->showMessage('添加成功');
         }
     }
 }
 private function updateShopTag()
 {
     $shopId = $this->getInput('shopid', 'get');
     $tags = $this->getInput('tags', 'post');
     $newTags = $this->getInput('newtags', 'post');
     if ($tags) {
         foreach ($tags as $key => $item) {
             $dm = new App_Tag_Dm();
             $dm->setShopId($shopId)->setTagName($item['name'])->setIsActive($item['isactive'])->setLastUpdateTime(Pw::getTime());
             $this->_getTagDs()->update($key, $dm);
         }
     }
     if ($newTags) {
         foreach ($newTags as $key => $item) {
             $tag['shopid'] = $shopId;
             $tag['name'] = $item['name'];
             $tag['isactive'] = $item['isactive'];
             $tag['issystem'] = 0;
             $tag['createdate'] = Pw::getTime();
             $tag['lastupdatetime'] = Pw::getTime();
             $dm = new App_Tag_Dm();
             $dm->setTag($tag);
             $this->_getTagDs()->add($dm);
         }
     }
     return true;
 }