Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 54 Rev 112
Línea 113... Línea 113...
113
        $this->cache        = $cache;
113
        $this->cache        = $cache;
114
        $this->logger       = $logger;
114
        $this->logger       = $logger;
115
        $this->config       = $config;
115
        $this->config       = $config;
116
    }
116
    }
Línea -... Línea 117...
-
 
117
    
-
 
118
    public function indexAction() 
-
 
119
    {
-
 
120
        return new JsonModel(['ok' => false]);
-
 
121
    }
117
    
122
    
118
    public function signoutAction()
123
    public function signoutAction()
119
    {
124
    {
120
        $currentUser = $this->plugin('currentUserPlugin');
125
        $currentUser = $this->plugin('currentUserPlugin');
121
        if($currentUser->hasIdentity()) {
126
        if($currentUser->hasIdentity()) {
Línea 441... Línea 446...
441
        
446
        
442
        if($request->isPost()) {
447
        if($request->isPost()) {
443
            $currentUserPlugin = $this->plugin('currentUserPlugin');
448
            $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 444... Línea 449...
444
            $user = $currentUserPlugin->getUser();
449
            $user = $currentUserPlugin->getUser();
-
 
450
            
-
 
451
            $rawdata = file_get_contents("php://input");
445
            
452
            error_log('url = ' . $_SERVER['REQUEST_URI']);
Línea 446... Línea 453...
446
            //$rawdata = file_get_contents("php://input");
453
            error_log('query = ' . $_SERVER['QUERY_STRING']);
Línea 447... Línea 454...
447
            //error_log('$rawdata = ' . $rawdata );
454
            error_log('$rawdata = ' . $rawdata );
448
            
455
            
449
            
456
            
450
            $serviceDatetimeFormat = $this->config['leaderslinked.services.datetime'];
-
 
-
 
457
            $serviceDatetimeFormat = $this->config['leaderslinked.services.datetime'];
Línea 451... Línea 458...
451
            
458
            
452
            
459
            
453
            $device_uuid        = filter_var($this->params()->fromPost('device_uuid', ''), FILTER_SANITIZE_STRING);
460
            $device_uuid        = filter_var($this->params()->fromPost('device_uuid', ''), FILTER_SANITIZE_STRING);
454
            $max_date_changes   = filter_var($this->params()->fromPost('max_date_changes', ''), FILTER_SANITIZE_STRING);
461
            $max_date_changes   = filter_var($this->params()->fromPost('max_date_changes', ''), FILTER_SANITIZE_STRING);
Línea 469... Línea 476...
469
                    array_push($ids, $matches[0]);
476
                    array_push($ids, $matches[0]);
470
                }
477
                }
Línea 471... Línea 478...
471
 
478
 
Línea -... Línea 479...
-
 
479
            }
-
 
480
            
-
 
481
            if(empty($ids)) {
Línea 472... Línea 482...
472
            }
482
                $max_date_changes = '';
473
            
483
            }  else {
474
            
484
            
475
            
485
            
-
 
486
                if($max_date_changes) {
-
 
487
                    $dt = \DateTime::createFromFormat($serviceDatetimeFormat, $max_date_changes);
-
 
488
                    if($dt) {
476
            if($max_date_changes) {
489
                      $max_date_changes = $dt->format('Y-m-d H:i:s');  
477
                $dt = \DateTime::createFromFormat($serviceDatetimeFormat, $max_date_changes);
490
                    } else {
478
                if($dt) {
491
                        $max_date_changes = '';
479
                  $max_date_changes = $dt->format('Y-m-d H:i:s');  
-
 
480
                } else {
-
 
481
                    $max_date_changes = '';
492
                    }
-
 
493
                } else {
Línea 482... Línea 494...
482
                }
494
                    $max_date_changes = '';
Línea 483... Línea 495...
483
            } else {
495
                } 
Línea 512... Línea 524...
512
            
524
            
513
            //Cargamos la fecha máxima del cambio
525
            //Cargamos la fecha máxima del cambio
514
            $companyMicrolearningUserMapper = CompanyMicrolearningUserMapper::getInstance($this->adapter);
526
            $companyMicrolearningUserMapper = CompanyMicrolearningUserMapper::getInstance($this->adapter);
Línea -... Línea 527...
-
 
527
            $max_date_changes_db = $companyMicrolearningUserMapper->fetchMaxDateChanges($user->id);
-
 
528
            
-
 
529
            
515
            $max_date_changes_db = $companyMicrolearningUserMapper->fetchMaxDateChanges($user->id);
530
 
516
            
531
            
517
            //Si la fecha es vacia agregamos la fecha máxima de la asignación de la capsula
532
            //Si la fecha es vacia agregamos la fecha máxima de la asignación de la capsula
518
            if(!$max_date_changes_db) {
533
            if(!$max_date_changes_db) {
519
                $companyUsers = [];
534
                $companyUsers = [];
Línea 550... Línea 565...
550
                    
565
                    
551
                    $companyMicrolearningUserMapper->insert($companyMicrolearningUser);
566
                    $companyMicrolearningUserMapper->insert($companyMicrolearningUser);
552
                }
567
                }
Línea -... Línea 568...
-
 
568
            }
-
 
569
            
-
 
570
            /*
-
 
571
            echo '$max_date_changes  = ' . $max_date_changes  . PHP_EOL;
-
 
572
            echo '$max_date_changes_db  = ' . $max_date_changes_db. PHP_EOL;
-
 
573
            exit;
Línea 553... Línea 574...
553
            }
574
            */
554
            
575
           // $max_date_changes = '';
555
            
576
            
Línea 566... Línea 587...
566
                    {
587
                    {
567
                        $topics[$topic->id] = $topic->uuid;
588
                        $topics[$topic->id] = $topic->uuid;
568
                    }
589
                    }
Línea 569... Línea 590...
569
                        
590
                        
570
                    $companyMicrolearningCapsuleMapper = CompanyMicrolearningCapsuleMapper::getInstance($this->adapter);
591
                    $companyMicrolearningCapsuleMapper = CompanyMicrolearningCapsuleMapper::getInstance($this->adapter);
Línea 571... Línea 592...
571
                    $companyMicrolearningCapsules = $companyMicrolearningCapsuleMapper->fetchAllActiveAndPublic();
592
                    $companyMicrolearningCapsules = $companyMicrolearningCapsuleMapper->fetchAllActive();
572
                        
593
                        
573
                    $capsules = [];
594
                    $capsules = [];
574
                    foreach($companyMicrolearningCapsules as $capsule)
595
                    foreach($companyMicrolearningCapsules as $capsule)
575
                    {                            
596
                    {                            
Línea 576... Línea 597...
576
                        $capsules[$capsule->id] = $capsule->uuid;
597
                        $capsules[$capsule->id] = $capsule->uuid;
577
                    }
598
                    }
Línea -... Línea 599...
-
 
599
                        
-
 
600
                    $companyMicrolearningCapsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
-
 
601
                    $user_capsules = $companyMicrolearningCapsuleUserMapper->fetchAllActiveByUserId($user->id);
578
                        
602
                        
579
                    $companyMicrolearningCapsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
603
                    
580
                    $user_capsules = $companyMicrolearningCapsuleUserMapper->fetchAllActiveByUserId($user->id);
604
                    //print_r($user_capsules); 
581
                        
605
                    
Línea 582... Línea 606...
582
                    foreach($user_capsules as $user_capsule) 
606
                    foreach($user_capsules as $user_capsule) 
583
                    {
607
                    {
584
                        $topic_uuid     = isset($topics[$user_capsule->topic_id]) ? $topics[$user_capsule->topic_id] : '';
608
                        $topic_uuid     = isset($topics[$user_capsule->topic_id]) ? $topics[$user_capsule->topic_id] : '';
Línea 585... Línea 609...
585
                        $capsule_uuid   = isset($capsules[$user_capsule->capsule_id]) ?  $capsules[$user_capsule->capsule_id] : '';
609
                        $capsule_uuid   = isset($capsules[$user_capsule->capsule_id]) ?  $capsules[$user_capsule->capsule_id] : '';
-
 
610
                            
-
 
611
                        if(!$topic_uuid || !$capsule_uuid) {
-
 
612
                            continue;
586
                            
613
                        }
587
                        if(!$topic_uuid || !$capsule_uuid) {
614
                            
588
                            continue;
615
                        $key = $topic_uuid . '|' . $capsule_uuid;
589
                        }
616
                        //echo 'key =  ' . $key . PHP_EOL;
590
                            
617
                        
591
                        $key = $topic_uuid . '|' . $capsule_uuid;
618
                        
Línea -... Línea 619...
-
 
619
                        if(!in_array($key, $ids)) {
592
                        if(!in_array($key, $ids)) {
620
                            $newCapsules++;
593
                            $newCapsules++;
621
                        }
594
                        }
622
                    }
Línea -... Línea 623...
-
 
623
                }
595
                    }
624
            }
596
                }
625
 
Línea 597... Línea 626...
597
            }
626
            $dataSync = [];
598
 
627
            
599
     
628
            //echo 'Vamos a lanzar un PUSH' . PHP_EOL;
Línea 638... Línea 667...
638
                                'data' => [
667
                                'data' => [
639
                                    'new_capsules' => $newCapsules,
668
                                    'new_capsules' => $newCapsules,
640
                                ]
669
                                ]
641
                            ]
670
                            ]
642
                        ]);
671
                        ]);
-
 
672
                        
-
 
673
                        
-
 
674
                        //print_r($push);
-
 
675
                        
643
                        $pushMapper->insert($push);
676
                        $pushMapper->insert($push);
644
                    }
677
                    }
645
                }
678
                }
Línea -... Línea 679...
-
 
679
                
646
                
680
                if(!$is_foreground) {
647
                $dataSync = $this->getSyncData($user,false, false);
681
                    $dataSync = $this->getSyncData($user,false, false);
648
            } else {
-
 
649
                $dataSync = [];
682
                }
650
            } 
-
 
Línea 651... Línea 683...
651
                
683
            }
Línea 652... Línea 684...
652
           
684
           
Línea 668... Línea 700...
668
                        'first_name' => $user->first_name,
700
                        'first_name' => $user->first_name,
669
                        'last_name' => $user->last_name,
701
                        'last_name' => $user->last_name,
670
                        'email' => $user->email,
702
                        'email' => $user->email,
671
                        'image' => $this->url()->fromRoute('services/storage',['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image], ['force_canonical' => true]),
703
                        'image' => $this->url()->fromRoute('services/storage',['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image], ['force_canonical' => true]),
672
                    ],
704
                    ],
-
 
705
                    'new_capsules' => $newCapsules,
673
                    'max_date_changes' => $max_date_changes_db,
706
                    'max_date_changes' => $max_date_changes_db,
674
                    'topics'    => isset( $dataSync['topics'] ) ? $dataSync['topics'] : [],
707
                    'topics'    => isset( $dataSync['topics'] ) ? $dataSync['topics'] : [],
675
                    'quizzes'   => isset( $dataSync['quizzes'] ) ? $dataSync['quizzes'] : [],
708
                    'quizzes'   => isset( $dataSync['quizzes'] ) ? $dataSync['quizzes'] : [],
676
                    'extended'=> isset( $dataSync['extended'] ) ? $dataSync['extended'] : [],
709
                    'extended'=> isset( $dataSync['extended'] ) ? $dataSync['extended'] : [],
677
                ]
710
                ]
Línea 782... Línea 815...
782
        $request = $this->getRequest();
815
        $request = $this->getRequest();
Línea 783... Línea 816...
783
        
816
        
Línea 784... Línea 817...
784
        if($request->isPost()) {
817
        if($request->isPost()) {
-
 
818
            
-
 
819
            
785
            
820
            $rawdata = file_get_contents("php://input");
Línea 786... Línea 821...
786
            
821
            error_log('url = ' . $_SERVER['REQUEST_URI']);
787
            //$rawdata = file_get_contents("php://input");
822
            error_log('query = ' . $_SERVER['QUERY_STRING']);
788
            //error_log('$rawdata = ' . $rawdata );
823
            error_log('$rawdata = ' . $rawdata );