Merge pull request #12815 from artis-auxilium/fix_massaction_checkbox

Fix massaction checkbox when product module disable
This commit is contained in:
Laurent Destailleur 2020-01-10 00:22:02 +01:00 committed by GitHub
commit 4f2f2f0d73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 6 deletions

View File

@ -573,15 +573,14 @@ class Form
* Generate select HTML to choose massaction * Generate select HTML to choose massaction
* *
* @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default. * @param string $selected Value auto selected when at least one record is selected. Not a preselected value. Use '0' by default.
* @param int $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action. * @param array $arrayofaction array('code'=>'label', ...). The code is the key stored into the GETPOST('massaction') when submitting action.
* @param int $alwaysvisible 1=select button always visible * @param int $alwaysvisible 1=select button always visible
* @return string Select list * @return string|void Select list
*/ */
function selectMassAction($selected, $arrayofaction, $alwaysvisible=0) function selectMassAction($selected, $arrayofaction, $alwaysvisible=0)
{ {
global $conf,$langs,$hookmanager; global $conf,$langs,$hookmanager;
if (count($arrayofaction) == 0) return;
$disabled=0; $disabled=0;
$ret='<div class="centpercent center">'; $ret='<div class="centpercent center">';
@ -590,6 +589,8 @@ class Form
// Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks. // Complete list with data from external modules. THe module can use $_SERVER['PHP_SELF'] to know on which page we are, or use the $parameters['currentcontext'] completed by executeHooks.
$parameters=array(); $parameters=array();
$reshook=$hookmanager->executeHooks('addMoreMassActions',$parameters); // Note that $action and $object may have been modified by hook $reshook=$hookmanager->executeHooks('addMoreMassActions',$parameters); // Note that $action and $object may have been modified by hook
// check if there is a mass action
if (count($arrayofaction) == 0 && empty($hookmanager->resPrint)) return;
if (empty($reshook)) if (empty($reshook))
{ {
$ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>'; $ret.='<option value="0"'.($disabled?' disabled="disabled"':'').'>-- '.$langs->trans("SelectAction").' --</option>';

View File

@ -424,13 +424,13 @@ if ($resql)
//'presend'=>$langs->trans("SendByMail"), //'presend'=>$langs->trans("SendByMail"),
//'builddoc'=>$langs->trans("PDFMerge"), //'builddoc'=>$langs->trans("PDFMerge"),
); );
if ($user->rights->produit->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); $rightskey='produit';
if($type == Product::TYPE_SERVICE) $rightskey='service';
if ($user->rights->{$rightskey}->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete");
if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array();
$massactionbutton=$form->selectMassAction('', $arrayofmassactions); $massactionbutton=$form->selectMassAction('', $arrayofmassactions);
$newcardbutton=''; $newcardbutton='';
$rightskey='produit';
if($type == Product::TYPE_SERVICE) $rightskey='service';
if($user->rights->{$rightskey}->creer) if($user->rights->{$rightskey}->creer)
{ {
$label='NewProduct'; $label='NewProduct';