Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 111 Rev 283
Línea 33... Línea 33...
33
use LeadersLinked\Mapper\IndustryMapper;
33
use LeadersLinked\Mapper\IndustryMapper;
34
use LeadersLinked\Mapper\GroupTypeMapper;
34
use LeadersLinked\Mapper\GroupTypeMapper;
35
use LeadersLinked\Mapper\GroupMemberMapper;
35
use LeadersLinked\Mapper\GroupMemberMapper;
36
use LeadersLinked\Mapper\QueryMapper;
36
use LeadersLinked\Mapper\QueryMapper;
37
use LeadersLinked\Model\GroupMember;
37
use LeadersLinked\Model\GroupMember;
-
 
38
use LeadersLinked\Library\Storage;
Línea 38... Línea 39...
38
 
39
 
39
class MyGroupsController extends AbstractActionController
40
class MyGroupsController extends AbstractActionController
40
{
41
{
41
    /**
42
    /**
Línea 130... Línea 131...
130
                $values = [
131
                $values = [
131
                    Group::PRIVACY_IS_PRIVATE => 'LABEL_PRIVATE',
132
                    Group::PRIVACY_IS_PRIVATE => 'LABEL_PRIVATE',
132
                    Group::PRIVACY_IS_PUBLIC => 'LABEL_PUBLIC'
133
                    Group::PRIVACY_IS_PUBLIC => 'LABEL_PUBLIC'
133
                ];
134
                ];
Línea -... Línea 135...
-
 
135
 
Línea 134... Línea 136...
134
 
136
                $storage = Storage::getInstance($this->config);
135
                
137
                
136
                $items = [];
138
                $items = [];
Línea 137... Línea 139...
137
                foreach($records as $record)
139
                foreach($records as $record)
138
                {
140
                {
139
                    
141
                    
140
                    $item = [
142
                    $item = [
141
                        'name' => $record['name'],
143
                        'name' => $record['name'],
142
                        'privacy' => $values[$record['privacy']],
144
                        'privacy' => $values[$record['privacy']],
143
                        'image' => $this->url()->fromRoute('storage', ['type' => 'group', 'code' => $record['uuid'], 'filename' => $record['image'] ],['force_canonical' => true]),
145
                        'image' => $storage->getGroupImageForCodeAndFilename($record['uuid'],  $record['image']),
Línea 144... Línea 146...
144
                        'link_view' => $allowView ? $this->url()->fromRoute('group/view', ['id' => $record['uuid'] ])  : '',
146
                        'link_view' => $allowView ? $this->url()->fromRoute('group/view', ['id' => $record['uuid'] ])  : '',
Línea 429... Línea 431...
429
                $total_members = $groupMemberMapper->fetchTotalByGroupId($group->id);
431
                $total_members = $groupMemberMapper->fetchTotalByGroupId($group->id);
Línea 430... Línea 432...
430
                
432
                
431
                $image_size_cover = $this->config['leaderslinked.image_sizes.group_cover_upload'];
433
                $image_size_cover = $this->config['leaderslinked.image_sizes.group_cover_upload'];
Línea 432... Línea -...
432
                $image_size_profile = $this->config['leaderslinked.image_sizes.group_image_upload'];
-
 
-
 
434
                $image_size_profile = $this->config['leaderslinked.image_sizes.group_image_upload'];
Línea 433... Línea 435...
433
                
435
                
434
                
436
                $storage = Storage::getInstance($this->config);
435
                
437
                
Línea 441... Línea 443...
441
                    'industry'              => $industry,
443
                    'industry'              => $industry,
442
                    'group_id'              => $group->id,
444
                    'group_id'              => $group->id,
443
                    'group_type'            => $group_type,
445
                    'group_type'            => $group_type,
444
                    'group_uuid'            => $group->uuid,
446
                    'group_uuid'            => $group->uuid,
445
                    'name'                  => trim($group->name),
447
                    'name'                  => trim($group->name),
446
                    'image'                 => $this->url()->fromRoute('storage', ['type' => 'group', 'code' => $group->uuid, 'filename' => $group->image],['force_canonical' => true]),
448
                    'image'                 => $storage->getGroupImage($group),
447
                    'cover'                 => $this->url()->fromRoute('storage', ['type' => 'group-cover', 'code' => $group->uuid, 'filename' => $group->cover],['force_canonical' => true]),
449
                    'cover'                 => $storage->getGroupCover($group),
448
                    'overview'              => $group->description,
450
                    'overview'              => $group->description,
449
                    'website'               => $group->website,
451
                    'website'               => $group->website,
450
                    'image_size_cover'      => $image_size_cover,
452
                    'image_size_cover'      => $image_size_cover,
451
                    'image_size_profile'    => $image_size_profile,
453
                    'image_size_profile'    => $image_size_profile,
Línea 599... Línea 601...
599
        
601
        
600
        
602
        
-
 
603
        
601
        
604
        $request = $this->getRequest();
Línea 602... Línea 605...
602
        $request = $this->getRequest();
605
        if($request->isPost()) {
603
        if($request->isPost()) {
606
            $image = Image::getInstance($this->config);
604
            $target_path = $this->config['leaderslinked.fullpath.group'] . DIRECTORY_SEPARATOR . $group->uuid;
607
            $target_path = $image->getStorage()->getPathGroup();
605
 
608
 
606
            
609
            
607
            if($operation == 'delete') {
610
            if($operation == 'delete') {
608
                $this->logger->info('Se borro el image del grupo : ' .  $group->name, ['user_id' => $group->user_id, 'ip' => Functions::getUserIP()]);
611
                $this->logger->info('Se borro el image del grupo : ' .  $group->name, ['user_id' => $group->user_id, 'ip' => Functions::getUserIP()]);
609
                if($group->image) {
612
                if($group->image) {
610
                    if(!Image::delete($target_path, $group->image)) {
613
                    if(!$image->getStorage()->deleteFile($target_path, $group->uuid, $group->image)) {
Línea 642... Línea 645...
642
                        
645
                        
Línea 643... Línea 646...
643
                        
646
                        
644
                    }
647
                    }
645
                    
648
                    
646
                    if($group->image) {
649
                    if($group->image) {
647
                        if(!Image::delete($target_path, $group->image)) {
650
                        if(!$image->getStorage()->deleteFile($target_path, $group->uuid, $group->image)) {
648
                            return new JsonModel([
651
                            return new JsonModel([
649
                                'success'   => false,
652
                                'success'   => false,
Línea 655... Línea 658...
655
                    
658
                    
656
                    list( $target_width, $target_height ) = explode('x', $this->config['leaderslinked.image_sizes.group_image_size']);
659
                    list( $target_width, $target_height ) = explode('x', $this->config['leaderslinked.image_sizes.group_image_size']);
657
                    $source             = $files['image']['tmp_name'];
660
                    $source             = $files['image']['tmp_name'];
658
                    $target_filename    = 'group-image-' . uniqid() . '.png';
661
                    $target_filename    = 'group-image-' . uniqid() . '.png';
-
 
662
                    $crop_to_dimensions = true;
Línea 659... Línea 663...
659
                    $crop_to_dimensions = true;
663
                    $unlink_source = true;
660
                    
664
                    
661
                    if(!Image::uploadImage($source, $target_path, $target_filename, $target_width, $target_height, $crop_to_dimensions)) {
665
                    if(!$image->uploadImageChangeSize($source, $target_path, $group->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
662
                        return new JsonModel([
666
                        return new JsonModel([
663
                            'success'   => false,
667
                            'success'   => false,
664
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
668
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
Línea 687... Línea 691...
687
                        'success'   => false,
691
                        'success'   => false,
688
                        'data'   => $messages
692
                        'data'   => $messages
689
                    ]);
693
                    ]);
690
                }
694
                }
691
            }
695
            }
-
 
696
            
-
 
697
            $storage = Storage::getInstance($this->config);
-
 
698
            
692
            return new JsonModel([
699
            return new JsonModel([
693
                'success'   => true,
700
                'success'   => true,
694
                'data' => $this->url()->fromRoute('storage', ['type' => 'group', 'code' => $group->uuid, 'filename' => $group->image],['force_canonical' => true])
701
                'data' => $storage->getGroupImage($group),
Línea 695... Línea 702...
695
                
702
                
696
            ]);
703
            ]);
Línea 740... Línea 747...
740
        
747
        
741
        
748
        
-
 
749
        
742
        
750
        $request = $this->getRequest();
Línea 743... Línea 751...
743
        $request = $this->getRequest();
751
        if($request->isPost()) {
744
        if($request->isPost()) {
752
            $image = Image::getInstance($this->config);
745
            $target_path = $this->config['leaderslinked.fullpath.group'] . DIRECTORY_SEPARATOR . $group->uuid;
753
            $target_path = $image->getStorage()->getPathGroup();
746
            
754
            
747
            
755
            
748
            if($operation == 'delete') {
756
            if($operation == 'delete') {
749
                if($group->cover) {
757
                if($group->cover) {
750
                    if(!Image::delete($target_path, $group->cover)) {
758
                    if(!$image->getStorage()->delete($target_path, $group->uuid, $group->cover)) {
Línea 783... Línea 791...
783
                        
791
                        
Línea 784... Línea 792...
784
                        
792
                        
785
                    }
793
                    }
786
                    
794
                    
787
                    if($group->cover) {
795
                    if($group->cover) {
788
                        if(!Image::delete($target_path, $group->cover)) {
796
                        if(!$image->getStorage()->delete($target_path, $group->uuid, $group->cover)) {
789
                            return new JsonModel([
797
                            return new JsonModel([
790
                                'success'   => false,
798
                                'success'   => false,
Línea 795... Línea 803...
795
 
803
 
796
                    list( $target_width, $target_height ) = explode('x', $this->config['leaderslinked.image_sizes.group_cover_size']);
804
                    list( $target_width, $target_height ) = explode('x', $this->config['leaderslinked.image_sizes.group_cover_size']);
797
                    $source             = $files['cover']['tmp_name'];
805
                    $source             = $files['cover']['tmp_name'];
798
                    $target_filename    = 'group-cover-' . uniqid() . '.png';
806
                    $target_filename    = 'group-cover-' . uniqid() . '.png';
-
 
807
                    $crop_to_dimensions = false;
Línea 799... Línea 808...
799
                    $crop_to_dimensions = false;
808
                    $unlink_source = true;
800
                    
809
                    
801
                    if(!Image::uploadImage($source, $target_path, $target_filename, $target_width, $target_height, $crop_to_dimensions)) {
810
                    if(!$image->uploadImageChangeSize($source, $target_path, $group->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
802
                        return new JsonModel([
811
                        return new JsonModel([
803
                            'success'   => false,
812
                            'success'   => false,
804
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
813
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
Línea 829... Línea 838...
829
                        'success'   => false,
838
                        'success'   => false,
830
                        'data'   => $messages
839
                        'data'   => $messages
831
                    ]);
840
                    ]);
832
                }
841
                }
833
            }
842
            }
-
 
843
            
-
 
844
            $storage = Storage::getInstance($this->config);
-
 
845
            
834
            return new JsonModel([
846
            return new JsonModel([
835
                'success'   => true,
847
                'success'   => true,
836
                'data' => $this->url()->fromRoute('storage', ['type' => 'group-cover', 'code' => $group->uuid, 'filename' => $group->cover],['force_canonical' => true])
848
                'data' => $storage->getGroupCover($group),
Línea 837... Línea 849...
837
                
849
                
838
            ]);
850
            ]);