/** * @param array $formData * @param array $comment * @param int $commentId * @param int $moduleId * * @return \Symfony\Component\HttpFoundation\RedirectResponse */ protected function executePost(array $formData, array $comment, $commentId, $moduleId) { return $this->actionHelper->handleEditPostAction(function () use($formData, $comment, $commentId) { $this->adminFormValidation->validate($formData); $updateValues = ['message' => $formData['message']]; if ((empty($comment['user_id']) || $this->validator->is(IntegerValidationRule::class, $comment['user_id']) === false) && !empty($formData['name'])) { $updateValues['name'] = $formData['name']; } return $this->commentsModel->save($updateValues, $commentId); }, 'acp/comments/details/index/id_' . $moduleId); }
/** * @param int $id * @param string $action * * @return array|\Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse * @throws \ACP3\Core\Controller\Exception\ResultNotExistsException */ public function execute($id, $action = '') { return $this->actionHelper->handleCustomDeleteAction($action, function (array $items) use($id) { $result = $this->commentsModel->delete($items); // If there are no comments for the given module, redirect to the general comments admin panel page if ($this->commentRepository->countAll($id) == 0) { $redirectUrl = 'acp/comments'; } else { $redirectUrl = 'acp/comments/details/index/id_' . $id; } return $this->redirectMessages()->setMessage($result, $this->translator->t('system', $result !== false ? 'delete_success' : 'delete_error'), $redirectUrl); }, 'acp/comments/details/delete/id_' . $id, 'acp/comments/details/index/id_' . $id); }
/** * @param array $formData * @param string $module * @param int $entryId * @param string $redirectUrl * @return \Symfony\Component\HttpFoundation\RedirectResponse */ protected function executePost(array $formData, $module, $entryId, $redirectUrl) { return $this->actionHelper->handlePostAction(function () use($formData, $module, $entryId, $redirectUrl) { $ipAddress = $this->request->getSymfonyRequest()->getClientIp(); $this->formValidation->setIpAddress($ipAddress)->validate($formData); $formData['date'] = 'now'; $formData['ip'] = $ipAddress; $formData['user_id'] = $this->user->isAuthenticated() === true ? $this->user->getUserId() : null; $formData['module_id'] = $this->modules->getModuleId($module); $formData['entry_id'] = $entryId; $bool = $this->commentsModel->save($formData); return $this->redirectMessages()->setMessage($bool, $this->translator->t('system', $bool !== false ? 'create_success' : 'create_error'), base64_decode(urldecode($redirectUrl))); }); }