Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 5915 Rev 5993
Línea 454... Línea 454...
454
                $topic->image = null;
454
                $topic->image = null;
455
                $topic->marketplace = null;
455
                $topic->marketplace = null;
Línea 456... Línea 456...
456
 
456
 
457
                if($topicMapper->update($topic)) {
457
                if($topicMapper->update($topic)) {
-
 
458
                    $topic = $topicMapper->fetchOne($topic->id);
-
 
459
                    $fileBase64Content = $this->params()->fromPost('file');
-
 
460
 
-
 
461
                    try {
-
 
462
                       
-
 
463
                        $fileBase64Content = base64_decode($fileBase64Content);
-
 
464
                        $target_path = $this->config['leaderslinked.fullpath.microlearning_topic'] . $topic->uuid;
-
 
465
                        $topic_filename      = 'topic-' .uniqid() . '.png';
-
 
466
                        $topic_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
467
                        if(!file_exists($topic_tmp_filename)) {
-
 
468
                            mkdir($topic_tmp_filename, 0755, true);
-
 
469
                        }
-
 
470
                        $topic_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $topic_filename;
-
 
471
                            file_put_contents($topic_tmp_filename, $fileBase64Content);
-
 
472
                        
-
 
473
                        list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
-
 
474
 
-
 
475
                        $crop_to_dimensions = false;
-
 
476
                        if(Image::uploadImage($topic_tmp_filename, $target_path, $topic_filename, $target_width, $target_height, $crop_to_dimensions )) {
-
 
477
                            $topic->image = basename($topic_filename);
-
 
478
                            $topicMapper->update($topic);
-
 
479
                        }
-
 
480
                    } catch(\Throwable $e) {
-
 
481
                        error_log($e->getTraceAsString());
-
 
482
                    }       
-
 
483
                   
-
 
484
                    $this->logger->info('Se agrego el tópico ' . $topic->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
-
 
485
                    
-
 
486
                    $data = [
-
 
487
                        'success'   => true,
-
 
488
                        'data'   => 'LABEL_RECORD_ADDED'
-
 
489
                    ];
-
 
490
                    /*
Línea 458... Línea 491...
458
                    $topic = $topicMapper->fetchOne($topic->id);
491
                    $topic = $topicMapper->fetchOne($topic->id);
459
                    
492
                    
460
                    
493
                    
Línea 499... Línea 532...
499
                    $this->logger->info('Se edito el tópico ' . $topic->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
532
                    $this->logger->info('Se edito el tópico ' . $topic->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
Línea 500... Línea 533...
500
                    
533
                    
501
                    $data = [
534
                    $data = [
502
                        'success'   => true,
535
                        'success'   => true,
503
                        'data'   => 'LABEL_RECORD_UPDATED'
536
                        'data'   => 'LABEL_RECORD_UPDATED'
504
                    ];
537
                    ];*/
505
                } else {
538
                } else {
506
                    $data = [
539
                    $data = [
507
                        'success'   => false,
540
                        'success'   => false,
508
                        'data'      => $topicMapper->getError()
541
                        'data'      => $topicMapper->getError()