13010 |
nelberth |
1 |
<?php
|
16798 |
efrain |
2 |
/**
|
|
|
3 |
*
|
|
|
4 |
* Controlador: Mis Perfiles
|
|
|
5 |
*
|
|
|
6 |
*/
|
13010 |
nelberth |
7 |
declare(strict_types=1);
|
|
|
8 |
|
|
|
9 |
namespace LeadersLinked\Controller;
|
|
|
10 |
|
|
|
11 |
use Laminas\Db\Adapter\AdapterInterface;
|
16768 |
efrain |
12 |
|
13010 |
nelberth |
13 |
use Laminas\Mvc\Controller\AbstractActionController;
|
|
|
14 |
use Laminas\Log\LoggerInterface;
|
|
|
15 |
use Laminas\View\Model\ViewModel;
|
16798 |
efrain |
16 |
|
|
|
17 |
use LeadersLinked\Mapper\UserMapper;
|
|
|
18 |
|
|
|
19 |
use LeadersLinked\Mapper\CompanyUserMapper;
|
|
|
20 |
use LeadersLinked\Mapper\ConversationMapper;
|
|
|
21 |
use LeadersLinked\Mapper\MessageMapper;
|
|
|
22 |
use LeadersLinked\Model\Conversation;
|
|
|
23 |
use LeadersLinked\Library\Image;
|
13010 |
nelberth |
24 |
use Laminas\View\Model\JsonModel;
|
16798 |
efrain |
25 |
use LeadersLinked\Model\Message;
|
|
|
26 |
use LeadersLinked\Model\VideoConvert;
|
|
|
27 |
use LeadersLinked\Mapper\VideoConvertMapper;
|
|
|
28 |
use LeadersLinked\Form\Communication\CommunicationForm;
|
|
|
29 |
use LeadersLinked\Mapper\JobDescriptionMapper;
|
|
|
30 |
use LeadersLinked\Model\User;
|
|
|
31 |
use LeadersLinked\Model\Company;
|
|
|
32 |
use LeadersLinked\Mapper\OrganizationPositionMapper;
|
13010 |
nelberth |
33 |
|
16798 |
efrain |
34 |
|
|
|
35 |
|
13010 |
nelberth |
36 |
class CommunicationController extends AbstractActionController
|
|
|
37 |
{
|
|
|
38 |
/**
|
|
|
39 |
*
|
16769 |
efrain |
40 |
* @var \Laminas\Db\Adapter\AdapterInterface
|
13010 |
nelberth |
41 |
*/
|
|
|
42 |
private $adapter;
|
|
|
43 |
|
|
|
44 |
/**
|
|
|
45 |
*
|
16769 |
efrain |
46 |
* @var \LeadersLinked\Cache\CacheInterface
|
13010 |
nelberth |
47 |
*/
|
16769 |
efrain |
48 |
private $cache;
|
|
|
49 |
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
*
|
|
|
53 |
* @var \Laminas\Log\LoggerInterface
|
|
|
54 |
*/
|
13010 |
nelberth |
55 |
private $logger;
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
*
|
|
|
59 |
* @var array
|
|
|
60 |
*/
|
|
|
61 |
private $config;
|
|
|
62 |
|
16769 |
efrain |
63 |
|
13010 |
nelberth |
64 |
/**
|
|
|
65 |
*
|
16769 |
efrain |
66 |
* @var \Laminas\Mvc\I18n\Translator
|
|
|
67 |
*/
|
|
|
68 |
private $translator;
|
|
|
69 |
|
|
|
70 |
|
|
|
71 |
/**
|
|
|
72 |
*
|
|
|
73 |
* @param \Laminas\Db\Adapter\AdapterInterface $adapter
|
|
|
74 |
* @param \LeadersLinked\Cache\CacheInterface $cache
|
|
|
75 |
* @param \Laminas\Log\LoggerInterface LoggerInterface $logger
|
13010 |
nelberth |
76 |
* @param array $config
|
16769 |
efrain |
77 |
* @param \Laminas\Mvc\I18n\Translator $translator
|
13010 |
nelberth |
78 |
*/
|
16769 |
efrain |
79 |
public function __construct($adapter, $cache, $logger, $config, $translator)
|
13010 |
nelberth |
80 |
{
|
16769 |
efrain |
81 |
$this->adapter = $adapter;
|
|
|
82 |
$this->cache = $cache;
|
|
|
83 |
$this->logger = $logger;
|
|
|
84 |
$this->config = $config;
|
|
|
85 |
$this->translator = $translator;
|
13010 |
nelberth |
86 |
}
|
|
|
87 |
|
16798 |
efrain |
88 |
|
13010 |
nelberth |
89 |
public function indexAction()
|
|
|
90 |
{
|
|
|
91 |
$request = $this->getRequest();
|
16798 |
efrain |
92 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
93 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
94 |
$currentUser = $currentUserPlugin->getUser();
|
13010 |
nelberth |
95 |
|
16798 |
efrain |
96 |
|
13010 |
nelberth |
97 |
$request = $this->getRequest();
|
|
|
98 |
if($request->isGet()) {
|
|
|
99 |
|
16798 |
efrain |
100 |
$jobDescriptionIdBoss = 0;
|
|
|
101 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
102 |
$jobsDescription = $this->recursiveLoadJobDescription($currentUser, $currentCompany, $jobDescriptionMapper, $jobDescriptionIdBoss);
|
|
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
106 |
$bossId = 0;
|
|
|
107 |
$organizationPositionMapper = OrganizationPositionMapper::getInstance($this->adapter);
|
|
|
108 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
109 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
$positions = $this->recursiveLoadPosition($currentUser, $currentCompany, $organizationPositionMapper, $userMapper, $jobDescriptionMapper, $bossId);
|
|
|
113 |
|
|
|
114 |
|
|
|
115 |
|
|
|
116 |
$form = new CommunicationForm();
|
13010 |
nelberth |
117 |
$this->layout()->setTemplate('layout/layout-backend');
|
|
|
118 |
$viewModel = new ViewModel();
|
16798 |
efrain |
119 |
$viewModel->setTemplate('leaders-linked/communication/index.phtml');
|
|
|
120 |
$viewModel->setVariables([
|
|
|
121 |
'form' => $form,
|
|
|
122 |
'companyName' => $currentCompany->name,
|
|
|
123 |
'jobsDescription' => $jobsDescription,
|
|
|
124 |
'positions' => $positions
|
|
|
125 |
]);
|
13010 |
nelberth |
126 |
return $viewModel ;
|
|
|
127 |
|
16798 |
efrain |
128 |
} else {
|
|
|
129 |
return new JsonModel([
|
|
|
130 |
'success' => false,
|
|
|
131 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
|
|
132 |
]);
|
|
|
133 |
}
|
|
|
134 |
}
|
|
|
135 |
|
|
|
136 |
/**
|
|
|
137 |
*
|
|
|
138 |
* @param User $currentUser
|
|
|
139 |
* @param Company $currentCompany
|
|
|
140 |
* @param JobDescriptionMapper $jobDescriptionMapper
|
|
|
141 |
* @param int $jobDescriptionIdBoss
|
|
|
142 |
* @return array
|
|
|
143 |
*/
|
|
|
144 |
private function recursiveLoadJobDescription($currentUser, $currentCompany, $jobDescriptionMapper, $jobDescriptionIdBoss)
|
|
|
145 |
{
|
|
|
146 |
$items = [];
|
|
|
147 |
$records = $jobDescriptionMapper->fetchAllByCompanyIdAndJobDescriptionIdBoss($currentCompany->id, $jobDescriptionIdBoss);
|
|
|
148 |
|
|
|
149 |
|
|
|
150 |
foreach($records as $record)
|
|
|
151 |
{
|
13010 |
nelberth |
152 |
|
16798 |
efrain |
153 |
|
|
|
154 |
|
|
|
155 |
array_push($items, [
|
|
|
156 |
'uuid' => $record->uuid,
|
|
|
157 |
'name' => $record->name,
|
|
|
158 |
'children' => $this->recursiveLoadJobDescription($currentUser, $currentCompany, $jobDescriptionMapper, $record->id),
|
|
|
159 |
]);
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
return $items;
|
|
|
163 |
}
|
|
|
164 |
|
|
|
165 |
/**
|
|
|
166 |
*
|
|
|
167 |
* @param User $currentUser
|
|
|
168 |
* @param Company $currentCompany
|
|
|
169 |
* @param OrganizationPositionMapper $organizationPositionMapper
|
|
|
170 |
* @param UserMapper $userMapper
|
|
|
171 |
* @param JobDescriptionMapper $jobDescriptionMapper
|
|
|
172 |
* @param int $bossId
|
|
|
173 |
* @return array
|
|
|
174 |
*/
|
|
|
175 |
private function recursiveLoadPosition($currentUser, $currentCompany, $organizationPositionMapper, $userMapper, $jobDescriptionMapper, $bossId)
|
|
|
176 |
{
|
|
|
177 |
$items = [];
|
|
|
178 |
$records = $organizationPositionMapper->fetchAllByCompanyIdAndBossId($currentCompany->id, $bossId);
|
|
|
179 |
|
|
|
180 |
|
|
|
181 |
foreach($records as $record)
|
|
|
182 |
{
|
|
|
183 |
|
|
|
184 |
$user = $userMapper->fetchOne($record->employee_id);
|
|
|
185 |
$jobDescription = $jobDescriptionMapper->fetchOne($record->job_description_id);
|
|
|
186 |
|
|
|
187 |
|
|
|
188 |
array_push($items, [
|
|
|
189 |
'uuid' => $record->uuid,
|
|
|
190 |
'name' => trim($user->first_name . ' ' . $user->last_name),
|
|
|
191 |
'title' => $jobDescription->name,
|
|
|
192 |
'children' => $this->recursiveLoadPosition($currentUser, $currentCompany, $organizationPositionMapper, $userMapper, $jobDescriptionMapper, $record->employee_id),
|
|
|
193 |
]);
|
|
|
194 |
}
|
|
|
195 |
|
|
|
196 |
return $items;
|
|
|
197 |
}
|
|
|
198 |
|
|
|
199 |
public function sendAction()
|
|
|
200 |
{
|
|
|
201 |
|
|
|
202 |
$request = $this->getRequest();
|
|
|
203 |
|
|
|
204 |
if($request->isPost()) {
|
|
|
205 |
|
|
|
206 |
|
|
|
207 |
$currentUserPlugin = $this->plugin('currentUserPlugin');
|
|
|
208 |
$currentUser = $currentUserPlugin->getUser();
|
|
|
209 |
$currentCompany = $currentUserPlugin->getCompany();
|
|
|
210 |
|
|
|
211 |
$data = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
|
|
|
212 |
|
|
|
213 |
$form = new CommunicationForm();
|
|
|
214 |
$form->setData($data);
|
|
|
215 |
|
|
|
216 |
if($form->isValid()) {
|
|
|
217 |
$organizationPositionMapper = OrganizationPositionMapper::getInstance($this->adapter);
|
|
|
218 |
$jobDescriptionMapper = JobDescriptionMapper::getInstance($this->adapter);
|
|
|
219 |
$companyUserMapper = CompanyUserMapper::getInstance($this->adapter);
|
|
|
220 |
$userMapper = UserMapper::getInstance($this->adapter);
|
|
|
221 |
|
|
|
222 |
$dataPost = (array) $form->getData();
|
|
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
$user_ids = [];
|
|
|
227 |
$message_text = $dataPost['message'];
|
|
|
228 |
|
|
|
229 |
$job_description_ids = $dataPost['job_description_id'];
|
|
|
230 |
$position_ids = $dataPost['position_id'];
|
|
|
231 |
|
|
|
232 |
|
|
|
233 |
$user_selected_ids = $dataPost['user_selected_id'];
|
|
|
234 |
if(!empty($user_selected_ids)) {
|
|
|
235 |
|
|
|
236 |
foreach($user_selected_ids as $uuid)
|
|
|
237 |
{
|
|
|
238 |
$user = $userMapper->fetchOneByUuid($uuid);
|
|
|
239 |
if(!in_array($user->id, $user_ids)) {
|
|
|
240 |
array_push($user_ids, $user->id);
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
|
|
|
244 |
}
|
|
|
245 |
}
|
|
|
246 |
|
|
|
247 |
if(!empty($job_description_ids)) {
|
|
|
248 |
foreach($job_description_ids as $uuid)
|
|
|
249 |
{
|
|
|
250 |
$jobDescription = $jobDescriptionMapper->fetchOneByUuid($uuid);
|
|
|
251 |
if(!$jobDescription || $jobDescription->company_id != $currentCompany->id) {
|
|
|
252 |
continue;
|
|
|
253 |
}
|
|
|
254 |
|
|
|
255 |
$records = $organizationPositionMapper->fetchAllByCompanyIdAndJobDescriptionId($jobDescription->company_id, $jobDescription->id);
|
|
|
256 |
if(!empty($records)) {
|
|
|
257 |
foreach($records as $record) {
|
|
|
258 |
if(!in_array($record->employee_id, $user_ids)) {
|
|
|
259 |
array_push($user_ids, $record->employee_id);
|
|
|
260 |
}
|
|
|
261 |
}
|
|
|
262 |
}
|
|
|
263 |
}
|
|
|
264 |
}
|
|
|
265 |
|
|
|
266 |
if(!empty($position_ids)) {
|
|
|
267 |
foreach($position_ids as $uuid)
|
|
|
268 |
{
|
|
|
269 |
$organizationPosition = $organizationPositionMapper->fetchOneByUuid($uuid);
|
|
|
270 |
if(!$organizationPosition || $organizationPosition->company_id != $currentCompany->id) {
|
|
|
271 |
if(!in_array($organizationPosition->employee_id, $user_ids)) {
|
|
|
272 |
array_push($user_ids, $organizationPosition->employee_id);
|
|
|
273 |
}
|
|
|
274 |
}
|
|
|
275 |
}
|
|
|
276 |
}
|
|
|
277 |
|
16800 |
efrain |
278 |
$owner = $companyUserMapper->fetchOwnerByCompanyId($currentCompany->id);
|
|
|
279 |
|
|
|
280 |
|
16798 |
efrain |
281 |
$records = $companyUserMapper->fetchAllActivesByCompanyIdAndUserIds($currentCompany->id, $user_ids);
|
|
|
282 |
|
|
|
283 |
if(empty($records)) {
|
|
|
284 |
return new JsonModel([
|
|
|
285 |
'success' => false,
|
|
|
286 |
'data' => 'ERROR_MESSAGE_NOT_FOUND_TARGET_ACTIVES'
|
|
|
287 |
]);
|
|
|
288 |
}
|
|
|
289 |
|
|
|
290 |
$message_tmp_filename = '';
|
|
|
291 |
$message_filename = '';
|
|
|
292 |
|
|
|
293 |
$type = Message::TYPE_TEXT;
|
|
|
294 |
|
|
|
295 |
$files = $this->getRequest()->getFiles()->toArray();
|
|
|
296 |
if(isset($files['file']) && empty($files['file']['error'])) {
|
|
|
297 |
$message_tmp_filename = $files['file']['tmp_name'];
|
17018 |
efrain |
298 |
$message_filename = \LeadersLinked\Library\Functions::normalizeStringFilename($files['file']['name']);
|
16798 |
efrain |
299 |
|
|
|
300 |
$mime_type = mime_content_type($message_tmp_filename);
|
|
|
301 |
|
|
|
302 |
|
|
|
303 |
if($mime_type == 'image/jpg' || $mime_type == 'image/jpeg' || $mime_type == 'image/png') {
|
|
|
304 |
$type = Message::TYPE_IMAGE;
|
16822 |
efrain |
305 |
} else if($mime_type == 'video/quicktime' || $mime_type == 'video/webm' || $mime_type == 'video/mpeg' || $mime_type == 'video/mpg' || $mime_type == 'video/mp4') {
|
16798 |
efrain |
306 |
$type = Message::TYPE_VIDEO;
|
|
|
307 |
} else if($mime_type == 'application/pdf') {
|
|
|
308 |
$type = Message::TYPE_DOCUMENT;
|
|
|
309 |
}
|
|
|
310 |
}
|
|
|
311 |
|
|
|
312 |
|
|
|
313 |
$message_sent = 0;
|
|
|
314 |
$conversationMapper = ConversationMapper::getInstance($this->adapter);
|
|
|
315 |
|
|
|
316 |
foreach($records as $record)
|
|
|
317 |
{
|
|
|
318 |
|
|
|
319 |
$conversation = $conversationMapper->fetchOneByUserId1AndUserId2($owner->user_id, $record->user_id);
|
16800 |
efrain |
320 |
|
|
|
321 |
|
16798 |
efrain |
322 |
if($conversation) {
|
|
|
323 |
if($conversation->sender_id == $owner->id) {
|
|
|
324 |
$conversation->receiver_status = Conversation::STATUS_NORMAL;
|
|
|
325 |
$conversation->sender_status = $conversation->sender_status == Conversation::STATUS_DELETED ? Conversation::STATUS_DELETED : Conversation::STATUS_NORMAL;
|
|
|
326 |
} else {
|
|
|
327 |
$conversation->receiver_status = $conversation->receiver_status == Conversation::STATUS_DELETED ? Conversation::STATUS_DELETED : Conversation::STATUS_NORMAL;
|
|
|
328 |
$conversation->sender_status = Conversation::STATUS_NORMAL;
|
|
|
329 |
}
|
|
|
330 |
|
|
|
331 |
if(!$conversationMapper->update($conversation)) {
|
|
|
332 |
return new JsonModel([
|
|
|
333 |
'success' => false,
|
|
|
334 |
'data' => $conversationMapper->getError()
|
|
|
335 |
]);
|
|
|
336 |
}
|
|
|
337 |
} else {
|
|
|
338 |
$conversation = new Conversation();
|
16800 |
efrain |
339 |
$conversation->sender_id = $owner->user_id;
|
16798 |
efrain |
340 |
$conversation->sender_status = Conversation::STATUS_DELETED;
|
|
|
341 |
|
|
|
342 |
$conversation->receiver_id = $record->user_id;
|
|
|
343 |
$conversation->receiver_status = Conversation::STATUS_NORMAL;
|
16801 |
efrain |
344 |
|
16798 |
efrain |
345 |
if(!$conversationMapper->insert($conversation)) {
|
|
|
346 |
continue;
|
|
|
347 |
}
|
|
|
348 |
}
|
|
|
349 |
|
|
|
350 |
$message = new Message();
|
|
|
351 |
$message->conversation_id = $conversation->id;
|
|
|
352 |
$message->read = Message::NO;
|
|
|
353 |
$message->message = $message_text;
|
|
|
354 |
$message->receiver_id = $record->user_id;
|
|
|
355 |
$message->receiver_status = Message::STATUS_NORMAL;
|
|
|
356 |
$message->sender_id = $owner->user_id;
|
|
|
357 |
$message->sender_status = Message::STATUS_NORMAL;
|
|
|
358 |
$message->type = $type;
|
|
|
359 |
|
|
|
360 |
|
|
|
361 |
$messageMapper = MessageMapper::getInstance($this->adapter);
|
|
|
362 |
if($messageMapper->insert($message)) {
|
|
|
363 |
$message_sent++;
|
|
|
364 |
$message = $messageMapper->fetchOne($message->id);
|
|
|
365 |
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
if( $type == Message::TYPE_DOCUMENT) {
|
|
|
369 |
try {
|
|
|
370 |
$target_path = $this->config['leaderslinked.fullpath.message'] . $message->uuid;
|
|
|
371 |
if(!file_exists($target_path)) {
|
|
|
372 |
mkdir($target_path, 0755, true);
|
|
|
373 |
}
|
|
|
374 |
|
|
|
375 |
$full_filename = $target_path . DIRECTORY_SEPARATOR .$message_filename;
|
|
|
376 |
$result = @copy($message_tmp_filename, $full_filename);
|
|
|
377 |
if ($result) {
|
|
|
378 |
|
|
|
379 |
$message->type = $type;
|
|
|
380 |
$message->filename = basename($message_filename);
|
|
|
381 |
$messageMapper->update($message);
|
|
|
382 |
}
|
|
|
383 |
} catch(\Throwable $e) {
|
|
|
384 |
error_log($e->getTraceAsString());
|
|
|
385 |
}
|
|
|
386 |
}
|
|
|
387 |
if( $type == Message::TYPE_IMAGE) {
|
|
|
388 |
try {
|
|
|
389 |
|
17002 |
efrain |
390 |
|
16798 |
efrain |
391 |
list($target_width, $target_height) = explode('x', $this->config['leaderslinked.image_sizes.message_image_size']);
|
|
|
392 |
|
|
|
393 |
$message_filename = substr($message_filename, 0, strrpos($message_filename, '.')) . '.png';
|
|
|
394 |
$crop_to_dimensions = false;
|
17002 |
efrain |
395 |
|
|
|
396 |
$image = Image::getInstance($this->config);
|
17018 |
efrain |
397 |
$storage = \LeadersLinked\Library\Storage::getInstance($this->config, $this->adapter);
|
17002 |
efrain |
398 |
|
17018 |
efrain |
399 |
$target_path = $storage ->getPathMessage();
|
|
|
400 |
|
17002 |
efrain |
401 |
|
17018 |
efrain |
402 |
$full_tmp_filename = $image->uploadProcessChangeSize($message_tmp_filename, $message_filename, $target_width, $target_height, $crop_to_dimensions);
|
|
|
403 |
|
|
|
404 |
if($full_tmp_filename) {
|
|
|
405 |
if($storage->putFile($target_path, $message->uuid, $full_tmp_filename)) {
|
|
|
406 |
$message->type = $type;
|
|
|
407 |
$message->filename = basename($message_filename);
|
|
|
408 |
$messageMapper->update($message);
|
|
|
409 |
}
|
16798 |
efrain |
410 |
}
|
17018 |
efrain |
411 |
|
|
|
412 |
$full_tmp_filename = $image->uploadProcessChangeSize($message_tmp_filename, $message_filename, $target_width, $target_height, $crop_to_dimensions);
|
|
|
413 |
|
|
|
414 |
|
16798 |
efrain |
415 |
} catch(\Throwable $e) {
|
|
|
416 |
error_log($e->getTraceAsString());
|
|
|
417 |
}
|
|
|
418 |
}
|
|
|
419 |
if( $type == Message::TYPE_VIDEO) {
|
|
|
420 |
try {
|
|
|
421 |
$target_path = $this->config['leaderslinked.fullpath.message'] . $message->uuid;
|
|
|
422 |
if(!file_exists($target_path)) {
|
|
|
423 |
mkdir($target_path, 0755, true);
|
|
|
424 |
}
|
|
|
425 |
|
|
|
426 |
$full_filename = $target_path . DIRECTORY_SEPARATOR . $message_filename;
|
|
|
427 |
$result = @copy($message_tmp_filename, $full_filename);
|
|
|
428 |
if ($result) {
|
|
|
429 |
|
|
|
430 |
$size = $this->config['leaderslinked.image_sizes.message_image_size'];
|
|
|
431 |
$getFromSecound = 2;
|
|
|
432 |
|
|
|
433 |
//extracción del cover
|
|
|
434 |
$generateFileName = substr($message_filename, 0, strrpos($message_filename, '.'));
|
|
|
435 |
$generateFile = $target_path . DIRECTORY_SEPARATOR . $generateFileName . '.png';
|
|
|
436 |
$cmd = "/usr/bin/ffmpeg -i $full_filename -an -ss $getFromSecound -s $size $generateFile";
|
|
|
437 |
exec($cmd);
|
|
|
438 |
|
|
|
439 |
|
|
|
440 |
$message->type = $type;
|
|
|
441 |
$message->filename = basename($message_filename);
|
|
|
442 |
$message->image_preview = basename($generateFile);
|
|
|
443 |
$messageMapper->update($message);
|
|
|
444 |
|
|
|
445 |
$videoConvert = new VideoConvert();
|
|
|
446 |
$videoConvert->filename = $full_filename;
|
17002 |
efrain |
447 |
$videoConvert->type = VideoConvert::TYPE_COMMUNICATION;
|
16798 |
efrain |
448 |
|
|
|
449 |
$videoConvertMapper = VideoConvertMapper::getInstance($this->adapter);
|
|
|
450 |
$videoConvertMapper->insert($videoConvert);
|
|
|
451 |
}
|
|
|
452 |
} catch(\Throwable $e) {
|
|
|
453 |
error_log($e->getTraceAsString());
|
|
|
454 |
}
|
|
|
455 |
}
|
|
|
456 |
} else {
|
|
|
457 |
return new JsonModel([
|
|
|
458 |
'success' => false,
|
|
|
459 |
'data' => $messageMapper->getError()
|
|
|
460 |
]);
|
|
|
461 |
}
|
|
|
462 |
}
|
|
|
463 |
|
|
|
464 |
if(1 == $message_sent) {
|
|
|
465 |
return new JsonModel([
|
|
|
466 |
'success' => true,
|
|
|
467 |
'data' => 'LABEL_MESSAGE_ONE_SENT'
|
|
|
468 |
]);
|
|
|
469 |
} else {
|
|
|
470 |
$message = strval($message_sent) . 'LABEL_MESSAGE_TWO_OR_MORE_SENT';
|
|
|
471 |
return new JsonModel([
|
|
|
472 |
'success' => true,
|
|
|
473 |
'data' => $message
|
|
|
474 |
]);
|
|
|
475 |
}
|
|
|
476 |
|
|
|
477 |
|
|
|
478 |
} else {
|
|
|
479 |
|
|
|
480 |
|
|
|
481 |
$messages = [];
|
|
|
482 |
$form_messages = (array) $form->getMessages();
|
|
|
483 |
foreach($form_messages as $fieldname => $field_messages)
|
|
|
484 |
{
|
|
|
485 |
$messages[$fieldname] = array_values($field_messages);
|
|
|
486 |
}
|
|
|
487 |
|
|
|
488 |
return new JsonModel([
|
|
|
489 |
'success' => false,
|
|
|
490 |
'data' => $messages
|
|
|
491 |
]);
|
|
|
492 |
}
|
|
|
493 |
|
|
|
494 |
|
|
|
495 |
|
13010 |
nelberth |
496 |
} else {
|
|
|
497 |
return new JsonModel([
|
|
|
498 |
'success' => false,
|
|
|
499 |
'data' => 'ERROR_METHOD_NOT_ALLOWED'
|
16798 |
efrain |
500 |
]);
|
13010 |
nelberth |
501 |
}
|
16798 |
efrain |
502 |
|
13010 |
nelberth |
503 |
}
|
16798 |
efrain |
504 |
|
|
|
505 |
|
17018 |
efrain |
506 |
|
13010 |
nelberth |
507 |
}
|