Skip to content

Commit

Permalink
GH-126 Normalizer should allow max length customizations
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Sep 23, 2020
1 parent 8bd1ea2 commit 581e4cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,13 @@
$MsgBox = [];

if (isset($_POST['send_msg'])) {
$handleSendMessage = function () use ($_User, $_Lang, $_EnginePath, &$parse, &$MsgBox) {
$handleSendMessage = function () use ($_User, $_Lang, $_EnginePath, &$parse, &$MsgBox, $_MaxLength_Subject, $_MaxLength_Text) {
$formDataNormalizationResult = Messages\Utils\normalizeFormData(
$_POST,
[
'senderUser' => &$_User,
'subjectMaxLength' => $_MaxLength_Subject,
'contentMaxLength' => $_MaxLength_Text,
]
);

Expand Down
6 changes: 4 additions & 2 deletions modules/messages/utils/normalizeFormData.utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* @param string $input['text']
* @param array $params
* @param &array $params['senderUser']
* @param number $params['subjectMaxLength']
* @param number $params['contentMaxLength']
*/
function normalizeFormData($input, $params) {
$senderUser = &$params['senderUser'];
Expand Down Expand Up @@ -155,13 +157,13 @@ function normalizeFormData($input, $params) {
if (empty($formData['message']['subject'])) {
$formData['message']['subject'] = $normalizeUserContent(
$input['subject'],
[ 'maxLength' => 100, ]
[ 'maxLength' => $params['subjectMaxLength'], ]
);
}

$formData['message']['content'] = $normalizeUserContent(
$input['text'],
[ 'maxLength' => 5000, ]
[ 'maxLength' => $params['contentMaxLength'], ]
);

$hasNormalizationErrors = (
Expand Down

0 comments on commit 581e4cc

Please sign in to comment.