コード例 #1
0
 /**
  * Main Feed / Login Page
  */
 public function indexAction()
 {
     $request = $this->getRequest();
     $Connections = new Application_Model_Connections();
     $limit = Zend_Registry::get('config')->get('sidebar_max_users');
     // put addPost form on the front page
     $this->_helper->addPostFormLoader();
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->view->sidebar_myprofile = true;
     } else {
         $this->view->sidebar_login = true;
     }
     // attach sidebar box
     Zend_Registry::get('hooks')->attach('hook_view_sidebar', 2, function () {
         echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/myprofile.phtml');
         echo Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view->render('/_sidebar/loginregister.phtml');
     });
     // load initial posts
     $Posts = new Application_Model_Posts();
     // Add coment form
     $add_comment_form = new Application_Form_AddComment();
     $this->view->add_comment_form = $add_comment_form;
     // offset infinite scroll
     if ($this->view->post_page_number) {
         $Posts->page_number = $this->view->post_page_number;
     }
     $data = $Posts->getPosts();
     $this->view->posts_data = $data;
     $this->view->profile_type = 'feed';
     // continue to load posts with ajax
     if (count($data) >= Zend_Registry::get('config')->get('limit_posts')) {
         $this->view->php_loadPostURL = $this->_helper->url->url(array('controller' => 'posts', 'action' => 'load'), 'default', true);
     }
     // auto show image (shares)
     $image_uid = $request->getParam('showimage', 0);
     if ($image_uid) {
         if (!Zend_Auth::getInstance()->hasIdentity()) {
             $this->redirect('');
         }
         $Images = new Application_Model_Images();
         $image = $Images->getImageByUID($image_uid);
         if (isset($image)) {
             $this->view->auto_show_image = $image['id'];
             $this->view->auto_show_image_file_name = $image['file_name'];
         } else {
             Application_Plugin_Alerts::error($this->view->translate('Resource does not exists'), 'on');
             $this->redirect('');
         }
     }
 }
コード例 #2
0
ファイル: Comments.php プロジェクト: georgepaul/socialstrap
 /**
  * Add comment
  */
 public function addComment($content, $resource_id, $resource_type)
 {
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         return false;
     }
     if (!is_string($content) || !is_string($resource_type) || strlen($content) < 1) {
         return false;
     }
     $content = Application_Plugin_Common::limitInput($content);
     $author_id = Zend_Auth::getInstance()->getIdentity()->id;
     // find resource author
     switch ($resource_type) {
         case 'post':
             $Posts = new Application_Model_Posts();
             $resource_author = $Posts->getPostAuthorId($resource_id);
             $resource_wall = $Posts->getPostsWallProfileData($resource_id);
             // for page comments written by page admin switch owner to be a page itself
             if ($resource_wall['type'] == 'page' && $resource_wall['owner'] == $author_id) {
                 $author_id = $resource_wall['id'];
                 $resource_author = $author_id;
             }
             break;
         case 'image':
             $Images = new Application_Model_Images();
             $image = $Images->getImage($resource_id);
             $resource_author = $image['data']['uploaded_by'];
             break;
         default:
             $resource_author = 0;
             break;
     }
     $ret = $this->insert(array('author_id' => $author_id, 'resource_type' => $resource_type, 'resource_id' => $resource_id, 'created_on' => Application_Plugin_Common::now(), 'content' => $content, 'is_hidden' => 0));
     $this->markOldAsHidden($resource_type, $resource_id);
     $Notifications = new Application_Model_Notifications();
     // notify all users involved in comment discussion
     $notify_users = $this->getUsersCommented($resource_type, $resource_id, true);
     // notify resource author if not already on the list
     if (array_search($resource_author, $notify_users) === false) {
         $notify_users[] = $resource_author;
     }
     $Notifications->pushNotification($notify_users, 1, 'comment', $ret);
     // trigger hooks
     $data = array('comment_id' => $ret, 'content' => $content);
     Zend_Registry::get('hooks')->trigger('hook_data_aftersavecomment', $data);
     return $ret;
 }
コード例 #3
0
ファイル: Likes.php プロジェクト: georgepaul/socialstrap
 /**
  * Like toggle
  */
 public function toggleLike($resource_id, $resource_type)
 {
     if (!Zend_Auth::getInstance()->hasIdentity() || !$resource_id || !$resource_type) {
         return null;
     }
     $user_id = Zend_Auth::getInstance()->getIdentity()->id;
     if ($this->isLiked($resource_id, $resource_type)) {
         $result = $this->delete(array('resource_id = ?' => (int) $resource_id, 'resource_type = ?' => $resource_type, 'user_id = ?' => (int) $user_id));
         $state = 0;
     } else {
         $data = array('user_id' => (int) $user_id, 'resource_type' => $resource_type, 'resource_id' => (int) $resource_id, 'created_on' => Application_Plugin_Common::now());
         $ret = $this->insert($data);
         $state = 1;
     }
     $likes_count = $this->getLikesCount($resource_id, $resource_type);
     // notify author
     $Notifications = new Application_Model_Notifications();
     if ($state == 1) {
         // find resource author
         switch ($resource_type) {
             case 'post':
                 $Posts = new Application_Model_Posts();
                 $resource_author = array($Posts->getPostAuthorId($resource_id));
                 break;
             case 'comment':
                 $Comments = new Application_Model_Comments();
                 $resource_author = array($Comments->getCommentAuthorId($resource_id));
                 break;
             case 'image':
                 $Images = new Application_Model_Images();
                 $resource_author = array($Images->getImageOwnerId($resource_id));
                 break;
             default:
                 $resource_author = false;
                 break;
         }
         if ($resource_author) {
             // notify resource owner
             $Notifications->pushNotification($resource_author, 2, 'like', $ret);
         }
     }
     return array('count' => $likes_count, 'state' => $state);
 }
コード例 #4
0
ファイル: Activity.php プロジェクト: abdulnizam/zend-freniz
 public function myStreams($ruserid)
 {
     if (isset($this->authIdentity)) {
         $sql = $this->_db->select()->from('activity', array('activityid', 'userid', 'ruserid', 'contentid', 'title', 'contenttype', 'contenturl', 'alternate_contentid', 'date'))->joinLeft('freniz', 'freniz.userid=activity.ruserid', array('ruserid' => 'userid', 'rusername' => 'username', 'ruserurl' => 'url'))->joinLeft('image', 'image.imageid=freniz.propic', 'image.url as ruserimageurl')->where('ruserid=?', $ruserid)->where('(contenttype=\'post\' and activity.title=\'posted on\') or (contenttype=\'video\' and activity.title=\'post a video on\') or (contenttype=\'image\' and activity.title=\'post image\' and activity.userid!=?) or (contenttype in (\'propic\',\'basicinfo\',\'personalinfo\',\'mood\',\'city\'))', $ruserid);
         $results = $this->_db->fetchAssoc($sql);
         $myStreamsMapper = array();
         foreach ($results as $id => $values) {
             switch ($values['contenttype']) {
                 case 'post':
                     $myStreamsMapper['posts'][$id] = $values['contentid'];
                     break;
                 case 'image':
                     $myStreamsMapper['images'][$id] = $values['contentid'];
                     break;
                 case 'video':
                     $myStreamsMapper['videos'][$id] = $values['contentid'];
                     break;
             }
         }
         if (!empty($myStreamsMapper['posts'])) {
             $posts = new Application_Model_Post($this->_db);
             $myStream_results['post'] = $posts->getPosts($myStreamsMapper['posts']);
         }
         if (!empty($myStreamsMapper['images'])) {
             $images = new Application_Model_Images($this->_db);
             $myStream_results['image'] = $images->getArrayOfImages($myStreamsMapper['images']);
         }
         if (!empty($myStreamsMapper['videos'])) {
             $videos = new Application_Model_Videos($this->_db);
             $myStream_results['video'] = $videos->getVideos($myStreamsMapper['videos']);
         }
         $final_results['mystream'] = $results;
         $final_results['results'] = $myStream_results;
         $sql = $this->_db->select()->from('commentactivity', 'max(id) as maxcomment');
         $result = $this->_db->fetchRow($sql);
         $final_results['maxcomment'] = $result['maxcomment'];
         return $final_results;
     }
 }
コード例 #5
0
 public function placesAction()
 {
     $getimage = new Application_Model_Images($this->registry['DB']);
     //$imageid=$this->getRequest()->getParam('imageid');
     //$this->view->results=$this->authIdentity;
     $this->view->results = $getimage->getImages('10', 'image');
     //$this->_helper->viewRenderer->setNoRender(true);
     //$this->getResponse()->setBody(json_encode($places->uploadImage($album)));
     //$this->view->results= $places->getUserDetailts('leaf_1164721637_31408804');
     //$this->view->results= $places->doComment(1, 'ifadfja');
 }
コード例 #6
0
 /**
  * rotate image (via ajax)
  */
 public function rotateimageAction()
 {
     $request = $this->getRequest();
     $image_id = $request->getParam('resource_id');
     $Images = new Application_Model_Images();
     $ret = $Images->rotateImage($image_id);
     $this->getHelper('json')->sendJson($ret);
 }
コード例 #7
0
 public function deleteimagecommentAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     if ($this->authIdentity->userid) {
         $deleteimagecomment = new Application_Model_Images($this->registry['DB']);
         $commentid = $this->getRequest()->getParam('commentid');
         $deleteimagecomment->deleteimageComment($commentid);
         echo json_encode(array('status' => 'success'));
     } else {
         echo json_encode(array('status' => 'error'));
     }
 }
コード例 #8
0
ファイル: Profiles.php プロジェクト: georgepaul/socialstrap
 /**
  * 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;
 }
コード例 #9
0
 /**
  * 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);
 }
コード例 #10
0
 public function reviewpinreqAction()
 {
     $this->_helper->viewRenderer->setNoRender();
     if ($this->authidentity->userid) {
         $imageid = $this->getRequest()->getParam('imageid');
         $accept = $this->getRequest()->getParam('accept');
         if ($accept == 'true') {
             $accept = true;
         } else {
             $accept = false;
         }
         $ImageModel = new Application_Model_Images($this->registry->DB);
         $this->view->result = $ImageModel->reviewPinReq($imageid, $accept);
         echo json_encode(array('status' => 'success'));
     } else {
         echo json_encode(array('status' => 'error'));
     }
 }
コード例 #11
0
 /**
  * Show images
  */
 public function imagesAction()
 {
     $Images = new Application_Model_Images();
     $Albums = new Application_Model_Albums();
     $request = $this->getRequest();
     // flush if user not found
     if (!$this->profile) {
         $this->redirect('');
     }
     $page = (int) $request->getParam('page');
     if ($page < 1) {
         $page = 1;
     }
     $album_id = $request->getParam('album', false);
     $current_album_count = $Images->getImages($this->profile->id, $album_id, true);
     $Images->page_number = $page;
     $this->view->images = $Images->getImages($this->profile->id, $album_id);
     $this->view->pagination_last_page = (int) ceil($current_album_count / (int) Zend_Registry::get('config')->get('pagination_limit'));
     $this->view->pagination_current_page = $page;
     $this->prepareProfile($this->profile);
     $this->prepareImagesAlbumsCount();
     if (!$album_id) {
         $this->view->active_item = 'all';
         $this->view->context = 'images';
     } else {
         $album = $Albums->getAlbum($album_id);
         $this->view->active_item_id = $album['id'];
         $this->view->active_item = $album['name'] . ' (' . $current_album_count . ')';
         $this->view->context = 'album';
     }
     $this->render('images');
 }
コード例 #12
0
ファイル: Posts.php プロジェクト: georgepaul/songslikesocial
 /**
  * Delete post
  */
 public function deletePost($post_id)
 {
     $post_wall_data = $this->getPostsWallProfileData($post_id);
     // check if my post or on my wall
     if ($this->getPostAuthorId($post_id) != Zend_Auth::getInstance()->getIdentity()->id && $post_wall_data['owner'] != Zend_Auth::getInstance()->getIdentity()->id && $this->getPostWallId($post_id) != Zend_Auth::getInstance()->getIdentity()->id && Zend_Auth::getInstance()->getIdentity()->role !== 'admin' && Zend_Auth::getInstance()->getIdentity()->role !== 'reviewer') {
         return false;
     }
     // delete post's images
     $Images = new Application_Model_Images();
     $Images->deletePostImages($post_id);
     // delete post's meta data
     $PostsMeta = new Application_Model_PostsMeta();
     $PostsMeta->metaRemove($post_id);
     // delete connected comments, likes and reports
     $this->deleteConnectedResourcesData('post', $post_id);
     // delete post and return
     return $this->delete(array('id = ?' => $post_id));
 }
コード例 #13
0
 public function getwallphotosAction()
 {
     if (isset($this->authIdentity)) {
         $get = new Application_Model_Images($this->registry['DB']);
         $id = $this->getRequest()->getParam('id');
         $this->view->results = $get->getbanners($id);
     }
 }
コード例 #14
0
 /**
  * Receive uploaded files (ajax/blueimp)
  */
 public function receivefileAction()
 {
     $ret = Zend_Registry::get('Zend_Translate')->translate('Server-side error');
     if ($this->getRequest()->isPost()) {
         $Images = new Application_Model_Images();
         $adapter = new Zend_File_Transfer_Adapter_Http();
         $adapter->addValidator('Extension', false, 'jpg,jpeg,png,gif');
         $files = $adapter->getFileInfo();
         $receive_to = $this->getRequest()->getParam('to');
         $form_unique_key = (int) $this->getRequest()->getParam('form_unique_key');
         $current_user_id = Zend_Auth::getInstance()->getIdentity()->id;
         $current_user_role = Zend_Auth::getInstance()->getIdentity()->role;
         foreach ($files as $file => $info) {
             // file uploaded & is valid
             if (!$adapter->isUploaded($file)) {
                 continue;
             }
             if (!$adapter->isValid($file)) {
                 continue;
             }
             // check max file size
             if ($info['size'] > Zend_Registry::get('config')->get('max_file_upload_size')) {
                 continue;
             }
             $filename = $adapter->getFileName($file);
             $extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
             $fileinfo = $adapter->getFileInfo($file);
             $filesize = $fileinfo[$file]['size'];
             $profilename = Zend_Auth::getInstance()->getIdentity()->name;
             $randomstring = Application_Plugin_Common::getRandomString();
             // generate tmp filename
             $tmp_filename = 'post_' . $profilename . '_' . $form_unique_key . '_' . $randomstring . '.' . $extension;
             $tmp_filename_full = TMP_PATH . '/' . $tmp_filename;
             // set to rename uploaded file upon receiving to tmp folder
             $adapter->setDestination(TMP_PATH);
             $adapter->addFilter('rename', $tmp_filename_full);
             // receive the files into the tmp directory, must have
             $adapter->receive($file);
             // check if valid image
             if (!Application_Plugin_ImageLib::isValidImage($tmp_filename_full)) {
                 unlink($tmp_filename_full);
                 continue;
             }
             // check storage limits
             $max_files_per_user = 0 + Zend_Registry::get('config')->get('max_files_per_user');
             $max_storage_per_user = 0 + Zend_Registry::get('config')->get('max_storage_per_user');
             if ($current_user_role == 'user' && ($max_files_per_user || $max_storage_per_user)) {
                 $storage_usage = $Images->getStorageUsage($current_user_id);
                 if ($max_files_per_user && $storage_usage['image_count'] > $max_files_per_user || $max_storage_per_user && $storage_usage['image_size'] > $max_storage_per_user) {
                     $ret = Zend_Registry::get('Zend_Translate')->translate('Storage limits reached');
                     unlink($tmp_filename_full);
                     continue;
                 }
             }
             if ($receive_to !== 'tmp') {
                 // receive to album, check if user is an album owner
                 if ($receive_to > 0) {
                     $Albums = new Application_Model_Albums();
                     $album = $Albums->getAlbum($receive_to);
                     // exit on wrong album
                     if (!$album || $album['user_id'] != $current_user_id) {
                         $this->_helper->json(false);
                         return;
                     }
                 }
                 $Storage = new Application_Model_Storage();
                 $StorageAdapter = $Storage->getAdapter();
                 $original_filename = '';
                 if (Zend_Registry::get('config')->get('resample_images')) {
                     Application_Plugin_ImageLib::resample(TMP_PATH . '/' . $tmp_filename, TMP_PATH . '/thumb_' . $tmp_filename);
                     $image_filename = $StorageAdapter->moveFileToStorage('thumb_' . $tmp_filename, 'posts');
                     if (Zend_Registry::get('config')->get('keep_original')) {
                         $original_filename = $StorageAdapter->moveFileToStorage($tmp_filename, 'posts');
                     } else {
                         $original_filename = '';
                         unlink(TMP_PATH . '/' . $tmp_filename);
                         // clean up
                     }
                 } else {
                     $image_filename = $StorageAdapter->moveFileToStorage($tmp_filename, 'posts');
                 }
                 if ($image_filename) {
                     $ret = $Images->addImage($image_filename, $filesize, $current_user_id, $current_user_id, 0, $receive_to, $original_filename);
                 }
             }
             $ret = true;
         }
     }
     $this->_helper->json($ret);
 }
コード例 #15
0
 /**
  * get share modal content (via ajax)
  */
 public function shareAction()
 {
     $request = $this->getRequest();
     $resource_type = $request->getParam('resource_type', 0);
     $resource_id = $request->getParam('resource_id', 0);
     $base_link = Application_Plugin_Common::getFullBaseUrl();
     $repost_link = false;
     switch ($resource_type) {
         case 'post':
             $Posts = new Application_Model_Posts();
             $post = $Posts->getPost($resource_id);
             $profile = $Posts->getProfileDataByPostWall($resource_id);
             $profile_name = $profile['name'];
             $direct_link = $base_link . '/profiles/showpost/name/' . $profile_name . '/post/' . $resource_id;
             $repost_link = $base_link . '/posts/repost/post_id/' . $resource_id;
             break;
         case 'profile':
             $direct_link = $base_link . '/' . $resource_id;
             break;
         case 'image':
             $Images = new Application_Model_Images();
             $image = $Images->getImage($resource_id);
             $direct_link = $base_link . '/index/index/showimage/' . $image['data']['uid'];
             break;
         default:
             $direct_link = $base_link;
             break;
     }
     // drop repost link if not logged in
     if (!Zend_Auth::getInstance()->hasIdentity()) {
         $repost_link = false;
     }
     $this->view->repost_link = $repost_link;
     $this->view->direct_link = $direct_link;
     // trigger hooks
     Zend_Registry::get('hooks')->trigger('hook_app_share', $this);
     $html = $this->view->render('/partial/share_modal_content.phtml');
     $this->getHelper('json')->sendJson($html);
 }