1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace LeadersLinked\Controller;
|
|
|
6 |
|
|
|
7 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
8 |
use Laminas\View\Model\JsonModel;
|
|
|
9 |
use LeadersLinked\Mapper\CalendarEventMapper;
|
|
|
10 |
use LeadersLinked\Mapper\CompanyFollowerMapper;
|
|
|
11 |
use LeadersLinked\Mapper\JobDescriptionMapper;
|
|
|
12 |
use LeadersLinked\Mapper\PerformanceEvaluationFormMapper;
|
|
|
13 |
use LeadersLinked\Mapper\PerformanceEvaluationTestMapper;
|
|
|
14 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
15 |
use LeadersLinked\Mapper\RecruitmentSelectionCandidateMapper;
|
|
|
16 |
use LeadersLinked\Mapper\RecruitmentSelectionInterviewMapper;
|
|
|
17 |
use LeadersLinked\Mapper\RecruitmentSelectionVacancyMapper;
|
|
|
18 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
19 |
use LeadersLinked\Mapper\ZoomMeetingMapper;
|
|
|
20 |
use LeadersLinked\Library\Functions;
|
|
|
21 |
use LeadersLinked\Mapper\UserNotificationSettingMapper;
|
|
|
22 |
|
|
|
23 |
use LeadersLinked\Model\CalendarEvent;
|
|
|
24 |
use LeadersLinked\Model\User;
|
|
|
25 |
use LeadersLinked\Mapper\ConnectionMapper;
|
|
|
26 |
use LeadersLinked\Mapper\ProfileVisitMapper;
|
|
|
27 |
use LeadersLinked\Mapper\GroupMemberMapper;
|
|
|
28 |
use LeadersLinked\Model\GroupMember;
|
|
|
29 |
use LeadersLinked\Mapper\GroupMapper;
|
|
|
30 |
use LeadersLinked\Model\Group;
|
|
|
31 |
use Laminas\Db\Sql\Expression;
|
|
|
32 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
|
|
33 |
use LeadersLinked\Model\CompanyUser;
|
|
|
34 |
use LeadersLinked\Model\UserType;
|
|
|
35 |
use LeadersLinked\Model\Notification;
|
|
|
36 |
use LeadersLinked\Mapper\NotificationMapper;
|
|
|
37 |
use LeadersLinked\Mapper\EmailTemplateMapper;
|
|
|
38 |
use LeadersLinked\Model\EmailTemplate;
|
|
|
39 |
use LeadersLinked\Library\QueueEmail;
|
|
|
40 |
use LeadersLinked\Mapper\PostMapper;
|
|
|
41 |
use LeadersLinked\Mapper\CompanyMapper;
|
|
|
42 |
use LeadersLinked\Model\Company;
|
|
|
43 |
use LeadersLinked\Model\Connection;
|
|
|
44 |
use LeadersLinked\Mapper\UserProfileMapper;
|
|
|
45 |
use LeadersLinked\Model\Network;
|
|
|
46 |
use LeadersLinked\Mapper\LocationMapper;
|
|
|
47 |
use LeadersLinked\Mapper\CompanySizeMapper;
|
|
|
48 |
use LeadersLinked\Mapper\DegreeMapper;
|
|
|
49 |
use LeadersLinked\Mapper\LanguageMapper;
|
|
|
50 |
use LeadersLinked\Mapper\SkillMapper;
|
|
|
51 |
use LeadersLinked\Mapper\AptitudeMapper;
|
|
|
52 |
use LeadersLinked\Mapper\HobbyAndInterestMapper;
|
|
|
53 |
use LeadersLinked\Mapper\IndustryMapper;
|
|
|
54 |
use LeadersLinked\Mapper\SurveyTestMapper;
|
|
|
55 |
use LeadersLinked\Mapper\SurveyCampaignMapper;
|
117 |
efrain |
56 |
use LeadersLinked\Mapper\GroupTypeMapper;
|
192 |
efrain |
57 |
use LeadersLinked\Mapper\FeedMapper;
|
|
|
58 |
use LeadersLinked\Model\Feed;
|
|
|
59 |
use LeadersLinked\Model\AbuseReport;
|
|
|
60 |
use LeadersLinked\Form\AbuseReport\CreateForm;
|
|
|
61 |
use LeadersLinked\Model\Post;
|
|
|
62 |
use LeadersLinked\Mapper\CommentMapper;
|
|
|
63 |
use LeadersLinked\Model\Comment;
|
|
|
64 |
use LeadersLinked\Mapper\AbuseReportMapper;
|
|
|
65 |
use LeadersLinked\Mapper\UserBlockedMapper;
|
|
|
66 |
use LeadersLinked\Model\UserBlocked;
|
269 |
efrain |
67 |
use LeadersLinked\Library\Storage;
|
626 |
stevensc |
68 |
use LeadersLinked\Mapper\MicrolearningTopicUserMapper;
|
710 |
stevensc |
69 |
use LeadersLinked\Mapper\MessageMapper;
|
|
|
70 |
use LeadersLinked\Model\Message;
|
1 |
efrain |
71 |
|
|
|
72 |
class HelperController extends AbstractActionController
|
|
|
73 |
{
|
283 |
www |
74 |
|
1 |
efrain |
75 |
/**
|
|
|
76 |
*
|
|
|
77 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
|
|
78 |
*/
|
|
|
79 |
private $adapter;
|
|
|
80 |
|
|
|
81 |
/**
|
|
|
82 |
*
|
|
|
83 |
* @var \LeadersLinked\Cache\CacheInterface
|
|
|
84 |
*/
|
|
|
85 |
private $cache;
|
|
|
86 |
|
|
|
87 |
|
|
|
88 |
/**
|
|
|
89 |
*
|
|
|
90 |
* @var \Laminas\Log\LoggerInterface
|
|
|
91 |
*/
|
|
|
92 |
private $logger;
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
*
|
|
|
96 |
* @var array
|
|
|
97 |
*/
|
|
|
98 |
private $config;
|
|
|
99 |
|
|
|
100 |
|
|
|
101 |
/**
|
|
|
102 |
*
|
|
|
103 |
* @var \Laminas\Mvc\I18n\Translator
|
|
|
104 |
*/
|
|
|
105 |
private $translator;
|
|
|
106 |
|
|
|
107 |
|
|
|
108 |
/**
|
|
|
109 |
*
|
|
|
110 |
* @var array
|
|
|
111 |
*/
|
|
|
112 |
private $navigation;
|
|
|
113 |
|
|
|
114 |
/**
|
|
|
115 |
*
|
|
|
116 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
|
|
117 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
|
|
118 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
|
|
119 |
* @param array $config
|
|
|
120 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
|
|
121 |
* @param array $navigation
|
|
|
122 |
*/
|
|
|
123 |
public function __construct($adapter, $cache, $logger, $config, $translator, $navigation)
|
|
|
124 |
{
|
|
|
125 |
$this->adapter = $adapter;
|
|
|
126 |
$this->cache = $cache;
|
|
|
127 |
$this->logger = $logger;
|
|
|
128 |
$this->config = $config;
|
|
|
129 |
$this->translator = $translator;
|
|
|
130 |
$this->navigation = $navigation;
|
|
|
131 |
}
|
|
|
132 |
|
|
|
133 |
|
|
|
134 |
/**
|
|
|
135 |
* Recuperamos las personas que pueda conocer
|
|
|
136 |
* tiene que enviarse un petición GET a la siguiente url: /helpers/people-you-may-know
|
|
|
137 |
* retorna un json en caso de ser positivo
|
|
|
138 |
* [
|
|
|
139 |
* 'success' : true,
|
|
|
140 |
* 'data' : [
|
|
|
141 |
* [
|
|
|
142 |
* 'id' => 'id del usuario encriptado',
|
|
|
143 |
* 'name' => 'nombre del usuario',
|
|
|
144 |
* 'image' => 'imagen del usuario',
|
|
|
145 |
* 'profile' => 'url del profile',
|
|
|
146 |
* ]
|
|
|
147 |
* ]
|
|
|
148 |
* En caso de ser negativo
|
|
|
149 |
* [
|
|
|
150 |
* 'success' : false,
|
|
|
151 |
* 'data' : mensaje de error
|
|
|
152 |
* ]
|
|
|
153 |
* @return \Laminas\View\Model\JsonModel
|
|
|
154 |
*/
|
|
|
155 |
public function peopleYouMayKnowAction()
|
|
|
156 |
{
|
|
|
157 |
$request = $this->getRequest();
|
|
|
158 |
if ($request->isGet()) {
|
|
|
159 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
160 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
161 |
|
|
|
162 |
$connectionMapper = ConnectionMapper::getInstance($this->adapter);
|
|
|
163 |
$first_degree_connections_ids = $connectionMapper->fetchAllConnectionsByUserReturnIds($currentUser->id);
|
|
|
164 |
$first_degree_connections_ids = $first_degree_connections_ids ? $first_degree_connections_ids : [0];
|
|
|
165 |
|
|
|
166 |
$second_degree_connections_ids = $connectionMapper->fetchAllSecondDegreeConnectionsForUserIdReturnIds($currentUser->id);
|
|
|
167 |
$second_degree_connections_ids = $second_degree_connections_ids ? $second_degree_connections_ids : [0];
|
|
|
168 |
|
|
|
169 |
/*Usuarios de la empresas donde trabajo o soy dueño */
|
|
|
170 |
$company_user_ids = [];
|
|
|
171 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
172 |
|
|
|
173 |
$records = $companyUserMapper->fetchAllByUserId($currentUser->id);
|
|
|
174 |
foreach ($records as $record) {
|
|
|
175 |
|
|
|
176 |
if ($record->status != CompanyUser::STATUS_ACCEPTED) {
|
|
|
177 |
continue;
|
|
|
178 |
}
|
|
|
179 |
|
|
|
180 |
$otherUsers = $companyUserMapper->fetchAllByCompanyId($record->company_id);
|
|
|
181 |
foreach ($otherUsers as $otherUser) {
|
|
|
182 |
if ($currentUser->id != $otherUser->user_id && $otherUser->creator == CompanyUser::CREATOR_NO && $otherUser->status == CompanyUser::STATUS_ACCEPTED) {
|
|
|
183 |
|
|
|
184 |
if (!in_array($otherUser->user_id, $company_user_ids)) {
|
|
|
185 |
array_push($company_user_ids, $otherUser->user_id);
|
|
|
186 |
}
|
|
|
187 |
}
|
|
|
188 |
}
|
|
|
189 |
}
|
|
|
190 |
$company_user_ids = $company_user_ids ? $company_user_ids : [0];
|
|
|
191 |
|
|
|
192 |
/* Usuario de los grupos donde soy dueño o participo */
|
|
|
193 |
|
|
|
194 |
$groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
195 |
|
|
|
196 |
$group_member_ids = [];
|
|
|
197 |
|
|
|
198 |
$records = $groupMemberMapper->fetchAllByUserId($currentUser->id);
|
|
|
199 |
foreach ($records as $record) {
|
|
|
200 |
if ($record->status != GroupMember::STATUS_ACCEPTED) {
|
|
|
201 |
continue;
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
$otherUsers = $groupMemberMapper->fetchAllByGroupId($record->group_id);
|
|
|
205 |
foreach ($otherUsers as $otherUser) {
|
|
|
206 |
if ($currentUser->id != $otherUser->user_id && $otherUser->status == GroupMember::STATUS_ACCEPTED) {
|
|
|
207 |
|
|
|
208 |
if (!in_array($otherUser->user_id, $group_member_ids)) {
|
|
|
209 |
array_push($group_member_ids, $otherUser->user_id);
|
|
|
210 |
}
|
|
|
211 |
}
|
|
|
212 |
}
|
|
|
213 |
}
|
|
|
214 |
|
|
|
215 |
$group_member_ids = $group_member_ids ? $group_member_ids : [0];
|
|
|
216 |
|
|
|
217 |
|
|
|
218 |
|
626 |
stevensc |
219 |
/* Usuarios con que comparto topicos */
|
|
|
220 |
$topic_user_ids = [];
|
|
|
221 |
$topicUserMapper = MicrolearningTopicUserMapper::getInstance($this->adapter);
|
1 |
efrain |
222 |
|
|
|
223 |
$company_ids = [];
|
626 |
stevensc |
224 |
$records = $topicUserMapper->fetchAllActiveByUserId($currentUser->id);
|
1 |
efrain |
225 |
foreach ($records as $record) {
|
|
|
226 |
if (!in_array($record->company_id, $company_ids)) {
|
|
|
227 |
array_push($company_ids, $record->company_id);
|
|
|
228 |
}
|
|
|
229 |
}
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
foreach ($company_ids as $company_id) {
|
626 |
stevensc |
234 |
$otherUsers = $topicUserMapper->fetchAllUserIdsForTopicsActiveByCompanyId($company_id);
|
1 |
efrain |
235 |
foreach ($otherUsers as $user_id) {
|
|
|
236 |
if ($currentUser->id != $user_id) {
|
|
|
237 |
|
626 |
stevensc |
238 |
if (!in_array($user_id, $topic_user_ids)) {
|
|
|
239 |
array_push($topic_user_ids, $user_id);
|
1 |
efrain |
240 |
}
|
|
|
241 |
}
|
|
|
242 |
}
|
|
|
243 |
}
|
|
|
244 |
|
626 |
stevensc |
245 |
$topic_user_ids = $topic_user_ids ? $topic_user_ids : [0];
|
1 |
efrain |
246 |
|
|
|
247 |
|
|
|
248 |
$other_users = array_unique(array_merge(
|
|
|
249 |
$second_degree_connections_ids,
|
|
|
250 |
$company_user_ids,
|
|
|
251 |
$group_member_ids,
|
626 |
stevensc |
252 |
$topic_user_ids
|
1 |
efrain |
253 |
));
|
|
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
|
260 |
|
|
|
261 |
|
|
|
262 |
$items = [];
|
|
|
263 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
264 |
$select = $queryMapper->getSql()->select();
|
|
|
265 |
$select->columns(['id', 'uuid', 'first_name', 'last_name', 'image']);
|
|
|
266 |
$select->from(['u' => UserMapper::_TABLE]);
|
|
|
267 |
$select->join(['up' => UserProfileMapper::_TABLE], 'up.user_id = u.id ', ['description']);
|
|
|
268 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
269 |
$select->where->in('u.id', $other_users);
|
|
|
270 |
$select->where->notIn('u.id', $first_degree_connections_ids);
|
|
|
271 |
$select->where->notEqualTo('u.id', $currentUser->id);
|
|
|
272 |
$select->where->equalTo('u.status', User::STATUS_ACTIVE);
|
|
|
273 |
$select->where->in('u.usertype_id', [UserType::ADMIN, UserType::USER]);
|
|
|
274 |
$select->order(['first_name', 'last_name']);
|
|
|
275 |
|
|
|
276 |
//echo $select->getSqlString($this->adapter->platform); exit;
|
|
|
277 |
|
333 |
www |
278 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
283 |
www |
279 |
|
269 |
efrain |
280 |
|
1 |
efrain |
281 |
$records = $queryMapper->fetchAll($select);
|
|
|
282 |
foreach ($records as $record) {
|
|
|
283 |
|
|
|
284 |
$relation = [];
|
|
|
285 |
if (in_array($record['id'], $second_degree_connections_ids)) {
|
|
|
286 |
array_push($relation, 'LABEL_RELATION_TYPE_SECOND_GRADE');
|
|
|
287 |
}
|
|
|
288 |
if (in_array($record['id'], $company_user_ids)) {
|
|
|
289 |
array_push($relation, 'LABEL_RELATION_TYPE_COMPANY_USER');
|
|
|
290 |
}
|
|
|
291 |
if (in_array($record['id'], $group_member_ids)) {
|
|
|
292 |
array_push($relation, 'LABEL_RELATION_TYPE_GROUP_MEMBER');
|
|
|
293 |
}
|
626 |
stevensc |
294 |
if (in_array($record['id'], $topic_user_ids)) {
|
|
|
295 |
array_push($relation, 'LABEL_RELATION_TYPE_TOPIC_USER');
|
1 |
efrain |
296 |
}
|
|
|
297 |
|
|
|
298 |
|
|
|
299 |
$connection = $connectionMapper->fetchOneByUserId1AndUserId2($currentUser->id, $record['id']);
|
|
|
300 |
|
|
|
301 |
$item = [
|
|
|
302 |
'id' => $record['uuid'],
|
|
|
303 |
'name' => trim($record['first_name'] . ' ' . $record['last_name']),
|
283 |
www |
304 |
'image' => $storage->getUserImageForCodeAndFilename($record['uuid'], $record['image']),
|
1 |
efrain |
305 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
|
|
|
306 |
'relation' => $relation,
|
|
|
307 |
'link_cancel' => '',
|
|
|
308 |
'link_request' => '',
|
|
|
309 |
'user_profile' => $record['description'],
|
|
|
310 |
];
|
|
|
311 |
|
|
|
312 |
if ($connection) {
|
|
|
313 |
switch ($connection->status) {
|
|
|
314 |
case Connection::STATUS_SENT:
|
|
|
315 |
$item['link_cancel'] = $this->url()->fromRoute('connection/delete', ['id' => $record['uuid']]);
|
|
|
316 |
break;
|
|
|
317 |
|
|
|
318 |
case Connection::STATUS_ACCEPTED:
|
|
|
319 |
$item['link_cancel'] = $this->url()->fromRoute('connection/cancel', ['id' => $record['uuid']]);
|
|
|
320 |
break;
|
|
|
321 |
|
|
|
322 |
default:
|
|
|
323 |
$item['link_request'] = $this->url()->fromRoute('connection/request', ['id' => $record['uuid']]);
|
|
|
324 |
break;
|
|
|
325 |
}
|
|
|
326 |
} else {
|
|
|
327 |
$item['link_request'] = $this->url()->fromRoute('connection/request', ['id' => $record['uuid']]);
|
|
|
328 |
}
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
array_push($items, $item);
|
|
|
332 |
}
|
|
|
333 |
|
|
|
334 |
return new JsonModel([
|
|
|
335 |
'success' => true,
|
|
|
336 |
'data' => $items
|
|
|
337 |
]);
|
|
|
338 |
} else {
|
|
|
339 |
return new JsonModel([
|
|
|
340 |
'success' => false,
|
|
|
341 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
342 |
]);
|
|
|
343 |
}
|
|
|
344 |
}
|
|
|
345 |
|
|
|
346 |
/**
|
|
|
347 |
* Recuperamos las personas que pueda conocer
|
|
|
348 |
* tiene que enviarse un petición GET a la siguiente url: /helpers/people-viewed-profile/:user_profile_id
|
|
|
349 |
* retorna un json en caso de ser positivo
|
|
|
350 |
* [
|
|
|
351 |
* 'success' : true,
|
|
|
352 |
* 'data' : [
|
|
|
353 |
* [
|
|
|
354 |
* 'id' => 'id del usuario encriptado',
|
|
|
355 |
* 'name' => 'nombre del usuario',
|
|
|
356 |
* 'image' => 'imagen del usuario',
|
|
|
357 |
* 'profile' => 'url del profile',
|
|
|
358 |
* ]
|
|
|
359 |
* ]
|
|
|
360 |
* En caso de ser negativo
|
|
|
361 |
* [
|
|
|
362 |
* 'success' : false,
|
|
|
363 |
* 'data' : mensaje de error
|
|
|
364 |
* ]
|
|
|
365 |
* @return \Laminas\View\Model\JsonModel
|
|
|
366 |
*/
|
|
|
367 |
public function peopleViewedProfileAction()
|
|
|
368 |
{
|
|
|
369 |
$request = $this->getRequest();
|
|
|
370 |
if ($request->isGet()) {
|
|
|
371 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
372 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
373 |
|
|
|
374 |
$items = [];
|
|
|
375 |
$user_profile_id = $this->params()->fromRoute('user_profile_id');
|
|
|
376 |
|
|
|
377 |
$items = [];
|
|
|
378 |
|
|
|
379 |
$mapper = QueryMapper::getInstance($this->adapter);
|
|
|
380 |
$select = $mapper->getSql()->select(ProfileVisitMapper::_TABLE);
|
|
|
381 |
$select->columns(['user_id' => new Expression('DISTINCT(visitor_id)')]);
|
|
|
382 |
$select->where->equalTo('user_profile_id', $user_profile_id);
|
|
|
383 |
$records = $mapper->fetchAll($select);
|
|
|
384 |
|
|
|
385 |
if ($records) {
|
|
|
386 |
|
|
|
387 |
$user_ids = [];
|
|
|
388 |
foreach ($records as $record) {
|
|
|
389 |
array_push($user_ids, $record['user_id']);
|
|
|
390 |
}
|
|
|
391 |
|
|
|
392 |
$mapper = QueryMapper::getInstance($this->adapter);
|
|
|
393 |
$select = $mapper->getSql()->select(UserMapper::_TABLE);
|
|
|
394 |
$select->columns(['id', 'uuid', 'first_name', 'last_name', 'image']);
|
|
|
395 |
$select->where->in('id', $user_ids);
|
|
|
396 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
397 |
$select->where->equalTo('status', User::STATUS_ACTIVE);
|
|
|
398 |
$select->order(['last_name ASC', 'first_name ASC']);
|
|
|
399 |
|
333 |
www |
400 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
283 |
www |
401 |
|
269 |
efrain |
402 |
|
1 |
efrain |
403 |
$records = $mapper->fetchAll($select);
|
|
|
404 |
foreach ($records as $record) {
|
|
|
405 |
array_push($items, [
|
|
|
406 |
'id' => $record['uuid'],
|
|
|
407 |
'name' => trim($record['first_name'] . ' ' . $record['last_name']),
|
283 |
www |
408 |
'image' => $storage->getUserImageForCodeAndFilename($record['uuid'], $record['image']),
|
1 |
efrain |
409 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
|
281 |
efrain |
410 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
|
1 |
efrain |
411 |
]);
|
|
|
412 |
}
|
|
|
413 |
}
|
|
|
414 |
|
|
|
415 |
|
|
|
416 |
return new JsonModel([
|
|
|
417 |
'success' => true,
|
|
|
418 |
'data' => $items
|
|
|
419 |
]);
|
|
|
420 |
} else {
|
|
|
421 |
return new JsonModel([
|
|
|
422 |
'success' => false,
|
|
|
423 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
424 |
]);
|
|
|
425 |
}
|
|
|
426 |
}
|
|
|
427 |
|
|
|
428 |
|
|
|
429 |
/**
|
|
|
430 |
* Recuperamos los seguidores de la empresa
|
|
|
431 |
* tiene que enviarse un petición GET a la siguiente url: /helpers/company-follower/:company_id
|
|
|
432 |
* retorna un json en caso de ser positivo
|
|
|
433 |
* [
|
|
|
434 |
* 'success' : true,
|
|
|
435 |
* 'data' : [
|
|
|
436 |
* [
|
|
|
437 |
* 'id' => 'id del usuario encriptado',
|
|
|
438 |
* 'name' => 'nombre del usuario',
|
|
|
439 |
* 'image' => 'imagen del usuario',
|
|
|
440 |
* 'profile' => 'url del profile',
|
|
|
441 |
* ]
|
|
|
442 |
* ]
|
|
|
443 |
* En caso de ser negativo
|
|
|
444 |
* [
|
|
|
445 |
* 'success' : false,
|
|
|
446 |
* 'data' : mensaje de error
|
|
|
447 |
* ]
|
|
|
448 |
* @return \Laminas\View\Model\JsonModel
|
|
|
449 |
*/
|
|
|
450 |
public function companyFollowerAction()
|
|
|
451 |
{
|
|
|
452 |
|
|
|
453 |
|
|
|
454 |
$request = $this->getRequest();
|
|
|
455 |
if ($request->isGet()) {
|
|
|
456 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
457 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
458 |
|
|
|
459 |
$company_uuid = $this->params()->fromRoute('company_id');
|
|
|
460 |
|
|
|
461 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
462 |
$company = $companyMapper->fetchOneByUuidAndNetworkId($company_uuid, $currentUser->network_id);
|
|
|
463 |
|
|
|
464 |
$items = [];
|
|
|
465 |
if ($company && $company->status == Company::STATUS_ACTIVE) {
|
|
|
466 |
|
|
|
467 |
$companyFollowerMapper = CompanyFollowerMapper::getInstance($this->adapter);
|
|
|
468 |
$records = $companyFollowerMapper->fetchAllByCompanyId($company->id);
|
|
|
469 |
|
|
|
470 |
$ids = [];
|
|
|
471 |
foreach ($records as $record) {
|
|
|
472 |
if (!in_array($record->follower_id, $ids)) {
|
|
|
473 |
array_push($ids, $record->follower_id);
|
|
|
474 |
}
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
if ($ids) {
|
|
|
478 |
|
|
|
479 |
$mapper = QueryMapper::getInstance($this->adapter);
|
|
|
480 |
$select = $mapper->getSql()->select(UserMapper::_TABLE);
|
|
|
481 |
$select->columns(['id', 'uuid', 'first_name', 'last_name', 'image']);
|
|
|
482 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
483 |
$select->where->in('id', $ids);
|
|
|
484 |
$select->where->equalTo('status', User::STATUS_ACTIVE);
|
|
|
485 |
$select->order(['last_name', 'first_name']);
|
|
|
486 |
|
|
|
487 |
//echo $select->getSqlString($this->adapter->platform); exit;
|
|
|
488 |
|
|
|
489 |
|
333 |
www |
490 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
1 |
efrain |
491 |
|
|
|
492 |
$records = $mapper->fetchAll($select);
|
|
|
493 |
foreach ($records as $record) {
|
|
|
494 |
|
|
|
495 |
|
|
|
496 |
array_push($items, [
|
|
|
497 |
'id' => $record['uuid'],
|
|
|
498 |
'name' => trim($record['first_name'] . ' ' . $record['last_name']),
|
283 |
www |
499 |
'image' => $storage->getUserImageForCodeAndFilename($record['uuid'], $record['image']),
|
1 |
efrain |
500 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
|
|
|
501 |
]);
|
|
|
502 |
}
|
|
|
503 |
}
|
|
|
504 |
}
|
|
|
505 |
|
|
|
506 |
return new JsonModel([
|
|
|
507 |
'success' => true,
|
|
|
508 |
'data' => $items
|
|
|
509 |
]);
|
|
|
510 |
} else {
|
|
|
511 |
return new JsonModel([
|
|
|
512 |
'success' => false,
|
|
|
513 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
514 |
]);
|
|
|
515 |
}
|
|
|
516 |
}
|
|
|
517 |
|
|
|
518 |
public function companySuggestionAction()
|
|
|
519 |
{
|
|
|
520 |
$request = $this->getRequest();
|
|
|
521 |
if ($request->isGet()) {
|
|
|
522 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
523 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
524 |
|
|
|
525 |
$company_uuid = $this->params()->fromRoute('company_id');
|
|
|
526 |
|
|
|
527 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
528 |
$company = $companyMapper->fetchOneByUuidAndNetworkId($company_uuid, $currentUser->network_id);
|
|
|
529 |
|
|
|
530 |
$items = [];
|
|
|
531 |
if ($company && $company->status == Company::STATUS_ACTIVE) {
|
|
|
532 |
|
|
|
533 |
|
|
|
534 |
$mapper = QueryMapper::getInstance($this->adapter);
|
|
|
535 |
$select = $mapper->getSql()->select(CompanyMapper::_TABLE);
|
|
|
536 |
$select->columns(['id', 'uuid', 'name', 'image']);
|
|
|
537 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
538 |
$select->where->notEqualTo('id', $company->id);
|
|
|
539 |
$select->where->equalTo('status', Company::STATUS_ACTIVE);
|
|
|
540 |
$select->where->equalTo('industry_id', $company->industry_id);
|
|
|
541 |
// $select->where->equalTo('company_size_id', $company->company_size_id);
|
|
|
542 |
$select->order(['name']);
|
|
|
543 |
|
|
|
544 |
|
|
|
545 |
//echo $select->getSqlString($this->adapter->platform); exit;
|
|
|
546 |
|
333 |
www |
547 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
283 |
www |
548 |
|
269 |
efrain |
549 |
|
1 |
efrain |
550 |
$records = $mapper->fetchAll($select);
|
|
|
551 |
foreach ($records as $record) {
|
|
|
552 |
array_push($items, [
|
|
|
553 |
'id' => $record['uuid'],
|
|
|
554 |
'name' => trim($record['name']),
|
283 |
www |
555 |
'image' => $storage->getCompanyImageForCodeAndFilename($record['uuid'], $record['image']) ,
|
1 |
efrain |
556 |
'profile' => $this->url()->fromRoute('company/view', ['id' => $record['uuid']]),
|
|
|
557 |
]);
|
|
|
558 |
}
|
|
|
559 |
}
|
|
|
560 |
|
|
|
561 |
return new JsonModel([
|
|
|
562 |
'success' => true,
|
|
|
563 |
'data' => $items
|
|
|
564 |
]);
|
|
|
565 |
} else {
|
|
|
566 |
return new JsonModel([
|
|
|
567 |
'success' => false,
|
|
|
568 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
569 |
]);
|
|
|
570 |
}
|
|
|
571 |
}
|
|
|
572 |
|
|
|
573 |
/**
|
|
|
574 |
* Recuperamos los miembros del grupo
|
|
|
575 |
* tiene que enviarse un petición GET a la siguiente url: /helpers/group-members/:group_id
|
|
|
576 |
* retorna un json en caso de ser positivo
|
|
|
577 |
* [
|
|
|
578 |
* 'success' : true,
|
|
|
579 |
* 'data' : [
|
|
|
580 |
* [
|
|
|
581 |
* 'id' => 'id del usuario encriptado',
|
|
|
582 |
* 'name' => 'nombre del usuario',
|
|
|
583 |
* 'image' => 'imagen del usuario',
|
|
|
584 |
* 'profile' => 'url del profile',
|
|
|
585 |
* ]
|
|
|
586 |
* ]
|
|
|
587 |
* En caso de ser negativo
|
|
|
588 |
* [
|
|
|
589 |
* 'success' : false,
|
|
|
590 |
* 'data' : mensaje de error
|
|
|
591 |
* ]
|
|
|
592 |
* @return \Laminas\View\Model\JsonModel
|
|
|
593 |
*/
|
|
|
594 |
public function groupMembersAction()
|
|
|
595 |
{
|
|
|
596 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
597 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
598 |
|
|
|
599 |
$request = $this->getRequest();
|
|
|
600 |
if ($request->isGet()) {
|
|
|
601 |
|
|
|
602 |
$group_uuid = $this->params()->fromRoute('group_id');
|
|
|
603 |
|
|
|
604 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
605 |
$group = $groupMapper->fetchOneByUuidAndNetworkId($group_uuid, $currentUser->network_id);
|
|
|
606 |
|
|
|
607 |
$items = [];
|
|
|
608 |
if ($group && $group->status == Group::STATUS_ACTIVE) {
|
|
|
609 |
|
|
|
610 |
$mapper = QueryMapper::getInstance($this->adapter);
|
|
|
611 |
$select = $mapper->getSql()->select();
|
|
|
612 |
$select->columns(['id', 'uuid', 'first_name', 'last_name', 'image']);
|
|
|
613 |
$select->from(['u' => UserMapper::_TABLE]);
|
|
|
614 |
$select->join(['gm' => GroupMemberMapper::_TABLE], 'gm.user_id = u.id ', ['user_id', 'status']);
|
|
|
615 |
$select->join(['g' => GroupMapper::_TABLE], 'gm.group_id = g.id', ['group_uuid' => 'uuid']);
|
|
|
616 |
$select->where->equalTo('u.network_id', $currentUser->network_id);
|
|
|
617 |
$select->where->equalTo('g.network_id', $currentUser->network_id);
|
|
|
618 |
$select->where->equalTo('g.uuid', $group_uuid);
|
|
|
619 |
|
|
|
620 |
if ($group->user_id == $currentUser->id) {
|
|
|
621 |
$select->where->in('gm.status', [
|
|
|
622 |
GroupMember::STATUS_ACCEPTED,
|
|
|
623 |
GroupMember::STATUS_ADDED_BY_ADMIN,
|
|
|
624 |
GroupMember::STATUS_AUTO_JOIN,
|
|
|
625 |
GroupMember::STATUS_JOINING_REQUESTED,
|
|
|
626 |
]);
|
|
|
627 |
} else {
|
|
|
628 |
$select->where->in('gm.status', [GroupMember::STATUS_ACCEPTED, GroupMember::STATUS_AUTO_JOIN]);
|
|
|
629 |
}
|
|
|
630 |
|
|
|
631 |
|
|
|
632 |
$select->where->equalTo('u.status', User::STATUS_ACTIVE);
|
|
|
633 |
$select->order(['last_name', 'first_name']);
|
|
|
634 |
|
|
|
635 |
//echo $select->getSqlString($this->adapter->platform);
|
|
|
636 |
|
|
|
637 |
|
333 |
www |
638 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
1 |
efrain |
639 |
|
|
|
640 |
|
|
|
641 |
$records = $mapper->fetchAll($select);
|
|
|
642 |
foreach ($records as $record) {
|
|
|
643 |
|
|
|
644 |
$actions = [];
|
|
|
645 |
if ($group->user_id == $currentUser->id) {
|
|
|
646 |
if ($record['id'] != $currentUser->id) {
|
|
|
647 |
|
|
|
648 |
|
|
|
649 |
|
|
|
650 |
switch ($record['status']) {
|
|
|
651 |
case GroupMember::STATUS_JOINING_REQUESTED:
|
|
|
652 |
$actions['link_approve'] = $this->url()->fromRoute('helpers/group-members/approve', ['group_id' => $group->uuid, 'user_id' => $record['uuid']]);
|
|
|
653 |
$actions['link_reject'] = $this->url()->fromRoute('helpers/group-members/reject', ['group_id' => $group->uuid, 'user_id' => $record['uuid']]);
|
|
|
654 |
break;
|
|
|
655 |
|
|
|
656 |
case GroupMember::STATUS_ACCEPTED:
|
|
|
657 |
case GroupMember::STATUS_AUTO_JOIN:
|
|
|
658 |
case GroupMember::STATUS_ADDED_BY_ADMIN:
|
|
|
659 |
$actions['link_cancel'] = $this->url()->fromRoute('helpers/group-members/cancel', ['group_id' => $group->uuid, 'user_id' => $record['uuid']]);
|
|
|
660 |
break;
|
|
|
661 |
}
|
|
|
662 |
}
|
|
|
663 |
}
|
|
|
664 |
|
|
|
665 |
array_push($items, [
|
|
|
666 |
'id' => $record['uuid'],
|
|
|
667 |
'name' => trim($record['first_name'] . ' ' . $record['last_name']),
|
283 |
www |
668 |
'image' => $storage->getGroupImageForCodeAndFilename($record['uuid'], $record['image']),
|
1 |
efrain |
669 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $record['uuid']]),
|
|
|
670 |
'actions' => $actions,
|
|
|
671 |
|
|
|
672 |
]);
|
|
|
673 |
}
|
|
|
674 |
}
|
|
|
675 |
|
|
|
676 |
return new JsonModel([
|
|
|
677 |
'success' => true,
|
|
|
678 |
'data' => [
|
|
|
679 |
'items' => $items,
|
|
|
680 |
'link_invite' => $group->user_id == $currentUser->id ? $this->url()->fromRoute('helpers/group-members/invite', ['group_id' => $group->uuid]) : '',
|
|
|
681 |
]
|
|
|
682 |
]);
|
|
|
683 |
} else {
|
|
|
684 |
return new JsonModel([
|
|
|
685 |
'success' => false,
|
|
|
686 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
687 |
]);
|
|
|
688 |
}
|
|
|
689 |
}
|
|
|
690 |
|
|
|
691 |
public function groupMemberInviteAction()
|
|
|
692 |
{
|
|
|
693 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
694 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
695 |
|
|
|
696 |
$group_uuid = $this->params()->fromRoute('group_id');
|
|
|
697 |
|
|
|
698 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
699 |
$group = $groupMapper->fetchOneByUuidAndNetworkId($group_uuid, $currentUser->network_id);
|
|
|
700 |
|
|
|
701 |
if (!$group) {
|
|
|
702 |
return new JsonModel([
|
|
|
703 |
'success' => false,
|
|
|
704 |
'data' => 'ERROR_GROUP_NOT_FOUND'
|
|
|
705 |
]);
|
|
|
706 |
}
|
|
|
707 |
|
|
|
708 |
if ($group->status != Group::STATUS_ACTIVE) {
|
|
|
709 |
return new JsonModel([
|
|
|
710 |
'success' => false,
|
|
|
711 |
'data' => 'ERROR_GROUP_IS_NOT_ACTIVE'
|
|
|
712 |
]);
|
|
|
713 |
}
|
|
|
714 |
|
|
|
715 |
if ($currentUser->id != $group->user_id) {
|
|
|
716 |
return new JsonModel([
|
|
|
717 |
'success' => false,
|
|
|
718 |
'data' => 'ERROR_GROUP_IS_NOT_YOU_ARE_THE_OWNER_OF_THIS_GROUP'
|
|
|
719 |
]);
|
|
|
720 |
}
|
|
|
721 |
|
|
|
722 |
|
|
|
723 |
$request = $this->getRequest();
|
|
|
724 |
if ($request->isGet()) {
|
|
|
725 |
$search = filter_var($this->params()->fromQuery('search', ''));
|
|
|
726 |
if (strlen($search) >= 3) {
|
|
|
727 |
|
|
|
728 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
729 |
$records = $userMapper->fetchAllSuggestForInvitationByGroupIdAndNetworkIdAndSearch($group->id, $currentUser->network_id, $search);
|
|
|
730 |
|
|
|
731 |
$users = [];
|
|
|
732 |
foreach ($records as $record) {
|
|
|
733 |
array_push($users, [
|
|
|
734 |
'value' => $record->uuid,
|
|
|
735 |
'text' => trim($record->first_name . ' ' . $record->last_name) . ' (' . $record->email . ')'
|
|
|
736 |
|
|
|
737 |
]);
|
|
|
738 |
}
|
|
|
739 |
|
|
|
740 |
return new JsonModel([
|
|
|
741 |
'success' => true,
|
|
|
742 |
'data' => $users
|
|
|
743 |
]);
|
|
|
744 |
} else {
|
|
|
745 |
return new JsonModel([
|
|
|
746 |
'success' => true,
|
|
|
747 |
'data' => []
|
|
|
748 |
]);
|
|
|
749 |
}
|
|
|
750 |
} else if ($request->isPost()) {
|
|
|
751 |
$uuid = $this->params()->fromPost('id');
|
|
|
752 |
if (!$uuid) {
|
|
|
753 |
return new JsonModel([
|
|
|
754 |
'success' => false,
|
|
|
755 |
'data' => 'ERROR_INVALID_PARAMETER'
|
|
|
756 |
]);
|
|
|
757 |
}
|
|
|
758 |
|
|
|
759 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
760 |
$user = $userMapper->fetchOneByUuidAndNetworkId($uuid, $currentUser->network_id);
|
|
|
761 |
|
|
|
762 |
if (!$user) {
|
|
|
763 |
return new JsonModel([
|
|
|
764 |
'success' => false,
|
|
|
765 |
'data' => 'ERROR_USER_NOT_FOUND'
|
|
|
766 |
]);
|
|
|
767 |
}
|
|
|
768 |
|
|
|
769 |
if ($user->status != User::STATUS_ACTIVE) {
|
|
|
770 |
return new JsonModel([
|
|
|
771 |
'success' => false,
|
|
|
772 |
'data' => 'ERROR_USER_IS_INACTIVE'
|
|
|
773 |
]);
|
|
|
774 |
}
|
|
|
775 |
|
|
|
776 |
if ($group->user_id == $user->id) {
|
|
|
777 |
return new JsonModel([
|
|
|
778 |
'success' => false,
|
|
|
779 |
'data' => 'ERROR_GROUP_YOU_ARE_THE_OWNER_OF_THIS_GROUP'
|
|
|
780 |
]);
|
|
|
781 |
}
|
|
|
782 |
|
|
|
783 |
$groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
784 |
$groupMember = $groupMemberMapper->fetchOneByGroupIdAndUserId($group->id, $user->id);
|
|
|
785 |
|
|
|
786 |
|
|
|
787 |
|
|
|
788 |
if ($groupMember) {
|
|
|
789 |
$result = false;
|
|
|
790 |
|
|
|
791 |
switch ($groupMember->status) {
|
|
|
792 |
case GroupMember::STATUS_ACCEPTED:
|
|
|
793 |
case GroupMember::STATUS_AUTO_JOIN:
|
|
|
794 |
|
|
|
795 |
return new JsonModel([
|
|
|
796 |
'success' => false,
|
|
|
797 |
'data' => 'ERROR_GROUP_YOU_ARE_MEMBER',
|
|
|
798 |
]);
|
|
|
799 |
break;
|
|
|
800 |
|
|
|
801 |
|
|
|
802 |
case $groupMember->status == GroupMember::STATUS_REJECTED:
|
|
|
803 |
case $groupMember->status == GroupMember::STATUS_CANCELLED:
|
|
|
804 |
|
|
|
805 |
$groupMember->status = GroupMember::STATUS_ADDED_BY_ADMIN;
|
|
|
806 |
$groupMember->joining_request_on = date('H-m-d H:i:s');
|
|
|
807 |
|
|
|
808 |
$result = $groupMemberMapper->update($groupMember);
|
|
|
809 |
break;
|
|
|
810 |
|
|
|
811 |
case GroupMember::STATUS_ADDED_BY_ADMIN:
|
|
|
812 |
case GroupMember::STATUS_JOINING_REQUESTED:
|
|
|
813 |
return new JsonModel([
|
|
|
814 |
'success' => false,
|
|
|
815 |
'data' => 'ERROR_GROUP_THERE_IS_A_PENDING_REQUEST'
|
|
|
816 |
]);
|
|
|
817 |
break;
|
|
|
818 |
|
|
|
819 |
default:
|
|
|
820 |
return new JsonModel([
|
|
|
821 |
'success' => false,
|
|
|
822 |
'data' => 'ERROR_UNKNOWN_OPERATION'
|
|
|
823 |
]);
|
|
|
824 |
break;
|
|
|
825 |
}
|
|
|
826 |
} else {
|
|
|
827 |
|
|
|
828 |
|
|
|
829 |
|
|
|
830 |
$groupMember = new GroupMember();
|
|
|
831 |
$groupMember->user_id = $user->id;
|
|
|
832 |
$groupMember->group_id = $group->id;
|
|
|
833 |
$groupMember->status = GroupMember::STATUS_ADDED_BY_ADMIN;
|
|
|
834 |
$groupMember->joining_request_on = date('H-m-d H:i:s');
|
|
|
835 |
|
|
|
836 |
$result = $groupMemberMapper->insert($groupMember);
|
|
|
837 |
}
|
|
|
838 |
|
|
|
839 |
if ($result) {
|
|
|
840 |
|
|
|
841 |
$notification = new Notification();
|
|
|
842 |
$notification->type = Notification::TYPE_RECEIVE_INVITATION_GROUP;
|
|
|
843 |
$notification->read = Notification::NO;
|
|
|
844 |
$notification->user_id = $user->id;
|
|
|
845 |
$notification->group_id = $group->id;
|
|
|
846 |
$notification->message = 'LABEL_NOTIFICATION_RECEIVE_INVITATION_GROUP';
|
|
|
847 |
$notification->url = $this->url()->fromRoute('group/view', ['id' => $group->uuid]);
|
|
|
848 |
|
|
|
849 |
$notificationMapper = NotificationMapper::getInstance($this->adapter);
|
|
|
850 |
$notificationMapper->insert($notification);
|
|
|
851 |
|
|
|
852 |
$userNotificationMapper = UserNotificationSettingMapper::getInstance($this->adapter);
|
|
|
853 |
$userNotification = $userNotificationMapper->fetchOne($user->id);
|
|
|
854 |
|
|
|
855 |
if ($userNotification && $userNotification->receive_invitation_group) {
|
|
|
856 |
$emailTemplateMapper = EmailTemplateMapper::getInstance($this->adapter);
|
|
|
857 |
$emailTemplate = $emailTemplateMapper->fetchOneByCodeAndNetworkId(EmailTemplate::CODE_RECEIVE_INVITATION_GROUP, $currentUser->network_id);
|
|
|
858 |
|
|
|
859 |
if ($emailTemplate) {
|
|
|
860 |
$arrayCont = [
|
|
|
861 |
'firstname' => $currentUser->first_name,
|
|
|
862 |
'lastname' => $currentUser->last_name,
|
|
|
863 |
'other_user_firstname' => $user->first_name,
|
|
|
864 |
'other_user_lastname' => $user->last_name,
|
|
|
865 |
'company_name' => '',
|
|
|
866 |
'group_name' => $group->name,
|
|
|
867 |
'content' => '',
|
|
|
868 |
'code' => '',
|
|
|
869 |
'link' => $this->url()->fromRoute('group/view', ['id' => $group->uuid], ['force_canonical' => true])
|
|
|
870 |
];
|
|
|
871 |
|
|
|
872 |
$email = new QueueEmail($this->adapter);
|
|
|
873 |
$email->processEmailTemplate($emailTemplate, $arrayCont, $user->email, trim($user->first_name . ' ' . $user->last_name));
|
|
|
874 |
}
|
|
|
875 |
}
|
|
|
876 |
|
|
|
877 |
return new JsonModel([
|
|
|
878 |
'success' => true,
|
|
|
879 |
'data' => 'LABEL_GROUP_REQUEST_SUCCESS'
|
|
|
880 |
]);
|
|
|
881 |
} else {
|
|
|
882 |
|
|
|
883 |
return new JsonModel([
|
|
|
884 |
'success' => false,
|
|
|
885 |
'data' => 'ERROR_GROUP_REQUEST_COULD_NOT_BE_SENT'
|
|
|
886 |
]);
|
|
|
887 |
}
|
|
|
888 |
} else {
|
|
|
889 |
return new JsonModel([
|
|
|
890 |
'success' => false,
|
|
|
891 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
892 |
]);
|
|
|
893 |
}
|
|
|
894 |
}
|
|
|
895 |
|
|
|
896 |
public function groupMemberCancelAction()
|
|
|
897 |
{
|
|
|
898 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
899 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
900 |
|
|
|
901 |
$request = $this->getRequest();
|
|
|
902 |
if ($request->isPost()) {
|
|
|
903 |
$group_uuid = $this->params()->fromRoute('group_id');
|
|
|
904 |
$user_uuid = $this->params()->fromRoute('user_id');
|
|
|
905 |
|
|
|
906 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
907 |
$group = $groupMapper->fetchOneByUuidAndNetworkId($group_uuid, $currentUser->network_id);
|
|
|
908 |
|
|
|
909 |
if (!$group) {
|
|
|
910 |
return new JsonModel([
|
|
|
911 |
'success' => false,
|
|
|
912 |
'data' => 'ERROR_GROUP_NOT_FOUND'
|
|
|
913 |
]);
|
|
|
914 |
}
|
|
|
915 |
|
|
|
916 |
if ($group->status != Group::STATUS_ACTIVE) {
|
|
|
917 |
return new JsonModel([
|
|
|
918 |
'success' => false,
|
|
|
919 |
'data' => 'ERROR_GROUP_IS_NOT_ACTIVE'
|
|
|
920 |
]);
|
|
|
921 |
}
|
|
|
922 |
|
|
|
923 |
if ($currentUser->id != $group->user_id) {
|
|
|
924 |
return new JsonModel([
|
|
|
925 |
'success' => false,
|
|
|
926 |
'data' => 'ERROR_GROUP_IS_NOT_YOU_ARE_THE_OWNER_OF_THIS_GROUP'
|
|
|
927 |
]);
|
|
|
928 |
}
|
|
|
929 |
|
|
|
930 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
931 |
$user = $userMapper->fetchOneByUuidAndNetworkId($user_uuid, $currentUser->network_id);
|
|
|
932 |
|
|
|
933 |
if (!$user) {
|
|
|
934 |
return new JsonModel([
|
|
|
935 |
'success' => false,
|
|
|
936 |
'data' => 'ERROR_USER_NOT_FOUND'
|
|
|
937 |
]);
|
|
|
938 |
}
|
|
|
939 |
|
|
|
940 |
if ($user->id == $currentUser->id) {
|
|
|
941 |
return new JsonModel([
|
|
|
942 |
'success' => false,
|
|
|
943 |
'data' => 'ERROR_GROUP_YOU_ARE_THE_OWNER_OF_THIS_GROUP'
|
|
|
944 |
]);
|
|
|
945 |
}
|
|
|
946 |
|
|
|
947 |
|
|
|
948 |
|
|
|
949 |
$groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
950 |
$groupMember = $groupMemberMapper->fetchOneByGroupIdAndUserId($group->id, $user->id);
|
|
|
951 |
if ($groupMember) {
|
|
|
952 |
|
|
|
953 |
if (
|
|
|
954 |
$groupMember->status == GroupMember::STATUS_ACCEPTED ||
|
|
|
955 |
$groupMember->status == GroupMember::STATUS_ADDED_BY_ADMIN ||
|
|
|
956 |
$groupMember->status == GroupMember::STATUS_AUTO_JOIN
|
|
|
957 |
) {
|
|
|
958 |
|
|
|
959 |
$groupMember->status = GroupMember::STATUS_CANCELLED;
|
|
|
960 |
if ($groupMemberMapper->update($groupMember)) {
|
|
|
961 |
|
|
|
962 |
return new JsonModel([
|
|
|
963 |
'success' => true,
|
|
|
964 |
'data' => 'LABEL_GROUP_MEMBER_CANCELLED_SUCCESS'
|
|
|
965 |
]);
|
|
|
966 |
} else {
|
|
|
967 |
return new JsonModel([
|
|
|
968 |
'success' => true,
|
|
|
969 |
'data' => 'LABEL_GROUP_MEMBER_CANCELLED_FAILED'
|
|
|
970 |
]);
|
|
|
971 |
}
|
|
|
972 |
}
|
|
|
973 |
}
|
|
|
974 |
|
|
|
975 |
|
|
|
976 |
return new JsonModel([
|
|
|
977 |
'success' => false,
|
|
|
978 |
'data' => 'ERROR_GROUP_REQUEST_OR_MEMBER_NOT_FOUND_TO_CANCEL'
|
|
|
979 |
]);
|
|
|
980 |
} else {
|
|
|
981 |
|
|
|
982 |
return new JsonModel([
|
|
|
983 |
'success' => false,
|
|
|
984 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
985 |
]);
|
|
|
986 |
}
|
|
|
987 |
}
|
|
|
988 |
|
|
|
989 |
public function groupMemberRejectAction()
|
|
|
990 |
{
|
|
|
991 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
992 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
993 |
|
|
|
994 |
$request = $this->getRequest();
|
|
|
995 |
if ($request->isPost()) {
|
|
|
996 |
$group_uuid = $this->params()->fromRoute('group_id');
|
|
|
997 |
$user_uuid = $this->params()->fromRoute('user_id');
|
|
|
998 |
|
|
|
999 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
1000 |
$group = $groupMapper->fetchOneByUuidAndNetworkId($group_uuid, $currentUser->network_id);
|
|
|
1001 |
|
|
|
1002 |
if (!$group) {
|
|
|
1003 |
return new JsonModel([
|
|
|
1004 |
'success' => false,
|
|
|
1005 |
'data' => 'ERROR_GROUP_NOT_FOUND'
|
|
|
1006 |
]);
|
|
|
1007 |
}
|
|
|
1008 |
|
|
|
1009 |
if ($group->status != Group::STATUS_ACTIVE) {
|
|
|
1010 |
return new JsonModel([
|
|
|
1011 |
'success' => false,
|
|
|
1012 |
'data' => 'ERROR_GROUP_IS_NOT_ACTIVE'
|
|
|
1013 |
]);
|
|
|
1014 |
}
|
|
|
1015 |
|
|
|
1016 |
if ($currentUser->id != $group->user_id) {
|
|
|
1017 |
return new JsonModel([
|
|
|
1018 |
'success' => false,
|
|
|
1019 |
'data' => 'ERROR_GROUP_IS_NOT_YOU_ARE_THE_OWNER_OF_THIS_GROUP'
|
|
|
1020 |
]);
|
|
|
1021 |
}
|
|
|
1022 |
|
|
|
1023 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1024 |
$user = $userMapper->fetchOneByUuidAndNetworkId($user_uuid, $currentUser->network_id);
|
|
|
1025 |
|
|
|
1026 |
if (!$user) {
|
|
|
1027 |
return new JsonModel([
|
|
|
1028 |
'success' => false,
|
|
|
1029 |
'data' => 'ERROR_USER_NOT_FOUND'
|
|
|
1030 |
]);
|
|
|
1031 |
}
|
|
|
1032 |
|
|
|
1033 |
if ($user->id == $currentUser->id) {
|
|
|
1034 |
return new JsonModel([
|
|
|
1035 |
'success' => false,
|
|
|
1036 |
'data' => 'ERROR_GROUP_YOU_ARE_THE_OWNER_OF_THIS_GROUP'
|
|
|
1037 |
]);
|
|
|
1038 |
}
|
|
|
1039 |
|
|
|
1040 |
|
|
|
1041 |
|
|
|
1042 |
$groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
1043 |
$groupMember = $groupMemberMapper->fetchOneByGroupIdAndUserId($group->id, $user->id);
|
|
|
1044 |
if ($groupMember) {
|
|
|
1045 |
|
|
|
1046 |
if ($groupMember->status == GroupMember::STATUS_JOINING_REQUESTED) {
|
|
|
1047 |
|
|
|
1048 |
$groupMember->status = GroupMember::STATUS_REJECTED;
|
|
|
1049 |
if ($groupMemberMapper->update($groupMember)) {
|
|
|
1050 |
|
|
|
1051 |
return new JsonModel([
|
|
|
1052 |
'success' => true,
|
|
|
1053 |
'data' => 'LABEL_GROUP_MEMBER_REJECTED_SUCCESS'
|
|
|
1054 |
]);
|
|
|
1055 |
} else {
|
|
|
1056 |
return new JsonModel([
|
|
|
1057 |
'success' => true,
|
|
|
1058 |
'data' => 'LABEL_GROUP_MEMBER_REJECTED_FAILED'
|
|
|
1059 |
]);
|
|
|
1060 |
}
|
|
|
1061 |
}
|
|
|
1062 |
}
|
|
|
1063 |
|
|
|
1064 |
|
|
|
1065 |
return new JsonModel([
|
|
|
1066 |
'success' => false,
|
|
|
1067 |
'data' => 'ERROR_GROUP_THERE_IS_NO_PENDING_REQUEST_TO_REJECT'
|
|
|
1068 |
]);
|
|
|
1069 |
} else {
|
|
|
1070 |
|
|
|
1071 |
return new JsonModel([
|
|
|
1072 |
'success' => false,
|
|
|
1073 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1074 |
]);
|
|
|
1075 |
}
|
|
|
1076 |
}
|
|
|
1077 |
|
|
|
1078 |
public function groupMemberApproveAction()
|
|
|
1079 |
{
|
|
|
1080 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1081 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1082 |
|
|
|
1083 |
$request = $this->getRequest();
|
|
|
1084 |
if ($request->isPost()) {
|
|
|
1085 |
$group_uuid = $this->params()->fromRoute('group_id');
|
|
|
1086 |
$user_uuid = $this->params()->fromRoute('user_id');
|
|
|
1087 |
|
|
|
1088 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
1089 |
$group = $groupMapper->fetchOneByUuidAndNetworkId($group_uuid, $currentUser->network_id);
|
|
|
1090 |
|
|
|
1091 |
if (!$group) {
|
|
|
1092 |
return new JsonModel([
|
|
|
1093 |
'success' => false,
|
|
|
1094 |
'data' => 'ERROR_GROUP_NOT_FOUND'
|
|
|
1095 |
]);
|
|
|
1096 |
}
|
|
|
1097 |
|
|
|
1098 |
if ($group->status != Group::STATUS_ACTIVE) {
|
|
|
1099 |
return new JsonModel([
|
|
|
1100 |
'success' => false,
|
|
|
1101 |
'data' => 'ERROR_GROUP_IS_NOT_ACTIVE'
|
|
|
1102 |
]);
|
|
|
1103 |
}
|
|
|
1104 |
|
|
|
1105 |
if ($currentUser->id != $group->user_id) {
|
|
|
1106 |
return new JsonModel([
|
|
|
1107 |
'success' => false,
|
|
|
1108 |
'data' => 'ERROR_GROUP_IS_NOT_YOU_ARE_THE_OWNER_OF_THIS_GROUP'
|
|
|
1109 |
]);
|
|
|
1110 |
}
|
|
|
1111 |
|
|
|
1112 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1113 |
$user = $userMapper->fetchOneByUuidAndNetworkId($user_uuid, $currentUser->network_id);
|
|
|
1114 |
|
|
|
1115 |
if (!$user) {
|
|
|
1116 |
return new JsonModel([
|
|
|
1117 |
'success' => false,
|
|
|
1118 |
'data' => 'ERROR_USER_NOT_FOUND'
|
|
|
1119 |
]);
|
|
|
1120 |
}
|
|
|
1121 |
|
|
|
1122 |
if ($user->id == $currentUser->id) {
|
|
|
1123 |
return new JsonModel([
|
|
|
1124 |
'success' => false,
|
|
|
1125 |
'data' => 'ERROR_GROUP_YOU_ARE_THE_OWNER_OF_THIS_GROUP'
|
|
|
1126 |
]);
|
|
|
1127 |
}
|
|
|
1128 |
|
|
|
1129 |
|
|
|
1130 |
|
|
|
1131 |
$groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
1132 |
$groupMember = $groupMemberMapper->fetchOneByGroupIdAndUserId($group->id, $user->id);
|
|
|
1133 |
if ($groupMember) {
|
|
|
1134 |
|
|
|
1135 |
if ($groupMember->status == GroupMember::STATUS_JOINING_REQUESTED) {
|
|
|
1136 |
|
|
|
1137 |
$groupMember->status = GroupMember::STATUS_ACCEPTED;
|
|
|
1138 |
if ($groupMemberMapper->update($groupMember)) {
|
|
|
1139 |
|
|
|
1140 |
|
|
|
1141 |
$notification = new Notification();
|
|
|
1142 |
$notification->type = Notification::TYPE_ACCEPT_MY_REQUEST_JOIN_GROUP;
|
|
|
1143 |
$notification->read = Notification::NO;
|
|
|
1144 |
$notification->user_id = $user->id;
|
|
|
1145 |
$notification->group_id = $group->id;
|
|
|
1146 |
$notification->message = 'LABEL_NOTIFICATION_ACCEPT_MY_REQUEST_JOIN_GROUP';
|
|
|
1147 |
$notification->url = $this->url()->fromRoute('group/view', ['id' => $group->uuid]);
|
|
|
1148 |
|
|
|
1149 |
$notificationMapper = NotificationMapper::getInstance($this->adapter);
|
|
|
1150 |
$notificationMapper->insert($notification);
|
|
|
1151 |
|
|
|
1152 |
$userNotificationMapper = UserNotificationSettingMapper::getInstance($this->adapter);
|
|
|
1153 |
$userNotification = $userNotificationMapper->fetchOne($user->id);
|
|
|
1154 |
|
|
|
1155 |
if ($userNotification && $userNotification->receive_invitation_group) {
|
|
|
1156 |
$emailTemplateMapper = EmailTemplateMapper::getInstance($this->adapter);
|
|
|
1157 |
$emailTemplate = $emailTemplateMapper->fetchOneByCodeAndNetworkId(EmailTemplate::CODE_ACCEPT_MY_REQUEST_JOIN_GROUP, $currentUser->network_id);
|
|
|
1158 |
|
|
|
1159 |
if ($emailTemplate) {
|
|
|
1160 |
$arrayCont = [
|
|
|
1161 |
'firstname' => $currentUser->first_name,
|
|
|
1162 |
'lastname' => $currentUser->last_name,
|
|
|
1163 |
'other_user_firstname' => $user->first_name,
|
|
|
1164 |
'other_user_lastname' => $user->last_name,
|
|
|
1165 |
'company_name' => '',
|
|
|
1166 |
'group_name' => $group->name,
|
|
|
1167 |
'content' => '',
|
|
|
1168 |
'code' => '',
|
|
|
1169 |
'link' => $this->url()->fromRoute('group/view', ['id' => $group->uuid], ['force_canonical' => true])
|
|
|
1170 |
];
|
|
|
1171 |
|
|
|
1172 |
$email = new QueueEmail($this->adapter);
|
|
|
1173 |
$email->processEmailTemplate($emailTemplate, $arrayCont, $user->email, trim($user->first_name . ' ' . $user->last_name));
|
|
|
1174 |
}
|
|
|
1175 |
}
|
|
|
1176 |
|
|
|
1177 |
return new JsonModel([
|
|
|
1178 |
'success' => true,
|
|
|
1179 |
'data' => 'LABEL_GROUP_MEMBER_APPROVED_SUCCESS'
|
|
|
1180 |
]);
|
|
|
1181 |
} else {
|
|
|
1182 |
return new JsonModel([
|
|
|
1183 |
'success' => true,
|
|
|
1184 |
'data' => 'LABEL_GROUP_MEMBER_APPROVED_FAILED'
|
|
|
1185 |
]);
|
|
|
1186 |
}
|
|
|
1187 |
}
|
|
|
1188 |
}
|
|
|
1189 |
|
|
|
1190 |
|
|
|
1191 |
return new JsonModel([
|
|
|
1192 |
'success' => false,
|
|
|
1193 |
'data' => 'ERROR_GROUP_THERE_IS_NO_PENDING_REQUEST_TO_APPROVED'
|
|
|
1194 |
]);
|
|
|
1195 |
} else {
|
|
|
1196 |
|
|
|
1197 |
return new JsonModel([
|
|
|
1198 |
'success' => false,
|
|
|
1199 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1200 |
]);
|
|
|
1201 |
}
|
|
|
1202 |
}
|
|
|
1203 |
|
|
|
1204 |
|
|
|
1205 |
/**
|
|
|
1206 |
* Recuperamos los grupos sugeridos
|
|
|
1207 |
* tiene que enviarse un petición GET a la siguiente url: /helpers/groups-suggestion/:group_id
|
|
|
1208 |
* retorna un json en caso de ser positivo
|
|
|
1209 |
* [
|
|
|
1210 |
* 'success' : true,
|
|
|
1211 |
* 'data' : [
|
|
|
1212 |
* [
|
|
|
1213 |
* 'id' => 'id del grupo encriptado',
|
|
|
1214 |
* 'name' => 'nombre del grupo',
|
|
|
1215 |
* 'image' => 'imagen del grupo',
|
|
|
1216 |
* 'profile' => 'url del profile',
|
|
|
1217 |
* ]
|
|
|
1218 |
* ]
|
|
|
1219 |
* En caso de ser negativo
|
|
|
1220 |
* [
|
|
|
1221 |
* 'success' : false,
|
|
|
1222 |
* 'data' : mensaje de error
|
|
|
1223 |
* ]
|
|
|
1224 |
* @return \Laminas\View\Model\JsonModel
|
|
|
1225 |
*/
|
|
|
1226 |
public function groupsSuggestionAction()
|
|
|
1227 |
{
|
|
|
1228 |
|
|
|
1229 |
$request = $this->getRequest();
|
|
|
1230 |
if ($request->isGet()) {
|
|
|
1231 |
|
|
|
1232 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1233 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1234 |
|
|
|
1235 |
$connectionMapper = ConnectionMapper::getInstance($this->adapter);
|
|
|
1236 |
$first_degree_connections_ids = $connectionMapper->fetchAllConnectionsByUserReturnIds($currentUser->id);
|
|
|
1237 |
$first_degree_connections_ids = $first_degree_connections_ids ? $first_degree_connections_ids : [0];
|
|
|
1238 |
|
|
|
1239 |
$second_degree_connections_ids = $connectionMapper->fetchAllSecondDegreeConnectionsForUserIdReturnIds($currentUser->id);
|
|
|
1240 |
$second_degree_connections_ids = $second_degree_connections_ids ? $second_degree_connections_ids : [0];
|
|
|
1241 |
|
|
|
1242 |
/*Usuarios de la empresas donde trabajo o soy dueño */
|
|
|
1243 |
$company_user_ids = [];
|
|
|
1244 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
1245 |
|
|
|
1246 |
$records = $companyUserMapper->fetchAllByUserId($currentUser->id);
|
|
|
1247 |
foreach ($records as $record) {
|
|
|
1248 |
|
|
|
1249 |
if ($record->status != CompanyUser::STATUS_ACCEPTED) {
|
|
|
1250 |
continue;
|
|
|
1251 |
}
|
|
|
1252 |
|
|
|
1253 |
$otherUsers = $companyUserMapper->fetchAllByCompanyId($record->company_id);
|
|
|
1254 |
foreach ($otherUsers as $otherUser) {
|
|
|
1255 |
if ($currentUser->id != $otherUser->user_id && $otherUser->creator == CompanyUser::CREATOR_NO && $otherUser->status == CompanyUser::STATUS_ACCEPTED) {
|
|
|
1256 |
|
|
|
1257 |
if (!in_array($otherUser->user_id, $company_user_ids)) {
|
|
|
1258 |
array_push($company_user_ids, $otherUser->user_id);
|
|
|
1259 |
}
|
|
|
1260 |
}
|
|
|
1261 |
}
|
|
|
1262 |
}
|
|
|
1263 |
$company_user_ids = $company_user_ids ? $company_user_ids : [0];
|
|
|
1264 |
|
|
|
1265 |
/* Usuario de los grupos donde soy dueño o participo */
|
|
|
1266 |
|
|
|
1267 |
$groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
1268 |
|
|
|
1269 |
$group_member_ids = [];
|
|
|
1270 |
|
|
|
1271 |
$records = $groupMemberMapper->fetchAllByUserId($currentUser->id);
|
|
|
1272 |
foreach ($records as $record) {
|
|
|
1273 |
if ($record->status != GroupMember::STATUS_ACCEPTED) {
|
|
|
1274 |
continue;
|
|
|
1275 |
}
|
|
|
1276 |
|
|
|
1277 |
$otherUsers = $groupMemberMapper->fetchAllByGroupId($record->group_id);
|
|
|
1278 |
foreach ($otherUsers as $otherUser) {
|
|
|
1279 |
if ($currentUser->id != $otherUser->user_id && $otherUser->status == GroupMember::STATUS_ACCEPTED) {
|
|
|
1280 |
|
|
|
1281 |
if (!in_array($otherUser->user_id, $group_member_ids)) {
|
|
|
1282 |
array_push($group_member_ids, $otherUser->user_id);
|
|
|
1283 |
}
|
|
|
1284 |
}
|
|
|
1285 |
}
|
|
|
1286 |
}
|
|
|
1287 |
|
|
|
1288 |
$group_member_ids = $group_member_ids ? $group_member_ids : [0];
|
|
|
1289 |
|
626 |
stevensc |
1290 |
/* Usuarios con que comparto topicos */
|
|
|
1291 |
$topic_user_ids = [];
|
|
|
1292 |
$topicUserMapper = MicrolearningTopicUserMapper::getInstance($this->adapter);
|
1 |
efrain |
1293 |
|
|
|
1294 |
$company_ids = [];
|
626 |
stevensc |
1295 |
$records = $topicUserMapper->fetchAllActiveByUserId($currentUser->id);
|
1 |
efrain |
1296 |
foreach ($records as $record) {
|
|
|
1297 |
if (!in_array($record->company_id, $company_ids)) {
|
|
|
1298 |
array_push($company_ids, $record->company_id);
|
|
|
1299 |
}
|
|
|
1300 |
}
|
|
|
1301 |
|
|
|
1302 |
foreach ($company_ids as $company_id) {
|
626 |
stevensc |
1303 |
$otherUsers = $topicUserMapper->fetchAllUserIdsForTopicsActiveByCompanyId($company_id);
|
1 |
efrain |
1304 |
foreach ($otherUsers as $user_id) {
|
|
|
1305 |
if ($currentUser->id != $user_id) {
|
|
|
1306 |
|
626 |
stevensc |
1307 |
if (!in_array($user_id, $topic_user_ids)) {
|
|
|
1308 |
array_push($topic_user_ids, $user_id);
|
1 |
efrain |
1309 |
}
|
|
|
1310 |
}
|
|
|
1311 |
}
|
|
|
1312 |
}
|
|
|
1313 |
|
626 |
stevensc |
1314 |
$topic_user_ids = $topic_user_ids ? $topic_user_ids : [0];
|
1 |
efrain |
1315 |
|
|
|
1316 |
|
|
|
1317 |
$other_users = array_unique(array_merge(
|
|
|
1318 |
|
|
|
1319 |
$second_degree_connections_ids,
|
|
|
1320 |
$company_user_ids,
|
|
|
1321 |
$group_member_ids,
|
626 |
stevensc |
1322 |
$topic_user_ids
|
1 |
efrain |
1323 |
));
|
|
|
1324 |
|
|
|
1325 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
1326 |
|
|
|
1327 |
|
|
|
1328 |
$groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
1329 |
$group_ids = $groupMemberMapper->fetchAllGroupIdsByUserIds($other_users);
|
|
|
1330 |
$group_ids = $group_ids ? $group_ids : [0];
|
|
|
1331 |
|
|
|
1332 |
|
|
|
1333 |
|
|
|
1334 |
|
|
|
1335 |
$select = $queryMapper->getSql()->select();
|
|
|
1336 |
$select->columns(['id', 'uuid', 'name', 'image', 'status', 'privacy', 'priority' => new Expression('0')]);
|
|
|
1337 |
$select->from(['g' => GroupMapper::_TABLE]);
|
|
|
1338 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
1339 |
$select->where->equalTo('privacy', Group::PRIVACY_IS_PUBLIC);
|
|
|
1340 |
$select->where->equalTo('status', Group::STATUS_ACTIVE);
|
|
|
1341 |
$select->where->in('g.id', $group_ids);
|
|
|
1342 |
$select->where->notEqualTo('g.user_id', $currentUser->id);
|
|
|
1343 |
$select->order('name ASC');
|
|
|
1344 |
|
|
|
1345 |
|
|
|
1346 |
|
|
|
1347 |
//echo $select->getSqlString($this->adapter->platform); exit;
|
|
|
1348 |
|
|
|
1349 |
$records = $queryMapper->fetchAll($select);
|
|
|
1350 |
usort($records, function ($a, $b) {
|
|
|
1351 |
if ($a['priority'] == $b['priority']) {
|
|
|
1352 |
return 0;
|
|
|
1353 |
} else {
|
|
|
1354 |
return $a['priority'] < $b['priority'] ? 1 : -1;
|
|
|
1355 |
}
|
|
|
1356 |
});
|
|
|
1357 |
|
|
|
1358 |
|
|
|
1359 |
$items = [];
|
269 |
efrain |
1360 |
|
333 |
www |
1361 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
1 |
efrain |
1362 |
|
283 |
www |
1363 |
|
1 |
efrain |
1364 |
foreach ($records as $record) {
|
|
|
1365 |
|
|
|
1366 |
array_push($items, [
|
|
|
1367 |
'id' => $record['uuid'],
|
|
|
1368 |
'name' => trim($record['name']),
|
283 |
www |
1369 |
'image' => $storage->getGroupImageForCodeAndFilename($record['uuid'], $record['image']),
|
1 |
efrain |
1370 |
'profile' => $this->url()->fromRoute('group/view', ['id' => $record['uuid']]),
|
|
|
1371 |
'priority' => $record['priority'],
|
|
|
1372 |
|
|
|
1373 |
]);
|
|
|
1374 |
}
|
|
|
1375 |
|
|
|
1376 |
return new JsonModel([
|
|
|
1377 |
'success' => true,
|
|
|
1378 |
'data' => $items
|
|
|
1379 |
]);
|
|
|
1380 |
} else {
|
|
|
1381 |
return new JsonModel([
|
|
|
1382 |
'success' => false,
|
|
|
1383 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1384 |
]);
|
|
|
1385 |
}
|
|
|
1386 |
}
|
|
|
1387 |
|
|
|
1388 |
public function postsAction()
|
|
|
1389 |
{
|
|
|
1390 |
$request = $this->getRequest();
|
|
|
1391 |
if ($request->isGet()) {
|
|
|
1392 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1393 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1394 |
|
|
|
1395 |
$items = [];
|
|
|
1396 |
$postMapper = PostMapper::getInstance($this->adapter);
|
|
|
1397 |
$posts = $postMapper->fetchAllActiveByNetworkId($currentUser->network_id);
|
|
|
1398 |
|
|
|
1399 |
|
333 |
www |
1400 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
283 |
www |
1401 |
$path = $storage->getPathPost();
|
269 |
efrain |
1402 |
|
1 |
efrain |
1403 |
foreach ($posts as $post) {
|
|
|
1404 |
$dt = \DateTime::createFromFormat('Y-m-d', $post->date);
|
|
|
1405 |
array_push($items, [
|
283 |
www |
1406 |
'image' => $storage->getGenericImage($path, $post->uuid, $post->image),
|
1 |
efrain |
1407 |
'date' => $dt->format('d/m/Y'),
|
|
|
1408 |
'title' => $post->title,
|
|
|
1409 |
'link' => $this->url()->fromRoute('post', ['id' => $post->uuid]),
|
|
|
1410 |
]);
|
|
|
1411 |
}
|
|
|
1412 |
|
|
|
1413 |
return new JsonModel([
|
|
|
1414 |
'success' => true,
|
|
|
1415 |
'data' => $items
|
|
|
1416 |
]);
|
|
|
1417 |
}
|
|
|
1418 |
|
|
|
1419 |
return new JsonModel([
|
|
|
1420 |
'success' => false,
|
|
|
1421 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1422 |
]);
|
|
|
1423 |
}
|
|
|
1424 |
|
|
|
1425 |
|
|
|
1426 |
|
|
|
1427 |
public function searchPeopleAction()
|
|
|
1428 |
{
|
|
|
1429 |
$request = $this->getRequest();
|
|
|
1430 |
if ($request->isGet()) {
|
|
|
1431 |
|
|
|
1432 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1433 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1434 |
|
707 |
stevensc |
1435 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
|
|
1436 |
|
1 |
efrain |
1437 |
$search = Functions::sanitizeFilterString($this->params()->fromQuery('search'));
|
|
|
1438 |
if (strlen($search) >= 3) {
|
|
|
1439 |
|
270 |
efrain |
1440 |
$userBlockedIds = [$currentUser->id];
|
269 |
efrain |
1441 |
|
270 |
efrain |
1442 |
|
|
|
1443 |
$userBlockedMapper = \LeadersLinked\Mapper\UserBlockedMapper::getInstance($this->adapter);
|
|
|
1444 |
$ids = $userBlockedMapper->fetchAllBlockedReturnIds($currentUser->id);
|
|
|
1445 |
foreach($ids as $id)
|
|
|
1446 |
{
|
|
|
1447 |
if(!in_array($id, $userBlockedIds)) {
|
|
|
1448 |
array_push($userBlockedIds, $id);
|
|
|
1449 |
}
|
|
|
1450 |
}
|
|
|
1451 |
|
|
|
1452 |
$ids = $userBlockedMapper->fetchAllUserBlockMeReturnIds($currentUser->id);
|
|
|
1453 |
foreach($ids as $id)
|
|
|
1454 |
{
|
|
|
1455 |
if(!in_array($id, $userBlockedIds)) {
|
|
|
1456 |
array_push($userBlockedIds, $id);
|
|
|
1457 |
}
|
|
|
1458 |
}
|
|
|
1459 |
|
|
|
1460 |
|
|
|
1461 |
|
|
|
1462 |
|
269 |
efrain |
1463 |
$records_x_page = 10;
|
|
|
1464 |
$page = intval($this->params()->fromQuery('page', 0), 10);
|
|
|
1465 |
$page = $page > 0 ? $page : 1;
|
|
|
1466 |
|
1 |
efrain |
1467 |
$userMapper = UserMapper::getInstance($this->adapter);
|
270 |
efrain |
1468 |
$paginator = $userMapper->fetchAllSuggestPaginateByNetworkIdAndSearchAndNotBlocked(
|
|
|
1469 |
$currentUser->network_id, $search, $records_x_page, $page, $userBlockedIds );
|
1 |
efrain |
1470 |
|
269 |
efrain |
1471 |
$items = [];
|
|
|
1472 |
foreach ( $paginator as $record) {
|
1 |
efrain |
1473 |
if ($currentUser->id == $record->id) {
|
|
|
1474 |
continue;
|
|
|
1475 |
}
|
278 |
efrain |
1476 |
|
1 |
efrain |
1477 |
|
269 |
efrain |
1478 |
array_push($items, [
|
|
|
1479 |
'uuid' => $record->uuid,
|
707 |
stevensc |
1480 |
'name' => trim($record->first_name . ' ' . $record->last_name),
|
|
|
1481 |
'image' => $storage->getUserImage($record),
|
|
|
1482 |
'profile' => $this->url()->fromRoute('profile/view', ['id' => $record->uuid]),
|
|
|
1483 |
'last_message' => '',
|
|
|
1484 |
'count_unread' => 0,
|
|
|
1485 |
'selected' => 0,
|
|
|
1486 |
'last_message' => '',
|
|
|
1487 |
'messages_url' => $this->url()->fromRoute('inmail/messages',['uuid' => $record->uuid]),
|
|
|
1488 |
'save_url' => $this->url()->fromRoute('inmail/messages/send',['uuid' => $record->uuid]),
|
|
|
1489 |
'delete_url' => $this->url()->fromRoute('inmail/messages/delete',['uuid' => $record->uuid])
|
1 |
efrain |
1490 |
]);
|
|
|
1491 |
}
|
269 |
efrain |
1492 |
|
|
|
1493 |
|
|
|
1494 |
$response = [
|
|
|
1495 |
'success' => true,
|
|
|
1496 |
'data' => [
|
|
|
1497 |
'total' => [
|
|
|
1498 |
'count' => $paginator->getTotalItemCount(),
|
|
|
1499 |
'pages' => $paginator->getPages()->pageCount,
|
|
|
1500 |
],
|
|
|
1501 |
'current' => [
|
|
|
1502 |
'items' => $items,
|
|
|
1503 |
'page' => $paginator->getCurrentPageNumber(),
|
|
|
1504 |
'count' => $paginator->getCurrentItemCount(),
|
|
|
1505 |
]
|
|
|
1506 |
]
|
|
|
1507 |
];
|
1 |
efrain |
1508 |
|
269 |
efrain |
1509 |
return new JsonModel($response);
|
1 |
efrain |
1510 |
} else {
|
|
|
1511 |
return new JsonModel([
|
|
|
1512 |
'success' => true,
|
|
|
1513 |
'data' => []
|
|
|
1514 |
]);
|
|
|
1515 |
}
|
|
|
1516 |
} else {
|
|
|
1517 |
return new JsonModel([
|
|
|
1518 |
'success' => false,
|
|
|
1519 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1520 |
]);
|
|
|
1521 |
}
|
|
|
1522 |
}
|
|
|
1523 |
|
|
|
1524 |
public function footerAction()
|
|
|
1525 |
{
|
|
|
1526 |
$request = $this->getRequest();
|
|
|
1527 |
if ($request->isGet()) {
|
|
|
1528 |
|
|
|
1529 |
|
|
|
1530 |
$links = isset($this->navigation['footer']) ? $this->navigation['footer'] : [];
|
|
|
1531 |
|
|
|
1532 |
|
|
|
1533 |
$data = [];
|
|
|
1534 |
foreach ($links as $link) {
|
|
|
1535 |
$data[$link['route']] = $link['label'];
|
|
|
1536 |
}
|
|
|
1537 |
|
|
|
1538 |
|
|
|
1539 |
return new JsonModel([
|
|
|
1540 |
'success' => true,
|
|
|
1541 |
'data' => $data,
|
|
|
1542 |
]);
|
|
|
1543 |
} else {
|
|
|
1544 |
return new JsonModel([
|
|
|
1545 |
'success' => false,
|
|
|
1546 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1547 |
]);
|
|
|
1548 |
}
|
|
|
1549 |
}
|
|
|
1550 |
|
|
|
1551 |
|
|
|
1552 |
/**
|
|
|
1553 |
* Recuperamos los grupos sugeridos
|
|
|
1554 |
* tiene que enviarse un petición GET a la siguiente url: /helpers/groups-suggestion/:group_id
|
|
|
1555 |
* retorna un json en caso de ser positivo
|
|
|
1556 |
* [
|
|
|
1557 |
* 'success' : true,
|
|
|
1558 |
* 'data' : [
|
|
|
1559 |
* [
|
|
|
1560 |
* 'id' => 'id del grupo encriptado',
|
|
|
1561 |
* 'name' => 'nombre del grupo',
|
|
|
1562 |
* 'image' => 'imagen del grupo',
|
|
|
1563 |
* 'profile' => 'url del profile',
|
|
|
1564 |
* ]
|
|
|
1565 |
* ]
|
|
|
1566 |
* En caso de ser negativo
|
|
|
1567 |
* [
|
|
|
1568 |
* 'success' : false,
|
|
|
1569 |
* 'data' : mensaje de error
|
|
|
1570 |
* ]
|
|
|
1571 |
* @return \Laminas\View\Model\JsonModel
|
|
|
1572 |
*/
|
|
|
1573 |
public function myGroupsAction()
|
|
|
1574 |
{
|
|
|
1575 |
|
|
|
1576 |
$request = $this->getRequest();
|
|
|
1577 |
if ($request->isGet()) {
|
|
|
1578 |
|
|
|
1579 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1580 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1581 |
|
|
|
1582 |
|
|
|
1583 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
1584 |
$select = $queryMapper->getSql()->select();
|
|
|
1585 |
$select->columns(['id', 'uuid', 'name', 'image', 'status', 'privacy', 'priority' => new Expression('0')]);
|
|
|
1586 |
$select->from(['g' => GroupMapper::_TABLE]);
|
|
|
1587 |
$select->where->equalTo('status', Group::STATUS_ACTIVE);
|
|
|
1588 |
$select->where->equalTo('g.user_id', $currentUser->id);
|
|
|
1589 |
$select->order('name ASC');
|
|
|
1590 |
|
|
|
1591 |
|
|
|
1592 |
$items = [];
|
333 |
www |
1593 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
1 |
efrain |
1594 |
|
283 |
www |
1595 |
|
1 |
efrain |
1596 |
$records = $queryMapper->fetchAll($select);
|
|
|
1597 |
foreach ($records as $record) {
|
|
|
1598 |
|
|
|
1599 |
array_push($items, [
|
|
|
1600 |
'id' => $record['uuid'],
|
|
|
1601 |
'name' => trim($record['name']),
|
283 |
www |
1602 |
'image' => $storage->getGroupImageForCodeAndFilename($record['uuid'], $record['image']),
|
1 |
efrain |
1603 |
'profile' => $this->url()->fromRoute('group/view', ['id' => $record['uuid']]),
|
|
|
1604 |
'priority' => $record['priority'],
|
|
|
1605 |
|
|
|
1606 |
]);
|
|
|
1607 |
}
|
|
|
1608 |
|
|
|
1609 |
return new JsonModel([
|
|
|
1610 |
'success' => true,
|
|
|
1611 |
'data' => $items
|
|
|
1612 |
]);
|
|
|
1613 |
} else {
|
|
|
1614 |
return new JsonModel([
|
|
|
1615 |
'success' => false,
|
|
|
1616 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1617 |
]);
|
|
|
1618 |
}
|
|
|
1619 |
}
|
|
|
1620 |
|
|
|
1621 |
public function nextEventsAction()
|
|
|
1622 |
{
|
|
|
1623 |
$request = $this->getRequest();
|
|
|
1624 |
if ($request->isGet()) {
|
|
|
1625 |
|
|
|
1626 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1627 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1628 |
|
|
|
1629 |
$currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
|
|
|
1630 |
$currentNetwork = $currentNetworkPlugin->getNetwork();
|
|
|
1631 |
|
|
|
1632 |
|
|
|
1633 |
|
|
|
1634 |
$dt = new \DateTime();
|
|
|
1635 |
$dt->setTime(0, 0, 0);
|
|
|
1636 |
$start = $dt->format('Y-m-d H:i:s');
|
|
|
1637 |
|
|
|
1638 |
$dt->add(new \DateInterval('P30D'));
|
|
|
1639 |
$dt->setTime(23, 59, 59);
|
|
|
1640 |
$end = $dt->format('Y-m-d H:i:s');
|
|
|
1641 |
|
|
|
1642 |
|
|
|
1643 |
|
|
|
1644 |
|
|
|
1645 |
$events = [];
|
|
|
1646 |
|
|
|
1647 |
|
|
|
1648 |
|
|
|
1649 |
//3 días
|
|
|
1650 |
$expirePeriod = 86400 * 3;
|
|
|
1651 |
$t1 = time();
|
|
|
1652 |
|
|
|
1653 |
$companies = [];
|
|
|
1654 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
1655 |
|
|
|
1656 |
$companyUsers = [];
|
|
|
1657 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
1658 |
$records = $companyUserMapper->fetchAllByUserId($currentUser->id);
|
|
|
1659 |
|
|
|
1660 |
foreach ($records as $record) {
|
|
|
1661 |
$companyUsers[$record->company_id] = $record->backend == CompanyUser::BACKEND_YES;
|
|
|
1662 |
}
|
|
|
1663 |
|
|
|
1664 |
|
|
|
1665 |
|
|
|
1666 |
$zoomMeetingMapper = ZoomMeetingMapper::getInstance($this->adapter);
|
|
|
1667 |
$recruitmentSelectionCandidateMapper = RecruitmentSelectionCandidateMapper::getInstance($this->adapter);
|
|
|
1668 |
$recruitmentSelectionVacancyMapper = RecruitmentSelectionVacancyMapper::getInstance($this->adapter);
|
|
|
1669 |
$recruitmentSelectionInterviewMapper = RecruitmentSelectionInterviewMapper::getInstance($this->adapter);
|
|
|
1670 |
$performanceEvaluationTestMapper = PerformanceEvaluationTestMapper::getInstance($this->adapter);
|
|
|
1671 |
$performanceEvaluationFormMapper = PerformanceEvaluationFormMapper::getInstance($this->adapter);
|
|
|
1672 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
1673 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1674 |
|
|
|
1675 |
$calendarEventMapper = CalendarEventMapper::getInstance($this->adapter);
|
|
|
1676 |
$records = $calendarEventMapper->fetchAllByUserIdAndStartTimeAndEndTime($currentUser->id, $start, $end);
|
|
|
1677 |
foreach ($records as $record) {
|
|
|
1678 |
switch ($record->type) {
|
|
|
1679 |
|
|
|
1680 |
case CalendarEvent::TYPE_SURVEY_NORMAL:
|
|
|
1681 |
$backgroundColor = $currentNetwork->css_calendar_survey_bg_color;
|
|
|
1682 |
$textColor = $currentNetwork->css_calendar_survey_text_color;
|
|
|
1683 |
|
|
|
1684 |
$surveyTestMapper = SurveyTestMapper::getInstance($this->adapter);
|
|
|
1685 |
$surveyTest = $surveyTestMapper->fetchOne($record->relational_id);
|
|
|
1686 |
|
|
|
1687 |
if($surveyTest && $surveyTest->user_id == $currentUser->id) {
|
|
|
1688 |
|
|
|
1689 |
$surveyCampaingMapper = SurveyCampaignMapper::getInstance($this->adapter);
|
|
|
1690 |
$surveyCampaing = $surveyCampaingMapper->fetchOne($surveyTest->campaign_id);
|
|
|
1691 |
|
|
|
1692 |
$url = '';
|
|
|
1693 |
$hasLink = !empty($companyUsers[$surveyTest->company_id]);
|
|
|
1694 |
|
|
|
1695 |
if ($hasLink) {
|
|
|
1696 |
|
|
|
1697 |
if (!isset($companies[$surveyTest->company_id])) {
|
|
|
1698 |
$company = $companyMapper->fetchOne($surveyTest->company_id);
|
|
|
1699 |
|
|
|
1700 |
$companies[$company->id] = $company;
|
|
|
1701 |
} else {
|
|
|
1702 |
$company = $companies[$surveyTest->company_id];
|
|
|
1703 |
}
|
|
|
1704 |
|
|
|
1705 |
|
|
|
1706 |
$url = $this->url()->fromRoute('backend/signin-company', [
|
|
|
1707 |
'id' => $company->uuid,
|
|
|
1708 |
'relational' => $surveyTest->uuid,
|
|
|
1709 |
'type' => CalendarEvent::TYPE_SURVEY_ORGANIZATIONAL_CLIMATE,
|
136 |
efrain |
1710 |
], ['force_canonical' => true]);
|
1 |
efrain |
1711 |
}
|
|
|
1712 |
|
|
|
1713 |
$dtStart = \DateTime::createFromFormat('Y-m-d', $surveyCampaing->end_date);
|
|
|
1714 |
|
|
|
1715 |
|
|
|
1716 |
array_push($events, [
|
|
|
1717 |
'id' => $surveyTest->uuid,
|
|
|
1718 |
'title' => $surveyCampaing->name,
|
146 |
efrain |
1719 |
'start' => $dtStart->format('Y-m-d'),
|
1 |
efrain |
1720 |
'url' => $url,
|
|
|
1721 |
'backgroundColor' => $backgroundColor,
|
|
|
1722 |
'textColor' => $textColor,
|
|
|
1723 |
'allDay' => true,
|
|
|
1724 |
'type' => 'task',
|
135 |
efrain |
1725 |
'source' => 'internal',
|
1 |
efrain |
1726 |
]);
|
|
|
1727 |
}
|
|
|
1728 |
|
|
|
1729 |
break;
|
|
|
1730 |
|
|
|
1731 |
case CalendarEvent::TYPE_SURVEY_ORGANIZATIONAL_CLIMATE:
|
|
|
1732 |
$backgroundColor = $currentNetwork->css_calendar_organizational_climate_bg_color;
|
|
|
1733 |
$textColor = $currentNetwork->css_calendar_organizational_climate_text_color;
|
|
|
1734 |
|
|
|
1735 |
$surveyTestMapper = SurveyTestMapper::getInstance($this->adapter);
|
|
|
1736 |
$surveyTest = $surveyTestMapper->fetchOne($record->relational_id);
|
|
|
1737 |
|
|
|
1738 |
if($surveyTest && $surveyTest->user_id == $currentUser->id) {
|
|
|
1739 |
|
|
|
1740 |
$surveyCampaingMapper = SurveyCampaignMapper::getInstance($this->adapter);
|
|
|
1741 |
$surveyCampaing = $surveyCampaingMapper->fetchOne($surveyTest->campaign_id);
|
|
|
1742 |
|
|
|
1743 |
$url = '';
|
|
|
1744 |
$hasLink = !empty($companyUsers[$surveyTest->company_id]);
|
|
|
1745 |
|
|
|
1746 |
if ($hasLink) {
|
|
|
1747 |
|
|
|
1748 |
if (!isset($companies[$surveyTest->company_id])) {
|
|
|
1749 |
$company = $companyMapper->fetchOne($surveyTest->company_id);
|
|
|
1750 |
|
|
|
1751 |
$companies[$company->id] = $company;
|
|
|
1752 |
} else {
|
|
|
1753 |
$company = $companies[$surveyTest->company_id];
|
|
|
1754 |
}
|
|
|
1755 |
|
|
|
1756 |
|
|
|
1757 |
$url = $this->url()->fromRoute('backend/signin-company', [
|
|
|
1758 |
'id' => $company->uuid,
|
|
|
1759 |
'relational' => $surveyTest->uuid,
|
|
|
1760 |
'type' => CalendarEvent::TYPE_SURVEY_ORGANIZATIONAL_CLIMATE,
|
136 |
efrain |
1761 |
], ['force_canonical' => true]);
|
1 |
efrain |
1762 |
}
|
|
|
1763 |
|
|
|
1764 |
$dtStart = \DateTime::createFromFormat('Y-m-d', $surveyCampaing->end_date);
|
|
|
1765 |
|
|
|
1766 |
|
|
|
1767 |
array_push($events, [
|
|
|
1768 |
'id' => $surveyTest->uuid,
|
|
|
1769 |
'title' => $surveyCampaing->name,
|
146 |
efrain |
1770 |
'start' => $dtStart->format('Y-m-d'),
|
1 |
efrain |
1771 |
'url' => $url,
|
|
|
1772 |
'backgroundColor' => $backgroundColor,
|
|
|
1773 |
'textColor' => $textColor,
|
|
|
1774 |
'allDay' => true,
|
|
|
1775 |
'type' => 'task',
|
135 |
efrain |
1776 |
'source' => 'internal',
|
1 |
efrain |
1777 |
]);
|
|
|
1778 |
}
|
|
|
1779 |
|
|
|
1780 |
break;
|
|
|
1781 |
|
|
|
1782 |
|
|
|
1783 |
|
|
|
1784 |
|
|
|
1785 |
|
|
|
1786 |
|
|
|
1787 |
|
|
|
1788 |
|
|
|
1789 |
|
|
|
1790 |
|
|
|
1791 |
case CalendarEvent::TYPE_RECRUITMENT_SELECTION_INTERVIEW:
|
|
|
1792 |
$backgroundColor = $currentNetwork->css_calendar_recruitment_and_selection_bg_color;
|
|
|
1793 |
$textColor = $currentNetwork->css_calendar_recruitment_and_selection_text_color;
|
|
|
1794 |
|
|
|
1795 |
|
|
|
1796 |
$recruitmentSelectionInterview = $recruitmentSelectionInterviewMapper->fetchOne($record->relational_id);
|
|
|
1797 |
if ($recruitmentSelectionInterview) {
|
|
|
1798 |
$recruitmentSelectionVacancy = $recruitmentSelectionVacancyMapper->fetchOne($recruitmentSelectionInterview->vacancy_id);
|
|
|
1799 |
|
|
|
1800 |
$recruitmentSelectionCandidate = $recruitmentSelectionCandidateMapper->fetchOne($recruitmentSelectionInterview->candidate_id);
|
|
|
1801 |
if ($recruitmentSelectionVacancy && $recruitmentSelectionCandidate) {
|
|
|
1802 |
$jobDescription = $jobDescriptionMapper->fetchOne($recruitmentSelectionVacancy->job_description_id);
|
|
|
1803 |
if ($jobDescription) {
|
|
|
1804 |
$url = '';
|
|
|
1805 |
$hasLink = !empty($companyUsers[$recruitmentSelectionInterview->company_id]);
|
|
|
1806 |
|
|
|
1807 |
if ($hasLink) {
|
|
|
1808 |
|
|
|
1809 |
if (!isset($companies[$recruitmentSelectionInterview->company_id])) {
|
|
|
1810 |
$company = $companyMapper->fetchOne($recruitmentSelectionInterview->company_id);
|
|
|
1811 |
|
|
|
1812 |
$companies[$company->id] = $company;
|
|
|
1813 |
} else {
|
|
|
1814 |
$company = $companies[$recruitmentSelectionInterview->company_id];
|
|
|
1815 |
}
|
|
|
1816 |
|
|
|
1817 |
|
|
|
1818 |
$url = $this->url()->fromRoute('backend/signin-company', [
|
|
|
1819 |
'id' => $company->uuid,
|
|
|
1820 |
'relational' => $recruitmentSelectionInterview->uuid,
|
|
|
1821 |
'type' => CalendarEvent::TYPE_RECRUITMENT_SELECTION_INTERVIEW
|
136 |
efrain |
1822 |
], ['force_canonical' => true]);
|
1 |
efrain |
1823 |
}
|
|
|
1824 |
|
|
|
1825 |
$dtStart = \DateTime::createFromFormat('Y-m-d', $recruitmentSelectionInterview->last_date);
|
|
|
1826 |
|
|
|
1827 |
|
|
|
1828 |
|
|
|
1829 |
|
|
|
1830 |
array_push($events, [
|
|
|
1831 |
'id' => $recruitmentSelectionInterview->uuid,
|
|
|
1832 |
'title' => $recruitmentSelectionVacancy->name,
|
146 |
efrain |
1833 |
'start' => $dtStart->format('Y-m-d'),
|
1 |
efrain |
1834 |
'url' => $url,
|
|
|
1835 |
'backgroundColor' => $backgroundColor,
|
|
|
1836 |
'textColor' => $textColor,
|
|
|
1837 |
'allDay' => true,
|
|
|
1838 |
'type' => 'task',
|
135 |
efrain |
1839 |
'source' => 'internal',
|
1 |
efrain |
1840 |
]);
|
|
|
1841 |
}
|
|
|
1842 |
}
|
|
|
1843 |
}
|
|
|
1844 |
|
|
|
1845 |
|
|
|
1846 |
break;
|
|
|
1847 |
|
|
|
1848 |
case CalendarEvent::TYPE_PERFORMANCE_EVALUATION:
|
|
|
1849 |
|
|
|
1850 |
|
|
|
1851 |
$backgroundColor = $currentNetwork->css_calendar_performance_evaluation_bg_color;
|
|
|
1852 |
$textColor = $currentNetwork->css_calendar_performance_evaluation_text_color;
|
|
|
1853 |
|
|
|
1854 |
|
|
|
1855 |
$performanceEvaluationTest = $performanceEvaluationTestMapper->fetchOne($record->relational_id);
|
|
|
1856 |
if ($performanceEvaluationTest) {
|
|
|
1857 |
|
|
|
1858 |
$performanceEvaluationForm = $performanceEvaluationFormMapper->fetchOne($performanceEvaluationTest->form_id);
|
|
|
1859 |
if ($performanceEvaluationForm) {
|
|
|
1860 |
$jobDescription = $jobDescriptionMapper->fetchOne($performanceEvaluationForm->job_description_id);
|
|
|
1861 |
if ($jobDescription) {
|
|
|
1862 |
$url = '';
|
|
|
1863 |
$hasLink = !empty($companyUsers[$performanceEvaluationTest->company_id]);
|
|
|
1864 |
|
|
|
1865 |
if ($performanceEvaluationTest->supervisor_id) {
|
|
|
1866 |
$supervisor = $userMapper->fetchOne($performanceEvaluationTest->supervisor_id);
|
|
|
1867 |
} else {
|
|
|
1868 |
$supervisor = '';
|
|
|
1869 |
}
|
|
|
1870 |
|
|
|
1871 |
if ($performanceEvaluationTest->employee_id) {
|
|
|
1872 |
$employee = $userMapper->fetchOne($performanceEvaluationTest->employee_id);
|
|
|
1873 |
} else {
|
|
|
1874 |
$employee = '';
|
|
|
1875 |
}
|
|
|
1876 |
|
|
|
1877 |
|
|
|
1878 |
|
|
|
1879 |
if ($hasLink) {
|
|
|
1880 |
|
|
|
1881 |
if (!isset($companies[$performanceEvaluationTest->company_id])) {
|
|
|
1882 |
$company = $companyMapper->fetchOne($performanceEvaluationTest->company_id);
|
|
|
1883 |
|
|
|
1884 |
$companies[$company->id] = $company;
|
|
|
1885 |
} else {
|
|
|
1886 |
$company = $companies[$performanceEvaluationTest->company_id];
|
|
|
1887 |
}
|
|
|
1888 |
|
|
|
1889 |
|
|
|
1890 |
$url = $this->url()->fromRoute('backend/signin-company', [
|
|
|
1891 |
'id' => $company->uuid,
|
|
|
1892 |
'relational' => $performanceEvaluationTest->uuid,
|
|
|
1893 |
'type' => CalendarEvent::TYPE_PERFORMANCE_EVALUATION
|
136 |
efrain |
1894 |
], ['force_canonical' => true]);
|
1 |
efrain |
1895 |
}
|
|
|
1896 |
|
|
|
1897 |
$dtStart = \DateTime::createFromFormat('Y-m-d', $performanceEvaluationTest->last_date);
|
|
|
1898 |
|
|
|
1899 |
array_push($events, [
|
|
|
1900 |
'id' => $performanceEvaluationTest->uuid,
|
|
|
1901 |
'title' => $performanceEvaluationForm->name,
|
146 |
efrain |
1902 |
'start' => $dtStart->format('Y-m-d'),
|
1 |
efrain |
1903 |
'url' => $url,
|
|
|
1904 |
'backgroundColor' => $backgroundColor,
|
|
|
1905 |
'textColor' => $textColor,
|
|
|
1906 |
'allDay' => true,
|
|
|
1907 |
'type' => 'task',
|
135 |
efrain |
1908 |
'source' => 'internal',
|
1 |
efrain |
1909 |
]);
|
|
|
1910 |
}
|
|
|
1911 |
}
|
|
|
1912 |
}
|
|
|
1913 |
|
|
|
1914 |
|
|
|
1915 |
|
|
|
1916 |
|
|
|
1917 |
|
|
|
1918 |
break;
|
|
|
1919 |
|
|
|
1920 |
|
|
|
1921 |
case CalendarEvent::TYPE_ZOOM:
|
|
|
1922 |
$zoomMeeting = $zoomMeetingMapper->fetchOne($record->relational_id);
|
|
|
1923 |
if ($zoomMeeting) {
|
|
|
1924 |
|
|
|
1925 |
$backgroundColor = $currentNetwork->css_calendar_zoom_bg_color;
|
|
|
1926 |
$textColor = $currentNetwork->css_calendar_zoom_text_color;
|
|
|
1927 |
|
|
|
1928 |
$dtStart = \DateTime::createFromFormat('Y-m-d H:i:s', $zoomMeeting->start_time);
|
|
|
1929 |
$t2 = $dtStart->getTimestamp();
|
|
|
1930 |
|
|
|
1931 |
if ($t2 > $t1) {
|
|
|
1932 |
|
|
|
1933 |
$t3 = $t1 + $expirePeriod;
|
|
|
1934 |
if ($t3 > $t2) {
|
|
|
1935 |
$backgroundColor = $currentNetwork->css_calendar_expire_bg_color;
|
|
|
1936 |
$textColor = $currentNetwork->css_calendar_expire_text_color;
|
|
|
1937 |
}
|
|
|
1938 |
}
|
|
|
1939 |
|
|
|
1940 |
|
|
|
1941 |
|
|
|
1942 |
if ($currentUser->timezone && $currentUser->timezone != $zoomMeeting->timezone) {
|
|
|
1943 |
|
|
|
1944 |
$start = str_replace(' ', 'T', Functions::convertDateTimeBetweenTimeZones($zoomMeeting->start_time, $zoomMeeting->timezone, $currentUser->timezone));
|
|
|
1945 |
$end = str_replace(' ', 'T', Functions::convertDateTimeBetweenTimeZones($zoomMeeting->end_time, $zoomMeeting->timezone, $currentUser->timezone));
|
|
|
1946 |
} else {
|
|
|
1947 |
$start = str_replace(' ', 'T', $zoomMeeting->start_time);
|
|
|
1948 |
$end = str_replace(' ', 'T', $zoomMeeting->end_time);
|
|
|
1949 |
}
|
|
|
1950 |
|
|
|
1951 |
|
|
|
1952 |
|
|
|
1953 |
$url = $zoomMeeting->join_url;
|
|
|
1954 |
|
|
|
1955 |
|
|
|
1956 |
|
|
|
1957 |
|
|
|
1958 |
$agenda = $zoomMeeting->agenda . "<br>" .
|
|
|
1959 |
" LABEL_ZOOM_MEETING_START_DATE : " . $dtStart->format('Y-m-d') . "<br>" .
|
|
|
1960 |
" LABEL_ZOOM_MEETING_START_TIME : " . $dtStart->format('H:i a') . "<br>" .
|
|
|
1961 |
" LABEL_ZOOM_MEETING_TIMEZONE : " . $zoomMeeting->timezone . "<br>" .
|
|
|
1962 |
" LABEL_ZOOM_MEETING_TITLE : " . $zoomMeeting->topic . "<br>" .
|
|
|
1963 |
" LABEL_ZOOM_MEETING_URL : " . $zoomMeeting->join_url . "<br>" .
|
|
|
1964 |
" LABEL_ZOOM_MEETING_PASSWORD : " . $zoomMeeting->password . "<br>";
|
|
|
1965 |
|
|
|
1966 |
array_push($events, [
|
|
|
1967 |
'id' => $zoomMeeting->id,
|
|
|
1968 |
'title' => $zoomMeeting->topic,
|
|
|
1969 |
'agenda' => $agenda,
|
|
|
1970 |
'start' => $start,
|
|
|
1971 |
'end' => $end,
|
|
|
1972 |
'url' => $zoomMeeting->join_url,
|
|
|
1973 |
'backgroundColor' => $backgroundColor,
|
|
|
1974 |
'textColor' => $textColor,
|
135 |
efrain |
1975 |
'type' => 'event',
|
|
|
1976 |
'source' => 'external',
|
1 |
efrain |
1977 |
]);
|
|
|
1978 |
}
|
|
|
1979 |
break;
|
|
|
1980 |
}
|
|
|
1981 |
}
|
|
|
1982 |
|
|
|
1983 |
|
|
|
1984 |
|
|
|
1985 |
return new JsonModel([
|
|
|
1986 |
'success' => true,
|
|
|
1987 |
'data' => $events
|
|
|
1988 |
]);
|
|
|
1989 |
} else {
|
|
|
1990 |
return new JsonModel([
|
|
|
1991 |
'success' => false,
|
|
|
1992 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1993 |
]);
|
|
|
1994 |
}
|
|
|
1995 |
}
|
|
|
1996 |
|
|
|
1997 |
public function menuAction()
|
|
|
1998 |
{
|
|
|
1999 |
|
|
|
2000 |
|
|
|
2001 |
$request = $this->getRequest();
|
|
|
2002 |
|
|
|
2003 |
|
|
|
2004 |
|
|
|
2005 |
if ($request->isGet()) {
|
|
|
2006 |
$currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
|
|
|
2007 |
$network = $currentNetworkPlugin->getNetwork();
|
|
|
2008 |
|
|
|
2009 |
|
|
|
2010 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
2011 |
if($currentUserPlugin->hasIdentity()) {
|
|
|
2012 |
$currentUser = $currentUserPlugin->getUser();
|
157 |
efrain |
2013 |
|
1 |
efrain |
2014 |
|
|
|
2015 |
|
|
|
2016 |
$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
|
|
2017 |
|
|
|
2018 |
$link_admin = $currentUser->usertype_id == UserType::ADMIN ? 1 : 0;
|
|
|
2019 |
$link_impersonate = $currentUser->is_super_user == User::IS_SUPER_USER_YES ? 1 : 0;
|
|
|
2020 |
if($link_impersonate) {
|
|
|
2021 |
$url_impersonate = $this->url()->fromRoute('signin/impersonate');
|
|
|
2022 |
} else {
|
|
|
2023 |
$url_impersonate = '';
|
|
|
2024 |
}
|
|
|
2025 |
|
|
|
2026 |
$fullname = trim($currentUser->first_name . ' ' . $currentUser->last_name);
|
|
|
2027 |
|
|
|
2028 |
$profileVisitMapper = ProfileVisitMapper::getInstance($this->adapter);
|
|
|
2029 |
$visits = $profileVisitMapper->getTotalByVisitedId($currentUser->id);
|
|
|
2030 |
|
|
|
2031 |
$connectionMapper = ConnectionMapper::getInstance($this->adapter);
|
|
|
2032 |
$connections = $connectionMapper->fetchTotalConnectionByUser($currentUser->id);
|
|
|
2033 |
|
|
|
2034 |
|
|
|
2035 |
if($currentUser->location_id) {
|
|
|
2036 |
$locationMapper = LocationMapper::getInstance($this->adapter);
|
|
|
2037 |
$location = $locationMapper->fetchOne($currentUser->location_id);
|
|
|
2038 |
|
|
|
2039 |
$country = $location->country;
|
|
|
2040 |
} else {
|
|
|
2041 |
$country = '';
|
|
|
2042 |
}
|
|
|
2043 |
|
|
|
2044 |
|
|
|
2045 |
|
|
|
2046 |
|
|
|
2047 |
if($currentUser->usertype_id == UserType::ADMIN) {
|
|
|
2048 |
$url_admin = $this->url()->fromRoute( 'backend/signin-admin');
|
|
|
2049 |
} else {
|
|
|
2050 |
$url_admin = '';
|
|
|
2051 |
}
|
|
|
2052 |
|
|
|
2053 |
|
|
|
2054 |
|
|
|
2055 |
$link_company = '';
|
|
|
2056 |
if($network->default != Network::DEFAULT_YES) {
|
|
|
2057 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
2058 |
$company = $companyMapper->fetchDefaultForNetworkByNetworkId($network->id);
|
|
|
2059 |
if($company) {
|
|
|
2060 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
2061 |
$companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($company->id, $currentUser->id);
|
|
|
2062 |
if($companyUser) {
|
|
|
2063 |
if($companyUser && $companyUser->status == CompanyUser::STATUS_ACCEPTED && $companyUser->backend == CompanyUser::BACKEND_YES ) {
|
|
|
2064 |
$link_company = ['route' => 'backend/signin-company', 'id' => $company->uuid ];
|
|
|
2065 |
}
|
|
|
2066 |
}
|
|
|
2067 |
}
|
157 |
efrain |
2068 |
} else {
|
|
|
2069 |
|
1 |
efrain |
2070 |
}
|
|
|
2071 |
|
167 |
efrain |
2072 |
|
|
|
2073 |
|
|
|
2074 |
|
|
|
2075 |
|
1 |
efrain |
2076 |
if ($acl->isAllowed($currentUser->usertype_id, 'knowledge-area')) {
|
302 |
www |
2077 |
$route_knowledge_area = $this->url()->fromRoute('knowledge-area', [], ['force_canonical' => true]);
|
1 |
efrain |
2078 |
$link_knowledge_area = 1;
|
|
|
2079 |
} else {
|
|
|
2080 |
|
|
|
2081 |
$route_knowledge_area = '';
|
|
|
2082 |
$link_knowledge_area = 0;
|
|
|
2083 |
}
|
|
|
2084 |
|
|
|
2085 |
if ($acl->isAllowed($currentUser->usertype_id, 'my-coach')) {
|
302 |
www |
2086 |
$route_my_coach = $this->url()->fromRoute('my-coach', [], ['force_canonical' => true]);
|
1 |
efrain |
2087 |
$link_my_coach = 1;
|
|
|
2088 |
} else {
|
|
|
2089 |
|
|
|
2090 |
$route_my_coach = '';
|
|
|
2091 |
$link_my_coach = 0;
|
|
|
2092 |
}
|
|
|
2093 |
|
|
|
2094 |
if($network->default == Network::DEFAULT_YES) {
|
|
|
2095 |
if($network->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER) {
|
|
|
2096 |
$pages = getAclMenuDefaultNetworkConnectionUser2User();
|
|
|
2097 |
} else {
|
|
|
2098 |
$pages = getAclMenuDefaultNetworkConnectionAll2All();
|
|
|
2099 |
}
|
|
|
2100 |
} else {
|
|
|
2101 |
if($network->relationship_user_mode == Network::RELATIONSHIP_USER_MODE_USER_2_USER) {
|
|
|
2102 |
|
|
|
2103 |
$pages = getAclMenuNonDefaulNetworkConnectionUser2User();
|
|
|
2104 |
|
|
|
2105 |
} else {
|
|
|
2106 |
$pages = getAclMenuNonDefaultNetworkConnectionAll2All();
|
|
|
2107 |
}
|
|
|
2108 |
}
|
|
|
2109 |
|
|
|
2110 |
|
|
|
2111 |
$menu = [];
|
|
|
2112 |
foreach ($pages as $page) {
|
|
|
2113 |
|
|
|
2114 |
if (!$page || empty($page['route']) || !$acl->isAllowed($currentUser->usertype_id, $page['route'])) {
|
|
|
2115 |
continue;
|
|
|
2116 |
}
|
|
|
2117 |
|
269 |
efrain |
2118 |
$childs = [];
|
|
|
2119 |
|
1 |
efrain |
2120 |
$ajax = false;
|
|
|
2121 |
if ($page['route'] == 'company' && $network->default == Network::DEFAULT_NO) {
|
|
|
2122 |
|
269 |
efrain |
2123 |
|
|
|
2124 |
|
1 |
efrain |
2125 |
if ($link_company) {
|
269 |
efrain |
2126 |
$ajax = true;
|
157 |
efrain |
2127 |
$page['route'] = $this->url()->fromRoute($link_company['route'], ['id' => $link_company['id']]);
|
269 |
efrain |
2128 |
|
|
|
2129 |
$childs = [
|
|
|
2130 |
'label' => 'Acceder',
|
|
|
2131 |
'href' => $page['route'],
|
|
|
2132 |
'ajax' => $ajax,
|
|
|
2133 |
'childs' => []
|
|
|
2134 |
];
|
|
|
2135 |
|
|
|
2136 |
|
|
|
2137 |
|
|
|
2138 |
|
1 |
efrain |
2139 |
} else {
|
|
|
2140 |
continue;
|
|
|
2141 |
}
|
|
|
2142 |
}
|
|
|
2143 |
|
|
|
2144 |
$option = [
|
|
|
2145 |
'label' => $page['label'],
|
|
|
2146 |
'href' => $page['route'],
|
|
|
2147 |
'img' => empty($page['class']) ? '' : $page['class'],
|
|
|
2148 |
'ajax' => $ajax ? 1 : 0,
|
269 |
efrain |
2149 |
'childs' => $childs,
|
1 |
efrain |
2150 |
];
|
|
|
2151 |
|
269 |
efrain |
2152 |
if ($page['route'] == 'company' && $network->default == Network::DEFAULT_NO) {
|
|
|
2153 |
if ($link_company) {
|
|
|
2154 |
array_push($option['childs'], );
|
|
|
2155 |
|
|
|
2156 |
|
|
|
2157 |
}
|
|
|
2158 |
}
|
|
|
2159 |
|
1 |
efrain |
2160 |
$childs = empty($page['pages']) ? [] : $page['pages'];
|
|
|
2161 |
if ($childs) {
|
|
|
2162 |
foreach ($childs as $child) {
|
|
|
2163 |
if (!$acl->isAllowed($currentUser->usertype_id, $child['route'])) {
|
|
|
2164 |
continue;
|
|
|
2165 |
}
|
|
|
2166 |
|
|
|
2167 |
$childs_level2 = [];
|
|
|
2168 |
|
|
|
2169 |
$childsLevel2 = empty($child['pages']) ? [] : $child['pages'];
|
|
|
2170 |
|
|
|
2171 |
if ($childsLevel2) {
|
|
|
2172 |
foreach ($childsLevel2 as $childLevel2) {
|
|
|
2173 |
if (!$acl->isAllowed($currentUser->usertype_id, $childLevel2['route'])) {
|
|
|
2174 |
continue;
|
|
|
2175 |
}
|
|
|
2176 |
|
|
|
2177 |
array_push($childs_level2, [
|
|
|
2178 |
'label' => $childLevel2['label'],
|
|
|
2179 |
'href' => $childLevel2['route'],
|
|
|
2180 |
|
|
|
2181 |
]);
|
|
|
2182 |
}
|
|
|
2183 |
}
|
|
|
2184 |
|
|
|
2185 |
array_push($option['childs'], [
|
|
|
2186 |
'label' => $child['label'],
|
|
|
2187 |
'href' => $child['route'],
|
|
|
2188 |
'childs' => $childs_level2,
|
|
|
2189 |
]);
|
|
|
2190 |
}
|
|
|
2191 |
}
|
|
|
2192 |
|
|
|
2193 |
array_push($menu, $option);
|
|
|
2194 |
}
|
|
|
2195 |
|
269 |
efrain |
2196 |
|
333 |
www |
2197 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
283 |
www |
2198 |
|
1 |
efrain |
2199 |
|
269 |
efrain |
2200 |
$image = $storage->getUserImage($currentUser);
|
1 |
efrain |
2201 |
$isChatPage = $this->getEvent()->getViewModel()->getVariable('is_chat');
|
|
|
2202 |
$routeCheckSession = $this->url()->fromRoute('check-session');
|
203 |
efrain |
2203 |
$routeAbuseReport = $this->url()->fromRoute('abuse-report');
|
1 |
efrain |
2204 |
|
|
|
2205 |
|
269 |
efrain |
2206 |
if($network->navbar) {
|
281 |
efrain |
2207 |
|
|
|
2208 |
|
|
|
2209 |
|
333 |
www |
2210 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
283 |
www |
2211 |
$path = $storage->getPathNetwork();
|
281 |
efrain |
2212 |
|
283 |
www |
2213 |
$navbar = $storage->getGenericImage($path, $network->uuid, $network->navbar);
|
281 |
efrain |
2214 |
|
|
|
2215 |
|
283 |
www |
2216 |
|
269 |
efrain |
2217 |
} else {
|
|
|
2218 |
$navbar = '';
|
|
|
2219 |
}
|
1 |
efrain |
2220 |
|
|
|
2221 |
return new JsonModel([
|
|
|
2222 |
'menu' => $menu,
|
|
|
2223 |
'isChatPage' => $isChatPage == 1,
|
|
|
2224 |
'routeCheckSession' => $routeCheckSession,
|
203 |
efrain |
2225 |
'routeAbuseReport' => $routeAbuseReport,
|
1 |
efrain |
2226 |
'linkAdmin' => $link_admin == 1,
|
|
|
2227 |
'urlAdmin' => $url_admin,
|
|
|
2228 |
'linkImpersonate' => $link_impersonate ==1 ,
|
|
|
2229 |
'urlImpersonate' => $url_impersonate,
|
|
|
2230 |
'image' => $image,
|
|
|
2231 |
'fullName' => $fullname,
|
|
|
2232 |
'country' => $country,
|
|
|
2233 |
'visits' => $visits,
|
|
|
2234 |
'connections' => $connections,
|
269 |
efrain |
2235 |
'logoForNavbar' => $navbar,
|
1 |
efrain |
2236 |
'defaultNetwork' => $network->default,
|
|
|
2237 |
]);
|
|
|
2238 |
|
|
|
2239 |
|
|
|
2240 |
|
|
|
2241 |
}
|
|
|
2242 |
|
|
|
2243 |
|
|
|
2244 |
return new JsonModel([
|
|
|
2245 |
'menu' => [],
|
|
|
2246 |
'isChatPage' => false,
|
|
|
2247 |
'routeCheckSession' => '',
|
|
|
2248 |
'linkAdmin' => false,
|
|
|
2249 |
'urlAdmin' => '',
|
|
|
2250 |
'linkImpersonate' => false,
|
|
|
2251 |
'urlImpersonate' => '',
|
|
|
2252 |
'image' => '',
|
|
|
2253 |
'fullName' => '',
|
|
|
2254 |
'country' => 0,
|
|
|
2255 |
'visits' => 0,
|
|
|
2256 |
'connections' => 0,
|
|
|
2257 |
'logoForNavbar' => 'https://' . $network->main_hostname . '/storage-network/type/navbar',
|
|
|
2258 |
'defaultNetwork' => $network->default,
|
|
|
2259 |
'linkKnowledgeArea' => false,
|
|
|
2260 |
'routeKnowledgeArea' => '',
|
|
|
2261 |
'linkMyCoach' => false,
|
|
|
2262 |
'routeMyCoach' => '',
|
|
|
2263 |
]);
|
|
|
2264 |
|
|
|
2265 |
} else {
|
|
|
2266 |
|
|
|
2267 |
return new JsonModel([
|
|
|
2268 |
'success' => false,
|
|
|
2269 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2270 |
]);
|
|
|
2271 |
}
|
|
|
2272 |
|
|
|
2273 |
|
|
|
2274 |
return new JsonModel([
|
|
|
2275 |
'success' => false,
|
|
|
2276 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2277 |
]);
|
|
|
2278 |
}
|
|
|
2279 |
|
|
|
2280 |
public function companySizesAction()
|
|
|
2281 |
{
|
|
|
2282 |
$request = $this->getRequest();
|
|
|
2283 |
|
|
|
2284 |
|
|
|
2285 |
|
|
|
2286 |
if ($request->isGet()) {
|
|
|
2287 |
$items = [];
|
|
|
2288 |
|
|
|
2289 |
$mapper = CompanySizeMapper::getInstance($this->adapter);
|
|
|
2290 |
$records = $mapper->fetchAllActive();
|
|
|
2291 |
foreach($records as $record)
|
|
|
2292 |
{
|
|
|
2293 |
$items[ $record->uuid ] = $record->name;
|
|
|
2294 |
}
|
|
|
2295 |
|
|
|
2296 |
return new JsonModel([
|
|
|
2297 |
'success' => true,
|
|
|
2298 |
'data' => $items
|
|
|
2299 |
]);
|
|
|
2300 |
|
|
|
2301 |
|
|
|
2302 |
}
|
|
|
2303 |
return new JsonModel([
|
|
|
2304 |
'success' => false,
|
|
|
2305 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2306 |
]);
|
|
|
2307 |
}
|
|
|
2308 |
|
|
|
2309 |
public function degreesAction()
|
|
|
2310 |
{
|
|
|
2311 |
$request = $this->getRequest();
|
|
|
2312 |
|
|
|
2313 |
|
|
|
2314 |
|
|
|
2315 |
if ($request->isGet()) {
|
|
|
2316 |
$items = [];
|
|
|
2317 |
|
|
|
2318 |
$mapper = DegreeMapper::getInstance($this->adapter);
|
|
|
2319 |
$records = $mapper->fetchAllActive();
|
|
|
2320 |
foreach($records as $record)
|
|
|
2321 |
{
|
|
|
2322 |
$items[ $record->uuid ] = $record->name;
|
|
|
2323 |
}
|
|
|
2324 |
|
|
|
2325 |
return new JsonModel([
|
|
|
2326 |
'success' => true,
|
|
|
2327 |
'data' => $items
|
|
|
2328 |
]);
|
|
|
2329 |
|
|
|
2330 |
|
|
|
2331 |
}
|
|
|
2332 |
return new JsonModel([
|
|
|
2333 |
'success' => false,
|
|
|
2334 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2335 |
]);
|
|
|
2336 |
}
|
|
|
2337 |
|
|
|
2338 |
public function languagesAction()
|
|
|
2339 |
{
|
|
|
2340 |
$request = $this->getRequest();
|
|
|
2341 |
|
|
|
2342 |
|
|
|
2343 |
|
|
|
2344 |
if ($request->isGet()) {
|
|
|
2345 |
$items = [];
|
|
|
2346 |
|
|
|
2347 |
$mapper = LanguageMapper::getInstance($this->adapter);
|
|
|
2348 |
$records = $mapper->fetchAllActive();
|
|
|
2349 |
foreach($records as $record)
|
|
|
2350 |
{
|
|
|
2351 |
$items[ $record->id ] = $record->name;
|
|
|
2352 |
}
|
|
|
2353 |
|
|
|
2354 |
return new JsonModel([
|
|
|
2355 |
'success' => true,
|
|
|
2356 |
'data' => $items
|
|
|
2357 |
]);
|
|
|
2358 |
|
|
|
2359 |
|
|
|
2360 |
}
|
|
|
2361 |
return new JsonModel([
|
|
|
2362 |
'success' => false,
|
|
|
2363 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2364 |
]);
|
|
|
2365 |
}
|
|
|
2366 |
|
|
|
2367 |
public function skillsAction()
|
|
|
2368 |
{
|
|
|
2369 |
$request = $this->getRequest();
|
|
|
2370 |
|
|
|
2371 |
|
|
|
2372 |
|
|
|
2373 |
if ($request->isGet()) {
|
|
|
2374 |
$items = [];
|
|
|
2375 |
|
|
|
2376 |
$mapper = SkillMapper::getInstance($this->adapter);
|
|
|
2377 |
$records = $mapper->fetchAllActive();
|
|
|
2378 |
foreach($records as $record)
|
|
|
2379 |
{
|
|
|
2380 |
$items[ $record->uuid ] = $record->name;
|
|
|
2381 |
}
|
|
|
2382 |
|
|
|
2383 |
return new JsonModel([
|
|
|
2384 |
'success' => true,
|
|
|
2385 |
'data' => $items
|
|
|
2386 |
]);
|
|
|
2387 |
|
|
|
2388 |
|
|
|
2389 |
}
|
|
|
2390 |
return new JsonModel([
|
|
|
2391 |
'success' => false,
|
|
|
2392 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2393 |
]);
|
|
|
2394 |
}
|
|
|
2395 |
|
|
|
2396 |
|
|
|
2397 |
public function aptitudesAction()
|
|
|
2398 |
{
|
|
|
2399 |
$request = $this->getRequest();
|
|
|
2400 |
|
|
|
2401 |
|
|
|
2402 |
|
|
|
2403 |
if ($request->isGet()) {
|
|
|
2404 |
$items = [];
|
|
|
2405 |
|
|
|
2406 |
$mapper = AptitudeMapper::getInstance($this->adapter);
|
|
|
2407 |
$records = $mapper->fetchAllActive();
|
|
|
2408 |
foreach($records as $record)
|
|
|
2409 |
{
|
|
|
2410 |
$items[ $record->uuid ] = $record->name;
|
|
|
2411 |
}
|
|
|
2412 |
|
|
|
2413 |
return new JsonModel([
|
|
|
2414 |
'success' => true,
|
|
|
2415 |
'data' => $items
|
|
|
2416 |
]);
|
|
|
2417 |
|
|
|
2418 |
|
|
|
2419 |
}
|
|
|
2420 |
return new JsonModel([
|
|
|
2421 |
'success' => false,
|
|
|
2422 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2423 |
]);
|
|
|
2424 |
}
|
|
|
2425 |
|
|
|
2426 |
public function hobbiesAction()
|
|
|
2427 |
{
|
|
|
2428 |
$request = $this->getRequest();
|
|
|
2429 |
|
|
|
2430 |
|
|
|
2431 |
|
|
|
2432 |
if ($request->isGet()) {
|
|
|
2433 |
$items = [];
|
|
|
2434 |
|
|
|
2435 |
$mapper = HobbyAndInterestMapper::getInstance($this->adapter);
|
|
|
2436 |
$records = $mapper->fetchAllActive();
|
|
|
2437 |
foreach($records as $record)
|
|
|
2438 |
{
|
|
|
2439 |
$items[ $record->uuid ] = $record->name;
|
|
|
2440 |
}
|
|
|
2441 |
|
|
|
2442 |
return new JsonModel([
|
|
|
2443 |
'success' => true,
|
|
|
2444 |
'data' => $items
|
|
|
2445 |
]);
|
|
|
2446 |
|
|
|
2447 |
|
|
|
2448 |
}
|
|
|
2449 |
return new JsonModel([
|
|
|
2450 |
'success' => false,
|
|
|
2451 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2452 |
]);
|
|
|
2453 |
}
|
|
|
2454 |
|
|
|
2455 |
public function industriesAction()
|
|
|
2456 |
{
|
|
|
2457 |
$request = $this->getRequest();
|
|
|
2458 |
|
|
|
2459 |
|
|
|
2460 |
|
|
|
2461 |
if ($request->isGet()) {
|
|
|
2462 |
$items = [];
|
|
|
2463 |
|
|
|
2464 |
$mapper = IndustryMapper::getInstance($this->adapter);
|
|
|
2465 |
$records = $mapper->fetchAllActive();
|
|
|
2466 |
foreach($records as $record)
|
|
|
2467 |
{
|
|
|
2468 |
$items[ $record->uuid ] = $record->name;
|
|
|
2469 |
}
|
|
|
2470 |
|
|
|
2471 |
return new JsonModel([
|
|
|
2472 |
'success' => true,
|
|
|
2473 |
'data' => $items
|
|
|
2474 |
]);
|
|
|
2475 |
|
|
|
2476 |
|
|
|
2477 |
}
|
|
|
2478 |
return new JsonModel([
|
|
|
2479 |
'success' => false,
|
|
|
2480 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2481 |
]);
|
|
|
2482 |
}
|
|
|
2483 |
|
|
|
2484 |
public function timeZonesAction() {
|
|
|
2485 |
|
|
|
2486 |
$request = $this->getRequest();
|
|
|
2487 |
|
|
|
2488 |
|
|
|
2489 |
|
|
|
2490 |
if ($request->isGet()) {
|
|
|
2491 |
$items = [];
|
|
|
2492 |
|
|
|
2493 |
|
|
|
2494 |
$records = Functions::getAllTimeZones();
|
|
|
2495 |
foreach($records as $record)
|
|
|
2496 |
{
|
|
|
2497 |
$items[ $record ] = $record;
|
|
|
2498 |
}
|
|
|
2499 |
|
|
|
2500 |
return new JsonModel([
|
|
|
2501 |
'success' => true,
|
|
|
2502 |
'data' => $items
|
|
|
2503 |
]);
|
|
|
2504 |
|
|
|
2505 |
|
|
|
2506 |
}
|
|
|
2507 |
return new JsonModel([
|
|
|
2508 |
'success' => false,
|
|
|
2509 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2510 |
]);
|
|
|
2511 |
|
|
|
2512 |
|
|
|
2513 |
|
|
|
2514 |
|
|
|
2515 |
|
|
|
2516 |
|
|
|
2517 |
}
|
|
|
2518 |
|
117 |
efrain |
2519 |
|
|
|
2520 |
public function groupTypesAction()
|
|
|
2521 |
{
|
|
|
2522 |
$request = $this->getRequest();
|
|
|
2523 |
|
|
|
2524 |
|
|
|
2525 |
|
|
|
2526 |
if ($request->isGet()) {
|
|
|
2527 |
$items = [];
|
|
|
2528 |
|
|
|
2529 |
$mapper = GroupTypeMapper::getInstance($this->adapter);
|
|
|
2530 |
$records = $mapper->fetchAllActive();
|
|
|
2531 |
foreach($records as $record)
|
|
|
2532 |
{
|
|
|
2533 |
$items[ $record->uuid ] = $record->name;
|
|
|
2534 |
}
|
|
|
2535 |
|
|
|
2536 |
return new JsonModel([
|
|
|
2537 |
'success' => true,
|
|
|
2538 |
'data' => $items
|
|
|
2539 |
]);
|
|
|
2540 |
|
|
|
2541 |
|
|
|
2542 |
}
|
|
|
2543 |
return new JsonModel([
|
|
|
2544 |
'success' => false,
|
|
|
2545 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2546 |
]);
|
|
|
2547 |
}
|
|
|
2548 |
|
|
|
2549 |
|
192 |
efrain |
2550 |
public function abuseReportAction()
|
|
|
2551 |
{
|
195 |
efrain |
2552 |
|
|
|
2553 |
|
|
|
2554 |
|
192 |
efrain |
2555 |
$request = $this->getRequest();
|
|
|
2556 |
|
|
|
2557 |
if ($request->isPost()) {
|
|
|
2558 |
|
|
|
2559 |
$dataPost = $request->getPost()->toArray();
|
|
|
2560 |
|
|
|
2561 |
$form = new CreateForm();
|
|
|
2562 |
$form->setData($dataPost);
|
|
|
2563 |
|
195 |
efrain |
2564 |
|
|
|
2565 |
|
192 |
efrain |
2566 |
if(!$form->isValid()) {
|
|
|
2567 |
$messages = [];
|
195 |
efrain |
2568 |
|
192 |
efrain |
2569 |
|
|
|
2570 |
|
|
|
2571 |
$form_messages = (array) $form->getMessages();
|
|
|
2572 |
foreach($form_messages as $fieldname => $field_messages)
|
|
|
2573 |
{
|
|
|
2574 |
|
|
|
2575 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
2576 |
}
|
|
|
2577 |
|
195 |
efrain |
2578 |
|
|
|
2579 |
|
192 |
efrain |
2580 |
return new JsonModel([
|
|
|
2581 |
'success' => false,
|
|
|
2582 |
'data' => $messages
|
|
|
2583 |
]);
|
|
|
2584 |
|
|
|
2585 |
}
|
195 |
efrain |
2586 |
|
192 |
efrain |
2587 |
|
|
|
2588 |
$dataPost = (array) $form->getData();
|
1 |
efrain |
2589 |
|
192 |
efrain |
2590 |
$currentNetworkPlugin = $this->plugin('currentNetworkPlugin');
|
|
|
2591 |
$network = $currentNetworkPlugin->getNetwork();
|
|
|
2592 |
|
|
|
2593 |
|
|
|
2594 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
2595 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
2596 |
|
|
|
2597 |
$id = $this->params()->fromRoute('id');
|
|
|
2598 |
$type = $this->params()->fromRoute('type');
|
|
|
2599 |
|
|
|
2600 |
$blockUser = $dataPost['block_user'] == 'y';
|
|
|
2601 |
|
|
|
2602 |
$abuseReport = new AbuseReport();
|
|
|
2603 |
$abuseReport->network_id = $network->id;
|
|
|
2604 |
$abuseReport->user_reporting_id = $currentUser->id;
|
|
|
2605 |
$abuseReport->status = AbuseReport::STATUS_PENDING;
|
|
|
2606 |
$abuseReport->comment = $dataPost['comment'];
|
|
|
2607 |
$abuseReport->reason = $dataPost['reason'];
|
|
|
2608 |
|
195 |
efrain |
2609 |
|
192 |
efrain |
2610 |
|
|
|
2611 |
switch($type)
|
|
|
2612 |
{
|
|
|
2613 |
case 'feed' :
|
195 |
efrain |
2614 |
$feedMapper = FeedMapper::getInstance($this->adapter);
|
192 |
efrain |
2615 |
$feed = $feedMapper->fetchOneByUuid($id);
|
|
|
2616 |
if(!$feed || $feed->status != Feed::STATUS_PUBLISHED || $feed->network_id != $network->id) {
|
|
|
2617 |
|
|
|
2618 |
return new JsonModel([
|
|
|
2619 |
'success' => false,
|
|
|
2620 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_NOT_AVAILABLE'
|
|
|
2621 |
]);
|
|
|
2622 |
}
|
|
|
2623 |
|
|
|
2624 |
if($feed->user_id == 1) {
|
|
|
2625 |
return new JsonModel([
|
|
|
2626 |
'success' => false,
|
|
|
2627 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_OWNER_SYSADMIN'
|
|
|
2628 |
]);
|
|
|
2629 |
}
|
|
|
2630 |
|
|
|
2631 |
if($feed->user_id == $currentUser->id) {
|
|
|
2632 |
return new JsonModel([
|
|
|
2633 |
'success' => false,
|
|
|
2634 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_OWNER_IS_YOURSELF'
|
|
|
2635 |
]);
|
|
|
2636 |
}
|
|
|
2637 |
|
|
|
2638 |
$abuseReport->related_id = $feed->id;
|
|
|
2639 |
$abuseReport->user_reported_id = $feed->user_id;
|
|
|
2640 |
$abuseReport->type = AbuseReport::TYPE_FEED;
|
|
|
2641 |
|
|
|
2642 |
|
|
|
2643 |
|
|
|
2644 |
break;
|
|
|
2645 |
|
|
|
2646 |
case 'post' :
|
|
|
2647 |
$postMapper = PostMapper::getInstance($this->adapter);
|
|
|
2648 |
$post = $postMapper->fetchOneByUuid($id);
|
|
|
2649 |
if(!$post || $post->status != Post::STATUS_ACTIVE || $post->network_id != $network->id) {
|
|
|
2650 |
|
|
|
2651 |
return new JsonModel([
|
|
|
2652 |
'success' => false,
|
|
|
2653 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_NOT_AVAILABLE'
|
|
|
2654 |
]);
|
|
|
2655 |
}
|
|
|
2656 |
|
|
|
2657 |
if($post->user_id == 1) {
|
|
|
2658 |
return new JsonModel([
|
|
|
2659 |
'success' => false,
|
|
|
2660 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_OWNER_SYSADMIN'
|
|
|
2661 |
]);
|
|
|
2662 |
}
|
|
|
2663 |
|
|
|
2664 |
|
|
|
2665 |
if($post->user_id == $currentUser->id) {
|
|
|
2666 |
return new JsonModel([
|
|
|
2667 |
'success' => false,
|
|
|
2668 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_OWNER_IS_YOURSELF'
|
|
|
2669 |
]);
|
|
|
2670 |
}
|
|
|
2671 |
|
|
|
2672 |
|
|
|
2673 |
$abuseReport->related_id = $post->id;
|
|
|
2674 |
$abuseReport->user_reported_id = $post->user_id;
|
|
|
2675 |
$abuseReport->type = AbuseReport::TYPE_POST;
|
|
|
2676 |
|
|
|
2677 |
break;
|
|
|
2678 |
|
|
|
2679 |
|
|
|
2680 |
case 'comment' :
|
|
|
2681 |
$commentMapper = CommentMapper::getInstance($this->adapter);
|
|
|
2682 |
$comment = $commentMapper->fetchOneByUuid($id);
|
|
|
2683 |
if(!$comment || $comment->network_id != $network->id || $comment->status != Comment::STATUS_PUBLISHED) {
|
|
|
2684 |
|
|
|
2685 |
return new JsonModel([
|
|
|
2686 |
'success' => false,
|
|
|
2687 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_NOT_AVAILABLE'
|
|
|
2688 |
]);
|
|
|
2689 |
}
|
|
|
2690 |
|
|
|
2691 |
if($comment->user_id == 1) {
|
|
|
2692 |
return new JsonModel([
|
|
|
2693 |
'success' => false,
|
|
|
2694 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_OWNER_SYSADMIN'
|
|
|
2695 |
]);
|
|
|
2696 |
}
|
|
|
2697 |
|
|
|
2698 |
if($comment->user_id == $currentUser->id) {
|
|
|
2699 |
return new JsonModel([
|
|
|
2700 |
'success' => false,
|
|
|
2701 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_OWNER_IS_YOURSELF'
|
|
|
2702 |
]);
|
|
|
2703 |
}
|
|
|
2704 |
|
|
|
2705 |
$abuseReport->related_id = $comment->id;
|
|
|
2706 |
$abuseReport->user_reported_id = $comment->user_id;
|
|
|
2707 |
$abuseReport->type = AbuseReport::TYPE_COMMENT;
|
|
|
2708 |
|
|
|
2709 |
break;
|
|
|
2710 |
|
709 |
stevensc |
2711 |
|
192 |
efrain |
2712 |
case 'message' :
|
|
|
2713 |
$messageMapper = MessageMapper::getInstance($this->adapter);
|
|
|
2714 |
$message = $messageMapper->fetchOneByUuid($id);
|
|
|
2715 |
if(!$message || $message->receiver_id != $currentUser->id || $message->receiver_status != Message::STATUS_NORMAL) {
|
|
|
2716 |
|
|
|
2717 |
return new JsonModel([
|
|
|
2718 |
'success' => false,
|
|
|
2719 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_NOT_AVAILABLE'
|
|
|
2720 |
]);
|
|
|
2721 |
}
|
|
|
2722 |
|
|
|
2723 |
if($message->sender_id == 1) {
|
|
|
2724 |
return new JsonModel([
|
|
|
2725 |
'success' => false,
|
|
|
2726 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_OWNER_SYSADMIN'
|
|
|
2727 |
]);
|
|
|
2728 |
}
|
|
|
2729 |
|
|
|
2730 |
$abuseReport->related_id = $message->id;
|
|
|
2731 |
$abuseReport->user_reported_id = $message->sender_id;
|
|
|
2732 |
$abuseReport->type = AbuseReport::TYPE_INMAIL_MESSAGE;
|
|
|
2733 |
|
|
|
2734 |
break;
|
269 |
efrain |
2735 |
|
192 |
efrain |
2736 |
case 'chat-message' :
|
|
|
2737 |
$messageMapper = ChatMessageMapper::getInstance($this->adapter);
|
|
|
2738 |
$message = $messageMapper->fetchOneByUuid($id);
|
|
|
2739 |
if(!$message || $message->to_id != $currentUser->id || $message->status != ChatMessage::STATUS_PUBLISHED) {
|
|
|
2740 |
|
|
|
2741 |
return new JsonModel([
|
|
|
2742 |
'success' => false,
|
|
|
2743 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_NOT_AVAILABLE'
|
|
|
2744 |
]);
|
|
|
2745 |
}
|
|
|
2746 |
|
|
|
2747 |
if($message->from_id == 1) {
|
|
|
2748 |
return new JsonModel([
|
|
|
2749 |
'success' => false,
|
|
|
2750 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_OWNER_SYSADMIN'
|
|
|
2751 |
]);
|
|
|
2752 |
}
|
|
|
2753 |
|
|
|
2754 |
$abuseReport->related_id = $message->id;
|
|
|
2755 |
$abuseReport->user_reported_id = $message->from_id;
|
|
|
2756 |
$abuseReport->type = AbuseReport::TYPE_CHAT_USER_MESSAGE;
|
|
|
2757 |
|
|
|
2758 |
break;
|
269 |
efrain |
2759 |
|
192 |
efrain |
2760 |
case 'chat-group-message' :
|
|
|
2761 |
$messageMapper = ChatGroupMessageMapper::getInstance($this->adapter);
|
|
|
2762 |
$message = $messageMapper->fetchOne($id);
|
|
|
2763 |
if(!$message || $message->status != ChatMessage::STATUS_PUBLISHED) {
|
|
|
2764 |
|
|
|
2765 |
return new JsonModel([
|
|
|
2766 |
'success' => false,
|
|
|
2767 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_NOT_AVAILABLE'
|
|
|
2768 |
]);
|
|
|
2769 |
}
|
|
|
2770 |
|
|
|
2771 |
$userMessageMapper = ChatGroupUserMessageMapper::getInstance($this->adapter);
|
|
|
2772 |
$userMessage = $userMessageMapper->fetchOneByIdMessageIdAndReceiverId($message->id, $currentUser->id);
|
|
|
2773 |
if(!$userMessage) {
|
|
|
2774 |
|
|
|
2775 |
return new JsonModel([
|
|
|
2776 |
'success' => false,
|
|
|
2777 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_NOT_AVAILABLE'
|
|
|
2778 |
]);
|
|
|
2779 |
}
|
|
|
2780 |
|
|
|
2781 |
|
|
|
2782 |
if($message->sender_id == 1) {
|
|
|
2783 |
return new JsonModel([
|
|
|
2784 |
'success' => false,
|
|
|
2785 |
'data' => 'ERROR_ABUSE_REPORT_CONTENT_OWNER_SYSADMIN'
|
|
|
2786 |
]);
|
|
|
2787 |
}
|
|
|
2788 |
|
|
|
2789 |
$abuseReport->related_id = $message->id;
|
|
|
2790 |
$abuseReport->user_reported_id = $message->sender_id;
|
|
|
2791 |
$abuseReport->type = AbuseReport::TYPE_CHAT_USER_MESSAGE;
|
|
|
2792 |
|
709 |
stevensc |
2793 |
break;
|
192 |
efrain |
2794 |
}
|
195 |
efrain |
2795 |
|
|
|
2796 |
|
192 |
efrain |
2797 |
|
|
|
2798 |
$abuseReportMapper = AbuseReportMapper::getInstance($this->adapter);
|
|
|
2799 |
if($abuseReportMapper->insert($abuseReport)) {
|
|
|
2800 |
|
|
|
2801 |
if($blockUser) {
|
|
|
2802 |
|
|
|
2803 |
$userBlockedMapper = UserBlockedMapper::getInstance($this->adapter);
|
|
|
2804 |
$userBlocked = $userBlockedMapper->fetchOneByUserIdAndBlockedId($abuseReport->user_reporting_id, $abuseReport->user_reporting_id);
|
|
|
2805 |
if($userBlocked) {
|
|
|
2806 |
|
|
|
2807 |
|
|
|
2808 |
return new JsonModel([
|
|
|
2809 |
'success' => true,
|
|
|
2810 |
'data' => [
|
|
|
2811 |
'message' => 'LABEL_ABUSE_REPORT_SENT_WITH_BLOCK_USER',
|
|
|
2812 |
'block' => true
|
|
|
2813 |
]
|
|
|
2814 |
]);
|
|
|
2815 |
|
|
|
2816 |
} else {
|
|
|
2817 |
|
|
|
2818 |
$userBlocked = new UserBlocked();
|
|
|
2819 |
$userBlocked->user_id = $abuseReport->user_reporting_id;
|
|
|
2820 |
$userBlocked->blocked_id = $abuseReport->user_reported_id;
|
|
|
2821 |
|
|
|
2822 |
if($userBlockedMapper->insert($userBlocked)) {
|
|
|
2823 |
return new JsonModel([
|
|
|
2824 |
'success' => true,
|
|
|
2825 |
'data' => [
|
|
|
2826 |
'message' => 'LABEL_ABUSE_REPORT_SENT_WITH_BLOCK_USER',
|
|
|
2827 |
'block' => true
|
|
|
2828 |
]
|
|
|
2829 |
]);
|
|
|
2830 |
|
|
|
2831 |
} else {
|
|
|
2832 |
return new JsonModel([
|
|
|
2833 |
'success' => true,
|
|
|
2834 |
'data' => [
|
|
|
2835 |
'message' => 'LABEL_ABUSE_REPORT_SENT_WITHOUT_BLOCK_USER',
|
|
|
2836 |
'block' => false
|
|
|
2837 |
]
|
|
|
2838 |
]);
|
|
|
2839 |
|
|
|
2840 |
|
|
|
2841 |
}
|
|
|
2842 |
}
|
|
|
2843 |
|
|
|
2844 |
|
|
|
2845 |
} else {
|
|
|
2846 |
return new JsonModel([
|
|
|
2847 |
'success' => true,
|
|
|
2848 |
'data' => [
|
|
|
2849 |
'message' => 'LABEL_ABUSE_REPORT_SENT_WITHOUT_BLOCK_USER',
|
|
|
2850 |
'block' => false
|
|
|
2851 |
]
|
|
|
2852 |
]);
|
|
|
2853 |
}
|
|
|
2854 |
|
|
|
2855 |
|
|
|
2856 |
} else {
|
|
|
2857 |
return new JsonModel([
|
|
|
2858 |
'success' => false,
|
|
|
2859 |
'data' => 'ERROR_ABUSE_REPORT_NOT_SENT'
|
|
|
2860 |
]);
|
|
|
2861 |
}
|
|
|
2862 |
|
|
|
2863 |
|
|
|
2864 |
|
|
|
2865 |
|
|
|
2866 |
|
|
|
2867 |
|
|
|
2868 |
|
|
|
2869 |
|
|
|
2870 |
}
|
|
|
2871 |
return new JsonModel([
|
|
|
2872 |
'success' => false,
|
|
|
2873 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2874 |
]);
|
|
|
2875 |
|
|
|
2876 |
|
307 |
www |
2877 |
|
|
|
2878 |
|
|
|
2879 |
|
192 |
efrain |
2880 |
}
|
|
|
2881 |
|
307 |
www |
2882 |
public function habitsAndSkillsAction()
|
|
|
2883 |
{
|
|
|
2884 |
$request = $this->getRequest();
|
|
|
2885 |
$request = $this->getRequest();
|
|
|
2886 |
if ($request->isGet()) {
|
321 |
www |
2887 |
|
|
|
2888 |
$items = [];
|
322 |
www |
2889 |
|
321 |
www |
2890 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
2891 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
2892 |
|
|
|
2893 |
|
|
|
2894 |
|
|
|
2895 |
$company_ids = [];
|
|
|
2896 |
$habitUserMapper = \LeadersLinked\Mapper\HabitUserMapper::getInstance($this->adapter);
|
|
|
2897 |
$records = $habitUserMapper->fetchAllActiveByUserId($currentUser->id);
|
|
|
2898 |
foreach($records as $record)
|
|
|
2899 |
{
|
|
|
2900 |
if($record->company_id) {
|
|
|
2901 |
|
|
|
2902 |
if(!in_array($record->company_id, $company_ids)) {
|
|
|
2903 |
array_push($company_ids, $record->company_id);
|
|
|
2904 |
}
|
|
|
2905 |
}
|
|
|
2906 |
}
|
|
|
2907 |
|
|
|
2908 |
|
|
|
2909 |
if($company_ids) {
|
|
|
2910 |
|
|
|
2911 |
$habitSkillMapper = \LeadersLinked\Mapper\HabitSkillMapper::getInstance($this->adapter);
|
|
|
2912 |
$records = $habitSkillMapper->fetchAllTemplateByCompayIds($company_ids);
|
|
|
2913 |
foreach($records as $record)
|
|
|
2914 |
{
|
|
|
2915 |
array_push($items, [
|
|
|
2916 |
'uuid' => $record->uuid,
|
|
|
2917 |
'name' => $record->name,
|
|
|
2918 |
'link' => $this->url()->fromRoute('helpers/habits-and-skills/get', ['id' => $record->uuid], ['force_canonical' => true]),
|
|
|
2919 |
|
|
|
2920 |
|
|
|
2921 |
|
|
|
2922 |
]);
|
|
|
2923 |
}
|
|
|
2924 |
}
|
322 |
www |
2925 |
|
321 |
www |
2926 |
|
|
|
2927 |
|
|
|
2928 |
return new JsonModel([
|
|
|
2929 |
'success' => true,
|
|
|
2930 |
'data' => $items,
|
|
|
2931 |
]);
|
|
|
2932 |
|
|
|
2933 |
}
|
|
|
2934 |
return new JsonModel([
|
|
|
2935 |
'success' => false,
|
|
|
2936 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
2937 |
]);
|
|
|
2938 |
}
|
|
|
2939 |
|
|
|
2940 |
public function habitsAndSkillsGetAction()
|
|
|
2941 |
{
|
|
|
2942 |
$request = $this->getRequest();
|
|
|
2943 |
$request = $this->getRequest();
|
|
|
2944 |
if ($request->isGet()) {
|
|
|
2945 |
|
307 |
www |
2946 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
2947 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
2948 |
|
321 |
www |
2949 |
|
|
|
2950 |
$id = Functions::sanitizeFilterString($this->params()->fromRoute('id'));
|
|
|
2951 |
|
|
|
2952 |
$habitSkillMapper = \LeadersLinked\Mapper\HabitSkillMapper::getInstance($this->adapter);
|
|
|
2953 |
$habitSkill = $habitSkillMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
|
|
|
2954 |
|
|
|
2955 |
|
|
|
2956 |
if(!$habitSkill) {
|
|
|
2957 |
return new JsonModel([
|
|
|
2958 |
'success' => true,
|
|
|
2959 |
'data' => 'ERROR_HABIT_NOT_FOUND'
|
|
|
2960 |
]);
|
|
|
2961 |
}
|
|
|
2962 |
|
|
|
2963 |
|
|
|
2964 |
$allow = false;
|
307 |
www |
2965 |
$habitUserMapper = \LeadersLinked\Mapper\HabitUserMapper::getInstance($this->adapter);
|
|
|
2966 |
$records = $habitUserMapper->fetchAllActiveByUserId($currentUser->id);
|
|
|
2967 |
foreach($records as $record)
|
|
|
2968 |
{
|
321 |
www |
2969 |
if($habitSkill->company_id == $record->company_id) {
|
|
|
2970 |
|
|
|
2971 |
$allow = true;
|
|
|
2972 |
break;
|
307 |
www |
2973 |
}
|
|
|
2974 |
}
|
|
|
2975 |
|
321 |
www |
2976 |
if(!$allow) {
|
|
|
2977 |
return new JsonModel([
|
|
|
2978 |
'success' => true,
|
|
|
2979 |
'data' => 'ERROR_HABIT_YOU_DO_NOT_HAVE_ACCESS_TO_THIS'
|
|
|
2980 |
]);
|
307 |
www |
2981 |
}
|
321 |
www |
2982 |
|
307 |
www |
2983 |
return new JsonModel([
|
|
|
2984 |
'success' => true,
|
321 |
www |
2985 |
'data' =>[
|
|
|
2986 |
'uuid' => $habitSkill->uuid,
|
|
|
2987 |
'name' => $habitSkill->name,
|
|
|
2988 |
'description' => $habitSkill->description,
|
|
|
2989 |
'intelligence' => $habitSkill->intelligence,
|
|
|
2990 |
'monday_active' => $habitSkill->monday_active,
|
|
|
2991 |
'monday_time' => $habitSkill->monday_time,
|
|
|
2992 |
'tuesday_active' => $habitSkill->tuesday_active,
|
|
|
2993 |
'tuesday_time' => $habitSkill->tuesday_time,
|
|
|
2994 |
'wednesday_active' => $habitSkill->wednesday_active,
|
|
|
2995 |
'wednesday_time' => $habitSkill->wednesday_time,
|
|
|
2996 |
'thursday_active' => $habitSkill->thursday_active,
|
|
|
2997 |
'thursday_time' => $habitSkill->thursday_time,
|
|
|
2998 |
'friday_active' => $habitSkill->friday_active,
|
|
|
2999 |
'friday_time' => $habitSkill->friday_time,
|
|
|
3000 |
'saturday_active' => $habitSkill->saturday_active,
|
|
|
3001 |
'saturday_time' => $habitSkill->saturday_time,
|
|
|
3002 |
'sunday_active' => $habitSkill->sunday_active,
|
|
|
3003 |
'sunday_time' => $habitSkill->sunday_time,
|
|
|
3004 |
|
|
|
3005 |
'quantitative_value' => $habitSkill->quantitative_value,
|
|
|
3006 |
'qualitative_description' => $habitSkill->qualitative_description,
|
|
|
3007 |
'notification_10min_before' => $habitSkill->notification_10min_before,
|
|
|
3008 |
'notification_30min_before' => $habitSkill->notification_30min_before,
|
|
|
3009 |
|
|
|
3010 |
|
|
|
3011 |
],
|
307 |
www |
3012 |
]);
|
|
|
3013 |
|
|
|
3014 |
}
|
|
|
3015 |
return new JsonModel([
|
|
|
3016 |
'success' => false,
|
|
|
3017 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
3018 |
]);
|
|
|
3019 |
}
|
192 |
efrain |
3020 |
|
323 |
www |
3021 |
|
|
|
3022 |
public function myHabitsAndSkillsGetAction()
|
|
|
3023 |
{
|
|
|
3024 |
$request = $this->getRequest();
|
|
|
3025 |
$request = $this->getRequest();
|
|
|
3026 |
if ($request->isGet()) {
|
|
|
3027 |
|
|
|
3028 |
$items = [];
|
|
|
3029 |
|
|
|
3030 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
3031 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
3032 |
|
|
|
3033 |
|
|
|
3034 |
$habitSkillMapper = \LeadersLinked\Mapper\HabitSkillMapper::getInstance($this->adapter);
|
|
|
3035 |
$records = $habitSkillMapper->fetchAllByUserId($currentUser->id);
|
|
|
3036 |
foreach($records as $record)
|
|
|
3037 |
{
|
|
|
3038 |
array_push($items, [
|
|
|
3039 |
'uuid' => $record->uuid,
|
|
|
3040 |
'name' => $record->name,
|
|
|
3041 |
'link' => $this->url()->fromRoute('habits/skills/registers', ['id' => $record->uuid], ['force_canonical' => true]),
|
|
|
3042 |
]);
|
|
|
3043 |
}
|
192 |
efrain |
3044 |
|
323 |
www |
3045 |
|
|
|
3046 |
return new JsonModel([
|
|
|
3047 |
'success' => true,
|
|
|
3048 |
'data' => $items,
|
|
|
3049 |
]);
|
|
|
3050 |
|
|
|
3051 |
}
|
|
|
3052 |
return new JsonModel([
|
|
|
3053 |
'success' => false,
|
|
|
3054 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
3055 |
]);
|
|
|
3056 |
}
|
|
|
3057 |
|
|
|
3058 |
|
1 |
efrain |
3059 |
}
|