Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 15024 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 15024 Rev 15028
Línea 68... Línea 68...
68
        $this->adapter = $adapter;
68
        $this->adapter = $adapter;
69
        $this->cache = $cache;
69
        $this->cache = $cache;
70
        $this->logger = $logger;
70
        $this->logger = $logger;
71
        $this->config = $config;
71
        $this->config = $config;
72
    }
72
    }
73
 
73
    
74
    public function indexAction()
74
    public function indexAction()
75
    {
75
    {
-
 
76
        return new JsonModel([
-
 
77
            'success' => false,
-
 
78
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
79
        ]);
-
 
80
    }
-
 
81
 
-
 
82
    public function listingAction()
-
 
83
    {
76
        $request = $this->getRequest();
84
        $request = $this->getRequest();
77
        $currentUserPlugin = $this->plugin('currentUserPlugin');
85
        $currentUserPlugin = $this->plugin('currentUserPlugin');
78
        $currentCompany = $currentUserPlugin->getCompany();
86
        $currentCompany = $currentUserPlugin->getCompany();
79
        $currentUser = $currentUserPlugin->getUser();
87
        $currentUser = $currentUserPlugin->getUser();
Línea 153... Línea 161...
153
                        'link_file' => $this->url()->fromRoute('storage', ['code' => $record->uuid, 'type' => 'feed', 'filename' => $record->file_name]),
161
                        'link_file' => $this->url()->fromRoute('storage', ['code' => $record->uuid, 'type' => 'feed', 'filename' => $record->file_name]),
154
                        'status' => $record->status,
162
                        'status' => $record->status,
155
                        'preview' => $preview,
163
                        'preview' => $preview,
156
                        'actions' => [
164
                        'actions' => [
157
                            'link_edit' => ($allowEdit) ? $this->url()->fromRoute('development-and-content/edit', ['id' => $record->uuid]) : '',
165
                            'link_edit' => ($allowEdit) ? $this->url()->fromRoute('development-and-content/edit', ['id' => $record->uuid]) : '',
158
                            'link_get' => $this->url()->fromRoute('development-and-content/getContent', ['id' => $record->uuid]),
-
 
159
                            'link_aproved' => ($allowAproved) ? $this->url()->fromRoute('development-and-content/aproved', ['id' => $record->uuid]) : '',
166
                            'link_aproved' => ($allowAproved) ? $this->url()->fromRoute('development-and-content/aproved', ['id' => $record->uuid]) : '',
160
                            'link_delete' => ($allowDelete) ? $this->url()->fromRoute('development-and-content/delete', ['id' => $record->uuid]) : '',
167
                            'link_delete' => ($allowDelete) ? $this->url()->fromRoute('development-and-content/delete', ['id' => $record->uuid]) : '',
161
                        ]
168
                        ]
162
                    ];
169
                    ];
Línea 204... Línea 211...
204
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
211
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
205
            ]);
212
            ]);
206
        }
213
        }
207
    }
214
    }
Línea 208... Línea 215...
208
 
215
 
209
    public function getContentAction()
216
    public function viewAction()
210
    {
217
    {
211
        $request = $this->getRequest();
218
        $request = $this->getRequest();
212
        $currentUserPlugin = $this->plugin('currentUserPlugin');
219
        $currentUserPlugin = $this->plugin('currentUserPlugin');
213
        $currentCompany = $currentUserPlugin->getCompany();
220
        $currentCompany = $currentUserPlugin->getCompany();
Línea 629... Línea 636...
629
    {
636
    {
630
        $currentUserPlugin  = $this->plugin('currentUserPlugin');
637
        $currentUserPlugin  = $this->plugin('currentUserPlugin');
631
        $currentCompany     = $currentUserPlugin->getCompany();
638
        $currentCompany     = $currentUserPlugin->getCompany();
632
        $currentUser        = $currentUserPlugin->getUser();
639
        $currentUser        = $currentUserPlugin->getUser();
633
        $request    = $this->getRequest();
640
        $request    = $this->getRequest();
634
        try {
-
 
Línea 635... Línea -...
635
 
-
 
636
            $uuid = $this->params()->fromRoute('id');
-
 
637
            if (!$uuid) {
-
 
638
                $data = [
-
 
639
                    'success' => false,
-
 
640
                    'data' => 'ERROR_INVALID_PARAMETER'
-
 
Línea -... Línea 641...
-
 
641
 
-
 
642
 
-
 
643
        $uuid = $this->params()->fromRoute('id');
641
                ];
644
        if (!$uuid) {
-
 
645
            $data = [
642
 
646
                'success' => false,
Línea 643... Línea 647...
643
                return new JsonModel($data);
647
                'data' => 'ERROR_INVALID_PARAMETER'
-
 
648
            ];
Línea -... Línea 649...
-
 
649
 
644
            }
650
            return new JsonModel($data);
Línea 645... Línea 651...
645
 
651
        }
-
 
652
 
-
 
653
        $feedMapper = FeedMapper::getInstance($this->adapter);
-
 
654
        $feed = $feedMapper->fetchOneByUuid($uuid);
-
 
655
 
-
 
656
 
-
 
657
        if (!$feed) {
-
 
658
            $data = [
-
 
659
                'success' => false,
-
 
660
                'data' => 'ERROR_RECORD_NOT_FOUND'
-
 
661
             ];
646
            $feedMapper = FeedMapper::getInstance($this->adapter);
662
 
647
 
663
            return new JsonModel($data);
648
            $feed = $feedMapper->fetchOneByUuid($uuid);
664
        }
649
 
665
 
Línea 650... Línea 666...
650
 
666
        if ($currentCompany) {
651
            if (!$feed) {
667
            if ($feed->company_id != $currentCompany->id) {
-
 
668
                $data = [
-
 
669
                    'success' => false,
-
 
670
                    'data' => 'ERROR_UNAUTHORIZED'
-
 
671
                ];
-
 
672
 
-
 
673
                return new JsonModel($data);
Línea 652... Línea -...
652
                $data = [
-
 
653
                    'success' => false,
-
 
654
                    'data' => 'ERROR_RECORD_NOT_FOUND'
-
 
655
                ];
-
 
656
 
-
 
657
                return new JsonModel($data);
-
 
658
            }
-
 
659
 
674
            }
660
            if ($currentCompany) {
-
 
661
                if ($feed->company_id != $currentCompany->id) {
-
 
662
                    $data = [
-
 
663
                        'success' => false,
-
 
664
                        'data' => 'ERROR_UNAUTHORIZED'
-
 
665
                    ];
-
 
666
 
-
 
667
                    return new JsonModel($data);
-
 
668
                }
-
 
669
            } else {
-
 
670
                if ($feed->company_id) {
675
        } else {
-
 
676
            if ($feed->company_id) {
671
                    $data = [
677
                $data = [
-
 
678
                    'success' => false,
-
 
679
                    'data' => 'ERROR_UNAUTHORIZED'
-
 
680
                ];
-
 
681
 
-
 
682
                return new JsonModel($data);
-
 
683
            }
-
 
684
        }
-
 
685
        
-
 
686
        if($request->isGet()) {
-
 
687
            
-
 
688
            $topicMapper = TopicMapper::getInstance($this->adapter);
-
 
689
            $topic = $topicMapper->fetchOne($feed->topic_id);
-
 
690
            $link_file = ($feed->file_name != null && $feed->file_name != '') ? $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name]) : null;
-
 
691
            $preview = ($feed->file_image_preview != null && $feed->file_image_preview != '') ? $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_image_preview]) : null;
-
 
692
            return new JsonModel([
-
 
693
                'success' => true,
-
 
694
                'data' => [
-
 
695
                    'feed' => [
-
 
696
                        'uuid' => $feed->uuid,
-
 
697
                        'title' => $feed->title,
-
 
698
                        'added_on' => $feed->added_on,
-
 
699
                        'description' => $feed->description,
-
 
700
                        'file' => $feed->file_type ? $feed->file_type : '',
-
 
701
                        'link_media' => $feed->link_media ? $feed->link_media : '',
-
 
702
                        'link_name' => $feed->link_name,
-
 
703
                        'file_name' => $feed->file_name ? $feed->file_name : '',
-
 
704
                        'link_file' => $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name]),
-
 
705
                        'status' => $feed->status,
-
 
706
                    ],
-
 
707
                    'topic' => $topic,
672
                        'success' => false,
708
                    'titulo' => $feed->title,
Línea 673... Línea 709...
673
                        'data' => 'ERROR_UNAUTHORIZED'
709
                    'description' => $feed->description,
674
                    ];
710
                    'action' => $this->url()->fromRoute('development-and-content/edit', ['id' => $feed->uuid]),
675
 
711
                    'link_file' => $link_file,
Línea 877... Línea 913...
877
                    ];
913
                    ];
878
                }
914
                }
Línea 879... Línea 915...
879
 
915
 
880
                return new JsonModel($response);
916
                return new JsonModel($response);
-
 
917
            }
-
 
918
            
881
            }
919
            /*
882
        } catch (\Throwable $e) {
-
 
-
 
920
        } catch (\Throwable $e) {
883
            $e->getMessage();
921
 
884
            return new JsonModel([
922
            return new JsonModel([
885
                'success' => false,
923
                'success' => false,
886
                'data' => $e
924
                'data' => $e
887
            ]);
925
            ]);
888
        }
926
        }*/
Línea 889... Línea 927...
889
    }
927
    }