Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 4778 Rev 4808
Línea 319... Línea 319...
319
 
319
 
320
        return new JsonModel($response);
320
        return new JsonModel($response);
Línea 321... Línea -...
321
    }
-
 
322
 
-
 
323
   
-
 
324
    public function postAction()
-
 
325
    {
-
 
326
        $request = $this->getRequest();
-
 
327
        if ($request->isGet()) {
-
 
328
            $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
329
            $currentUser = $currentUserPlugin->getUser();
-
 
330
            
-
 
331
            
-
 
332
            $id = $this->params()->fromRoute('id');
-
 
333
    
-
 
334
            $postMapper = PostMapper::getInstance($this->adapter);
-
 
335
            $post = $postMapper->fetchOneByUuid($id);
-
 
Línea 336... Línea -...
336
    
-
 
337
            if (!$post || $post->status != Post::STATUS_ACTIVE) {
-
 
338
                $flashMessenger = $this->plugin('FlashMessenger');
-
 
339
    
-
 
340
                if (!$id) {
-
 
341
                    $flashMessenger->addErrorMessage('ERROR_POST_NOT_AVAILABLE');
-
 
342
                    return $this->redirect()->toRoute('dashboard');
-
 
343
                }
-
 
344
            }
-
 
345
            
-
 
346
            
-
 
347
       
-
 
348
            $timestamp = time();
-
 
349
      
-
 
350
            list($usec, $sec) = explode(' ', microtime());
-
 
351
            $seed = intval($sec + ((float) $usec * 100000));
-
 
352
            mt_srand($seed, MT_RAND_MT19937);
-
 
353
            $rand =  mt_rand();
-
 
354
            
-
 
355
            
-
 
356
 
-
 
357
            $password  = md5('user-' . $currentUser->uuid . '-post-' . $post->uuid . '-timestamp-' . $timestamp . '-rand-' . $rand . '-share-key-' . $currentUser->share_key) ;
-
 
358
            
-
 
359
            
-
 
360
            $share_params = [
-
 
361
                'type' => 'post',
-
 
362
                'code' => $post->uuid,
-
 
363
                'user' => $currentUser->uuid,
-
 
364
                'timestamp' => $timestamp,
-
 
365
                'rand' => $rand,
-
 
366
                'password' => $password,
-
 
367
            ];
-
 
368
            
-
 
369
            
-
 
370
            $share_increment_external_counter_url = $this->url()->fromRoute('share/increment-external-counter',$share_params  , ['force_canonical' => true]);
-
 
371
 
-
 
372
            
-
 
373
            $share_external_url = $this->url()->fromRoute('shorter/generate', ['code' => $post->uuid, 'type' => 'post' ]  , ['force_canonical' => true]);
-
 
374
            
-
 
375
            
-
 
376
            
-
 
377
            $this->layout()->setTemplate('layout/layout.phtml');
-
 
378
            $viewModel = new ViewModel();
-
 
379
            $viewModel->setTemplate('leaders-linked/home/post.phtml');
-
 
380
            $viewModel->setVariables([
-
 
381
                'post' => $post,
-
 
382
                'id' => $post->id,
-
 
383
                'uuid' => $post->uuid,
-
 
384
                'title' => $post->title,
-
 
385
                'description' => $post->description,
-
 
386
                'url' => $post->url,
-
 
387
                'date' => $post->date,
-
 
388
                'status' => $post->status,
-
 
389
                'image' => $post->image,
-
 
390
                'file' => $post->file,
-
 
391
                'added_on' => $post->added_on,
-
 
392
                'share_external_url' =>  $share_external_url,
-
 
393
                'total_share_external' => $post->total_external_shared,
-
 
394
                'share_increment_external_counter_url' => $share_increment_external_counter_url,
-
 
395
                
-
 
396
            ]);
-
 
397
            return $viewModel;
-
 
398
            
-
 
399
        } else {
-
 
400
            $response = [
-
 
401
                'success' => false,
-
 
402
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
-
 
403
            ];
-
 
Línea 404... Línea 321...
404
            
321
    }
405
            return new JsonModel($response);
322