Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 60 Rev 242
Línea 32... Línea 32...
32
use LeadersLinked\Model\Comment;
32
use LeadersLinked\Model\Comment;
33
use LeadersLinked\Mapper\ContentReactionMapper;
33
use LeadersLinked\Mapper\ContentReactionMapper;
34
use LeadersLinked\Model\ContentReaction;
34
use LeadersLinked\Model\ContentReaction;
35
use LeadersLinked\Mapper\KnowledgeAreaCategoryJobDescriptionMapper;
35
use LeadersLinked\Mapper\KnowledgeAreaCategoryJobDescriptionMapper;
36
use LeadersLinked\Mapper\OrganizationPositionMapper;
36
use LeadersLinked\Mapper\OrganizationPositionMapper;
-
 
37
use LeadersLinked\Model\User;
Línea 37... Línea 38...
37
 
38
 
38
class KnowledgeAreaController extends AbstractActionController
39
class KnowledgeAreaController extends AbstractActionController
39
{
40
{
40
    /**
41
    /**
Línea 228... Línea 229...
228
                        'image' => $this->url()->fromRoute('storage', ['type' => 'knowledge-area', 'code' => $record->uuid,  'filename' => $record->image],['force_canonical' => true]),
229
                        'image' => $this->url()->fromRoute('storage', ['type' => 'knowledge-area', 'code' => $record->uuid,  'filename' => $record->image],['force_canonical' => true]),
229
                        'title' => $record->title,
230
                        'title' => $record->title,
230
                        'description' => $description,
231
                        'description' => $description,
231
                        'category' => $categories[$record->category_id]['name'],
232
                        'category' => $categories[$record->category_id]['name'],
232
                        'link_view' => $allowView ?  $this->url()->fromRoute('knowledge-area/view', ['id' => $record->uuid]) : '',
233
                        'link_view' => $allowView ?  $this->url()->fromRoute('knowledge-area/view', ['id' => $record->uuid]) : '',
233
 
234
 
234
                    ];
235
                    ];
Línea 235... Línea 236...
235
 
236
 
Línea 782... Línea 783...
782
                        'description' => $knowledgeAreaContent->description,
783
                        'description' => $knowledgeAreaContent->description,
783
                        'link' => $knowledgeAreaContent->link,
784
                        'link' => $knowledgeAreaContent->link,
784
                        'image' =>  $this->url()->fromRoute('storage', ['type' => 'knowledge-area', 'code' =>  $knowledgeAreaContent->uuid,  'filename' =>  $knowledgeAreaContent->image],['force_canonical' => true]),
785
                        'image' =>  $this->url()->fromRoute('storage', ['type' => 'knowledge-area', 'code' =>  $knowledgeAreaContent->uuid,  'filename' =>  $knowledgeAreaContent->image],['force_canonical' => true]),
785
                        'attachment' =>  $knowledgeAreaContent->attachment ? $this->url()->fromRoute('storage', ['type' => 'knowledge-area', 'code' =>  $knowledgeAreaContent->uuid,  'filename' =>  $knowledgeAreaContent->attachment],['force_canonical' => true]) : '',
786
                        'attachment' =>  $knowledgeAreaContent->attachment ? $this->url()->fromRoute('storage', ['type' => 'knowledge-area', 'code' =>  $knowledgeAreaContent->uuid,  'filename' =>  $knowledgeAreaContent->attachment],['force_canonical' => true]) : '',
786
                        'reaction' => $contentReaction ? $contentReaction->reaction : '',
787
                        'reaction' => $contentReaction ? $contentReaction->reaction : '',
787
                        'routeComments' => $this->url()->fromRoute('knowledge-area/comments', ['id' => $knowledgeAreaContent->uuid]),
788
                        'routeComments' => $this->url()->fromRoute('knowledge-area/comments', ['id' => $knowledgeAreaContent->uuid],['force_canonical' => true]),
788
                        'routeCommentAdd' => $this->url()->fromRoute('knowledge-area/comments/add', ['id' => $knowledgeAreaContent->uuid]),
789
                        'routeCommentAdd' => $this->url()->fromRoute('knowledge-area/comments/add', ['id' => $knowledgeAreaContent->uuid],['force_canonical' => true]),
789
                        'routeSaveReaction' => $this->url()->fromRoute('knowledge-area/save-reaction', ['id' => $knowledgeAreaContent->uuid]),
790
                        'routeSaveReaction' => $this->url()->fromRoute('knowledge-area/save-reaction', ['id' => $knowledgeAreaContent->uuid],['force_canonical' => true]),
790
                        'routeDeleteReaction' => $this->url()->fromRoute('knowledge-area/delete-reaction', ['id' => $knowledgeAreaContent->uuid]),
791
                        'routeDeleteReaction' => $this->url()->fromRoute('knowledge-area/delete-reaction', ['id' => $knowledgeAreaContent->uuid],['force_canonical' => true]),
-
 
792
                        'routeReactions' => $this->url()->fromRoute('knowledge-area/reactions', ['id' => $knowledgeAreaContent->uuid],['force_canonical' => true]),
791
                    ]
793
                    ]
792
                ]);
794
                ]);
Línea 793... Línea 795...
793
 
795
 
794
        } else {
796
        } else {
Línea 800... Línea 802...
800
            return new JsonModel($data);
802
            return new JsonModel($data);
801
        }
803
        }
Línea 802... Línea 804...
802
 
804
 
803
        return new JsonModel($data);
805
        return new JsonModel($data);
-
 
806
    }
-
 
807
    
-
 
808
    public function reactionsAction()
-
 
809
    {
-
 
810
        $id = $this->params()->fromRoute('id');
-
 
811
        
-
 
812
        $request = $this->getRequest();
-
 
813
        $request = $this->getRequest();
-
 
814
        if ($request->isGet()) {
-
 
815
            
-
 
816
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
817
            $currentUser = $currentUserPlugin->getUser();
-
 
818
            
-
 
819
            $knowledgeAreaContentMapper = KnowledgeAreaContentMapper::getInstance($this->adapter);
-
 
820
            $knowledgeAreaContent = $knowledgeAreaContentMapper->fetchOneByUuid($id);
-
 
821
            if (!$knowledgeAreaContent || $knowledgeAreaContent->network_id != $currentUser->network_id) {
-
 
822
                return new JsonModel([
-
 
823
                    'success'   => false,
-
 
824
                    'data'   => 'ERROR_RECORD_NOT_FOUND'
-
 
825
                ]);
-
 
826
            }
-
 
827
            
-
 
828
            
-
 
829
            
-
 
830
            $userMapper = UserMapper::getInstance($this->adapter);
-
 
831
            
-
 
832
            $items = [];
-
 
833
            
-
 
834
            $contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
-
 
835
            $records = $contentReactionMapper->fetchAllByKnowledgeAreaId($knowledgeAreaContent->id);
-
 
836
            
-
 
837
            foreach($records as $record)
-
 
838
            {
-
 
839
                $user = $userMapper->fetchOne($record->user_id);
-
 
840
                if($user && $user->status == User::STATUS_ACTIVE) {
-
 
841
                    
-
 
842
                    array_push($items, [
-
 
843
                        'first_name' => $user->first_name,
-
 
844
                        'last_name' => $user->last_name,
-
 
845
                        'email' => $user->email,
-
 
846
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image], ['force_canonical' => true]),
-
 
847
                        'reaction' => $record->reaction,
-
 
848
                    ]);
-
 
849
                }
-
 
850
            }
-
 
851
            
-
 
852
            $response = [
-
 
853
                'success' => true,
-
 
854
                'data' => $items
-
 
855
            ];
-
 
856
            
-
 
857
            return new JsonModel($response);
-
 
858
            
-
 
859
            
-
 
860
            
-
 
861
            
-
 
862
        } else {
-
 
863
            $response = [
-
 
864
                'success' => false,
-
 
865
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
866
            ];
-
 
867
            
-
 
868
            return new JsonModel($response);
-
 
869
        }
Línea 804... Línea 870...
804
    }
870
    }
805
 
871
 
806
 
872
 
Línea 829... Línea 895...
829
            $dataPost = $request->getPost()->toArray();
895
            $dataPost = $request->getPost()->toArray();
830
            $form = new CommentForm();
896
            $form = new CommentForm();
831
            $form->setData($dataPost);
897
            $form->setData($dataPost);
Línea 832... Línea 898...
832
 
898
 
833
            if ($form->isValid()) {
-
 
834
                $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
835
                $currentUser = $currentUserPlugin->getUser();
899
            if ($form->isValid()) {
836
 
900
  
Línea 837... Línea 901...
837
                $dataPost = (array) $form->getData();
901
                $dataPost = (array) $form->getData();
838
 
902
 
839
                $comment = new Comment();
903
                $comment = new Comment();