Beispiel #1
0
 /**
  * @overrides put() from RestResource
  */
 public function put()
 {
     if (parent::put() !== false) {
         $bm = new Default_Model_MailSubscription();
         $id = $this->_parser->getID($this->getData(), "application:application");
         if ($this->_parser->getError() === RestErrorEnum::RE_OK) {
             $apps = new Default_Model_Applications();
             $apps->filter->id->equals($id);
             if ($apps->count() > 0) {
                 $bm->flt = "=application.id:{$id} application.id:SYSTAG_FOLLOW";
                 $bm->researcherid = $this->getParam("id");
                 $bm->delivery = NewsDeliveryType::D_DAILY_DIGEST;
                 $bm->events = NewsEventType::E_DELETE | NewsEventType::E_INSERT_COMMENT | NewsEventType::E_INSERT_CONTACT | NewsEventType::E_UPDATE;
                 $bm->subjecttype = "app-entry";
                 $bm->name = $apps->items[0]->name . " Subscription";
                 $fhash = 0;
                 FilterParser::filterNormalization($bm->flt, $fhash);
                 $bm->flthash = num_to_string($fhash);
                 try {
                     $bm->save();
                 } catch (Exception $e) {
                     $this->setError(RestErrorEnum::RE_BACKEND_ERROR, $e->getMessage());
                     return false;
                 }
                 $res = new RestAppItem(array("id" => $id), $this);
                 return $res->get();
             } else {
                 $this->setError(RestErrorEnum::RE_ITEM_NOT_FOUND);
                 return false;
             }
         } else {
             $this->setError($this->_parser->getError());
             return false;
         }
     } else {
         return false;
     }
 }