Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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