Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 1 Rev 2
Línea 35... Línea 35...
35
use LeadersLinked\Form\SlideQuizzAddForm;
35
use LeadersLinked\Form\SlideQuizzAddForm;
36
use LeadersLinked\Form\SlideQuizzEditForm;
36
use LeadersLinked\Form\SlideQuizzEditForm;
37
use LeadersLinked\Form\SlideVideoEditForm;
37
use LeadersLinked\Form\SlideVideoEditForm;
Línea 38... Línea 38...
38
 
38
 
39
 
39
 
40
class MicroLearningSlideController extends AbstractActionController
40
class MicrolearningSlideController extends AbstractActionController
41
{
41
{
42
    /**
42
    /**
43
     *
43
     *
Línea 377... Línea -...
377
        
-
 
378
 
-
 
379
        
-
 
380
        
-
 
381
        
-
 
382
 
-
 
383
        $topic_id   = $this->params()->fromRoute('topic_id');
-
 
384
        $capsule_id = $this->params()->fromRoute('capsule_id');
-
 
385
        
-
 
386
        $currentUserPlugin = $this->plugin('currentUserPlugin');
-
 
387
        $currentUser = $currentUserPlugin->getUser();
-
 
388
        
-
 
389
        $companyMapper = CompanyMapper::getInstance($this->adapter);
-
 
390
        $company = $companyMapper->fetchOneByUuid($id);
-
 
391
        if(!$company) {
-
 
392
            $flashMessenger->addErrorMessage('ERROR_COMPANY_NOT_FOUND');
-
 
393
            return $this->redirect()->toRoute('dashboard');
-
 
394
        }
-
 
395
        
-
 
396
        $topicMapper = CompanyMicrolearningTopicMapper::getInstance($this->adapter);
-
 
397
        $topic = $topicMapper->fetchOneByUuid($topic_id);
-
 
398
        if(!$topic) {
-
 
399
            $flashMessenger->addErrorMessage('ERROR_TOPIC_NOT_FOUND');
-
 
400
            return $this->redirect()->toRoute('dashboard');
-
 
401
        }
-
 
402
        
-
 
403
        if($topic->company_id != $company->id) {
-
 
404
            $flashMessenger->addErrorMessage('ERROR_UNAUTHORIZED');
-
 
405
            return $this->redirect()->toRoute('dashboard');
-
 
406
        }
-
 
407
        
-
 
408
        $capsuleMapper = CompanyMicrolearningCapsuleMapper::getInstance($this->adapter);
-
 
409
        $capsule = $capsuleMapper->fetchOneByUuid($capsule_id);
-
 
410
        if(!$capsule) {
-
 
411
            $flashMessenger->addErrorMessage('ERROR_CAPSULE_NOT_FOUND');
-
 
412
            return $this->redirect()->toRoute('dashboard');
-
 
413
        }
-
 
414
        
-
 
415
        if($capsule->topic_id != $topic->id) {
-
 
416
            $flashMessenger->addErrorMessage('ERROR_UNAUTHORIZED');
-
 
417
            return $this->redirect()->toRoute('dashboard');
-
 
418
        }
-
 
419
        
-
 
420
        $request = $this->getRequest();
-
 
421
        if($request->isGet()) {
-
 
422
            
-
 
423
            
-
 
424
            $headers  = $request->getHeaders();
-
 
425
            
-
 
426
            $isJson = false;
-
 
427
            if($headers->has('Accept')) {
-
 
428
                $accept = $headers->get('Accept');
-
 
429
                
-
 
430
                $prioritized = $accept->getPrioritized();
-
 
431
                
-
 
432
                foreach($prioritized as $key => $value) {
-
 
433
                    $raw = trim($value->getRaw());
-
 
434
                    
-
 
435
                    if(!$isJson) {
-
 
436
                        $isJson = strpos($raw, 'json');
-
 
437
                    }
-
 
438
                    
-
 
439
                }
-
 
440
            }
-
 
441
            
-
 
442
            if($isJson) {
-
 
443
               
-
 
444
                
-
 
445
                
-
 
446
            } else {
-
 
447
                
-
 
448
 
-
 
449
            }
-
 
450
            
-
 
451
        } else {
-
 
452
            return new JsonModel([
377
        
Línea 453... Línea 378...
453
                'success' => false,
378
 
454
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
379