Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 1 Rev 1302
Línea 221... Línea 221...
221
        if($request->isGet()) {
221
        if($request->isGet()) {
Línea 222... Línea 222...
222
            
222
            
223
            $currentUserPlugin = $this->plugin('currentUserPlugin');
223
            $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 224... Línea -...
224
            $currentUser = $currentUserPlugin->getUser();
-
 
225
            
-
 
226
           
224
            $currentUser = $currentUserPlugin->getUser();
Línea 227... Línea 225...
227
            $notificationMapper = NotificationMapper::getInstance($this->adapter);
225
            
228
            $records = $notificationMapper->fetchAllsUnreadByUserId($currentUser->id);
226
            $headers  = $request->getHeaders();
229
            
-
 
230
            $items = [];
227
            
Línea 231... Línea -...
231
            foreach($records as $record)
-
 
232
            {
228
            $isJson = false;
233
                $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $record->added_on);
-
 
234
                
-
 
235
                array_push($items,[
-
 
Línea -... Línea 229...
-
 
229
            if($headers->has('Accept')) {
-
 
230
                $accept = $headers->get('Accept');
-
 
231
                
-
 
232
                $prioritized = $accept->getPrioritized();
-
 
233
                
-
 
234
                foreach($prioritized as $key => $value) {
-
 
235
                    $raw = trim($value->getRaw());
-
 
236
                    
236
                    'message' => $record->message,
237
                    if(!$isJson) {
-
 
238
                        $isJson = strpos($raw, 'json');
-
 
239
                    }
-
 
240
                    
Línea -... Línea 241...
-
 
241
                }
-
 
242
            }
-
 
243
            
-
 
244
            if($isJson) {
-
 
245
            
-
 
246
               
-
 
247
                $notificationMapper = NotificationMapper::getInstance($this->adapter);
-
 
248
                $records = $notificationMapper->fetchAllsUnreadByUserId($currentUser->id);
-
 
249
                
-
 
250
                $items = [];
-
 
251
                foreach($records as $record)
-
 
252
                {
-
 
253
                    $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $record->added_on);
-
 
254
                    
-
 
255
                    array_push($items,[
-
 
256
                        'message' => $record->message,
237
                    'link' => $record->url,
257
                        'link' => $record->url,
238
                    'time_elapsed' => Functions::timeElapsedString($dt->getTimestamp())
258
                        'time_elapsed' => Functions::timeElapsedString($dt->getTimestamp())
239
                ]);
259
                    ]);
-
 
260
                    
-
 
261
                }
-
 
262
                   
-
 
263
                $response = [
-
 
264
                    'success' => true,
-
 
265
                    'data' => $items
-
 
266
                ];
240
                
267
            } else {
Línea 241... Línea 268...
241
            }
268
                $this->layout()->setTemplate('layout/layout.phtml');
242
               
269
                $viewModel = new ViewModel();
243
            $response = [
270
               
244
                'success' => true,
271
                $viewModel->setTemplate('leaders-linked/home/notifications.phtml');