Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 332 Rev 333
Línea 6... Línea 6...
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
{
-
 
11
    
-
 
12
    const TYPE_CHAT                             = 'chat';
-
 
13
    const TYPE_GROUP                            = 'group';
-
 
14
    const TYPE_USER                             = 'user';
-
 
15
    const TYPE_IMAGE                            = 'image';
-
 
16
    const TYPE_JOB                              = 'job';
-
 
17
    const TYPE_COMPANY                          = 'company';
-
 
18
    const TYPE_FEED                             = 'feed';
-
 
19
    CONST TYPE_POST                             = 'post';
-
 
20
    const TYPE_MICROLEARNING_TOPIC              = 'topic';
-
 
21
    const TYPE_MICROLEARNING_CAPSULE            = 'capsule';
-
 
22
    const TYPE_MICROLEARNING_SLIDE              = 'slide';
-
 
23
    const TYPE_JOB_DESCRIPTION                  = 'jobdesc';
-
 
24
    const TYPE_SELF_EVALUATION                  = 'selfval';
-
 
25
    const TYPE_PERFORMANCE_EVALUATION           = 'perfeva';
-
 
26
    const TYPE_RECRUITMENT_SELECTION            = 'recrsel';
-
 
27
    const TYPE_PLANNING_OBJECTIVES_AND_GOALS    = 'plannig';
-
 
28
    const TYPE_MESSAGE                          = 'message';
-
 
29
    const TYPE_SURVEY                           = 'survey';
-
 
30
    const TYPE_NETWORK                          = 'network';
-
 
31
    const TYPE_DAILY_PULSE                      = 'dailpuls';
-
 
32
    const TYPE_ENGAGEMENT_REWARD                = 'engarewr';
-
 
33
    const TYPE_KNOWLEDGE_AREA                   = 'knowarea';
-
 
34
    const TYPE_MY_COACH                         = 'mycoach';
-
 
35
    const TYPE_HABIT_EMOJI                      = 'habit-emoji';
-
 
36
    const TYPE_HABIT_CONTENT                    = 'habit-content';
-
 
37
    
-
 
38
    const BASE_PATH = 'data/storage';
-
 
39
    
10
{
40
    
11
    /**
41
    /**
12
     * 
42
     * 
13
     * @var\LeadersLinked\Library\Storage 
43
     * @var\LeadersLinked\Library\Storage 
14
     */
44
     */
Línea 18... Línea 48...
18
     * 
48
     * 
19
     * @var array
49
     * @var array
20
     */
50
     */
21
    private $config;
51
    private $config;
Línea 22... Línea -...
22
    
-
 
23
    
52
    
24
    /**
53
    /**
25
     * 
54
     * 
26
     * @var S3Files
55
     * @var \Laminas\Db\Adapter\AdapterInterface 
27
     */
56
     */
-
 
57
    private $adapter;
-
 
58
    
-
 
59
    
Línea 28... Línea 60...
28
    private $s3Files;
60
 
29
    
61
    
30
    /**
62
    /**
-
 
63
     * 
31
     * 
64
     * @param array $config
32
     * @param array $config
65
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
33
     */
66
     */
34
    private function __construct($config) 
67
    private function __construct($config, $adapter) 
35
    {
68
    {
36
        $this->config = $config;
69
        $this->config       = $config;
Línea 37... Línea 70...
37
        $this->s3Files = S3Files::getInstance($this->config);
70
        $this->adapter      = $adapter;
38
    }
71
    }
39
    
72
    
-
 
73
    /**
40
    /**
74
     * 
41
     * 
75
     * @param array $config
42
     * @param array $config
76
     * @param \Laminas\Db\Adapter\AdapterInterface $adapter
43
     * @return \LeadersLinked\Library\Storage
77
     * @return \LeadersLinked\Library\Storage
44
     */
78
     */
45
    public static function getInstance($config)
79
    public static function getInstance($config, $adapter)
46
    {
80
    {
Línea 47... Línea 81...
47
        if(self::$_instance == null) {
81
        if(self::$_instance == null) {
48
            self::$_instance = new Storage($config);
82
            self::$_instance = new Storage($config, $adapter);
Línea 57... Línea 91...
57
     * @return string
91
     * @return string
58
     */
92
     */
59
    public function getUserImage($user)
93
    public function getUserImage($user)
60
    {
94
    {
61
        if($user->image) {
95
        if($user->image) {
62
            $remoto = $this->getPathUser() . '/' . $user->uuid . '/' .  $user->image;
96
            $remoto = self::BASE_PATH . '/' .$this->getPathUser() . '/' . $user->uuid . '/' .  $user->image;
63
            if($this->s3Files->objectExist($remoto)) {
97
            if(file_exists($remoto)) {
64
                return $this->s3Files->getPresignedUrl($remoto);
98
                return $this->getPresignedUrl($remoto);
Línea 65... Línea 99...
65
                
99
                
66
            }
100
            }
Línea 67... Línea 101...
67
        }
101
        }
68
        
102
        
69
        $remoto = $this->config['leaderslinked.images_default.user_image'];
103
        $remoto = $this->config['leaderslinked.images_default.user_image'];
Línea 70... Línea 104...
70
        return $this->s3Files->getPresignedUrl($remoto);
104
        return $this->getPresignedUrl($remoto);
71
    }
105
    }
Línea 77... Línea 111...
77
     * @return string
111
     * @return string
78
     */
112
     */
79
    public function getUserImageForCodeAndFilename($code, $filename)
113
    public function getUserImageForCodeAndFilename($code, $filename)
80
    {
114
    {
81
        if($filename) {
115
        if($filename) {
82
            $remoto = $this->getPathUser() . '/' . $code . '/' .  $filename;
116
            $remoto = self::BASE_PATH . '/' .$this->getPathUser() . '/' . $code . '/' .  $filename;
83
            if($this->s3Files->objectExist($remoto)) {
117
            if(file_exists($remoto)) {
84
                return $this->s3Files->getPresignedUrl($remoto);
118
                return $this->getPresignedUrl($remoto);
Línea 85... Línea 119...
85
                
119
                
86
            }
120
            }
Línea 87... Línea 121...
87
        }
121
        }
88
        
122
        
Línea 89... Línea 123...
89
        $remoto = $this->config['leaderslinked.images_default.user_image'];
123
        $remoto = $this->config['leaderslinked.images_default.user_image'];
Línea 90... Línea 124...
90
        return $this->s3Files->getPresignedUrl($remoto);
124
        return $this->getPresignedUrl($remoto);
91
        
125
        
Línea 98... Línea 132...
98
     * @return string
132
     * @return string
99
     */
133
     */
100
    public function getUserProfileImage($user, $userProfile)
134
    public function getUserProfileImage($user, $userProfile)
101
    {
135
    {
102
        if($userProfile->image) {
136
        if($userProfile->image) {
103
            $remoto = $this->getPathUser() . '/' . $user->uuid . '/' .  $userProfile->image;
137
            $remoto = self::BASE_PATH . '/' .$this->getPathUser() . '/' . $user->uuid . '/' .  $userProfile->image;
104
            if($this->s3Files->objectExist($remoto)) {
138
            if(file_exists($remoto)) {
105
                return $this->s3Files->getPresignedUrl($remoto);
139
                return $this->getPresignedUrl($remoto);
Línea 106... Línea 140...
106
                
140
                
107
            }
141
            }
Línea 108... Línea 142...
108
        }
142
        }
109
        
143
        
Línea 110... Línea 144...
110
        $remoto = $this->config['leaderslinked.images_default.user_profile'];
144
        $remoto = $this->config['leaderslinked.images_default.user_profile'];
Línea 111... Línea 145...
111
        return $this->s3Files->getPresignedUrl($remoto);
145
        return $this->getPresignedUrl($remoto);
112
        
146
        
Línea 119... Línea 153...
119
     * @return string
153
     * @return string
120
     */
154
     */
121
    public function getUserProfileCover($user, $userProfile)
155
    public function getUserProfileCover($user, $userProfile)
122
    {
156
    {
123
        if($userProfile->cover) {
157
        if($userProfile->cover) {
124
            $remoto = $this->getPathUser() . '/' . $user->uuid . '/' .  $userProfile->cover;
158
            $remoto = self::BASE_PATH . '/' .$this->getPathUser() . '/' . $user->uuid . '/' .  $userProfile->cover;
125
            if($this->s3Files->objectExist($remoto)) {
159
            if(file_exists($remoto)) {
126
                return $this->s3Files->getPresignedUrl($remoto);
160
                return $this->getPresignedUrl($remoto);
Línea 127... Línea 161...
127
                
161
                
128
            }
162
            }
Línea 129... Línea 163...
129
        }
163
        }
130
        
164
        
Línea 131... Línea 165...
131
        $remoto = $this->config['leaderslinked.images_default.user_cover'];
165
        $remoto = $this->config['leaderslinked.images_default.user_cover'];
Línea 132... Línea 166...
132
        return $this->s3Files->getPresignedUrl($remoto);
166
        return $this->getPresignedUrl($remoto);
133
        
167
        
Línea 139... Línea 173...
139
     * @return string
173
     * @return string
140
     */
174
     */
141
    public function getCompanyImage($company)
175
    public function getCompanyImage($company)
142
    {
176
    {
143
        if($company->image) {
177
        if($company->image) {
144
            $remoto = $this->getPathCompany() . '/' . $company->uuid . '/' .  $company->image;
178
            $remoto = self::BASE_PATH . '/' .$this->getPathCompany() . '/' . $company->uuid . '/' .  $company->image;
145
            if($this->s3Files->objectExist($remoto)) {
179
            if(file_exists($remoto)) {
146
                return $this->s3Files->getPresignedUrl($remoto);
180
                return $this->getPresignedUrl($remoto);
Línea 147... Línea 181...
147
                
181
                
148
            }
182
            }
Línea 149... Línea 183...
149
        }
183
        }
150
        
184
        
Línea 151... Línea 185...
151
        $remoto = $this->config['leaderslinked.images_default.company_profile'];
185
        $remoto = $this->config['leaderslinked.images_default.company_profile'];
Línea 152... Línea 186...
152
        return $this->s3Files->getPresignedUrl($remoto);
186
        return $this->getPresignedUrl($remoto);
153
        
187
        
Línea 160... Línea 194...
160
     * @return string
194
     * @return string
161
     */
195
     */
162
    public function getCompanyImageForCodeAndFilename($code, $filename)
196
    public function getCompanyImageForCodeAndFilename($code, $filename)
163
    {
197
    {
164
        if($filename) {
198
        if($filename) {
165
            $remoto = $this->getPathCompany() . '/' . $code . '/' .  $filename;
199
            $remoto = self::BASE_PATH . '/' .$this->getPathCompany() . '/' . $code . '/' .  $filename;
166
            if($this->s3Files->objectExist($remoto)) {
200
            if(file_exists($remoto)) {
167
                return $this->s3Files->getPresignedUrl($remoto);
201
                return $this->getPresignedUrl($remoto);
Línea 168... Línea 202...
168
                
202
                
169
            }
203
            }
Línea 170... Línea 204...
170
        }
204
        }
171
        
205
        
Línea 172... Línea 206...
172
        $remoto = $this->config['leaderslinked.images_default.company_profile'];
206
        $remoto = $this->config['leaderslinked.images_default.company_profile'];
Línea 173... Línea 207...
173
        return $this->s3Files->getPresignedUrl($remoto);
207
        return $this->getPresignedUrl($remoto);
174
        
208
        
Línea 180... Línea 214...
180
     * @return string
214
     * @return string
181
     */
215
     */
182
    public function getCompanyCover($company)
216
    public function getCompanyCover($company)
183
    {
217
    {
184
        if($company->cover) {
218
        if($company->cover) {
185
            $remoto = $this->getPathCompany() . '/' . $company->uuid . '/' .  $company->cover;
219
            $remoto = self::BASE_PATH . '/' .$this->getPathCompany() . '/' . $company->uuid . '/' .  $company->cover;
186
            if($this->s3Files->objectExist($remoto)) {
220
            if(file_exists($remoto)) {
187
                return $this->s3Files->getPresignedUrl($remoto);
221
                return $this->getPresignedUrl($remoto);
Línea 188... Línea 222...
188
                
222
                
189
            }
223
            }
Línea 190... Línea 224...
190
        }
224
        }
191
        
225
        
Línea 192... Línea 226...
192
        $remoto = $this->config['leaderslinked.images_default.company_cover'];
226
        $remoto = $this->config['leaderslinked.images_default.company_cover'];
Línea 193... Línea 227...
193
        return $this->s3Files->getPresignedUrl($remoto);
227
        return $this->getPresignedUrl($remoto);
194
        
228
        
Línea 200... Línea 234...
200
     * @return string
234
     * @return string
201
     */
235
     */
202
    public function getGroupImage($group)
236
    public function getGroupImage($group)
203
    {
237
    {
204
        if($group->image) {
238
        if($group->image) {
205
            $remoto = $this->getPathGroup() . '/' . $group->uuid . '/' .  $group->image;
239
            $remoto = self::BASE_PATH . '/' .$this->getPathGroup() . '/' . $group->uuid . '/' .  $group->image;
206
            if($this->s3Files->objectExist($remoto)) {
240
            if(file_exists($remoto)) {
207
                return $this->s3Files->getPresignedUrl($remoto);
241
                return $this->getPresignedUrl($remoto);
Línea 208... Línea 242...
208
                
242
                
209
            }
243
            }
Línea 210... Línea 244...
210
        }
244
        }
211
        
245
        
Línea 212... Línea 246...
212
        $remoto = $this->config['leaderslinked.images_default.group_profile'];
246
        $remoto = $this->config['leaderslinked.images_default.group_profile'];
Línea 213... Línea 247...
213
        return $this->s3Files->getPresignedUrl($remoto);
247
        return $this->getPresignedUrl($remoto);
214
        
248
        
Línea 221... Línea 255...
221
     * @return string
255
     * @return string
222
     */
256
     */
223
    public function getGroupImageForCodeAndFilename($code, $filename)
257
    public function getGroupImageForCodeAndFilename($code, $filename)
224
    {
258
    {
225
        if($filename) {
259
        if($filename) {
226
            $remoto = $this->getPathGroup() . '/' . $code . '/' .  $filename;
260
            $remoto = self::BASE_PATH . '/' .$this->getPathGroup() . '/' . $code . '/' .  $filename;
227
            if($this->s3Files->objectExist($remoto)) {
261
            if(file_exists($remoto)) {
228
                return $this->s3Files->getPresignedUrl($remoto);
262
                return $this->getPresignedUrl($remoto);
Línea 229... Línea 263...
229
                
263
                
230
            }
264
            }
Línea 231... Línea 265...
231
        }
265
        }
232
        
266
        
Línea 233... Línea 267...
233
        $remoto = $this->config['leaderslinked.images_default.group_profile'];
267
        $remoto = $this->config['leaderslinked.images_default.group_profile'];
Línea 234... Línea 268...
234
        return $this->s3Files->getPresignedUrl($remoto);
268
        return $this->getPresignedUrl($remoto);
235
        
269
        
Línea 241... Línea 275...
241
     * @return string
275
     * @return string
242
     */
276
     */
243
    public function getGroupCover($group)
277
    public function getGroupCover($group)
244
    {
278
    {
245
        if($group->cover) {
279
        if($group->cover) {
246
            $remoto = $this->getPathGroup() . '/' . $group->uuid . '/' .  $group->cover;
280
            $remoto = self::BASE_PATH . '/' .$this->getPathGroup() . '/' . $group->uuid . '/' .  $group->cover;
247
            if($this->s3Files->objectExist($remoto)) {
281
            if(file_exists($remoto)) {
248
                return $this->s3Files->getPresignedUrl($remoto);
282
                return $this->getPresignedUrl($remoto);
Línea 249... Línea 283...
249
                
283
                
250
            }
284
            }
Línea 251... Línea 285...
251
        }
285
        }
252
        
286
        
Línea 253... Línea 287...
253
        $remoto = $this->config['leaderslinked.images_default.group_cover'];
287
        $remoto = $this->config['leaderslinked.images_default.group_cover'];
Línea 254... Línea 288...
254
        return $this->s3Files->getPresignedUrl($remoto);
288
        return $this->getPresignedUrl($remoto);
255
        
289
        
256
    }
290
    }
257
    
291
    
258
    /**
292
    /**
259
     *
293
     *
260
     * @param Group $group
294
     * @param Group $group
261
     * @return string
295
     * @return string
Línea 262... Línea -...
262
     */
-
 
263
    public function getGenericImage($path, $code, $filename)
296
     */
264
    {
297
    public function getGenericImage($path, $code, $filename)
265
        $remoto = $path . '/' . $code. '/' .  $filename;
298
    {
Línea 266... Línea 299...
266
        
299
        $remoto = self::BASE_PATH . '/' .$path . '/' . $code. '/' .  $filename;
267
 
300
        
268
        
301
  
Línea 269... Línea 302...
269
        if($this->s3Files->objectExist($remoto)) {
302
        if(file_exists($remoto)) {
270
            return $this->s3Files->getPresignedUrl($remoto);
303
            return $this->getPresignedUrl($remoto);
Línea 271... Línea 304...
271
            
304
            
Línea 284... Línea 317...
284
     * @param boolean $checkExists
317
     * @param boolean $checkExists
285
     * @return string
318
     * @return string
286
     */
319
     */
287
    public function getGenericFile($path, $code, $filename, $checkExists = true)
320
    public function getGenericFile($path, $code, $filename, $checkExists = true)
288
    {
321
    {
289
        $remoto = $path . '/' . $code. '/' .  $filename;
322
        $remoto = self::BASE_PATH . '/' .$path . '/' . $code. '/' .  $filename;
Línea -... Línea 323...
-
 
323
        
290
        
324
 
291
        if($checkExists) {
325
        if($checkExists) {
292
            if($this->s3Files->objectExist($remoto)) {
326
            if(file_exists($remoto)) {
Línea 293... Línea 327...
293
                return $this->s3Files->getPresignedUrl($remoto);
327
                return $this->getPresignedUrl($remoto);
294
                
328
                
295
            } else {
329
            } else {
296
                return;
330
                return;
-
 
331
            } 
-
 
332
        } 
-
 
333
        return $this->getPresignedUrl($remoto);
-
 
334
    }
-
 
335
    
-
 
336
    public function getPathByType($type)
-
 
337
    {
-
 
338
        switch($type) 
-
 
339
        {
-
 
340
            case TYPE_CHAT : 
-
 
341
                return $this->getPathChat();
-
 
342
                
-
 
343
            case TYPE_GROUP : 
-
 
344
                return $this->getPathGroup();
-
 
345
                
-
 
346
            case TYPE_USER : 
-
 
347
                return $this->getPathUser();
-
 
348
                
-
 
349
            case TYPE_IMAGE : 
-
 
350
                return $this->getPathImage();
-
 
351
                
-
 
352
            case TYPE_JOB : 
-
 
353
                return $this->getPathJob();
-
 
354
                
-
 
355
            case TYPE_COMPANY : 
-
 
356
                return $this->getPathCompany();
-
 
357
                
-
 
358
            case TYPE_FEED : 
-
 
359
                return $this->getPathFeed();
-
 
360
                
-
 
361
            case TYPE_POST : 
-
 
362
                return $this->getPathPost();
-
 
363
                
-
 
364
            case TYPE_MICROLEARNING_TOPIC  : 
-
 
365
                return $this->getPathMicrolearningTopic();
-
 
366
                
-
 
367
            case TYPE_MICROLEARNING_CAPSULE : 
-
 
368
                return $this->getPathMicrolearningCapsule();
-
 
369
                
-
 
370
            case TYPE_MICROLEARNING_SLIDE  : 
-
 
371
                return $this->getPathMicrolearningSlide();
-
 
372
                
-
 
373
            case TYPE_JOB_DESCRIPTION : 
-
 
374
                return $this->getPathJobDescription();
-
 
375
                
-
 
376
            case TYPE_SELF_EVALUATION  : 
-
 
377
                return $this->getPathSelfEvaluation();
-
 
378
                
-
 
379
            case TYPE_PERFORMANCE_EVALUATION  : 
-
 
380
                return $this->getPathPerformanceEvaluation();
-
 
381
                
-
 
382
            case TYPE_RECRUITMENT_SELECTION  : 
-
 
383
                return $this->getPathRecruitmentSelection();
-
 
384
                
-
 
385
            case TYPE_PLANNING_OBJECTIVES_AND_GOALS : 
-
 
386
                return $this->getPathPlanningObjectivesAnGoals();
-
 
387
                
-
 
388
                
-
 
389
            case TYPE_MESSAGE  : 
-
 
390
                return $this->getPathMessage();
-
 
391
                
-
 
392
            case TYPE_SURVEY   : 
-
 
393
                return $this->getPathSurvey();
-
 
394
                
-
 
395
            case TYPE_NETWORK   : 
-
 
396
                return $this->getPathNetwork();
-
 
397
                
-
 
398
            case TYPE_DAILY_PULSE : 
-
 
399
                return $this->getPathDailyPulse();
-
 
400
                
-
 
401
            case TYPE_ENGAGEMENT_REWARD  : 
-
 
402
                return $this->getPathEngagementReward();
-
 
403
                
-
 
404
            case TYPE_KNOWLEDGE_AREA : 
-
 
405
                return $this->getPathKnowledgeArea();
-
 
406
                
-
 
407
            case TYPE_MY_COACH : 
-
 
408
                return $this->getPathMyCoach();
-
 
409
                
-
 
410
            case TYPE_HABIT_EMOJI  : 
-
 
411
                return $this->getPathHabitEmoji();
-
 
412
                
-
 
413
            case TYPE_HABIT_CONTENT : 
-
 
414
                return $this->getPathHabitContent();
-
 
415
                
-
 
416
            default : 
-
 
417
                return '/';
-
 
418
        }
-
 
419
        
-
 
420
       
-
 
421
    }
-
 
422
    
-
 
423
    /**
-
 
424
     *
-
 
425
     * @param Group $group
-
 
426
     * @return string
-
 
427
     */
-
 
428
    public function getGenericImageByType($type, $code, $filename)
-
 
429
    {
-
 
430
        $path = $this->getPathByType($type);
-
 
431
        $remoto = self::BASE_PATH . '/' .$path . '/' . $code. '/' .  $filename;
-
 
432
 
-
 
433
        if(file_exists($remoto)) {
-
 
434
            return $this->getPresignedUrl($remoto);
-
 
435
            
-
 
436
        } else {
-
 
437
            $remoto = $this->config['leaderslinked.images_default.no_image'];
-
 
438
            return $this->getPresignedUrl($remoto);
-
 
439
            
-
 
440
        }
-
 
441
    }
-
 
442
    
-
 
443
    /**
-
 
444
     *
-
 
445
     * @param string $type
-
 
446
     * @param string $code,
-
 
447
     * @param string $filename
-
 
448
     * @param boolean $checkExists
-
 
449
     * @return string
-
 
450
     */
-
 
451
    public function getGenericFileByType($type, $code, $filename, $checkExists = true)
-
 
452
    {
-
 
453
        $path = $this->getPathByType($type);
-
 
454
        $remoto = self::BASE_PATH . '/' .$path . '/' . $code. '/' .  $filename;
-
 
455
 
-
 
456
        if($checkExists) {
-
 
457
            if(file_exists($remoto)) {
-
 
458
                return $this->getPresignedUrl($remoto);
-
 
459
                
-
 
460
            } else {
-
 
461
                return;
297
            } 
462
            }
298
        } 
463
        }
Línea 299... Línea 464...
299
        return $this->s3Files->getPresignedUrl($remoto);
464
        return $this->getPresignedUrl($remoto);
300
    }
465
    }
301
    
466
    
Línea 306... Línea 471...
306
     * @param string $filename
471
     * @param string $filename
307
     * @return string
472
     * @return string
308
     */
473
     */
309
    public function delete($path, $code, $filename)
474
    public function delete($path, $code, $filename)
310
    {
475
    {
311
        $remoto = $path . '/' . $code. '/' .  $filename;
476
        $remoto = self::BASE_PATH . '/' .$path . '/' . $code. '/' .  $filename;
312
        try {
-
 
313
            $this->s3Files->deleteObject($remoto);
-
 
314
            return true;
-
 
315
        } catch (\Exception $exception) {
-
 
316
            //echo "No se pudo borrar el archivo : $remoto (" . $exception->getMessage() . ")";
-
 
317
            return false;
477
        return @unlink($remoto);
318
        }
478
 
Línea 319... Línea 479...
319
        
479
        
Línea 325... Línea 485...
325
     *
485
     *
326
     * @return string
486
     * @return string
327
     */
487
     */
328
    public function getPathMedia()
488
    public function getPathMedia()
329
    {
489
    {
330
        return $this->config['leaderslinked.minio.fullpath_media'];
490
        return $this->config['leaderslinked.storage.fullpath_media'];
331
    }
491
    }
Línea 332... Línea 492...
332
    
492
    
333
    
493
    
334
    /**
494
    /**
335
     *
495
     *
336
     * @return string
496
     * @return string
337
     */
497
     */
338
    public function getPathHabitEmoji()
498
    public function getPathHabitEmoji()
339
    {
499
    {
Línea 340... Línea 500...
340
        return $this->config['leaderslinked.minio.fullpath_habit_emoji'];
500
        return $this->config['leaderslinked.storage.fullpath_habit_emoji'];
341
    }
501
    }
342
    
502
    
343
    /**
503
    /**
344
     *
504
     *
345
     * @return string
505
     * @return string
346
     */
506
     */
347
    public function getPathHabitContent()
507
    public function getPathHabitContent()
Línea 348... Línea 508...
348
    {
508
    {
349
        return $this->config['leaderslinked.minio.fullpath_habit_content'];
509
        return $this->config['leaderslinked.storage.fullpath_habit_content'];
350
    }
510
    }
351
 
511
 
352
    
512
    
353
    /**
513
    /**
354
     * 
514
     * 
355
     * @return string
515
     * @return string
Línea 356... Línea 516...
356
     */
516
     */
357
    public function getPathGroup()
517
    public function getPathGroup()
358
    {
518
    {
359
        return $this->config['leaderslinked.minio.fullpath_group'];
519
        return $this->config['leaderslinked.storage.fullpath_group'];
360
    }
520
    }
361
    
521
    
362
    /**
522
    /**
363
     *
523
     *
Línea 364... Línea 524...
364
     * @return string
524
     * @return string
365
     */
525
     */
366
    public function getPathUser()
526
    public function getPathUser()
367
    {
527
    {
368
        return $this->config['leaderslinked.minio.fullpath_user'];
528
        return $this->config['leaderslinked.storage.fullpath_user'];
369
    }
529
    }
370
    
530
    
371
    /**
531
    /**
Línea 372... Línea 532...
372
     *
532
     *
373
     * @return string
533
     * @return string
374
     */
534
     */
375
    public function getPathImage()
535
    public function getPathImage()
376
    {
536
    {
377
        return $this->config['leaderslinked.minio.fullpath_image'];
537
        return $this->config['leaderslinked.storage.fullpath_image'];
378
    }
538
    }
-
 
539
    
-
 
540
    /**
-
 
541
     *
-
 
542
     * @return string
-
 
543
     */
-
 
544
    public function getPathJob()
-
 
545
    {
-
 
546
        return $this->config['leaderslinked.storage.fullpath_job'];
-
 
547
    }
379
    
548
    
Línea 380... Línea 549...
380
    /**
549
    /**
381
     *
550
     *
382
     * @return string
551
     * @return string
383
     */
552
     */
384
    public function getPathJob()
553
    public function getPathChat()
385
    {
554
    {
386
        return $this->config['leaderslinked.minio.fullpath_job'];
555
        return $this->config['leaderslinked.storage.fullpath_chat'];
387
    }
556
    }
Línea 388... Línea 557...
388
    
557
    
389
    /**
558
    /**
390
     *
559
     *
391
     * @return string
560
     * @return string
392
     */
561
     */
393
    public function getPathCompany()
562
    public function getPathCompany()
394
    {
563
    {
395
        return $this->config['leaderslinked.minio.fullpath_company'];
564
        return $this->config['leaderslinked.storage.fullpath_company'];
Línea 396... Línea 565...
396
    }
565
    }
397
    
566
    
398
    /**
567
    /**
399
     *
568
     *
400
     * @return string
569
     * @return string
401
     */
570
     */
402
    public function getPathFeed()
571
    public function getPathFeed()
403
    {
572
    {
Línea 404... Línea 573...
404
        return $this->config['leaderslinked.minio.fullpath_feed'];
573
        return $this->config['leaderslinked.storage.fullpath_feed'];
405
    }
574
    }
406
    
575
    
407
    
576
    
408
    
577
    
409
    /**
578
    /**
410
     *
579
     *
411
     * @return string
580
     * @return string
Línea 412... Línea 581...
412
     */
581
     */
413
    public function getPathMessage()
582
    public function getPathMessage()
414
    {
583
    {
415
        return $this->config['leaderslinked.minio.fullpath_message'];
584
        return $this->config['leaderslinked.storage.fullpath_message'];
416
    }
585
    }
417
    
586
    
418
    /**
587
    /**
419
     *
588
     *
Línea 420... Línea 589...
420
     * @return string
589
     * @return string
421
     */
590
     */
422
    public function getPathPost()
591
    public function getPathPost()
423
    {
592
    {
424
        return $this->config['leaderslinked.minio.fullpath_post'];
593
        return $this->config['leaderslinked.storage.fullpath_post'];
425
    }
594
    }
426
    
595
    
427
    /**
596
    /**
Línea 428... Línea 597...
428
     *
597
     *
429
     * @return string
598
     * @return string
430
     */
599
     */
431
    public function getPathMicrolearningTopic()
600
    public function getPathMicrolearningTopic()
432
    {
601
    {
433
        return $this->config['leaderslinked.minio.fullpath_microlearning_topic'];
602
        return $this->config['leaderslinked.storage.fullpath_microlearning_topic'];
434
    }
603
    }
435
    
604
    
Línea 436... Línea 605...
436
    /**
605
    /**
437
     *
606
     *
438
     * @return string
607
     * @return string
439
     */
608
     */
440
    public function getPathMicrolearningCapsule()
609
    public function getPathMicrolearningCapsule()
441
    {
610
    {
442
        return $this->config['leaderslinked.minio.fullpath_microlearning_capsule'];
611
        return $this->config['leaderslinked.storage.fullpath_microlearning_capsule'];
443
    }
612
    }
Línea 444... Línea 613...
444
    
613
    
445
    /**
614
    /**
446
     *
615
     *
447
     * @return string
616
     * @return string
448
     */
617
     */
449
    public function getPathMicrolearningSlide()
618
    public function getPathMicrolearningSlide()
450
    {
619
    {
451
        return $this->config['leaderslinked.minio.fullpath_microlearning_slide'];
620
        return $this->config['leaderslinked.storage.fullpath_microlearning_slide'];
Línea 452... Línea 621...
452
    }
621
    }
453
    
622
    
454
    /**
623
    /**
455
     *
624
     *
456
     * @return string
625
     * @return string
457
     */
626
     */
458
    public function getPathJobDescription()
627
    public function getPathJobDescription()
459
    {
628
    {
Línea 460... Línea 629...
460
        return $this->config['leaderslinked.minio.fullpath_job_description'];
629
        return $this->config['leaderslinked.storage.fullpath_job_description'];
461
    }
630
    }
462
    
631
    
463
    /**
632
    /**
464
     *
633
     *
465
     * @return string
634
     * @return string
466
     */
635
     */
467
    public function getPathSelfEvaluation()
636
    public function getPathSelfEvaluation()
Línea 468... Línea 637...
468
    {
637
    {
469
        return $this->config['leaderslinked.minio.fullpath_self_evaluation'];
638
        return $this->config['leaderslinked.storage.fullpath_self_evaluation'];
470
    }
639
    }
471
    
640
    
472
    /**
641
    /**
473
     *
642
     *
474
     * @return string
643
     * @return string
475
     */
644
     */
Línea 476... Línea 645...
476
    public function getPathRecruitmentSelection()
645
    public function getPathRecruitmentSelection()
477
    {
646
    {
478
        return $this->config['leaderslinked.minio.fullpath_recruitment_selection'];
647
        return $this->config['leaderslinked.storage.fullpath_recruitment_selection'];
479
    }
648
    }
480
    
649
    
481
    /**
650
    /**
482
     *
651
     *
483
     * @return string
652
     * @return string
Línea 484... Línea 653...
484
     */
653
     */
485
    public function getPathPerformanceEvaluation()
654
    public function getPathPerformanceEvaluation()
486
    {
655
    {
487
        return $this->config['leaderslinked.minio.fullpath_performance_evaluation'];
656
        return $this->config['leaderslinked.storage.fullpath_performance_evaluation'];
488
    }
657
    }
489
    
658
    
490
    /**
659
    /**
491
     *
660
     *
Línea 492... Línea 661...
492
     * @return string
661
     * @return string
493
     */
662
     */
494
    public function getPathPlanningObjectivesAnGoals()
663
    public function getPathPlanningObjectivesAnGoals()
495
    {
664
    {
496
        return $this->config['leaderslinked.minio.fullpath_planning_objectives_and_goals'];
665
        return $this->config['leaderslinked.storage.fullpath_planning_objectives_and_goals'];
497
    }
666
    }
498
    
667
    
499
    /**
668
    /**
Línea 500... Línea 669...
500
     *
669
     *
501
     * @return string
670
     * @return string
502
     */
671
     */
503
    public function getPathSurvey()
672
    public function getPathSurvey()
504
    {
673
    {
505
        return $this->config['leaderslinked.minio.fullpath_survey'];
674
        return $this->config['leaderslinked.storage.fullpath_survey'];
506
    }
675
    }
507
    
676
    
Línea 508... Línea 677...
508
    /**
677
    /**
509
     *
678
     *
510
     * @return string
679
     * @return string
511
     */
680
     */
512
    public function getPathNetwork()
681
    public function getPathNetwork()
513
    {
682
    {
514
        return $this->config['leaderslinked.minio.fullpath_network'];
683
        return $this->config['leaderslinked.storage.fullpath_network'];
515
    }
684
    }
Línea 516... Línea 685...
516
    
685
    
517
    /**
686
    /**
518
     *
687
     *
519
     * @return string
688
     * @return string
520
     */
689
     */
521
    public function getPathEngagementReward()
690
    public function getPathEngagementReward()
522
    {
691
    {
523
        return $this->config['leaderslinked.minio.fullpath_engagement_reward'];
692
        return $this->config['leaderslinked.storage.fullpath_engagement_reward'];
Línea 524... Línea 693...
524
    }
693
    }
525
    
694
    
526
    /**
695
    /**
527
     *
696
     *
528
     * @return string
697
     * @return string
529
     */
698
     */
530
    public function getPathDailyPulse()
699
    public function getPathDailyPulse()
531
    {
700
    {
532
        return $this->config['leaderslinked.minio.fullpath_daily_pulse'];
701
        return $this->config['leaderslinked.storage.fullpath_daily_pulse'];
Línea 533... Línea 702...
533
    }
702
    }
534
    
703
    
535
    /**
704
    /**
536
     *
705
     *
537
     * @return string
706
     * @return string
538
     */
707
     */
539
    public function getPathKnowledgeArea()
708
    public function getPathKnowledgeArea()
540
    {
709
    {
541
        return $this->config['leaderslinked.minio.fullpath_knowledge_area'];
710
        return $this->config['leaderslinked.storage.fullpath_knowledge_area'];
542
    }
711
    }
Línea 543... Línea 712...
543
    
712
    
544
    /**
713
    /**
Línea 578... Línea 747...
578
 
747
 
579
     * @return boolean
748
     * @return boolean
580
     */
749
     */
581
    public function deleteObject($filename)
750
    public function deleteObject($filename)
582
    {
751
    {
583
        return $this->s3Files->deleteObject($filename);
752
        return @unlink($filename);
Línea 584... Línea 753...
584
    }
753
    }
585
    
754
    
Línea 596... Línea 765...
596
        if($code) {
765
        if($code) {
597
            $remoto = $path . '/' . $code. '/' .  $filename;
766
            $remoto = $path . '/' . $code. '/' .  $filename;
598
        } else {
767
        } else {
599
            $remoto = $path . '/' .  $filename;
768
            $remoto = $path . '/' .  $filename;
600
        }
769
        }
601
        if($this->s3Files->objectExist($remoto)) {
770
        if(file_exists($remoto)) {
602
            return $this->s3Files->deleteObject($remoto);
771
            return @unlink($remoto);
603
        } else {
772
        } else {
604
            return true;
773
            return true;
605
        }
774
        }
606
    }
775
    }
Línea 612... Línea 781...
612
     * @return boolean
781
     * @return boolean
613
     */
782
     */
614
    public function deleteDirectory($path, $code)
783
    public function deleteDirectory($path, $code)
615
    {
784
    {
616
        $remoto = $path . '/' . $code;
785
        $remoto = $path . '/' . $code;
617
        if($this->s3Files->objectExist($remoto)) {
786
        if(file_exists($remoto)) {
618
            return $this->s3Files->deleteObject($remoto);
787
            return @unlink($remoto);
619
        } else {
788
        } else {
620
            return true;
789
            return true;
621
        }
790
        }
622
    }
791
    }
Línea 637... Línea 806...
637
        } else {
806
        } else {
638
            $remote = $path. '/' . basename($local_filename);
807
            $remote = $path. '/' . basename($local_filename);
639
        }
808
        }
Línea 640... Línea -...
640
        
-
 
641
 
-
 
642
        $result = $this->s3Files->putObject($remote, $local_filename);
809
        
643
        if(file_exists($local_filename)) {
-
 
644
            @unlink($local_filename);
810
 
645
        }
-
 
646
        
811
        return @rename($local_filename, $remote);
Línea 647... Línea 812...
647
        return $result;
812
 
648
    }
813
    }
Línea 657... Línea 822...
657
     * @return boolean
822
     * @return boolean
658
     */
823
     */
659
    public function moveAndPutFile($path, $code, $tempfile, $filename)
824
    public function moveAndPutFile($path, $code, $tempfile, $filename)
660
    {
825
    {
661
        if($code) {
826
        if($code) {
662
            $filepath = $path . '/' . $code;
827
            $targetfile = $path . '/' . $code;
663
        } else {
828
        } else {
664
            $filepath = $path;
829
            $targetfile = $path . '/' . $filename;
665
        }
830
        }
666
        
831
 
667
        $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $filename;
-
 
668
        
-
 
669
        move_uploaded_file($tempfile, $filename);
832
        return move_uploaded_file($tempfile, $targetfile);
670
        
-
 
671
        $result = $this->s3Files->putObject($filename, $filepath);
-
 
672
        @unlink($filename);
-
 
673
        
-
 
674
        return $result;
-
 
675
    }
833
    }
Línea 676... Línea 834...
676
    
834
    
677
    /**
835
    /**
678
     *
836
     *
Línea 681... Línea 839...
681
    public function getTempPath()
839
    public function getTempPath()
682
    {
840
    {
683
        return 'data' . DIRECTORY_SEPARATOR . 'storage';
841
        return 'data' . DIRECTORY_SEPARATOR . 'storage';
684
    }
842
    }
Línea -... Línea 843...
-
 
843
    
-
 
844
    /**
-
 
845
     * 
-
 
846
     * @param string $url
-
 
847
     * @return string
-
 
848
     */
-
 
849
    public function getPresignedUrl($url)
-
 
850
    {
-
 
851
        
-
 
852
 
-
 
853
        
-
 
854
        $code = hash('sha256', $url);
-
 
855
        
-
 
856
        $storageFileMapper = \LeadersLinked\Mapper\StorageFileMapper::getInstance($this->adapter);
-
 
857
        $storageFile = $storageFileMapper->fetchOneByCode($code);
-
 
858
        if(!$storageFile) {
-
 
859
            $storageFile = new \LeadersLinked\Model\StorageFile();
-
 
860
            $storageFile->code = $code;
-
 
861
            $storageFile->path = $url;
-
 
862
            $storageFile->salt = \LeadersLinked\Library\Functions::generatePassword(8);
-
 
863
            
-
 
864
            
-
 
865
            
-
 
866
            $storageFileMapper->insert($storageFile);
-
 
867
            
-
 
868
        }
-
 
869
        
-
 
870
        /*
-
 
871
        $hostname = empty($_SERVER['HTTP_ORIGIN']) ? '' : $_SERVER['HTTP_ORIGIN'];
-
 
872
        
-
 
873
        if(empty($hostname)) {
-
 
874
            
-
 
875
            $hostname = empty($_SERVER['HTTP_REFERER']) ?  '' : $_SERVER['HTTP_REFERER'];
-
 
876
            
-
 
877
            if(empty($hostname)) {
-
 
878
                $hostname = empty($_SERVER['HTTP_HOST']) ?  '' : $_SERVER['HTTP_HOST'];
-
 
879
                
-
 
880
            }
-
 
881
        }
-
 
882
        
-
 
883
        print_r($_SERVER);
-
 
884
        
-
 
885
        
-
 
886
        $hostname = trim(str_replace('http://', 'https://', $hostname));
-
 
887
        */
-
 
888
        
-
 
889
        
-
 
890
        
-
 
891
        
-
 
892
 
-
 
893
      
-
 
894
       
-
 
895
        
-
 
896
        return 'https://' . $_SERVER['SERVER_NAME'] . '/storage/' . $code;
-
 
897
        
-
 
898
    }