FIX Protection on agenda view for a thirdparty id that does not exist

This commit is contained in:
Laurent Destailleur 2023-03-15 09:44:50 +01:00
parent dc1ba8f447
commit 765b1a858a

View File

@ -79,9 +79,16 @@ $socid = GETPOST('socid', 'int');
if ($user->socid) { if ($user->socid) {
$socid = $user->socid; $socid = $user->socid;
} }
$result = $object->fetch($socid);
if ($result <= 0) {
accessforbidden('Third party not found');
}
$result = restrictedArea($user, 'societe', $socid, '&societe'); $result = restrictedArea($user, 'societe', $socid, '&societe');
/* /*
* Actions * Actions
*/ */
@ -114,9 +121,6 @@ if (empty($reshook)) {
$form = new Form($db); $form = new Form($db);
if ($socid > 0) {
$result = $object->fetch($socid);
$title = $langs->trans("Agenda"); $title = $langs->trans("Agenda");
if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) { if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
$title = $object->name." - ".$title; $title = $object->name." - ".$title;
@ -216,7 +220,6 @@ if ($socid > 0) {
// TODO Replace this with same code than into list.php // TODO Replace this with same code than into list.php
show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module); show_actions_done($conf, $langs, $db, $object, null, 0, $actioncode, '', $filters, $sortfield, $sortorder, $object->module);
} }
}
// End of page // End of page
llxFooter(); llxFooter();