Ejemplo n.º 1
0
 /**
  * Create standard display vars for each view
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $controller_name = $request->getControllerName();
     $action_name = $request->getActionName();
     // redirect to facebook after share callback
     $url = $request->getRequestUri();
     if (strpos($url, '/fb-redirect') !== false) {
         $r = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
         $r->gotoUrl('http://facebook.com')->redirectAndExit();
     }
     // add <head> code for all global pages
     $this->view->custom_head = Zend_Registry::get('config')->get('global_head') ? Zend_Registry::get('config')->get('global_head') : '';
     // global javascript vars
     $this->view->php_controller = $controller_name;
     $this->view->php_action = $action_name;
     // view perspective
     $this->view->view_perspective = 'global_view';
     // offset infinite scroll - for bots crawling without js
     if (isset($_GET['scroll_offset'])) {
         $scroll_offset = (int) $_GET['scroll_offset'];
         $this->view->post_page_number = $scroll_offset + 1;
     }
     // background image
     $this->view->app_background_image = Zend_Registry::get('config')->background;
     // for logged in users
     if (Zend_Auth::getInstance()->hasIdentity()) {
         // notifications
         $Notifications = new Application_Model_Notifications();
         $notifications_count = $Notifications->getUnreadNotificationsCount();
         $this->view->notifications_count = $notifications_count;
         $this->view->addScriptPath(APPLICATION_PATH . '/views/scripts/');
         $notifications_html = $this->view->render('/partial/notifications_popover.phtml');
         $this->view->notifications_html = $notifications_html;
         // new messages count
         $Messages = new Application_Model_Messages();
         $new_messages_count = $Messages->getMessagesCount(false, true);
         $this->view->new_messages_count = $new_messages_count;
     } else {
         // skip on ajax validator
         if ($action_name == 'validateformajax') {
             return;
         }
         $this->loginFormsLoader($request);
     }
     // attach app sidebar box
     Zend_Registry::get('hooks')->attach('hook_view_sidebar', 20, function () {
         echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/apps.phtml');
     });
     return;
 }
 /**
  * heartbeat actions (via continuous ajax call)
  */
 public function heartbeatAction()
 {
     $Notifications = new Application_Model_Notifications();
     $notifications = $Notifications->getNotifications(true, 10);
     $notifications_count = $Notifications->getUnreadNotificationsCount();
     $this->view->notifications = $notifications;
     $notifications_html = $this->view->render('/partial/notifications_popover.phtml');
     // new messages count
     $Messages = new Application_Model_Messages();
     $new_messages_count = $Messages->getMessagesCount(false, true);
     $ProfilesMeta = new Application_Model_ProfilesMeta();
     // we will use timestamp format here since it's easier to calculate diff with ANSI SQL
     $ProfilesMeta->metaUpdate('last_heartbeat', time());
     $out = array('notification_count' => $notifications_count, 'notification_html' => $notifications_html, 'new_messages' => $new_messages_count);
     // trigger hooks
     Zend_Registry::get('hooks')->trigger('hook_app_heartbeat', $out);
     $this->_helper->json($out);
 }
 /**
  * Remove message (via ajax)
  */
 public function removeAction()
 {
     $message_id = (int) $this->getRequest()->getParam('message_id', false);
     $user = $this->getRequest()->getParam('user', false);
     $Messages = new Application_Model_Messages();
     $ret = false;
     if ($message_id) {
         $ret = $Messages->removeMessage($message_id);
     }
     if ($user) {
         $ret = $Messages->removeAllMessagesWithUser($user);
     }
     $this->getHelper('json')->sendJson($ret);
 }
Ejemplo n.º 4
0
 /**
  * Permanently remove all profile's associated data
  */
 public function removeAllProfilesData($profile_id)
 {
     // check if exists
     $profile = $this->getProfileByField('id', $profile_id);
     if (!$profile) {
         return false;
     }
     $Images = new Application_Model_Images();
     $Images->removeUsersImages($profile_id);
     $Albums = new Application_Model_Albums();
     $Albums->deleteAlbums($profile_id);
     $Comments = new Application_Model_Comments();
     $Comments->deleteComments($profile_id);
     $Connections = new Application_Model_Connections();
     $Connections->removeUsersConnections($profile_id);
     $Likes = new Application_Model_Likes();
     $Likes->removeUsersLikes($profile_id);
     $Notifications = new Application_Model_Notifications();
     $Notifications->removeUsersNotifications($profile_id);
     $Reports = new Application_Model_Reports();
     $Reports->removeUsersReports($profile_id);
     $Posts = new Application_Model_Posts();
     $Posts->removeUsersPosts($profile_id);
     $Messages = new Application_Model_Messages();
     $Messages->removeUsersMessages($profile_id);
     $ProfilesMeta = new Application_Model_ProfilesMeta();
     $ProfilesMeta->removeMetaForProfile($profile_id);
     return true;
 }
 /**
  * Update reported resource (via ajax)
  */
 public function updatereportedAction()
 {
     $report_id = (int) $this->getRequest()->getParam('report_id');
     $mark_reported = (int) $this->getRequest()->getParam('mark_reported');
     $Reports = new Application_Model_Reports();
     $report = $Reports->getReport($report_id);
     $ret = false;
     if ($mark_reported == 1) {
         switch ($report['resource_type']) {
             case 'post':
                 // posts
                 $Posts = new Application_Model_Posts();
                 $ret = $Posts->markHidden($report['resource_id']);
                 break;
             case 'user':
             case 'group':
             case 'page':
                 // profiles
                 $Profiles = new Application_Model_Profiles();
                 $ret = $Profiles->markHidden($report['resource_id']);
                 break;
             case 'message':
                 // messages
                 $Messages = new Application_Model_Messages();
                 $ret = $Messages->markHidden($report['resource_id']);
                 break;
             case 'comment':
                 // comments
                 $Comments = new Application_Model_Comments();
                 $ret = $Comments->deleteComment($report['resource_id']);
                 break;
             case 'image':
                 // images
                 $Images = new Application_Model_Images();
                 $ret = $Images->deleteImage($report['resource_id'], 'posts');
                 $Reports->clearReports($report['resource_id'], 'image');
                 break;
             default:
                 break;
         }
     }
     $Reports->updateReport($report_id, $mark_reported);
     $this->getHelper('json')->sendJson($ret);
 }
Ejemplo n.º 6
0
 public function sentmessagesAction()
 {
     if ($this->auth->hasIdentity()) {
         $sentmess = new Application_Model_Messages($this->registry['DB']);
         $this->view->mydetails = $this->authIdentity;
         $this->view->results = $sentmess->sentMessages();
     }
 }