From 0baea219475b7cf3cff22be47629b71c7aa84eb2 Mon Sep 17 00:00:00 2001 From: Supermanu Date: Thu, 28 May 2020 14:31:19 +0200 Subject: [PATCH] NEW Add mass deletion for events Only users with the right `allactions->delete` will be able to mass delete. --- htdocs/comm/action/list.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 467275d5fc0..abe4d79256d 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -52,6 +52,7 @@ $year = GETPOST("year", 'int'); $month = GETPOST("month", 'int'); $day = GETPOST("day", 'int'); $toselect = GETPOST('toselect', 'array'); +$confirm = GETPOST('confirm','alpha'); // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index) if (GETPOST('search_actioncode', 'array')) @@ -156,6 +157,11 @@ $arrayfields = dol_sort_array($arrayfields, 'position'); * Actions */ +if (GETPOST('cancel','alpha')) +{ + $action='list'; $massaction=''; +} + if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday")) { $param = ''; @@ -224,6 +230,17 @@ if (empty($reshook) && !empty($massaction)) } } +// As mass deletion happens with a confirm step, $massaction is not use for the final step (deletion). +if (empty($reshook)) +{ + $objectclass = 'ActionComm'; + $objectlabel = 'Events'; + $uploaddir = true; + // Only users that can delete any event can remove records. + $permissiontodelete = $user->rights->agenda->allactions->delete; + include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; +} + /* * View */ @@ -280,6 +297,10 @@ $arrayofmassactions = array( 'set_all_events_to_in_progress' => $langs->trans("SetAllEventsToInProgress"), 'set_all_events_to_finished' => $langs->trans("SetAllEventsToFinished"), ); +if ($user->rights->agenda->allactions->delete) +{ + $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); +} $massactionbutton = $form->selectMassAction('', $arrayofmassactions); @@ -477,6 +498,8 @@ if ($resql) print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1); + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + $moreforfilter = ''; $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;