Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 6983 Rev 6990
Línea 672... Línea 672...
672
                $capsule->marketplace = null;
672
                $capsule->marketplace = null;
Línea 673... Línea 673...
673
                
673
                
Línea 674... Línea 674...
674
                if($capsuleMapper->update($capsule)) {
674
                if($capsuleMapper->update($capsule)) {
-
 
675
                    
-
 
676
                    $capsule = $capsuleMapper->fetchOne($capsule->id);
-
 
677
                  
-
 
678
                    $fileBase64Content = $this->params()->fromPost('file');
-
 
679
                    try {
-
 
680
                        if($topic->image) {
-
 
681
                                
-
 
682
                            if(!image ::delete($target_path, $capsule->image)) {
-
 
683
                                return new JsonModel([
-
 
684
                                    'success'   => false,
-
 
685
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
686
                                ]);
-
 
687
                            }
-
 
688
                        }
675
                    
689
                        
-
 
690
                        $fileBase64Content = base64_decode($fileBase64Content);
-
 
691
                        $target_path = $this->config['leaderslinked.fullpath.microlearning_capsule'] . $capsule->uuid;
676
                    $capsule = $capsuleMapper->fetchOne($capsule->id);
692
                        $capsule_filename      = 'capsule-' .uniqid() . '.jpg';
677
                    $target_path = $this->config['leaderslinked.fullpath.microlearning_capsule'] .  $capsule->uuid;
693
                        $capsule_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
694
                        if(!file_exists($capsule_tmp_filename)) {
-
 
695
                            mkdir($capsule_tmp_filename, 0755, true);
-
 
696
                        }
-
 
697
                        $capsule_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $capsule_filename;
-
 
698
                            file_put_contents($capsule_tmp_filename, $fileBase64Content);
-
 
699
                        
-
 
700
                        list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.microlearning_image_size']);
-
 
701
 
-
 
702
                        $crop_to_dimensions = false;
-
 
703
                        if(Image::uploadImage($capsule_tmp_filename, $target_path, $capsule_filename, $target_width, $target_height, $crop_to_dimensions )) {
-
 
704
                            $capsule->image = basename($capsule_filename);
-
 
705
                            $capsuleMapper->update($capsule);
-
 
706
                        }
678
                    if(!file_exists($target_path)) {
707
                    } catch(\Throwable $e) {
-
 
708
                        error_log($e->getTraceAsString());
-
 
709
                    }  
-
 
710
 
-
 
711
                    $fileBase64Content2 = $this->params()->fromPost('marketplace'); 
-
 
712
                    try {
-
 
713
                        if($topic->marketplace) {
-
 
714
                                
-
 
715
                            if(!image ::delete($target_path, $capsule->marketplace)) {
-
 
716
                                return new JsonModel([
-
 
717
                                    'success'   => false,
-
 
718
                                    'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
719
                                ]);
-
 
720
                            }
-
 
721
                        }
-
 
722
                        $fileBase64Content2 = base64_decode($fileBase64Content2);
-
 
723
                        $target_path2 = $this->config['leaderslinked.fullpath.microlearning_capsule'] . $capsule->uuid;
-
 
724
                        $capsule_filename2  = 'marketplace-' .uniqid() . '.jpg';
-
 
725
                        $capsule_tmp_filename2 = 'data' . DIRECTORY_SEPARATOR . 'tmp';
-
 
726
                        if(!file_exists($capsule_tmp_filename2)) {
-
 
727
                            mkdir($capsule_tmp_filename2, 0755, true);
-
 
728
                        }
679
                        mkdir($target_path, 0755, true);
729
                        $capsule_tmp_filename2 = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $capsule_filename2;
-
 
730
                            file_put_contents($capsule_tmp_filename2, $fileBase64Content2);
680
                    }
731
                         
-
 
732
                            list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.marketplace']);
-
 
733
 
-
 
734
                        $crop_to_dimensions = false;
-
 
735
                        if(Image::uploadImage($capsule_tmp_filename2, $target_path2, $capsule_filename2, $target_width, $target_height, $crop_to_dimensions )) {
-
 
736
                            $capsule->marketplace = basename($capsule_filename2);
-
 
737
                            $capsuleMapper->update($capsule);
-
 
738
                        }
-
 
739
                    } catch(\Throwable $e) {
-
 
740
                        error_log($e->getTraceAsString());
681
                    
741
                    }  
682
                    
742
                    /*
683
                    $files = $this->getRequest()->getFiles()->toArray();
743
                    $files = $this->getRequest()->getFiles()->toArray();
684
                    if(isset($files['file']) && empty($files['file']['error'])) {
744
                    if(isset($files['file']) && empty($files['file']['error'])) {
Línea 736... Línea 796...
736
                            }
796
                            }
737
                        } catch(\Throwable $e) {
797
                        } catch(\Throwable $e) {
738
                            error_log($e->getTraceAsString());
798
                            error_log($e->getTraceAsString());
739
                        }
799
                        }
740
                    }
800
                    }
741
                    
-
 
-
 
801
                    */
742
                    $this->logger->info('Se edito la cápsula ' . $capsule->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
802
                    $this->logger->info('Se edito la cápsula ' . $capsule->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
Línea 743... Línea 803...
743
                    
803
                    
744
                    $data = [
804
                    $data = [
745
                        'success'   => true,
805
                        'success'   => true,