public function subscribeAction()
 {
     try {
         if ($data = Zend_Json::decode($this->getRequest()->getRawBody())) {
             if ($data["device_uid"] and $data["category_id"]) {
                 $subscription = new Topic_Model_Subscription();
                 if ($data["subscribe"] === true) {
                     $subscription->setData($data)->save();
                 } else {
                     $subscriptions = $subscription->findAll(array("device_uid" => $data["device_uid"], "category_id" => $data["category_id"]));
                     foreach ($subscriptions as $subscription) {
                         if ($subscription->getId()) {
                             $subscription->delete();
                         }
                     }
                 }
                 $html = array('success' => 1);
             } else {
                 throw new exception($this->_('An error occurred while saving. Please try again later.'));
             }
         }
     } catch (Exception $e) {
         $html = array('error' => 1, 'message' => $e->getMessage(), 'message_button' => 1, 'message_loader' => 1);
     }
     $this->_sendHtml($html);
 }
Beispiel #2
0
 public function findLastInAppMessage($app_id, $device_id)
 {
     $subscription = new Topic_Model_Subscription();
     $allowed_categories = $subscription->findAllowedCategories($device_id);
     $row = $this->getTable()->findLastInAppMessage($app_id, $device_id, $allowed_categories);
     $this->_prepareDatas($row);
     return $this;
 }