Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 334 Rev 345
Línea 4... Línea 4...
4
use LeadersLinked\Model\User;
4
use LeadersLinked\Model\User;
5
use LeadersLinked\Model\UserProfile;
5
use LeadersLinked\Model\UserProfile;
6
use LeadersLinked\Model\Company;
6
use LeadersLinked\Model\Company;
7
use LeadersLinked\Model\Group;
7
use LeadersLinked\Model\Group;
Línea 8... Línea 8...
8
 
8
 
9
class Storage 
9
class Storage
10
{
10
{
-
 
11
 
-
 
12
    const FILE_TYPE_IMAGE = 'image';
-
 
13
 
-
 
14
    const FILE_TYPE_VIDEO = 'video';
-
 
15
 
-
 
16
    const FILE_TYPE_DOCUMENT = 'document';
-
 
17
 
-
 
18
    const TYPE_DEFAULT = 'default';
11
    
19
 
-
 
20
    const TYPE_CHAT = 'chat';
12
    const TYPE_CHAT                             = 'chat';
21
 
-
 
22
    const TYPE_GROUP = 'group';
13
    const TYPE_GROUP                            = 'group';
23
 
-
 
24
    const TYPE_USER = 'user';
14
    const TYPE_USER                             = 'user';
25
 
-
 
26
    const TYPE_IMAGE = 'image';
15
    const TYPE_IMAGE                            = 'image';
27
 
-
 
28
    const TYPE_JOB = 'job';
-
 
29
 
-
 
30
    const TYPE_MEDIA = 'media';
16
    const TYPE_JOB                              = 'job';
31
 
-
 
32
    const TYPE_COMPANY = 'company';
17
    const TYPE_COMPANY                          = 'company';
33
 
-
 
34
    const TYPE_FEED = 'feed';
18
    const TYPE_FEED                             = 'feed';
35
 
-
 
36
    const TYPE_POST = 'post';
19
    CONST TYPE_POST                             = 'post';
37
 
-
 
38
    const TYPE_MICROLEARNING_TOPIC = 'topic';
20
    const TYPE_MICROLEARNING_TOPIC              = 'topic';
39
 
-
 
40
    const TYPE_MICROLEARNING_CAPSULE = 'capsule';
21
    const TYPE_MICROLEARNING_CAPSULE            = 'capsule';
41
 
-
 
42
    const TYPE_MICROLEARNING_SLIDE = 'slide';
22
    const TYPE_MICROLEARNING_SLIDE              = 'slide';
43
 
-
 
44
    const TYPE_JOB_DESCRIPTION = 'jobdesc';
23
    const TYPE_JOB_DESCRIPTION                  = 'jobdesc';
45
 
-
 
46
    const TYPE_SELF_EVALUATION = 'selfval';
24
    const TYPE_SELF_EVALUATION                  = 'selfval';
47
 
-
 
48
    const TYPE_PERFORMANCE_EVALUATION = 'perfeva';
25
    const TYPE_PERFORMANCE_EVALUATION           = 'perfeva';
49
 
-
 
50
    const TYPE_RECRUITMENT_SELECTION = 'recrsel';
26
    const TYPE_RECRUITMENT_SELECTION            = 'recrsel';
51
 
-
 
52
    const TYPE_PLANNING_OBJECTIVES_AND_GOALS = 'plannig';
27
    const TYPE_PLANNING_OBJECTIVES_AND_GOALS    = 'plannig';
53
 
-
 
54
    const TYPE_MESSAGE = 'message';
28
    const TYPE_MESSAGE                          = 'message';
55
 
-
 
56
    const TYPE_SURVEY = 'survey';
29
    const TYPE_SURVEY                           = 'survey';
57
 
-
 
58
    const TYPE_NETWORK = 'network';
30
    const TYPE_NETWORK                          = 'network';
59
 
-
 
60
    const TYPE_DAILY_PULSE = 'dailpuls';
31
    const TYPE_DAILY_PULSE                      = 'dailpuls';
61
 
-
 
62
    const TYPE_ENGAGEMENT_REWARD = 'engarewr';
32
    const TYPE_ENGAGEMENT_REWARD                = 'engarewr';
63
 
-
 
64
    const TYPE_KNOWLEDGE_AREA = 'knowarea';
33
    const TYPE_KNOWLEDGE_AREA                   = 'knowarea';
65
 
34
    const TYPE_MY_COACH                         = 'mycoach';
-
 
35
    const TYPE_HABIT_EMOJI                      = 'habit-emoji';
-
 
36
    const TYPE_HABIT_CONTENT                    = 'habit-content';
66
    const TYPE_MY_COACH = 'mycoach';
37
    
67
 
38
    const BASE_PATH = 'data' . DIRECTORY_SEPARATOR . 'storage';
68
    const TYPE_HABIT_EMOJI = 'habit-emoji';
-
 
69
 
39
    
70
    const TYPE_HABIT_CONTENT = 'habit-content';
40
    
71
 
41
    /**
72
    /**
42
     * 
73
     *
43
     * @var\LeadersLinked\Library\Storage 
74
     * @var\LeadersLinked\Library\Storage
44
     */
75
     */
45
    private static $_instance;
76
    private static $_instance;
46
    
77
 
47
    /**
78
    /**
48
     * 
79
     *
49
     * @var array
80
     * @var array
50
     */
81
     */
51
    private $config;
82
    private $config;
52
    
83
 
53
    /**
84
    /**
54
     * 
85
     *
55
     * @var \Laminas\Db\Adapter\AdapterInterface 
86
     * @var \Laminas\Db\Adapter\AdapterInterface
56
     */
87
     */
57
    private $adapter;
-
 
58
    
-
 
Línea -... Línea 88...
-
 
88
    private $adapter;
-
 
89
 
-
 
90
    /**
-
 
91
     *
-
 
92
     * @var string
-
 
93
     */
-
 
94
    private $tempPath;
-
 
95
 
-
 
96
    /**
-
 
97
     *
-
 
98
     * @var string
-
 
99
     */
-
 
100
    private $storagePath;
-
 
101
 
-
 
102
    /**
-
 
103
     *
-
 
104
     * @var array
-
 
105
     */
Línea 59... Línea 106...
59
    
106
    private $currentFile;
60
 
107
    
-
 
108
    
-
 
109
    /**
-
 
110
     * 
-
 
111
     * @var array
-
 
112
     */
-
 
113
    private $files;
61
    
114
 
62
    /**
115
    /**
63
     * 
116
     *
64
     * @param array $config
117
     * @param array $config
65
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
118
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
66
     */
119
     */
67
    private function __construct($config, $adapter) 
120
    private function __construct($config, $adapter)
-
 
121
    {
-
 
122
        $this->config = $config;
-
 
123
        $this->adapter = $adapter;
-
 
124
        $this->currentFile = [];
-
 
125
 
-
 
126
        $this->storagePath = 'data' . DIRECTORY_SEPARATOR . 'storage';
-
 
127
        if (! file_exists($this->storagePath)) {
-
 
128
            mkdir($this->tempPath, 0775);
-
 
129
        }
-
 
130
 
-
 
131
        $this->tempPath = 'data' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
-
 
132
 
68
    {
133
        if (! file_exists($this->tempPath)) {
69
        $this->config       = $config;
134
            mkdir($this->tempPath, 0775);
70
        $this->adapter      = $adapter;
135
        }
71
    }
136
    }
72
    
137
 
73
    /**
138
    /**
74
     * 
139
     *
75
     * @param array $config
140
     * @param array $config
76
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
141
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
77
     * @return \LeadersLinked\Library\Storage
142
     * @return \LeadersLinked\Library\Storage
78
     */
143
     */
79
    public static function getInstance($config, $adapter)
144
    public static function getInstance($config, $adapter)
80
    {
145
    {
81
        if(self::$_instance == null) {
146
        if (self::$_instance == null) {
82
            self::$_instance = new Storage($config, $adapter);
147
            self::$_instance = new Storage($config, $adapter);
83
        }
148
        }
-
 
149
 
-
 
150
        return self::$_instance;
-
 
151
    }
-
 
152
 
-
 
153
    /**
-
 
154
     *
-
 
155
     * @return string
-
 
156
     */
-
 
157
    public function getFullPathImageDefault()
-
 
158
    {
-
 
159
        return $this->storagePath . DIRECTORY_SEPARATOR . 'no-image.jpg';
-
 
160
    }
-
 
161
 
-
 
162
    /**
-
 
163
     *
-
 
164
     * @return string
-
 
165
     */
-
 
166
    public function getFullPathImageUserDefault()
-
 
167
    {
-
 
168
        return $this->storagePath . DIRECTORY_SEPARATOR . 'no-image-user.jpg';
-
 
169
    }
-
 
170
 
-
 
171
    /**
-
 
172
     *
-
 
173
     * @return string
-
 
174
     */
-
 
175
    public function getFullPathImageUserPofileDefault()
-
 
176
    {
-
 
177
        return $this->storagePath . DIRECTORY_SEPARATOR . 'no-image-user-profile.png';
-
 
178
    }
-
 
179
 
-
 
180
    /**
-
 
181
     *
-
 
182
     * @return string
-
 
183
     */
-
 
184
    public function getFullPathImageUserCoverDefault()
-
 
185
    {
-
 
186
        return $this->storagePath . DIRECTORY_SEPARATOR . 'no-image-cover.jpg';
-
 
187
    }
-
 
188
 
-
 
189
    /**
-
 
190
     *
-
 
191
     * @return string
-
 
192
     */
-
 
193
    public function getFullPathImageCompanyDefault()
-
 
194
    {
-
 
195
        return $this->storagePath . DIRECTORY_SEPARATOR . 'no-image-company.jpg';
-
 
196
    }
-
 
197
 
-
 
198
    /**
-
 
199
     *
-
 
200
     * @return string
-
 
201
     */
-
 
202
    public function getFullPathImageCompanyCoverDefault()
-
 
203
    {
-
 
204
        return $this->storagePath . DIRECTORY_SEPARATOR . 'no-image-cover.jpg';
-
 
205
    }
-
 
206
 
-
 
207
    /**
-
 
208
     *
-
 
209
     * @return string
-
 
210
     */
-
 
211
    public function getFullPathImageGroupDefault()
-
 
212
    {
-
 
213
        return $this->storagePath . DIRECTORY_SEPARATOR . 'no-image-group.jpg';
-
 
214
    }
-
 
215
 
-
 
216
    /**
-
 
217
     *
-
 
218
     * @return string
-
 
219
     */
-
 
220
    public function getFullPathImageGroupCoverDefault()
-
 
221
    {
-
 
222
        return $this->storagePath . DIRECTORY_SEPARATOR . 'no-image-cover.jpg';
-
 
223
    }
-
 
224
 
-
 
225
    /**
-
 
226
     *
-
 
227
     * @return string
-
 
228
     */
-
 
229
    public function getFullPathImageCompanyHeaderPdfDefault()
-
 
230
    {
-
 
231
        return $this->storagePath . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'company-header.png';
-
 
232
    }
-
 
233
 
-
 
234
    /**
-
 
235
     *
-
 
236
     * @return string
-
 
237
     */
-
 
238
    public function getFullPathImageCompanyFooterPdfDefault()
-
 
239
    {
-
 
240
        return $this->storagePath . DIRECTORY_SEPARATOR . 'default' . DIRECTORY_SEPARATOR . 'company-footer.png';
-
 
241
    }
-
 
242
 
-
 
243
    /**
-
 
244
     *
-
 
245
     * @return string
-
 
246
     */
-
 
247
    public function getStoagePath()
-
 
248
    {
-
 
249
        return $this->storagePath;
-
 
250
    }
-
 
251
 
-
 
252
    /**
-
 
253
     *
-
 
254
     * @return string
-
 
255
     */
-
 
256
    public function getTempPath()
-
 
257
    {
-
 
258
        return $this->tempPath;
-
 
259
    }
-
 
260
 
-
 
261
    /**
-
 
262
     *
-
 
263
     * @return array
-
 
264
     */
-
 
265
    public function getCurrentFile()
-
 
266
    {
-
 
267
        return $this->currentFile;
-
 
268
    }
-
 
269
 
-
 
270
    /**
-
 
271
     *
-
 
272
     * @param array $currentFile
-
 
273
     */
-
 
274
    public function setCurrentFile($currentFile)
-
 
275
    {
-
 
276
        $this->currentFile = $currentFile;
-
 
277
    }
-
 
278
 
-
 
279
    /**
-
 
280
     *
-
 
281
     * @param array $filename
-
 
282
     */
-
 
283
    public function setCurrentFilename($filename)
-
 
284
    {
-
 
285
        if(empty($this->files)) {
-
 
286
            if (isset($_FILES[$filename]) && empty($_FILES[$filename]['error'])) {
-
 
287
                $this->currentFile = $_FILES[$filename];
-
 
288
            } else {
-
 
289
                $this->currentFile = [];
-
 
290
            }
-
 
291
        } else {
-
 
292
            if (isset($this->files[$filename]) && empty($this->files[$filename]['error'])) {
-
 
293
                $this->currentFile = $this->files[$filename];
-
 
294
            } else {
-
 
295
                $this->currentFile = [];
-
 
296
                
-
 
297
            }
-
 
298
        }
Línea 84... Línea 299...
84
        
299
        
85
        return self::$_instance;
300
        return !empty($this->currentFile);
-
 
301
    }
-
 
302
    
-
 
303
    /**
-
 
304
     * 
-
 
305
     * @return boolean
-
 
306
     */
-
 
307
    public function hasFile()
-
 
308
    {
-
 
309
        return !empty($this->currentFile);
-
 
310
    }
-
 
311
    
-
 
312
    /**
-
 
313
     * 
-
 
314
     * @param array $files
-
 
315
     */
-
 
316
    public function setFiles($files)
-
 
317
    {
-
 
318
        $this->files = $files;
-
 
319
    }
-
 
320
 
-
 
321
    /**
-
 
322
     *
-
 
323
     * @param string $type
-
 
324
     * @param string $code
-
 
325
     * @param string $filename
-
 
326
     * @return string
-
 
327
     */
-
 
328
    public function composePathToFilename($type, $code, $filename)
-
 
329
    {
-
 
330
        $path = $this->getPathByType($type);
-
 
331
        $path = $path . DIRECTORY_SEPARATOR . $code;
-
 
332
        if (! file_exists($path)) {
-
 
333
            @mkdir($path, 0775, true);
-
 
334
        }
-
 
335
        return $path . DIRECTORY_SEPARATOR . $filename;
-
 
336
    }
-
 
337
 
-
 
338
    /**
-
 
339
     *
-
 
340
     * @param string $type
-
 
341
     * @param string $code
-
 
342
     * @return string
-
 
343
     */
-
 
344
    public function composePathToDirectory($type, $code)
-
 
345
    {
-
 
346
        $path = $this->getPathByType($type);
-
 
347
        $path = $path . DIRECTORY_SEPARATOR . $code;
-
 
348
        if (! file_exists($path)) {
-
 
349
            @mkdir($path, 0775, true);
-
 
350
        }
-
 
351
        return $path;
86
    }
352
    }
87
    
353
 
88
    /**
354
    /**
89
     * 
355
     *
90
     * @param User $user
356
     * @param User $user
91
     * @return string
357
     * @return string
92
     */
358
     */
93
    public function getUserImage($user)
359
    public function getUserImage($user)
94
    {
360
    {
95
        if($user->image) {
-
 
96
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $this->getPathUser() . DIRECTORY_SEPARATOR . $user->uuid . DIRECTORY_SEPARATOR . $user->image;
361
        if ($user->image) {
97
            if(file_exists($remoto)) {
362
            $remoto = $this->composePathToFilename(self::TYPE_USER, $user->uuid, $user->image);
98
                return $this->getPresignedUrl($remoto);
363
            if (file_exists($remoto)) {
99
                
364
                return $this->getPresignedUrl($remoto);
100
            }
365
            }
101
        }
366
        }
102
        
-
 
103
        $remoto = $this->config['leaderslinked.images_default.user_image'];
367
 
104
        return $this->getPresignedUrl($remoto);
368
        $remoto = $this->getFullPathImageUserDefault();
105
    }
369
        return $this->getPresignedUrl($remoto);
106
    
370
    }
107
    
371
 
108
    /**
372
    /**
109
     *
373
     *
110
     * @param User $user
374
     * @param User $user
111
     * @return string
375
     * @return string
112
     */
376
     */
113
    public function getUserImageForCodeAndFilename($code, $filename)
377
    public function getUserImageForCodeAndFilename($code, $filename)
114
    {
378
    {
115
        if($filename) {
-
 
116
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $this->getPathUser() . DIRECTORY_SEPARATOR . $code . DIRECTORY_SEPARATOR . $filename;
379
        if ($filename) {
117
            if(file_exists($remoto)) {
380
            $remoto = $this->composePathToFilename(self::TYPE_USER, $code, $filename);
118
                return $this->getPresignedUrl($remoto);
-
 
119
                
381
            if (file_exists($remoto)) {
120
            }
382
                return $this->getPresignedUrl($remoto);
121
        }
-
 
122
        
383
            }
123
        $remoto = $this->config['leaderslinked.images_default.user_image'];
384
        }
124
        return $this->getPresignedUrl($remoto);
385
        $remoto = $this->getFullPathImageUserDefault();
125
        
386
        return $this->getPresignedUrl($remoto);
126
    }
387
    }
127
    
388
 
128
    /**
389
    /**
129
     *
390
     *
130
     * @param User $user
391
     * @param User $user
131
     * @param UserProfile $userProfile
392
     * @param UserProfile $userProfile
132
     * @return string
393
     * @return string
133
     */
394
     */
134
    public function getUserProfileImage($user, $userProfile)
395
    public function getUserProfileImage($user, $userProfile)
135
    {
396
    {
136
        if($userProfile->image) {
-
 
137
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $this->getPathUser() . DIRECTORY_SEPARATOR . $user->uuid . DIRECTORY_SEPARATOR . $userProfile->image;
397
        if ($userProfile->image) {
138
            if(file_exists($remoto)) {
398
            $remoto = $this->composePathToFilename(self::TYPE_USER, $user->uuid, $userProfile->image);
139
                return $this->getPresignedUrl($remoto);
399
            if (file_exists($remoto)) {
140
                
400
                return $this->getPresignedUrl($remoto);
141
            }
401
            }
142
        }
-
 
143
        
402
        }
144
        $remoto = $this->config['leaderslinked.images_default.user_profile'];
403
 
145
        return $this->getPresignedUrl($remoto);
404
        $remoto = $this->getFullPathImageUserPofileDefault();
146
        
405
        return $this->getPresignedUrl($remoto);
147
    }
406
    }
148
    
407
 
149
    /**
408
    /**
150
     *
409
     *
151
     * @param User $user
410
     * @param User $user
152
     * @param UserProfile $userProfile
411
     * @param UserProfile $userProfile
153
     * @return string
412
     * @return string
154
     */
413
     */
155
    public function getUserProfileCover($user, $userProfile)
414
    public function getUserProfileCover($user, $userProfile)
156
    {
415
    {
157
        if($userProfile->cover) {
-
 
158
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $this->getPathUser() . DIRECTORY_SEPARATOR . $user->uuid . DIRECTORY_SEPARATOR . $userProfile->cover;
416
        if ($userProfile->cover) {
159
            if(file_exists($remoto)) {
417
            $remoto = $this->composePathToFilename(self::TYPE_USER, $user->uuid, $userProfile->cover);
160
                return $this->getPresignedUrl($remoto);
418
            if (file_exists($remoto)) {
161
                
419
                return $this->getPresignedUrl($remoto);
162
            }
420
            }
163
        }
-
 
164
        
421
        }
165
        $remoto = $this->config['leaderslinked.images_default.user_cover'];
422
 
166
        return $this->getPresignedUrl($remoto);
423
        $remoto = $this->getFullPathImageUserCoverDefault();
167
        
424
        return $this->getPresignedUrl($remoto);
168
    }
425
    }
169
    
426
 
170
    /**
427
    /**
171
     *
428
     *
172
     * @param Company $company
429
     * @param Company $company
173
     * @return string
430
     * @return string
174
     */
431
     */
175
    public function getCompanyImage($company)
432
    public function getCompanyImage($company)
176
    {
433
    {
177
        if($company->image) {
-
 
178
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $this->getPathCompany() . DIRECTORY_SEPARATOR . $company->uuid . DIRECTORY_SEPARATOR . $company->image;
434
        if ($company->image) {
179
            if(file_exists($remoto)) {
435
            $remoto = $this->composePathToFilename(self::TYPE_COMPANY, $company->uuid, $company->image);
180
                return $this->getPresignedUrl($remoto);
436
            if (file_exists($remoto)) {
181
                
437
                return $this->getPresignedUrl($remoto);
182
            }
438
            }
183
        }
-
 
184
        
439
        }
185
        $remoto = $this->config['leaderslinked.images_default.company_profile'];
440
 
186
        return $this->getPresignedUrl($remoto);
441
        $remoto = $this->getFullPathImageCompanyDefault();
187
        
442
        return $this->getPresignedUrl($remoto);
188
    }
443
    }
189
    
444
 
190
    /**
445
    /**
191
     *
446
     *
192
     * @param string $code
447
     * @param string $code
193
     * @param string $filename
448
     * @param string $filename
194
     * @return string
449
     * @return string
195
     */
450
     */
196
    public function getCompanyImageForCodeAndFilename($code, $filename)
451
    public function getCompanyImageForCodeAndFilename($code, $filename)
197
    {
452
    {
198
        if($filename) {
-
 
199
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $this->getPathCompany() . DIRECTORY_SEPARATOR . $code . DIRECTORY_SEPARATOR . $filename;
453
        if ($filename) {
200
            if(file_exists($remoto)) {
454
            $remoto = $this->composePathToFilename(self::TYPE_COMPANY, $code, $filename);
201
                return $this->getPresignedUrl($remoto);
455
            if (file_exists($remoto)) {
202
                
456
                return $this->getPresignedUrl($remoto);
203
            }
457
            }
204
        }
-
 
205
        
458
        }
206
        $remoto = $this->config['leaderslinked.images_default.company_profile'];
459
 
207
        return $this->getPresignedUrl($remoto);
460
        $remoto = $this->getFullPathImageCompanyDefault();
208
        
461
        return $this->getPresignedUrl($remoto);
209
    }
462
    }
210
    
463
 
211
    /**
464
    /**
212
     *
465
     *
213
     * @param Company $company
466
     * @param Company $company
214
     * @return string
467
     * @return string
215
     */
468
     */
216
    public function getCompanyCover($company)
469
    public function getCompanyCover($company)
217
    {
470
    {
218
        if($company->cover) {
-
 
219
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $this->getPathCompany() . DIRECTORY_SEPARATOR . $company->uuid . DIRECTORY_SEPARATOR . $company->cover;
471
        if ($company->cover) {
220
            if(file_exists($remoto)) {
472
            $remoto = $this->composePathToFilename(self::TYPE_COMPANY, $company->uuid, $company->cover);
221
                return $this->getPresignedUrl($remoto);
473
            if (file_exists($remoto)) {
222
                
474
                return $this->getPresignedUrl($remoto);
223
            }
475
            }
224
        }
-
 
225
        
476
        }
226
        $remoto = $this->config['leaderslinked.images_default.company_cover'];
477
 
227
        return $this->getPresignedUrl($remoto);
478
        $remoto = $this->getFullPathImageCompanyCoverDefault();
228
        
479
        return $this->getPresignedUrl($remoto);
229
    }
480
    }
230
    
481
 
231
    /**
482
    /**
232
     *
483
     *
233
     * @param Group $group
484
     * @param Group $group
234
     * @return string
485
     * @return string
235
     */
486
     */
236
    public function getGroupImage($group)
487
    public function getGroupImage($group)
237
    {
488
    {
238
        if($group->image) {
-
 
239
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $this->getPathGroup() . DIRECTORY_SEPARATOR . $group->uuid . DIRECTORY_SEPARATOR . $group->image;
489
        if ($group->image) {
240
            if(file_exists($remoto)) {
490
            $remoto = $this->composePathToFilename(self::TYPE_COMPANY, $group->uuid, $group->image);
241
                return $this->getPresignedUrl($remoto);
491
            if (file_exists($remoto)) {
242
                
492
                return $this->getPresignedUrl($remoto);
243
            }
493
            }
244
        }
-
 
245
        
494
        }
246
        $remoto = $this->config['leaderslinked.images_default.group_profile'];
495
 
247
        return $this->getPresignedUrl($remoto);
496
        $remoto = $this->getFullPathImageGroupDefault();
248
        
497
        return $this->getPresignedUrl($remoto);
249
    }
498
    }
250
    
499
 
251
    /**
500
    /**
252
     *
501
     *
253
     * @param string $code
502
     * @param string $code
254
     * @param string $filename
503
     * @param string $filename
255
     * @return string
504
     * @return string
256
     */
505
     */
257
    public function getGroupImageForCodeAndFilename($code, $filename)
506
    public function getGroupImageForCodeAndFilename($code, $filename)
258
    {
507
    {
259
        if($filename) {
-
 
260
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR .$this->getPathGroup() . DIRECTORY_SEPARATOR . $code . DIRECTORY_SEPARATOR .  $filename;
508
        if ($filename) {
261
            if(file_exists($remoto)) {
509
            $remoto = $this->composePathToFilename(self::TYPE_COMPANY, $code, $filename);
262
                return $this->getPresignedUrl($remoto);
510
            if (file_exists($remoto)) {
263
                
511
                return $this->getPresignedUrl($remoto);
264
            }
512
            }
265
        }
-
 
266
        
513
        }
267
        $remoto = $this->config['leaderslinked.images_default.group_profile'];
514
 
268
        return $this->getPresignedUrl($remoto);
515
        $remoto = $this->getFullPathImageGroupDefault();
269
        
516
        return $this->getPresignedUrl($remoto);
270
    }
517
    }
271
    
518
 
272
    /**
519
    /**
273
     *
520
     *
274
     * @param Group $group
521
     * @param Group $group
275
     * @return string
522
     * @return string
276
     */
523
     */
277
    public function getGroupCover($group)
524
    public function getGroupCover($group)
278
    {
525
    {
279
        if($group->cover) {
-
 
280
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR .$this->getPathGroup() . DIRECTORY_SEPARATOR . $group->uuid . DIRECTORY_SEPARATOR .  $group->cover;
526
        if ($group->cover) {
281
            if(file_exists($remoto)) {
527
            $remoto = $this->composePathToFilename(self::TYPE_COMPANY, $group->uuid, $group->cover);
282
                return $this->getPresignedUrl($remoto);
528
            if (file_exists($remoto)) {
283
                
529
                return $this->getPresignedUrl($remoto);
284
            }
530
            }
285
        }
-
 
286
        
531
        }
287
        $remoto = $this->config['leaderslinked.images_default.group_cover'];
532
 
288
        return $this->getPresignedUrl($remoto);
533
        $remoto = $this->getFullPathImageGroupCoverDefault();
289
        
534
        return $this->getPresignedUrl($remoto);
290
    }
535
    }
291
    
536
 
292
    /**
537
    /**
293
     *
538
     *
294
     * @param Group $group
539
     * @param Group $group
295
     * @return string
540
     * @return string
Línea -... Línea 541...
-
 
541
     */
296
     */
542
    public function getGenericImage($path, $code, $filename)
-
 
543
    {
-
 
544
        $remoto = $path . DIRECTORY_SEPARATOR . $code . DIRECTORY_SEPARATOR . $filename;
297
    public function getGenericImage($path, $code, $filename)
545
        
298
    {
-
 
Línea 299... Línea -...
299
        $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR .$path . DIRECTORY_SEPARATOR . $code. DIRECTORY_SEPARATOR .  $filename;
-
 
300
        
546
        
-
 
547
     
301
  
548
        
-
 
549
 
Línea -... Línea 550...
-
 
550
        if (file_exists($remoto)) {
302
        if(file_exists($remoto)) {
551
            
303
            return $this->getPresignedUrl($remoto);
-
 
304
            
-
 
305
        } else {
-
 
306
            $remoto = $this->config['leaderslinked.images_default.no_image'];
-
 
307
            return $this->getPresignedUrl($remoto);
-
 
308
            
-
 
309
        }
-
 
310
    }
-
 
311
    
-
 
312
    /**
-
 
313
     *
-
 
314
     * @param string $path
-
 
315
     * @param string $code,
-
 
316
     * @param string $filename
-
 
Línea 317... Línea -...
317
     * @param boolean $checkExists
-
 
318
     * @return string
-
 
319
     */
-
 
320
    public function checkDirectory($path, $code)
552
            if($code == 'd8e6c5de-52a6-4c28-bdce-4ba2823ba841') {
321
    {
-
 
322
        $directory = self::BASE_PATH . DIRECTORY_SEPARATOR .$path . DIRECTORY_SEPARATOR . $code;
-
 
323
        
-
 
324
 
-
 
325
        if(file_exists( $directory)) {
-
 
326
            return true; 
-
 
327
        } else {
-
 
328
            return @mkdir($directory, 0755, true);  
-
 
329
        }
-
 
330
        
-
 
331
    }
-
 
332
    
-
 
333
    
-
 
334
    /**
-
 
335
     *
-
 
336
     * @param string $path
-
 
337
     * @param string $code,
-
 
338
     * @param string $filename
553
                
339
     * @return string
-
 
340
     */
-
 
341
    public function getFileFromDisk($path, $code, $filename)
-
 
342
    {
-
 
343
        $current_file = self::BASE_PATH . DIRECTORY_SEPARATOR .$path . DIRECTORY_SEPARATOR . $code. DIRECTORY_SEPARATOR .  $filename;
-
 
344
        
-
 
345
        if(file_exists($current_file)) {
-
 
346
            return $current_file;
-
 
347
        } 
-
 
348
        return;
-
 
349
    }
-
 
350
    
-
 
351
    /**
-
 
352
     *
-
 
353
     * @param string $path
-
 
354
     * @param string $code,
-
 
355
     * @return string
-
 
356
     */
-
 
357
    public function getDirectoryFromDisk($path, $code)
554
                error_log('getGenericImage = ' . $remoto);
358
    {
-
 
359
        $directory = self::BASE_PATH . DIRECTORY_SEPARATOR .$path . DIRECTORY_SEPARATOR . $code;
-
 
Línea 360... Línea -...
360
        
-
 
361
        if(file_exists($directory)) {
555
            }
362
            return $directory;
556
            
363
        }
557
            return $this->getPresignedUrl($remoto);
364
        return;
558
        }
365
    }
559
 
366
    
-
 
367
    
560
        $remoto = $this->getFullPathImageDefault();
368
 
561
        return $this->getPresignedUrl($remoto);
369
    
562
    }
370
    /**
563
 
371
     *
564
    /**
372
     * @param string $path
-
 
373
     * @param string $code,
-
 
374
     * @param string $filename
-
 
375
     * @param boolean $checkExists
-
 
376
     * @return string
-
 
377
     */
-
 
378
    public function getGenericFile($path, $code, $filename, $checkExists = true)
-
 
379
    {
-
 
380
        $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR .$path . DIRECTORY_SEPARATOR . $code. DIRECTORY_SEPARATOR .  $filename;
-
 
381
        
-
 
382
 
-
 
383
        if($checkExists) {
-
 
384
            if(file_exists($remoto)) {
-
 
385
                return $this->getPresignedUrl($remoto);
-
 
386
                
-
 
387
            } else {
-
 
388
                return;
-
 
389
            } 
-
 
390
        } 
-
 
391
        return $this->getPresignedUrl($remoto);
-
 
392
    }
-
 
393
    
-
 
394
    public function getPathByType($type)
-
 
395
    {
-
 
396
        switch($type) 
-
 
397
        {
-
 
398
            case TYPE_CHAT : 
-
 
399
                return $this->getPathChat();
-
 
400
                
-
 
401
            case TYPE_GROUP : 
-
 
402
                return $this->getPathGroup();
-
 
403
                
-
 
404
            case TYPE_USER : 
-
 
405
                return $this->getPathUser();
-
 
406
                
-
 
407
            case TYPE_IMAGE : 
-
 
408
                return $this->getPathImage();
-
 
409
                
-
 
410
            case TYPE_JOB : 
-
 
411
                return $this->getPathJob();
-
 
412
                
-
 
413
            case TYPE_COMPANY : 
-
 
414
                return $this->getPathCompany();
-
 
415
                
-
 
416
            case TYPE_FEED : 
-
 
417
                return $this->getPathFeed();
-
 
418
                
-
 
419
            case TYPE_POST : 
-
 
420
                return $this->getPathPost();
-
 
421
                
-
 
422
            case TYPE_MICROLEARNING_TOPIC  : 
-
 
423
                return $this->getPathMicrolearningTopic();
-
 
424
                
-
 
425
            case TYPE_MICROLEARNING_CAPSULE : 
-
 
426
                return $this->getPathMicrolearningCapsule();
-
 
427
                
-
 
428
            case TYPE_MICROLEARNING_SLIDE  : 
-
 
429
                return $this->getPathMicrolearningSlide();
-
 
430
                
-
 
431
            case TYPE_JOB_DESCRIPTION : 
-
 
432
                return $this->getPathJobDescription();
-
 
433
                
-
 
434
            case TYPE_SELF_EVALUATION  : 
-
 
435
                return $this->getPathSelfEvaluation();
-
 
436
                
-
 
437
            case TYPE_PERFORMANCE_EVALUATION  : 
-
 
438
                return $this->getPathPerformanceEvaluation();
-
 
439
                
-
 
440
            case TYPE_RECRUITMENT_SELECTION  : 
-
 
441
                return $this->getPathRecruitmentSelection();
-
 
442
                
-
 
443
            case TYPE_PLANNING_OBJECTIVES_AND_GOALS : 
-
 
444
                return $this->getPathPlanningObjectivesAnGoals();
-
 
445
                
-
 
446
                
-
 
447
            case TYPE_MESSAGE  : 
-
 
448
                return $this->getPathMessage();
-
 
449
                
-
 
450
            case TYPE_SURVEY   : 
-
 
451
                return $this->getPathSurvey();
-
 
452
                
-
 
453
            case TYPE_NETWORK   : 
-
 
454
                return $this->getPathNetwork();
-
 
455
                
-
 
456
            case TYPE_DAILY_PULSE : 
-
 
457
                return $this->getPathDailyPulse();
-
 
458
                
-
 
459
            case TYPE_ENGAGEMENT_REWARD  : 
-
 
460
                return $this->getPathEngagementReward();
-
 
461
                
-
 
462
            case TYPE_KNOWLEDGE_AREA : 
-
 
463
                return $this->getPathKnowledgeArea();
-
 
464
                
-
 
465
            case TYPE_MY_COACH : 
-
 
466
                return $this->getPathMyCoach();
-
 
467
                
-
 
Línea 468... Línea -...
468
            case TYPE_HABIT_EMOJI  : 
-
 
469
                return $this->getPathHabitEmoji();
565
     *
470
                
-
 
471
            case TYPE_HABIT_CONTENT : 
-
 
472
                return $this->getPathHabitContent();
-
 
473
                
-
 
474
            default : 
-
 
475
                return DIRECTORY_SEPARATOR;
-
 
476
        }
-
 
477
        
-
 
478
       
-
 
479
    }
-
 
480
    
566
     * @param string $path
481
    /**
-
 
482
     *
-
 
483
     * @param Group $group
-
 
484
     * @return string
-
 
485
     */
-
 
486
    public function getGenericImageByType($type, $code, $filename)
-
 
487
    {
-
 
488
        $path = $this->getPathByType($type);
-
 
489
        $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR .$path . DIRECTORY_SEPARATOR . $code. DIRECTORY_SEPARATOR .  $filename;
-
 
490
 
-
 
491
        if(file_exists($remoto)) {
-
 
492
            return $this->getPresignedUrl($remoto);
-
 
493
            
-
 
494
        } else {
-
 
495
            $remoto = $this->config['leaderslinked.images_default.no_image'];
-
 
496
            return $this->getPresignedUrl($remoto);
-
 
497
            
-
 
498
        }
-
 
499
    }
-
 
500
    
-
 
501
    /**
-
 
502
     *
-
 
503
     * @param string $type
-
 
504
     * @param string $code,
-
 
505
     * @param string $filename
567
     * @param string $code,
Línea 506... Línea -...
506
     * @param boolean $checkExists
-
 
507
     * @return string
568
     * @param string $filename
508
     */
569
     * @return string
-
 
570
     */
-
 
571
    public function getGenericFile($path, $code, $filename)
-
 
572
    {
509
    public function getGenericFileByType($type, $code, $filename, $checkExists = true)
573
        $remoto = $path . DIRECTORY_SEPARATOR . $code . DIRECTORY_SEPARATOR . $filename;
510
    {
-
 
511
        $path = $this->getPathByType($type);
-
 
512
        $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR .$path . DIRECTORY_SEPARATOR . $code. DIRECTORY_SEPARATOR .  $filename;
-
 
513
 
-
 
514
        if($checkExists) {
-
 
515
            if(file_exists($remoto)) {
-
 
516
                return $this->getPresignedUrl($remoto);
-
 
517
                
-
 
518
            } else {
574
        
519
                return;
-
 
520
            }
-
 
521
        }
-
 
522
        return $this->getPresignedUrl($remoto);
-
 
523
    }
-
 
524
    
-
 
525
    /**
-
 
526
     *
575
       
Línea 527... Línea -...
527
     * @param string $path
-
 
528
     * @param string $code
-
 
529
     * @param string $filename
-
 
530
     * @return string
-
 
531
     */
-
 
532
    public function delete($path, $code, $filename)
-
 
533
    {
576
        
534
        $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR .$path . DIRECTORY_SEPARATOR . $code. DIRECTORY_SEPARATOR .  $filename;
577
        if (file_exists($remoto)) {
535
        return @unlink($remoto);
578
            if($code == 'd8e6c5de-52a6-4c28-bdce-4ba2823ba841') {
536
 
579
                
Línea 537... Línea -...
537
        
-
 
538
    }
-
 
539
    
-
 
540
  
-
 
541
    
-
 
542
    /**
580
                error_log('getGenericFile = ' . $remoto);
543
     *
-
 
544
     * @return string
-
 
545
     */
-
 
546
    public function getPathMedia()
-
 
547
    {
-
 
548
        return $this->config['leaderslinked.storage.fullpath_media'];
-
 
549
    }
-
 
550
    
-
 
551
    
-
 
552
    /**
581
            }
553
     *
582
            
554
     * @return string
583
            
555
     */
-
 
Línea 556... Línea -...
556
    public function getPathHabitEmoji()
-
 
557
    {
-
 
558
        return $this->config['leaderslinked.storage.fullpath_habit_emoji'];
-
 
559
    }
-
 
560
    
584
            return $this->getPresignedUrl($remoto);
561
    /**
585
        }
562
     *
586
        return;
563
     * @return string
587
    }
Línea 564... Línea -...
564
     */
-
 
565
    public function getPathHabitContent()
-
 
566
    {
-
 
567
        return $this->config['leaderslinked.storage.fullpath_habit_content'];
-
 
568
    }
588
    
569
 
589
    public function getPathDefault()
570
    
590
    {
571
    /**
591
        return $this->getPathByType(self::TYPE_DEFAULT);
Línea 572... Línea -...
572
     * 
-
 
573
     * @return string
-
 
574
     */
-
 
575
    public function getPathGroup()
-
 
576
    {
592
    }
577
        return $this->config['leaderslinked.storage.fullpath_group'];
593
    
578
    }
594
    public function getPathChat()
579
    
595
    {
Línea 580... Línea -...
580
    /**
-
 
581
     *
-
 
582
     * @return string
-
 
583
     */
-
 
584
    public function getPathUser()
596
        return $this->getPathByType(self::TYPE_CHAT);
585
    {
597
    }
586
        return $this->config['leaderslinked.storage.fullpath_user'];
598
    
587
    }
599
    public function getPathGroup()
Línea 588... Línea -...
588
    
-
 
589
    /**
-
 
590
     *
-
 
591
     * @return string
-
 
592
     */
-
 
593
    public function getPathImage()
-
 
594
    {
-
 
595
        return $this->config['leaderslinked.storage.fullpath_image'];
-
 
596
    }
-
 
597
    
-
 
598
    /**
-
 
599
     *
-
 
600
     * @return string
-
 
601
     */
600
    {
602
    public function getPathJob()
601
        return $this->getPathByType(self::TYPE_GROUP);
603
    {
602
    }
604
        return $this->config['leaderslinked.storage.fullpath_job'];
603
    
Línea 605... Línea -...
605
    }
-
 
606
    
604
    public function getPathUser()
607
    /**
-
 
608
     *
-
 
609
     * @return string
605
    {
610
     */
606
        return $this->getPathByType(self::TYPE_USER);
611
    public function getPathChat()
607
    }
612
    {
608
    
Línea 613... Línea -...
613
        return $this->config['leaderslinked.storage.fullpath_chat'];
-
 
614
    }
-
 
615
    
-
 
616
    /**
-
 
617
     *
-
 
618
     * @return string
-
 
619
     */
609
    public function getPathImage()
620
    public function getPathCompany()
610
    {
621
    {
611
        return $this->getPathByType(self::TYPE_IMAGE);
622
        return $this->config['leaderslinked.storage.fullpath_company'];
612
    }
Línea 623... Línea -...
623
    }
-
 
624
    
-
 
625
    /**
-
 
626
     *
-
 
627
     * @return string
613
    
628
     */
614
    public function getPathJob()
629
    public function getPathFeed()
615
    {
630
    {
616
        return $this->getPathByType(self::TYPE_JOB);
Línea 631... Línea -...
631
        return $this->config['leaderslinked.storage.fullpath_feed'];
-
 
632
    }
617
    }
633
    
-
 
634
    
-
 
635
    
618
    
636
    /**
619
    public function getPathCompany()
637
     *
620
    {
638
     * @return string
621
        return $this->getPathByType(self::TYPE_COMPANY);
Línea 639... Línea -...
639
     */
-
 
640
    public function getPathMessage()
-
 
641
    {
-
 
642
        return $this->config['leaderslinked.storage.fullpath_message'];
-
 
643
    }
622
    }
644
    
623
    
645
    /**
624
    
646
     *
625
    public function getPathFeed()
Línea 647... Línea -...
647
     * @return string
-
 
648
     */
-
 
649
    public function getPathPost()
-
 
650
    {
-
 
651
        return $this->config['leaderslinked.storage.fullpath_post'];
626
    {
652
    }
627
        return $this->getPathByType(self::TYPE_FEED);
653
    
628
    }
654
    /**
629
    
Línea 655... Línea -...
655
     *
-
 
656
     * @return string
-
 
657
     */
-
 
658
    public function getPathMicrolearningTopic()
-
 
659
    {
630
    public function getPathMedia()
660
        return $this->config['leaderslinked.storage.fullpath_microlearning_topic'];
631
    {
661
    }
632
        return $this->getPathByType(self::TYPE_MEDIA);
662
    
633
    }
Línea 663... Línea -...
663
    /**
-
 
664
     *
-
 
665
     * @return string
-
 
666
     */
-
 
667
    public function getPathMicrolearningCapsule()
634
    
668
    {
635
    public function getPathPost()
669
        return $this->config['leaderslinked.storage.fullpath_microlearning_capsule'];
636
    {
670
    }
637
        return $this->getPathByType(self::TYPE_POST);
Línea 671... Línea 638...
671
    
638
    }
672
    /**
639
    
673
     *
640
    
674
     * @return string
641
    public function getPathMicrolearningTopic()
-
 
642
    {
-
 
643
        return $this->getPathByType(self::TYPE_MICROLEARNING_TOPIC);
675
     */
644
    }
676
    public function getPathMicrolearningSlide()
645
    
677
    {
646
    public function getPathMicrolearningCapsule()
678
        return $this->config['leaderslinked.storage.fullpath_microlearning_slide'];
647
    {
Línea 679... Línea -...
679
    }
-
 
680
    
648
        return $this->getPathByType(self::TYPE_MICROLEARNING_CAPSULE);
681
    /**
-
 
682
     *
-
 
683
     * @return string
649
    }
684
     */
650
    
685
    public function getPathJobDescription()
651
    public function getPathMicrolearningSlide()
686
    {
652
    {
Línea 687... Línea -...
687
        return $this->config['leaderslinked.storage.fullpath_job_description'];
-
 
688
    }
-
 
689
    
-
 
690
    /**
-
 
691
     *
653
        return $this->getPathByType(self::TYPE_MICROLEARNING_SLIDE);
692
     * @return string
654
    }
693
     */
655
    
694
    public function getPathSelfEvaluation()
656
    public function getPathJobDescription()
Línea 695... Línea -...
695
    {
-
 
696
        return $this->config['leaderslinked.storage.fullpath_self_evaluation'];
657
    {
697
    }
-
 
698
    
-
 
699
    /**
658
        return $this->getPathByType(self::TYPE_JOB_DESCRIPTION);
700
     *
659
    }
701
     * @return string
660
    
702
     */
661
    public function getPathSelfEvaluation()
Línea 703... Línea -...
703
    public function getPathRecruitmentSelection()
-
 
704
    {
662
    {
705
        return $this->config['leaderslinked.storage.fullpath_recruitment_selection'];
-
 
706
    }
-
 
707
    
663
        return $this->getPathByType(self::TYPE_SELF_EVALUATION);
708
    /**
664
    }
709
     *
665
    
710
     * @return string
666
    public function getPathPerformanceEvaluation()
Línea 711... Línea -...
711
     */
-
 
712
    public function getPathPerformanceEvaluation()
667
    {
713
    {
-
 
714
        return $this->config['leaderslinked.storage.fullpath_performance_evaluation'];
-
 
715
    }
668
        return $this->getPathByType(self::TYPE_PERFORMANCE_EVALUATION);
716
    
669
    }
717
    /**
670
    
718
     *
671
    
-
 
672
    public function getPathRecruitmentSelection()
Línea 719... Línea -...
719
     * @return string
-
 
720
     */
-
 
721
    public function getPathPlanningObjectivesAnGoals()
-
 
722
    {
-
 
723
        return $this->config['leaderslinked.storage.fullpath_planning_objectives_and_goals'];
673
    {
724
    }
674
        return $this->getPathByType(self::TYPE_RECRUITMENT_SELECTION);
725
    
675
    }
726
    /**
676
    
Línea 727... Línea -...
727
     *
-
 
728
     * @return string
-
 
729
     */
-
 
730
    public function getPathSurvey()
-
 
731
    {
677
    
732
        return $this->config['leaderslinked.storage.fullpath_survey'];
678
    public function getPathPlanningObjectivesAndGoals()
733
    }
679
    {
734
    
680
        return $this->getPathByType(self::TYPE_PLANNING_OBJECTIVES_AND_GOALS);
Línea 735... Línea -...
735
    /**
-
 
736
     *
-
 
737
     * @return string
-
 
738
     */
-
 
739
    public function getPathNetwork()
681
    }
740
    {
682
    
741
        return $this->config['leaderslinked.storage.fullpath_network'];
683
    public function getPathMessage()
742
    }
684
    {
Línea 743... Línea -...
743
    
-
 
744
    /**
-
 
745
     *
-
 
746
     * @return string
-
 
747
     */
-
 
748
    public function getPathEngagementReward()
685
        return $this->getPathByType(self::TYPE_MESSAGE);
749
    {
686
    }
750
        return $this->config['leaderslinked.storage.fullpath_engagement_reward'];
687
    
751
    }
688
    
752
    
689
    public function getPathSurvey()
753
    /**
-
 
754
     *
-
 
755
     * @return string
-
 
756
     */
-
 
757
    public function getPathDailyPulse()
-
 
758
    {
-
 
759
        return $this->config['leaderslinked.storage.fullpath_daily_pulse'];
690
    {
760
    }
691
        return $this->getPathByType(self::TYPE_SURVEY);
761
    
-
 
762
    /**
-
 
763
     *
-
 
764
     * @return string
-
 
765
     */
-
 
766
    public function getPathKnowledgeArea()
-
 
767
    {
692
    }
768
        return $this->config['leaderslinked.storage.fullpath_knowledge_area'];
693
    
769
    }
-
 
770
    
694
    
771
    /**
-
 
772
     *
-
 
773
     * @return string
-
 
774
     */
695
    public function getPathNetwork()
775
    public function getPathMyCoach()
-
 
776
    {
-
 
777
        return $this->config['leaderslinked.storage.fullpath_my_coach'];
696
    {
778
    }
697
        return $this->getPathByType(self::TYPE_NETWORK);
-
 
698
    }
-
 
699
    
-
 
700
    
-
 
701
    public function getPathDailyPulse()
-
 
702
    {
-
 
703
        return $this->getPathByType(self::TYPE_DAILY_PULSE);
-
 
704
    }
-
 
705
 
-
 
706
    
-
 
707
    public function getPathEngagementReward()
-
 
708
    {
-
 
709
        return $this->getPathByType(self::TYPE_ENGAGEMENT_REWARD);
-
 
710
    }
-
 
711
    
-
 
712
    public function getPathKnowledgeArea()
-
 
713
    {
-
 
714
        return $this->getPathByType(self::TYPE_KNOWLEDGE_AREA);
-
 
715
    }
-
 
716
    
-
 
717
    public function getPathMyCoach()
-
 
718
    {
-
 
719
        return $this->getPathByType(self::TYPE_MY_COACH);
-
 
720
    }
-
 
721
    
-
 
722
    public function getPathHabitEmoji()
-
 
723
    {
-
 
724
        return $this->getPathByType(self::TYPE_HABIT_EMOJI);
-
 
725
    }
-
 
726
 
-
 
727
    public function getPathHabitContent()
-
 
728
    {
-
 
729
        return $this->getPathByType(self::TYPE_HABIT_CONTENT);
-
 
730
    }
-
 
731
 
-
 
732
 
-
 
733
    public function getPathByType($type)
-
 
734
    {
-
 
735
        switch ($type) {
-
 
736
            case self::TYPE_DEFAULT:
-
 
737
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'default';
-
 
738
                break;
-
 
739
 
-
 
740
            case self::TYPE_CHAT:
-
 
741
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'chat';
-
 
742
                break;
-
 
743
 
-
 
744
            case self::TYPE_GROUP:
-
 
745
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'group';
-
 
746
                break;
-
 
747
 
-
 
748
            case self::TYPE_USER:
-
 
749
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'user';
-
 
750
                break;
-
 
751
 
-
 
752
            case self::TYPE_IMAGE:
-
 
753
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'image';
-
 
754
                break;
-
 
755
 
-
 
756
            case self::TYPE_JOB:
-
 
757
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'job';
-
 
758
                break;
-
 
759
 
-
 
760
            case self::TYPE_COMPANY:
-
 
761
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'company';
-
 
762
                break;
-
 
763
 
-
 
764
            case self::TYPE_FEED:
-
 
765
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'feed';
-
 
766
                break;
-
 
767
 
-
 
768
            case self::TYPE_MEDIA:
-
 
769
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'media';
-
 
770
                break;
-
 
771
 
-
 
772
            case self::TYPE_POST:
-
 
773
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'post';
-
 
774
                break;
-
 
775
 
-
 
776
            case self::TYPE_MICROLEARNING_TOPIC:
-
 
777
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'microlearning' . DIRECTORY_SEPARATOR . 'topic';
-
 
778
                break;
-
 
779
 
-
 
780
            case self::TYPE_MICROLEARNING_CAPSULE:
-
 
781
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'microlearning' . DIRECTORY_SEPARATOR . 'capsule';
-
 
782
                break;
-
 
783
 
-
 
784
            case self::TYPE_MICROLEARNING_SLIDE:
-
 
785
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'microlearning' . DIRECTORY_SEPARATOR . 'slide';
-
 
786
                break;
-
 
787
 
-
 
788
            case self::TYPE_JOB_DESCRIPTION:
-
 
789
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'job-description';
-
 
790
                break;
-
 
791
 
-
 
792
            case self::TYPE_SELF_EVALUATION:
-
 
793
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'self-evaluation';
-
 
794
                break;
-
 
795
 
-
 
796
            case self::TYPE_PERFORMANCE_EVALUATION:
-
 
797
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'performance-evaluation';
-
 
798
                break;
-
 
799
 
-
 
800
            case self::TYPE_RECRUITMENT_SELECTION:
-
 
801
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'recruitment-selection';
-
 
802
                break;
-
 
803
 
-
 
804
            case self::TYPE_PLANNING_OBJECTIVES_AND_GOALS:
-
 
805
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'planning-objectives-and-goals';
-
 
806
                break;
-
 
807
 
-
 
808
            case self::TYPE_MESSAGE:
-
 
809
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'message';
-
 
810
                break;
-
 
811
 
-
 
812
            case self::TYPE_SURVEY:
-
 
813
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'survey';
-
 
814
                break;
-
 
815
 
779
    
816
            case self::TYPE_NETWORK:
780
    /**
817
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'network';
781
     * 
-
 
782
     * @param String $filename
818
                break;
783
     * return boolean
819
 
784
     */
820
            case self::TYPE_DAILY_PULSE:
785
    public function objectExist($filename) 
821
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'daily-pulse';
786
    {
822
                break;
787
        return file_exists($filename);
823
 
788
    }
824
            case self::TYPE_ENGAGEMENT_REWARD:
789
    
825
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'engagement-reward';
790
    /**
826
                break;
791
     * 
827
 
792
     * @param string $remote
-
 
793
     * @param string $local
-
 
794
     * @return boolean
-
 
795
     */
828
            case self::TYPE_KNOWLEDGE_AREA:
796
    public function putObject($remote, $local)
-
 
797
    {
829
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'knowledge-area';
798
        
830
                break;
799
        $dir = dirname($remote);
831
 
800
        if(!file_exists($dir)) {
832
            case self::TYPE_MY_COACH:
801
            @mkdir($dir, 0755, true);
833
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'my-coach';
802
        }
834
                break;
803
        
835
 
804
        return @rename($local, $remote);
836
            case self::TYPE_HABIT_EMOJI:
805
    }
837
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'habit' . DIRECTORY_SEPARATOR . 'emoji';
806
    
838
                break;
807
    
839
 
808
    /**
840
            case self::TYPE_HABIT_CONTENT:
809
     *
841
                $path = $this->storagePath . DIRECTORY_SEPARATOR . 'habit' . DIRECTORY_SEPARATOR . 'content';
810
     * @param string $filename
842
                break;
811
 
843
 
812
     * @return boolean
844
            default:
813
     */
845
                $path = $this->storagePath;
814
    public function deleteObject($filename)
846
                break;
815
    {
847
        }
816
        return @unlink($filename);
848
 
817
    }
849
        if (! file_exists($path)) {
818
    
850
            mkdir($path, 0775, true);
819
    
851
        }
820
    /**
852
 
821
     * 
853
        return $path;
822
     * @param string $path
854
    }
823
     * @param string $code
855
 
824
     * @param string $filename
856
    /**
825
     * @return boolean
857
     *
-
 
858
     * @param string $path
826
     */
859
     * @param string $code
827
    public function deleteFile($path, $code, $filename)
860
     * @param string $filename
828
    {
861
     * @return string
829
        if($code) {
862
     */
830
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $code. DIRECTORY_SEPARATOR .  $filename;
863
    public function deleteFile($path, $code, $filename)
831
        } else {
864
    {
-
 
865
        $remoto = $path . DIRECTORY_SEPARATOR . $code . DIRECTORY_SEPARATOR . $filename;
832
            $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR .  $filename;
866
        if(file_exists($filename)) {
833
        }
867
            return @unlink($remoto);
834
        if(file_exists($remoto)) {
868
        } else {
835
            return @unlink($remoto);
869
            return true;
836
        } else {
870
        }
837
            return true;
871
    }
838
        }
872
 
839
    }
873
    /**
840
    
-
 
841
    /**
-
 
Línea 842... Línea 874...
842
     *
874
     *
843
     * @param string $path
875
     * @param string $path
844
     * @param string $code
876
     * @param string $code
845
     * @return boolean
877
     * @return boolean
846
     */
878
     */
847
    public function deleteDirectory($path, $code)
879
    public function deleteDirectory($path, $code)
848
    {
880
    {
849
        $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR .  $path . DIRECTORY_SEPARATOR . $code;
881
        $remoto = self::BASE_PATH . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $code;
-
 
882
        if (file_exists($remoto)) {
-
 
883
            $this->deleteDirectoryRecursive($remoto);
-
 
884
            return true;
-
 
885
        } else {
-
 
886
            return true;
-
 
887
        }
-
 
888
    }
-
 
889
 
-
 
890
    /**
-
 
891
     *
-
 
892
     * @param string $dir
-
 
893
     */
-
 
894
    private function deleteDirectoryRecursive($dir)
850
        if(file_exists($remoto)) {
895
    {
-
 
896
        if (is_dir($dir)) {
-
 
897
            $objects = scandir($dir);
-
 
898
            foreach ($objects as $object) {
-
 
899
                if ($object != '.' && $object != '..') {
-
 
900
                    $s = $dir . DIRECTORY_SEPARATOR . $object;
-
 
901
                    if (is_dir($s) && ! is_link($s)) {
851
            $this->deleteDirectoryRecursive($remoto);
902
                        @rmdir($s);
-
 
903
                    } else {
-
 
904
                        @unlink($s);
-
 
905
                    }
-
 
906
                }
-
 
907
            }
852
            return true;
908
            @rmdir($dir);
-
 
909
        }
853
        } else {
910
    }
-
 
911
 
-
 
912
    /**
-
 
913
     *
-
 
914
     * @param string $path
-
 
915
     * @param string $code
-
 
916
     * @param string $local_filename
-
 
917
     * @return boolean
-
 
918
     */
-
 
919
    public function putFile($source_file, $target_file)
-
 
920
    {
-
 
921
        return @rename($source_file, $target_file);
-
 
922
    }
-
 
923
 
-
 
924
    /**
854
            return true;
925
     *
-
 
926
     * @param string $tempfile
-
 
927
     * @param string $path
-
 
928
     * @param string $code
-
 
929
     * @param string $filename
-
 
930
     * @return boolean
-
 
931
     */
-
 
932
    public function moveUploadedFile($source_file, $target_file)
-
 
933
    {
-
 
934
        return move_uploaded_file($source_file, $target_file);
-
 
935
    }
855
        }
936
 
Línea -... Línea 937...
-
 
937
    /**
856
    }
938
     *
857
    
939
     * @param string $url
858
    /**
940
     * @return string
859
     *
941
     */
Línea -... Línea 942...
-
 
942
    public function getPresignedUrl($url)
-
 
943
    {
Línea -... Línea 944...
-
 
944
        
-
 
945
       
-
 
946
        if(strpos($url, 'd8e6c5de-52a6-4c28-bdce-4ba2823ba841') !== false) {
-
 
947
            $show = true;
-
 
948
        } else {
-
 
949
            $show = false;
-
 
950
        } 
-
 
951
        
-
 
952
        
860
     * @param string $dir
953
        if($show) {
-
 
954
            error_log('getPresignedUrl : ' . $url);
-
 
955
        }
-
 
956
        
-
 
957
        $code = hash('sha256', $url);
Línea -... Línea 958...
-
 
958
        
-
 
959
        if($show) {
-
 
960
            error_log('getPresignedUrl CODE : ' . $code);
-
 
961
        }
-
 
962
 
-
 
963
        $storageFileMapper = \LeadersLinked\Mapper\StorageFileMapper::getInstance($this->adapter);
-
 
964
        $storageFile = $storageFileMapper->fetchOneByCode($code);
-
 
965
        if (! $storageFile) {
-
 
966
            $storageFile = new \LeadersLinked\Model\StorageFile();
-
 
967
            $storageFile->code = $code;
-
 
968
            $storageFile->path = $url;
861
     */
969
            $storageFile->salt = \LeadersLinked\Library\Functions::generatePassword(8);
862
    private function deleteDirectoryRecursive($dir) {
-
 
863
        if (is_dir($dir)) {
970
 
864
            $objects = scandir($dir);
971
        
865
            foreach ($objects as $object) {
972
            
866
                if ($object != ''.'' && $object != '..') {
-
 
867
                    if (is_dir($dir. DIRECTORY_SEPARATOR .$object) && !is_link($dir.'/'.$object)) {
-
 
868
                        @rmdir($dir. DIRECTORY_SEPARATOR .$object);
-
 
869
                    }  else {
-
 
870
                        @unlink($dir. DIRECTORY_SEPARATOR .$object);
973
            $storageFileMapper->insert($storageFile);
871
                    }
974
        }
872
                }
975
 
873
            }
976
        
874
            @rmdir($dir);
977
        $url = 'https://' . $_SERVER['SERVER_NAME'] . '/storage/' . $code;
875
        }
978
        if($show) {
876
    }
979
            error_log('URL : ' .  $url);
877
    
980
        }
878
 
981
        
879
 
982
        return $url;
Línea -... Línea 983...
-
 
983
    }
-
 
984
 
-
 
985
    /**
-
 
986
     *
880
    /**
987
     * @return @return void|string
-
 
988
     */
881
     *
989
    public function getFilenamePNG()
-
 
990
    {
-
 
991
        if ($this->currentFile) {
-
 
992
            $filename = $this->normalizeStringFilename($this->currentFile['name']);
-
 
993
            $path_parts = pathinfo($filename);
-
 
994
            return $path_parts['filename'] . '.png';
-
 
995
        } else {
-
 
996
            return;
-
 
997
        }
-
 
998
    }
882
     * @param string $path
999
 
-
 
1000
    /**
-
 
1001
     *
-
 
1002
     * @return @return void|string
883
     * @param string $code
1003
     */
884
     * @param string $local_filename
-
 
885
     * @return boolean
-
 
886
     */
1004
    public function getTmpFilename()
887
    public function putFile($path, $code, $local_filename)
1005
    {
888
    {
1006
        if ($this->currentFile) {
889
        if($code) {
1007
            return $this->currentFile['tmp_name'];
890
            $remote = self::BASE_PATH . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR .  $code . DIRECTORY_SEPARATOR . basename($local_filename);
1008
        } else {
891
        } else {
1009
            return;
892
            $remote = self::BASE_PATH . DIRECTORY_SEPARATOR . $path  . DIRECTORY_SEPARATOR .  basename($local_filename);
1010
        }
893
        }
1011
    }
-
 
1012
 
-
 
1013
    /**
894
 
1014
     *
-
 
1015
     * @return @return void|string
-
 
1016
     */
-
 
1017
    public function getFilename()
-
 
1018
    {
895
        $dir = dirname($remote);
1019
        if ($this->currentFile) {
Línea 896... Línea 1020...
896
        if(!file_exists($dir)) {
1020
            return $this->normalizeStringFilename($this->currentFile['name']);
897
            @mkdir($dir, 0755, true);
1021
        } else {
-
 
1022
            return;
-
 
1023
        }
-
 
1024
    }
-
 
1025
 
898
        }
1026
    /**
899
        
1027
     *
-
 
1028
     * @return void|string
-
 
1029
     */
-
 
1030
    public function getFileType()
-
 
1031
    {
-
 
1032
        if ($this->currentFile) {
-
 
1033
            $tmp_name = $this->currentFile['tmp_name'];
-
 
1034
            $mime_type = mime_content_type($tmp_name);
-
 
1035
            if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
-
 
1036
                return self::FILE_TYPE_IMAGE;
900
 
1037
            } else if ($mime_type == 'video/quicktime' || $mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
901
        return @rename($local_filename, $remote);
1038
                return self::FILE_TYPE_VIDEO;
-
 
1039
            } else if ($mime_type == 'application/pdf') {
-
 
1040
                return self::FILE_TYPE_DOCUMENT;
-
 
1041
            } else {
-
 
1042
                return;
-
 
1043
            }
902
 
1044
        } else {
-
 
1045
            return;
-
 
1046
        }
-
 
1047
    }
-
 
1048
 
-
 
1049
    /**
-
 
1050
     *
-
 
1051
     * @return void|string
-
 
1052
     */
-
 
1053
    public function getExtension()
-
 
1054
    {
-
 
1055
        if ($this->currentFile) {
-
 
1056
            $path_parts = pathinfo($this->currentFile['name']);
-
 
1057
            $ext = $path_parts['extension'];
-
 
1058
            return $ext;
-
 
1059
        } else {
-
 
1060
            return;
-
 
1061
        }
-
 
1062
    }
-
 
1063
    
-
 
1064
    /**
-
 
1065
     *
-
 
1066
     * @param string $source
-
 
1067
     * @param string $target_filename
-
 
1068
     * @param number $target_width
-
 
1069
     * @param number $target_height
-
 
1070
     * @return boolean
-
 
1071
     */
-
 
1072
    public function uploadImageResize($source_filename, $target_filename, $target_width, $target_height)
-
 
1073
    {
-
 
1074
 
-
 
1075
        try {
-
 
1076
            
-
 
1077
            $data = file_get_contents($source_filename);
903
    }
1078
            $img = imagecreatefromstring($data);
-
 
1079
            
-
 
1080
            
904
    
1081
            if($img) {
905
    
1082
                list($source_width, $source_height) = getimagesize($source_filename);
906
    /**
-
 
907
     *
-
 
908
     * @param string $tempfile
1083
                
Línea -... Línea 1084...
-
 
1084
                
909
     * @param string $path
1085
                $width_ratio = $target_width / $source_width;
910
     * @param string $code
1086
                $height_ratio = $target_height / $source_height;
911
     * @param string $filename
1087
                
-
 
1088
                if($width_ratio > $height_ratio) {
-
 
1089
                    $resized_width = $target_width;
-
 
1090
                    $resized_height = $source_height * $width_ratio;
-
 
1091
                } else {
912
     * @return boolean
1092
                    $resized_height = $target_height;
913
     */
1093
                    $resized_width = $source_width * $height_ratio;
914
    public function moveAndPutFile($tempfile, $path, $code, $filename)
1094
                }
915
    {
1095
                
916
        if($code) {
-
 
Línea 917... Línea -...
917
            $target_file = self::BASE_PATH . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $code . DIRECTORY_SEPARATOR . $filename;
-
 
918
        } else {
-
 
919
            $target_file = self::BASE_PATH . DIRECTORY_SEPARATOR . $path . DIRECTORY_SEPARATOR . $filename;
-
 
920
        }
-
 
921
        
-
 
922
 
1096
                
923
        $dir = dirname($target_file);
-
 
924
        if(!file_exists($dir)) {
-
 
925
            @mkdir($dir, 0755, true);
-
 
926
        }
-
 
Línea -... Línea 1097...
-
 
1097
                
-
 
1098
                $resized_width = round($resized_width);
Línea -... Línea 1099...
-
 
1099
                $resized_height = round($resized_height);
-
 
1100
                
-
 
1101
                $new_image = imageCreateTrueColor($target_width, $target_height);
-
 
1102
                imageAlphaBlending($new_image, False);
-
 
1103
                imageSaveAlpha($new_image, True);
-
 
1104
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
-
 
1105
                imagefill($new_image, 0, 0, $transparent);
-
 
1106
                imageCopyResampled($new_image, $img , 0, 0, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
-
 
1107
                
-
 
1108
          
-
 
1109
                imagepng($new_image, $target_filename);
-
 
1110
                
-
 
1111
                @unlink($source_filename);
-
 
1112
                return true;
-
 
1113
                
-
 
1114
            }
-
 
1115
            
-
 
1116
            @unlink($source_filename);
-
 
1117
            return false;
-
 
1118
            
-
 
1119
        } catch (\Throwable $e) {
-
 
1120
            error_log( $e->getTraceAsString() );
-
 
1121
            
927
 
1122
            @unlink($source_filename);
-
 
1123
            return false;
-
 
1124
            
-
 
1125
        }
-
 
1126
 
-
 
1127
    }
-
 
1128
    
-
 
1129
    
-
 
1130
    /**
-
 
1131
     *
-
 
1132
     * @param string $source
-
 
1133
     * @param string $target_filename
-
 
1134
     * @param number $target_width
-
 
1135
     * @param number $target_height
-
 
1136
 
Línea 928... Línea 1137...
928
        return move_uploaded_file($tempfile, $target_file);
1137
     * @return boolean
-
 
1138
     */
-
 
1139
    public function uploadImageCrop($source_filename, $target_filename, $target_width, $target_height)
-
 
1140
    {
929
    }
1141
 
-
 
1142
        try {
-
 
1143
            
-
 
1144
            $data = file_get_contents($source_filename);
930
    
1145
            $img = imagecreatefromstring($data);
-
 
1146
            
-
 
1147
            
-
 
1148
            if($img) {
-
 
1149
                list($source_width, $source_height) = getimagesize($source_filename);
-
 
1150
                
-
 
1151
                $width_ratio = $target_width / $source_width;
-
 
1152
                $height_ratio = $target_height / $source_height;
-
 
1153
                if($width_ratio > $height_ratio) {
-
 
1154
                    $resized_width = $target_width;
931
    /**
1155
                    $resized_height = $source_height * $width_ratio;
-
 
1156
                } else {
932
     *
1157
                    $resized_height = $target_height;
933
     * @return string
1158
                    $resized_width = $source_width * $height_ratio;
-
 
1159
                }
-
 
1160
                
Línea 934... Línea 1161...
934
     */
1161
                
Línea 935... Línea 1162...
935
    public function getStoagePath()
1162
                
-
 
1163
                $resized_width = round($resized_width);
-
 
1164
                $resized_height = round($resized_height);
936
    {
1165
                
-
 
1166
                $offset_width = round(($target_width - $resized_width) / 2);
-
 
1167
                $offset_height = round(($target_height - $resized_height) / 2);
-
 
1168
                
-
 
1169
                
-
 
1170
                $new_image = imageCreateTrueColor($target_width, $target_height);
Línea -... Línea 1171...
-
 
1171
                imageAlphaBlending($new_image, False);
-
 
1172
                imageSaveAlpha($new_image, True);
-
 
1173
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
-
 
1174
                imagefill($new_image, 0, 0, $transparent);
-
 
1175
                imageCopyResampled($new_image, $img , $offset_width, $offset_height, 0, 0, $resized_width, $resized_height, $source_width, $source_height);
-
 
1176
                
937
        return 'data' . DIRECTORY_SEPARATOR . 'storage';
1177
                imagepng($new_image, $target_filename);
-
 
1178
                
-
 
1179
                @unlink($source_filename);
-
 
1180
                return true;
-
 
1181
                
-
 
1182
            } 
-
 
1183
            
-
 
1184
            @unlink($source_filename);
-
 
1185
            return false;
-
 
1186
            
-
 
1187
        }
938
    }
1188
        catch (\Throwable $e)
Línea 939... Línea -...
939
    
-
 
940
    /**
-
 
941
     * 
-
 
942
     * @return string
-
 
943
     */
-
 
944
    public function getTempPath() {
-
 
945
        $interal_path   = 'data' . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'tmp';
-
 
Línea -... Línea 1189...
-
 
1189
        {
-
 
1190
            error_log( $e->getTraceAsString() );
-
 
1191
            
-
 
1192
            @unlink($source_filename);
Línea -... Línea 1193...
-
 
1193
            return false;
-
 
1194
            
-
 
1195
        }
946
        if(!file_exists($interal_path)) {
1196
    
-
 
1197
    }
-
 
1198
    
-
 
1199
    /**
-
 
1200
     *
-
 
1201
     * @param string $source
-
 
1202
     * @param string $target_filename
-
 
1203
     * @return boolean
-
 
1204
     */
-
 
1205
    public function uploadImageWithOutChangeSize($source_filename, $target_filename)
-
 
1206
    {
-
 
1207
 
-
 
1208
        try {
-
 
1209
            $data = file_get_contents($source_filename);
-
 
1210
            
-
 
1211
            
-
 
1212
            $img = imagecreatefromstring($data);
-
 
1213
            
-
 
1214
            if($img) {
-
 
1215
                list($source_width, $source_height) = getimagesize($source_filename);
-
 
1216
    
-
 
1217
                $new_image = imageCreateTrueColor($source_width, $source_height);
-
 
1218
                imageAlphaBlending($new_image, False);
-
 
1219
                imageSaveAlpha($new_image, True);
-
 
1220
                $transparent = imageColorAllocateAlpha($new_image, 0, 0, 0, 127);
-
 
1221
                imagefill($new_image, 0, 0, $transparent);
-
 
1222
                imageCopyResampled($new_image, $img , 0, 0, 0, 0, $source_width, $source_height, $source_width, $source_height);
-
 
1223
                
-
 
1224
                
-
 
1225
                imagepng($new_image, $target_filename);
-
 
1226
                
947
            mkdir($interal_path, 0775);
1227
                @unlink($source_filename);
-
 
1228
                return true;
948
        }
1229
                
-
 
1230
            } 
Línea 949... Línea -...
949
        
-
 
Línea 950... Línea 1231...
950
        return $interal_path;
1231
            
951
        
1232
            @unlink($source_filename);
-
 
1233
            return false;
952
    }
1234
            
-
 
1235
        } catch (\Throwable $e) {
-
 
1236
            error_log( $e->getTraceAsString() );
-
 
1237
            
-
 
1238
            @unlink($source_filename);
953
    
1239
            return false;
-
 
1240
            
-
 
1241
        }
954
    /**
1242
        
-
 
1243
        
955
     * 
1244
    }
-
 
1245
    
956
     * @param string $url
1246
    public static function extractPosterFromVideo($source_filename, $target_filename)
-
 
1247
    {
-
 
1248
        
-
 
1249
        try {
-
 
1250
            $cmd        = "/usr/bin/ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width,duration  $source_filename";
-
 
1251
            $response   = trim(shell_exec($cmd));
-
 
1252
            
-
 
1253
            $source_duration = 0;
-
 
1254
            $lines = explode("\n", $response);
-
 
1255
            foreach ($lines as $line) {
-
 
1256
                $line = trim(strtolower($line));
-
 
1257
                if (strpos($line, 'duration') !== false) {
-
 
1258
                    $values = explode('=', $line);
-
 
1259
                    $source_duration = intval(str_replace($values[1], '#', ''), 10);
-
 
1260
                }
-
 
1261
            }
-
 
1262
            
-
 
1263
            
957
     * @return string
1264
            if ($source_duration == 0) {
958
     */
1265
                $second_extract = '00:00:02';
959
    public function getPresignedUrl($url)
1266
            } else {