Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 1 | Rev 3648 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 www 1
<?php
2
/**
3
 *
4
 * Controlador: Mis Perfiles
5
 *
6
 */
7
declare(strict_types=1);
8
 
9
namespace LeadersLinked\Controller;
10
 
11
use Laminas\Db\Adapter\AdapterInterface;
12
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
13
use Laminas\Mvc\Controller\AbstractActionController;
14
use Laminas\Log\LoggerInterface;
15
use Laminas\View\Model\ViewModel;
16
use Laminas\View\Model\JsonModel;
17
use Laminas\Db\Sql\Expression;
18
use LeadersLinked\Model\User;
19
use LeadersLinked\Mapper\ConnectionMapper;
20
use LeadersLinked\Mapper\UserMapper;
21
use LeadersLinked\Model\Connection;
22
use Laminas\Paginator\Adapter\DbSelect;
23
use Laminas\Paginator\Paginator;
24
use LeadersLinked\Mapper\UserBlockedMapper;
25
use LeadersLinked\Model\UserBlocked;
26
use LeadersLinked\Mapper\QueryMapper;
27
use LeadersLinked\Model\UserType;
28
use LeadersLinked\Model\CompanyUser;
29
use LeadersLinked\Mapper\GroupMemberMapper;
30
use LeadersLinked\Model\GroupMember;
31
use LeadersLinked\Mapper\CompanyUserMapper;
32
use LeadersLinked\Mapper\CompanyMicrolearningCapsuleUserMapper;
33
use LeadersLinked\Model\Notification;
34
use LeadersLinked\Mapper\NotificationMapper;
35
use LeadersLinked\Mapper\UserNotificationSettingMapper;
36
use LeadersLinked\Mapper\EmailTemplateMapper;
37
use LeadersLinked\Model\EmailTemplate;
38
use LeadersLinked\Library\QueueEmail;
39
 
40
class ConnectionController extends AbstractActionController
41
{
42
    /**
43
     *
44
     * @var AdapterInterface
45
     */
46
    private $adapter;
47
 
48
 
49
    /**
50
     *
51
     * @var AbstractAdapter
52
     */
53
    private $cache;
54
 
55
    /**
56
     *
57
     * @var  LoggerInterface
58
     */
59
    private $logger;
60
 
61
 
62
    /**
63
     *
64
     * @var array
65
     */
66
    private $config;
67
 
68
    /**
69
     *
70
     * @param AdapterInterface $adapter
71
     * @param AbstractAdapter $cache
72
     * @param LoggerInterface $logger
73
     * @param array $config
74
     */
75
    public function __construct($adapter, $cache , $logger,  $config)
76
    {
77
        $this->adapter      = $adapter;
78
        $this->cache        = $cache;
79
        $this->logger       = $logger;
80
        $this->config       = $config;
81
 
82
    }
83
 
84
    /**
85
     *
86
     * Generación del listado de perfiles
87
     * {@inheritDoc}
88
     * @see \Laminas\Mvc\Controller\AbstractActionController::indexAction()
89
     */
90
    public function indexAction()
91
    {
92
        return new JsonModel([
93
            'success' => false,
94
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
95
        ]);
96
    }
97
 
98
    public function myConnectionsAction()
99
    {
100
        $currentUserPlugin = $this->plugin('currentUserPlugin');
101
        $currentUser = $currentUserPlugin->getUser();
102
 
103
        $request = $this->getRequest();
104
        if($request->isGet()) {
105
 
106
 
107
            $headers  = $request->getHeaders();
108
            $isJson = false;
109
            if($headers->has('Accept')) {
110
                $accept = $headers->get('Accept');
111
 
112
                $prioritized = $accept->getPrioritized();
113
 
114
                foreach($prioritized as $key => $value) {
115
                    $raw = trim($value->getRaw());
116
 
117
                    if(!$isJson) {
118
                        $isJson = strpos($raw, 'json');
119
                    }
120
 
121
                }
122
            }
123
 
124
            if($isJson) {
125
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
126
 
127
 
128
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
129
                $user_ids = $connectionMapper->fetchAllConnectionsByUserReturnIds($currentUser->id);
130
 
131
                $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
132
                $user_blocked_ids = $userBlockedMapper->fetchAllBlockedReturnIds($currentUser->id);
133
                $user_ids = array_diff($user_ids, $user_blocked_ids);
134
 
135
                $queryMapper = QueryMapper::getInstance($this->adapter);
136
 
137
                $select = $queryMapper->getSql()->select(UserMapper::_TABLE);
138
                $select->where->in('id', $user_ids);
139
                $select->where->equalTo('status', User::STATUS_ACTIVE);
140
 
141
                if($search) {
142
                    $select->where->NEST->like('first_name', '%' . $search . '%')->or->like('last_name', '%' . $search . '%')->UNNEST;
143
                }
144
                $select->order('first_name ASC, last_name ASC');
145
 
146
                $records = $queryMapper->fetchAll($select);
147
                $items = [];
148
                foreach($records as $record)
149
                {
150
 
151
 
152
                    $item = [
153
                        'name' => trim($record['first_name'] . ' ' . $record['last_name']),
154
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $record['uuid'], 'filename' => $record['image'] ]),
155
                        'link_view' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']  ]),
156
                        'link_inmail'   => $this->url()->fromRoute('inmail', ['id' => $record['uuid']  ]),
157
                        'link_cancel' => $this->url()->fromRoute('connection/cancel', ['id' => $record['uuid']  ]),
158
                        'link_block'=> $this->url()->fromRoute('connection/block', ['id' => $record['uuid']  ]),
159
 
160
                    ];
161
 
162
 
163
 
164
                    array_push($items, $item);
165
                }
166
 
167
 
168
 
169
 
170
                $response = [
171
                    'success' => true,
172
                    'data' => $items
173
                ];
174
 
175
                return new JsonModel($response);
176
 
177
 
178
            } else {
179
 
180
                $notificationMapper = NotificationMapper::getInstance($this->adapter);
181
                $notificationMapper->markAllNotificationsAsReadByTypeAndUserId(Notification::TYPE_ACCEPT_MY_REQUEST_CONNECTION, $currentUser->id);
182
 
183
                $this->layout()->setTemplate('layout/layout.phtml');
184
                $viewModel = new ViewModel();
185
                $viewModel->setTemplate('leaders-linked/connection/my-connections.phtml');
186
                return $viewModel ;
187
            }
188
 
189
        } else {
190
            return new JsonModel([
191
                'success' => false,
192
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
193
            ]);
194
        }
195
    }
196
 
197
    public function invitationsSentAction()
198
    {
199
        $currentUserPlugin = $this->plugin('currentUserPlugin');
200
        $currentUser = $currentUserPlugin->getUser();
201
 
202
        $request = $this->getRequest();
203
        if($request->isGet()) {
204
 
205
 
206
            $headers  = $request->getHeaders();
207
            $isJson = false;
208
            if($headers->has('Accept')) {
209
                $accept = $headers->get('Accept');
210
 
211
                $prioritized = $accept->getPrioritized();
212
 
213
                foreach($prioritized as $key => $value) {
214
                    $raw = trim($value->getRaw());
215
 
216
                    if(!$isJson) {
217
                        $isJson = strpos($raw, 'json');
218
                    }
219
 
220
                }
221
            }
222
 
223
            if($isJson) {
224
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
225
 
226
 
227
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
228
                $user_ids = $connectionMapper->fetchAllSentInvitationsReturnIds($currentUser->id);
229
 
230
                $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
231
                $user_blocked_ids = $userBlockedMapper->fetchAllBlockedReturnIds($currentUser->id);
232
                $user_ids = array_diff($user_ids, $user_blocked_ids);
233
 
234
 
235
                $queryMapper = QueryMapper::getInstance($this->adapter);
236
 
237
                $select = $queryMapper->getSql()->select(UserMapper::_TABLE);
238
                $select->where->in('id', $user_ids);
239
                $select->where->equalTo('status', User::STATUS_ACTIVE);
240
 
241
                if($search) {
242
                    $select->where->NEST->like('first_name', '%' . $search . '%')->or->like('last_name', '%' . $search . '%')->UNNEST;
243
                }
244
                $select->order('first_name ASC, last_name ASC');
245
 
246
                $records = $queryMapper->fetchAll($select);
247
                $items = [];
248
                foreach($records as $record)
249
                {
250
                    $item = [
251
                        'name' => trim($record['first_name'] . ' ' . $record['last_name']),
252
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $record['uuid'], 'filename' => $record['image'] ]),
253
                        'link_view' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']  ]),
254
                        'link_delete' => $this->url()->fromRoute('connection/delete', ['id' => $record['uuid']  ]),
255
                    ];
256
 
257
                    array_push($items, $item);
258
                }
259
 
260
                $response = [
261
                    'success' => true,
262
                    'data' => $items
263
                ];
264
 
265
                return new JsonModel($response);
266
            } else {
267
                $this->layout()->setTemplate('layout/layout.phtml');
268
                $viewModel = new ViewModel();
269
                $viewModel->setTemplate('leaders-linked/connection/invitations-sent.phtml');
270
                return $viewModel ;
271
            }
272
 
273
        } else {
274
            return new JsonModel([
275
                'success' => false,
276
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
277
            ]);
278
        }
279
    }
280
 
281
    public function invitationsReceivedAction()
282
    {
283
        $currentUserPlugin = $this->plugin('currentUserPlugin');
284
        $currentUser = $currentUserPlugin->getUser();
285
 
286
        $request = $this->getRequest();
287
        if($request->isGet()) {
288
 
289
 
290
            $headers  = $request->getHeaders();
291
            $isJson = false;
292
            if($headers->has('Accept')) {
293
                $accept = $headers->get('Accept');
294
 
295
                $prioritized = $accept->getPrioritized();
296
 
297
                foreach($prioritized as $key => $value) {
298
                    $raw = trim($value->getRaw());
299
 
300
                    if(!$isJson) {
301
                        $isJson = strpos($raw, 'json');
302
                    }
303
 
304
                }
305
            }
306
 
307
            if($isJson) {
308
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
309
 
310
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
311
                $user_ids = $connectionMapper->fetchAllReceiveInvitationsReturnIds($currentUser->id);
312
 
313
 
314
                $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
315
                $user_blocked_ids = $userBlockedMapper->fetchAllBlockedReturnIds($currentUser->id);
316
                $user_ids = array_diff($user_ids, $user_blocked_ids);
317
 
318
                $queryMapper = QueryMapper::getInstance($this->adapter);
319
                $select = $queryMapper->getSql()->select(UserMapper::_TABLE);
320
                $select->where->in('id', $user_ids);
321
                $select->where->equalTo('status', User::STATUS_ACTIVE);
322
 
323
                if($search) {
324
                    $select->where->NEST->like('first_name', '%' . $search . '%')->or->like('last_name', '%' . $search . '%')->UNNEST;
325
                }
326
                $select->order('first_name ASC, last_name ASC');
327
 
328
                $records = $queryMapper->fetchAll($select);
329
                $items = [];
330
                foreach($records as $record)
331
                {
332
                    $item = [
333
                        'name' => trim($record['first_name'] . ' ' . $record['last_name']),
334
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $record['uuid'], 'filename' => $record['image'] ]),
335
                        'link_view' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']  ]),
336
                        'link_approve' => $this->url()->fromRoute('connection/approve', ['id' => $record['uuid']  ]),
337
                        'link_reject' => $this->url()->fromRoute('connection/reject', ['id' => $record['uuid']  ]),
338
 
339
                    ];
340
 
341
                    array_push($items, $item);
342
                }
343
 
344
                $response = [
345
                    'success' => true,
346
                    'data' => $items
347
                ];
348
 
349
                return new JsonModel($response);
350
            } else {
351
                $notificationMapper = NotificationMapper::getInstance($this->adapter);
352
                $notificationMapper->markAllNotificationsAsReadByTypeAndUserId(Notification::TYPE_RECEIVE_CONNECTION_REQUEST, $currentUser->id);
353
 
354
 
355
                $this->layout()->setTemplate('layout/layout.phtml');
356
                $viewModel = new ViewModel();
357
                $viewModel->setTemplate('leaders-linked/connection/invitations-received.phtml');
358
                return $viewModel ;
359
            }
360
 
361
        } else {
362
            return new JsonModel([
363
                'success' => false,
364
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
365
            ]);
366
        }
367
    }
368
 
369
    public function cancelAction()
370
    {
371
        $request = $this->getRequest();
372
        if($request->isPost()) {
373
            $currentUserPlugin = $this->plugin('currentUserPlugin');
374
            $currentUser = $currentUserPlugin->getUser();
375
 
376
            $id = $this->params()->fromRoute('id');
377
 
378
            $id = $this->params()->fromRoute('id');
379
            $userMapper = UserMapper::getInstance($this->adapter);
380
            $user = $userMapper->fetchOneByUuid($id);
381
 
382
            if(!$user) {
383
                return new JsonModel([
384
                    'success' => true,
385
                    'data' => 'ERROR_USER_NOT_FOUND'
386
                ]);
387
            }
388
 
389
 
390
 
391
            if($user->id == $currentUser->id || in_array($user->status, [User::STATUS_DELETED, User::STATUS_INACTIVE]) || $user->email_verified == User::EMAIL_VERIFIED_NO || $user->blocked == User::BLOCKED_YES) {
392
                return new JsonModel([
393
                    'success' => false,
394
                    'data' => 'ERROR_USER_UNAVAILABLE'
395
                ]);
396
            }
397
 
398
 
399
 
400
            $connectionMapper = ConnectionMapper::getInstance($this->adapter);
401
            $connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
402
            if($connection) {
403
                if($connection->status == Connection::STATUS_ACCEPTED) {
404
                    if($connectionMapper->cancel($connection)) {
405
                        return new JsonModel([
406
                            'success' => true,
407
                            'data' => 'LABEL_CONNECTION_CANCELED'
408
                        ]);
409
                    } else {
410
                        return new JsonModel([
411
                            'success' => true,
412
                            'data' => $connectionMapper->getError()
413
                        ]);
414
                    }
415
                } else {
416
                    return new JsonModel([
417
                        'success' => true,
418
                        'data' => 'LABEL_CONNECTION_CANCELED'
419
                    ]);
420
                }
421
            } else {
422
                return new JsonModel([
423
                    'success' => true,
424
                    'data' => 'LABEL_CONNECTION_NOT_FOUND'
425
                ]);
426
 
427
            }
428
 
429
        } else {
430
            return new JsonModel([
431
                'success' => false,
432
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
433
            ]);
434
        }
435
    }
436
 
437
    public function approveAction()
438
    {
439
        $request = $this->getRequest();
440
        if($request->isPost()) {
441
            $currentUserPlugin = $this->plugin('currentUserPlugin');
442
            $currentUser = $currentUserPlugin->getUser();
443
 
444
            $id = $this->params()->fromRoute('id');
445
            $userMapper = UserMapper::getInstance($this->adapter);
446
            $user = $userMapper->fetchOneByUuid($id);
447
 
448
            if($user) {
449
 
450
                if($user->id == $currentUser->id || in_array($user->status, [User::STATUS_DELETED, User::STATUS_INACTIVE]) || $user->email_verified == User::EMAIL_VERIFIED_NO || $user->blocked == User::BLOCKED_YES) {
451
                    return new JsonModel([
452
                        'success' => true,
453
                        'data' => 'ERROR_USER_UNAVAILABLE'
454
                    ]);
455
                }
456
 
457
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
458
                $connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
459
                if($connection) {
460
                    if($connection->status == Connection::STATUS_SENT) {
461
                        if($connectionMapper->approve($connection)) {
462
 
463
                            if($currentUser->id == $connection->request_to) {
464
                                $other_user_id = $connection->request_from;
465
                            } else {
466
                                $other_user_id = $connection->request_to;
467
                            }
468
 
469
                            $otherUser = $userMapper->fetchOne($other_user_id);
470
 
471
                            $notification = new Notification();
472
                            $notification->type     = Notification::TYPE_ACCEPT_MY_REQUEST_CONNECTION;
473
                            $notification->read     = Notification::NO;
474
                            $notification->user_id  = $otherUser->id;
475
                            $notification->message  = 'LABEL_NOTIFICATION_ACCEPT_MY_REQUEST_CONNECTION';
476
                            $notification->url      = $this->url()->fromRoute('connection/my-connections');
477
 
478
                            $notificationMapper = NotificationMapper::getInstance($this->adapter);
479
                            $notificationMapper->insert($notification);
480
 
481
                            $userNotificationMapper = UserNotificationSettingMapper::getInstance($this->adapter);
482
                            $userNotification = $userNotificationMapper->fetchOne($otherUser->id);
483
 
484
                            if($userNotification && $userNotification->receive_connection_request)
485
                            {
486
                                $emailTemplateMapper = EmailTemplateMapper::getInstance($this->adapter);
3639 efrain 487
                                $emailTemplate = $emailTemplateMapper->fetchOne(EmailTemplate::CODE_ACCEPT_MY_REQUEST_CONNECTION);
1 www 488
 
489
                                if($emailTemplate) {
490
                                    $arrayCont = [
491
                                        'firstname'             => $currentUser->first_name,
492
                                        'lastname'              => $currentUser->last_name,
493
                                        'other_user_firstname'  => $otherUser->first_name,
494
                                        'other_user_lastname'   => $otherUser->last_name,
495
                                        'company_name'          => '',
496
                                        'group_name'            => '',
497
                                        'content'               => '',
498
                                        'code'                  => '',
499
                                        'link'                  => $this->url()->fromRoute('connection/my-connections', [], ['force_canonical' => true])
500
                                    ];
501
 
502
                                    $email = new QueueEmail($this->adapter);
503
                                    $email->processEmailTemplate($emailTemplate, $arrayCont, $otherUser->email, trim($otherUser->first_name . ' ' . $otherUser->last_name));
504
                                }
505
                            }
506
 
507
                            return new JsonModel([
508
                                'success' => true,
509
                                'data' => 'LABEL_CONNECTION_APPROVED'
510
                            ]);
511
                        } else {
512
                            return new JsonModel([
513
                                'success' => true,
514
                                'data' => $connectionMapper->getError()
515
                            ]);
516
                        }
517
                    } else {
518
                        return new JsonModel([
519
                            'success' => true,
520
                            'data' => 'LABEL_CONNECTION_NOT_PENDING'
521
                        ]);
522
                    }
523
                } else {
524
                    return new JsonModel([
525
                        'success' => true,
526
                        'data' => 'LABEL_CONNECTION_NOT_FOUND'
527
                    ]);
528
 
529
                }
530
            } else {
531
                return new JsonModel([
532
                    'success' => true,
533
                    'data' => 'ERROR_USER_NOT_FOUND'
534
                ]);
535
            }
536
        } else {
537
            return new JsonModel([
538
                'success' => false,
539
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
540
            ]);
541
        }
542
    }
543
 
544
    public function rejectAction()
545
    {
546
        $request = $this->getRequest();
547
        if($request->isPost()) {
548
            $currentUserPlugin = $this->plugin('currentUserPlugin');
549
            $currentUser = $currentUserPlugin->getUser();
550
 
551
            $id = $this->params()->fromRoute('id');
552
            $userMapper = UserMapper::getInstance($this->adapter);
553
            $user = $userMapper->fetchOneByUuid($id);
554
 
555
            if($user) {
556
 
557
                if($user->id == $currentUser->id || in_array($user->status, [User::STATUS_DELETED, User::STATUS_INACTIVE]) || $user->email_verified == User::EMAIL_VERIFIED_NO || $user->blocked == User::BLOCKED_YES) {
558
                    return new JsonModel([
559
                        'success' => true,
560
                        'data' => 'ERROR_USER_UNAVAILABLE'
561
                    ]);
562
                }
563
 
564
 
565
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
566
                $connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
567
                if($connection) {
568
                    if($connection->status == Connection::STATUS_SENT) {
569
                        if($connectionMapper->reject($connection)) {
570
                            return new JsonModel([
571
                                'success' => true,
572
                                'data' => 'LABEL_CONNECTION_REJECTED'
573
                            ]);
574
                        } else {
575
                            return new JsonModel([
576
                                'success' => true,
577
                                'data' => $connectionMapper->getError()
578
                            ]);
579
                        }
580
                    } else {
581
                        return new JsonModel([
582
                            'success' => true,
583
                            'data' => 'LABEL_CONNECTION_NOT_PENDING'
584
                        ]);
585
                    }
586
                } else {
587
                    return new JsonModel([
588
                        'success' => true,
589
                        'data' => 'LABEL_CONNECTION_NOT_FOUND'
590
                    ]);
591
 
592
                }
593
            } else {
594
                return new JsonModel([
595
                    'success' => false,
596
                    'data' => 'ERROR_USER_NOT_FOUND'
597
                ]);
598
            }
599
        } else {
600
            return new JsonModel([
601
                'success' => false,
602
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
603
            ]);
604
        }
605
    }
606
 
607
    public function requestAction()
608
    {
609
        $request = $this->getRequest();
610
        if($request->isPost()) {
611
            $currentUserPlugin = $this->plugin('currentUserPlugin');
612
            $currentUser = $currentUserPlugin->getUser();
613
 
614
            $id = $this->params()->fromRoute('id');
615
 
616
            $id = $this->params()->fromRoute('id');
617
            $userMapper = UserMapper::getInstance($this->adapter);
618
            $user = $userMapper->fetchOneByUuid($id);
619
 
620
            if($user) {
621
 
622
                if($user->id == $currentUser->id || in_array($user->status, [User::STATUS_DELETED, User::STATUS_INACTIVE]) || $user->email_verified == User::EMAIL_VERIFIED_NO || $user->blocked == User::BLOCKED_YES) {
623
                    return new JsonModel([
624
                        'success' => true,
625
                        'data' => 'ERROR_USER_UNAVAILABLE'
626
                    ]);
627
                }
628
 
629
 
630
                $send_notification = false;
631
 
632
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
633
                $connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
634
                if(!$connection) {
635
                    $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
636
                    $userBlocked = $userBlockedMapper->fetchOneByUserIdAndBlockedId($currentUser->id, $user->id);
637
 
638
                    if(!$userBlocked ) {
639
                        $connection = new Connection();
640
                        $connection->request_from = $currentUser->id;
641
                        $connection->request_to = $user->id;
642
                        $connection->status = Connection::STATUS_SENT;
643
 
644
 
645
                        if($connectionMapper->insert($connection)) {
646
 
647
                            $send_notification = true;
648
 
649
                            $response = [
650
                                'success' => true,
651
                                'data' => 'LABEL_CONNECTION_REQUESTED'
652
                            ];
653
                        } else {
654
                            $response = [
655
                                'success' => true,
656
                                'data' => $connectionMapper->getError()
657
                            ];
658
                        }
659
                    } else {
660
                        $response = [
661
                            'success' => true,
662
                            'data' => 'ERROR_USER_NOT_FOUND'
663
                        ];
664
                    }
665
                } else {
666
 
667
 
668
                    $connection->request_from = $currentUser->id;
669
                    $connection->request_to = $user->id;
670
                    $connection->status = Connection::STATUS_SENT;
671
                    if( $connectionMapper->update($connection)) {
672
                        $send_notification = true;
673
                        $response = [
674
                            'success' => true,
675
                            'data' => 'LABEL_CONNECTION_REQUESTED'
676
                        ];
677
                    } else {
678
                        $response = [
679
                            'success' => true,
680
                            'data' => $connectionMapper->getError()
681
                        ];
682
                    }
683
 
684
 
685
 
686
                }
687
 
688
                if($send_notification) {
689
                    $notification = new Notification();
690
                    $notification->type     = Notification::TYPE_RECEIVE_CONNECTION_REQUEST;
691
                    $notification->read     = Notification::NO;
692
                    $notification->user_id  = $user->id;
693
                    $notification->message  = 'LABEL_NOTIFICATION_RECEIVE_CONNECTION_REQUEST';
694
                    $notification->url      = $this->url()->fromRoute('connection/invitations-received');
695
 
696
                    $notificationMapper = NotificationMapper::getInstance($this->adapter);
697
                    $notificationMapper->insert($notification);
698
 
699
                    $userNotificationMapper = UserNotificationSettingMapper::getInstance($this->adapter);
700
                    $userNotification = $userNotificationMapper->fetchOne($user->id);
701
 
702
                    if($userNotification && $userNotification->receive_connection_request)
703
                    {
704
                        $emailTemplateMapper = EmailTemplateMapper::getInstance($this->adapter);
3639 efrain 705
                        $emailTemplate = $emailTemplateMapper->fetchOne(EmailTemplate::CODE_RECEIVE_CONNECTION_REQUEST);
1 www 706
 
707
                        if($emailTemplate) {
708
                            $arrayCont = [
709
                                'firstname'             => $currentUser->first_name,
710
                                'lastname'              => $currentUser->last_name,
711
                                'other_user_firstname'  => $user->first_name,
712
                                'other_user_lastname'   => $user->last_name,
713
                                'company_name'          => '',
714
                                'group_name'            => '',
715
                                'content'               => '',
716
                                'code'                  => '',
717
                                'link'                  => $this->url()->fromRoute('connection/invitations-received', [], ['force_canonical' => true])
718
                            ];
719
 
720
                            $email = new QueueEmail($this->adapter);
721
                            $email->processEmailTemplate($emailTemplate, $arrayCont, $user->email, trim($user->first_name . ' ' . $user->last_name));
722
                        }
723
                    }
724
                }
725
 
726
                return new JsonModel($response);
727
 
728
            } else {
729
                return new JsonModel([
730
                    'success' => false,
731
                    'data' => 'ERROR_METHOD_NOT_ALLOWED'
732
                ]);
733
            }
734
 
735
 
736
 
737
        }
738
 
739
        return new JsonModel([
740
            'success' => false,
741
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
742
        ]);
743
    }
744
 
745
 
746
    public function deleteAction()
747
    {
748
        $request = $this->getRequest();
749
        if($request->isPost()) {
750
            $currentUserPlugin = $this->plugin('currentUserPlugin');
751
            $currentUser = $currentUserPlugin->getUser();
752
 
753
            $id = $this->params()->fromRoute('id');
754
            $userMapper = UserMapper::getInstance($this->adapter);
755
            $user = $userMapper->fetchOneByUuid($id);
756
 
757
            if(!$user) {
758
                return new JsonModel([
759
                    'success' => true,
760
                    'data' => 'ERROR_USER_NOT_FOUND'
761
                ]);
762
            }
763
 
764
            if($user->id == $currentUser->id || in_array($user->status, [User::STATUS_DELETED, User::STATUS_INACTIVE]) || $user->email_verified == User::EMAIL_VERIFIED_NO || $user->blocked == User::BLOCKED_YES) {
765
 
766
                return new JsonModel([
767
                    'success' => true,
768
                    'data' => 'ERROR_USER_UNAVAILABLE'
769
                ]);
770
            }
771
 
772
 
773
 
774
            $connectionMapper = ConnectionMapper::getInstance($this->adapter);
775
            $connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $user->id);
776
            if($connection) {
777
                if($connection->status == Connection::STATUS_SENT) {
778
                    if($connectionMapper->delete($connection)) {
779
                        return new JsonModel([
780
                            'success' => true,
781
                            'data' => 'LABEL_CONNECTION_DELETED'
782
                        ]);
783
                    } else {
784
                        return new JsonModel([
785
                            'success' => true,
786
                            'data' => $connectionMapper->getError()
787
                        ]);
788
                    }
789
                } else {
790
                    $connection->status = Connection::STATUS_CANCELLED;
791
                    if($connectionMapper->update($connection)) {
792
                        return new JsonModel([
793
                            'success' => true,
794
                            'data' => 'LABEL_CONNECTION_CANCELLED'
795
                        ]);
796
                    } else {
797
                        return new JsonModel([
798
                            'success' => true,
799
                            'data' => $connectionMapper->getError()
800
                        ]);
801
                    }
802
 
803
 
804
                    return new JsonModel([
805
                        'success' => true,
806
                        'data' => 'LABEL_CONNECTION_NOT_PENDING'
807
                    ]);
808
                }
809
            } else {
810
                return new JsonModel([
811
                    'success' => true,
812
                    'data' => 'LABEL_CONNECTION_NOT_FOUND'
813
                ]);
814
 
815
            }
816
        } else {
817
 
818
            return new JsonModel([
819
                'success' => false,
820
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
821
            ]);
822
        }
823
    }
824
 
825
    public function blockAction()
826
    {
827
        $request = $this->getRequest();
828
        if($request->isPost()) {
829
            $currentUserPlugin = $this->plugin('currentUserPlugin');
830
            $currentUser = $currentUserPlugin->getUser();
831
 
832
            $id = $this->params()->fromRoute('id');
833
            $userMapper = UserMapper::getInstance($this->adapter);
834
            $user = $userMapper->fetchOneByUuid($id);
835
            if($user) {
836
                if($user->id == $currentUser->id || in_array($user->status, [User::STATUS_DELETED, User::STATUS_INACTIVE]) || $user->email_verified == User::EMAIL_VERIFIED_NO || $user->blocked == User::BLOCKED_YES) {
837
                    return new JsonModel([
838
                        'success' => true,
839
                        'data' => 'ERROR_USER_UNAVAILABLE'
840
                    ]);
841
                }
842
 
843
                $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
844
                $userBlocked = $userBlockedMapper->fetchOneByUserIdAndBlockedId($currentUser->id, $user->id);
845
                if($userBlocked) {
846
                    return new JsonModel([
847
                        'success' => false,
848
                        'data' =>  'ERROR_THIS_USER_WAS_ALREADY_BLOCKED'
849
                    ]);
850
                } else {
851
                    $userBlocked = new UserBlocked();
852
                    $userBlocked->user_id = $currentUser->id;
853
                    $userBlocked->blocked_id = $user->id;
854
 
855
                    if($userBlockedMapper->insert($userBlocked)) {
856
                        return new JsonModel([
857
                            'success' => true,
858
                            'data' => 'LABEL_USER_HAS_BEEN_BLOCKED'
859
                        ]);
860
                    } else {
861
                        return new JsonModel([
862
                            'success' => false,
863
                            'data' => $userBlockedMapper->getError()
864
                        ]);
865
                    }
866
                }
867
            } else {
868
                return new JsonModel([
869
                    'success' => false,
870
                    'data' =>  'ERROR_USER_NOT_FOUND'
871
                ]);
872
            }
873
        } else {
874
 
875
            return new JsonModel([
876
                'success' => false,
877
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
878
            ]);
879
        }
880
    }
881
 
882
    public function unblockAction()
883
    {
884
        $request = $this->getRequest();
885
        if($request->isPost()) {
886
            $currentUserPlugin = $this->plugin('currentUserPlugin');
887
            $currentUser = $currentUserPlugin->getUser();
888
 
889
            $id = $this->params()->fromRoute('id');
890
            $userMapper = UserMapper::getInstance($this->adapter);
891
            $user = $userMapper->fetchOneByUuid($id);
892
 
893
            if($user) {
894
                if($user->id == $currentUser->id || in_array($user->status, [User::STATUS_DELETED, User::STATUS_INACTIVE]) || $user->email_verified == User::EMAIL_VERIFIED_NO || $user->blocked == User::BLOCKED_YES) {
895
                    return new JsonModel([
896
                        'success' => true,
897
                       'data' => 'ERROR_USER_UNAVAILABLE'
898
                    ]);
899
                }
900
 
901
                $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
902
                $userBlocked = $userBlockedMapper->fetchOneByUserIdAndBlockedId($currentUser->id, $user->id);
903
                if($userBlocked) {
904
                   if($userBlockedMapper->deleteByUserIdAndBlockedId($currentUser->id, $user->id)) {
905
                       return new JsonModel([
906
                           'success' => true,
907
                           'data' => 'LABEL_USER_HAS_BEEN_UNBLOCKED'
908
                        ]);
909
                    } else {
910
                        return new JsonModel([
911
                            'success' => false,
912
                            'data' => $userBlockedMapper->getError()
913
                        ]);
914
                    }
915
                } else {
916
                    return new JsonModel([
917
                        'success' => false,
918
                        'data' =>  'ERROR_USER_IS_NOT_BLOCKED'
919
                    ]);
920
                }
921
            } else {
922
                return new JsonModel([
923
                    'success' => false,
924
                    'data' =>  'ERROR_USER_NOT_FOUND'
925
                ]);
926
            }
927
 
928
 
929
        } else {
930
 
931
            return new JsonModel([
932
                'success' => false,
933
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
934
            ]);
935
        }
936
    }
937
 
938
 
939
    public function peopleBlockedAction()
940
    {
941
        $currentUserPlugin = $this->plugin('currentUserPlugin');
942
        $currentUser = $currentUserPlugin->getUser();
943
 
944
        $request = $this->getRequest();
945
        if($request->isGet()) {
946
 
947
 
948
            $headers  = $request->getHeaders();
949
            $isJson = false;
950
            if($headers->has('Accept')) {
951
                $accept = $headers->get('Accept');
952
 
953
                $prioritized = $accept->getPrioritized();
954
 
955
                foreach($prioritized as $key => $value) {
956
                    $raw = trim($value->getRaw());
957
 
958
                    if(!$isJson) {
959
                        $isJson = strpos($raw, 'json');
960
                    }
961
 
962
                }
963
            }
964
 
965
            if($isJson) {
966
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
967
 
968
                $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
969
                $user_ids = $userBlockedMapper->fetchAllBlockedReturnIds($currentUser->id);
970
 
971
 
972
                $queryMapper = QueryMapper::getInstance($this->adapter);
973
 
974
                $select = $queryMapper->getSql()->select(UserMapper::_TABLE);
975
                $select->where->in('id', $user_ids);
976
                $select->where->equalTo('status', User::STATUS_ACTIVE);
977
 
978
                if($search) {
979
                    $select->where->NEST->like('first_name', '%' . $search . '%')->or->like('last_name', '%' . $search . '%')->UNNEST;
980
                }
981
                $select->order('first_name ASC, last_name ASC');
982
 
983
                //echo $select->getSqlString($this->adapter->platform); exit;
984
 
985
 
986
                $records = $queryMapper->fetchAll($select);
987
                $items = [];
988
                foreach($records as $record)
989
                {
990
 
991
                    $userBlocked = $userBlockedMapper->fetchOneByUserIdAndBlockedId($record['id'], $currentUser->id);
992
                    $link_view = $userBlocked ? '' : $this->url()->fromRoute('profile/view', ['id' => $record['uuid']  ]);
993
 
994
                    $item = [
995
                        'name' => trim($record['first_name'] . ' ' . $record['last_name']),
996
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $record['uuid'], 'filename' => $record['image'] ]),
997
                        'link_view' => $link_view,
998
                        'link_unblock' => $this->url()->fromRoute('connection/unblock', ['id' => $record['uuid']  ]),
999
                    ];
1000
 
1001
                    array_push($items, $item);
1002
                }
1003
 
1004
 
1005
 
1006
                $response = [
1007
                    'success' => true,
1008
                    'data' => $items
1009
                ];
1010
 
1011
                return new JsonModel($response);
1012
            } else {
1013
                $this->layout()->setTemplate('layout/layout.phtml');
1014
                $viewModel = new ViewModel();
1015
                $viewModel->setTemplate('leaders-linked/connection/people-blocked.phtml');
1016
                return $viewModel ;
1017
            }
1018
 
1019
        } else {
1020
            return new JsonModel([
1021
                'success' => false,
1022
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1023
            ]);
1024
        }
1025
    }
1026
 
1027
 
1028
    public function peopleYouMayKnowAction()
1029
    {
1030
 
1031
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1032
        $currentUser = $currentUserPlugin->getUser();
1033
 
1034
        $request = $this->getRequest();
1035
        if($request->isGet()) {
1036
 
1037
 
1038
            $headers  = $request->getHeaders();
1039
            $isJson = false;
1040
            if($headers->has('Accept')) {
1041
                $accept = $headers->get('Accept');
1042
 
1043
                $prioritized = $accept->getPrioritized();
1044
 
1045
                foreach($prioritized as $key => $value) {
1046
                    $raw = trim($value->getRaw());
1047
 
1048
                    if(!$isJson) {
1049
                        $isJson = strpos($raw, 'json');
1050
                    }
1051
 
1052
                }
1053
            }
1054
 
1055
            if($isJson) {
1056
                $page = (int) $this->params()->fromQuery('page');
1057
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
1058
 
1059
 
1060
                $queryMapper = QueryMapper::getInstance($this->adapter);
1061
                /*
1062
                $select = $queryMapper->getSql()->select(UserExperienceMapper::_TABLE);
1063
                $select->columns(['industry_id' => new Expression('DISTINCT(industry_id)')]);
1064
                $select->where->equalTo('user_id', $currentUser->id);
1065
 
1066
 
1067
                $industry_ids = [];
1068
                $records = $queryMapper->fetchAll($select);
1069
                foreach($records as $record)
1070
                {
1071
                    array_push($industry_ids, $record['industry_id']);
1072
                }*/
1073
 
1074
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
1075
                $first_degree_connections_ids = $connectionMapper->fetchAllConnectionsByUserReturnIds($currentUser->id);
1076
                $first_degree_connections_ids = $first_degree_connections_ids ? $first_degree_connections_ids : [0];
1077
 
1078
 
1079
 
1080
                $second_degree_connections_ids = $connectionMapper->fetchAllSecondDegreeConnectionsForUserIdReturnIds($currentUser->id);
1081
                $second_degree_connections_ids = $second_degree_connections_ids ? $second_degree_connections_ids : [0];
1082
 
1083
 
1084
                /*Usuarios de la empresas donde trabajo o soy dueño */
1085
                $company_user_ids = [];
1086
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
1087
 
1088
                $records = $companyUserMapper->fetchAllByUserId($currentUser->id);
1089
                foreach($records as $record)
1090
                {
1091
 
1092
                    if($record->status != CompanyUser::STATUS_ACCEPTED) {
1093
                        continue;
1094
                    }
1095
 
1096
                    $otherUsers = $companyUserMapper->fetchAllByCompanyId($record->company_id);
1097
                    foreach($otherUsers as $otherUser)
1098
                    {
1099
                        if($currentUser->id != $otherUser->user_id && $otherUser->creator == CompanyUser::CREATOR_NO && $otherUser->status == CompanyUser::STATUS_ACCEPTED) {
1100
 
1101
                            if(!in_array($otherUser->user_id, $company_user_ids)) {
1102
                                array_push($company_user_ids, $otherUser->user_id);
1103
                            }
1104
                        }
1105
                    }
1106
                }
1107
                $company_user_ids =  $company_user_ids ? $company_user_ids : [0];
1108
 
1109
                /* Usuario de los grupos donde soy dueño o participo */
1110
 
1111
                $groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
1112
 
1113
                $group_member_ids = [];
1114
 
1115
                $records = $groupMemberMapper->fetchAllByUserId($currentUser->id);
1116
                foreach($records as $record)
1117
                {
1118
                    if($record->status != GroupMember::STATUS_ACCEPTED) {
1119
                        continue;
1120
                    }
1121
 
1122
                    $otherUsers = $groupMemberMapper->fetchAllByGroupId($record->group_id);
1123
                    foreach($otherUsers as $otherUser)
1124
                    {
1125
                        if($currentUser->id != $otherUser->user_id && $otherUser->status == GroupMember::STATUS_ACCEPTED) {
1126
 
1127
                            if(!in_array($otherUser->user_id, $group_member_ids)) {
1128
                                array_push($group_member_ids, $otherUser->user_id);
1129
                            }
1130
                        }
1131
                    }
1132
 
1133
 
1134
                }
1135
 
1136
                $group_member_ids = $group_member_ids ? $group_member_ids : [0];
1137
 
1138
                /* Usuarios con que comparto capsulas */
1139
                $capsule_user_ids = [];
1140
                $capsuleUserMapper = CompanyMicrolearningCapsuleUserMapper::getInstance($this->adapter);
1141
 
1142
                $company_ids = [];
1143
                $records = $capsuleUserMapper->fetchAllActiveByUserId($currentUser->id);
1144
                foreach($records as $record)
1145
                {
1146
                    if(!in_array($record->company_id,$company_ids)) {
1147
                        array_push($company_ids, $record->company_id);
1148
                    }
1149
                }
1150
 
1151
                foreach($company_ids as $company_id)
1152
                {
1153
                    $otherUsers = $capsuleUserMapper->fetchAllUserIdsForCapsulesActiveByCompanyId($company_id);
1154
                    foreach($otherUsers as $user_id)
1155
                    {
1156
                        if($currentUser->id != $user_id ) {
1157
 
1158
                            if(!in_array($user_id, $capsule_user_ids)) {
1159
                                array_push($capsule_user_ids, $user_id);
1160
                            }
1161
                        }
1162
                    }
1163
                }
1164
 
1165
                $capsule_user_ids = $capsule_user_ids ? $capsule_user_ids : [0];
1166
 
1167
 
1168
                $other_users = array_unique(array_merge(
1169
                    $second_degree_connections_ids,
1170
                    $company_user_ids,
1171
                    $group_member_ids,
1172
                    $capsule_user_ids
1173
                ));
1174
 
1175
                $queryMapper = QueryMapper::getInstance($this->adapter);
1176
                $select = $queryMapper->getSql()->select();
1177
                $select->columns(['id', 'uuid',  'first_name','last_name', 'image']);
1178
                $select->from(['u' => UserMapper::_TABLE]);
1179
                $select->where->in('u.id', $other_users);
1180
                $select->where->notIn('u.id', $first_degree_connections_ids);
1181
                $select->where->notEqualTo('u.id', $currentUser->id);
1182
                $select->where->equalTo('u.status', User::STATUS_ACTIVE);
1183
                $select->where->in('u.usertype_id', [UserType::ADMIN, UserType::USER]);
1184
 
1185
 
1186
 
1187
                if($search) {
1188
                    $select->where->NEST->like('first_name', '%' . $search . '%')->or->like('last_name', '%' . $search . '%')->UNNEST;
1189
                }
1190
 
1191
                $select->order(['first_name','last_name']);
1192
 
1193
 
1194
                //$select->order(new Expression("rand()"));
1195
 
1196
 
1197
                //echo $select->getSqlString($this->adapter->platform); exit;
1198
 
1199
 
1200
 
1201
                $dbSelect = new DbSelect($select, $this->adapter);
1202
                $paginator = new Paginator($dbSelect);
1203
                $paginator->setCurrentPageNumber($page ? $page : 1);
1204
                $paginator->setItemCountPerPage(12);
1205
 
1206
 
1207
                $items = [];
1208
                $records = $paginator->getCurrentItems();
1209
 
1210
                foreach($records as $record)
1211
                {
1212
                    $connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $record['id']);
1213
 
1214
 
1215
 
1216
                    $relation = [];
1217
                    if(in_array($record['id'], $second_degree_connections_ids)) {
1218
                        array_push($relation, 'LABEL_RELATION_TYPE_SECOND_GRADE');
1219
                    }
1220
                    if(in_array($record['id'], $company_user_ids)) {
1221
                        array_push($relation, 'LABEL_RELATION_TYPE_COMPANY_USER');
1222
                    }
1223
                    if(in_array($record['id'], $group_member_ids)) {
1224
                        array_push($relation, 'LABEL_RELATION_TYPE_GROUP_MEMBER');
1225
                    }
1226
                    if(in_array($record['id'], $capsule_user_ids)) {
1227
                        array_push($relation, 'LABEL_RELATION_TYPE_CAPSULE_USER');
1228
                    }
1229
 
1230
                    $item = [
1231
                        'name' => trim($record['first_name'] . ' ' . $record['last_name']),
1232
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $record['uuid'], 'filename' => $record['image'] ]),
1233
                        'link_view' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']  ]),
1234
                        'link_inmail'   => $this->url()->fromRoute('inmail', ['id' => $record['uuid']  ]),
1235
                        'relation' => $relation,
1236
                        'link_cancel'   => '',
1237
                        'link_request'  => '',
1238
 
1239
                    ];
1240
 
1241
                    if($connection) {
1242
                        switch($connection->status)
1243
                        {
1244
                            case Connection::STATUS_SENT :
1245
                                $item['link_cancel'] = $this->url()->fromRoute('connection/delete',['id' => $record['uuid'] ]);
1246
                                break;
1247
 
1248
                            case Connection::STATUS_ACCEPTED :
1249
                                $item['link_cancel'] = $this->url()->fromRoute('connection/cancel',['id' => $record['uuid'] ]);
1250
                                break;
1251
 
1252
                            default :
1253
                                $item['link_request'] = $this->url()->fromRoute('connection/request',['id' => $record['uuid'] ]);
1254
                                break;
1255
 
1256
                        }
1257
 
1258
 
1259
                    } else {
1260
                        $item['link_request'] = $this->url()->fromRoute('connection/request',['id' => $record['uuid'] ]);
1261
                    }
1262
 
1263
                    array_push($items, $item);
1264
                }
1265
 
1266
                $response = [
1267
                    'success' => true,
1268
                    'data' => [
1269
                        'total' => [
1270
                            'count' => $paginator->getTotalItemCount(),
1271
                            'pages' => $paginator->getPages()->pageCount,
1272
                        ],
1273
                        'current' => [
1274
                            'items'    => $items,
1275
                            'page'     => $paginator->getCurrentPageNumber(),
1276
                        'count'    => $paginator->getCurrentItemCount(),
1277
                        ]
1278
                    ]
1279
                ];
1280
 
1281
 
1282
 
1283
 
1284
                return new JsonModel($response);
1285
            } else {
1286
                $this->layout()->setTemplate('layout/layout.phtml');
1287
                $viewModel = new ViewModel();
1288
                $viewModel->setTemplate('leaders-linked/connection/people-you-may-know.phtml');
1289
                return $viewModel ;
1290
            }
1291
 
1292
        } else {
1293
            return new JsonModel([
1294
                'success' => false,
1295
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
1296
            ]);
1297
        }
1298
    }
1299
}