Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 5696 | Rev 5775 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 5696 Rev 5765
Línea 29... Línea 29...
29
use LeadersLinked\Mapper\ConnectionMapper;
29
use LeadersLinked\Mapper\ConnectionMapper;
30
use LeadersLinked\Mapper\CompanyFollowerMapper;
30
use LeadersLinked\Mapper\CompanyFollowerMapper;
31
use LeadersLinked\Mapper\QueryMapper;
31
use LeadersLinked\Mapper\QueryMapper;
32
use Laminas\Paginator\Paginator;
32
use Laminas\Paginator\Paginator;
33
use Laminas\Paginator\Adapter\DbSelect;
33
use Laminas\Paginator\Adapter\DbSelect;
34
use LeadersLinked\Mapper\LikeMapper;
34
use LeadersLinked\Mapper\ContentReactionMapper;
35
use LeadersLinked\Model\Like;
35
use LeadersLinked\Model\ContentReaction;
36
use LeadersLinked\Form\Feed\CommentForm;
36
use LeadersLinked\Form\Feed\CommentForm;
37
use LeadersLinked\Model\Comment;
37
use LeadersLinked\Model\Comment;
38
use LeadersLinked\Form\Feed\CreateGroupCompanyForm;
38
use LeadersLinked\Form\Feed\CreateGroupCompanyForm;
39
use LeadersLinked\Model\CompanyUser;
39
use LeadersLinked\Model\CompanyUser;
40
use LeadersLinked\Model\VideoConvert;
40
use LeadersLinked\Model\VideoConvert;
Línea 851... Línea 851...
851
                'success'   => false,
851
                'success'   => false,
852
                'data'   => $messages
852
                'data'   => $messages
853
            ];
853
            ];
854
        }
854
        }
855
    }
855
    }
-
 
856
    
-
 
857
    public function saveReactionAction()
-
 
858
    {
-
 
859
        $id = $this->params()->fromRoute('id');
-
 
860
        $reaction  = $this->params()->fromRoute('reaction');
-
 
861
        
-
 
862
        $request = $this->getRequest();
-
 
863
        if ($request->isPost()) {
-
 
864
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
865
            $currentUser = $currentUserPlugin->getUser();
-
 
866
            
-
 
867
            
-
 
868
            $feedMapper = FeedMapper::getInstance($this->adapter);
-
 
869
            $feed = $feedMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
-
 
870
            if (!$feed) {
-
 
871
                $response = [
-
 
872
                    'success' => false,
-
 
873
                    'data' => 'ERROR_POST_NOT_FOUND'
-
 
874
                ];
-
 
875
                return new JsonModel($response);
-
 
876
            }
-
 
877
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
-
 
878
            $contentReaction = $contentReactionMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
-
 
879
            
-
 
880
            if ($contentReaction) {
-
 
881
                $response = [
-
 
882
                    'success' => false,
-
 
883
                    'data' => 'ERROR_DUPLICATE_ACTION'
-
 
884
                ];
-
 
885
                return new JsonModel($response);
-
 
886
            }
-
 
887
            
-
 
888
            $contentReaction = new ContentReaction();
-
 
889
            $contentReaction->user_id = $currentUser->id;
-
 
890
            $contentReaction->feed_id_id = $feed->id;
-
 
891
            $contentReaction->relational = ContentReaction::RELATIONAL_FEED;
-
 
892
            $contentReaction->reaction = $reaction;
-
 
893
            
-
 
894
            if ($contentReactionMapper->insert($contentReaction)) {
-
 
895
                
-
 
896
                $reactions = $contentReactionMapper->fetchCountContentReactionsByFeedId($feed->id);
-
 
897
                $response = [
-
 
898
                    'success' => true,
-
 
899
                    'data' => [
-
 
900
                        'likes' => $reactions
-
 
901
                    ]
-
 
902
                ];
-
 
903
            } else {
-
 
904
                $response = [
-
 
905
                    'success' => false,
-
 
906
                    'data' => $contentReactionMapper->getError()
-
 
907
                ];
-
 
908
            }
-
 
909
            return new JsonModel($response);
-
 
910
        }
-
 
911
        
-
 
912
        $response = [
-
 
913
            'success' => false,
-
 
914
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
915
        ];
-
 
916
        return new JsonModel($response);
-
 
917
    }
-
 
918
    
-
 
919
    public function deleteReactionAction()
-
 
920
    {
-
 
921
        $id = $this->params()->fromRoute('id');
-
 
922
        
-
 
923
        $request = $this->getRequest();
-
 
924
        if ($request->isPost()) {
-
 
925
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
926
            $currentUser = $currentUserPlugin->getUser();
-
 
927
            
-
 
928
            $feedMapper = FeedMapper::getInstance($this->adapter);
-
 
929
            $feed = $feedMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
-
 
930
            if (!$feed) {
-
 
931
                $response = [
-
 
932
                    'success' => false,
-
 
933
                    'data' => 'ERROR_POST_NOT_FOUND'
-
 
934
                ];
-
 
935
                return new JsonModel($response);
-
 
936
            }
-
 
937
            
-
 
938
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
-
 
939
            $like = $contentReactionMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
-
 
940
            
-
 
941
            if (!$like) {
-
 
942
                $response = [
-
 
943
                    'success' => false,
-
 
944
                    'data' => 'ERROR_DUPLICATE_ACTION'
-
 
945
                ];
-
 
946
                return new JsonModel($response);
-
 
947
            }
-
 
948
            
-
 
949
            if ($contentReactionMapper->deleteByFeedIdAndUserId($feed->id, $currentUser->id)) {
-
 
950
                $reactions = $contentReactionMapper->fetchCountContentReactionByFeedId($feed->id);
-
 
951
                
-
 
952
                
-
 
953
                $response = [
-
 
954
                    'success' => true,
-
 
955
                    'data' => [
-
 
956
                        'reactions' => $reactions
-
 
957
                    ]
-
 
958
                ];
-
 
959
            } else {
-
 
960
                $response = [
-
 
961
                    'success' => false,
-
 
962
                    'data' => $contentReactionMapper->getError()
-
 
963
                ];
-
 
964
            }
-
 
965
            return new JsonModel($response);
-
 
966
        }
-
 
967
        
-
 
968
        $response = [
-
 
969
            'success' => false,
-
 
970
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
971
        ];
-
 
972
        return new JsonModel($response);
-
 
973
    }
Línea -... Línea 974...
-
 
974
 
856
 
975
    /*
857
    public function likeAction()
976
    public function likeAction()
858
    {
977
    {
Línea 859... Línea 978...
859
        $id = $this->params()->fromRoute('id');
978
        $id = $this->params()->fromRoute('id');
Línea 872... Línea 991...
872
                    'data' => 'ERROR_POST_NOT_FOUND'
991
                    'data' => 'ERROR_POST_NOT_FOUND'
873
                ];
992
                ];
874
                return new JsonModel($response);
993
                return new JsonModel($response);
875
            }
994
            }
Línea 876... Línea 995...
876
 
995
 
877
            $likeMapper = LikeMapper::getInstance($this->adapter);
996
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
Línea 878... Línea 997...
878
            $like = $likeMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
997
            $contentReaction =  $contentReactionMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
879
 
998
 
880
            if ($like) {
999
            if ($contentReaction) {
881
                $response = [
1000
                $response = [
882
                    'success' => false,
1001
                    'success' => false,
883
                    'data' => 'ERROR_DUPLICATE_ACTION'
1002
                    'data' => 'ERROR_DUPLICATE_ACTION'
Línea 1020... Línea 1139...
1020
        $response = [
1139
        $response = [
1021
            'success' => false,
1140
            'success' => false,
1022
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1141
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
1023
        ];
1142
        ];
1024
        return new JsonModel($response);
1143
        return new JsonModel($response);
1025
    }
1144
    }*/
Línea 1026... Línea 1145...
1026
 
1145
 
1027
    public function timelineAction()
1146
    public function timelineAction()
1028
    {
1147
    {
1029
        $utilMapper = UtilMapper::getInstance($this->adapter);
1148
        $utilMapper = UtilMapper::getInstance($this->adapter);
Línea 1330... Línea 1449...
1330
        $feed = $feedMapper->fetchOneAnyStatus($feed_id);
1449
        $feed = $feedMapper->fetchOneAnyStatus($feed_id);
Línea 1331... Línea 1450...
1331
 
1450
 
1332
 
1451
 
1333
 
1452
 
1334
 
1453
 
-
 
1454
        /*
-
 
1455
        $likeMapper = LikeMapper::getInstance($this->adapter);
-
 
1456
        $like = $likeMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
-
 
1457
        $likes = $likeMapper->fetchCountLikeByFeedId($feed->id);
-
 
1458
        */
1335
 
1459
        $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
1336
        $likeMapper = LikeMapper::getInstance($this->adapter);
1460
        $reactions = $contentReactionMapper->fetchCountContentReactionsByFeedId($feed->id);
1337
        $like = $likeMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
1461
        $reaction = $contentReactionMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
1338
        $likes = $likeMapper->fetchCountLikeByFeedId($feed->id);
1462
        
1339
 
1463
        
1340
        $params = [
1464
        $params = [
Línea 1383... Línea 1507...
1383
        $share_increment_external_counter_url = $this->url()->fromRoute('share/increment-external-counter', $share_params, ['force_canonical' => true]);
1507
        $share_increment_external_counter_url = $this->url()->fromRoute('share/increment-external-counter', $share_params, ['force_canonical' => true]);
Línea 1384... Línea 1508...
1384
 
1508
 
Línea -... Línea 1509...
-
 
1509
 
-
 
1510
        $share_external_url = $this->url()->fromRoute('shorter/generate', ['code' => $feed->uuid, 'type' => 'feed'], ['force_canonical' => true]);
-
 
1511
 
-
 
1512
        
-
 
1513
        
-
 
1514
        $params_reaction = array_merge($params, ['reaction' => ContentReaction::REACTION_RECOMMENDED]);
-
 
1515
        $feed_save_reaction_recommended = $this->url()->fromRoute('feed/save-reaction', $params_reaction);
-
 
1516
        
-
 
1517
        $params_reaction = array_merge($params, ['reaction' => ContentReaction::REACTION_SUPPORT]);
-
 
1518
        $feed_save_reaction_support = $this->url()->fromRoute('feed/save-reaction', $params_reaction);
-
 
1519
        
-
 
1520
        $params_reaction = array_merge($params, ['reaction' => ContentReaction::REACTION_LOVE]);
-
 
1521
        $feed_save_reaction_love = $this->url()->fromRoute('feed/save-reaction', $params_reaction);
-
 
1522
        
-
 
1523
        $params_reaction = array_merge($params, ['reaction' => ContentReaction::REACTION_INTEREST]);
-
 
1524
        $feed_save_reaction_interest = $this->url()->fromRoute('feed/save-reaction', $params_reaction);
-
 
1525
        
-
 
1526
        $params_reaction = array_merge($params, ['reaction' => ContentReaction::REACTION_FUN]);
-
 
1527
        $feed_save_reaction_fun = $this->url()->fromRoute('feed/save-reaction', $params_reaction);
1385
 
1528
        
1386
        $share_external_url = $this->url()->fromRoute('shorter/generate', ['code' => $feed->uuid, 'type' => 'feed'], ['force_canonical' => true]);
1529
        
1387
 
1530
        
-
 
1531
        $item = [
-
 
1532
            'feed_unique' => uniqid(),
-
 
1533
            'feed_uuid' => $feed->uuid,
1388
        $item = [
1534
            'feed_my_reaction' => $reaction ? $reaction->reaction : '',
1389
            'feed_unique' => uniqid(),
1535
            'feed_save_reaction_recommended_url' => $feed_save_reaction_recommended,
-
 
1536
            'feed_save_reaction_support_url' => $feed_save_reaction_support,
1390
            'feed_uuid' => $feed->uuid,
1537
            'feed_save_reaction_love_url' => $feed_save_reaction_love,
1391
            'feed_is_liked' => $like ? true : false,
1538
            'feed_save_reaction_interest_url' => $feed_save_reaction_interest,
1392
            'feed_like_url' => $this->url()->fromRoute('feed/like',  $params),
1539
            'feed_save_reaction_fun_url' => $feed_save_reaction_fun,
1393
            'feed_unlike_url' => $this->url()->fromRoute('feed/unlike',  $params),
1540
            'feed_delete_reaction_url' =>  $this->url()->fromRoute('feed/delete-reaction',  $params),
1394
            'feed_share_url' => $this->url()->fromRoute('feed/share',  $params),
1541
            'feed_share_url' => $this->url()->fromRoute('feed/share',  $params),
1395
            'feed_share_external_url' => $share_external_url,
1542
            'feed_share_external_url' => $share_external_url,
1396
            'feed_increment_external_counter_url' => $share_increment_external_counter_url,
1543
            'feed_increment_external_counter_url' => $share_increment_external_counter_url,
1397
            'feed_delete_url' =>  '',
1544
            'feed_delete_url' =>  '',
-
 
1545
            'feed_content_type' => $feed->file_type ? $feed->file_type : '',
-
 
1546
            'feed_reactions' =>  $reactions,
-
 
1547
            'feed_highlighted' => $feed->id == $feedHighlighted ? 1 : 0,
Línea 1398... Línea 1548...
1398
            'feed_content_type' => $feed->file_type ? $feed->file_type : '',
1548
            //'is_liked' => $like ? 1 : 0,
Línea 1399... Línea 1549...
1399
            'feed_likes' =>  $likes,
1549
            //'like_url' => $this->url()->fromRoute('post/like', ['id' => $post->uuid]),