예제 #1
0
 /**
  * 勋章修改处理
  *
  */
 public function doEditAction()
 {
     $medalid = (int) $this->getInput('medalid', 'post');
     $expired = (int) $this->getInput('expired', 'post');
     $awardtype = (int) $this->getInput('awardtype', 'post');
     $receivetype = $this->getInput('receivetype', 'post');
     $condition = $this->getInput('awardcondition', 'post');
     if ($_FILES['image']['size']) {
         $image = $this->_uploadImage('image');
     }
     if ($_FILES['icon']['size']) {
         $icon = $this->_uploadImage('icon');
     }
     $info = $this->_getMedalDs()->getMedalInfo($medalid);
     if ($receivetype == 1) {
         $expired = 0;
     }
     if ($receivetype == 1 && in_array($awardtype, array(1, 2, 3))) {
         $expired = 3;
     }
     if ($receivetype == 2) {
         $awardtype = 0;
         $condition = 0;
     }
     Wind::import('SRV:medal.dm.PwMedalDm');
     $dm = new PwMedalDm($medalid);
     $dm->setMedalName($this->getInput('medalname', 'post'))->setDescrip($this->getInput('descrip', 'post'))->setMedalGids($this->getInput('visitGid', 'post'))->setReceiveType($receivetype)->setAwardCondition($condition)->setAwardType($awardtype)->setExpiredDays($expired);
     if ($image) {
         if ($info['path']) {
             Pw::deleteAttach($info['path'] . $info['image']);
         }
         $dm->setImage($image['filename'])->setPath($image['path']);
     }
     if ($icon) {
         if ($info['path']) {
             Pw::deleteAttach($info['path'] . $info['icon']);
         }
         $dm->setIcon($icon['filename'])->setPath($image['path']);
     }
     $resource = $this->_getMedalDs()->updateInfo($dm);
     if ($resource instanceof PwError) {
         $this->showError($resource->getError());
     }
     $this->_getMedalService()->updateCache();
     $this->showMessage("MEDAL:success");
 }
예제 #2
0
 public function updateInfo(PwMedalDm $dm)
 {
     $resource = $dm->beforeUpdate();
     if ($resource instanceof PwError) {
         return $resource;
     }
     return $this->_getDao()->updateInfo($dm->medalId, $dm->getData());
 }