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