Línea 378... |
Línea 378... |
378 |
}
|
378 |
}
|
Línea 379... |
Línea 379... |
379 |
|
379 |
|
Línea -... |
Línea 380... |
- |
|
380 |
|
- |
|
381 |
$this->logger->info('Se agrego la pregunta ' . $myCoachQuestion->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
- |
|
382 |
|
- |
|
383 |
// Obtener datos adicionales para formato consistente con questionsAction
|
- |
|
384 |
$userMapper = UserMapper::getInstance($this->adapter);
|
- |
|
385 |
$user = $userMapper->fetchOne($currentUser->id);
|
- |
|
386 |
|
- |
|
387 |
$contentReactionMapper = ContentReactionMapper::getInstance($this->adapter);
|
- |
|
388 |
$commentMapper = CommentMapper::getInstance($this->adapter);
|
- |
|
389 |
$myCoachAnswerMapper = MyCoachAnswerMapper::getInstance($this->adapter);
|
- |
|
390 |
$myCoachQuestionViewMapper = MyCoachQuestionViewMapper::getInstance($this->adapter);
|
- |
|
391 |
|
- |
|
392 |
$storage = Storage::getInstance($this->config, $this->adapter);
|
- |
|
393 |
|
- |
|
394 |
// Obtener categorías de la pregunta
|
- |
|
395 |
$bags_categories = [];
|
- |
|
396 |
if(is_array($category_ids)) {
|
- |
|
397 |
foreach($category_ids as $category_id) {
|
- |
|
398 |
$category = $myCoachCategoryMapper->fetchOneByUuid($category_id);
|
- |
|
399 |
if($category) {
|
- |
|
400 |
array_push($bags_categories, $category->name);
|
- |
|
401 |
}
|
- |
|
402 |
}
|
- |
|
403 |
} else {
|
- |
|
404 |
$category = $myCoachCategoryMapper->fetchOneByUuid($category_ids);
|
- |
|
405 |
if($category) {
|
- |
|
406 |
array_push($bags_categories, $category->name);
|
- |
|
407 |
}
|
- |
|
408 |
}
|
- |
|
409 |
|
- |
|
410 |
// Formatear descripción (limitar a 250 caracteres)
|
- |
|
411 |
$description = strip_tags($myCoachQuestion->description);
|
- |
|
412 |
if (strlen($description) > 250) {
|
- |
|
413 |
$description = substr($description, 0, 250) . '...';
|
- |
|
414 |
}
|
- |
|
415 |
|
- |
|
416 |
// Formatear fechas
|
- |
|
417 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $myCoachQuestion->added_on);
|
- |
|
418 |
$added_on = $dt->format('d/m/Y H:i a');
|
- |
|
419 |
|
- |
|
420 |
$dt = \DateTime::createFromFormat('Y-m-d H:i:s', $myCoachQuestion->updated_on);
|
- |
|
421 |
$updated_on = $dt->format('d/m/Y H:i a');
|
- |
|
422 |
|
- |
|
423 |
// Verificar permisos
|
- |
|
424 |
$myCoachAccessControl = MyCoachAccessControl::getInstance($this->adapter);
|
- |
|
425 |
$message_error = '';
|
- |
|
426 |
$allowEdit = $myCoachAccessControl->hasAccessEditQuestion($currentUser->id, $myCoachQuestion->id, $currentNetwork->id, $message_error);
|
- |
|
427 |
$allowDelete = $myCoachAccessControl->hasAccessDeleteQuestion($currentUser->id, $myCoachQuestion->id, $currentNetwork->id, $message_error);
|
- |
|
428 |
|
- |
|
429 |
$questionData = [
|
- |
|
430 |
'uuid' => $myCoachQuestion->uuid,
|
- |
|
431 |
'user_name' => trim($user->first_name . ' ' . $user->last_name),
|
- |
|
432 |
'user_image' => $storage->getUserImage($user),
|
- |
|
433 |
'title' => $myCoachQuestion->title,
|
- |
|
434 |
'description' => $description,
|
- |
|
435 |
'categories' => $bags_categories,
|
- |
|
436 |
'views' => 0, // Nueva pregunta, sin vistas aún
|
- |
|
437 |
'answers' => 0, // Nueva pregunta, sin respuestas aún
|
- |
|
438 |
'reactions' => 0, // Nueva pregunta, sin reacciones aún
|
- |
|
439 |
'comments' => 0, // Nueva pregunta, sin comentarios aún
|
- |
|
440 |
'added_on' => $added_on,
|
- |
|
441 |
'updated_on' => $updated_on,
|
- |
|
442 |
'link_add_comment' => $this->url()->fromRoute('my-coach/questions/comments/add', ['id' => $myCoachQuestion->uuid],['force_canonical' => true]),
|
- |
|
443 |
'link_view' => $this->url()->fromRoute('my-coach/questions/view', ['id' => $myCoachQuestion->uuid]),
|
- |
|
444 |
'link_edit' => $allowEdit ? $this->url()->fromRoute('my-coach/questions/edit', ['id' => $myCoachQuestion->uuid],['force_canonical' => true]) : '',
|
- |
|
445 |
'link_delete' => $allowDelete ? $this->url()->fromRoute('my-coach/questions/delete', ['id' => $myCoachQuestion->uuid],['force_canonical' => true]) : '',
|
380 |
|
446 |
'link_reactions' => $this->url()->fromRoute('my-coach/questions/reactions', ['id' => $myCoachQuestion->uuid],['force_canonical' => true])
|
381 |
$this->logger->info('Se agrego la pregunta ' . $myCoachQuestion->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
|
447 |
];
|
- |
|
448 |
|
- |
|
449 |
$data = [
|
382 |
|
450 |
'success' => true,
|
- |
|
451 |
'data' => [
|
383 |
$data = [
|
452 |
'question' => $questionData,
|
384 |
'success' => true,
|
453 |
'message' => 'LABEL_RECORD_ADDED'
|
385 |
'data' => 'LABEL_RECORD_ADDED'
|
454 |
]
|
386 |
];
|
455 |
];
|
387 |
} else {
|
456 |
} else {
|