Exemplo n.º 1
0
 public function prepareParams()
 {
     // render notification html
     $notifications =& $this->_params['notifications'];
     $templates = bdApi_ViewApi_Helper_Alert::getTemplates($this, $this->_params['_alerts'], $this->_params['_alertHandlers']);
     foreach ($notifications as $key => &$notification) {
         $notification['notification_html'] = $templates[$notification['notification_id']]['template'];
     }
     call_user_func_array(array('bdApi_ViewApi_Helper_Subscription', 'prepareDiscoveryParams'), array(&$this->_params, $this->_response, bdApi_Model_Subscription::TYPE_NOTIFICATION, XenForo_Visitor::getUserId(), XenForo_Link::buildApiLink('notifications', null, array('oauth_token' => '')), XenForo_Visitor::getInstance()->get('bdapi_user_notification')));
     parent::prepareParams();
 }
Exemplo n.º 2
0
 protected function _preparePingDataManyNotification($pingDataMany)
 {
     /* @var $alertModel bdApi_XenForo_Model_Alert */
     $alertModel = $this->getModelFromCache('XenForo_Model_Alert');
     $alertIds = array();
     foreach ($pingDataMany as $pingData) {
         $alertIds[] = $pingData['object_data'];
     }
     $alerts = $alertModel->bdApi_getAlertsByIds($alertIds);
     $userIds = array();
     $alertsByUser = array();
     foreach ($alerts as $alert) {
         $userIds[] = $alert['alerted_user_id'];
         if (!isset($alertsByUser[$alert['alerted_user_id']])) {
             $alertsByUser[$alert['alerted_user_id']] = array();
         }
         $alertsByUser[$alert['alerted_user_id']][$alert['alert_id']] = $alert;
     }
     $viewingUsers = $this->_preparePingData_getViewingUsers($userIds);
     foreach ($alertsByUser as $userId => &$userAlerts) {
         if (!isset($viewingUsers[$userId])) {
             // user not found
             foreach (array_keys($userAlerts) as $userAlertId) {
                 // delete the alert too
                 unset($alerts[$userAlertId]);
             }
             continue;
         }
         $userAlerts = $alertModel->bdApi_prepareContentForAlerts($userAlerts, $viewingUsers[$userId]);
         bdApi_Template_Simulation_Template::$bdApi_visitor = $viewingUsers[$userId];
         $userAlerts = bdApi_ViewApi_Helper_Alert::getTemplates(bdApi_Template_Simulation_View::create(), $userAlerts, $alertModel->bdApi_getAlertHandlers());
         foreach (array_keys($userAlerts) as $userAlertId) {
             $alerts[$userAlertId] = $userAlerts[$userAlertId];
         }
     }
     foreach (array_keys($pingDataMany) as $pingDataKey) {
         $pingDataRef =& $pingDataMany[$pingDataKey];
         if (empty($pingDataRef['object_data'])) {
             // no alert is attached to object data
             continue;
         }
         if (!isset($alerts[$pingDataRef['object_data']])) {
             // alert not found
             unset($pingDataMany[$pingDataKey]);
             continue;
         }
         $alertRef =& $alerts[$pingDataRef['object_data']];
         $pingDataRef['object_data'] = $alertModel->prepareApiDataForAlert($alertRef);
         if (isset($alertRef['template'])) {
             $pingDataRef['object_data']['notification_html'] = strval($alertRef['template']);
         }
     }
     return $pingDataMany;
 }