Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 11725 Rev 14740
Línea 41... Línea 41...
41
use LeadersLinked\Mapper\TopicMapper;
41
use LeadersLinked\Mapper\TopicMapper;
42
use LeadersLinked\Model\HighPerformanceTeamsGroupsMembers;
42
use LeadersLinked\Model\HighPerformanceTeamsGroupsMembers;
43
use LeadersLinked\Model\HighPerformanceTeamsGroups;
43
use LeadersLinked\Model\HighPerformanceTeamsGroups;
44
use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMembersMapper;
44
use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMembersMapper;
45
use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMapper;
45
use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMapper;
-
 
46
use LeadersLinked\Mapper\UtilMapper;
Línea 46... Línea 47...
46
 
47
 
47
class FeedController extends AbstractActionController
48
class FeedController extends AbstractActionController
48
{
49
{
49
    /**
50
    /**
Línea 176... Línea 177...
176
            $dataPost = $request->getPost()->toArray();
177
            $dataPost = $request->getPost()->toArray();
177
            $form = new CommentForm();
178
            $form = new CommentForm();
178
            $form->setData($dataPost);
179
            $form->setData($dataPost);
Línea 179... Línea 180...
179
            
180
            
-
 
181
            if($form->isValid()) {
-
 
182
                $utilMapper = UtilMapper::getInstance($this->adapter);
Línea 180... Línea 183...
180
            if($form->isValid()) {
183
                $now = $utilMapper->getDatebaseNow();
181
                
184
                
Línea 182... Línea 185...
182
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
185
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
Línea 204... Línea 207...
204
                    $feed->total_comments = $total_comments;
207
                    $feed->total_comments = $total_comments;
205
                    $feedMapper->update($feed);
208
                    $feedMapper->update($feed);
Línea 206... Línea 209...
206
                    
209
                    
207
                    $response = [
210
                    $response = [
208
                        'success'   => true,
211
                        'success'   => true,
209
                        'data'   => $this->renderComment($comment->id),
212
                        'data'   => $this->renderComment($comment->id, $now),
210
                        'total_comments' => $total_comments
213
                        'total_comments' => $total_comments
Línea 211... Línea 214...
211
                    ];
214
                    ];
Línea 290... Línea 293...
290
            $form = new CommentAnswerForm();
293
            $form = new CommentAnswerForm();
291
            $form->setData($dataPost);
294
            $form->setData($dataPost);
Línea 292... Línea 295...
292
            
295
            
Línea -... Línea 296...
-
 
296
            if($form->isValid()) {
-
 
297
                
-
 
298
                $utilMapper = UtilMapper::getInstance($this->adapter);
293
            if($form->isValid()) {
299
                $now = $utilMapper->getDatebaseNow();
294
                
300
                
Línea 295... Línea 301...
295
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
301
                $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
296
                $owner = $companyUserMapper->fetchOwnerByCompanyId($currentCompany->id);
302
                $owner = $companyUserMapper->fetchOwnerByCompanyId($currentCompany->id);
Línea 319... Línea 325...
319
                    $feed->total_comments = $total_comments;
325
                    $feed->total_comments = $total_comments;
320
                    $feedMapper->update($feed);
326
                    $feedMapper->update($feed);
Línea 321... Línea 327...
321
                    
327
                    
322
                    $response = [
328
                    $response = [
323
                        'success'   => true,
329
                        'success'   => true,
324
                        'data'   => $this->renderComment($answer->id),
330
                        'data'   => $this->renderComment($answer->id, $now),
325
                        'total_comments' => $total_comments
331
                        'total_comments' => $total_comments
Línea 326... Línea 332...
326
                    ];
332
                    ];
Línea 508... Línea 514...
508
        return new JsonModel($response);
514
        return new JsonModel($response);
509
    }
515
    }
Línea 510... Línea 516...
510
    
516
    
511
    public function addAction()
517
    public function addAction()
-
 
518
    {
-
 
519
        $utilMapper = UtilMapper::getInstance($this->adapter);
-
 
520
        $now = $utilMapper->getDatebaseNow();
512
    {
521
        
513
        $currentUserPlugin = $this->plugin('currentUserPlugin');
522
        $currentUserPlugin = $this->plugin('currentUserPlugin');
514
        $currentUser = $currentUserPlugin->getUser();
523
        $currentUser = $currentUserPlugin->getUser();
515
        $currentCompany = $currentUserPlugin->getCompany();
524
        $currentCompany = $currentUserPlugin->getCompany();
516
        $myt_id =  $this->params()->fromRoute('myt_id');
525
        $myt_id =  $this->params()->fromRoute('myt_id');
Línea 745... Línea 754...
745
                    }
754
                    }
Línea 746... Línea 755...
746
                    
755
                    
747
                    
756
                    
748
                    $response = [
757
                    $response = [
749
                        'success'   => true,
758
                        'success'   => true,
Línea 750... Línea 759...
750
                        'data'   => $this->renderFeed($feed->id)
759
                        'data'   => $this->renderFeed($feed->id, $now)
751
                    ];
760
                    ];
752
                   
761
                   
Línea 779... Línea 788...
779
        
788
        
780
        return new JsonModel($response);
789
        return new JsonModel($response);
Línea 781... Línea 790...
781
    }
790
    }
-
 
791
    
Línea -... Línea 792...
-
 
792
    
-
 
793
    public function timelineAction()
-
 
794
    {
782
    
795
       
783
    
796
        $utilMapper = UtilMapper::getInstance($this->adapter);
784
    public function timelineAction() {
797
        $now = $utilMapper->getDatebaseNow();
Línea 922... Línea 935...
922
            $items = [];
935
            $items = [];
923
            $feeds = $paginator->getCurrentItems();
936
            $feeds = $paginator->getCurrentItems();
Línea 924... Línea 937...
924
            
937
            
925
            foreach($feeds as $feed)
938
            foreach($feeds as $feed)
926
            {
939
            {
927
                $items[] = $this->renderFeed($feed->id);
940
                $items[] = $this->renderFeed($feed->id, $now);
Línea 928... Línea 941...
928
            }
941
            }
929
            
942
            
930
            $response = [
943
            $response = [
Línea 952... Línea 965...
952
        
965
        
953
        
966
        
Línea 954... Línea 967...
954
        return new JsonModel($response);
967
        return new JsonModel($response);
-
 
968
    }
-
 
969
    
-
 
970
    public function oneFeedAction()
-
 
971
    {
-
 
972
        $utilMapper = UtilMapper::getInstance($this->adapter);
955
    }
973
        $now = $utilMapper->getDatebaseNow();
956
    
974
        
957
    public function oneFeedAction(){
975
        
Línea 958... Línea 976...
958
        $currentUserPlugin = $this->plugin('currentUserPlugin');
976
        $currentUserPlugin = $this->plugin('currentUserPlugin');
Línea 987... Línea 1005...
987
                return new JsonModel($data);
1005
                return new JsonModel($data);
988
            }      
1006
            }      
Línea 989... Línea 1007...
989
            
1007
            
Línea 990... Línea 1008...
990
            if ($feed->type=='mytq'){
1008
            if ($feed->type=='mytq'){
Línea 991... Línea 1009...
991
                
1009
                
992
                $items = $this->renderFeed($feed->id,$myt_id);
1010
                $items = $this->renderFeed($feed->id, $now, $myt_id);
993
 
1011
 
994
                $response = [
1012
                $response = [
Línea 1000... Línea 1018...
1000
                    ]
1018
                    ]
1001
                ];
1019
                ];
Línea 1002... Línea 1020...
1002
 
1020
 
Línea 1003... Línea 1021...
1003
            } else if ($feed->type=='myta'){
1021
            } else if ($feed->type=='myta'){
Línea 1004... Línea 1022...
1004
                
1022
                
1005
                $items = $this->renderFeed($feed->id,$myt_id);
1023
                $items = $this->renderFeed($feed->id, $now, $myt_id);
1006
 
1024
 
1007
                $response = [
1025
                $response = [
Línea 1082... Línea 1100...
1082
                        'success' => false,
1100
                        'success' => false,
1083
                        'data' => 'ERROR_METHOD_NOT_ALLOWED'
1101
                        'data' => 'ERROR_METHOD_NOT_ALLOWED'
1084
                    ]);
1102
                    ]);
1085
                }  
1103
                }  
Línea 1086... Línea 1104...
1086
 
1104
 
Línea 1087... Línea 1105...
1087
                $items = $this->renderFeed($feed->id,$group_uuid);   
1105
                $items = $this->renderFeed($feed->id, $now, $group_uuid);   
1088
            
1106
            
1089
                $response = [
1107
                $response = [
1090
                    'success' => true,
1108
                    'success' => true,
Línea 1131... Línea 1149...
1131
     *
1149
     *
1132
     * @param int $feed_id
1150
     * @param int $feed_id
1133
     * @param Company $company
1151
     * @param Company $company
1134
     * @return array
1152
     * @return array
1135
     */
1153
     */
1136
    private function renderFeed($feed_id,$group_uuid="",$myt_id="")
1154
    private function renderFeed($feed_id, $now , $group_uuid = '', $myt_id = '' )
1137
    {
1155
    {
Línea 1138... Línea 1156...
1138
        
1156
        
1139
        $sandbox = $this->config['leaderslinked.runmode.sandbox'];
1157
        $sandbox = $this->config['leaderslinked.runmode.sandbox'];
1140
        if($sandbox) {
1158
        if($sandbox) {
Línea 1260... Línea 1278...
1260
        $item['owner_description'] = strip_tags($feed->description, 'p');        
1278
        $item['owner_description'] = strip_tags($feed->description, 'p');        
1261
        $item['owner_shared'] = $feed->total_shared;
1279
        $item['owner_shared'] = $feed->total_shared;
1262
        $item['owner_comments'] = $feed->total_comments;
1280
        $item['owner_comments'] = $feed->total_comments;
Línea 1263... Línea -...
1263
        
-
 
1264
        
1281
        
Línea 1265... Línea 1282...
1265
        $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $feed->added_on);
1282
        
1266
        $item['owner_time_elapse'] = Functions::timeElapsedString( $dt->getTimestamp());
1283
        $item['owner_time_elapse'] = Functions::timeAgo( $feed->added_on, $now);
Línea 1267... Línea 1284...
1267
        
1284
        
Línea 1297... Línea 1314...
1297
        $comments = [];
1314
        $comments = [];
1298
        $comment_count=0;
1315
        $comment_count=0;
1299
        foreach($records as $record)
1316
        foreach($records as $record)
1300
        {
1317
        {
1301
            $user = $userMapper->fetchOne($record->user_id);
1318
            $user = $userMapper->fetchOne($record->user_id);
1302
            $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $record->added_on);
-
 
Línea 1303... Línea 1319...
1303
 
1319
 
1304
            $comment = [];
1320
            $comment = [];
1305
            $comment['unique'] = uniqid();
1321
            $comment['unique'] = uniqid();
1306
            $comment_count++;
1322
            $comment_count++;
Línea 1325... Línea 1341...
1325
            }else{
1341
            }else{
1326
                $comment['link_delete'] = $this->url()->fromRoute('feeds/comments/delete',['id' => $feed->uuid, 'comment' => $record->uuid ]);
1342
                $comment['link_delete'] = $this->url()->fromRoute('feeds/comments/delete',['id' => $feed->uuid, 'comment' => $record->uuid ]);
1327
            }
1343
            }
Línea 1328... Línea 1344...
1328
            
1344
            
1329
            $comment['link_answer_add'] = $this->url()->fromRoute('feeds/comments/answer',['id' => $feed->uuid, 'comment' => $record->uuid ]);
1345
            $comment['link_answer_add'] = $this->url()->fromRoute('feeds/comments/answer',['id' => $feed->uuid, 'comment' => $record->uuid ]);
1330
            $comment['time_elapsed'] = Functions::timeElapsedString($dt->getTimestamp());
1346
            $comment['time_elapsed'] = Functions::timeAgo(  $record->added_on, $now);
Línea 1331... Línea 1347...
1331
            $comment['comment'] = $record->comment;
1347
            $comment['comment'] = $record->comment;
1332
            
1348
            
1333
            $records2 = $commentMapper->fetchAllPublishedByCommentId($record->id);
1349
            $records2 = $commentMapper->fetchAllPublishedByCommentId($record->id);
1334
            $answers = [];
1350
            $answers = [];
1335
            $contador=0;
1351
            $contador=0;
1336
            foreach($records2 as $record2)
1352
            foreach($records2 as $record2)
1337
            {
-
 
-
 
1353
            {
Línea 1338... Línea 1354...
1338
                $user = $userMapper->fetchOne($record2->user_id);
1354
                $user = $userMapper->fetchOne($record2->user_id);
1339
                $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $record2->added_on);
1355
 
Línea 1361... Línea 1377...
1361
                    }
1377
                    }
1362
                }else{
1378
                }else{
1363
                    $answer['link_delete'] = $this->url()->fromRoute('feeds/comments/delete',['id' => $feed->uuid, 'comment' => $record2->uuid ]);
1379
                    $answer['link_delete'] = $this->url()->fromRoute('feeds/comments/delete',['id' => $feed->uuid, 'comment' => $record2->uuid ]);
1364
                }
1380
                }
Línea 1365... Línea 1381...
1365
                
1381
                
1366
                $answer['time_elapsed'] = Functions::timeElapsedString($dt->getTimestamp());
1382
                $answer['time_elapsed'] = Functions::timeAgo($record2->added_on, $now);
Línea 1367... Línea 1383...
1367
                $answer['comment'] = $record2->comment;
1383
                $answer['comment'] = $record2->comment;
Línea 1368... Línea 1384...
1368
                
1384
                
Línea 1386... Línea 1402...
1386
    /**
1402
    /**
1387
     *
1403
     *
1388
     * @param int $comment_id
1404
     * @param int $comment_id
1389
     * @return array
1405
     * @return array
1390
     */
1406
     */
1391
    private function renderComment($comment_id)
1407
    private function renderComment($comment_id, $now)
1392
    {
1408
    {
1393
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1409
        $currentUserPlugin = $this->plugin('currentUserPlugin');
1394
        $currentUser = $currentUserPlugin->getUser();
1410
        $currentUser = $currentUserPlugin->getUser();
1395
        $currentCompany = $currentUserPlugin->getCompany();
1411
        $currentCompany = $currentUserPlugin->getCompany();
Línea 1421... Línea 1437...
1421
        $feed = $feedMapper->fetchOne($record->feed_id);
1437
        $feed = $feedMapper->fetchOne($record->feed_id);
Línea 1422... Línea 1438...
1422
        
1438
        
1423
        if($record) {
1439
        if($record) {
Línea 1424... Línea -...
1424
            $userMapper = UserMapper::getInstance($this->adapter);
-
 
1425
            
1440
            $userMapper = UserMapper::getInstance($this->adapter);
1426
            $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $record->added_on);
-
 
1427
            
1441
            
1428
            
1442
 
Línea 1429... Línea 1443...
1429
            $item = [];
1443
            $item = [];
Línea 1443... Línea 1457...
1443
            
1457
            
1444
            
1458
            
1445
          
1459
          
1446
            $item['link_answer_add'] = $this->url()->fromRoute('feeds/comments/answer',['id' => $feed->uuid, 'comment' => $record->uuid ]);
1460
            $item['link_answer_add'] = $this->url()->fromRoute('feeds/comments/answer',['id' => $feed->uuid, 'comment' => $record->uuid ]);
Línea 1447... Línea 1461...
1447
            $item['link_delete'] = $this->url()->fromRoute('feeds/comments/delete',['id' => $feed->uuid, 'comment' => $record->uuid ]);
1461
            $item['link_delete'] = $this->url()->fromRoute('feeds/comments/delete',['id' => $feed->uuid, 'comment' => $record->uuid ]);
1448
            $item['time_elapsed'] = Functions::timeElapsedString($dt->getTimestamp());
1462
            $item['time_elapsed'] = Functions::timeAgo($record->added_on, $now);
1449
            $item['comment'] = $record->comment;
1463
            $item['comment'] = $record->comment;