Skip to content

Commit

Permalink
NEW Add a confirmation for all mass action 'delete'
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Nov 11, 2017
1 parent 01a4123 commit d1860b8
Show file tree
Hide file tree
Showing 37 changed files with 262 additions and 276 deletions.
2 changes: 1 addition & 1 deletion htdocs/accountancy/customer/list.php
Expand Up @@ -303,7 +303,7 @@
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);

print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/expensereport/list.php
Expand Up @@ -267,7 +267,7 @@
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);


Expand Down
2 changes: 1 addition & 1 deletion htdocs/accountancy/supplier/list.php
Expand Up @@ -299,7 +299,7 @@
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->mymodule->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('ventil', $arrayofmassactions, 1);

print '<form action="' . $_SERVER["PHP_SELF"] . '" method="post">' . "\n";
Expand Down
3 changes: 1 addition & 2 deletions htdocs/adherents/list.php
Expand Up @@ -355,9 +355,8 @@
// 'presend'=>$langs->trans("SendByMail"),
// 'builddoc'=>$langs->trans("PDFMerge"),
);
//if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->adherent->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
Expand Down
3 changes: 1 addition & 2 deletions htdocs/adherents/subscription/list.php
Expand Up @@ -177,9 +177,8 @@
//'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->adherent->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/admin/mails_senderprofile_list.php
Expand Up @@ -318,7 +318,7 @@ function init_myfunc()
//'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->monmodule->delete) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
Expand Down
16 changes: 6 additions & 10 deletions htdocs/comm/propal/list.php
Expand Up @@ -401,7 +401,7 @@
'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->propal->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

// Lignes des champs de filtre
Expand All @@ -417,15 +417,11 @@

print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);

if ($massaction == 'presend')
{
$topicmail="SendSupplierProposalRef";
$modelmail="supplier_proposal_send";
$objecttmp=new Propal($db);
$trackid='ord'.$object->id;

include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php';
}
$topicmail="SendSupplierProposalRef";
$modelmail="supplier_proposal_send";
$objecttmp=new Propal($db);
$trackid='ord'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';

if ($sall)
{
Expand Down
16 changes: 6 additions & 10 deletions htdocs/commande/list.php
Expand Up @@ -652,7 +652,7 @@
);
if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->commande->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend' || $massaction == 'createbills') $arrayofmassactions=array();
if (in_array($massaction, array('presend','predelete','createbills'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

// Lines of title fields
Expand All @@ -669,15 +669,11 @@

print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_commercial.png', 0, '', '', $limit);

if ($massaction == 'presend')
{
$topicmail="SendOrderRef";
$modelmail="order_send";
$objecttmp=new Commande($db);
$trackid='ord'.$object->id;

include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php';
}
$topicmail="SendOrderRef";
$modelmail="order_send";
$objecttmp=new Commande($db);
$trackid='ord'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';

if ($massaction == 'createbills')
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/bank/bankentries_list.php
Expand Up @@ -574,7 +574,7 @@
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->bank->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

// Confirmation delete
Expand Down
2 changes: 1 addition & 1 deletion htdocs/compta/bank/list.php
Expand Up @@ -239,7 +239,7 @@
// 'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->banque->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

$newcardbutton='';
Expand Down
16 changes: 6 additions & 10 deletions htdocs/compta/facture/list.php
Expand Up @@ -595,7 +595,7 @@
$arrayofmassactions['delete']=$langs->trans("Delete");
}
}
if ($massaction == 'presend') $arrayofmassactions=array();
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

$i = 0;
Expand All @@ -613,15 +613,11 @@

print_barre_liste($langs->trans('BillsCustomers').' '.($socid?' '.$soc->name:''), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_accountancy.png', 0, '', '', $limit);

if ($massaction == 'presend')
{
$topicmail="SendBillRef";
$modelmail="facture_send";
$objecttmp=new Facture($db);
$trackid='inv'.$object->id;

include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php';
}
$topicmail="SendBillRef";
$modelmail="facture_send";
$objecttmp=new Facture($db);
$trackid='inv'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';

if ($sall)
{
Expand Down
10 changes: 8 additions & 2 deletions htdocs/contact/list.php
Expand Up @@ -420,8 +420,8 @@
// 'builddoc'=>$langs->trans("PDFMerge"),
);
//if($user->rights->societe->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer");
if ($user->rights->societe->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
if ($user->rights->societe->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

print '<form method="post" action="'.$_SERVER["PHP_SELF"].'" name="formfilter">';
Expand All @@ -435,6 +435,12 @@

print_barre_liste($titre, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'title_companies.png', 0, '', '', $limit);

$topicmail="Information";
$modelmail="contact";
$objecttmp=new Contact($db);
$trackid='ctc'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';

if ($sall)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
Expand Down
16 changes: 6 additions & 10 deletions htdocs/contrat/list.php
Expand Up @@ -366,7 +366,7 @@
'builddoc'=>$langs->trans("PDFMerge"),
);
if ($user->rights->contrat->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
if ($massaction == 'presend') $arrayofmassactions=array();
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
Expand All @@ -380,15 +380,11 @@

print_barre_liste($langs->trans("ListOfContracts"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $totalnboflines, 'title_commercial.png', 0, '', '', $limit);

if ($massaction == 'presend')
{
$topicmail="SendContractRef";
$modelmail="contract";
$objecttmp=new Contrat($db);
$trackid='con'.$object->id;

include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_form.tpl.php';
}
$topicmail="SendContractRef";
$modelmail="contract";
$objecttmp=new Contrat($db);
$trackid='con'.$object->id;
include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';

if ($sall)
{
Expand Down
2 changes: 1 addition & 1 deletion htdocs/contrat/services_list.php
Expand Up @@ -324,7 +324,7 @@
//'builddoc'=>$langs->trans("PDFMerge"),
);
//if ($user->rights->contrat->supprimer) $arrayofmassactions['delete']=$langs->trans("Delete");
//if ($massaction == 'presend') $arrayofmassactions=array();
//if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions);

print '<form method="POST" action="'. $_SERVER["PHP_SELF"] .'">';
Expand Down
4 changes: 2 additions & 2 deletions htdocs/core/actions_massactions.inc.php
Expand Up @@ -726,8 +726,8 @@
}
}

// Delete records
if (! $error && $massaction == 'delete' && $permtodelete)
// Delete record from mass action (massaction = 'delete' for direct delete, action/confirm='delete'/'yes' with a confirmation step before)
if (! $error && ($massaction == 'delete' || ($action == 'delete' && $confirm == 'yes')) && $permtodelete)
{
$db->begin();

Expand Down
10 changes: 6 additions & 4 deletions htdocs/core/class/html.form.class.php
Expand Up @@ -3552,9 +3552,10 @@ function form_confirm($page, $title, $question, $action, $formquestion='', $sele
* @param int $useajax 0=No, 1=Yes, 2=Yes but submit page with &confirm=no if choice is No, 'xxx'=Yes and preoutput confirm box with div id=dialog-confirm-xxx
* @param int $height Force height of box
* @param int $width Force width of box ('999' or '90%'). Ignored and forced to 90% on smartphones.
* @param int $disableformtag 1=Disable form tag. Can be used if we are already inside a <form> section.
* @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form
*/
function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=200, $width=500)
function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice='', $useajax=0, $height=200, $width=500, $disableformtag=0)
{
global $langs,$conf;
global $useglobalvars;
Expand Down Expand Up @@ -3783,9 +3784,10 @@ function formconfirm($page, $title, $question, $action, $formquestion='', $selec
{
$formconfirm.= "\n<!-- begin form_confirm page=".$page." -->\n";

$formconfirm.= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n";
if (empty($disableformtag)) $formconfirm.= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n";

$formconfirm.= '<input type="hidden" name="action" value="'.$action.'">'."\n";
$formconfirm.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
if (empty($disableformtag)) $formconfirm.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";

$formconfirm.= '<table width="100%" class="valid">'."\n";

Expand All @@ -3811,7 +3813,7 @@ function formconfirm($page, $title, $question, $action, $formquestion='', $selec

$formconfirm.= '</table>'."\n";

$formconfirm.= "</form>\n";
if (empty($disableformtag)) $formconfirm.= "</form>\n";
$formconfirm.= '<br>';

$formconfirm.= "<!-- end form_confirm -->\n";
Expand Down

0 comments on commit d1860b8

Please sign in to comment.