Example #1
0
 public static function getInstance()
 {
     if (!is_object(self::$_instance)) {
         self::$_instance = new Application_Model_Reports();
     }
     return self::$_instance;
 }
 public function getReportsAction()
 {
     // die("ok");
     $objReportModel = Application_Model_Reports::getInstance();
     if ($this->getRequest()->isPost()) {
         $reportId = $this->getRequest()->getPost('reportId');
         $result = $objReportModel->getReportDetails($reportId);
         if ($result) {
             echo json_encode($result);
         } else {
             return 0;
         }
     } else {
         die("not a post");
     }
 }
Example #3
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;
 }
 /**
  * Edit comment
  */
 public function editcommentAction()
 {
     $Reports = new Application_Model_Reports();
     $total_counts = $Reports->getTotalCount();
     $this->buildMenu($total_counts);
     $request = $this->getRequest();
     $page = (int) $request->getParam('page');
     $comment_id = (int) $request->getParam('comment');
     $Comments = new Application_Model_Comments();
     $comment = $Comments->getComment($comment_id);
     // load and fill up form
     $edit_comment_form = new Application_Form_EditComment();
     $edit_comment_form->getElement('comment')->setValue($comment['content']);
     $this->view->edit_comment_form = $edit_comment_form;
     if ($request->isPost() && $edit_comment_form->isValid($_POST)) {
         $comment_content = $edit_comment_form->getElement('comment')->getValue();
         $comment_content = Application_Plugin_Common::prepareComment($comment_content);
         // drop on false
         if ($comment_content === false) {
             return;
         }
         $Comments->updateComment($comment_id, $comment_content);
         Application_Plugin_Alerts::success($this->view->translate('Comment updated'));
         if ($page > 0) {
             $this->redirect('reports/reviewcomments/page/' . $page);
         }
     }
 }
 /**
  * Prepare profile for cover view
  */
 public function prepareProfile($profile)
 {
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $current_user = (int) Zend_Auth::getInstance()->getIdentity()->id;
     } else {
         $current_user = 0;
     }
     $Images = new Application_Model_Images();
     $Connections = new Application_Model_Connections();
     $Reports = new Application_Model_Reports();
     $ProfilesMeta = new Application_Model_ProfilesMeta();
     $meta_values = $ProfilesMeta->getMetaValues($profile->id);
     // user's data, object style
     $this->view->profile_data = $profile;
     $this->view->profile_data->meta_values = $meta_values;
     // attach sidebar box
     Zend_Registry::get('hooks')->attach('hook_view_sidebar', 5, function () {
         echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/profileinfo.phtml');
     });
     $limit = (int) Zend_Registry::get('config')->get('sidebar_max_users');
     $is_following = $Connections->isFollowing($current_user, $profile->id);
     $is_friend = $Connections->areFriends($profile->id, $current_user);
     $is_reported = $Reports->isReported($profile->id, $profile->type);
     // @formatter:off
     // check privacy
     if (isset($profile) && (Zend_Auth::getInstance()->hasIdentity() && (Zend_Auth::getInstance()->getIdentity()->role == 'admin' || Zend_Auth::getInstance()->getIdentity()->role == 'reviewer') || Zend_Auth::getInstance()->hasIdentity() && Zend_Auth::getInstance()->getIdentity()->id == $profile->id || $profile->profile_privacy === 'friends' && $is_friend || $profile->profile_privacy === 'followers' && $is_following || $profile->profile_privacy === 'everyone' && Zend_Auth::getInstance()->hasIdentity() || $profile->profile_privacy === 'public')) {
         if ($profile->type === 'group') {
             $this->view->sidebar_members = $Connections->getFriends($profile->id, $limit, false, 'user');
             $this->view->sidebar_members_count = $Connections->getFriends($profile->id, false, true);
             // attach sidebar box
             Zend_Registry::get('hooks')->attach('hook_view_sidebar', 10, function () {
                 echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/members.phtml');
             });
             // check if secret group and this is a group owner
             if ($current_user > 0 && $current_user == $profile->owner && $profile->profile_privacy === 'friends') {
                 $Connections->mix_friends = false;
                 $this->view->sidebar_approve_members = $Connections->getFollowers($profile->id);
                 $this->view->sidebar_approve_members_count = $Connections->getFollowers($profile->id, false, true);
                 // attach sidebar box
                 Zend_Registry::get('hooks')->attach('hook_view_sidebar', 10, function () {
                     echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/approvemembers.phtml');
                 });
             }
         } elseif ($profile->type === 'user') {
             // TODO: optiomize this to a single join call
             $this->view->sidebar_followers = $Connections->getFollowers($profile->id, $limit);
             $this->view->sidebar_following = $Connections->getFollowing($profile->id, $limit);
             $this->view->sidebar_friends = $Connections->getFriends($profile->id, $limit, false, 'user');
             $this->view->sidebar_followers_count = $Connections->getFollowers($profile->id, false, true);
             $this->view->sidebar_following_count = $Connections->getFollowing($profile->id, false, true);
             $this->view->sidebar_friends_count = $Connections->getFriends($profile->id, false, true);
             $this->view->sidebar_groups = $Connections->getFriends($profile->id, $limit, false, 'group');
             $this->view->sidebar_groups_count = $Connections->getFriends($profile->id, $limit, true, 'group');
             // attach sidebar box
             Zend_Registry::get('hooks')->attach('hook_view_sidebar', 10, function () {
                 echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/followers.phtml');
                 echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/following.phtml');
                 echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/friends.phtml');
                 echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/groups.phtml');
             });
         } elseif ($profile->type === 'page') {
         }
         // put images to sidebar
         // $this->view->sidebar_images_count = $Images->getImages($profile->id, false, true);
         // $this->view->sidebar_images = $Images->getImages($profile->id, false, false, $limit);
         Zend_Registry::get('hooks')->attach('hook_view_sidebar', 10, function () {
             echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/images.phtml');
         });
     }
     // @formatter:on
     // set view params
     $this->view->user_cover = true;
     $this->view->is_following = $is_following;
     $this->view->is_friend = $is_friend;
     $this->view->is_reported = $is_reported;
     // override <head> for profile pages
     if (Zend_Registry::get('config')->get('profiles_head')) {
         $content = Zend_Registry::get('config')->get('profiles_head');
         $this->view->custom_head = Application_Plugin_Common::parseProfileTags($content, $profile);
     }
     // view perspective
     $this->view->view_perspective = 'profile_view';
     return;
 }
 /**
  * get lightbox data (via ajax)
  */
 public function getlightboxdataAction()
 {
     $Comments = new Application_Model_Comments();
     $Images = new Application_Model_Images();
     $Likes = new Application_Model_Likes();
     $Reports = new Application_Model_Reports();
     $Albums = new Application_Model_Albums();
     $add_comment_form = new Application_Form_AddComment();
     $request = $this->getRequest();
     $resource_id = $request->getParam('resource_id', 0);
     $context = $request->getParam('context');
     $image = $Images->getImage($resource_id, $context);
     if (!$image) {
         $this->getHelper('json')->sendJson(false);
         return;
     }
     $resource_type = 'image';
     $this->view->resource_type = $resource_type;
     $this->view->resource_id = $resource_id;
     $this->view->context = $context;
     $dropdown_options = array();
     $this->view->can_rotate = false;
     if (Zend_Auth::getInstance()->hasIdentity()) {
         // if owner is viewing, add albums for moving
         if ($image['data']['owner_id'] == Zend_Auth::getInstance()->getIdentity()->id) {
             $albums = $Albums->getAlbums(Zend_Auth::getInstance()->getIdentity()->id, false);
             if (!empty($albums)) {
                 foreach ($albums as $album) {
                     $dropdown_options[] = array('id' => $album['id'], 'name' => Zend_Registry::get('Zend_Translate')->translate('Move to ') . $album['name']);
                 }
             }
         }
         // add move to cover / profile options
         if (!empty($dropdown_options)) {
             $dropdown_options[] = array('id' => 'divider');
         }
         $dropdown_options[] = array('id' => 'avatar', 'name' => Zend_Registry::get('Zend_Translate')->translate('Set as profile picture'));
         $dropdown_options[] = array('id' => 'cover', 'name' => Zend_Registry::get('Zend_Translate')->translate('Set as cover picture'));
         // if owner, admin or reviewer - add trash link
         if ($image['data']['uploaded_by'] == Zend_Auth::getInstance()->getIdentity()->id || Zend_Auth::getInstance()->getIdentity()->role == 'admin' || Zend_Auth::getInstance()->getIdentity()->role == 'reviewer') {
             // add trash
             $dropdown_options[] = array('id' => 'divider');
             $dropdown_options[] = array('id' => 'trash', 'name' => Zend_Registry::get('Zend_Translate')->translate('Delete Image'));
         }
         // if owner - add rotate link
         if ($image['data']['uploaded_by'] == Zend_Auth::getInstance()->getIdentity()->id) {
             $this->view->can_rotate = true;
         }
     }
     $this->view->dropdown_options = $dropdown_options;
     // comments
     $show_hidden_comments = $context == 'single' ? true : false;
     $new_comments_data = $Comments->getCommentsForResources(array($resource_id), $resource_type, $show_hidden_comments);
     $add_comment_form->reset();
     $this->view->comments = isset($new_comments_data[$resource_id]) ? $new_comments_data[$resource_id] : array();
     $this->view->add_comment_form = $add_comment_form;
     // likes
     $this->view->is_liked = $Likes->isLiked($resource_id, $resource_type);
     $this->view->likes_count = $Likes->getLikesCount($resource_id, $resource_type);
     // reports
     $this->view->is_reported = $Reports->isReported($resource_id, $resource_type);
     $this->view->resource_owner_name = 'not-used';
     $this->view->btn_title = Zend_Registry::get('Zend_Translate')->translate('Report');
     $this->view->class = 'btn btn-default btn-xs';
     $this->view->image = $image;
     $html = $this->view->render('/partial/lightbox.phtml');
     $this->getHelper('json')->sendJson($html);
 }