Proyectos de Subversion LeadersLinked - Backend

Rev

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

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