Fulfill help path and mail check

This commit is contained in:
fbsanchez 2019-11-07 19:39:50 +01:00
parent 424aa10555
commit 4905b18888
3 changed files with 114 additions and 7 deletions

View File

@ -105,6 +105,11 @@ class HelpFeedBack extends Wizard
<?php
}
$hidden = '<input type="hidden" value="'.$help_url.'" ';
$hidden .= ' form="feedback_form" name="help_url" />';
echo $hidden;
echo '<div class="help_feedback">';
// Load feedback form.
echo $this->loadFeedbackForm();
@ -178,7 +183,8 @@ class HelpFeedBack extends Wizard
'name' => 'feedback_email',
'input_class' => 'email_feedback',
'class' => 'email_feedback',
'type' => 'text',
'type' => 'email',
'required' => true,
],
],
[
@ -232,11 +238,19 @@ class HelpFeedBack extends Wizard
$suggestion = get_parameter('type', 'false');
$feedback_text = get_parameter('feedback_text', null);
$feedback_mail = get_parameter('feedback_email', null);
$help_url = get_parameter('help_url', 'unknown');
$section = explode('title=', $help_url, 2);
$subject = '';
if (is_array($section) === true && isset($section[1]) === true) {
$subject = '['.$section[1].']';
}
if ($suggestion !== 'false') {
$subject = __('[pandorafms wiki] New suggestion');
$subject .= __('[pandorafms wiki] New suggestion');
} else {
$subject = __('[pandorafms wiki] New report');
$subject .= __('[pandorafms wiki] New report');
}
if (empty($feedback_mail) === true) {
@ -271,14 +285,17 @@ class HelpFeedBack extends Wizard
$uid = 'not registered';
}
$body = '<b>User mail</b> '.$feedback_mail.'<br />';
$body .= '<b>console</b> <i>'.$uid.'</i>';
$body = '<ul><li><b>User mail</b> '.$feedback_mail.'</li>';
$body .= '<li><b>Console</b> <i>'.$uid.'</i></li>';
$body .= '<li><b>URL</b> '.$help_url.'</li></ul>';
$body .= '<h2>Message</h2>';
$body .= '<p>'.$feedback_text.'</p>';
$res = enterprise_hook(
'send_email_attachment',
[
'feedback@artica.es',
// 'feedback@artica.es',
'fborja.sanchez@artica.es',
$body,
$subject,
]
@ -323,7 +340,8 @@ class HelpFeedBack extends Wizard
method: 'sendMailMethod',
type: $('#suggestion').prop('checked'),
feedback_text: $("textarea[name=feedback_text]").val(),
feedback_email: $("input[name=feedback_email]").val()
feedback_email: $("input[name=feedback_email]").val(),
help_url: $("input[name=help_url]").val(),
},
success: function (data) {
var title;

View File

@ -1535,6 +1535,89 @@ function html_print_input_text($name, $value, $alt='', $size=50, $maxlength=255,
}
/**
* Render an input email element.
*
* @param array $settings Array with attributes input.
* only name is necessary.
*
* @return string Html input.
*/
function html_print_input_email(array $settings):string
{
// TODO: const.
$valid_attrs = [
'accept',
'disabled',
'maxlength',
'name',
'readonly',
'placeholder',
'size',
'value',
'accesskey',
'class',
'dir',
'id',
'lang',
'style',
'tabindex',
'title',
'xml:lang',
'onfocus',
'onblur',
'onselect',
'onchange',
'onclick',
'ondblclick',
'onmousedown',
'onmouseup',
'onmouseover',
'onmousemove',
'onmouseout',
'onkeypress',
'onkeydown',
'onkeyup',
'required',
'pattern',
'autocomplete',
];
$output = '';
if (isset($settings) === true && is_array($settings) === true) {
// Check Name is necessary.
if (isset($settings['name']) === true) {
$output = '<input type="email" ';
// Check Max length.
if (isset($settings['maxlength']) === false) {
$settings['maxlength'] = 255;
}
// Check Size.
if (isset($settings['size']) === false
|| $settings['size'] === 0
) {
$settings['size'] = 255;
}
foreach ($settings as $attribute => $attr_value) {
// Check valid attribute.
if (in_array($attribute, $valid_attrs) === false) {
continue;
}
$output .= $attribute.'="'.$attr_value.'" ';
}
$output .= $function.'/>';
}
}
return $output;
}
/**
* Render an input image element.
*
@ -3397,6 +3480,11 @@ function html_print_input($data, $wrapper='div', $input_only=false)
((isset($data['message']) === true) ? $data['message'] : 'visualmodal'),
((isset($data['id']) === true) ? $data['id'] : null)
);
break;
case 'email':
$output .= html_print_input_email($data);
break;
default:
// Ignore.

View File

@ -206,6 +206,7 @@ label {
li > input[type="text"],
li > input[type="password"],
li > input[type="email"],
.discovery_text_input > input[type="password"],
.discovery_text_input > input[type="text"],
#interval_manual > input[type="text"] {