NEW Add hidden option MAIN_MAILFORM_DISABLE_ENTERKEY to disable the key

enter into the form to send email.
This commit is contained in:
Laurent Destailleur 2015-06-04 12:57:49 +02:00
parent 331ebbdd73
commit fa01dc200d
4 changed files with 78 additions and 30 deletions

View File

@ -275,7 +275,7 @@ class FormMail extends Form
$out.= "\n<!-- Debut form mail -->\n";
if ($this->withform == 1)
{
$out.= '<form method="POST" name="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'."\n";
$out.= '<form method="POST" name="mailform" id="mailform" enctype="multipart/form-data" action="'.$this->param["returnurl"].'">'."\n";
$out.= '<input style="display:none" type="submit" id="sendmail" name="sendmail">';
$out.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'" />';
$out.= '<input type="hidden" name="trackid" value="'.$this->trackid.'" />';
@ -703,6 +703,23 @@ class FormMail extends Form
$out.= '</table>'."\n";
if ($this->withform == 1) $out.= '</form>'."\n";
// Disable enter key if option MAIN_MAILFORM_DISABLE_ENTER is set
if (! empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY))
{
$out.= '<script type="text/javascript" language="javascript">';
$out.= 'jQuery(document).ready(function () {';
$out.= ' $(document).on("keypress", \'#mailform\', function (e) { /* Note this is calle at every key pressed ! */
var code = e.keyCode || e.which;
if (code == 13) {
e.preventDefault();
return false;
}
});';
$out.=' })';
$out.= '</script>';
}
$out.= "<!-- Fin form mail -->\n";
return $out;

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
* Copyright (C) 2013 Florian Henry <florian.henry@open-concpt.pro>
* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -227,7 +227,6 @@ llxHeader('',$langs->trans("CronAdd"));
if ($action=='edit' || empty($action) || $action=='delete' || $action=='execute')
{
$head=cron_prepare_head($object);
print dol_get_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'cron');
}
elseif ($action=='create')
{
@ -292,6 +291,8 @@ if (($action=="create") || ($action=="edit"))
print '<input type="hidden" name="action" value="add">'."\n";
}
dol_fiche_head('');
print '<table class="border" width="100%">';
print '<tr><td width="30%">';
@ -474,7 +475,9 @@ if (($action=="create") || ($action=="edit"))
print '</table>';
print '<div align="center"><br>';
dol_fiche_end();
print '<div align="center">';
print '<input type="submit" name="save" class="button" value="'.$langs->trans("Save").'">';
print '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
@ -482,12 +485,15 @@ if (($action=="create") || ($action=="edit"))
print "</form>\n";
}else {
}
else
{
/*
* view Template
* view card
*/
dol_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'cron');
// box add_jobs_box
print '<table class="border" width="100%">';
@ -572,6 +578,17 @@ if (($action=="create") || ($action=="edit"))
print "</td></tr>";
print '<tr><td>';
print $langs->trans('Active')."</td><td>";
print yn($object->status);
print "</td></tr>";
print '</table>';
print '<br>';
print '<table class="border" width="100%">';
print '<tr><td width="30%">';
print $langs->trans('CronDtLastLaunch')."</td><td>";
if(!empty($object->datelastrun)) {print dol_print_date($object->datelastrun,'dayhourtext');} else {print $langs->trans('CronNone');}
print "</td></tr>";
@ -598,7 +615,6 @@ if (($action=="create") || ($action=="edit"))
print '</table>';
dol_fiche_end();
@ -633,7 +649,9 @@ if (($action=="create") || ($action=="edit"))
else {
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?action=execute&id='.$object->id.'">'.$langs->trans("CronExecute").'</a>';
}
print '<br><br></div>';
print '</div>';
print '<br>';
}

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Laurent Destailleur <eldy@users.srouceforge.net>
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.srouceforge.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -165,6 +165,7 @@ print '<input type="hidden" name="status" value="'.$status.'" >';
print '<table width="100%" class="noborder">';
print '<tr class="liste_titre">';
$arg_url='&page='.$page.'&status='.$status.'&search_label='.$search_label;
print_liste_field_titre($langs->trans("ID"),$_SERVER["PHP_SELF"],"t.rowid","",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronLabel"),$_SERVER["PHP_SELF"],"t.label","",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronTask"),'','',"",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronDtStart"),$_SERVER["PHP_SELF"],"t.datestart","",$arg_url,'',$sortfield,$sortorder);
@ -176,11 +177,11 @@ print_liste_field_titre($langs->trans("CronNbRun"),$_SERVER["PHP_SELF"],"t.nbrun
print_liste_field_titre($langs->trans("CronLastResult"),$_SERVER["PHP_SELF"],"t.lastresult","",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVER["PHP_SELF"],"t.lastoutput","",$arg_url,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("Enabled"),$_SERVER["PHP_SELF"],"t.status","",$arg_url,'align="center"',$sortfield,$sortorder);
print '<td></td>';
print_liste_field_titre('');
print '</tr>';
print '<tr class="liste_titre">';
print '<td>&nbsp;</td>';
print '<td class="liste_titre">';
print '<input type="text" class="flat" name="search_label" value="'.$search_label.'" size="10">';
print '</td>';
@ -201,7 +202,6 @@ print '<input class="liste_titre" type="image" src="'.img_picto($langs->trans("S
print '&nbsp; ';
print '<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans("Search"),'searchclear.png','','',1).'" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
print '</td>';
print '</tr>';
@ -218,16 +218,26 @@ if (count($object->lines) > 0)
print '<tr class="'.$style.'">';
print '<td>';
if(!empty($line->label)) {
print '<a href="'.DOL_URL_ROOT.'/cron/card.php?id='.$line->id.'">';
print img_picto('', 'object_cron').' ';
print $line->id;
print '</a>';
print '</td>';
print '<td>';
if (! empty($line->label))
{
print '<a href="'.DOL_URL_ROOT.'/cron/card.php?id='.$line->id.'">'.$line->label.'</a>';
}
else {
else
{
print $langs->trans('CronNone');
}
print '</td>';
print '<td>';
if ($line->jobtype=='method') {
if ($line->jobtype=='method')
{
print $langs->trans('CronModule').':'.$line->module_name.'<BR>';
print $langs->trans('CronClass').':'. $line->classesname.'<BR>';
print $langs->trans('CronObject').':'. $line->objectname.'<BR>';
@ -279,20 +289,23 @@ if (count($object->lines) > 0)
if(!empty($line->lastoutput)) {print dol_trunc(nl2br($line->lastoutput),100);} else {print $langs->trans('CronNone');}
print '</td>';
// Status
print '<td align="center">';
print yn($line->status);
print '</td>';
print '<td align="right">';
if ($user->rights->cron->delete) {
print "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$line->id."&status=".$status."&action=delete\" title=\"".$langs->trans('CronDelete')."\">".img_delete()."</a> &nbsp;";
if ($user->rights->cron->delete)
{
print "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$line->id."&status=".$status."&action=delete\" title=\"".dol_escape_htmltag($langs->trans('CronDelete'))."\">".img_picto($langs->trans('CronDelete'),'delete')."</a> &nbsp;";
} else {
print "<a href=\"#\" title=\"".$langs->trans('NotEnoughPermissions')."\">".img_delete()."</a> &nbsp; ";
print "<a href=\"#\" title=\"".dol_escape_htmltag($langs->trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'), 'delete')."</a> &nbsp; ";
}
if ($user->rights->cron->execute) {
print "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$line->id."&status=".$status."&action=execute\" title=\"".$langs->trans('CronExecute')."\">".img_picto('',"play")."</a>";
if ($user->rights->cron->execute)
{
print "<a href=\"".$_SERVER["PHP_SELF"]."?id=".$line->id."&status=".$status."&action=execute\" title=\"".dol_escape_htmltag($langs->trans('CronExecute'))."\">".img_picto($langs->trans('CronExecute'),"play")."</a>";
} else {
print "<a href=\"#\" title=\"".$langs->trans('NotEnoughPermissions')."\">".img_picto('',"execute")."</a>";
print "<a href=\"#\" title=\"".dol_escape_htmltag($langs->trans('NotEnoughPermissions'))."\">".img_picto($langs->trans('NotEnoughPermissions'),"execute")."</a>";
}
print '</td>';
@ -301,7 +314,7 @@ if (count($object->lines) > 0)
}
else
{
print '<tr><td colspan="8">'.$langs->trans('CronNoJobs').'</td></tr>';
print '<tr><td colspan="9">'.$langs->trans('CronNoJobs').'</td></tr>';
}
print '</table>';

View File

@ -4,10 +4,10 @@ About = About
CronAbout = About Cron
CronAboutPage = Cron about page
# Right
Permission23101 = Read Scheduled task
Permission23102 = Create/update Scheduled task
Permission23103 = Delete Scheduled task
Permission23104 = Execute Scheduled task
Permission23101 = Read Scheduled job
Permission23102 = Create/update Scheduled job
Permission23103 = Delete Scheduled job
Permission23104 = Execute Scheduled job
# Admin
CronSetup= Scheduled job management setup
URLToLaunchCronJobs=URL to check and launch cron jobs if required
@ -55,9 +55,9 @@ CronEach=Every
JobFinished=Job launched and finished
#Page card
CronAdd= Add jobs
CronHourStart= Start hour and date of task
CronEvery= And execute task each
CronObject= Instance/Object to create
CronHourStart= Start hour and date of job
CronEvery=Execute job each
CronObject=Instance/Object to create
CronArgs=Parameters
CronSaveSucess=Save succesfully
CronNote=Comment