public function lastmessagesAction()
 {
     $data = array();
     if ($device_uid = $this->getRequest()->getParam('device_uid')) {
         $message = new Push_Model_Message();
         $message->findLastPushMessage($device_uid);
         if ($message->getId()) {
             //We read this push
             $message->markAsRead($device_uid, $message->getMessageId());
             if (is_numeric($message->getActionValue())) {
                 $option_value = new Application_Model_Option_Value();
                 $option_value->find($message->getActionValue());
                 $action_url = $option_value->getPath(null, array('value_id' => $option_value->getId()), false);
             } else {
                 $action_url = $message->getActionValue();
             }
             $data["push_message"] = array("title" => $message->getTitle(), "text" => $message->getText(), "cover" => $message->getCoverUrl(), "action_value" => $action_url, "open_webview" => !is_numeric($message->getActionValue()));
         }
         $message = new Push_Model_Message();
         $message->findLastInAppMessage($this->getApplication()->getId(), $device_uid);
         if ($message->getId()) {
             $data["inapp_message"] = array("title" => $message->getTitle(), "text" => $message->getText(), "cover" => $message->getCoverUrl());
         }
     }
     $this->_sendHtml($data);
 }
 public function deleteAction()
 {
     if ($datas = $this->getRequest()->getPost()) {
         try {
             if (empty($datas['value_id'])) {
                 throw new Exception($this->_('An error occurred while deleting the option'));
             }
             // Récupère les données de l'application pour cette option
             $option_value = new Application_Model_Option_Value();
             $option_value->find($datas['value_id']);
             $app_id = $this->getApplication()->getId();
             if (!$option_value->getId() or $option_value->getAppId() != $app_id) {
                 throw new Exception($this->_('An error occurred while deleting the option'));
             }
             $html = array('success' => 1, 'value_id' => $datas['value_id'], 'path' => $option_value->getPath(null, array(), "mobile"), 'was_folder' => false, 'was_category' => false, 'was_feature' => false);
             // Option folder
             if (isset($datas['category_id'])) {
                 $option_value->setFolderId(null)->setFolderCategoryId(null)->setFolderCategoryPosition(null)->save();
                 $html['was_category'] = true;
                 $html['category'] = array('id' => $datas['category_id']);
             } else {
                 // Récupère l'option
                 $option = new Application_Model_Option();
                 $option->find($option_value->getOptionId());
                 $html['was_feature'] = true;
                 $html['use_user_account'] = $this->getApplication()->usesUserAccount();
                 if ($option_value->getCode() == "folder") {
                     $html['was_folder'] = true;
                 }
                 // Supprime l'option de l'application
                 $option_value->delete();
                 if ($option->onlyOnce()) {
                     $html['page'] = array('id' => $option->getId(), 'name' => $option->getName(), 'icon_url' => $option->getIconUrl(), 'category_id' => $option->getCategoryId());
                 }
                 // Renvoi le nouveau code HTML
                 //                    $this->getLayout()->setBaseRender('content', 'application/customization/page/list.phtml', 'admin_view_default');
             }
         } catch (Exception $e) {
             $html = array('message' => $this->_('An error occurred while deleting the option'), 'message_button' => 1, 'message_loader' => 1);
         }
         $this->_sendHtml($html);
     }
 }
Esempio n. 3
0
 public function findallAction()
 {
     $data = array("collection" => array());
     $option = $this->getCurrentOptionValue();
     $color = $this->getApplication()->getBlock('background')->getColor();
     $offset = $this->getRequest()->getParam('offset', 0);
     if ($device_uid = $this->getRequest()->getParam('device_uid')) {
         $message = new Push_Model_Message();
         $message->setMessageTypeByOptionValue($this->getCurrentOptionValue()->getOptionId());
         $messages = $message->findByDeviceId($device_uid, $offset);
         $icon_new = $option->getImage()->getCanBeColorized() ? $this->_getColorizedImage($option->getIconId(), $color) : $option->getIconUrl();
         $icon_pencil = $this->_getColorizedImage($this->_getImage("pictos/pencil.png"), $color);
         foreach ($messages as $message) {
             $meta = array("area1" => array("picto" => $icon_pencil, "text" => $message->getFormattedCreatedAt(Zend_Date::DATETIME_MEDIUM)));
             if (!$message->getIsRead()) {
                 $meta["area3"] = array("picto" => $icon_new, "text" => $this->_("New"));
             }
             $picture = $message->getCover() ? Application_Model_Application::getImagePath() . $message->getCover() : null;
             $action_value = null;
             if ($message->getActionValue()) {
                 if (is_numeric($message->getActionValue())) {
                     $option_value = new Application_Model_Option_Value();
                     $option_value->find($message->getActionValue());
                     $action_value = $option_value->getPath(null, array('value_id' => $option_value->getId()), false);
                 } else {
                     $action_value = $message->getActionValue();
                 }
             }
             if ($this->getApplication()->getIcon(74)) {
                 $icon = $this->getApplication()->getIcon(74);
             } else {
                 $icon = null;
             }
             $data["collection"][] = array("id" => $message->getId(), "author" => $message->getTitle(), "message" => $message->getText(), "topic" => $message->getLabel(), "meta" => $meta, "picture" => $picture, "icon" => $icon, "action_value" => $action_value);
         }
         $message->markAsRead($device_uid);
     }
     $data["page_title"] = $this->getCurrentOptionValue()->getTabbarName();
     $data["displayed_per_page"] = Push_Model_Message::DISPLAYED_PER_PAGE;
     $this->_sendHtml($data);
 }
Esempio n. 4
0
 public function findAction()
 {
     if ($value_id = $this->getRequest()->getParam('value_id')) {
         $event_id = $this->getRequest()->getParam('event_id');
         if (is_null($event_id)) {
             return $this;
         }
         try {
             $option = $this->getCurrentOptionValue();
             $start_at = new Zend_Date();
             $end_at = new Zend_Date();
             $format = 'y-MM-dd HH:mm:ss';
             $events = $option->getObject()->getEvents(null, true);
             if (!empty($events[$event_id])) {
                 $event = $events[$event_id];
                 $data = array('event' => array());
                 $start_at->set($event->getStartAt(), $format);
                 $end_at->set($event->getEndAt(), $format);
                 $formatted_start_at = $start_at->toString($this->_("MM.dd.y"));
                 $formatted_end_at = $end_at->toString($this->_("MM.dd.y 'at' HH:mm a"));
                 $in_app_page_path = null;
                 if (is_numeric($event->getInAppValueId())) {
                     $option = new Application_Model_Option_Value();
                     $option->find($event->getInAppValueId());
                     if ($option->getId() and $option->isActive() and $option->getAppId() == $this->getApplication()->getId()) {
                         $in_app_page_path = $option->getPath("index");
                     }
                 }
                 $data['event'] = array("id" => $event_id, "title" => $event->getName(), "description" => $event->getDescription(), "address" => $event->getAddress(), "weekday_name" => $start_at->toString(Zend_Date::WEEKDAY_NAME), "start_at" => $formatted_start_at, "end_at" => $formatted_end_at, "ticket_shop_url" => $event->getTicketShopUrl(), "rsvp" => $event->getRsvp(), "websites" => $event->getWebsites(), "in_app_page_path" => $in_app_page_path, "social_sharing_active" => $option->getSocialSharingIsActive());
                 $data["cover"] = array("title" => $event->getName(), "subtitle" => $event->getSubtitle(), "title2" => "{$start_at->toString(Zend_Date::WEEKDAY_NAME)} {$formatted_start_at}", "subtitle2" => array("time" => $event->getStartTimeAt(), "location" => array("label" => $event->getLocationLabel(), "url" => $event->getLocationUrl())), "title3" => "{$end_at->toString(Zend_Date::WEEKDAY_NAME)} {$formatted_end_at}", "picture" => $event->getPicture());
                 $data['page_title'] = $event->getName();
             } else {
                 throw new Exception("Unable to find this event.");
             }
         } catch (Exception $e) {
             $data = array('error' => 1, 'message' => $e->getMessage());
         }
         $this->_sendHtml($data);
     }
 }