Skip to content

Commit

Permalink
FIX remove backward compatibility projectid and uses object id instead
Browse files Browse the repository at this point in the history
  • Loading branch information
lvessiller-opendsi committed Dec 23, 2019
1 parent 7b08ce9 commit e7a5d26
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions htdocs/projet/element.php
Expand Up @@ -83,17 +83,16 @@
//$dates=dol_time_plus_duree($datee, -1, 'y');
$dates=dol_get_first_day($tmp['year'], 1);
}
if ($id == '' && $projectid == '' && $ref == '')
if ($id == '' && $ref == '')
{
dol_print_error('', 'Bad parameter');
exit;
setEventMessage($langs->trans('ErrorBadParameters'), 'errors');
header('Location: list.php');
exit();
}

$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects

$projectid=$id; // For backward compatibility

$object = new Project($db);

include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once
Expand All @@ -102,7 +101,7 @@
// Security check
$socid=$object->socid;
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
$result = restrictedArea($user, 'projet', $projectid, 'projet&project');
$result = restrictedArea($user, 'projet', $object->id, 'projet&project');

$hookmanager->initHooks(array('projectOverview'));

Expand Down Expand Up @@ -513,7 +512,7 @@
{

$tablename = GETPOST("tablename", "aZ09");
$projectField = GETPOST("projectfield", "aZ09");
$projectField = GETPOST('projectfield', 'aZ09') ? GETPOST('projectfield', 'aZ09') : 'fk_projet';
$elementselectid = GETPOST("elementselect", "int");

$result = $object->remove_element($tablename, $elementselectid, $projectField);
Expand All @@ -532,7 +531,7 @@
if (! $showdatefilter)
{
print '<div class="center centpercent">';
print '<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">';
print '<form action="'.$_SERVER["PHP_SELF"].'?id=' . $object->id . '" method="post">';
print '<input type="hidden" name="token" value="'.$_SESSION["newtoken"].'">';
print '<input type="hidden" name="tablename" value="'.$tablename.'">';
print '<input type="hidden" name="action" value="view">';
Expand Down Expand Up @@ -755,15 +754,15 @@
if (empty($conf->global->PROJECT_LINK_ON_OVERWIEW_DISABLED) && $idtofilterthirdparty && !in_array($tablename, $exclude_select_element))
{
$selectList=$formproject->select_element($tablename, $idtofilterthirdparty, 'minwidth300', -2, !empty($project_field)?$project_field:'fk_projet');
if (! $selectList || ($selectList<0))
if ($selectList<0)
{
setEventMessages($formproject->error, $formproject->errors, 'errors');
}
elseif($selectList)
{
// Define form with the combo list of elements to link
$addform.='<div class="inline-block valignmiddle">';
$addform.='<form action="'.$_SERVER["PHP_SELF"].'?id='.$projectid.'" method="post">';
$addform.='<form action="'.$_SERVER["PHP_SELF"].'?id=' . $object->id . '" method="post">';
$addform.='<input type="hidden" name="token" value="'.$_SESSION["newtoken"].'">';
$addform.='<input type="hidden" name="tablename" value="'.$tablename.'">';
$addform.='<input type="hidden" name="action" value="addelement">';
Expand Down Expand Up @@ -890,7 +889,7 @@
{
if (empty($conf->global->PROJECT_DISABLE_UNLINK_FROM_OVERVIEW) || $user->admin) // PROJECT_DISABLE_UNLINK_FROM_OVERVIEW is empty by defaut, so this test true
{
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $projectid . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . ($project_field ? '&projectfield=' . $project_field : '') . '" class="reposition">';
print '<a href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=unlink&tablename=' . $tablename . '&elementselect=' . $element->id . ($project_field ? '&projectfield=' . $project_field : '') . '" class="reposition">';
print img_picto($langs->trans('Unlink'), 'unlink');
print '</a>';
}
Expand Down

0 comments on commit e7a5d26

Please sign in to comment.