Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 1 Rev 60
Línea 188... Línea 188...
188
           'success' => false,
188
           'success' => false,
189
           'data' => 'ERROR_METHOD_NOT_ALLOWED'
189
           'data' => 'ERROR_METHOD_NOT_ALLOWED'
190
        ]);
190
        ]);
191
    }
191
    }
Línea 192... Línea 192...
192
    
192
    
193
    public function error500Action()
193
    public function dashboard2Action()
-
 
194
    {
-
 
195
        $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
196
        $currentUser = $currentUserPlugin->getUser();
-
 
197
        
-
 
198
        $userMapper = UserMapper::getInstance($this->adapter);
-
 
199
        $user = $userMapper->fetchOne($currentUser->id);
-
 
200
        
-
 
201
        $request = $this->getRequest();
-
 
202
        if($request->isGet()) {
-
 
203
            
-
 
204
            
-
 
205
            $headers  = $request->getHeaders();
-
 
206
            
-
 
207
            $isJson = false;
-
 
208
            if($headers->has('Accept')) {
-
 
209
                $accept = $headers->get('Accept');
-
 
210
                
-
 
211
                $prioritized = $accept->getPrioritized();
-
 
212
                
-
 
213
                foreach($prioritized as $key => $value) {
-
 
214
                    $raw = trim($value->getRaw());
-
 
215
                    
-
 
216
                    if(!$isJson) {
-
 
217
                        $isJson = strpos($raw, 'json');
-
 
218
                    }
-
 
219
                    
-
 
220
                }
-
 
221
            }
-
 
222
            
-
 
223
            if($isJson) {
-
 
224
                $profileVisitMapper = ProfileVisitMapper::getInstance($this->adapter);
-
 
225
                $visits = $profileVisitMapper->getTotalByVisitedId($currentUser->id);
-
 
226
                
-
 
227
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
-
 
228
                $connections = $connectionMapper->fetchTotalConnectionByUser($currentUser->id);
-
 
229
                
-
 
230
                
-
 
231
                if($user->location_id) {
-
 
232
                    $locationMapper = LocationMapper::getInstance($this->adapter);
-
 
233
                    $location = $locationMapper->fetchOne($user->location_id);
-
 
234
                    
-
 
235
                    $country = $location->country;
-
 
236
                } else {
-
 
237
                    $country = '';
-
 
238
                }
-
 
239
                
-
 
240
                $image_size = $this->config['leaderslinked.image_sizes.feed_image_upload'];
-
 
241
                
-
 
242
                return new JsonModel([
-
 
243
                    'user_uuid' => $user->uuid,
-
 
244
                    'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image]),
-
 
245
                    'fullname' => trim($user->first_name . ' ' . $user->last_name),
-
 
246
                    'country' => $country,
-
 
247
                    'visits' => $visits,
-
 
248
                    'connections' => $connections,
194
    {
249
                    'image_size' => $image_size,
-
 
250
                ]);
-
 
251
                
-
 
252
            } else {
-
 
253
                $feed_uuid = $this->params()->fromRoute('feed');
195
        $uuid = '';
254
                if($feed_uuid) {
196
        $postMapper = PostMapper::getInstance($this->adapter);
255
                    $feedMapper = FeedMapper::getInstance($this->adapter);
-
 
256
                    $feed = $feedMapper->fetchOneByUuid($feed_uuid);
-
 
257
                    if($feed && $feed->type == Feed::TYPE_UPDATE && $feed->user_id == $currentUser->id && $feed->status == Feed::STATUS_PUBLISHED) {
-
 
258
                        $notificationMapper = NotificationMapper::getInstance($this->adapter);
-
 
259
                        $notificationMapper->markAllNotificationsAsReadByUserIdAndFeedId($currentUser->id, $feed->id);
-
 
260
                    } else {
-
 
261
                        $feed_uuid = '';
-
 
262
                    }
-
 
263
                } else {
-
 
264
                    $feed_uuid = '';
-
 
265
                }
-
 
266
                
-
 
267
                
-
 
268
                
-
 
269
                
-
 
270
                $profileVisitMapper = ProfileVisitMapper::getInstance($this->adapter);
-
 
271
                $visits = $profileVisitMapper->getTotalByVisitedId($currentUser->id);
-
 
272
                
-
 
273
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
-
 
274
                $connections = $connectionMapper->fetchTotalConnectionByUser($currentUser->id);
-
 
275
                
-
 
276
                
-
 
277
                if($user->location_id) {
-
 
278
                    $locationMapper = LocationMapper::getInstance($this->adapter);
-
 
279
                    $location = $locationMapper->fetchOne($user->location_id);
-
 
280
                    
-
 
281
                    $country = $location->country;
-
 
282
                } else {
-
 
283
                    $country = '';
-
 
284
                }
-
 
285
                
-
 
286
                $userProfileMapper = UserProfileMapper::getInstance($this->adapter);
-
 
287
                $userProfile = $userProfileMapper->fetchOnePublicByUserId($currentUser->id);
-
 
288
                
-
 
289
                
-
 
290
                $image_size = $this->config['leaderslinked.image_sizes.feed_image_upload'];
-
 
291
                
-
 
292
                $formFeed = new CreateForm();
-
 
293
                $formShare = new ShareForm();
-
 
294
                
-
 
295
                $this->layout()->setTemplate('layout/layout.phtml');
-
 
296
                $viewModel = new ViewModel();
-
 
297
                $viewModel->setVariables([
-
 
298
                    'user_uuid' => $user->uuid,
-
 
299
                    'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image]),
-
 
300
                    'fullname' => trim($user->first_name . ' ' . $user->last_name),
-
 
301
                    'description' => empty($userProfile->description) ? '' :  trim($userProfile->description) ,
-
 
302
                    'country' => $country,
-
 
303
                    'visits' => $visits,
-
 
304
                    'connections' => $connections,
-
 
305
                    'feed' => $feed_uuid,
-
 
306
                    'formFeed' => $formFeed,
-
 
307
                    'formShare' => $formShare,
-
 
308
                    'image_size' => $image_size,
-
 
309
                ]);
-
 
310
                $viewModel->setTemplate('leaders-linked/dashboard/dashboard2.phtml');
-
 
311
                return $viewModel ;
-
 
312
            }
Línea 197... Línea 313...
197
        $postMapper->fetchOneByUuidError500($uuid);
313
        }
198
        
314
        
199
        return new JsonModel([
315
        return new JsonModel([
200
            'success' => true,
316
            'success' => false,
201
            'data' => 'Prueba Error 500'
-
 
202
        ]);
317
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
203
        
318
        ]);
204
    }
319
    }