Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 190 Rev 283
Línea 51... Línea 51...
51
use PayPalCheckoutSdk\Core\SandboxEnvironment;
51
use PayPalCheckoutSdk\Core\SandboxEnvironment;
52
use PayPalCheckoutSdk\Core\ProductionEnvironment;
52
use PayPalCheckoutSdk\Core\ProductionEnvironment;
53
use PayPalCheckoutSdk\Core\PayPalHttpClient;
53
use PayPalCheckoutSdk\Core\PayPalHttpClient;
54
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
54
use PayPalCheckoutSdk\Orders\OrdersCreateRequest;
55
use Laminas\Mvc\I18n\Translator;
55
use Laminas\Mvc\I18n\Translator;
-
 
56
use LeadersLinked\Library\S3Files;
-
 
57
use LeadersLinked\Library\Storage;
Línea 56... Línea 58...
56
 
58
 
57
 
59
 
58
class AccountSettingController extends AbstractActionController
60
class AccountSettingController extends AbstractActionController
Línea 174... Línea 176...
174
                        break;
176
                        break;
Línea 175... Línea 177...
175
                        
177
                        
176
                }
178
                }
Línea -... Línea 179...
-
 
179
            }
-
 
180
            
-
 
181
            $storage = Storage::getInstance($this->config);
177
            }
182
            $image =  $storage->getUserImage($currentUser);
178
            
183
 
179
            return new JsonModel([
184
            return new JsonModel([
180
                'tab' => $tab,
185
                'tab' => $tab,
181
                'balance' => number_format(floatval($currentUser->balance), 2),
186
                'balance' => number_format(floatval($currentUser->balance), 2),
Línea 188... Línea 193...
188
                    '50' => '50 LABEL_USD',
193
                    '50' => '50 LABEL_USD',
189
                    '75' => '75 LABEL_USD',
194
                    '75' => '75 LABEL_USD',
190
                    '100' => '100 LABEL_USD',
195
                    '100' => '100 LABEL_USD',
191
                ],
196
                ],
192
                'usertype_id' => $currentUser->usertype_id,
197
                'usertype_id' => $currentUser->usertype_id,
193
                'image' => $this->url()->fromRoute('storage',['type' => 'user', 'code' => $currentUser->uuid, 'filename' => $currentUser->image],['force_canonical' => true]),
198
                'image' => $image,
194
               
-
 
195
                //'config' => $this->config,
199
                //'config' => $this->config,
196
                'google_map_key' => $google_map_key,
200
                'google_map_key' => $google_map_key,
197
                'location_formatted_address' => $location_formatted_address,
201
                'location_formatted_address' => $location_formatted_address,
198
                'google' => $google, 
202
                'google' => $google, 
199
                'facebook' => $facebook, 
203
                'facebook' => $facebook, 
Línea 441... Línea 445...
441
            $currentUserPlugin = $this->plugin('currentUserPlugin');
445
            $currentUserPlugin = $this->plugin('currentUserPlugin');
442
            $currentUser = $currentUserPlugin->getUser();
446
            $currentUser = $currentUserPlugin->getUser();
Línea 443... Línea 447...
443
            
447
            
Línea -... Línea 448...
-
 
448
            $userMapper = UserMapper::getInstance($this->adapter);
-
 
449
            
444
            $userMapper = UserMapper::getInstance($this->adapter);
450
          
-
 
451
            $storage = Storage::getInstance($this->config);
Línea 445... Línea 452...
445
            
452
            $image = $storage->getUserImage($currentUser);
446
            $target_path = $this->config['leaderslinked.fullpath.user'] . DIRECTORY_SEPARATOR . $currentUser->uuid;
453
 
447
            
454
            
448
            return new JsonModel([
455
            return new JsonModel([
Línea 449... Línea 456...
449
                'success' => true,
456
                'success' => true,
-
 
457
                'data' => $image,
450
                'data' => $this->url()->fromRoute('storage', ['code' => $currentUser->uuid, 'type' => 'user', 'filename' => $currentUser->image],['force_canonical' => true])
458
            ]);
-
 
459
            
Línea 451... Línea 460...
451
            ]);
460
            
Línea 452... Línea 461...
452
            
461
        } else  if($request->isPost()) {
453
            
462
            $image = Image::getInstance($this->config);
Línea 454... Línea 463...
454
        } else  if($request->isPost()) {
463
            $target_path = $image->getStorage()->getPathUser();
455
            $target_path = $this->config['leaderslinked.fullpath.user'] . DIRECTORY_SEPARATOR . $currentUser->uuid;
464
            
456
            
465
            
457
            $userMapper = UserMapper::getInstance($this->adapter);
466
            $userMapper = UserMapper::getInstance($this->adapter);
458
 
467
 
459
            if($operation == 'delete') {
468
            if($operation == 'delete') {
460
                $this->logger->info('Se borro el image  del usuario ', ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
469
                $this->logger->info('Se borro el image  del usuario ', ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
Línea 495... Línea 504...
495
                        ]);
504
                        ]);
Línea 496... Línea 505...
496
                        
505
                        
Línea -... Línea 506...
-
 
506
                        
497
                        
507
                    }
-
 
508
                    
498
                    }
509
 
499
                    
510
                    if($currentUser->image) {
500
                    if($currentUser->image) {
511
                       
501
                        if(!Image::delete($target_path, $currentUser->image)) {
512
                        if(!$image->getStorage()->deleteFile($target_path, $currentUser->uuid, $currentUser->image)) {
502
                            return new JsonModel([
513
                           return new JsonModel([
503
                                'success'   => false,
514
                                'success'   => false,
504
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
515
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
Línea 505... Línea -...
505
                            ]);
-
 
-
 
516
                            ]);
506
                        }
517
                        }
-
 
518
                    }
-
 
519
                    
-
 
520
                    
507
                    }
521
                    list( $target_width, $target_height ) = explode('x', $this->config['leaderslinked.image_sizes.user_size']);
-
 
522
                    
508
                    
523
           
509
                    $target_filename    = 'user-' . uniqid() . '.png';
524
                    $target_filename    = 'user-' . uniqid() . '.png';
510
                    list( $target_width, $target_height ) = explode('x', $this->config['leaderslinked.image_sizes.user_size']);
525
                    $source             = $files['image']['tmp_name'];
511
                    $source             = $files['image']['tmp_name'];
526
                    $unlink_source      = false;
512
                    $crop_to_dimensions = true;
527
                    $crop_to_dimensions = true;
513
                    if(!Image::uploadImage($source, $target_path, $target_filename, $target_width, $target_height, $crop_to_dimensions)) {
528
                    if(!$image->uploadImageChangeSize($source, $target_path, $currentUser->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
514
                        return new JsonModel([
529
                        return new JsonModel([
Línea 524... Línea 539...
524
                        return new JsonModel([
539
                        return new JsonModel([
525
                            'success'   => false,
540
                            'success'   => false,
526
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
541
                            'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
527
                        ]);
542
                        ]);
528
                    } else {
543
                    } else {
-
 
544
                        $unlink_source      = true;
-
 
545
                        $target_filename    = 'user-profile-' . uniqid() . '.png';
Línea -... Línea 546...
-
 
546
                        
-
 
547
                        if(!$image->uploadImageChangeSize($source, $target_path, $currentUser->uuid, $target_filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
-
 
548
                            return new JsonModel([
-
 
549
                                'success'   => false,
-
 
550
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
551
                            ]);
Línea 529... Línea 552...
529
                        
552
                        }
530
                       
553
                       
Línea 555... Línea 578...
555
                        'success'   => false,
578
                        'success'   => false,
556
                        'data'   => $messages
579
                        'data'   => $messages
557
                    ]);
580
                    ]);
558
                }
581
                }
559
            }
582
            }
-
 
583
            
-
 
584
            $storage = Storage::getInstance($this->config);
-
 
585
            
-
 
586
            
560
            return new JsonModel([
587
            return new JsonModel([
561
                'success'   => true,
588
                'success'   => true,
562
                'data' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $currentUser->uuid, 'filename' => $currentUser->image],['force_canonical' => true])
589
                'data' =>  $storage->getUserImage(currentUser)
Línea 563... Línea 590...
563
                
590
                
564
            ]);
591
            ]);