Proyectos de Subversion LeadersLinked - Services

Rev

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

Rev 282 Rev 283
Línea 67... Línea 67...
67
use LeadersLinked\Model\UserBlocked;
67
use LeadersLinked\Model\UserBlocked;
68
use LeadersLinked\Library\Storage;
68
use LeadersLinked\Library\Storage;
Línea 69... Línea 69...
69
 
69
 
70
class HelperController extends AbstractActionController
70
class HelperController extends AbstractActionController
71
{
-
 
72
    const _USE_S3 = false;
71
{
73
    
72
 
74
    /**
73
    /**
75
     *
74
     *
76
     * @var \Laminas\Db\Adapter\AdapterInterface
75
     * @var \Laminas\Db\Adapter\AdapterInterface
77
     */
76
     */
Línea 272... Línea 271...
272
            $select->where->in('u.usertype_id', [UserType::ADMIN, UserType::USER]);
271
            $select->where->in('u.usertype_id', [UserType::ADMIN, UserType::USER]);
273
            $select->order(['first_name', 'last_name']);
272
            $select->order(['first_name', 'last_name']);
Línea 274... Línea 273...
274
 
273
 
Línea 275... Línea -...
275
            //echo $select->getSqlString($this->adapter->platform); exit;
-
 
276
 
274
            //echo $select->getSqlString($this->adapter->platform); exit;
277
            if(self::_USE_S3) {
-
 
278
                $storage = Storage::getInstance($this->config);
-
 
279
            } else {
275
 
Línea 280... Línea 276...
280
                $storage = null;
276
            $storage = Storage::getInstance($this->config);
281
            }
277
 
Línea 282... Línea 278...
282
            
278
            
Línea 301... Línea 297...
301
                $connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $record['id']);
297
                $connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $record['id']);
Línea 302... Línea 298...
302
 
298
 
303
                $item = [
299
                $item = [
304
                    'id'    => $record['uuid'],
300
                    'id'    => $record['uuid'],
305
                    'name'  => trim($record['first_name'] . ' ' . $record['last_name']),
-
 
306
                    'image' => $storage 
301
                    'name'  => trim($record['first_name'] . ' ' . $record['last_name']),
307
                        ? $storage->getUserImageForCodeAndFilename($record['uuid'], $record['image']) 
-
 
308
                        : $this->url()->fromRoute('storage', ['code' => $record['uuid'], 'type' => 'user', 'filename' => $record['image'] ]), 
302
                    'image' =>   $storage->getUserImageForCodeAndFilename($record['uuid'], $record['image']),
309
                    'profile'   => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
303
                    'profile'   => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
310
                    'relation' => $relation,
304
                    'relation' => $relation,
311
                    'link_cancel'   => '',
305
                    'link_cancel'   => '',
312
                    'link_request'  => '',
306
                    'link_request'  => '',
Línea 390... Línea 384...
390
 
384
 
391
                $user_ids = [];
385
                $user_ids = [];
392
                foreach ($records as $record) {
386
                foreach ($records as $record) {
393
                    array_push($user_ids, $record['user_id']);
387
                    array_push($user_ids, $record['user_id']);
394
                }
-
 
Línea 395... Línea 388...
395
                
388
                }
396
 
389
 
397
                $mapper = QueryMapper::getInstance($this->adapter);
390
                $mapper = QueryMapper::getInstance($this->adapter);
398
                $select = $mapper->getSql()->select(UserMapper::_TABLE);
391
                $select = $mapper->getSql()->select(UserMapper::_TABLE);
399
                $select->columns(['id', 'uuid', 'first_name', 'last_name', 'image']);
392
                $select->columns(['id', 'uuid', 'first_name', 'last_name', 'image']);
400
                $select->where->in('id', $user_ids);
393
                $select->where->in('id', $user_ids);
401
                $select->where->equalTo('network_id', $currentUser->network_id);
394
                $select->where->equalTo('network_id', $currentUser->network_id);
Línea 402... Línea -...
402
                $select->where->equalTo('status', User::STATUS_ACTIVE);
-
 
403
                $select->order(['last_name ASC', 'first_name ASC']);
395
                $select->where->equalTo('status', User::STATUS_ACTIVE);
404
 
-
 
405
                if(self::_USE_S3) {
-
 
406
                    $storage = Storage::getInstance($this->config);
-
 
-
 
396
                $select->order(['last_name ASC', 'first_name ASC']);
Línea 407... Línea 397...
407
                } else {
397
 
408
                    $storage = null;
398
                $storage = Storage::getInstance($this->config);
409
                }
399
 
410
                
400
                
411
                $records = $mapper->fetchAll($select);
401
                $records = $mapper->fetchAll($select);
412
                foreach ($records as $record) {
-
 
413
                    array_push($items, [
402
                foreach ($records as $record) {
414
                        'id'        => $record['uuid'],
-
 
415
                        'name'      => trim($record['first_name'] . ' ' . $record['last_name']),
403
                    array_push($items, [
416
                        'image' => $storage
404
                        'id'        => $record['uuid'],
417
                            ? $storage->getUserImageForCodeAndFilename($record['uuid'], $record['image'])
405
                        'name'      => trim($record['first_name'] . ' ' . $record['last_name']),
418
                            : $this->url()->fromRoute('storage', ['code' => $record['uuid'], 'type' => 'user', 'filename' => $record['image'] ]),
406
                        'image' => $storage->getUserImageForCodeAndFilename($record['uuid'], $record['image']),
419
                        'profile'   => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
407
                        'profile'   => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
Línea 495... Línea 483...
495
                    $select->order(['last_name', 'first_name']);
483
                    $select->order(['last_name', 'first_name']);
Línea 496... Línea 484...
496
 
484
 
Línea 497... Línea -...
497
                    //echo $select->getSqlString($this->adapter->platform); exit;
-
 
498
 
485
                    //echo $select->getSqlString($this->adapter->platform); exit;
499
 
-
 
500
                    if(self::_USE_S3) {
-
 
501
                        $storage = Storage::getInstance($this->config);
-
 
Línea 502... Línea 486...
502
                    } else {
486
 
503
                        $storage = null;
487
 
Línea 504... Línea 488...
504
                    }
488
                    $storage = Storage::getInstance($this->config);
505
 
489
 
506
                    $records = $mapper->fetchAll($select);
490
                    $records = $mapper->fetchAll($select);
507
                    foreach ($records as $record) {
-
 
508
 
491
                    foreach ($records as $record) {
509
 
-
 
510
                        array_push($items, [
492
 
511
                            'id'        => $record['uuid'],
493
 
512
                            'name'      => trim($record['first_name'] . ' ' . $record['last_name']),
494
                        array_push($items, [
513
                            'image' => $storage
495
                            'id'        => $record['uuid'],
514
                                ? $storage->getUserImageForCodeAndFilename($record['uuid'], $record['image'])
496
                            'name'      => trim($record['first_name'] . ' ' . $record['last_name']),
Línea 558... Línea 540...
558
                $select->order(['name']);
540
                $select->order(['name']);
Línea 559... Línea 541...
559
 
541
 
Línea 560... Línea -...
560
 
-
 
561
                //echo $select->getSqlString($this->adapter->platform); exit;
542
 
562
 
-
 
563
                if(self::_USE_S3) {
-
 
564
                    $storage = Storage::getInstance($this->config);
-
 
-
 
543
                //echo $select->getSqlString($this->adapter->platform); exit;
Línea 565... Línea 544...
565
                } else {
544
 
566
                    $storage = null;
545
                $storage = Storage::getInstance($this->config);
567
                }
546
 
568
                
547
                
569
                $records = $mapper->fetchAll($select);
548
                $records = $mapper->fetchAll($select);
570
                foreach ($records as $record) {
-
 
571
                    array_push($items, [
549
                foreach ($records as $record) {
572
                        'id'        => $record['uuid'],
-
 
573
                        'name'      => trim($record['name']),
550
                    array_push($items, [
574
                        'image'     => $storage
551
                        'id'        => $record['uuid'],
575
                            ? $storage->getCompanyImageForCodeAndFilename($record['uuid'], $record['image']) 
552
                        'name'      => trim($record['name']),
576
                            : $this->url()->fromRoute('storage', ['code' => $record['uuid'], 'type' => 'company', 'filename' => $record['image'] ]),
553
                        'image'     => $storage->getCompanyImageForCodeAndFilename($record['uuid'], $record['image']) ,
Línea 654... Línea 631...
654
                $select->order(['last_name', 'first_name']);
631
                $select->order(['last_name', 'first_name']);
Línea 655... Línea 632...
655
 
632
 
Línea 656... Línea -...
656
                //echo $select->getSqlString($this->adapter->platform);
-
 
657
 
633
                //echo $select->getSqlString($this->adapter->platform);
658
 
-
 
659
                if(self::_USE_S3) {
-
 
660
                    $storage = Storage::getInstance($this->config);
-
 
Línea 661... Línea 634...
661
                } else {
634
 
662
                    $storage = null;
635
 
Línea 688... Línea 661...
688
                    }
661
                    }
Línea 689... Línea 662...
689
 
662
 
690
                    array_push($items, [
663
                    array_push($items, [
691
                        'id'        => $record['uuid'],
664
                        'id'        => $record['uuid'],
692
                        'name'      => trim($record['first_name'] . ' ' . $record['last_name']),
-
 
693
                        
-
 
694
                        'image'     => $storage
665
                        'name'      => trim($record['first_name'] . ' ' . $record['last_name']),
695
                        ? $storage->getGroupImageForCodeAndFilename($record['uuid'], $record['image'])
-
 
696
                        : $this->url()->fromRoute('storage', ['code' => $record['uuid'], 'type' => 'group', 'filename' => $record['image'] ]),
-
 
697
                        
666
                        'image'     =>  $storage->getGroupImageForCodeAndFilename($record['uuid'], $record['image']),
698
                        'profile'   => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
667
                        'profile'   => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
Línea 699... Línea 668...
699
                        'actions'   => $actions,
668
                        'actions'   => $actions,
700
 
669
 
Línea 1385... Línea 1354...
1385
            });
1354
            });
Línea 1386... Línea 1355...
1386
 
1355
 
Línea 1387... Línea -...
1387
 
-
 
1388
            $items = [];
1356
 
1389
            
-
 
1390
            if(self::_USE_S3) {
-
 
1391
                $storage = Storage::getInstance($this->config);
1357
            $items = [];
Línea 1392... Línea 1358...
1392
            } else {
1358
            
Línea 1393... Línea 1359...
1393
                $storage = null;
1359
            $storage = Storage::getInstance($this->config);
1394
            }
1360
 
1395
 
1361
 
1396
            foreach ($records as $record) {
-
 
1397
 
1362
            foreach ($records as $record) {
1398
                array_push($items, [
-
 
1399
                    'id'        => $record['uuid'],
-
 
1400
                    'name'      => trim($record['name']),
1363
 
1401
                    'image'     => $storage
1364
                array_push($items, [
Línea 1402... Línea 1365...
1402
                    ? $storage->getGroupImageForCodeAndFilename($record['uuid'], $record['image'])
1365
                    'id'        => $record['uuid'],
1403
                    : $this->url()->fromRoute('storage', ['code' => $record['uuid'], 'type' => 'group', 'filename' => $record['image'] ]),
1366
                    'name'      => trim($record['name']),
Línea 1430... Línea 1393...
1430
            $items = [];
1393
            $items = [];
1431
            $postMapper = PostMapper::getInstance($this->adapter);
1394
            $postMapper = PostMapper::getInstance($this->adapter);
1432
            $posts = $postMapper->fetchAllActiveByNetworkId($currentUser->network_id);
1395
            $posts = $postMapper->fetchAllActiveByNetworkId($currentUser->network_id);
Línea 1433... Línea -...
1433
 
-
 
1434
 
1396
 
1435
            if(self::_USE_S3) {
1397
 
1436
                $storage = Storage::getInstance($this->config);
-
 
1437
                $path = $storage->getPathPost();
-
 
1438
            } else {
-
 
1439
                $storage = null;
-
 
Línea 1440... Línea 1398...
1440
            }
1398
            $storage = Storage::getInstance($this->config);
1441
           
1399
            $path = $storage->getPathPost();
1442
 
1400
 
1443
            foreach ($posts as $post) {
-
 
1444
                $dt = \DateTime::createFromFormat('Y-m-d', $post->date);
1401
            foreach ($posts as $post) {
1445
                array_push($items, [
-
 
1446
                    'image' => $storage 
1402
                $dt = \DateTime::createFromFormat('Y-m-d', $post->date);
1447
                    ? $storage->getGenericImage($path, $post->uuid, $post->image)
1403
                array_push($items, [
1448
                    : $this->url()->fromRoute('storage', ['code' => $post->uuid, 'type' => 'post', 'filename' => $post->image ]),
1404
                    'image' => $storage->getGenericImage($path, $post->uuid, $post->image),
1449
                    'date' => $dt->format('d/m/Y'),
1405
                    'date' => $dt->format('d/m/Y'),
1450
                    'title' => $post->title,
1406
                    'title' => $post->title,
Línea 1620... Línea 1576...
1620
            $select->where->equalTo('g.user_id', $currentUser->id);
1576
            $select->where->equalTo('g.user_id', $currentUser->id);
1621
            $select->order('name ASC');
1577
            $select->order('name ASC');
Línea 1622... Línea 1578...
1622
 
1578
 
1623
 
-
 
1624
            $items = [];
1579
 
1625
            if(self::_USE_S3) {
-
 
1626
                $storage = Storage::getInstance($this->config);
-
 
1627
            } else {
-
 
1628
                $storage = null;
1580
            $items = [];
Línea 1629... Línea 1581...
1629
            }
1581
            $storage = Storage::getInstance($this->config);
1630
            
1582
 
Línea 1631... Línea 1583...
1631
 
1583
 
1632
            $records = $queryMapper->fetchAll($select);
1584
            $records = $queryMapper->fetchAll($select);
1633
            foreach ($records as $record) {
1585
            foreach ($records as $record) {
1634
 
-
 
1635
                array_push($items, [
1586
 
1636
                    'id'        => $record['uuid'],
-
 
1637
                    'name'      => trim($record['name']),
-
 
1638
                    'image'     => $storage
1587
                array_push($items, [
1639
                    ? $storage->getGroupImageForCodeAndFilename($record['uuid'], $record['image'])
1588
                    'id'        => $record['uuid'],
Línea 1640... Línea 1589...
1640
                    : $this->url()->fromRoute('storage', ['code' => $record['uuid'], 'type' => 'group', 'filename' => $record['image'] ]),
1589
                    'name'      => trim($record['name']),
1641
                    
1590
                    'image'     =>  $storage->getGroupImageForCodeAndFilename($record['uuid'], $record['image']),
Línea 2231... Línea 2180...
2231
                    
2180
                    
2232
                    array_push($menu, $option);
2181
                    array_push($menu, $option);
Línea 2233... Línea -...
2233
                }
-
 
2234
                
2182
                }
2235
           
-
 
2236
                if(self::_USE_S3) {
-
 
2237
                    $storage = Storage::getInstance($this->config);
-
 
-
 
2183
                
Línea 2238... Línea 2184...
2238
                } else {
2184
           
2239
                    $storage = null;
2185
                $storage = Storage::getInstance($this->config);
2240
                }
2186
 
2241
                
2187
                
Línea 2247... Línea 2193...
2247
                
2193
                
Línea 2248... Línea -...
2248
                if($network->navbar) {
-
 
2249
                    
-
 
2250
                    
-
 
2251
                    
2194
                if($network->navbar) {
2252
                    
2195
                    
2253
                    if(self::_USE_S3) {
-
 
2254
                        
-
 
Línea 2255... Línea -...
2255
                        $storage = Storage::getInstance($this->config);
-
 
2256
                        $path = $storage->getPathNetwork();
-
 
2257
                        
-
 
2258
                        $navbar = $storage->getGenericImage($path, $network->uuid, $network->navbar);
-
 
2259
                        
-
 
2260
                    } else {
-
 
2261
                        $storage = null;
-
 
2262
                    }
-
 
2263
                    
-
 
2264
                    $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
-
 
2265
                    $currentNetwork = $currentNetworkPlugin->getNetwork();
-
 
2266
                    
-
 
2267
                    $parts = explode('.', $currentNetwork->main_hostname);
-
 
2268
                    if($parts[1] === 'com') {
-
 
2269
                        $replace_main = false;
-
 
2270
                    } else {
2196
                    
2271
                        $replace_main = true;
-
 
2272
                    }
-
 
2273
                    
-
 
2274
                    if($currentNetwork->navbar) {
-
 
2275
                        $navbar_url = $storage->getGenericImage($path, $currentNetwork->uuid, $currentNetwork->navbar);
-
 
2276
                    } else {
-
 
2277
                        $navbar_url = '';
-
 
2278
                    }
-
 
2279
                    
-
 
2280
                    if($replace_main) {
-
 
Línea 2281... Línea -...
2281
                        $navbar_url = str_replace($currentNetwork->main_hostname, $currentNetwork->service_hostname, $navbar_url);
-
 
2282
                    }
-
 
2283
                    
-
 
2284
                    if($currentNetwork->alternative_hostname) {
-
 
2285
                        $navbar_url = str_replace($currentNetwork->alternative_hostname, $currentNetwork->service_hostname, $navbar_url);
-
 
2286
                        
-
 
Línea -... Línea 2197...
-
 
2197
                    
2287
                    }
2198
                    $storage = Storage::getInstance($this->config);
2288
                }
2199
                    $path = $storage->getPathNetwork();
2289
                
2200
                        
Línea 2290... Línea 2201...
2290
   
2201
                    $navbar = $storage->getGenericImage($path, $network->uuid, $network->navbar);