Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 5765 Rev 5775
Línea 139... Línea 139...
139
 
139
 
Línea 140... Línea 140...
140
 
140
 
141
            $share_external_url = $this->url()->fromRoute('shorter/generate', ['code' => $post->uuid, 'type' => 'post'], ['force_canonical' => true]);
141
            $share_external_url = $this->url()->fromRoute('shorter/generate', ['code' => $post->uuid, 'type' => 'post'], ['force_canonical' => true]);
Línea 142... Línea 142...
142
 
142
 
143
            //$contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
143
            //$contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
144
            //$like = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
144
            //$contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
Línea 174... Línea 174...
174
                'save_reaction_interest_url' => $this->url()->fromRoute('feed/save-reaction', ['id' => $post->uuid, 'reaction' => ContentReaction::REACTION_INTEREST]),
174
                'save_reaction_interest_url' => $this->url()->fromRoute('feed/save-reaction', ['id' => $post->uuid, 'reaction' => ContentReaction::REACTION_INTEREST]),
175
                'save_reaction_fun_url' => $this->url()->fromRoute('feed/save-reaction', ['id' => $post->uuid, 'reaction' => ContentReaction::REACTION_FUN]),
175
                'save_reaction_fun_url' => $this->url()->fromRoute('feed/save-reaction', ['id' => $post->uuid, 'reaction' => ContentReaction::REACTION_FUN]),
176
                'delete_reaction_url' =>  $this->url()->fromRoute('feed/delete-reaction', ['id' => $post->uuid]),
176
                'delete_reaction_url' =>  $this->url()->fromRoute('feed/delete-reaction', ['id' => $post->uuid]),
177
                'my_reaction' => $reaction ? $reaction->reaction : '',
177
                'my_reaction' => $reaction ? $reaction->reaction : '',
178
                'reactions' =>  $reactions,
178
                'reactions' =>  $reactions,
179
                //'is_liked' => $like ? 1 : 0,
179
                //'is_liked' => $contentReaction ? 1 : 0,
180
                //'like_url' => $this->url()->fromRoute('post/like', ['id' => $post->uuid]),
180
                //'like_url' => $this->url()->fromRoute('post/like', ['id' => $post->uuid]),
181
                //'unlike_url' => $this->url()->fromRoute('post/unlike', ['id' => $post->uuid]),
181
                //'unlike_url' => $this->url()->fromRoute('post/unlike', ['id' => $post->uuid]),
Línea 182... Línea 182...
182
 
182
 
183
            ]);
183
            ]);
Línea 374... Línea 374...
374
                ];
374
                ];
375
                return new JsonModel($response);
375
                return new JsonModel($response);
376
            }
376
            }
Línea 377... Línea 377...
377
 
377
 
378
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
378
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
Línea 379... Línea 379...
379
            $like = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
379
            $contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
380
 
380
 
381
            if ($like) {
381
            if ($contentReaction) {
382
                $response = [
382
                $response = [
383
                    'success' => false,
383
                    'success' => false,
384
                    'data' => 'ERROR_DUPLICATE_ACTION'
384
                    'data' => 'ERROR_DUPLICATE_ACTION'
385
                ];
385
                ];
Línea 386... Línea 386...
386
                return new JsonModel($response);
386
                return new JsonModel($response);
387
            }
387
            }
388
 
388
 
389
            $like = new Like();
389
            $contentReaction = new Like();
Línea 390... Línea 390...
390
            $like->user_id = $currentUser->id;
390
            $contentReaction->user_id = $currentUser->id;
Línea 391... Línea 391...
391
            $like->post_id = $post->id;
391
            $contentReaction->post_id = $post->id;
392
            $like->relational = Like::RELATIONAL_POST;
392
            $contentReaction->relational = Like::RELATIONAL_POST;
393
 
393
 
394
            if ($contentReactionMapper->insert($like)) {
394
            if ($contentReactionMapper->insert($contentReaction)) {
395
 
395
 
396
                $likes = $contentReactionMapper->fetchCountLikeByPostId($post->id);
396
                $contentReactions = $contentReactionMapper->fetchCountLikeByPostId($post->id);
397
                $response = [
397
                $response = [
398
                    'success' => true,
398
                    'success' => true,
399
                    'data' => [
399
                    'data' => [
400
                        'likes' => $likes
400
                        'likes' => $contentReactions
Línea 434... Línea 434...
434
                ];
434
                ];
435
                return new JsonModel($response);
435
                return new JsonModel($response);
436
            }
436
            }
Línea 437... Línea 437...
437
 
437
 
438
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
438
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
Línea 439... Línea 439...
439
            $like = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
439
            $contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
440
 
440
 
441
            if (!$like) {
441
            if (!$contentReaction) {
442
                $response = [
442
                $response = [
443
                    'success' => false,
443
                    'success' => false,
444
                    'data' => 'ERROR_DUPLICATE_ACTION'
444
                    'data' => 'ERROR_DUPLICATE_ACTION'
445
                ];
445
                ];
Línea 446... Línea 446...
446
                return new JsonModel($response);
446
                return new JsonModel($response);
447
            }
447
            }
Línea 448... Línea 448...
448
 
448
 
449
            if ($contentReactionMapper->deleteByPostIdAndUserId($post->id, $currentUser->id)) {
449
            if ($contentReactionMapper->deleteByPostIdAndUserId($post->id, $currentUser->id)) {
450
                $likes = $contentReactionMapper->fetchCountLikeByPostId($post->id);
450
                $contentReactions = $contentReactionMapper->fetchCountLikeByPostId($post->id);
451
 
451
 
452
 
452
 
453
                $response = [
453
                $response = [
454
                    'success' => true,
454
                    'success' => true,
455
                    'data' => [
455
                    'data' => [
456
                        'likes' => $likes
456
                        'likes' => $contentReactions
Línea 470... Línea 470...
470
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
470
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
471
        ];
471
        ];
472
        return new JsonModel($response);
472
        return new JsonModel($response);
473
    }*/
473
    }*/
Línea 474... Línea 474...
474
    
474
    
475
    public function likeAction()
475
    public function saveReactionAction()
476
    {
476
    {
477
        $id = $this->params()->fromRoute('id');
477
        $id = $this->params()->fromRoute('id');
Línea 478... Línea 478...
478
        $reaction  = $this->params()->fromRoute('reaction');
478
        $reaction  = $this->params()->fromRoute('reaction');
Línea 495... Línea 495...
495
            
495
            
496
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
496
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
Línea 497... Línea 497...
497
            $contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
497
            $contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
-
 
498
            
-
 
499
            if ($contentReaction) {
-
 
500
                $contentReaction->reaction = $reaction;
498
            
501
                
499
            if ($contentReaction) {
502
                $result = $contentReactionMapper->update($contentReaction);
500
                $response = [
503
            } else {
501
                    'success' => false,
504
                $contentReaction = new ContentReaction();
-
 
505
                $contentReaction->user_id = $currentUser->id;
502
                    'data' => 'ERROR_DUPLICATE_ACTION'
506
                $contentReaction->post_id = $post->id;
-
 
507
                $contentReaction->relational = ContentReaction::RELATIONAL_POST;
-
 
508
                $contentReaction->reaction = $reaction;
503
                ];
509
                
Línea 504... Línea -...
504
                return new JsonModel($response);
-
 
505
            }
-
 
506
            
-
 
507
            $contentReaction = new ContentReaction();
-
 
508
            $contentReaction->user_id = $currentUser->id;
-
 
-
 
510
                $result = $contentReactionMapper->insert($contentReaction);
Línea 509... Línea 511...
509
            $contentReaction->post_id = $post->id;
511
            }
Línea 510... Línea 512...
510
            $contentReaction->relational = ContentReaction::RELATIONAL_POST;
512
            
511
            $contentReaction->reaction = $reaction;
513
 
512
            
514
            
513
            if ($contentReactionMapper->insert($contentReaction)) {
515
            if ($result) {
514
                
516
                
515
                $reactions = $contentReactionMapper->fetchCountContentReactionsByPostId($post->id);
517
                $reactions = $contentReactionMapper->fetchCountContentReactionsByPostId($post->id);
516
                $response = [
518
                $response = [
517
                    'success' => true,
519
                    'success' => true,
518
                    'data' => [
520
                    'data' => [
519
                        'likes' => $reactions
521
                        'reactions' => $reactions
Línea 533... Línea 535...
533
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
535
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
534
        ];
536
        ];
535
        return new JsonModel($response);
537
        return new JsonModel($response);
536
    }
538
    }
Línea 537... Línea 539...
537
    
539
    
538
    public function deleteAction()
540
    public function deleteReactionAction()
539
    {
541
    {
Línea 540... Línea 542...
540
        $id = $this->params()->fromRoute('id');
542
        $id = $this->params()->fromRoute('id');
541
        
543
        
Línea 553... Línea 555...
553
                ];
555
                ];
554
                return new JsonModel($response);
556
                return new JsonModel($response);
555
            }
557
            }
Línea 556... Línea 558...
556
            
558
            
557
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
559
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
Línea 558... Línea 560...
558
            $like = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
560
            $contentReaction = $contentReactionMapper->fetchOneByPostIdAndUserId($post->id, $currentUser->id);
559
            
561
            
560
            if (!$like) {
562
            if (!$contentReaction) {
561
                $response = [
563
                $response = [
562
                    'success' => false,
564
                    'success' => false,
563
                    'data' => 'ERROR_DUPLICATE_ACTION'
565
                    'data' => 'ERROR_DUPLICATE_ACTION'