Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 12961 Rev 12962
Línea 73... Línea 73...
73
        $currentCompany = $currentUserPlugin->getCompany();
73
        $currentCompany = $currentUserPlugin->getCompany();
74
        $currentUser = $currentUserPlugin->getUser();
74
        $currentUser = $currentUserPlugin->getUser();
Línea 75... Línea 75...
75
 
75
 
Línea -... Línea 76...
-
 
76
        $id =  $this->params()->fromRoute('id');
76
        $id =  $this->params()->fromRoute('id');
77
 
-
 
78
        
Línea 77... Línea 79...
77
 
79
        $request = $this->getRequest();
78
        $request = $this->getRequest();
80
        
Línea 79... Línea 81...
79
 
81
 
Línea 90... Línea 92...
90
                    $raw = trim($value->getRaw());
92
                    $raw = trim($value->getRaw());
Línea 91... Línea 93...
91
 
93
 
92
                    if(!$isJson) {
94
                    if(!$isJson) {
93
                        $isJson = strpos($raw, 'json');
95
                        $isJson = strpos($raw, 'json');
-
 
96
                    }
94
                    }
97
 
95
                }
98
                }
Línea 96... Línea 99...
96
            }
99
            }
97
 
100
 
98
            $topicMapper = TopicMapper::getInstance($this->adapter);
-
 
99
            $topic = $topicMapper->fetchOneByUUid($id);
-
 
100
        
-
 
Línea -... Línea 101...
-
 
101
                $topicMapper = TopicMapper::getInstance($this->adapter);
-
 
102
                $topic = $topicMapper->fetchOneByUUid($id);
-
 
103
            
101
            $topicsMapper = FeedTopicMapper::getInstance($this->adapter);
104
                $topicsMapper = FeedTopicMapper::getInstance($this->adapter);
102
            $feedTopics = $topicsMapper->fetchOne($topic->id);
105
                $feedTopics = $topicsMapper->fetchAllByTopicId($topic->id);
Línea 103... Línea 106...
103
            
106
                
104
            foreach ($feedTopics as $feed) {
107
                foreach ($feedTopics as $feed) {
-
 
108
                    $questionsMapper = FeedMapper::getInstance($this->adapter);
105
                $questionsMapper = FeedMapper::getInstance($this->adapter);
109
 
106
 
-
 
107
                if ($question = $questionsMapper->fetchOne($feed->feed_id)) {
-
 
108
                    $questions [] = $question;
-
 
109
                }
-
 
110
            }
-
 
111
            
-
 
112
            $topics = [];
-
 
Línea -... Línea 110...
-
 
110
                    if ($question = $questionsMapper->fetchOne($feed->feed_id)) {
-
 
111
                        $questions [] = $question;
-
 
112
                    }
-
 
113
                }
-
 
114
                
-
 
115
                $topics = [];
113
            foreach ($questions as $question) {
116
                foreach ($questions as $question) {
114
                $topicRelationships = $topicsMapper->fetchAllByFeedId($question->id);
117
                    $topicRelationships = $topicsMapper->fetchAllByFeedId($question->id);
115
                $question->topics = [];
118
                    $question->topics = [];
116
            
119
                
-
 
120
                   
117
                
121
                    foreach ($topicRelationships as $rel) {
-
 
122
                        $topic = $topicMapper->fetchOne($rel->topic_id);
118
                foreach ($topicRelationships as $rel) {
123
                        if ($topic) {
119
                    $topic = $topicMapper->fetchOne($rel->topic_id);
-
 
120
                    if ($topic) {
124
                            $question->topics []= $topic;
121
                        $question->topics []= $topic;
125
                        }
122
                    }
126
                    }
123
                }
127
                    
124
            }
128
                }
125
            
129
               
126
            $acl = $this->getEvent()->getViewModel()->getVariable('acl');
130
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
127
            $allowAdd = $acl->isAllowed($currentUser->usertype_id, 'my-trainer/question/add');
131
                $allowAdd = $acl->isAllowed($currentUser->usertype_id, 'my-trainer/question/add');
128
            $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'my-trainer/question/edit');
132
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'my-trainer/question/edit');
129
            $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'my-trainer/question/delete');
133
                $allowDelete = $acl->isAllowed($currentUser->usertype_id, 'my-trainer/question/delete');
-
 
134
                $allowAnswer = $acl->isAllowed($currentUser->usertype_id, 'my-trainer/question/answer');
130
            $allowAnswer = $acl->isAllowed($currentUser->usertype_id, 'my-trainer/question/answer');
135
                $page = $this->params()->fromQuery('page', 1);
131
            $page = $this->params()->fromQuery('page', 1);
136
                $perpage = $this->params()->fromQuery('perpage', 20);
132
            $perpage = $this->params()->fromQuery('perpage', 20);
137
        
133
    
138
                $form = new CreateFeedForm($this->adapter);
134
            $form = new CreateFeedForm($this->adapter);
139
               
135
    
140
        
136
            $viewModel = new ViewModel();
141
                $viewModel = new ViewModel();
137
            $this->layout()->setTemplate('layout/layout-backend');
142
                $this->layout()->setTemplate('layout/layout-backend');
138
            $viewModel->setTemplate('leaders-linked/my-trainer-question-view/index.phtml');
143
                $viewModel->setTemplate('leaders-linked/my-trainer-question-view/index.phtml');
139
            $viewModel->setVariables([
144
                $viewModel->setVariables([
-
 
145
                    'form' => $form,
140
                'form' => $form,
146
                    'id' => $id,
141
                'id' => $id,
147
                    'page' => $page,
142
                'page' => $page,
148
                    'perpage' => $perpage,
143
                'perpage' => $perpage,
149
                    'questions' => $questions,
144
                'questions' => $questions,                 
150
                    // 'categories' => $categories                   
145
            ]);
151
                ]);
146
            return $viewModel;
152
                return $viewModel;
147
        } else {
153
        } else {
-
 
154
            return new JsonModel([
-
 
155
                'success' => false,
148
            return new JsonModel([
156
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
Línea 149... Línea 157...
149
                'success' => false,
157
            ]);
150
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
158
        }
151
            ]);
159