| 1 |
www |
1 |
<?php
|
| 5500 |
anderson |
2 |
|
| 1 |
www |
3 |
/**
|
|
|
4 |
*
|
|
|
5 |
* Controlador: Mis Perfiles
|
|
|
6 |
*
|
|
|
7 |
*/
|
| 5500 |
anderson |
8 |
|
| 1 |
www |
9 |
declare(strict_types=1);
|
|
|
10 |
|
|
|
11 |
namespace LeadersLinked\Controller;
|
|
|
12 |
|
|
|
13 |
use Laminas\Db\Adapter\AdapterInterface;
|
|
|
14 |
use Laminas\Cache\Storage\Adapter\AbstractAdapter;
|
|
|
15 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
16 |
use Laminas\Log\LoggerInterface;
|
|
|
17 |
use Laminas\View\Model\JsonModel;
|
|
|
18 |
|
|
|
19 |
use LeadersLinked\Library\Functions;
|
|
|
20 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
|
|
21 |
use LeadersLinked\Form\Feed\CreateForm;
|
|
|
22 |
use LeadersLinked\Hydrator\ObjectPropertyHydrator;
|
|
|
23 |
use LeadersLinked\Model\Feed;
|
|
|
24 |
use LeadersLinked\Mapper\FeedMapper;
|
|
|
25 |
use LeadersLinked\Library\Image;
|
|
|
26 |
use LeadersLinked\Mapper\GroupMapper;
|
|
|
27 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
28 |
use LeadersLinked\Mapper\CommentMapper;
|
|
|
29 |
use LeadersLinked\Mapper\ConnectionMapper;
|
|
|
30 |
use LeadersLinked\Mapper\CompanyFollowerMapper;
|
|
|
31 |
use LeadersLinked\Mapper\QueryMapper;
|
|
|
32 |
use Laminas\Paginator\Paginator;
|
|
|
33 |
use Laminas\Paginator\Adapter\DbSelect;
|
|
|
34 |
use LeadersLinked\Mapper\LikeMapper;
|
|
|
35 |
use LeadersLinked\Model\Like;
|
|
|
36 |
use LeadersLinked\Form\Feed\CommentForm;
|
|
|
37 |
use LeadersLinked\Model\Comment;
|
|
|
38 |
use LeadersLinked\Form\Feed\CreateGroupCompanyForm;
|
|
|
39 |
use LeadersLinked\Model\CompanyUser;
|
|
|
40 |
use LeadersLinked\Model\VideoConvert;
|
|
|
41 |
use LeadersLinked\Mapper\VideoConvertMapper;
|
|
|
42 |
use LeadersLinked\Mapper\CompanyMapper;
|
|
|
43 |
use LeadersLinked\Model\Company;
|
|
|
44 |
use LeadersLinked\Model\Group;
|
|
|
45 |
use LeadersLinked\Mapper\GroupMemberMapper;
|
|
|
46 |
use LeadersLinked\Model\GroupMember;
|
|
|
47 |
use LeadersLinked\Model\Notification;
|
|
|
48 |
use LeadersLinked\Mapper\NotificationMapper;
|
|
|
49 |
use LeadersLinked\Mapper\UserNotificationSettingMapper;
|
|
|
50 |
use LeadersLinked\Mapper\EmailTemplateMapper;
|
|
|
51 |
use LeadersLinked\Model\EmailTemplate;
|
|
|
52 |
use LeadersLinked\Library\QueueEmail;
|
| 3138 |
efrain |
53 |
use LeadersLinked\Mapper\UtilMapper;
|
| 1 |
www |
54 |
|
|
|
55 |
|
|
|
56 |
class FeedController extends AbstractActionController
|
|
|
57 |
{
|
|
|
58 |
/**
|
|
|
59 |
*
|
|
|
60 |
* @var AdapterInterface
|
|
|
61 |
*/
|
|
|
62 |
private $adapter;
|
| 5500 |
anderson |
63 |
|
|
|
64 |
|
| 1 |
www |
65 |
/**
|
|
|
66 |
*
|
|
|
67 |
* @var AbstractAdapter
|
|
|
68 |
*/
|
|
|
69 |
private $cache;
|
| 5500 |
anderson |
70 |
|
| 1 |
www |
71 |
/**
|
|
|
72 |
*
|
|
|
73 |
* @var LoggerInterface
|
|
|
74 |
*/
|
|
|
75 |
private $logger;
|
|
|
76 |
|
| 5500 |
anderson |
77 |
|
| 1 |
www |
78 |
/**
|
|
|
79 |
*
|
|
|
80 |
* @var array
|
|
|
81 |
*/
|
|
|
82 |
private $config;
|
| 5500 |
anderson |
83 |
|
| 1 |
www |
84 |
/**
|
|
|
85 |
*
|
|
|
86 |
* @param AdapterInterface $adapter
|
|
|
87 |
* @param AbstractAdapter $cache
|
|
|
88 |
* @param LoggerInterface $logger
|
|
|
89 |
* @param array $config
|
|
|
90 |
*/
|
| 5500 |
anderson |
91 |
public function __construct($adapter, $cache, $logger, $config)
|
| 1 |
www |
92 |
{
|
|
|
93 |
$this->adapter = $adapter;
|
|
|
94 |
$this->cache = $cache;
|
|
|
95 |
$this->logger = $logger;
|
|
|
96 |
$this->config = $config;
|
| 5500 |
anderson |
97 |
}
|
| 1 |
www |
98 |
|
|
|
99 |
/**
|
|
|
100 |
*
|
|
|
101 |
* Generación del listado de perfiles
|
|
|
102 |
* {@inheritDoc}
|
|
|
103 |
* @see \Laminas\Mvc\Controller\AbstractActionController::indexAction()
|
|
|
104 |
*/
|
|
|
105 |
public function indexAction()
|
|
|
106 |
{
|
| 5500 |
anderson |
107 |
|
| 1 |
www |
108 |
return new JsonModel([
|
|
|
109 |
'success' => false,
|
|
|
110 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
111 |
]);
|
|
|
112 |
}
|
| 5500 |
anderson |
113 |
|
| 5557 |
anderson |
114 |
// public function commentAction()
|
|
|
115 |
// {
|
|
|
116 |
// $id = $this->params()->fromRoute('id');
|
| 5500 |
anderson |
117 |
|
| 5557 |
anderson |
118 |
// $request = $this->getRequest();
|
|
|
119 |
// if ($request->isPost()) {
|
| 3639 |
efrain |
120 |
|
| 5500 |
anderson |
121 |
|
|
|
122 |
|
| 5557 |
anderson |
123 |
// $feedMapper = FeedMapper::getInstance($this->adapter);
|
|
|
124 |
// $feed = $feedMapper->fetchOneByUuid($id);
|
|
|
125 |
// if (!$feed) {
|
|
|
126 |
// $response = [
|
|
|
127 |
// 'success' => false,
|
|
|
128 |
// 'data' => 'ERROR_POST_NOT_FOUND'
|
|
|
129 |
// ];
|
|
|
130 |
// return new JsonModel($response);
|
|
|
131 |
// }
|
| 5500 |
anderson |
132 |
|
| 5557 |
anderson |
133 |
// $dataPost = $request->getPost()->toArray();
|
|
|
134 |
// $form = new CommentForm();
|
|
|
135 |
// $form->setData($dataPost);
|
| 5500 |
anderson |
136 |
|
| 5557 |
anderson |
137 |
// if ($form->isValid()) {
|
|
|
138 |
// $utilMapper = UtilMapper::getInstance($this->adapter);
|
|
|
139 |
// $now = $utilMapper->getDatebaseNow();
|
| 5500 |
anderson |
140 |
|
| 5557 |
anderson |
141 |
// $currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
142 |
// $currentUser = $currentUserPlugin->getUser();
|
| 5500 |
anderson |
143 |
|
| 5557 |
anderson |
144 |
// $dataPost = (array) $form->getData();
|
| 5500 |
anderson |
145 |
|
|
|
146 |
|
|
|
147 |
|
| 5557 |
anderson |
148 |
// $comment = new Comment();
|
|
|
149 |
// $comment->network_id = $currentUser->network_id;
|
|
|
150 |
// $comment->comment = $dataPost['comment'];
|
|
|
151 |
// $comment->user_id = $currentUser->id;
|
|
|
152 |
// $comment->feed_id = $feed->id;
|
|
|
153 |
// $comment->relational = Comment::RELATIONAL_FEED;
|
| 5500 |
anderson |
154 |
|
| 5557 |
anderson |
155 |
// $commentMapper = CommentMapper::getInstance($this->adapter);
|
|
|
156 |
// if ($commentMapper->insert($comment)) {
|
| 5500 |
anderson |
157 |
|
|
|
158 |
|
| 5557 |
anderson |
159 |
// if ($feed->type == Feed::TYPE_UPDATE) {
|
|
|
160 |
// $userMapper = UserMapper::getInstance($this->adapter);
|
|
|
161 |
// $ownerFeed = $userMapper->fetchOne($feed->user_id);
|
| 5500 |
anderson |
162 |
|
| 5557 |
anderson |
163 |
// $notification = new Notification();
|
|
|
164 |
// $notification->type = Notification::TYPE_COMMENT_MY_FEED;
|
|
|
165 |
// $notification->feed_id = $feed->id;
|
|
|
166 |
// $notification->read = Notification::NO;
|
|
|
167 |
// $notification->user_id = $ownerFeed->id;
|
|
|
168 |
// $notification->message = 'LABEL_COMMENT_MY_FEED';
|
|
|
169 |
// $notification->url = $this->url()->fromRoute('dashboard', ['feed' => $feed->uuid]);
|
| 5500 |
anderson |
170 |
|
| 5557 |
anderson |
171 |
// $notificationMapper = NotificationMapper::getInstance($this->adapter);
|
|
|
172 |
// $notificationMapper->insert($notification);
|
| 5500 |
anderson |
173 |
|
| 5557 |
anderson |
174 |
// $userNotificationMapper = UserNotificationSettingMapper::getInstance($this->adapter);
|
|
|
175 |
// $userNotification = $userNotificationMapper->fetchOne($ownerFeed->id);
|
| 5500 |
anderson |
176 |
|
| 5557 |
anderson |
177 |
// if ($userNotification && $userNotification->comment_my_feed) {
|
|
|
178 |
// $emailTemplateMapper = EmailTemplateMapper::getInstance($this->adapter);
|
|
|
179 |
// $emailTemplate = $emailTemplateMapper->fetchOneByCodeAndNetworkId(EmailTemplate::CODE_COMMENT_MY_FEED, $currentUser->network_id);
|
| 5500 |
anderson |
180 |
|
| 5557 |
anderson |
181 |
// if ($emailTemplate) {
|
|
|
182 |
// $arrayCont = [
|
|
|
183 |
// 'firstname' => $currentUser->first_name,
|
|
|
184 |
// 'lastname' => $currentUser->last_name,
|
|
|
185 |
// 'other_user_firstname' => $ownerFeed->first_name,
|
|
|
186 |
// 'other_user_lastname' => $ownerFeed->last_name,
|
|
|
187 |
// 'company_name' => '',
|
|
|
188 |
// 'group_name' => '',
|
|
|
189 |
// 'content' => '',
|
|
|
190 |
// 'code' => '',
|
|
|
191 |
// 'link' => $this->url()->fromRoute('dashboard', ['feed' => $feed->uuid], ['force_canonical' => true])
|
|
|
192 |
// ];
|
| 5500 |
anderson |
193 |
|
| 5557 |
anderson |
194 |
// $email = new QueueEmail($this->adapter);
|
|
|
195 |
// $email->processEmailTemplate($emailTemplate, $arrayCont, $ownerFeed->email, trim($ownerFeed->first_name . ' ' . $ownerFeed->last_name));
|
|
|
196 |
// }
|
|
|
197 |
// }
|
|
|
198 |
// }
|
| 5500 |
anderson |
199 |
|
| 5557 |
anderson |
200 |
// $total_comments = $commentMapper->fetchCountCommentByFeedId($comment->feed_id);
|
| 5500 |
anderson |
201 |
|
| 5557 |
anderson |
202 |
// $feed->total_comments = $total_comments;
|
|
|
203 |
// $feedMapper->update($feed);
|
| 5500 |
anderson |
204 |
|
| 5557 |
anderson |
205 |
// $response = [
|
|
|
206 |
// 'success' => true,
|
|
|
207 |
// 'data' => $this->renderComment($comment->id, $now),
|
|
|
208 |
// 'total_comments' => $total_comments
|
|
|
209 |
// ];
|
| 5500 |
anderson |
210 |
|
| 5557 |
anderson |
211 |
// return new JsonModel($response);
|
|
|
212 |
// } else {
|
| 5500 |
anderson |
213 |
|
| 5557 |
anderson |
214 |
// $response = [
|
|
|
215 |
// 'success' => false,
|
|
|
216 |
// 'data' => $commentMapper->getError()
|
|
|
217 |
// ];
|
| 5500 |
anderson |
218 |
|
| 5557 |
anderson |
219 |
// return new JsonModel($response);
|
|
|
220 |
// }
|
|
|
221 |
// } else {
|
|
|
222 |
// $message = '';;
|
|
|
223 |
// $form_messages = (array) $form->getMessages();
|
|
|
224 |
// foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
225 |
// foreach ($field_messages as $key => $value) {
|
|
|
226 |
// $message = $value;
|
|
|
227 |
// }
|
|
|
228 |
// }
|
| 5500 |
anderson |
229 |
|
| 5557 |
anderson |
230 |
// $response = [
|
|
|
231 |
// 'success' => false,
|
|
|
232 |
// 'data' => $message
|
|
|
233 |
// ];
|
| 5500 |
anderson |
234 |
|
| 5557 |
anderson |
235 |
// return new JsonModel($response);
|
|
|
236 |
// }
|
|
|
237 |
// } else {
|
|
|
238 |
// $response = [
|
|
|
239 |
// 'success' => false,
|
|
|
240 |
// 'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
241 |
// ];
|
| 5500 |
anderson |
242 |
|
| 5557 |
anderson |
243 |
// return new JsonModel($response);
|
|
|
244 |
// }
|
|
|
245 |
// }
|
| 5500 |
anderson |
246 |
|
| 5558 |
anderson |
247 |
// public function shareAction()
|
|
|
248 |
// {
|
|
|
249 |
// $id = $this->params()->fromRoute('id');
|
| 5500 |
anderson |
250 |
|
| 5558 |
anderson |
251 |
// $request = $this->getRequest();
|
|
|
252 |
// if ($request->isPost()) {
|
| 5500 |
anderson |
253 |
|
| 5558 |
anderson |
254 |
// $currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
255 |
// $currentUser = $currentUserPlugin->getUser();
|
| 5500 |
anderson |
256 |
|
|
|
257 |
|
| 5558 |
anderson |
258 |
// $feedMapper = FeedMapper::getInstance($this->adapter);
|
|
|
259 |
// $feed = $feedMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
|
|
|
260 |
// if (!$feed) {
|
|
|
261 |
// $response = [
|
|
|
262 |
// 'success' => false,
|
|
|
263 |
// 'data' => 'ERROR_POST_NOT_FOUND'
|
|
|
264 |
// ];
|
|
|
265 |
// return new JsonModel($response);
|
|
|
266 |
// }
|
| 5500 |
anderson |
267 |
|
| 5558 |
anderson |
268 |
// $dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
|
|
|
269 |
// $dataPost['company_id'] = $this->params()->fromRoute('company_id');
|
|
|
270 |
// $dataPost['group_id'] = $this->params()->fromRoute('group_id');
|
|
|
271 |
// $dataPost['shared_feed_id'] = $feed->id;
|
| 1 |
www |
272 |
|
| 5500 |
anderson |
273 |
|
|
|
274 |
|
|
|
275 |
|
| 5558 |
anderson |
276 |
// $response = $this->postOrShareFeed($dataPost);
|
|
|
277 |
// if ($response['success']) {
|
|
|
278 |
// $feedMapper->incTotalShared($feed->id);
|
|
|
279 |
// $total_shared = $feedMapper->fetchTotalShared($feed->id);
|
| 5500 |
anderson |
280 |
|
| 5558 |
anderson |
281 |
// $response['total_shared'] = $total_shared;
|
|
|
282 |
// }
|
| 5500 |
anderson |
283 |
|
|
|
284 |
|
| 5558 |
anderson |
285 |
// return new JsonModel($response);
|
|
|
286 |
// } else {
|
|
|
287 |
// $response = [
|
|
|
288 |
// 'success' => false,
|
|
|
289 |
// 'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
290 |
// ];
|
|
|
291 |
// }
|
| 5500 |
anderson |
292 |
|
| 5558 |
anderson |
293 |
// return new JsonModel($response);
|
|
|
294 |
// }
|
| 5500 |
anderson |
295 |
|
| 1 |
www |
296 |
public function commentDeleteAction()
|
|
|
297 |
{
|
|
|
298 |
$request = $this->getRequest();
|
| 5500 |
anderson |
299 |
if ($request->isPost()) {
|
| 1 |
www |
300 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
301 |
$currentUser = $currentUserPlugin->getUser();
|
| 5500 |
anderson |
302 |
|
| 1 |
www |
303 |
$feed_id = $this->params()->fromRoute('id');
|
|
|
304 |
$comment = $this->params()->fromRoute('comment');
|
| 5500 |
anderson |
305 |
|
| 1 |
www |
306 |
$feedMapper = FeedMapper::getInstance($this->adapter);
|
| 3639 |
efrain |
307 |
$feed = $feedMapper->fetchOneByUuidAndNetworkId($feed_id, $currentUser->network_id);
|
| 5500 |
anderson |
308 |
|
|
|
309 |
if ($feed) {
|
|
|
310 |
|
| 1 |
www |
311 |
$commentMapper = CommentMapper::getInstance($this->adapter);
|
|
|
312 |
$comment = $commentMapper->fetchOneByUuid($comment);
|
| 5500 |
anderson |
313 |
|
|
|
314 |
if ($comment && $comment->feed_id == $feed->id && $comment->user_id == $currentUser->id) {
|
|
|
315 |
|
| 1 |
www |
316 |
$comment->status = Comment::STATUS_DELETED;
|
| 5500 |
anderson |
317 |
|
|
|
318 |
if ($commentMapper->update($comment)) {
|
|
|
319 |
|
| 1 |
www |
320 |
$total_comments = $commentMapper->fetchCountCommentByFeedId($comment->feed_id);
|
| 5500 |
anderson |
321 |
|
|
|
322 |
|
| 1 |
www |
323 |
$feedMapper = FeedMapper::getInstance($this->adapter);
|
|
|
324 |
$feed = $feedMapper->fetchOne($comment->feed_id);
|
|
|
325 |
$feed->total_comments = $total_comments;
|
|
|
326 |
$feedMapper->update($feed);
|
| 5500 |
anderson |
327 |
|
|
|
328 |
|
|
|
329 |
|
|
|
330 |
|
|
|
331 |
|
| 1 |
www |
332 |
$response = [
|
|
|
333 |
'success' => true,
|
|
|
334 |
'data' => 'LABEL_COMMENT_WAS_DELETED',
|
|
|
335 |
'total_comments' => $total_comments
|
|
|
336 |
];
|
|
|
337 |
} else {
|
|
|
338 |
$response = [
|
|
|
339 |
'success' => false,
|
|
|
340 |
'data' => $commentMapper->getError()
|
|
|
341 |
];
|
|
|
342 |
}
|
|
|
343 |
} else {
|
|
|
344 |
$response = [
|
|
|
345 |
'success' => false,
|
|
|
346 |
'data' => 'ERROR_COMMENT_NOT_FOUND'
|
|
|
347 |
];
|
|
|
348 |
}
|
|
|
349 |
} else {
|
|
|
350 |
$response = [
|
|
|
351 |
'success' => false,
|
|
|
352 |
'data' => 'ERROR_COMMENT_NOT_FOUND'
|
|
|
353 |
];
|
|
|
354 |
}
|
|
|
355 |
} else {
|
|
|
356 |
$response = [
|
|
|
357 |
'success' => false,
|
|
|
358 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
359 |
];
|
|
|
360 |
}
|
| 5500 |
anderson |
361 |
|
| 1 |
www |
362 |
return new JsonModel($response);
|
|
|
363 |
}
|
| 5500 |
anderson |
364 |
|
| 1 |
www |
365 |
public function deleteAction()
|
|
|
366 |
{
|
|
|
367 |
$request = $this->getRequest();
|
| 5500 |
anderson |
368 |
if ($request->isPost()) {
|
| 1 |
www |
369 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
370 |
$currentUser = $currentUserPlugin->getUser();
|
| 5500 |
anderson |
371 |
|
| 1 |
www |
372 |
$feed_id = $this->params()->fromRoute('id');
|
| 5500 |
anderson |
373 |
|
| 1 |
www |
374 |
$feedMapper = FeedMapper::getInstance($this->adapter);
|
| 3639 |
efrain |
375 |
$feed = $feedMapper->fetchOneByUuidAndNetworkId($feed_id, $currentUser->network_id);
|
| 5500 |
anderson |
376 |
|
|
|
377 |
if ($feed) {
|
|
|
378 |
|
|
|
379 |
if ($feed->user_id && $feed->user_id == $currentUser->id) {
|
|
|
380 |
|
| 1 |
www |
381 |
return new JsonModel($this->deleteFeed($feed));
|
|
|
382 |
} else if ($feed->group_id) {
|
| 5500 |
anderson |
383 |
|
| 1 |
www |
384 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
385 |
$group = $groupMapper->fetchOne($feed->group_id);
|
| 5500 |
anderson |
386 |
if ($group && $group->user_id == $currentUser->id) {
|
| 1 |
www |
387 |
return new JsonModel($this->deleteFeed($feed));
|
|
|
388 |
}
|
|
|
389 |
} else if ($feed->company_id) {
|
|
|
390 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
391 |
$companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($feed->company_id, $currentUser->id);
|
| 5500 |
anderson |
392 |
if ($companyUser) {
|
|
|
393 |
if (in_array($companyUser->type, [CompanyUser::TYPE_OWNER, CompanyUser::TYPE_ADMINISTRATOR, CompanyUser::TYPE_MANAGER])) {
|
| 1 |
www |
394 |
return new JsonModel($this->deleteFeed($feed));
|
|
|
395 |
}
|
|
|
396 |
}
|
|
|
397 |
}
|
| 5500 |
anderson |
398 |
|
| 1 |
www |
399 |
$response = [
|
|
|
400 |
'success' => false,
|
|
|
401 |
'data' => ' ERROR_UNAUTHORIZED'
|
|
|
402 |
];
|
|
|
403 |
} else {
|
|
|
404 |
$response = [
|
|
|
405 |
'success' => false,
|
|
|
406 |
'data' => 'ERROR_FEED_NOT_FOUND'
|
|
|
407 |
];
|
|
|
408 |
}
|
| 5500 |
anderson |
409 |
|
| 1 |
www |
410 |
return new JsonModel($response);
|
|
|
411 |
} else {
|
|
|
412 |
$response = [
|
|
|
413 |
'success' => false,
|
|
|
414 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
415 |
];
|
|
|
416 |
}
|
| 5500 |
anderson |
417 |
|
| 1 |
www |
418 |
return new JsonModel($response);
|
|
|
419 |
}
|
| 5500 |
anderson |
420 |
|
| 1 |
www |
421 |
public function addAction()
|
|
|
422 |
{
|
|
|
423 |
$request = $this->getRequest();
|
| 5500 |
anderson |
424 |
if ($request->isPost()) {
|
| 1 |
www |
425 |
$dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
|
|
|
426 |
$dataPost['company_id'] = $this->params()->fromRoute('company_id');
|
|
|
427 |
$dataPost['group_id'] = $this->params()->fromRoute('group_id');
|
|
|
428 |
$response = $this->postOrShareFeed($dataPost);
|
| 5500 |
anderson |
429 |
|
|
|
430 |
|
| 1 |
www |
431 |
return new JsonModel($response);
|
|
|
432 |
} else {
|
|
|
433 |
$response = [
|
|
|
434 |
'success' => false,
|
|
|
435 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
436 |
];
|
|
|
437 |
}
|
| 5500 |
anderson |
438 |
|
| 1 |
www |
439 |
return new JsonModel($response);
|
|
|
440 |
}
|
|
|
441 |
|
| 5558 |
anderson |
442 |
// public function postOrShareFeed($dataPost)
|
|
|
443 |
// {
|
|
|
444 |
// $utilMapper = UtilMapper::getInstance($this->adapter);
|
|
|
445 |
// $now = $utilMapper->getDatebaseNow();
|
| 5500 |
anderson |
446 |
|
| 5558 |
anderson |
447 |
// $currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
448 |
// $currentUser = $currentUserPlugin->getUser();
|
| 5500 |
anderson |
449 |
|
| 5558 |
anderson |
450 |
// $companyId = empty($dataPost['company_id']) ? '' : $dataPost['company_id'];
|
|
|
451 |
// $groupId = empty($dataPost['group_id']) ? '' : $dataPost['group_id'];
|
| 5500 |
anderson |
452 |
|
|
|
453 |
|
| 5558 |
anderson |
454 |
// if ($groupId || $companyId) {
|
|
|
455 |
// $form = new CreateGroupCompanyForm($this->adapter);
|
|
|
456 |
// } else {
|
|
|
457 |
// $form = new CreateForm($this->adapter);
|
|
|
458 |
// }
|
|
|
459 |
// $form->setData($dataPost);
|
|
|
460 |
// if ($form->isValid()) {
|
| 1 |
www |
461 |
|
|
|
462 |
|
| 5500 |
anderson |
463 |
|
|
|
464 |
|
| 5558 |
anderson |
465 |
// $hydrator = new ObjectPropertyHydrator();
|
|
|
466 |
// $feed = new Feed();
|
|
|
467 |
// $hydrator->hydrate($dataPost, $feed);
|
| 1 |
www |
468 |
|
| 5558 |
anderson |
469 |
// $company = null;
|
|
|
470 |
// $group = null;
|
| 1 |
www |
471 |
|
| 5558 |
anderson |
472 |
// if ($companyId) {
|
|
|
473 |
// $companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
474 |
// $company = $companyMapper->fetchOneByUuidAndNetworkId($companyId, $currentUser->network_id);
|
| 5500 |
anderson |
475 |
|
|
|
476 |
|
| 5558 |
anderson |
477 |
// if (!$company) {
|
|
|
478 |
// return [
|
|
|
479 |
// 'success' => false,
|
|
|
480 |
// 'data' => 'ERROR_COMPANY_NOT_FOUND'
|
|
|
481 |
// ];
|
|
|
482 |
// }
|
| 5500 |
anderson |
483 |
|
| 5558 |
anderson |
484 |
// if ($company->status != Company::STATUS_ACTIVE) {
|
|
|
485 |
// return [
|
|
|
486 |
// 'success' => false,
|
|
|
487 |
// 'data' => 'ERROR_COMPANY_IS_NOT_ACTIVE'
|
|
|
488 |
// ];
|
|
|
489 |
// }
|
| 5500 |
anderson |
490 |
|
| 5558 |
anderson |
491 |
// $companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
492 |
// $companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($company->id, $currentUser->id);
|
| 5500 |
anderson |
493 |
|
| 5558 |
anderson |
494 |
// //print_r($companyUser); exit;
|
| 5500 |
anderson |
495 |
|
|
|
496 |
|
| 5558 |
anderson |
497 |
// if (!$companyUser || $companyUser->status != CompanyUser::STATUS_ACCEPTED) {
|
|
|
498 |
// return [
|
|
|
499 |
// 'success' => false,
|
|
|
500 |
// 'data' => 'ERROR_UNAUTHORIZED'
|
|
|
501 |
// ];
|
|
|
502 |
// }
|
|
|
503 |
// }
|
| 5500 |
anderson |
504 |
|
| 5558 |
anderson |
505 |
// if ($groupId) {
|
|
|
506 |
// $groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
507 |
// $group = $groupMapper->fetchOneByUuidAndNetworkId($groupId, $currentUser->network_id);
|
| 5500 |
anderson |
508 |
|
| 5558 |
anderson |
509 |
// if (!$group) {
|
|
|
510 |
// return [
|
|
|
511 |
// 'success' => false,
|
|
|
512 |
// 'data' => 'ERROR_GROUP_NOT_FOUND'
|
|
|
513 |
// ];
|
|
|
514 |
// }
|
| 5500 |
anderson |
515 |
|
| 5558 |
anderson |
516 |
// if ($group->status != Group::STATUS_ACTIVE) {
|
|
|
517 |
// return [
|
|
|
518 |
// 'success' => false,
|
|
|
519 |
// 'data' => 'ERROR_GROUP_IS_NOT_ACTIVE'
|
|
|
520 |
// ];
|
|
|
521 |
// }
|
| 5500 |
anderson |
522 |
|
| 5558 |
anderson |
523 |
// $groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
524 |
// $groupMember = $groupMemberMapper->fetchOneByGroupIdAndUserId($group->id, $currentUser->id);
|
|
|
525 |
// if (!$groupMember || !in_array($groupMember->status, [GroupMember::STATUS_ACCEPTED, GroupMember::STATUS_AUTO_JOIN])) {
|
|
|
526 |
// return [
|
|
|
527 |
// 'success' => false,
|
|
|
528 |
// 'data' => 'ERROR_UNAUTHORIZED'
|
|
|
529 |
// ];
|
|
|
530 |
// }
|
|
|
531 |
// }
|
| 5500 |
anderson |
532 |
|
| 5558 |
anderson |
533 |
// $feed->network_id = $currentUser->network_id;
|
|
|
534 |
// $feed->company_id = $company ? $company->id : null;
|
|
|
535 |
// $feed->group_id = $group ? $group->id : null;
|
|
|
536 |
// $feed->user_id = $currentUser->id;
|
| 5500 |
anderson |
537 |
|
| 5558 |
anderson |
538 |
// if ($companyId) {
|
|
|
539 |
// $feed->type = Feed::TYPE_COMPANY;
|
|
|
540 |
// } else if ($groupId) {
|
|
|
541 |
// $feed->type = Feed::TYPE_GROUP;
|
|
|
542 |
// } else {
|
|
|
543 |
// $feed->type = Feed::TYPE_UPDATE;
|
|
|
544 |
// }
|
| 5500 |
anderson |
545 |
|
| 5558 |
anderson |
546 |
// $posted_or_shared = $dataPost['posted_or_shared'];
|
|
|
547 |
// if ($posted_or_shared != Feed::POSTED && $posted_or_shared != Feed::SHARED) {
|
|
|
548 |
// return [
|
|
|
549 |
// 'success' => false,
|
|
|
550 |
// 'data' => 'ERROR_SUPPLY_VALID_SHARING_STATUS'
|
|
|
551 |
// ];
|
|
|
552 |
// }
|
|
|
553 |
// $feed->posted_or_shared = $posted_or_shared;
|
|
|
554 |
// $feedMapper = FeedMapper::getInstance($this->adapter);
|
| 5500 |
anderson |
555 |
|
| 5558 |
anderson |
556 |
// $shared_with = isset($dataPost['shared_with']) ? $dataPost['shared_with'] : Feed::SHARE_WITH_PUBLIC;
|
|
|
557 |
// if ($shared_with != Feed::SHARE_WITH_PUBLIC && $shared_with != Feed::SHARE_WITH_CONNECTIONS) {
|
|
|
558 |
// return [
|
|
|
559 |
// 'status' => false,
|
|
|
560 |
// 'error' => 'ERROR_SUPPLY_VALID_SHARING_WITH_TYPE',
|
|
|
561 |
// ];
|
|
|
562 |
// }
|
| 5500 |
anderson |
563 |
|
| 5558 |
anderson |
564 |
// $feed->shared_with = $shared_with;
|
|
|
565 |
// if (Feed::SHARED == $feed->posted_or_shared) {
|
|
|
566 |
// $shared_feed_id = empty($dataPost['shared_feed_id']) ? 0 : $dataPost['shared_feed_id'];
|
| 5500 |
anderson |
567 |
|
|
|
568 |
|
| 5558 |
anderson |
569 |
// $sharedFeed = $feedMapper->fetchOneByIdAndNetworkId($shared_feed_id, $currentUser->network_id);
|
|
|
570 |
// if (!$sharedFeed) {
|
|
|
571 |
// return [
|
|
|
572 |
// 'status' => false,
|
|
|
573 |
// 'error' => 'ERROR_POST_SHARE',
|
|
|
574 |
// ];
|
|
|
575 |
// }
|
| 5500 |
anderson |
576 |
|
| 5558 |
anderson |
577 |
// $feed->shared_feed_id = $sharedFeed->id;
|
|
|
578 |
// $feed->shared_company_id = $sharedFeed->shared_company_id;
|
|
|
579 |
// $feed->shared_group_id = $sharedFeed->shared_group_id;
|
|
|
580 |
// $feed->shared_job_id = $sharedFeed->shared_job_id;
|
|
|
581 |
// } else {
|
|
|
582 |
// $sharedFeed = null;
|
|
|
583 |
// }
|
| 414 |
geraldo |
584 |
|
| 5558 |
anderson |
585 |
// $feed->status = Feed::STATUS_PUBLISHED;
|
|
|
586 |
// $feed->total_comments = 0;
|
|
|
587 |
// $feed->total_shared = 0;
|
| 5500 |
anderson |
588 |
|
|
|
589 |
|
| 5558 |
anderson |
590 |
// $files = $this->getRequest()->getFiles()->toArray();
|
|
|
591 |
// $file_type = '';
|
| 5500 |
anderson |
592 |
|
| 5558 |
anderson |
593 |
// $encoding = $this->params()->fromRoute('encoding');
|
|
|
594 |
// if ($encoding == 'base64') {
|
| 5500 |
anderson |
595 |
|
|
|
596 |
|
| 5558 |
anderson |
597 |
// $fileBase64Name = $this->params()->fromPost('file_base64_name');
|
|
|
598 |
// $fileBase64Content = $this->params()->fromPost('file_base64_content');
|
| 5500 |
anderson |
599 |
|
| 5558 |
anderson |
600 |
// if ($fileBase64Name && $fileBase64Content) {
|
| 5500 |
anderson |
601 |
|
| 5558 |
anderson |
602 |
// try {
|
|
|
603 |
// $fileBase64Content = base64_decode($fileBase64Content);
|
|
|
604 |
// if ($fileBase64Content) {
|
|
|
605 |
// $feed_filename = $this->normalizeString($fileBase64Name);
|
|
|
606 |
// $feed_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp';
|
|
|
607 |
// if (!file_exists($feed_tmp_filename)) {
|
|
|
608 |
// mkdir($feed_tmp_filename, 0755, true);
|
|
|
609 |
// }
|
| 415 |
geraldo |
610 |
|
| 5500 |
anderson |
611 |
|
|
|
612 |
|
| 5558 |
anderson |
613 |
// $feed_tmp_filename = 'data' . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . $feed_filename;
|
|
|
614 |
// file_put_contents($feed_tmp_filename, $fileBase64Content);
|
| 5500 |
anderson |
615 |
|
|
|
616 |
|
|
|
617 |
|
| 5558 |
anderson |
618 |
// $mime_type = mime_content_type($feed_tmp_filename);
|
|
|
619 |
// //echo '$mime_type = '. $mime_type; exit;
|
| 5500 |
anderson |
620 |
|
|
|
621 |
|
| 5558 |
anderson |
622 |
// if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
|
|
|
623 |
// $file_type = Feed::FILE_TYPE_IMAGE;
|
|
|
624 |
// } else if ($mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
|
|
|
625 |
// $file_type = Feed::FILE_TYPE_VIDEO;
|
|
|
626 |
// } else if ($mime_type == 'application/pdf') {
|
|
|
627 |
// $file_type = Feed::FILE_TYPE_DOCUMENT;
|
|
|
628 |
// }
|
|
|
629 |
// }
|
|
|
630 |
// } catch (\Exception $e) {
|
|
|
631 |
// }
|
|
|
632 |
// }
|
|
|
633 |
// } else {
|
| 415 |
geraldo |
634 |
|
| 5558 |
anderson |
635 |
// if (isset($files['file']) && empty($files['file']['error'])) {
|
|
|
636 |
// $feed_tmp_filename = $files['file']['tmp_name'];
|
|
|
637 |
// $feed_filename = $this->normalizeString($files['file']['name']);
|
| 5500 |
anderson |
638 |
|
| 5558 |
anderson |
639 |
// $mime_type = mime_content_type($feed_tmp_filename);
|
| 5500 |
anderson |
640 |
|
|
|
641 |
|
| 5558 |
anderson |
642 |
// if ($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
|
|
|
643 |
// $file_type = Feed::FILE_TYPE_IMAGE;
|
|
|
644 |
// } else if ($mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
|
|
|
645 |
// $file_type = Feed::FILE_TYPE_VIDEO;
|
|
|
646 |
// } else if ($mime_type == 'application/pdf') {
|
|
|
647 |
// $file_type = Feed::FILE_TYPE_DOCUMENT;
|
|
|
648 |
// }
|
|
|
649 |
// }
|
|
|
650 |
// }
|
| 424 |
geraldo |
651 |
|
| 5500 |
anderson |
652 |
|
| 5558 |
anderson |
653 |
// $result = $feedMapper->insert($feed);
|
|
|
654 |
// if ($result) {
|
| 5500 |
anderson |
655 |
|
| 5558 |
anderson |
656 |
// if ($sharedFeed && $sharedFeed->type == Feed::TYPE_UPDATE) {
|
| 5500 |
anderson |
657 |
|
|
|
658 |
|
| 5558 |
anderson |
659 |
// $userMapper = UserMapper::getInstance($this->adapter);
|
|
|
660 |
// $ownerFeed = $userMapper->fetchOne($sharedFeed->user_id);
|
| 5500 |
anderson |
661 |
|
| 5558 |
anderson |
662 |
// $notification = new Notification();
|
|
|
663 |
// $notification->type = Notification::TYPE_SHARE_MY_FEED;
|
|
|
664 |
// $notification->read = Notification::NO;
|
|
|
665 |
// $notification->user_id = $ownerFeed->id;
|
|
|
666 |
// $notification->feed_id = $feed->id;
|
|
|
667 |
// $notification->message = 'LABEL_SHARE_MY_FEED';
|
|
|
668 |
// $notification->url = $this->url()->fromRoute('dashboard', ['feed' => $sharedFeed->uuid]);
|
| 5500 |
anderson |
669 |
|
| 5558 |
anderson |
670 |
// $notificationMapper = NotificationMapper::getInstance($this->adapter);
|
|
|
671 |
// $notificationMapper->insert($notification);
|
| 5500 |
anderson |
672 |
|
| 5558 |
anderson |
673 |
// $userNotificationMapper = UserNotificationSettingMapper::getInstance($this->adapter);
|
|
|
674 |
// $userNotification = $userNotificationMapper->fetchOne($ownerFeed->id);
|
| 5500 |
anderson |
675 |
|
| 5558 |
anderson |
676 |
// if ($userNotification && $userNotification->share_my_feed) {
|
|
|
677 |
// $emailTemplateMapper = EmailTemplateMapper::getInstance($this->adapter);
|
|
|
678 |
// $emailTemplate = $emailTemplateMapper->fetchOneByCodeAndNetworkId(EmailTemplate::CODE_SHARE_MY_FEED, $currentUser->network_id);
|
| 5500 |
anderson |
679 |
|
| 5558 |
anderson |
680 |
// if ($emailTemplate) {
|
|
|
681 |
// $arrayCont = [
|
|
|
682 |
// 'firstname' => $currentUser->first_name,
|
|
|
683 |
// 'lastname' => $currentUser->last_name,
|
|
|
684 |
// 'other_user_firstname' => $ownerFeed->first_name,
|
|
|
685 |
// 'other_user_lastname' => $ownerFeed->last_name,
|
|
|
686 |
// 'company_name' => '',
|
|
|
687 |
// 'group_name' => '',
|
|
|
688 |
// 'content' => '',
|
|
|
689 |
// 'code' => '',
|
|
|
690 |
// 'link' => $this->url()->fromRoute('dashboard', ['feed' => $feed->uuid], ['force_canonical' => true])
|
|
|
691 |
// ];
|
| 5500 |
anderson |
692 |
|
| 5558 |
anderson |
693 |
// $email = new QueueEmail($this->adapter);
|
|
|
694 |
// $email->processEmailTemplate($emailTemplate, $arrayCont, $ownerFeed->email, trim($ownerFeed->first_name . ' ' . $ownerFeed->last_name));
|
|
|
695 |
// }
|
|
|
696 |
// }
|
|
|
697 |
// }
|
| 5500 |
anderson |
698 |
|
|
|
699 |
|
| 5558 |
anderson |
700 |
// $feed = $feedMapper->fetchOne($feed->id);
|
| 5500 |
anderson |
701 |
|
| 5558 |
anderson |
702 |
// if ($file_type == Feed::FILE_TYPE_DOCUMENT) {
|
|
|
703 |
// try {
|
|
|
704 |
// $target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
|
|
|
705 |
// if (!file_exists($target_path)) {
|
|
|
706 |
// mkdir($target_path, 0755);
|
|
|
707 |
// }
|
| 5500 |
anderson |
708 |
|
| 5558 |
anderson |
709 |
// $full_filename = $target_path . DIRECTORY_SEPARATOR . $feed_filename;
|
| 5500 |
anderson |
710 |
|
| 5558 |
anderson |
711 |
// if ($encoding == 'base64') {
|
|
|
712 |
// $resultMoveOrRename = rename($feed_tmp_filename, $full_filename);
|
|
|
713 |
// } else {
|
|
|
714 |
// $resultMoveOrRename = move_uploaded_file($feed_tmp_filename, $full_filename);
|
|
|
715 |
// }
|
| 5500 |
anderson |
716 |
|
| 5558 |
anderson |
717 |
// if ($resultMoveOrRename) {
|
| 5500 |
anderson |
718 |
|
| 5558 |
anderson |
719 |
// $feed->file_type = $file_type;
|
|
|
720 |
// $feed->file_name = basename($feed_filename);
|
|
|
721 |
// $feedMapper->update($feed);
|
|
|
722 |
// } else {
|
|
|
723 |
// error_log('no se pudo mover o renombrar el documento : ' . $feed_tmp_filename . ' al directorio : ' . $full_filename);
|
|
|
724 |
// }
|
|
|
725 |
// } catch (\Throwable $e) {
|
|
|
726 |
// error_log($e->getTraceAsString());
|
|
|
727 |
// }
|
|
|
728 |
// }
|
|
|
729 |
// if ($file_type == Feed::FILE_TYPE_IMAGE) {
|
|
|
730 |
// try {
|
|
|
731 |
// $target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
|
|
|
732 |
// if (!file_exists($target_path)) {
|
|
|
733 |
// mkdir($target_path, 0755);
|
|
|
734 |
// }
|
| 5500 |
anderson |
735 |
|
| 5558 |
anderson |
736 |
// list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.feed_image_size']);
|
| 424 |
geraldo |
737 |
|
| 5558 |
anderson |
738 |
// $feed_filename = substr($feed_filename, 0, strrpos($feed_filename, '.')) . '.png';
|
|
|
739 |
// //$crop_to_dimensions = false;
|
|
|
740 |
// //if(Image::uploadImage($feed_tmp_filename, $target_path, $feed_filename, $target_width, $target_height, $crop_to_dimensions )) {
|
|
|
741 |
// if (Image::uploadImageWithoutCompletationSize($feed_tmp_filename, $target_path, $feed_filename, $target_width, $target_height)) {
|
| 5500 |
anderson |
742 |
|
| 5558 |
anderson |
743 |
// $feed->file_type = $file_type;
|
|
|
744 |
// $feed->file_name = basename($feed_filename);
|
|
|
745 |
// $feedMapper->update($feed);
|
|
|
746 |
// }
|
|
|
747 |
// } catch (\Throwable $e) {
|
|
|
748 |
// error_log($e->getTraceAsString());
|
|
|
749 |
// }
|
|
|
750 |
// }
|
|
|
751 |
// if ($file_type == Feed::FILE_TYPE_VIDEO) {
|
|
|
752 |
// try {
|
|
|
753 |
// $target_path = $this->config['leaderslinked.fullpath.feed'] . $feed->uuid;
|
|
|
754 |
// if (!file_exists($target_path)) {
|
|
|
755 |
// mkdir($target_path, 0755);
|
|
|
756 |
// }
|
| 5500 |
anderson |
757 |
|
| 5558 |
anderson |
758 |
// $full_filename = $target_path . DIRECTORY_SEPARATOR . $feed_filename;
|
| 424 |
geraldo |
759 |
|
| 5558 |
anderson |
760 |
// if ($encoding == 'base64') {
|
|
|
761 |
// $resultMoveOrRename = rename($feed_tmp_filename, $full_filename);
|
|
|
762 |
// } else {
|
|
|
763 |
// $resultMoveOrRename = move_uploaded_file($feed_tmp_filename, $full_filename);
|
|
|
764 |
// }
|
| 3477 |
efrain |
765 |
|
| 5558 |
anderson |
766 |
// if ($resultMoveOrRename) {
|
| 5500 |
anderson |
767 |
|
|
|
768 |
|
| 5558 |
anderson |
769 |
// // $getFromSecound = 2;
|
| 5500 |
anderson |
770 |
|
| 5558 |
anderson |
771 |
// //extracción del cover
|
|
|
772 |
// $generateFileName = substr($feed_filename, 0, strrpos($feed_filename, '.'));
|
|
|
773 |
// $generateFile = $target_path . DIRECTORY_SEPARATOR . $generateFileName . '.jpg';
|
| 3477 |
efrain |
774 |
|
| 5558 |
anderson |
775 |
// $cmd = "/usr/bin/ffprobe -v error -of flat=s=_ -select_streams v:0 -show_entries stream=height,width,duration $full_filename";
|
|
|
776 |
// //error_log($cmd);
|
| 5500 |
anderson |
777 |
|
| 5558 |
anderson |
778 |
// $response = trim(shell_exec($cmd));
|
| 5500 |
anderson |
779 |
|
| 5558 |
anderson |
780 |
// $source_duration = 0;
|
| 3477 |
efrain |
781 |
|
| 5500 |
anderson |
782 |
|
| 5558 |
anderson |
783 |
// $lines = explode("\n", $response);
|
|
|
784 |
// foreach ($lines as $line) {
|
|
|
785 |
// $line = trim(strtolower($line));
|
|
|
786 |
// if (strpos($line, 'duration') !== false) {
|
|
|
787 |
// $values = explode('=', $line);
|
|
|
788 |
// $source_duration = intval(str_replace($values[1], '#', ''), 10);
|
|
|
789 |
// }
|
|
|
790 |
// }
|
| 5500 |
anderson |
791 |
|
|
|
792 |
|
| 5558 |
anderson |
793 |
// if ($source_duration == 0) {
|
|
|
794 |
// $second_extract = '00:00:02';
|
|
|
795 |
// } else {
|
|
|
796 |
// if ($source_duration > 10) {
|
|
|
797 |
// $second_extract = '00:00:10';
|
|
|
798 |
// } else {
|
|
|
799 |
// $second_extract = '00:00:02';
|
|
|
800 |
// }
|
|
|
801 |
// }
|
| 5500 |
anderson |
802 |
|
| 5558 |
anderson |
803 |
// $imageSize = $this->config['leaderslinked.image_sizes.feed_image_size'];
|
| 5500 |
anderson |
804 |
|
| 5558 |
anderson |
805 |
// //$cmd = "/usr/bin/ffmpeg -y -i $full_filename -pix_fmt yuvj422p -deinterlace -an -ss $second_extract -f mjpeg -t 1 -r 1 -y -s $imageSize $generateFile";
|
|
|
806 |
// $cmd = "/usr/bin/ffmpeg -y -i $full_filename -pix_fmt yuvj422p -an -ss $second_extract -f mjpeg -t 1 -r 1 -y -s $imageSize $generateFile";
|
|
|
807 |
// //error_log($cmd);
|
| 3477 |
efrain |
808 |
|
| 5500 |
anderson |
809 |
|
| 5558 |
anderson |
810 |
// exec($cmd);
|
| 5500 |
anderson |
811 |
|
|
|
812 |
|
| 5558 |
anderson |
813 |
// $feed->file_type = $file_type;
|
|
|
814 |
// $feed->file_name = basename($feed_filename);
|
|
|
815 |
// $feed->file_image_preview = basename($generateFile);
|
|
|
816 |
// $feedMapper->update($feed);
|
| 5500 |
anderson |
817 |
|
| 5558 |
anderson |
818 |
// $videoConvert = new VideoConvert();
|
|
|
819 |
// $videoConvert->filename = $full_filename;
|
|
|
820 |
// $videoConvert->type = VideoConvert::TYPE_FEED;
|
| 5500 |
anderson |
821 |
|
| 5558 |
anderson |
822 |
// $videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
|
|
|
823 |
// $videoConvertMapper->insert($videoConvert);
|
|
|
824 |
// } else {
|
|
|
825 |
// error_log('no se pudo mover o renombrar el documento : ' . $feed_tmp_filename . ' al directorio : ' . $full_filename);
|
|
|
826 |
// }
|
|
|
827 |
// } catch (\Throwable $e) {
|
|
|
828 |
// error_log($e->getTraceAsString());
|
|
|
829 |
// }
|
|
|
830 |
// }
|
| 424 |
geraldo |
831 |
|
|
|
832 |
|
| 5558 |
anderson |
833 |
// return [
|
|
|
834 |
// 'success' => true,
|
|
|
835 |
// 'data' => $this->renderFeed($feed->id, $now)
|
|
|
836 |
// ];
|
|
|
837 |
// } else {
|
|
|
838 |
// return [
|
|
|
839 |
// 'success' => false,
|
|
|
840 |
// 'data' => $feedMapper->getError()
|
|
|
841 |
// ];
|
|
|
842 |
// }
|
|
|
843 |
// } else {
|
|
|
844 |
// $messages = [];
|
|
|
845 |
// $form_messages = (array) $form->getMessages();
|
|
|
846 |
// foreach ($form_messages as $fieldname => $field_messages) {
|
|
|
847 |
// $messages[$fieldname] = array_values($field_messages);
|
|
|
848 |
// }
|
| 5500 |
anderson |
849 |
|
| 5558 |
anderson |
850 |
// return [
|
|
|
851 |
// 'success' => false,
|
|
|
852 |
// 'data' => $messages
|
|
|
853 |
// ];
|
|
|
854 |
// }
|
|
|
855 |
// }
|
| 5500 |
anderson |
856 |
|
| 5558 |
anderson |
857 |
// public function likeAction()
|
|
|
858 |
// {
|
|
|
859 |
// $id = $this->params()->fromRoute('id');
|
| 5500 |
anderson |
860 |
|
| 5558 |
anderson |
861 |
// $request = $this->getRequest();
|
|
|
862 |
// if ($request->isPost()) {
|
|
|
863 |
// $currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
864 |
// $currentUser = $currentUserPlugin->getUser();
|
| 3639 |
efrain |
865 |
|
| 5500 |
anderson |
866 |
|
| 5558 |
anderson |
867 |
// $feedMapper = FeedMapper::getInstance($this->adapter);
|
|
|
868 |
// $feed = $feedMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
|
|
|
869 |
// if (!$feed) {
|
|
|
870 |
// $response = [
|
|
|
871 |
// 'success' => false,
|
|
|
872 |
// 'data' => 'ERROR_POST_NOT_FOUND'
|
|
|
873 |
// ];
|
|
|
874 |
// return new JsonModel($response);
|
|
|
875 |
// }
|
| 5500 |
anderson |
876 |
|
| 5558 |
anderson |
877 |
// $likeMapper = LikeMapper::getInstance($this->adapter);
|
|
|
878 |
// $like = $likeMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
|
| 5500 |
anderson |
879 |
|
| 5558 |
anderson |
880 |
// if ($like) {
|
|
|
881 |
// $response = [
|
|
|
882 |
// 'success' => false,
|
|
|
883 |
// 'data' => 'ERROR_DUPLICATE_ACTION'
|
|
|
884 |
// ];
|
|
|
885 |
// return new JsonModel($response);
|
|
|
886 |
// }
|
| 5500 |
anderson |
887 |
|
| 5558 |
anderson |
888 |
// $like = new Like();
|
|
|
889 |
// $like->user_id = $currentUser->id;
|
|
|
890 |
// $like->feed_id = $feed->id;
|
|
|
891 |
// $like->relational = Like::RELATIONAL_FEED;
|
| 5500 |
anderson |
892 |
|
| 5558 |
anderson |
893 |
// if ($likeMapper->insert($like)) {
|
| 5500 |
anderson |
894 |
|
| 5558 |
anderson |
895 |
// $likes = $likeMapper->fetchCountLikeByFeedId($feed->id);
|
| 5500 |
anderson |
896 |
|
|
|
897 |
|
|
|
898 |
|
| 5558 |
anderson |
899 |
// if ($feed->type == Feed::TYPE_UPDATE) {
|
| 5500 |
anderson |
900 |
|
|
|
901 |
|
| 5558 |
anderson |
902 |
// $userMapper = UserMapper::getInstance($this->adapter);
|
|
|
903 |
// $ownerFeed = $userMapper->fetchOne($feed->user_id);
|
| 5500 |
anderson |
904 |
|
| 5558 |
anderson |
905 |
// $notification = new Notification();
|
|
|
906 |
// $notification->type = Notification::TYPE_LIKE_MY_FEED;
|
|
|
907 |
// $notification->read = Notification::NO;
|
|
|
908 |
// $notification->user_id = $feed->user_id;
|
|
|
909 |
// $notification->feed_id = $feed->id;
|
|
|
910 |
// $notification->message = 'LABEL_LIKE_MY_FEED';
|
|
|
911 |
// $notification->url = $this->url()->fromRoute('dashboard', ['feed' => $feed->uuid]);
|
| 5500 |
anderson |
912 |
|
| 5558 |
anderson |
913 |
// $notificationMapper = NotificationMapper::getInstance($this->adapter);
|
|
|
914 |
// $notificationMapper->insert($notification);
|
| 5500 |
anderson |
915 |
|
| 5558 |
anderson |
916 |
// $userNotificationMapper = UserNotificationSettingMapper::getInstance($this->adapter);
|
|
|
917 |
// $userNotification = $userNotificationMapper->fetchOne($ownerFeed->id);
|
| 5500 |
anderson |
918 |
|
| 5558 |
anderson |
919 |
// if ($userNotification && $userNotification->like_my_feed) {
|
|
|
920 |
// $emailTemplateMapper = EmailTemplateMapper::getInstance($this->adapter);
|
|
|
921 |
// $emailTemplate = $emailTemplateMapper->fetchOneByCodeAndNetworkId(EmailTemplate::CODE_LIKE_MY_FEED, $currentUser->network_id);
|
| 5500 |
anderson |
922 |
|
| 5558 |
anderson |
923 |
// if ($emailTemplate) {
|
|
|
924 |
// $arrayCont = [
|
|
|
925 |
// 'firstname' => $currentUser->first_name,
|
|
|
926 |
// 'lastname' => $currentUser->last_name,
|
|
|
927 |
// 'other_user_firstname' => $ownerFeed->first_name,
|
|
|
928 |
// 'other_user_lastname' => $ownerFeed->last_name,
|
|
|
929 |
// 'company_name' => '',
|
|
|
930 |
// 'group_name' => '',
|
|
|
931 |
// 'content' => '',
|
|
|
932 |
// 'code' => '',
|
|
|
933 |
// 'link' => $this->url()->fromRoute('dashboard', ['feed' => $feed->uuid], ['force_canonical' => true])
|
|
|
934 |
// ];
|
| 5500 |
anderson |
935 |
|
| 5558 |
anderson |
936 |
// $email = new QueueEmail($this->adapter);
|
|
|
937 |
// $email->processEmailTemplate($emailTemplate, $arrayCont, $ownerFeed->email, trim($ownerFeed->first_name . ' ' . $ownerFeed->last_name));
|
|
|
938 |
// }
|
|
|
939 |
// }
|
|
|
940 |
// }
|
| 1 |
www |
941 |
|
| 5500 |
anderson |
942 |
|
|
|
943 |
|
|
|
944 |
|
|
|
945 |
|
|
|
946 |
|
|
|
947 |
|
|
|
948 |
|
| 5558 |
anderson |
949 |
// $response = [
|
|
|
950 |
// 'success' => true,
|
|
|
951 |
// 'data' => [
|
|
|
952 |
// 'likes' => $likes
|
|
|
953 |
// ]
|
|
|
954 |
// ];
|
|
|
955 |
// } else {
|
|
|
956 |
// $response = [
|
|
|
957 |
// 'success' => false,
|
|
|
958 |
// 'data' => $likeMapper->getError()
|
|
|
959 |
// ];
|
|
|
960 |
// }
|
|
|
961 |
// return new JsonModel($response);
|
|
|
962 |
// }
|
| 5500 |
anderson |
963 |
|
| 5558 |
anderson |
964 |
// $response = [
|
|
|
965 |
// 'success' => false,
|
|
|
966 |
// 'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
967 |
// ];
|
|
|
968 |
// return new JsonModel($response);
|
|
|
969 |
// }
|
| 5500 |
anderson |
970 |
|
| 5558 |
anderson |
971 |
// public function unlikeAction()
|
|
|
972 |
// {
|
|
|
973 |
// $id = $this->params()->fromRoute('id');
|
| 5500 |
anderson |
974 |
|
| 5558 |
anderson |
975 |
// $request = $this->getRequest();
|
|
|
976 |
// if ($request->isPost()) {
|
|
|
977 |
// $currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
978 |
// $currentUser = $currentUserPlugin->getUser();
|
| 3639 |
efrain |
979 |
|
| 5558 |
anderson |
980 |
// $feedMapper = FeedMapper::getInstance($this->adapter);
|
|
|
981 |
// $feed = $feedMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
|
|
|
982 |
// if (!$feed) {
|
|
|
983 |
// $response = [
|
|
|
984 |
// 'success' => false,
|
|
|
985 |
// 'data' => 'ERROR_POST_NOT_FOUND'
|
|
|
986 |
// ];
|
|
|
987 |
// return new JsonModel($response);
|
|
|
988 |
// }
|
| 5500 |
anderson |
989 |
|
| 5558 |
anderson |
990 |
// $likeMapper = LikeMapper::getInstance($this->adapter);
|
|
|
991 |
// $like = $likeMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
|
| 5500 |
anderson |
992 |
|
| 5558 |
anderson |
993 |
// if (!$like) {
|
|
|
994 |
// $response = [
|
|
|
995 |
// 'success' => false,
|
|
|
996 |
// 'data' => 'ERROR_DUPLICATE_ACTION'
|
|
|
997 |
// ];
|
|
|
998 |
// return new JsonModel($response);
|
|
|
999 |
// }
|
| 5500 |
anderson |
1000 |
|
| 5558 |
anderson |
1001 |
// if ($likeMapper->deleteByFeedIdAndUserId($feed->id, $currentUser->id)) {
|
|
|
1002 |
// $likes = $likeMapper->fetchCountLikeByFeedId($feed->id);
|
| 5500 |
anderson |
1003 |
|
|
|
1004 |
|
| 5558 |
anderson |
1005 |
// $response = [
|
|
|
1006 |
// 'success' => true,
|
|
|
1007 |
// 'data' => [
|
|
|
1008 |
// 'likes' => $likes
|
|
|
1009 |
// ]
|
|
|
1010 |
// ];
|
|
|
1011 |
// } else {
|
|
|
1012 |
// $response = [
|
|
|
1013 |
// 'success' => false,
|
|
|
1014 |
// 'data' => $likeMapper->getError()
|
|
|
1015 |
// ];
|
|
|
1016 |
// }
|
|
|
1017 |
// return new JsonModel($response);
|
|
|
1018 |
// }
|
| 5500 |
anderson |
1019 |
|
| 5558 |
anderson |
1020 |
// $response = [
|
|
|
1021 |
// 'success' => false,
|
|
|
1022 |
// 'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1023 |
// ];
|
|
|
1024 |
// return new JsonModel($response);
|
|
|
1025 |
// }
|
| 3639 |
efrain |
1026 |
|
| 5502 |
anderson |
1027 |
public function timelineAction()
|
|
|
1028 |
{
|
|
|
1029 |
$utilMapper = UtilMapper::getInstance($this->adapter);
|
|
|
1030 |
$now = $utilMapper->getDatebaseNow();
|
| 5517 |
anderson |
1031 |
|
|
|
1032 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1033 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
1034 |
|
|
|
1035 |
|
| 5518 |
anderson |
1036 |
$type = $this->params()->fromRoute('type');
|
| 5520 |
anderson |
1037 |
if ($type == 'user') {
|
|
|
1038 |
$id = $currentUser->id;
|
| 5526 |
anderson |
1039 |
} else {
|
|
|
1040 |
$id = $this->params()->fromRoute('id');
|
| 5520 |
anderson |
1041 |
}
|
| 5517 |
anderson |
1042 |
|
| 5518 |
anderson |
1043 |
$feedHighlighted = 0;
|
|
|
1044 |
$feedUuid = $this->params()->fromRoute('feed');
|
|
|
1045 |
|
|
|
1046 |
|
|
|
1047 |
|
|
|
1048 |
if ($feedUuid) {
|
|
|
1049 |
$feedMapper = FeedMapper::getInstance($this->adapter);
|
|
|
1050 |
$feed = $feedMapper->fetchOneByUuidAndNetworkIdAnyStatus($feedUuid, $currentUser->network_id);
|
|
|
1051 |
|
|
|
1052 |
if ($feed) {
|
|
|
1053 |
$feedHighlighted = $feed->id;
|
|
|
1054 |
}
|
|
|
1055 |
}
|
|
|
1056 |
|
|
|
1057 |
|
|
|
1058 |
|
|
|
1059 |
$request = $this->getRequest();
|
| 5531 |
anderson |
1060 |
if ($request->isGet()) {
|
| 5518 |
anderson |
1061 |
|
| 5531 |
anderson |
1062 |
$page = (int) $this->params()->fromQuery('page');
|
| 5545 |
anderson |
1063 |
if ($type == 'user') {
|
| 5532 |
anderson |
1064 |
$connectionMapper = ConnectionMapper::getInstance($this->adapter);
|
|
|
1065 |
$records = $connectionMapper->fetchAllConnectionsByUser($id);
|
|
|
1066 |
$connectionIds = [0];
|
|
|
1067 |
foreach ($records as $record) {
|
|
|
1068 |
if ($currentUser->id == $record->request_from) {
|
|
|
1069 |
array_push($connectionIds, $record->request_to);
|
|
|
1070 |
} else {
|
|
|
1071 |
array_push($connectionIds, $record->request_from);
|
|
|
1072 |
}
|
|
|
1073 |
}
|
|
|
1074 |
array_push($connectionIds, 1);
|
| 5518 |
anderson |
1075 |
|
| 5532 |
anderson |
1076 |
$companyFollowerMapper = CompanyFollowerMapper::getInstance($this->adapter);
|
|
|
1077 |
$records = $companyFollowerMapper->fetchAllByFollowerId($currentUser->id);
|
| 5518 |
anderson |
1078 |
|
| 5532 |
anderson |
1079 |
$companyIds = [0];
|
|
|
1080 |
foreach ($records as $record) {
|
|
|
1081 |
if (!in_array($record->company_id, $companyIds)) {
|
|
|
1082 |
array_push($companyIds, $record->company_id);
|
|
|
1083 |
}
|
|
|
1084 |
}
|
| 5518 |
anderson |
1085 |
|
| 5532 |
anderson |
1086 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
1087 |
$companyUsers = $companyUserMapper->fetchAllByUserId($currentUser->id);
|
| 5518 |
anderson |
1088 |
|
| 5532 |
anderson |
1089 |
foreach ($companyUsers as $companyUser) {
|
|
|
1090 |
if ($companyUser->status == CompanyUser::STATUS_ACCEPTED) {
|
|
|
1091 |
if (!in_array($companyUser->company_id, $companyIds)) {
|
|
|
1092 |
array_push($companyIds, $companyUser->company_id);
|
|
|
1093 |
}
|
|
|
1094 |
}
|
|
|
1095 |
}
|
| 5518 |
anderson |
1096 |
|
| 5547 |
anderson |
1097 |
$groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
1098 |
$groupMembers = $groupMemberMapper->fetchAllByUserId($currentUser->id);
|
| 5554 |
anderson |
1099 |
|
| 5555 |
anderson |
1100 |
$groupIds = [0];
|
| 5554 |
anderson |
1101 |
|
| 5552 |
anderson |
1102 |
foreach ($groupMembers as $groupMember) {
|
|
|
1103 |
if ($groupMember->status == GroupMember::STATUS_ACCEPTED) {
|
| 5555 |
anderson |
1104 |
if (!in_array($groupMember->group_id, $groupIds)) {
|
|
|
1105 |
array_push($groupIds, $groupMember->group_id);
|
| 5552 |
anderson |
1106 |
}
|
|
|
1107 |
}
|
|
|
1108 |
}
|
| 5546 |
anderson |
1109 |
|
| 5534 |
anderson |
1110 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
1111 |
$select = $queryMapper->getSql()->select(FeedMapper::_TABLE);
|
|
|
1112 |
$select->columns(['id']);
|
|
|
1113 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
1114 |
$select->where->equalTo('status', Feed::STATUS_PUBLISHED)
|
|
|
1115 |
->AND->NEST
|
|
|
1116 |
->OR->NEST->equalTo('user_id', $id)->and->equalTo('type', Feed::TYPE_UPDATE)->UNNEST
|
|
|
1117 |
->OR->NEST->and->equalTo('type', Feed::TYPE_UPDATE)->and->equalTo('shared_with', Feed::SHARE_WITH_PUBLIC)->UNNEST
|
|
|
1118 |
->OR->NEST->in('user_id', $connectionIds)->and->equalTo('type', Feed::TYPE_UPDATE)->and->equalTo('shared_with', Feed::SHARE_WITH_CONNECTIONS)->UNNEST
|
| 5535 |
anderson |
1119 |
->OR->NEST->or->in('company_id', $companyIds)->and->equalTo('type', Feed::TYPE_COMPANY)->UNNEST
|
| 5555 |
anderson |
1120 |
->OR->NEST->or->in('group_id', $groupIds)->and->equalTo('type', Feed::TYPE_GROUP)->UNNEST
|
| 5534 |
anderson |
1121 |
->UNNEST;
|
|
|
1122 |
$select->order('added_on desc');
|
| 5532 |
anderson |
1123 |
}
|
| 5531 |
anderson |
1124 |
if ($type == 'company') {
|
|
|
1125 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
1126 |
$company = $companyMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
|
| 5518 |
anderson |
1127 |
|
| 5531 |
anderson |
1128 |
if (!$company || $company->status != Company::STATUS_ACTIVE) {
|
|
|
1129 |
$id = 0;
|
| 5517 |
anderson |
1130 |
} else {
|
| 5531 |
anderson |
1131 |
$companyFollowerMapper = CompanyFollowerMapper::getInstance($this->adapter);
|
|
|
1132 |
$companyFollower = $companyFollowerMapper->fetchOneByCompanyIdAndUserId($company->id, $currentUser->id);
|
|
|
1133 |
if ($companyFollower) {
|
|
|
1134 |
$id = $company->id;
|
|
|
1135 |
} else {
|
| 5518 |
anderson |
1136 |
|
| 5531 |
anderson |
1137 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
1138 |
$companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($company->id, $currentUser->id);
|
| 5518 |
anderson |
1139 |
|
| 5531 |
anderson |
1140 |
if (!$companyUser || $companyUser->status != CompanyUser::STATUS_ACCEPTED) {
|
|
|
1141 |
$id = 0;
|
|
|
1142 |
} else {
|
|
|
1143 |
$id = $company->id;
|
|
|
1144 |
}
|
| 5518 |
anderson |
1145 |
}
|
| 5517 |
anderson |
1146 |
}
|
| 5518 |
anderson |
1147 |
|
|
|
1148 |
|
| 5531 |
anderson |
1149 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
1150 |
$select = $queryMapper->getSql()->select(FeedMapper::_TABLE);
|
|
|
1151 |
$select->columns(['id']);
|
|
|
1152 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
1153 |
$select->where->equalTo('status', Feed::STATUS_PUBLISHED);
|
|
|
1154 |
$select->where->equalTo('company_id', $id);
|
|
|
1155 |
$select->where->and->equalTo('type', Feed::TYPE_COMPANY);
|
|
|
1156 |
$select->order('added_on desc');
|
|
|
1157 |
}
|
| 5537 |
anderson |
1158 |
if ($type == 'group') {
|
|
|
1159 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
1160 |
$group = $groupMapper->fetchOneByUuidAndNetworkId($id, $currentUser->network_id);
|
| 5518 |
anderson |
1161 |
|
| 5537 |
anderson |
1162 |
$id = 0;
|
| 5518 |
anderson |
1163 |
|
| 5537 |
anderson |
1164 |
if ($group && $group->status == Group::STATUS_ACTIVE) {
|
|
|
1165 |
$groupMemberMapper = GroupMemberMapper::getInstance($this->adapter);
|
|
|
1166 |
$groupMember = $groupMemberMapper->fetchOneByGroupIdAndUserId($group->id, $currentUser->id);
|
|
|
1167 |
if ($groupMember) {
|
| 5518 |
anderson |
1168 |
|
|
|
1169 |
|
| 5537 |
anderson |
1170 |
if (
|
|
|
1171 |
$groupMember->status == GroupMember::STATUS_ACCEPTED ||
|
|
|
1172 |
$groupMember->status == GroupMember::STATUS_AUTO_JOIN
|
|
|
1173 |
) {
|
| 5518 |
anderson |
1174 |
|
| 5537 |
anderson |
1175 |
$id = $groupMember->group_id;
|
|
|
1176 |
}
|
|
|
1177 |
}
|
|
|
1178 |
}
|
| 5531 |
anderson |
1179 |
|
| 5537 |
anderson |
1180 |
$queryMapper = QueryMapper::getInstance($this->adapter);
|
|
|
1181 |
$select = $queryMapper->getSql()->select(FeedMapper::_TABLE);
|
|
|
1182 |
$select->columns(['id']);
|
|
|
1183 |
$select->where->equalTo('network_id', $currentUser->network_id);
|
|
|
1184 |
$select->where->equalTo('status', Feed::STATUS_PUBLISHED);
|
|
|
1185 |
$select->where->equalTo('group_id', $id);
|
|
|
1186 |
$select->where->and->equalTo('type', Feed::TYPE_GROUP);
|
|
|
1187 |
$select->order('added_on desc');
|
|
|
1188 |
}
|
| 5518 |
anderson |
1189 |
|
| 5531 |
anderson |
1190 |
$dbSelect = new DbSelect($select, $this->adapter);
|
|
|
1191 |
$paginator = new Paginator($dbSelect);
|
|
|
1192 |
$paginator->setCurrentPageNumber($page ? $page : 1);
|
|
|
1193 |
$paginator->setItemCountPerPage(10);
|
| 5518 |
anderson |
1194 |
|
| 5531 |
anderson |
1195 |
$items = [];
|
| 5518 |
anderson |
1196 |
|
|
|
1197 |
|
| 5531 |
anderson |
1198 |
if ($feedHighlighted) {
|
| 5518 |
anderson |
1199 |
|
|
|
1200 |
|
| 5531 |
anderson |
1201 |
$items[] = $this->renderFeed($feedHighlighted, $now, $feedHighlighted);
|
|
|
1202 |
}
|
| 5518 |
anderson |
1203 |
|
| 5531 |
anderson |
1204 |
$feeds = $paginator->getCurrentItems();
|
|
|
1205 |
foreach ($feeds as $feed) {
|
|
|
1206 |
$items[] = $this->renderFeed($feed->id, $now, $feedHighlighted);
|
|
|
1207 |
}
|
| 5518 |
anderson |
1208 |
|
| 5531 |
anderson |
1209 |
$response = [
|
|
|
1210 |
'success' => true,
|
|
|
1211 |
'data' => [
|
|
|
1212 |
'total' => [
|
|
|
1213 |
'count' => $paginator->getTotalItemCount(),
|
|
|
1214 |
'pages' => $paginator->getPages()->pageCount,
|
|
|
1215 |
],
|
|
|
1216 |
'current' => [
|
|
|
1217 |
'items' => $items,
|
|
|
1218 |
'page' => $paginator->getCurrentPageNumber(),
|
|
|
1219 |
'count' => $paginator->getCurrentItemCount(),
|
|
|
1220 |
]
|
| 5518 |
anderson |
1221 |
]
|
| 5531 |
anderson |
1222 |
];
|
| 5518 |
anderson |
1223 |
|
|
|
1224 |
|
|
|
1225 |
|
| 5531 |
anderson |
1226 |
/*
|
| 5518 |
anderson |
1227 |
if($feedHighlighted) {
|
|
|
1228 |
|
|
|
1229 |
|
|
|
1230 |
$items[] = $this->renderFeed($feedHighlighted, $now, $feedHighlighted);
|
|
|
1231 |
|
|
|
1232 |
$response = [
|
|
|
1233 |
'success' => true,
|
|
|
1234 |
'data' => [
|
|
|
1235 |
'total' => [
|
|
|
1236 |
'count' => 1,
|
|
|
1237 |
'pages' => 1,
|
|
|
1238 |
],
|
|
|
1239 |
'current' => [
|
|
|
1240 |
'items' => $items,
|
|
|
1241 |
'page' => 1,
|
|
|
1242 |
'count' => 1,
|
|
|
1243 |
]
|
|
|
1244 |
]
|
|
|
1245 |
];
|
|
|
1246 |
} else {
|
|
|
1247 |
|
|
|
1248 |
|
|
|
1249 |
|
|
|
1250 |
$feeds = $paginator->getCurrentItems();
|
|
|
1251 |
foreach($feeds as $feed)
|
|
|
1252 |
{
|
|
|
1253 |
$items[] = $this->renderFeed($feed->id, $now, $feedHighlighted);
|
|
|
1254 |
}
|
|
|
1255 |
|
|
|
1256 |
$response = [
|
|
|
1257 |
'success' => true,
|
|
|
1258 |
'data' => [
|
|
|
1259 |
'total' => [
|
|
|
1260 |
'count' => $paginator->getTotalItemCount(),
|
|
|
1261 |
'pages' => $paginator->getPages()->pageCount,
|
|
|
1262 |
],
|
|
|
1263 |
'current' => [
|
|
|
1264 |
'items' => $items,
|
|
|
1265 |
'page' => $paginator->getCurrentPageNumber(),
|
|
|
1266 |
'count' => $paginator->getCurrentItemCount(),
|
|
|
1267 |
]
|
|
|
1268 |
]
|
|
|
1269 |
];
|
|
|
1270 |
}*/
|
|
|
1271 |
|
|
|
1272 |
|
|
|
1273 |
|
| 5531 |
anderson |
1274 |
return new JsonModel($response);
|
|
|
1275 |
}
|
| 5518 |
anderson |
1276 |
|
|
|
1277 |
$response = [
|
|
|
1278 |
'success' => false,
|
|
|
1279 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
1280 |
];
|
|
|
1281 |
|
|
|
1282 |
|
|
|
1283 |
return new JsonModel($response);
|
| 5502 |
anderson |
1284 |
}
|
| 5500 |
anderson |
1285 |
|
| 1 |
www |
1286 |
/**
|
|
|
1287 |
*
|
|
|
1288 |
* @param string $str
|
|
|
1289 |
* @return string
|
|
|
1290 |
*/
|
| 5500 |
anderson |
1291 |
private function normalizeString($str = '')
|
| 1 |
www |
1292 |
{
|
|
|
1293 |
$basename = substr($str, 0, strrpos($str, '.'));
|
|
|
1294 |
$basename = str_replace('.', '-', $basename);
|
| 5500 |
anderson |
1295 |
|
| 1 |
www |
1296 |
$extension = substr($str, strrpos($str, '.'));
|
| 5500 |
anderson |
1297 |
|
| 1 |
www |
1298 |
$str = $basename . $extension;
|
| 5500 |
anderson |
1299 |
|
| 1 |
www |
1300 |
$str = strip_tags($str);
|
|
|
1301 |
$str = preg_replace('/[\r\n\t ]+/', ' ', $str);
|
|
|
1302 |
$str = preg_replace('/[\"\*\/\:\<\>\?\'\|\,]+/', ' ', $str);
|
|
|
1303 |
$str = strtolower($str);
|
| 5500 |
anderson |
1304 |
$str = html_entity_decode($str, ENT_QUOTES, "utf-8");
|
| 1 |
www |
1305 |
$str = htmlentities($str, ENT_QUOTES, "utf-8");
|
|
|
1306 |
$str = preg_replace("/(&)([a-z])([a-z]+;)/i", '$2', $str);
|
|
|
1307 |
$str = str_replace(' ', '-', $str);
|
|
|
1308 |
$str = rawurlencode($str);
|
|
|
1309 |
$str = str_replace('%', '-', $str);
|
|
|
1310 |
return trim(strtolower($str));
|
|
|
1311 |
}
|
| 5500 |
anderson |
1312 |
|
|
|
1313 |
|
|
|
1314 |
|
| 1 |
www |
1315 |
/**
|
|
|
1316 |
*
|
|
|
1317 |
* @param int $feed_id
|
|
|
1318 |
* @return array
|
|
|
1319 |
*/
|
| 3146 |
efrain |
1320 |
private function renderFeed($feed_id, $now, $feedHighlighted = 0)
|
| 1 |
www |
1321 |
{
|
|
|
1322 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
1323 |
$currentUser = $currentUserPlugin->getUser();
|
| 5500 |
anderson |
1324 |
|
| 3639 |
efrain |
1325 |
//$acl = $this->getEvent()->getViewModel()->getVariable('acl');
|
| 1 |
www |
1326 |
|
|
|
1327 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1328 |
$feedMapper = FeedMapper::getInstance($this->adapter);
|
| 3146 |
efrain |
1329 |
$feed = $feedMapper->fetchOneAnyStatus($feed_id);
|
| 5500 |
anderson |
1330 |
|
|
|
1331 |
|
|
|
1332 |
|
|
|
1333 |
|
|
|
1334 |
|
| 1 |
www |
1335 |
$likeMapper = LikeMapper::getInstance($this->adapter);
|
|
|
1336 |
$like = $likeMapper->fetchOneByFeedIdAndUserId($feed->id, $currentUser->id);
|
| 1042 |
efrain |
1337 |
$likes = $likeMapper->fetchCountLikeByFeedId($feed->id);
|
| 5500 |
anderson |
1338 |
|
| 1 |
www |
1339 |
$params = [
|
|
|
1340 |
'id' => $feed->uuid
|
|
|
1341 |
];
|
| 5500 |
anderson |
1342 |
if ($feed->company_id) {
|
| 1 |
www |
1343 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
1344 |
$company = $companyMapper->fetchOne($feed->company_id);
|
| 5500 |
anderson |
1345 |
|
| 1 |
www |
1346 |
$params['company_id'] = $company->uuid;
|
|
|
1347 |
} else {
|
|
|
1348 |
$company = null;
|
|
|
1349 |
}
|
| 5500 |
anderson |
1350 |
if ($feed->group_id) {
|
| 1 |
www |
1351 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
1352 |
$group = $groupMapper->fetchOne($feed->group_id);
|
| 5500 |
anderson |
1353 |
|
| 1 |
www |
1354 |
$params['group_id'] = $group->uuid;
|
|
|
1355 |
} else {
|
|
|
1356 |
$group = null;
|
|
|
1357 |
}
|
| 5500 |
anderson |
1358 |
|
|
|
1359 |
|
| 3364 |
efrain |
1360 |
$timestamp = time();
|
| 5500 |
anderson |
1361 |
|
| 3364 |
efrain |
1362 |
list($usec, $sec) = explode(' ', microtime());
|
|
|
1363 |
$seed = intval($sec + ((float) $usec * 100000));
|
|
|
1364 |
mt_srand($seed, MT_RAND_MT19937);
|
|
|
1365 |
$rand = mt_rand();
|
| 5500 |
anderson |
1366 |
|
|
|
1367 |
|
|
|
1368 |
|
|
|
1369 |
$password = md5('user-' . $currentUser->uuid . '-feed-' . $feed->uuid . '-timestamp-' . $timestamp . '-rand-' . $rand . '-share-key-' . $currentUser->share_key);
|
|
|
1370 |
|
|
|
1371 |
|
| 3380 |
efrain |
1372 |
$share_params = [
|
| 5500 |
anderson |
1373 |
'type' => 'feed',
|
| 3379 |
efrain |
1374 |
'code' => $feed->uuid,
|
|
|
1375 |
'user' => $currentUser->uuid,
|
|
|
1376 |
'timestamp' => $timestamp,
|
|
|
1377 |
'rand' => $rand,
|
|
|
1378 |
'password' => $password,
|
| 3364 |
efrain |
1379 |
];
|
| 3379 |
efrain |
1380 |
|
| 5500 |
anderson |
1381 |
|
|
|
1382 |
$share_increment_external_counter_url = $this->url()->fromRoute('share/increment-external-counter', $share_params, ['force_canonical' => true]);
|
|
|
1383 |
|
|
|
1384 |
|
|
|
1385 |
$share_external_url = $this->url()->fromRoute('shorter/generate', ['code' => $feed->uuid, 'type' => 'feed'], ['force_canonical' => true]);
|
|
|
1386 |
|
| 1 |
www |
1387 |
$item = [
|
|
|
1388 |
'feed_unique' => uniqid(),
|
|
|
1389 |
'feed_uuid' => $feed->uuid,
|
|
|
1390 |
'feed_is_liked' => $like ? true : false,
|
|
|
1391 |
'feed_like_url' => $this->url()->fromRoute('feed/like', $params),
|
|
|
1392 |
'feed_unlike_url' => $this->url()->fromRoute('feed/unlike', $params),
|
|
|
1393 |
'feed_share_url' => $this->url()->fromRoute('feed/share', $params),
|
| 3364 |
efrain |
1394 |
'feed_share_external_url' => $share_external_url,
|
| 4778 |
efrain |
1395 |
'feed_increment_external_counter_url' => $share_increment_external_counter_url,
|
| 1 |
www |
1396 |
'feed_delete_url' => '',
|
|
|
1397 |
'feed_content_type' => $feed->file_type ? $feed->file_type : '',
|
| 1042 |
efrain |
1398 |
'feed_likes' => $likes,
|
| 3146 |
efrain |
1399 |
'feed_highlighted' => $feed->id == $feedHighlighted ? 1 : 0,
|
| 5500 |
anderson |
1400 |
|
| 1 |
www |
1401 |
];
|
| 5500 |
anderson |
1402 |
|
|
|
1403 |
if ($feed->posted_or_shared == Feed::POSTED) {
|
|
|
1404 |
|
|
|
1405 |
|
|
|
1406 |
if ($feed->type == Feed::TYPE_COMPANY) {
|
| 1 |
www |
1407 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
1408 |
$company = $companyMapper->fetchOne($feed->company_id);
|
|
|
1409 |
$item['owner_url'] = $this->url()->fromRoute('company/view', ['id' => $company->uuid]);
|
|
|
1410 |
$item['owner_image'] = $this->url()->fromRoute('storage', ['code' => $company->uuid, 'type' => 'company', 'filename' => $company->image]);
|
|
|
1411 |
$item['owner_name'] = $company->name;
|
|
|
1412 |
/*
|
|
|
1413 |
|
|
|
1414 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
1415 |
$companyUser = $companyUserMapper->fetchOneByCompanyIdAndUserId($company->id, $currentUser->id);
|
|
|
1416 |
|
|
|
1417 |
|
|
|
1418 |
if( $companyUser && $acl->isAllowed( $currentUser->usertype_id, 'my-company/feed' ) ) {
|
|
|
1419 |
$item['feed_delete_url'] = $this->url()->fromRoute('feed/delete', $params);
|
|
|
1420 |
}
|
|
|
1421 |
*/
|
| 5500 |
anderson |
1422 |
} else if ($feed->type == Feed::TYPE_GROUP) {
|
| 1 |
www |
1423 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
1424 |
$group = $groupMapper->fetchOne($feed->group_id);
|
|
|
1425 |
$item['owner_url'] = '';
|
|
|
1426 |
$item['owner_image'] = $this->url()->fromRoute('storage', ['code' => $group->uuid, 'type' => 'group', 'filename' => $group->image]);
|
|
|
1427 |
$item['owner_name'] = $group->name;
|
| 5500 |
anderson |
1428 |
|
|
|
1429 |
if ($group->user_id == $currentUser->id) {
|
| 1 |
www |
1430 |
$item['feed_delete_url'] = $this->url()->fromRoute('feed/delete', $params);
|
|
|
1431 |
}
|
|
|
1432 |
} else {
|
|
|
1433 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1434 |
$user = $userMapper->fetchOne($feed->user_id);
|
| 5500 |
anderson |
1435 |
|
| 1 |
www |
1436 |
$item['owner_url'] = $this->url()->fromRoute('profile/view', ['id' => $user->uuid]);
|
|
|
1437 |
$item['owner_image'] = $this->url()->fromRoute('storage', ['code' => $user->uuid, 'type' => 'user', 'filename' => $user->image]);
|
|
|
1438 |
$item['owner_name'] = $user->first_name . ' ' . $user->last_name;
|
| 5500 |
anderson |
1439 |
|
|
|
1440 |
if ($feed->user_id == $currentUser->id) {
|
| 1 |
www |
1441 |
$item['feed_delete_url'] = $this->url()->fromRoute('feed/delete', $params);
|
|
|
1442 |
}
|
| 5500 |
anderson |
1443 |
}
|
| 1 |
www |
1444 |
} else {
|
| 5500 |
anderson |
1445 |
if ($feed->user_id == $currentUser->id) {
|
| 1 |
www |
1446 |
$item['feed_delete_url'] = $this->url()->fromRoute('feed/delete', $params);
|
|
|
1447 |
}
|
|
|
1448 |
}
|
| 5500 |
anderson |
1449 |
|
| 1 |
www |
1450 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
1451 |
$user = $userMapper->fetchOne($feed->user_id);
|
| 5500 |
anderson |
1452 |
|
|
|
1453 |
if ($feed->posted_or_shared == Feed::SHARED) {
|
| 1 |
www |
1454 |
$item['owner_url'] = $this->url()->fromRoute('profile/view', ['id' => $user->uuid]);
|
|
|
1455 |
$item['owner_image'] = $this->url()->fromRoute('storage', ['code' => $user->uuid, 'type' => 'user', 'filename' => $user->image]);
|
|
|
1456 |
$item['owner_name'] = $user->first_name . ' ' . $user->last_name;
|
|
|
1457 |
}
|
| 5500 |
anderson |
1458 |
|
| 1 |
www |
1459 |
$item['owner_description'] = $feed->description;
|
| 5500 |
anderson |
1460 |
|
| 1 |
www |
1461 |
$item['owner_shared'] = $feed->total_shared;
|
| 4778 |
efrain |
1462 |
$item['owner_external_shared'] = $feed->total_external_shared;
|
| 1 |
www |
1463 |
$item['owner_comments'] = $feed->total_comments;
|
| 5500 |
anderson |
1464 |
|
|
|
1465 |
|
| 3138 |
efrain |
1466 |
$item['owner_time_elapse'] = Functions::timeAgo($feed->added_on, $now);
|
| 5500 |
anderson |
1467 |
|
|
|
1468 |
if ($feed->file_type == Feed::FILE_TYPE_IMAGE) {
|
| 1 |
www |
1469 |
$item['owner_file_image'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name]);
|
|
|
1470 |
}
|
| 5500 |
anderson |
1471 |
if ($feed->file_type == Feed::FILE_TYPE_DOCUMENT) {
|
| 1 |
www |
1472 |
$item['owner_file_document'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name]);
|
|
|
1473 |
}
|
| 5500 |
anderson |
1474 |
if ($feed->file_type == Feed::FILE_TYPE_VIDEO) {
|
| 1 |
www |
1475 |
$item['owner_file_image_preview'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_image_preview]);
|
|
|
1476 |
$item['owner_file_video'] = $this->url()->fromRoute('storage', ['code' => $feed->uuid, 'type' => 'feed', 'filename' => $feed->file_name]);
|
|
|
1477 |
}
|
| 5500 |
anderson |
1478 |
|
|
|
1479 |
if ($feed->posted_or_shared == Feed::SHARED) {
|
|
|
1480 |
|
|
|
1481 |
|
| 3143 |
efrain |
1482 |
$sharedFeed = $feedMapper->fetchOneAnyStatus($feed->shared_feed_id);
|
| 5500 |
anderson |
1483 |
|
|
|
1484 |
|
|
|
1485 |
|
|
|
1486 |
|
| 1 |
www |
1487 |
$item['shared_description'] = $sharedFeed->description;
|
| 5500 |
anderson |
1488 |
$item['shared_time_elapse'] = Functions::timeAgo($sharedFeed->added_on, $now);
|
|
|
1489 |
|
|
|
1490 |
if ($sharedFeed->file_type == Feed::FILE_TYPE_IMAGE) {
|
| 1 |
www |
1491 |
$item['shared_file_image'] = $this->url()->fromRoute('storage', ['code' => $sharedFeed->uuid, 'type' => 'feed', 'filename' => $sharedFeed->file_name]);
|
|
|
1492 |
}
|
| 5500 |
anderson |
1493 |
if ($sharedFeed->file_type == Feed::FILE_TYPE_DOCUMENT) {
|
| 1 |
www |
1494 |
$item['shared_file_document'] = $this->url()->fromRoute('storage', ['code' => $sharedFeed->uuid, 'type' => 'feed', 'filename' => $sharedFeed->file_name]);
|
|
|
1495 |
}
|
| 5500 |
anderson |
1496 |
if ($sharedFeed->file_type == Feed::FILE_TYPE_VIDEO) {
|
| 1 |
www |
1497 |
$item['shared_file_image_preview'] = $this->url()->fromRoute('storage', ['code' => $sharedFeed->uuid, 'type' => 'feed', 'filename' => $sharedFeed->file_image_preview]);
|
|
|
1498 |
$item['shared_file_video'] = $this->url()->fromRoute('storage', ['code' => $sharedFeed->uuid, 'type' => 'feed', 'filename' => $sharedFeed->file_name]);
|
|
|
1499 |
}
|
| 5500 |
anderson |
1500 |
|
| 1 |
www |
1501 |
$item['shared_content_type'] = $sharedFeed->file_type ? $sharedFeed->file_type : '';
|
| 5500 |
anderson |
1502 |
|
|
|
1503 |
if ($feed->company_id) {
|
|
|
1504 |
|
| 1 |
www |
1505 |
$companyMapper = CompanyMapper::getInstance($this->adapter);
|
|
|
1506 |
$sharedCompany = $companyMapper->fetchOne($feed->company_id);
|
|
|
1507 |
$item['shared_url'] = $this->url()->fromRoute('company/view', ['id' => $sharedCompany->uuid]);
|
|
|
1508 |
$item['shared_image'] = $this->url()->fromRoute('storage', ['code' => $sharedCompany->uuid, 'type' => 'company', 'filename' => $sharedCompany->image]);
|
|
|
1509 |
$item['shared_name'] = $sharedCompany->name;
|
| 5500 |
anderson |
1510 |
} else if ($feed->group_id) {
|
| 1 |
www |
1511 |
$groupMapper = GroupMapper::getInstance($this->adapter);
|
|
|
1512 |
$sharedGroup = $groupMapper->fetchOne($feed->group_id);
|
| 5500 |
anderson |
1513 |
$item['shared_url'] = '';
|
| 1 |
www |
1514 |
$item['shared_image'] = $this->url()->fromRoute('storage', ['code' => $sharedGroup->uuid, 'type' => 'group', 'filename' => $sharedGroup->image]);
|
|
|
1515 |
$item['shared_name'] = $sharedGroup->name;
|
|
|
1516 |
} else {
|
| 5500 |
anderson |
1517 |
|
| 1 |
www |
1518 |
$sharedUser = $userMapper->fetchOne($sharedFeed->user_id);
|
|
|
1519 |
$item['shared_url'] = $this->url()->fromRoute('profile/view', ['id' => $sharedUser->uuid]);
|
|
|
1520 |
$item['shared_image'] = $this->url()->fromRoute('storage', ['code' => $sharedUser->uuid, 'type' => 'user', 'filename' => $sharedUser->image]);
|
|
|
1521 |
$item['shared_name'] = $sharedUser->first_name . ' ' . $sharedUser->last_name;
|
|
|
1522 |
}
|
|
|
1523 |
}
|
| 5500 |
anderson |
1524 |
|
| 1 |
www |
1525 |
$commentMapper = CommentMapper::getInstance($this->adapter);
|
|
|
1526 |
$records = $commentMapper->fetchAllPublishedByFeedId($feed->id);
|
| 5500 |
anderson |
1527 |
|
| 1 |
www |
1528 |
$comments = [];
|
| 5500 |
anderson |
1529 |
foreach ($records as $record) {
|
| 1 |
www |
1530 |
$user = $userMapper->fetchOne($record->user_id);
|
| 3138 |
efrain |
1531 |
|
| 5500 |
anderson |
1532 |
if ($record->user_id == $currentUser->id) {
|
|
|
1533 |
$link_delete = $this->url()->fromRoute('feed/comment/delete', ['id' => $feed->uuid, 'comment' => $record->uuid]);
|
| 1 |
www |
1534 |
} else {
|
|
|
1535 |
$link_delete = '';
|
|
|
1536 |
}
|
| 5500 |
anderson |
1537 |
|
| 1 |
www |
1538 |
array_push($comments, [
|
|
|
1539 |
'unique' => uniqid(),
|
|
|
1540 |
'user_url' => $this->url()->fromRoute('profile/view', ['id' => $user->uuid]),
|
|
|
1541 |
'user_name' => $user->first_name . ' ' . $user->last_name,
|
| 5500 |
anderson |
1542 |
'user_image' => $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image]),
|
| 3138 |
efrain |
1543 |
'time_elapsed' => Functions::timeAgo($record->added_on, $now),
|
| 1 |
www |
1544 |
'comment' => $record->comment,
|
|
|
1545 |
'link_delete' => $link_delete
|
|
|
1546 |
]);
|
|
|
1547 |
}
|
|
|
1548 |
$item['comment_add_url'] = $this->url()->fromRoute('feed/comment', ['id' => $feed->uuid]);
|
|
|
1549 |
$item['comments'] = $comments;
|
| 5500 |
anderson |
1550 |
|
| 1 |
www |
1551 |
return $item;
|
|
|
1552 |
}
|
| 5500 |
anderson |
1553 |
|
| 1 |
www |
1554 |
/**
|
|
|
1555 |
*
|
|
|
1556 |
* @param int $comment_id
|
|
|
1557 |
* @return array
|
|
|
1558 |
*/
|
| 3138 |
efrain |
1559 |
private function renderComment($comment_id, $now)
|
| 1 |
www |
1560 |
{
|
|
|
1561 |
$item = [];
|
| 5500 |
anderson |
1562 |
|
| 1 |
www |
1563 |
$commentMapper = CommentMapper::getInstance($this->adapter);
|
|
|
1564 |
$record = $commentMapper->fetchOne($comment_id);
|
| 5500 |
anderson |
1565 |
|
| 1 |
www |
1566 |
$feedMapper = FeedMapper::getInstance($this->adapter);
|
|
|
1567 |
$feed = $feedMapper->fetchOne($record->feed_id);
|
| 5500 |
anderson |
1568 |
|
|
|
1569 |
if ($record) {
|
| 1 |
www |
1570 |
$userMapper = UserMapper::getInstance($this->adapter);
|
| 5500 |
anderson |
1571 |
|
| 1 |
www |
1572 |
$user = $userMapper->fetchOne($record->user_id);
|
| 5500 |
anderson |
1573 |
|
| 1 |
www |
1574 |
$item['unique'] = uniqid();
|
| 5500 |
anderson |
1575 |
$item['user_image'] = $this->url()->fromRoute('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image]);
|
| 1 |
www |
1576 |
$item['user_url'] = $this->url()->fromRoute('profile', ['id' => $user->uuid]);
|
|
|
1577 |
$item['user_name'] = $user->first_name . ' ' . $user->last_name;
|
| 3138 |
efrain |
1578 |
$item['time_elapsed'] = Functions::timeAgo($record->added_on, $now);
|
| 1 |
www |
1579 |
$item['comment'] = $record->comment;
|
| 5500 |
anderson |
1580 |
$item['link_delete'] = $this->url()->fromRoute('feed/comment/delete', ['id' => $feed->uuid, 'comment' => $record->uuid]);
|
| 1 |
www |
1581 |
}
|
|
|
1582 |
return $item;
|
|
|
1583 |
}
|
| 5500 |
anderson |
1584 |
|
| 1 |
www |
1585 |
/**
|
|
|
1586 |
*
|
|
|
1587 |
* @param string $path
|
|
|
1588 |
* @return boolean
|
|
|
1589 |
*/
|
|
|
1590 |
private function deletePath($path)
|
|
|
1591 |
{
|
|
|
1592 |
try {
|
| 5500 |
anderson |
1593 |
if (is_dir($path)) {
|
| 1 |
www |
1594 |
if ($dh = opendir($path)) {
|
| 5500 |
anderson |
1595 |
while (($file = readdir($dh)) !== false) {
|
|
|
1596 |
if ($file == '.' || $file == '..') {
|
| 1 |
www |
1597 |
continue;
|
|
|
1598 |
}
|
|
|
1599 |
unlink($path . DIRECTORY_SEPARATOR . $file);
|
|
|
1600 |
}
|
|
|
1601 |
closedir($dh);
|
|
|
1602 |
}
|
| 5500 |
anderson |
1603 |
|
| 1 |
www |
1604 |
rmdir($path);
|
|
|
1605 |
}
|
|
|
1606 |
return true;
|
| 5500 |
anderson |
1607 |
} catch (\Throwable $e) {
|
| 1 |
www |
1608 |
error_log($e->getTraceAsString());
|
|
|
1609 |
return false;
|
|
|
1610 |
}
|
|
|
1611 |
}
|
| 5500 |
anderson |
1612 |
|
|
|
1613 |
|
| 1 |
www |
1614 |
/**
|
|
|
1615 |
*
|
|
|
1616 |
* @param Feed $feed
|
|
|
1617 |
* @return array
|
|
|
1618 |
*/
|
| 5500 |
anderson |
1619 |
private function deleteFeed($feed)
|
| 1 |
www |
1620 |
{
|
|
|
1621 |
$feedMapper = FeedMapper::getInstance($this->adapter);
|
|
|
1622 |
$feed->status = Feed::STATUS_DELETED;
|
| 5500 |
anderson |
1623 |
if ($feedMapper->update($feed)) {
|
| 1 |
www |
1624 |
$response = [
|
|
|
1625 |
'success' => true,
|
|
|
1626 |
'data' => 'LABEL_FEED_WAS_DELETED'
|
|
|
1627 |
];
|
|
|
1628 |
} else {
|
|
|
1629 |
$response = [
|
|
|
1630 |
'success' => false,
|
|
|
1631 |
'data' => $feedMapper->getError()
|
|
|
1632 |
];
|
|
|
1633 |
}
|
| 5500 |
anderson |
1634 |
|
|
|
1635 |
|
| 1 |
www |
1636 |
/*$commentMapper = CommentMapper::getInstance($this->adapter);
|
|
|
1637 |
if($commentMapper->deleteAllByFeedId($feed->id)) {
|
|
|
1638 |
if($feedMapper->delete($feed->id)) {
|
|
|
1639 |
$target_path = $this->config['leaderslinked.fullpath.feed'] . DIRECTORY_SEPARATOR . $feed->id;
|
|
|
1640 |
if(file_exists($target_path)) {
|
|
|
1641 |
$this->deletePath($target_path);
|
|
|
1642 |
}
|
|
|
1643 |
|
|
|
1644 |
$response = [
|
|
|
1645 |
'success' => true,
|
|
|
1646 |
'data' => 'LABEL_FEED_WAS_DELETED'
|
|
|
1647 |
];
|
|
|
1648 |
|
|
|
1649 |
} else {
|
|
|
1650 |
$response = [
|
|
|
1651 |
'success' => false,
|
|
|
1652 |
'data' => $feedMapper->getError()
|
|
|
1653 |
];
|
|
|
1654 |
}
|
|
|
1655 |
} else {
|
|
|
1656 |
$response = [
|
|
|
1657 |
'success' => false,
|
|
|
1658 |
'data' => $commentMapper->getError()
|
|
|
1659 |
];
|
|
|
1660 |
|
|
|
1661 |
}*/
|
| 5500 |
anderson |
1662 |
|
| 1 |
www |
1663 |
return $response;
|
|
|
1664 |
}
|
|
|
1665 |
}
|