Proyectos de Subversion LeadersLinked - Backend

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
7489 nelberth 1
<?php
2
declare(strict_types=1);
3
 
4
namespace LeadersLinked\Controller;
5
 
6
use Laminas\Authentication\AuthenticationService;
7
use Laminas\Authentication\Result as AuthResult;
8
use Laminas\Db\Adapter\AdapterInterface;
9
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
10
use Laminas\Mvc\Controller\AbstractActionController;
11
use Laminas\Mvc\I18n\Translator;
12
use Laminas\Log\LoggerInterface;
13
use Laminas\View\Model\ViewModel;
14
use Laminas\View\Model\JsonModel;
9524 nelberth 15
use LeadersLinked\Model\Topic;
10383 nelberth 16
use LeadersLinked\Model\HighPerformanceTeamsGroups;
7489 nelberth 17
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
10369 nelberth 18
use LeadersLinked\Form\HighPerformanceTeamsGroupsViewTopicForm;
7489 nelberth 19
use LeadersLinked\Library\Functions;
20
use LeadersLinked\Mapper\UserMapper;
9513 nelberth 21
use LeadersLinked\Mapper\TopicMapper;
7515 nelberth 22
use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMapper;
7759 nelberth 23
use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMembersMapper;
24
use LeadersLinked\Model\HighPerformanceTeamsGroupsMembers;
7489 nelberth 25
use LeadersLinked\Mapper\CompanyMapper;
26
use LeadersLinked\Mapper\CompanyUserMapper;
27
 
28
 
29
 
30
class HighPerformanceTeamsGroupsViewTopicController extends AbstractActionController
31
{
32
    /**
33
     *
34
     * @var AdapterInterface
35
     */
36
    private $adapter;
37
 
38
 
39
    /**
40
     *
41
     * @var AbstractAdapter
42
     */
43
    private $cache;
44
 
45
    /**
46
     *
47
     * @var  LoggerInterface
48
     */
49
    private $logger;
50
 
51
    /**
52
     *
53
     * @var array
54
     */
55
    private $config;
56
 
57
 
58
 
59
    /**
60
     *
61
     * @param AdapterInterface $adapter
62
     * @param AbstractAdapter $cache
63
     * @param LoggerInterface $logger
64
     * @param array $config
65
     */
66
    public function __construct($adapter, $cache , $logger, $config)
67
    {
68
        $this->adapter      = $adapter;
69
        $this->cache        = $cache;
70
        $this->logger       = $logger;
71
        $this->config       = $config;
72
 
73
 
74
    }
75
 
76
 
77
 
78
 
79
    public function indexAction()
80
    {
81
 
7713 nelberth 82
 
7489 nelberth 83
        $currentUserPlugin = $this->plugin('currentUserPlugin');
84
        $currentUser = $currentUserPlugin->getUser();
85
        $currentCompany = $currentUserPlugin->getCompany();
86
 
7622 nelberth 87
 
7489 nelberth 88
        $request = $this->getRequest();
89
        if($request->isGet()) {
90
 
91
 
92
            $headers  = $request->getHeaders();
93
 
94
            $isJson = false;
95
            if($headers->has('Accept')) {
96
                $accept = $headers->get('Accept');
97
 
98
                $prioritized = $accept->getPrioritized();
99
 
100
                foreach($prioritized as $key => $value) {
101
                    $raw = trim($value->getRaw());
102
 
103
                    if(!$isJson) {
104
                        $isJson = strpos($raw, 'json');
105
                    }
106
 
107
                }
108
            }
7855 nelberth 109
 
7489 nelberth 110
            if($isJson) {
7621 nelberth 111
 
11086 nelberth 112
                $group_uuid = $this->params()->fromRoute('group_id');
7847 nelberth 113
                if(!$group_uuid) {
7547 nelberth 114
                    $data = [
115
                        'success'   => false,
116
                        'data'   => 'ERROR_INVALID_PARAMETER'
117
                    ];
118
 
119
                    return new JsonModel($data);
120
                }
7856 nelberth 121
 
7547 nelberth 122
                $highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
7847 nelberth 123
                $highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($group_uuid);
10382 nelberth 124
 
7547 nelberth 125
                if (!$highPerformanceTeamsGroups) {
126
                    $data = [
127
                        'success' => false,
128
                        'data' => 'ERROR_RECORD_NOT_FOUND'
129
                    ];
130
 
131
                    return new JsonModel($data);
132
                }
10374 nelberth 133
                if($highPerformanceTeamsGroups->status != HighPerformanceTeamsGroups::STATUS_ACTIVE) {
134
 
135
                    return new JsonModel([
136
                        'success' => false,
137
                        'data' => 'ERROR_UNAUTHORIZED'
138
                    ]);
139
 
140
                }
10355 nelberth 141
                $highPerformanceTeamsGroupsMembersMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
142
                $highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMembersMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
7760 nelberth 143
                if(!$highPerformanceTeamsGroupsMember) {
144
                    return new JsonModel([
145
                        'success' => false,
10366 nelberth 146
                        'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS'
7760 nelberth 147
                    ]);
148
                }
7763 nelberth 149
                if(!($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN) ){
7760 nelberth 150
                    return new JsonModel([
151
                        'success' => false,
152
                        'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS'
153
                    ]);
154
                }
10355 nelberth 155
 
10366 nelberth 156
                $acl = $this->getEvent()->getViewModel()->getVariable('acl');
157
                $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'high-performance-teams/groups/view/topic/edit');
158
                $allowDelete = $acl->isAllowed($currentUser->usertype_id,'high-performance-teams/groups/view/topic/delete');
159
                $allowView = $acl->isAllowed($currentUser->usertype_id,'high-performance-teams/groups/view');
10369 nelberth 160
 
10355 nelberth 161
                $member = $highPerformanceTeamsGroupsMembersMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id,$currentUser->id);
10372 nelberth 162
 
10355 nelberth 163
                if($member->type==HighPerformanceTeamsGroupsMembers::TYPE_MODERATOR||$member->type==HighPerformanceTeamsGroupsMembers::TYPE_USER){
164
                    $allowDelete=false;
165
                    $allowEdit=false;
166
                }
7551 nelberth 167
 
10366 nelberth 168
 
7760 nelberth 169
 
9519 nelberth 170
 
171
 
172
                $topicMapper = TopicMapper::getInstance($this->adapter);
9522 nelberth 173
 
9523 nelberth 174
                $paginator = $topicMapper->fetchAllHighPerfromanceTeamsGroup($highPerformanceTeamsGroups->id);
9522 nelberth 175
 
7760 nelberth 176
                $items = [];
7554 nelberth 177
 
7760 nelberth 178
 
179
 
180
                foreach($paginator as $record)
181
                {
182
 
183
 
184
                    $item = [
185
                        'title' => $record->title,
186
                        'status'=> $record->status,
187
                        'actions' => [
11086 nelberth 188
                            'link_edit' => $allowEdit ? $this->url()->fromRoute('high-performance-teams/groups/view/topic/edit', ['group_id' => $highPerformanceTeamsGroups->uuid, 'topic_id' => $record->uuid]) : '',
189
                            'link_delete' => $allowDelete ? $this->url()->fromRoute('high-performance-teams/groups/view/topic/delete', ['group_id' => $highPerformanceTeamsGroups->uuid,'topic_id' => $record->uuid]) : '',
190
                            'link_view' => $allowView ? $this->url()->fromRoute('high-performance-teams/groups/view/topic/view', ['group_id' => $highPerformanceTeamsGroups->uuid,'topic_id' => $record->uuid]) : '',
7760 nelberth 191
                        ]
192
 
193
                    ];
7489 nelberth 194
 
7760 nelberth 195
                    array_push($items, $item);
7489 nelberth 196
 
197
                }
7760 nelberth 198
 
199
                return new JsonModel([
200
                    'success' => true,
201
                    'data' => [
202
                        'items' => $items
203
                    ]
204
                ]);
7489 nelberth 205
 
7500 nelberth 206
            }
7489 nelberth 207
        } else {
208
            return new JsonModel([
209
                'success' => false,
210
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
211
            ]);
212
        }
213
    }
214
 
215
    public function addAction()
216
    {
217
 
11086 nelberth 218
        $group_uuid = $this->params()->fromRoute('group_id');
7857 nelberth 219
        if(!$group_uuid) {
220
            $data = [
221
                'success'   => false,
222
                'data'   => 'ERROR_INVALID_PARAMETER'
223
            ];
224
 
225
            return new JsonModel($data);
226
        }
7717 nelberth 227
 
7514 nelberth 228
        $currentUserPlugin = $this->plugin('currentUserPlugin');
229
        $currentUser = $currentUserPlugin->getUser();
230
        $currentCompany = $currentUserPlugin->getCompany();
7499 nelberth 231
 
7489 nelberth 232
        $request = $this->getRequest();
233
        if($request->isPost()) {
10369 nelberth 234
            $form = new  HighPerformanceTeamsGroupsViewTopicForm();
7489 nelberth 235
            $dataPost = $request->getPost()->toArray();
236
 
237
            $form->setData($dataPost);
238
 
239
            if($form->isValid()) {
240
                $dataPost = (array) $form->getData();
9656 nelberth 241
                $dataPost['status'] =  isset($dataPost['status']) ? $dataPost['status'] : Topic::STATUS_INACTIVE;
7514 nelberth 242
 
7489 nelberth 243
 
7514 nelberth 244
                $highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
7857 nelberth 245
                $highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($group_uuid);
7514 nelberth 246
 
7763 nelberth 247
                if (!$highPerformanceTeamsGroups) {
7514 nelberth 248
                    $data = [
249
                        'success' => false,
250
                        'data' => 'ERROR_RECORD_NOT_FOUND'
251
                    ];
252
 
253
                    return new JsonModel($data);
254
                }
10374 nelberth 255
                if($highPerformanceTeamsGroups->status != HighPerformanceTeamsGroups::STATUS_ACTIVE) {
256
 
257
                    return new JsonModel([
258
                        'success' => false,
259
                        'data' => 'ERROR_UNAUTHORIZED'
260
                    ]);
261
 
262
                }
9527 nelberth 263
 
10355 nelberth 264
                $highPerformanceTeamsGroupsMembersMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
265
                $highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMembersMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
7763 nelberth 266
                if(!$highPerformanceTeamsGroupsMember) {
7514 nelberth 267
                    return new JsonModel([
268
                        'success' => false,
7763 nelberth 269
                        'data' => 'ERROR_RECORD_NOT_FOUND'
7514 nelberth 270
                    ]);
7763 nelberth 271
                }
272
                if(!($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN) ){
273
                    return new JsonModel([
274
                        'success' => false,
275
                        'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS'
276
                    ]);
277
                }
7514 nelberth 278
 
9528 nelberth 279
                $hydrator = new ObjectPropertyHydrator();
280
                $topic = new Topic();
281
 
9530 nelberth 282
 
9524 nelberth 283
                $hydrator->hydrate($dataPost, $topic);
9677 nelberth 284
                $topic->type='hptg';
9532 nelberth 285
                $topic->high_performance_group_id=$highPerformanceTeamsGroups->id;
9516 nelberth 286
                $topicMapper = TopicMapper::getInstance($this->adapter);
9533 nelberth 287
 
9524 nelberth 288
                $result = $topicMapper->insert($topic);
7489 nelberth 289
 
290
                if($result) {
291
 
9524 nelberth 292
                    $this->logger->info('Se agrego el topic del grupo ' . $topic->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
7489 nelberth 293
 
294
                    $data = [
295
                        'success'   => true,
296
                        'data'   => 'LABEL_RECORD_ADDED'
297
                    ];
298
                } else {
299
                    $data = [
300
                        'success'   => false,
9516 nelberth 301
                        'data'      => $topicMapper->getError()
7489 nelberth 302
                    ];
303
 
304
                }
305
 
306
                return new JsonModel($data);
307
 
308
            } else {
309
                $messages = [];
310
                $form_messages = (array) $form->getMessages();
311
                foreach($form_messages  as $fieldname => $field_messages)
312
                {
313
 
314
                    $messages[$fieldname] = array_values($field_messages);
315
                }
316
 
317
                return new JsonModel([
318
                    'success'   => false,
319
                    'data'   => $messages
320
                ]);
321
            }
322
 
323
        } else {
324
            $data = [
325
                'success' => false,
7704 nelberth 326
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
7489 nelberth 327
            ];
328
 
329
            return new JsonModel($data);
330
        }
331
 
332
        return new JsonModel($data);
333
 
334
 
335
    }
336
 
337
 
338
 
339
     public function editAction(){
340
 
341
        $currentUserPlugin = $this->plugin('currentUserPlugin');
342
        $currentUser = $currentUserPlugin->getUser();
343
        $currentCompany = $currentUserPlugin->getCompany();
344
        $request = $this->getRequest();
11086 nelberth 345
        $group_uuid = $this->params()->fromRoute('group_id');
7743 nelberth 346
 
11086 nelberth 347
        $topic_uuid = $this->params()->fromRoute('topic_id');
7489 nelberth 348
 
349
 
7847 nelberth 350
        if(!$group_uuid) {
7489 nelberth 351
            $data = [
352
                'success'   => false,
353
                'data'   => 'ERROR_INVALID_PARAMETER'
354
            ];
355
 
356
            return new JsonModel($data);
357
        }
7743 nelberth 358
        if(!$topic_uuid) {
359
            $data = [
360
                'success'   => false,
361
                'data'   => 'ERROR_INVALID_PARAMETER'
362
            ];
363
 
364
            return new JsonModel($data);
365
        }
7750 nelberth 366
 
9536 nelberth 367
 
9516 nelberth 368
        $topicMapper = TopicMapper::getInstance($this->adapter);
369
        $topic = $topicMapper->fetchOneByUuid($topic_uuid);
7489 nelberth 370
 
7743 nelberth 371
        if (!$topic) {
7489 nelberth 372
            $data = [
373
                'success' => false,
374
                'data' => 'ERROR_RECORD_NOT_FOUND'
375
            ];
376
 
377
            return new JsonModel($data);
378
        }
379
 
10372 nelberth 380
        $highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
381
        $highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($group_uuid);
382
 
383
        if (!$highPerformanceTeamsGroups) {
384
            $data = [
385
                'success' => false,
386
                'data' => 'ERROR_RECORD_NOT_FOUND'
387
            ];
7489 nelberth 388
 
10372 nelberth 389
            return new JsonModel($data);
390
        }
10374 nelberth 391
        if($highPerformanceTeamsGroups->status != HighPerformanceTeamsGroups::STATUS_ACTIVE) {
10372 nelberth 392
 
10374 nelberth 393
            return new JsonModel([
394
                'success' => false,
395
                'data' => 'ERROR_UNAUTHORIZED'
396
            ]);
397
 
398
        }
399
 
10372 nelberth 400
        $highPerformanceTeamsGroupsMembersMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
401
        $highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMembersMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
402
        if(!$highPerformanceTeamsGroupsMember) {
403
            return new JsonModel([
404
                'success' => false,
405
                'data' => 'ERROR_RECORD_NOT_FOUND'
406
            ]);
407
        }
408
        if(!($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN) ){
409
            return new JsonModel([
410
                'success' => false,
411
                'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS'
412
            ]);
413
        }
414
 
415
        if($highPerformanceTeamsGroupsMember->type==HighPerformanceTeamsGroupsMembers::TYPE_MODERATOR||$highPerformanceTeamsGroupsMember->type==HighPerformanceTeamsGroupsMembers::TYPE_USER){
416
            return new JsonModel([
417
                'success' => false,
418
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
419
            ]);
420
        }
7489 nelberth 421
        if($request->isPost()) {
10369 nelberth 422
            $form = new  HighPerformanceTeamsGroupsViewTopicForm();
7489 nelberth 423
            $dataPost = $request->getPost()->toArray();
9656 nelberth 424
            $dataPost['status'] =  isset($dataPost['status']) ? $dataPost['status'] : Topic::STATUS_INACTIVE;
7756 nelberth 425
 
7752 nelberth 426
 
7755 nelberth 427
 
7756 nelberth 428
 
7489 nelberth 429
            $form->setData($dataPost);
430
 
431
            if($form->isValid()) {
7757 nelberth 432
                $dataPost = (array) $form->getData();
10372 nelberth 433
 
7756 nelberth 434
 
7489 nelberth 435
                $hydrator = new ObjectPropertyHydrator();
7748 nelberth 436
                $hydrator->hydrate($dataPost, $topic);
7860 nelberth 437
 
9516 nelberth 438
                $result = $topicMapper->update($topic);
7751 nelberth 439
 
7489 nelberth 440
                if($result) {
7744 nelberth 441
                    $this->logger->info('Se actualizo el grupo de alto rendimiento ' . $topic->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
7489 nelberth 442
 
443
                    $data = [
444
                        'success' => true,
445
                        'data' => 'LABEL_RECORD_UPDATED'
446
                    ];
447
                } else {
448
                    $data = [
449
                        'success'   => false,
9516 nelberth 450
                        'data'      => $topicMapper->getError()
7489 nelberth 451
                    ];
452
                }
453
 
454
                return new JsonModel($data);
455
 
456
            } else {
457
                $messages = [];
458
                $form_messages = (array) $form->getMessages();
459
                foreach($form_messages  as $fieldname => $field_messages)
460
                {
461
                    $messages[$fieldname] = array_values($field_messages);
462
                }
463
 
464
                return new JsonModel([
465
                    'success'   => false,
466
                    'data'   => $messages
467
                ]);
468
            }
469
        }else if ($request->isGet()) {
470
            $hydrator = new ObjectPropertyHydrator();
471
 
472
            $data = [
473
                'success' => true,
7743 nelberth 474
                'data' => $hydrator->extract($topic)
7489 nelberth 475
            ];
476
 
477
            return new JsonModel($data);
478
        } else {
479
            $data = [
480
                'success' => false,
481
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
482
            ];
483
 
484
            return new JsonModel($data);
485
        }
486
 
487
        return new JsonModel($data);
488
 
489
    }
490
 
491
 
492
 
493
 
494
    public function deleteAction(){
7737 nelberth 495
 
7489 nelberth 496
        $currentUserPlugin = $this->plugin('currentUserPlugin');
497
        $currentCompany = $currentUserPlugin->getCompany();
498
        $currentUser = $currentUserPlugin->getUser();
499
 
500
        $request = $this->getRequest();
11086 nelberth 501
        $group_uuid = $this->params()->fromRoute('group_id');
502
        $topic_uuid = $this->params()->fromRoute('topic_id');
7489 nelberth 503
 
504
 
7847 nelberth 505
        if (!$group_uuid) {
7489 nelberth 506
            $data = [
507
                'success' => false,
508
                'data' => 'ERROR_INVALID_PARAMETER'
509
            ];
510
 
511
            return new JsonModel($data);
512
        }
7763 nelberth 513
        $highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
7847 nelberth 514
                $highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($group_uuid);
7763 nelberth 515
 
516
                if (!$highPerformanceTeamsGroups) {
517
                    $data = [
518
                        'success' => false,
519
                        'data' => 'ERROR_RECORD_NOT_FOUND'
520
                    ];
521
 
522
                    return new JsonModel($data);
523
                }
10374 nelberth 524
                if($highPerformanceTeamsGroups->status != HighPerformanceTeamsGroups::STATUS_ACTIVE) {
7489 nelberth 525
 
10374 nelberth 526
                    return new JsonModel([
527
                        'success' => false,
528
                        'data' => 'ERROR_UNAUTHORIZED'
529
                    ]);
530
 
531
                }
532
 
10372 nelberth 533
                $highPerformanceTeamsGroupsMembersMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
534
                $highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMembersMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
535
                if(!$highPerformanceTeamsGroupsMember) {
536
                    return new JsonModel([
537
                        'success' => false,
538
                        'data' => 'ERROR_RECORD_NOT_FOUND'
539
                    ]);
540
                }
541
                if(!($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN) ){
542
                    return new JsonModel([
543
                        'success' => false,
544
                        'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS'
545
                    ]);
546
                }
547
 
548
                if($highPerformanceTeamsGroupsMember->type==HighPerformanceTeamsGroupsMembers::TYPE_MODERATOR||$highPerformanceTeamsGroupsMember->type==HighPerformanceTeamsGroupsMembers::TYPE_USER){
549
                    return new JsonModel([
550
                        'success' => false,
551
                        'data' => 'ERROR_METHOD_NOT_ALLOWED'
552
                    ]);
553
                }
7489 nelberth 554
 
555
 
9516 nelberth 556
        $topicMapper = TopicMapper::getInstance($this->adapter);
557
        $topic = $topicMapper->fetchOneByUuid($topic_uuid);
7489 nelberth 558
 
7737 nelberth 559
        if (!$topic) {
7489 nelberth 560
            $data = [
561
                'success' => false,
562
                'data' => 'ERROR_RECORD_NOT_FOUND'
563
            ];
564
 
565
            return new JsonModel($data);
566
        }
567
 
7763 nelberth 568
 
7489 nelberth 569
 
570
        if ($request->isPost()) {
571
 
572
 
9516 nelberth 573
            $result = $topicMapper->delete($topic->id);
7489 nelberth 574
            if ($result) {
7737 nelberth 575
                $this->logger->info('Se borro el grupo de alto rendimiento  ' . $topic->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
7489 nelberth 576
 
577
                $data = [
578
                    'success' => true,
579
                    'data' => 'LABEL_RECORD_DELETED'
580
                ];
581
            } else {
582
 
583
                $data = [
584
                    'success' => false,
9516 nelberth 585
                    'data' => $topicMapper->getError()
7489 nelberth 586
                ];
587
 
588
                return new JsonModel($data);
589
            }
590
        } else {
591
            $data = [
592
                'success' => false,
593
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
594
            ];
595
 
596
            return new JsonModel($data);
597
        }
598
 
599
        return new JsonModel($data);
600
    }
601
 
602
 
603
 
604
 
605
}