From a37a4031e9878abf3f1ce884e569b701dcfb3fff 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. Conflicts: htdocs/core/actions_massactions.inc.php htdocs/website/index.php --- 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 | 123 ++++++++++++++++++------ 4 files changed, 116 insertions(+), 44 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index e19530ec209..40e6849d494 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -913,9 +913,10 @@ if (!$error && $massaction == 'cancelorders') setEventMessages($langs->trans("ErrorObjectMustHaveStatusValidToBeCanceled", $cmd->ref), null, 'errors'); $error++; break; - } - else + } 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 5d7e008e062..9540c9eef84 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4194,18 +4194,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) { @@ -4359,7 +4359,7 @@ class Form } // Show JQuery confirm box. $formconfirm .= ''; // Close current websitebar to open a new one @@ -2915,7 +2973,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%', ''); @@ -3210,6 +3271,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') $pageauthorid = $objectpage->fk_user_creat; $pageusermodifid = $objectpage->fk_user_modif; $pageauthoralias = $objectpage->author_alias; + $pagestatus = $objectpage->status; } else { @@ -3218,6 +3280,7 @@ if ($action == 'editmeta' || $action == 'createcontainer') $pageauthorid = $user->id; $pageusermodifid = 0; $pageauthoralias = ''; + $pagestatus = 1; } if (GETPOST('WEBSITE_TITLE', 'alpha')) $pagetitle = GETPOST('WEBSITE_TITLE', 'alpha'); if (GETPOST('WEBSITE_PAGENAME', 'alpha')) $pageurl = GETPOST('WEBSITE_PAGENAME', 'alpha'); @@ -3228,20 +3291,6 @@ if ($action == 'editmeta' || $action == 'createcontainer') if (GETPOST('WEBSITE_LANG', 'aZ09')) $pagelang = GETPOST('WEBSITE_LANG', 'aZ09'); if (GETPOST('htmlheader', 'none')) $pagehtmlheader = GETPOST('htmlheader', 'none'); - // Title - print ''; - print $langs->trans('WEBSITE_TITLE'); - print ''; - print ''; - print ''; - - // Alias - print ''; - print $langs->trans('WEBSITE_PAGENAME'); - print ''; - print ''; - print ''; - // Type of container print ''; print $langs->trans('WEBSITE_TYPE_CONTAINER'); @@ -3258,6 +3307,20 @@ if ($action == 'editmeta' || $action == 'createcontainer') print ''; } + // Title + print ''; + print $langs->trans('WEBSITE_TITLE'); + print ''; + print ''; + print ''; + + // Alias + print ''; + print $langs->trans('WEBSITE_PAGENAME'); + print ''; + print ''; + print ''; + print ''; print $langs->trans('WEBSITE_DESCRIPTION'); print ''; @@ -3548,7 +3611,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = print ''; - print ''."\n"; + print ''."\n"; print '

'; print load_fiche_titre($langs->trans("ReplaceWebsiteContent"), '', 'search'); @@ -3556,7 +3619,7 @@ if ($action == 'replacesite' || $action == 'replacesiteconfirm' || $massaction = print '
'; print '
'; - print '
'; + print '
'; print $langs->trans("SearchReplaceInto"); print '
'; print '
'; @@ -3593,15 +3656,15 @@ 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(); - if ($user->rights->website->writephp) $arrayofmassactions['replace'] = $langs->trans("Replace"); - if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); + if ($user->rights->website->writephp && $searchkey) $arrayofmassactions['replace'] = $langs->trans("Replace"); + //if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array(); $massactionbutton = $form->selectMassAction('', $arrayofmassactions); - $massactionbutton .= '