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