Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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