Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 3916 | Rev 6749 | 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
 
18
use LeadersLinked\Mapper\UserProfileMapper;
19
use LeadersLinked\Mapper\CompanyFollowerMapper;
20
use LeadersLinked\Mapper\LocationMapper;
21
use LeadersLinked\Mapper\UserLanguageMapper;
22
use LeadersLinked\Mapper\UserSkillMapper;
23
 
24
use LeadersLinked\Mapper\UserMapper;
25
use LeadersLinked\Mapper\UserEducationMapper;
26
use LeadersLinked\Mapper\DegreeMapper;
27
use LeadersLinked\Mapper\UserExperienceMapper;
28
use LeadersLinked\Mapper\IndustryMapper;
29
use LeadersLinked\Mapper\CompanySizeMapper;
30
use LeadersLinked\Mapper\ConnectionMapper;
31
use LeadersLinked\Mapper\UserBlockedMapper;
32
use LeadersLinked\Model\Connection;
4842 efrain 33
use LeadersLinked\Model\Network;
1 www 34
use LeadersLinked\Mapper\ProfileVisitMapper;
35
use LeadersLinked\Model\ProfileVisit;
36
use LeadersLinked\Mapper\QueryMapper;
37
use Laminas\Paginator\Adapter\DbSelect;
38
use Laminas\Paginator\Paginator;
39
use LeadersLinked\Model\User;
40
use Laminas\Db\Sql\Expression;
41
use LeadersLinked\Mapper\LanguageMapper;
42
use LeadersLinked\Mapper\SkillMapper;
3912 efrain 43
use LeadersLinked\Mapper\AptitudeMapper;
44
use LeadersLinked\Mapper\UserAptitudeMapper;
45
use LeadersLinked\Mapper\HobbyAndInterestMapper;
46
use LeadersLinked\Mapper\UserHobbyAndInterestMapper;
1 www 47
 
48
 
49
class ProfileController extends AbstractActionController
50
{
51
    /**
52
     *
53
     * @var AdapterInterface
54
     */
55
    private $adapter;
56
 
57
 
58
    /**
59
     *
60
     * @var AbstractAdapter
61
     */
62
    private $cache;
63
 
64
    /**
65
     *
66
     * @var  LoggerInterface
67
     */
68
    private $logger;
69
 
70
 
71
    /**
72
     *
73
     * @var array
74
     */
75
    private $config;
76
 
77
    /**
78
     *
79
     * @param AdapterInterface $adapter
80
     * @param AbstractAdapter $cache
81
     * @param LoggerInterface $logger
82
     * @param array $config
83
     */
84
    public function __construct($adapter, $cache , $logger,  $config)
85
    {
86
        $this->adapter      = $adapter;
87
        $this->cache        = $cache;
88
        $this->logger       = $logger;
89
        $this->config       = $config;
90
 
91
    }
92
 
93
    /**
94
     *
95
     * Generación del listado de perfiles
96
     * {@inheritDoc}
97
     * @see \Laminas\Mvc\Controller\AbstractActionController::indexAction()
98
     */
99
    public function indexAction()
100
    {
101
        $this->layout()->setTemplate('layout/layout.phtml');
102
        $viewModel = new ViewModel();
103
        $viewModel->setTemplate('leaders-linked/profile/index.phtml');
104
        return $viewModel ;
105
 
106
    }
107
 
108
 
109
    /**
110
     * Presenta el perfil con las opciónes de edición de cada sección
111
     * @return \Laminas\Http\Response|\Laminas\View\Model\ViewModel|\Laminas\View\Model\JsonModel
112
     */
113
    public function viewAction()
114
    {
115
 
3648 efrain 116
        $currentUserPlugin = $this->plugin('currentUserPlugin');
117
        $currentUser = $currentUserPlugin->getUser();
118
 
4842 efrain 119
        $currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
120
        $currentNetwork= $currentNetworkPlugin->getNetwork();
121
 
122
 
1 www 123
        $request = $this->getRequest();
124
        if($request->isGet()) {
125
 
126
 
127
            $flashMessenger = $this->plugin('FlashMessenger');
128
 
129
 
130
            $id = $this->params()->fromRoute('id');
131
            if(!$id) {
132
                $flashMessenger->addErrorMessage('ERROR_INVALID_PARAMETER');
133
                return $this->redirect()->toRoute('dashboard');
134
            }
135
 
136
 
137
            $userMapper = UserMapper::getInstance($this->adapter);
3648 efrain 138
            $user = $userMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
1 www 139
 
140
            $userProfileMapper = UserProfileMapper::getInstance($this->adapter);
141
            if($user) {
142
                $userProfile = $userProfileMapper->fetchOnePublicByUserId($user->id);
143
            } else {
144
                $userProfile = $userProfileMapper->fetchOneByUuid($id);
3648 efrain 145
 
146
                if($userProfile) {
147
                    $user = $userMapper->fetchOne($userProfile->user_id);
148
 
149
                    if($user && $currentUser->network_id != $user->network_id) {
150
                        $response = [
151
                            'success' => false,
152
                            'data' => 'ERROR_UNAUTHORIZED'
153
                        ];
154
 
155
                        return new JsonModel($response);
156
                    }
157
                }
1 www 158
            }
159
 
160
            if(!$userProfile) {
161
                $flashMessenger->addErrorMessage('ERROR_RECORD_NOT_FOUND');
162
                return $this->redirect()->toRoute('dashboard');
163
            }
164
 
3648 efrain 165
 
1 www 166
 
167
            $userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
168
            $userBlocked = $userBlockedMapper->fetchOneByUserIdAndBlockedId($userProfile->user_id, $currentUser->id);
169
 
170
            if($userBlocked) {
171
                $flashMessenger->addErrorMessage('ERROR_UNAUTHORIZED');
172
                return $this->redirect()->toRoute('dashboard');
173
            }
174
 
175
            if($currentUser->id != $userProfile->user_id) {
176
 
177
                $visited_on = date('Y-m-d');;
178
                $profileVisitMapper = ProfileVisitMapper::getInstance($this->adapter);
179
                $profileVisit = $profileVisitMapper->fetchOneByVisitorIdAndVisitedIdAndVisitedOn($currentUser->id, $userProfile->user_id, $visited_on);
180
                if(!$profileVisit) {
181
                    $profileVisit = new ProfileVisit();
182
                    $profileVisit->user_profile_id = $userProfile->id;
183
                    $profileVisit->visited_id = $userProfile->user_id;
184
                    $profileVisit->visitor_id = $currentUser->id;
185
                    $profileVisit->visited_on = date('Y-m-d');
186
                    $profileVisitMapper->insert($profileVisit);
187
                }
188
            }
189
 
190
            if($userProfile->location_id) {
191
                $locationMapper= LocationMapper::getInstance($this->adapter);
192
                $location = $locationMapper->fetchOne($userProfile->location_id);
193
 
194
                $formattedAddress = $location->formatted_address;
195
                $country = $location->country;
196
            } else {
197
                $formattedAddress = '';
198
                $country = '';
199
            }
200
 
201
            $connectionMapper = ConnectionMapper::getInstance($this->adapter);
202
            $connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $userProfile->user_id);
203
 
204
            $userMapper = UserMapper::getInstance($this->adapter);
205
            $user = $userMapper->fetchOne($userProfile->user_id);
206
 
207
            $userLanguages = [];
208
            $languageMapper = LanguageMapper::getInstance($this->adapter);
209
            $userLanguageMapper = UserLanguageMapper::getInstance($this->adapter);
210
            $records = $userLanguageMapper->fetchAllByUserProfileId($userProfile->id);
211
            foreach($records as $record)
212
            {
213
                $language = $languageMapper->fetchOne($record->language_id);
214
                $userLanguages[$language->id] = $language->name;
215
            }
216
 
217
 
218
            $locationMapper = LocationMapper::getInstance($this->adapter);
219
 
220
            $degreeMapper = DegreeMapper::getInstance($this->adapter);
221
            $userEducationMapper = UserEducationMapper::getInstance($this->adapter);
222
            $userEducations = $userEducationMapper->fetchAllByUserProfileId($userProfile->id);
223
 
224
            foreach($userEducations  as &$userEducation)
225
            {
226
                $location = $locationMapper->fetchOne($userEducation->location_id);
227
                $degree = $degreeMapper->fetchOne($userEducation->degree_id)    ;
228
 
229
 
230
                $userEducation = [
231
                    'university' => $userEducation->university,
232
                    'degree' => $degree->name,
233
                    'field_of_study' => $userEducation->field_of_study,
234
                    'grade_or_percentage' => $userEducation->grade_or_percentage,
235
                    'formatted_address' => $location->formatted_address,
236
                    'from_year' => $userEducation->from_year,
237
                    'to_year' => $userEducation->to_year,
238
                    'description' => $userEducation->description,
239
                ];
240
            }
241
 
242
            /*
243
            $industries = [];
244
            $industryMapper = IndustryMapper::getInstance($this->adapter);
3454 efrain 245
            $records = $industryMapper->fetchAllActive();
1 www 246
            foreach($records as $record)
247
            {
248
                $industries[$record->uuid] = $record->name;
249
            }
250
 
251
            $companySizes = [];
252
            $companySizeMapper = CompanySizeMapper::getInstance($this->adapter);
3454 efrain 253
            $records = $companySizeMapper->fetchAllActive();
1 www 254
            foreach($records as $record)
255
            {
256
                $companySizes[$record->uuid] = $record->name . ' ('.$record->minimum_no_of_employee . '-' . $record->maximum_no_of_employee .')';
257
            }
258
            */
259
 
260
            $industryMapper = IndustryMapper::getInstance($this->adapter);
261
            $companySizeMapper = CompanySizeMapper::getInstance($this->adapter);
262
 
263
 
264
            $userExperienceMapper = UserExperienceMapper::getInstance($this->adapter);
265
            $userExperiences = $userExperienceMapper->fetchAllByUserProfileId($userProfile->id);
266
 
267
            foreach($userExperiences  as &$userExperience)
268
            {
269
                $industry = $industryMapper->fetchOne($userExperience->industry_id);
270
                $companySize = $companySizeMapper->fetchOne($userExperience->company_size_id);
271
 
272
 
273
                $location = $locationMapper->fetchOne($userExperience->location_id);
274
 
275
                $userExperience = [
276
                    'company' => $userExperience->company,
277
                    'industry' => $industry->name,
278
                    'size' => $companySize->name . ' (' . $companySize->minimum_no_of_employee . ' - ' . $companySize->maximum_no_of_employee . ' ) ',
279
                    'title' => $userExperience->title,
280
                    'formatted_address' => $location->formatted_address,
281
                    'from_year' => $userExperience->from_year,
282
                    'from_month' => $userExperience->from_month,
283
                    'to_year' => $userExperience->to_year,
284
                    'to_month' => $userExperience->to_month,
285
                    'description' => $userExperience->description,
286
                    'is_current' => $userExperience->is_current,
287
                ];
288
            }
3912 efrain 289
 
290
            $userAptitudes = [];
291
            $aptitudeMapper = AptitudeMapper::getInstance($this->adapter);
292
            $userAptitudeMapper = UserAptitudeMapper::getInstance($this->adapter);
293
            $records  = $userAptitudeMapper->fetchAllByUserProfileId($userProfile->id);
294
            foreach($records as $record)
295
            {
3916 efrain 296
                $aptitude = $aptitudeMapper->fetchOne($record->aptitude_id);
3912 efrain 297
                if($aptitude) {
298
                    $userAptitudes[$aptitude->uuid] = $aptitude->name;
299
                }
300
            }
301
 
302
            $userHobbiesAndInterests = [];
303
            $hobbyAndInterestMapper = HobbyAndInterestMapper::getInstance($this->adapter);
304
            $userHobbyAndInterestMapper = UserHobbyAndInterestMapper::getInstance($this->adapter);
305
            $records  = $userHobbyAndInterestMapper->fetchAllByUserProfileId($userProfile->id);
306
            foreach($records as $record)
307
            {
3916 efrain 308
                $hobbyAndInterest = $hobbyAndInterestMapper->fetchOne($record->hobby_and_interest_id);
3912 efrain 309
                if($hobbyAndInterest) {
310
                    $userHobbiesAndInterests[$hobbyAndInterest->uuid] = $hobbyAndInterest->name;
311
                }
312
            }
313
 
314
 
1 www 315
            $userSkills = [];
316
            $skillMapper = SkillMapper::getInstance($this->adapter);
317
            $userSkillMapper = UserSkillMapper::getInstance($this->adapter);
318
            $records  = $userSkillMapper->fetchAllByUserProfileId($userProfile->id);
319
            foreach($records as $record)
320
            {
321
                $skill = $skillMapper->fetchOne($record->skill_id);
3912 efrain 322
                if($skill) {
323
                    $userSkills[$skill->uuid] = $skill->name;
324
                }
1 www 325
            }
326
 
327
 
4842 efrain 328
 
329
 
3912 efrain 330
 
4842 efrain 331
            if($currentNetwork->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER)  {
3912 efrain 332
 
4842 efrain 333
                $connectionMapper = ConnectionMapper::getInstance($this->adapter);
334
                $total_connections = $connectionMapper->fetchTotalConnectionByUser($user->id);
335
 
336
                $request_connection = 0;
337
                if($connection) {
338
                    if($connection->status == Connection::STATUS_REJECTED || $connection->status == Connection::STATUS_CANCELLED) {
339
                        $request_connection = 1;
340
                    }
341
                } else {
3115 efrain 342
                    $request_connection = 1;
1 www 343
                }
4842 efrain 344
 
345
 
346
 
347
                $common_connection = count($connectionMapper->fetchAllCommonConnectionsUserIdByUser1ReturnIds($currentUser->id, $userProfile->user_id));
1 www 348
            }
349
 
3189 efrain 350
 
1 www 351
            $profileVisitMapper = ProfileVisitMapper::getInstance($this->adapter);
352
            $views          = $profileVisitMapper->getTotalByVisitedId( $userProfile->user_id );
353
 
354
 
355
 
356
            $headers  = $request->getHeaders();
357
            $isJson = false;
358
            if($headers->has('Accept')) {
359
                $accept = $headers->get('Accept');
360
 
361
                $prioritized = $accept->getPrioritized();
362
 
363
                foreach($prioritized as $key => $value) {
364
                    $raw = trim($value->getRaw());
365
 
366
                    if(!$isJson) {
367
                        $isJson = strpos($raw, 'json');
368
                    }
369
 
370
                }
371
            }
372
 
373
 
374
            if($isJson) {
375
 
376
                $data = [
3912 efrain 377
                    'user_id'                       => $user->uuid,
378
                    'user_uuid'                     => ($user->uuid),
379
                    'full_name'                     => trim($user->first_name . ' ' . $user->last_name),
380
                    'user_profile_id'               => $userProfile->id,
381
                    'user_profile_uuid'             => $userProfile->uuid,
382
                    'image'                         => $this->url()->fromRoute('storage',['code' => $user->uuid, 'type' => 'user-profile', 'filename' => $user->image]),
383
                    'cover'                         => $this->url()->fromRoute('storage',['code' => $user->uuid, 'type' => 'user-cover', 'filename' => $userProfile->cover]),
384
                    'overview'                      => $userProfile->description,
385
                    'facebook'                      => $userProfile->facebook,
386
                    'instagram'                     => $userProfile->instagram,
387
                    'twitter'                       => $userProfile->twitter,
388
                    'formatted_address'             => $formattedAddress,
389
                    'country'                       => $country,
390
                    'user_skills'                   => $userSkills,
391
                    'user_languages'                => $userLanguages,
392
                    'user_educations'               => $userEducations,
393
                    'user_experiences'              => $userExperiences,
394
                    'user_aptitudes'                => $userAptitudes,
395
                    'user_hobbies_and_interests'    => $userHobbiesAndInterests,
396
                    'views'                         => $views,
397
                    'show_contact'                  => $user->id != $currentUser->id,
398
                    'link_inmail'                   => $this->url()->fromRoute('inmail',['id' => $user->uuid ]),
1 www 399
                ];
400
 
4842 efrain 401
 
402
                if($currentNetwork->default == Network::DEFAULT_YES) {
403
 
404
                    $companyFollowerMapper = CompanyFollowerMapper::getInstance($this->adapter);
405
                    $data['following'] = $companyFollowerMapper->getCountFollowing($user->id);
406
                    $data['view_following'] = 1;
407
                } else {
408
                    $data['following'] = 0;
409
                    $data['view_following'] = 0;
410
                }
411
 
412
 
413
                if($currentNetwork->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER)  {
414
                    $data['total_connections']  = $total_connections;
415
                    $data['view_total_connections']  = 1;
416
                    $data['request_connection'] = $request_connection;
417
                    $data['common_connection']  = $common_connection;
418
                    $data['link_cancel']        = $connection && $connection->status == Connection::STATUS_SENT ? $this->url()->fromRoute('connection/delete',['id' => $user->uuid ]) :  $this->url()->fromRoute('connection/cancel',['id' => $user->uuid]);
419
                    $data['link_request']       = $request_connection ? $this->url()->fromRoute('connection/request',['id' => $user->uuid ]) : '';
420
                } else {
421
                    $data['total_connections']  = 0;
422
                    $data['view_total_connections']  = 0;
423
                    $data['request_connection'] = 0;
424
                    $data['common_connection']  = 0;
425
                    $data['link_cancel']        = '';
426
                    $data['link_request']       = '';
427
                }
428
 
1 www 429
                return new JsonModel($data);
430
 
431
            } else {
432
 
4842 efrain 433
                if($currentNetwork->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER)  {
434
                    $data = [
435
                        'total_connections'             => $total_connections,
436
                        'view_total_connections'        => 1,
437
                        'user_id'                       => $user->uuid,
438
                        'user_uuid'                     => ($user->uuid),
439
                        'full_name'                     => trim($user->first_name . ' ' . $user->last_name),
440
                        'user_profile_id'               => $userProfile->id,
441
                        'user_profile_uuid'             => $userProfile->uuid,
442
                        'image'                         => $userProfile->image,
443
                        'cover'                         => $userProfile->cover,
444
                        'overview'                      => $userProfile->description,
445
                        'facebook'                      => $userProfile->facebook,
446
                        'instagram'                     => $userProfile->instagram,
447
                        'twitter'                       => $userProfile->twitter,
448
                        'formatted_address'             => $formattedAddress,
449
                        'country'                       => $country,
450
                        'user_skills'                   => $userSkills,
451
                        'user_languages'                => $userLanguages,
452
                        'user_educations'               => $userEducations,
453
                        'user_experiences'              => $userExperiences,
454
                        'user_aptitudes'                => $userAptitudes,
455
                        'user_hobbies_and_interests'    => $userHobbiesAndInterests,
456
                        'show_contact'                  => $user->id != $currentUser->id,
457
                        'request_connection'            => $request_connection,
458
                        'link_cancel'                   => $connection && $connection->status == Connection::STATUS_SENT ? $this->url()->fromRoute('connection/delete',['id' => $user->uuid ]) :  $this->url()->fromRoute('connection/cancel',['id' => $user->uuid]),
459
                        'link_request'                  => $request_connection ? $this->url()->fromRoute('connection/request',['id' => $user->uuid ]) : '',
460
                        'link_inmail'                   => $this->url()->fromRoute('inmail',['id' => $user->uuid ]),
461
                    ];
462
                } else {
463
                    $data = [
464
                        'total_connections'             => 0,
465
                        'view_total_connections'        => 0,
466
                        'user_id'                       => $user->uuid,
467
                        'user_uuid'                     => ($user->uuid),
468
                        'full_name'                     => trim($user->first_name . ' ' . $user->last_name),
469
                        'user_profile_id'               => $userProfile->id,
470
                        'user_profile_uuid'             => $userProfile->uuid,
471
                        'image'                         => $userProfile->image,
472
                        'cover'                         => $userProfile->cover,
473
                        'overview'                      => $userProfile->description,
474
                        'facebook'                      => $userProfile->facebook,
475
                        'instagram'                     => $userProfile->instagram,
476
                        'twitter'                       => $userProfile->twitter,
477
                        'formatted_address'             => $formattedAddress,
478
                        'country'                       => $country,
479
                        'user_skills'                   => $userSkills,
480
                        'user_languages'                => $userLanguages,
481
                        'user_educations'               => $userEducations,
482
                        'user_experiences'              => $userExperiences,
483
                        'user_aptitudes'                => $userAptitudes,
484
                        'user_hobbies_and_interests'    => $userHobbiesAndInterests,
485
                        'show_contact'                  => $user->id != $currentUser->id,
486
                        'request_connection'            => 0,
487
                        'link_cancel'                   => '',
488
                        'link_request'                  => '',
489
                        'link_inmail'                   => $this->url()->fromRoute('inmail',['id' => $user->uuid ]),
490
                    ];
491
                }
492
 
493
                if($currentNetwork->default == Network::DEFAULT_YES) {
494
 
495
                    $companyFollowerMapper = CompanyFollowerMapper::getInstance($this->adapter);
496
                    $data['following'] = $companyFollowerMapper->getCountFollowing($user->id);
497
                    $data['view_following'] = 1;
498
                } else {
499
                    $data['following'] = 0;
500
                    $data['view_following'] = 0;
501
                }
502
 
503
 
1 www 504
 
505
                $this->layout()->setTemplate('layout/layout.phtml');
506
                $viewModel = new ViewModel();
507
                $viewModel->setTemplate('leaders-linked/profile/view.phtml');
4842 efrain 508
                $viewModel->setVariables($data);
1 www 509
                return $viewModel ;
510
            }
511
        }
512
 
513
        return new JsonModel([
514
            'success' => false,
515
            'data' => 'ERROR_METHOD_NOT_ALLOWED'
516
        ]);
517
 
518
 
519
 
520
    }
521
 
522
    public function peopleViewedProfileAction()
523
    {
524
        $currentUserPlugin = $this->plugin('currentUserPlugin');
525
        $currentUser = $currentUserPlugin->getUser();
526
 
527
        $request = $this->getRequest();
528
        if($request->isGet()) {
529
 
530
 
531
            $headers  = $request->getHeaders();
532
            $isJson = false;
533
            if($headers->has('Accept')) {
534
                $accept = $headers->get('Accept');
535
 
536
                $prioritized = $accept->getPrioritized();
537
 
538
                foreach($prioritized as $key => $value) {
539
                    $raw = trim($value->getRaw());
540
 
541
                    if(!$isJson) {
542
                        $isJson = strpos($raw, 'json');
543
                    }
544
 
545
                }
546
            }
547
 
548
            if($isJson) {
549
                $page = (int) $this->params()->fromQuery('page');
550
                $search = trim(filter_var($this->params()->fromQuery('search', ''), FILTER_SANITIZE_STRING));
551
 
552
                $mapper = QueryMapper::getInstance($this->adapter);
553
                $select = $mapper->getSql()->select();
554
                $select->columns(['visitor_id' => new Expression('DISTINCT(visitor_id)')]);
555
                $select->from(['p' => ProfileVisitMapper::_TABLE]);
556
                $select->join(['u' => UserMapper::_TABLE], 'p.visitor_id = u.id ', ['uuid', 'first_name', 'last_name', 'image']);
557
                $select->where->equalTo('p.visited_id', $currentUser->id)->and->equalTo('u.status', User::STATUS_ACTIVE);
558
 
559
                if($search) {
560
                    $select->where->NEST->like('first_name', '%' . $search . '%')->or->like('last_name', '%' . $search . '%')->UNNEST;
561
                }
562
                $select->order('first_name','last_name');
563
 
564
                //echo $select->getSqlString($this->adapter->platform); exit;
565
 
566
                $dbSelect = new DbSelect($select, $this->adapter);
567
                $paginator = new Paginator($dbSelect);
568
                $paginator->setCurrentPageNumber($page ? $page : 1);
569
                $paginator->setItemCountPerPage(10);
570
 
571
                $items = [];
572
                $records = $paginator->getCurrentItems();
573
 
574
                foreach($records as $record)
575
                {
576
 
577
                    $item = [
578
                        'name' => trim($record['first_name'] . ' ' . $record['last_name']),
579
                        'image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $record['uuid'], 'filename' => $record['image'] ]),
580
                        'link_view' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']  ]),
581
                        'link_inmail'   => $this->url()->fromRoute('inmail', ['id' => $record['uuid']  ]),
582
                    ];
583
 
584
                    array_push($items, $item);
585
                }
586
 
587
                $response = [
588
                    'success' => true,
589
                    'data' => [
590
                        'total' => [
591
                            'count' => $paginator->getTotalItemCount(),
592
                            'pages' => $paginator->getPages()->pageCount,
593
                        ],
594
                        'current' => [
595
                            'items'    => $items,
596
                            'page'     => $paginator->getCurrentPageNumber(),
597
                            'count'    => $paginator->getCurrentItemCount(),
598
                        ]
599
                    ]
600
                ];
601
 
602
 
603
 
604
                return new JsonModel($response);
605
            } else {
606
                $this->layout()->setTemplate('layout/layout.phtml');
607
                $viewModel = new ViewModel();
608
                $viewModel->setTemplate('leaders-linked/profile/people-viewed-profile.phtml');
609
                return $viewModel ;
610
            }
611
 
612
        } else {
613
            return new JsonModel([
614
                'success' => false,
615
                'data' => 'ERROR_METHOD_NOT_ALLOWED'
616
            ]);
617
        }
618
    }
619
 
620
 
621
}