From d4db1836d1b6818cd28184c599176025c3d8f3e0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Jun 2020 00:46:09 +0200 Subject: [PATCH] FIX Delete of website page need permission. Conflict with mass action. --- htdocs/core/actions_massactions.inc.php | 5 +- htdocs/core/class/html.form.class.php | 28 ++++----- htdocs/core/lib/website2.lib.php | 4 +- htdocs/website/index.php | 80 ++++++++++++++++++++++--- 4 files changed, 93 insertions(+), 24 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 26ea16af4bb..97c1904d26e 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -878,7 +878,10 @@ if (!$error && $massaction == 'cancelorders') setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors'); $error++; break; - } else $result = $cmd->cancel(); + } else { + // TODO We do not provide warehouse so no stock change here for the moment. + $result = $cmd->cancel(); + } if ($result < 0) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 68c30f9290a..051834d4497 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4036,18 +4036,18 @@ class Form * print '});'."\n"; * print ''."\n"; * - * @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated) - * @param string $title Title - * @param string $question Question - * @param string $action Action - * @param array $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , )) - * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', ... - * @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0' - * @param int|string $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 (0 = auto) - * @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
section. - * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form + * @param string $page Url of page to call if confirmation is OK. Can contains parameters (param 'action' and 'confirm' will be reformated) + * @param string $title Title + * @param string $question Question + * @param string $action Action + * @param array|string $formquestion An array with complementary inputs to add into forms: array(array('label'=> ,'type'=> , )) + * type can be 'hidden', 'text', 'password', 'checkbox', 'radio', 'date', 'morecss', ... + * @param string $selectedchoice '' or 'no', or 'yes' or '1' or '0' + * @param int|string $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 (0 = auto) + * @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 section. + * @return string HTML ajax code if a confirm ajax popup is required, Pure HTML code if it's an html form */ public function formconfirm($page, $title, $question, $action, $formquestion = '', $selectedchoice = '', $useajax = 0, $height = 0, $width = 500, $disableformtag = 0) { @@ -4193,7 +4193,7 @@ class Form } // Show JQuery confirm box. $formconfirm .= ''; // Close current websitebar to open a new one @@ -2931,7 +2986,10 @@ if ($action == 'editcss') // JS file print ''; - print $langs->trans('WEBSITE_JS_INLINE'); + $textwithhelp = $langs->trans('WEBSITE_JS_INLINE'); + $htmlhelp2 = $langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").'
'; + print $form->textwithpicto($textwithhelp, $htmlhelp2, 1, 'warning', '', 0, 2, 'htmljstooltip2'); + print ''; $doleditor = new DolEditor('WEBSITE_JS_INLINE', $jscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); @@ -3688,7 +3746,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = $param = ''; $nbtotalofrecords = count($listofpages['list']); $num = $limit; - $permissiontodelete = 0; + $permissiontodelete = $user->rights->website->delete; // List of mass actions available $arrayofmassactions = array(); @@ -3715,6 +3773,12 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = print_barre_liste($langs->trans("Results"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit, 1, 1, 1); + $topicmail = "WebsitePageRef"; + $modelmail = "websitepage_send"; + $objecttmp = new WebsitePage($db); + $trackid = 'wsp'.$object->id; + include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; + $param = 'action=replacesiteconfirm&website='.urlencode($website->ref); $param .= '&searchstring='.urlencode($searchkey); if (GETPOST('optioncontent')) $param .= '&optioncontent=content';