diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 37d5b7f05dbf5..5776c85efdb2c 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -36,6 +36,18 @@ // $toselect may be defined // $diroutputmassaction may be defined +' +@phan-var-force ?string $permissiontoread +@phan-var-force ?string $permissiontodelete +@phan-var-force ?string $permissiontoclose +@phan-var-force ?string $permissiontoapprove +@phan-var-force ?int[] $toselect +@phan-var-force ?string $diroutputmassaction +@phan-var-force ?string $objectlabel +@phan-var-force ?string $option +@phan-var-force ?string $deliveryreceipt +'; + // Protection if (empty($objectclass) || empty($uploaddir)) { @@ -47,6 +59,14 @@ } $error = 0; +// Note: list of strings for objectclass could be extended to accepted/expected classes +' +@phan-var-force "CommonObject"|"CommandeFournisseur"|"ConferenceOrBoothAttendee"|"Contrat"|"Contact"|"Expedition"|"ExpenseReport"|"Facture"|"FactureFournisseur"|"Fichinter"|"Holiday"|"Partnership"|"Project"|"Propal"|"Societe"|"SupplierProposal" $objectclass +@phan-var-force string $massaction +@phan-var-force string $uploaddir +'; + + // For backward compatibility if (!empty($permtoread) && empty($permissiontoread)) { $permissiontoread = $permtoread; @@ -88,6 +108,7 @@ $contactidtosend = array(); $attachedfilesThirdpartyObj = array(); $oneemailperrecipient = (GETPOSTINT('oneemailperrecipient') ? 1 : 0); + $thirdparty = null; if (!$error) { $objecttmp = new $objectclass($db); @@ -108,21 +129,28 @@ foreach ($toselect as $toselectid) { $objecttmp = new $objectclass($db); // we must create new instance because instance is saved into $listofobjectref array for future use + '@phan-var-force CommonObject $objecttmp'; $result = $objecttmp->fetch($toselectid); if ($result > 0) { $listofobjectid[$toselectid] = $toselectid; $tmpobjectid = ($objecttmp->fk_soc ? $objecttmp->fk_soc : $objecttmp->socid); if ($objecttmp->element == 'societe') { + '@phan-var-force Societe $objecttmp'; $tmpobjectid = $objecttmp->id; } elseif ($objecttmp->element == 'contact') { + '@phan-var-force Contact $objecttmp'; $tmpobjectid = $objecttmp->id; } elseif ($objecttmp->element == 'expensereport') { + '@phan-var-force ExpenseReport $objecttmp'; $tmpobjectid = $objecttmp->fk_user_author; } elseif ($objecttmp->element == 'partnership' && getDolGlobalString('PARTNERSHIP_IS_MANAGED_FOR') == 'member') { + '@phan-var-force Partnership $objecttmp'; $tmpobjectid = $objecttmp->fk_member; } elseif ($objecttmp->element == 'holiday') { + '@phan-var-force Holiday $objecttmp'; $tmpobjectid = $objecttmp->fk_user; } elseif ($objecttmp->element == 'conferenceorboothattendee') { + '@phan-var-force ConferenceOrBoothAttendee $objecttmp'; $tmpobjectid = $objecttmp->id; } if (empty($tmpobjectid)) { @@ -130,6 +158,8 @@ } if ($objectclass == 'Facture') { + '@phan-var-force Facture $objecttmp'; + $tmpobjectid = $objecttmp->id; $tmparraycontact = array(); $tmparraycontact = $objecttmp->liste_contact(-1, 'external', 0, 'BILLING'); if (is_array($tmparraycontact) && count($tmparraycontact) > 0) { @@ -138,6 +168,7 @@ } } } elseif ($objectclass == 'CommandeFournisseur') { + '@phan-var-force CommandeFournisseur $objecttmp'; $tmparraycontact = array(); $tmparraycontact = $objecttmp->liste_contact(-1, 'external', 0, 'CUSTOMER'); if (is_array($tmparraycontact) && count($tmparraycontact) > 0) { @@ -200,7 +231,7 @@ // Recipients are provided into free text $tmparray[] = trim(GETPOST('sendto', 'alphawithlgt')); } - if (count($receiver) > 0) { + if (count($receiver) > 0 && is_object($thirdparty)) { foreach ($receiver as $key => $val) { // Recipient was provided from combo list if ($val == 'thirdparty') { // Id of third party or user @@ -1135,6 +1166,11 @@ // Generate document foreach object according to model linked to object // @todo : propose model selection if (!$error && $massaction == 'generate_doc' && $permissiontoread) { + // Complete with classes that use this massaction + <<<'EOPHAN' +@phan-var-force 'Commande'|'CommandeFournisseur'|'Contrat'|'Expedition'|'ExpenseReport'|'Facture'|'FactureFournisseur'|'Fichinter'|'Project'|'Propal'|'SupplierProposal' $objectclass +EOPHAN; + $db->begin(); $nbok = 0; foreach ($toselect as $toselectid) { @@ -1151,7 +1187,7 @@ $newlang = $objecttmp->thirdparty->default_lang; // for proposal, order, invoice, ... } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && isset($objecttmp->default_lang)) { - $newlang = $objecttmp->default_lang; // for thirdparty + $newlang = $objecttmp->default_lang; // for thirdparty @phan-suppress-current-line PhanUndeclaredProperty } if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && empty($objecttmp->thirdparty)) { //load lang from thirdparty $objecttmp->fetch_thirdparty(); @@ -1263,6 +1299,8 @@ } if (!$error && ($action == 'updateprice' && $confirm == 'yes') && $permissiontoadd) { + '@phan-var-force Product|ProductCustomerPrice $obj'; + '@phan-var-force Product|ProductCustomerPrice $object'; $nbok = 0; $db->begin(); if (GETPOSTISSET('pricerate')) { @@ -1308,9 +1346,10 @@ } if (!$error && ($action == 'setsupervisor' && $confirm == 'yes') && $permissiontoadd) { + '@phan-var-force User $object'; $nbok = 0; $db->begin(); - $supervisortoset = GETPOST('supervisortoset'); + $supervisortoset = GETPOSTINT('supervisortoset'); if (!empty($supervisortoset)) { foreach ($toselect as $toselectid) { $result = $object->fetch($toselectid); @@ -1358,7 +1397,7 @@ $res = $object->add_contact($usertoaffect, $projectrole, 'internal'); if ($res >= 0) { $taskstatic = new Task($db); - $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0); + $task_array = $taskstatic->getTasksArray(null, null, $object->id, 0, 0); foreach ($task_array as $task) { $tasksToAffect = new Task($db); @@ -1596,6 +1635,7 @@ $db->begin(); $objecttmp = new $objectclass($db); + '@phan-var-force Holiday $objecttmp'; $nbok = 0; foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); @@ -1605,7 +1645,7 @@ continue; } if ($user->id == $objecttmp->fk_validator) { - $objecttmp->oldcopy = dol_clone($objecttmp, 2); + $objecttmp->oldcopy = dol_clone($objecttmp, 2); // @phan-suppress-current-line PhanTypeMismatchProperty $objecttmp->date_valid = dol_now(); $objecttmp->fk_user_valid = $user->id; @@ -1712,7 +1752,8 @@ } } -if (!$error && ($massaction == 'increaseholiday' || ($action == 'increaseholiday' && $confirm == 'yes')) && $permissiontoapprove) { +if (!$error && ($massaction == 'increaseholiday' || ($action == 'increaseholiday' && $confirm == 'yes')) && $permissiontoapprove && is_array($toselect)) { + '@phan-var-force Holiday $holiday'; // Supposing that $holiday is set, it is needed. $db->begin(); $objecttmp = new $objectclass($db); $nbok = 0; @@ -1780,6 +1821,7 @@ if (getDolGlobalString('PROJECT_TASK_ADDON') && is_readable(DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON') . ".php")) { require_once DOL_DOCUMENT_ROOT . "/core/modules/project/task/" . getDolGlobalString('PROJECT_TASK_ADDON') . '.php'; $modTask = new $obj(); + '@phan-var-force ModeleNumRefTask $modTask'; $defaultref = $modTask->getNextValue(0, $clone_task); }