// validator on message field

This commit is contained in:
Rémi Gaillard
2013-11-04 14:21:42 +01:00
parent b8b7fbaf71
commit bf8cd29868
2 changed files with 12 additions and 8 deletions
@@ -320,12 +320,15 @@ class AdminCustomerThreadsControllerCore extends AdminController
$cm = new CustomerMessage(); $cm = new CustomerMessage();
$cm->id_employee = (int)$this->context->employee->id; $cm->id_employee = (int)$this->context->employee->id;
$cm->id_customer_thread = (int)Tools::getValue('id_customer_thread'); $cm->id_customer_thread = (int)Tools::getValue('id_customer_thread');
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']); $cm->ip_address = ip2long(Tools::getRemoteAddr());
$current_employee = $this->context->employee; $current_employee = $this->context->employee;
$id_employee = (int)Tools::getValue('id_employee_forward'); $id_employee = (int)Tools::getValue('id_employee_forward');
$employee = new Employee($id_employee); $employee = new Employee($id_employee);
$email = Tools::getValue('email'); $email = Tools::getValue('email');
if ($id_employee && $employee && Validate::isLoadedObject($employee)) $message = Tools::getValue('message_forward');
if (($error = $cm->validateField('message', $message, null, array(), true)) !== true)
$this->errors[] = $error;
elseif ($id_employee && $employee && Validate::isLoadedObject($employee))
{ {
$params = array( $params = array(
'{messages}' => Tools::nl2br(stripslashes($output)), '{messages}' => Tools::nl2br(stripslashes($output)),
@@ -344,7 +347,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
null, null, _PS_MAIL_DIR_, true)) null, null, _PS_MAIL_DIR_, true))
{ {
$cm->private = 1; $cm->private = 1;
$cm->message = $this->l('Message forwarded to').' '.$employee->firstname.' '.$employee->lastname."\n".$this->l('Comment:').' '.$_POST['message_forward']; $cm->message = $this->l('Message forwarded to').' '.$employee->firstname.' '.$employee->lastname."\n".$this->l('Comment:').' '.$message;
$cm->add(); $cm->add();
} }
} }
@@ -363,7 +366,7 @@ class AdminCustomerThreadsControllerCore extends AdminController
$current_employee->email, $current_employee->firstname.' '.$current_employee->lastname, $current_employee->email, $current_employee->firstname.' '.$current_employee->lastname,
null, null, _PS_MAIL_DIR_, true)) null, null, _PS_MAIL_DIR_, true))
{ {
$cm->message = $this->l('Message forwarded to').' '.$email."\n".$this->l('Comment:').' '.$_POST['message_forward']; $cm->message = $this->l('Message forwarded to').' '.$email."\n".$this->l('Comment:').' '.$message;
$cm->add(); $cm->add();
} }
} }
@@ -379,10 +382,11 @@ class AdminCustomerThreadsControllerCore extends AdminController
$cm = new CustomerMessage(); $cm = new CustomerMessage();
$cm->id_employee = (int)$this->context->employee->id; $cm->id_employee = (int)$this->context->employee->id;
$cm->id_customer_thread = $ct->id; $cm->id_customer_thread = $ct->id;
$cm->ip_address = ip2long(Tools::getRemoteAddr());
$cm->message = Tools::getValue('reply_message'); $cm->message = Tools::getValue('reply_message');
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']); if (($error = $cm->validateField('message', $cm->message, null, array(), true)) !== true)
if (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0) $this->errors[] = $error;
elseif (isset($_FILES) && !empty($_FILES['joinFile']['name']) && $_FILES['joinFile']['error'] != 0)
$this->errors[] = Tools::displayError('An error occurred during the file upload process.'); $this->errors[] = Tools::displayError('An error occurred during the file upload process.');
elseif ($cm->add()) elseif ($cm->add())
{ {
+1 -1
View File
@@ -147,7 +147,7 @@ class ContactControllerCore extends FrontController
$cm->message = $message; $cm->message = $message;
if (isset($fileAttachment['rename']) && !empty($fileAttachment['rename']) && rename($fileAttachment['tmp_name'], _PS_MODULE_DIR_.'../upload/'.basename($fileAttachment['rename']))) if (isset($fileAttachment['rename']) && !empty($fileAttachment['rename']) && rename($fileAttachment['tmp_name'], _PS_MODULE_DIR_.'../upload/'.basename($fileAttachment['rename'])))
$cm->file_name = $fileAttachment['rename']; $cm->file_name = $fileAttachment['rename'];
$cm->ip_address = ip2long($_SERVER['REMOTE_ADDR']); $cm->ip_address = ip2long(Tools::getRemoteAddr());
$cm->user_agent = $_SERVER['HTTP_USER_AGENT']; $cm->user_agent = $_SERVER['HTTP_USER_AGENT'];
if (!$cm->add()) if (!$cm->add())
$this->errors[] = Tools::displayError('An error occurred while sending the message.'); $this->errors[] = Tools::displayError('An error occurred while sending the message.');