Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16769 Rev 17002
Línea 13... Línea 13...
13
use LeadersLinked\Mapper\EngagementRewardMapper;
13
use LeadersLinked\Mapper\EngagementRewardMapper;
14
use LeadersLinked\Model\EngagementReward;
14
use LeadersLinked\Model\EngagementReward;
15
use LeadersLinked\Library\Image;
15
use LeadersLinked\Library\Image;
16
use LeadersLinked\Form\Engagement\EngagementRewardAddForm;
16
use LeadersLinked\Form\Engagement\EngagementRewardAddForm;
17
use LeadersLinked\Form\Engagement\EngagementRewardEditForm;
17
use LeadersLinked\Form\Engagement\EngagementRewardEditForm;
-
 
18
use LeadersLinked\Library\Storage;
Línea 18... Línea 19...
18
 
19
 
19
class EngagementRewardController extends AbstractActionController
20
class EngagementRewardController extends AbstractActionController
20
{
21
{
21
    /**
22
    /**
Línea 118... Línea 119...
118
                }
119
                }
Línea 119... Línea 120...
119
                
120
                
120
                $recompensaMapper = EngagementRewardMapper::getInstance($this->adapter);
121
                $recompensaMapper = EngagementRewardMapper::getInstance($this->adapter);
Línea -... Línea 122...
-
 
122
                $paginator = $recompensaMapper->fetchAllDataTable($currentCompany->id, $search,  $page, $records_x_page, $order_field, $order_direction);
-
 
123
                
Línea 121... Línea 124...
121
                $paginator = $recompensaMapper->fetchAllDataTable($currentCompany->id, $search,  $page, $records_x_page, $order_field, $order_direction);
124
                $storage = Storage::getInstance($this->config);
122
                
125
                $path = $storage->getPathEngagementReward();
123
                
126
                
124
                $items = [];
127
                $items = [];
Línea 130... Línea 133...
130
                    
133
                    
131
                    $item = [
134
                    $item = [
132
                        'name' => $record->name,
135
                        'name' => $record->name,
133
                        'status' => $record->status,
136
                        'status' => $record->status,
134
                        'points' => $record->points,
137
                        'points' => $record->points,
135
                        'image' => $this->url()->fromRoute('storage', ['type' => 'engagement-reward', 'code' => $record->uuid, 'filename' => $record->image]),
138
                        'image' => $storage->getGenericImage($path, $record->uuid, $record->image),
136
                        'actions' => [
139
                        'actions' => [
137
                            'link_edit' => $this->url()->fromRoute('engagement/rewards/edit', ['id' => $record->uuid ]),
140
                            'link_edit' => $this->url()->fromRoute('engagement/rewards/edit', ['id' => $record->uuid ]),
138
                            'link_delete' => $this->url()->fromRoute('engagement/rewards/delete', ['id' => $record->uuid ]),
141
                            'link_delete' => $this->url()->fromRoute('engagement/rewards/delete', ['id' => $record->uuid ]),
139
                        ]
142
                        ]
Línea 223... Línea 226...
223
                        $tmp_filename  = $files['image']['tmp_name'];
226
                        $tmp_filename  = $files['image']['tmp_name'];
224
                        $filename      = explode('.',  $files['image']['name']);
227
                        $filename      = explode('.',  $files['image']['name']);
225
                        $filename       = Functions::normalizeStringFilename(uniqid() . '-' . $filename[0].'.png');
228
                        $filename       = Functions::normalizeStringFilename(uniqid() . '-' . $filename[0].'.png');
Línea 226... Línea 229...
226
                        
229
                        
-
 
230
                        $crop_to_dimensions = true;
Línea -... Línea 231...
-
 
231
                        $unlink_source = true;
-
 
232
                        
Línea 227... Línea 233...
227
                        $crop_to_dimensions = true;
233
                        $image = Image::getInstance($this->config);
228
                        
234
                        $target_path = $image->getStorage()->getPathEngagementReward();
229
                        
235
                        
230
                        if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
236
                        if($image->uploadImageChangeSize($tmp_filename, $target_path, $recompensa->uuid, $filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
231
                            $recompensa->image = $filename;
237
                            $recompensa->image = $filename;
Línea 313... Línea 319...
313
            
319
            
314
            $result =  $recompensaMapper->delete($recompensa);
320
            $result =  $recompensaMapper->delete($recompensa);
315
            if($result) {
321
            if($result) {
Línea -... Línea 322...
-
 
322
                $this->logger->info('Se borro la recompensa : ' .  $recompensa->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
-
 
323
                
316
                $this->logger->info('Se borro la recompensa : ' .  $recompensa->name, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
324
               
317
                
-
 
318
                if($recompensa->image) {
-
 
319
                    
325
                
320
                    $target_path = $this->config['leaderslinked.fullpath.engagement_reward']  . $recompensa->image;
326
                if($recompensa->image) {
321
                    if(file_exists($target_path)) {
-
 
322
                        Functions::rmDirRecursive($target_path);
327
                    $storage = Storage::getInstance($this->config);
-
 
328
                    $target_path = $storage->getPathEngagementReward();
323
                    }
329
               
Línea 324... Línea 330...
324
                    
330
                    $storage->deleteFile($target_path, $recompensa->uuid, $recompensa->image);
325
                }
331
                }
326
                
332
                
Línea 377... Línea 383...
377
                'data'   => 'ERROR_UNAUTHORIZED'
383
                'data'   => 'ERROR_UNAUTHORIZED'
378
            ]);
384
            ]);
379
        }
385
        }
Línea 380... Línea 386...
380
        
386
        
-
 
387
        if($request->isGet()) {
-
 
388
            $storage = Storage::getInstance($this->config);
-
 
389
            $path = $storage->getPathEngagementReward();
381
        if($request->isGet()) {
390
            
382
            $data = [
391
            $data = [
383
                'success' => true,
392
                'success' => true,
384
                'data' => [
393
                'data' => [
385
                    'name' => $recompensa->name,
394
                    'name' => $recompensa->name,
386
                    'status' => $recompensa->status,
395
                    'status' => $recompensa->status,
387
                    'points' => $recompensa->points,
396
                    'points' => $recompensa->points,
388
                    'image' => $recompensa->image ? $this->url()->fromRoute('storage', ['type' => 'daily-pulse', 'code' => $recompensa->uuid, 'filename' => $recompensa->image]) : '',
397
                    'image' => $recompensa->image ? $storage->getGenericImage($path,  $recompensa->uuid, $recompensa->image) : '',
389
                ]
398
                ]
Línea 390... Línea 399...
390
            ];
399
            ];
391
            
400
            
Línea 424... Línea 433...
424
                        $tmp_filename  = $files['image']['tmp_name'];
433
                        $tmp_filename  = $files['image']['tmp_name'];
425
                        $filename      = explode('.',  $files['image']['name']);
434
                        $filename      = explode('.',  $files['image']['name']);
426
                        $filename       = Functions::normalizeStringFilename(uniqid() . '-' . $filename[0].'.png');
435
                        $filename       = Functions::normalizeStringFilename(uniqid() . '-' . $filename[0].'.png');
Línea 427... Línea 436...
427
                        
436
                        
428
                        $crop_to_dimensions = true;
-
 
-
 
437
                        $crop_to_dimensions = true;
Línea -... Línea 438...
-
 
438
                        $unlink_source = true;
-
 
439
                        
429
 
440
                        $image = Image::getInstance($this->config);
-
 
441
                        
Línea 430... Línea 442...
430
                        
442
                        if($image->uploadImageChangeSize($tmp_filename, $target_path, $recompensa->uuid, $filename, $target_width, $target_height, $crop_to_dimensions, $unlink_source)) {
431
                        if(Image::uploadImage($tmp_filename, $target_path, $filename, $target_width, $target_height, $crop_to_dimensions)) {
-
 
432
                            
443
 
433
                            if($recompensa->image) {
-
 
434
                                
444
                            
435
                                $target_path_delete = $target_path . $recompensa->image;
-
 
436
                                if(file_exists($target_path_delete)) {
-
 
437
                                    Functions::rmDirRecursive($target_path_delete);
445
                            if($recompensa->image) {
Línea 438... Línea 446...
438
                                }
446
                                $target_path = $image->getStorage()->getPathEngagementReward();
439
                                
447
                                $image->getStorage()->deleteFile($target_path, $recompensa->uuid, $recompensa->image);
440
                            }
448
                            }