| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/dansnotreville-fr/nice/components/com_rsfeedback/controllers/ |
Upload File : |
<?php
/**
* @package RSFeedback!
* @copyright (C) 2010-2018 www.rsjoomla.com
* @license GPL, http://www.gnu.org/licenses/gpl.html
*/
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Mail\MailHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Factory;
class RSFeedbackControllerComment extends FormController
{
protected function allowAdd($data = array()) {
$feedback = BaseDatabaseModel::getInstance('Feedback', 'RSFeedbackModel')->getItem(Factory::getApplication()->input->get('feedback_id', 0, 'int'));
$statuses = RSFeedbackHelper::getStatuses();
$permissions = RSFeedbackHelper::getPermissions();
$allow_commenting = $statuses[$feedback->status_id]->permissions->allow_commenting && (bool) $permissions['feedback_comment'];
return $allow_commenting;
}
/**
* Get the return URL.
*
* If a "return" variable has been passed in the request
*
* @return string The return URL.
* @since 1.6
*/
protected function getReturnPage() {
$return = Factory::getApplication()->input->getBase64('return', null);
if (empty($return) || !Uri::isInternal(base64_decode($return))) {
$url = Uri::base();
}
else {
$url = base64_decode($return);
}
return $url;
}
/**
* Method to save a record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
*
* @return Boolean True if successful, false otherwise.
* @since 1.6
*/
public function save($key = null, $urlVar = 'id') {
$app = Factory::getApplication();
$input = $app->input;
$data = $input->get('jform', array(), 'array');
$context = "$this->option.edit.$this->context";
$model = $this->getModel('comment');
$permissions = RSFeedbackHelper::getPermissions();
$errors = array();
$feedback_model = BaseDatabaseModel::getInstance('Feedback', 'RSFeedbackModel');
$feedback = $feedback_model->getItem($input->get('feedback_id'));
$statuses = RSFeedbackHelper::getStatuses();
$session = Factory::getSession();
$allow_commenting = $statuses[$feedback->status_id]->permissions->allow_commenting && (bool)$permissions['feedback_comment'];
$valid = true;
$comment_name = $data['name'];
$comment_email = $data['email'];
$comment_text = $data['text'];
$comment_consent = (isset($data['consent'][0])) ? (bool) $data['consent'][0] : false;
$data['date'] = Factory::getDate()->toSql();
$data['feedback_id'] = $input->get('feedback_id', 0, 'int');
if (!$data['feedback_id']) {
$valid = false;
$errors[] = Text::_('COM_RSFEEDBACK_FEEDBACK_NOT_FOUND');
}
if (!$allow_commenting) {
$valid = false;
$errors[] = Text::_('COM_RSFEEDBACK_COMMENTS_DISABLED_DESC');
}
if (!$comment_name) {
$valid = false;
$errors[] = Text::_('COM_RSFEEDBACK_NO_NAME');
}
if (!MailHelper::isEmailAddress($comment_email)) {
$valid = false;
$errors[] = Text::_('COM_RSFEEDBACK_NO_INVALID_EMAIL');
}
if (!$comment_text) {
$valid = false;
$errors[] = Text::_('COM_RSFEEDBACK_NO_TEXT');
}
$valid_captcha = true;
if ($permissions['captcha_comment']) {
$controller = new RSFeedbackController();
$input->set('permission', 'captcha_comment', 'string');
$valid_captcha = $controller->checkCaptcha();
}
if (!$valid_captcha) {
$valid = false;
$errors[] = Text::_('COM_RSFEEDBACK_INVALID_CAPTCHA');
}
if (!$comment_consent) {
$valid = false;
$errors[] = Text::_('COM_RSFEEDBACK_FEEDBACK_CONSENT_NEEDED_ERROR');
}
$session->set('com_rsfeedback.commentform.errors', $errors);
if ($valid) {
if ($model->save($data)) {
$session->set('com_rsfeedback.commentform.success', Text::_('COM_RSFEEDBACK_COMMENT_SAVE_SUCCESS'));
$app->setUserState($context . '.data', null);
}
} else {
$app->setUserState($context . '.data', $data);
}
$this->setRedirect($this->getReturnPage());
}
}