Fix: Project navigation forgot some project when permission see all was on

This commit is contained in:
Laurent Destailleur 2010-11-11 12:16:55 +00:00
parent 29e3e16280
commit 0d14009f4b
2 changed files with 395 additions and 391 deletions

View File

@ -805,6 +805,7 @@ class Project extends CommonObject
{ {
// No filter. Use this if user has permission to see all project // No filter. Use this if user has permission to see all project
} }
//print $sql;
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)

View File

@ -34,12 +34,12 @@ require_once(DOL_DOCUMENT_ROOT."/includes/modules/project/modules_project.php");
$langs->load("projects"); $langs->load("projects");
$langs->load('companies'); $langs->load('companies');
$projectid = (isset($_GET["id"])?$_GET["id"]:(isset($_POST["id"])?$_POST["id"]:'')); $projectid = GETPOST('id','int');
$projectref = (isset($_GET["ref"])?$_GET["ref"]:''); $projectref = GETPOST('ref');
if ($projectid == '' && $projectref == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden(); if ($projectid == '' && $projectref == '' && ($_GET['action'] != "create" && $_POST['action'] != "add" && $_POST["action"] != "update" && !$_POST["cancel"])) accessforbidden();
$mine = $_REQUEST['mode']=='mine' ? 1 : 0; $mine = GETPOST('mode')=='mine' ? 1 : 0;
//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects
// Security check // Security check
@ -144,20 +144,20 @@ if ($_POST["action"] == 'update' && ! $_POST["cancel"] && $user->rights->projet-
} }
// Build doc // Build doc
if ($_REQUEST['action'] == 'builddoc' && $user->rights->projet->creer) if (GETPOST('action') == 'builddoc' && $user->rights->projet->creer)
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET['id']); $project->fetch($_GET['id']);
if ($_REQUEST['model']) if (GETPOST('model'))
{ {
$project->setDocModel($user, $_REQUEST['model']); $project->setDocModel($user, GETPOST('model'));
} }
$outputlangs = $langs; $outputlangs = $langs;
if (! empty($_REQUEST['lang_id'])) if (GETPOST('lang_id'))
{ {
$outputlangs = new Translate("",$conf); $outputlangs = new Translate("",$conf);
$outputlangs->setDefaultLang($_REQUEST['lang_id']); $outputlangs->setDefaultLang(GETPOST('lang_id'));
} }
$result=project_pdf_create($db, $project, $project->modelpdf, $outputlangs); $result=project_pdf_create($db, $project, $project->modelpdf, $outputlangs);
if ($result <= 0) if ($result <= 0)
@ -172,10 +172,10 @@ if ($_REQUEST['action'] == 'builddoc' && $user->rights->projet->creer)
} }
} }
if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes') if (GETPOST('action') == 'confirm_validate' && GETPOST('confirm') == 'yes')
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET["id"]); $project->fetch(GETPOST("id"));
$result = $project->setValid($user, $conf->projet->outputdir); $result = $project->setValid($user, $conf->projet->outputdir);
if ($result <= 0) if ($result <= 0)
@ -184,10 +184,10 @@ if ($_REQUEST['action'] == 'confirm_validate' && $_REQUEST['confirm'] == 'yes')
} }
} }
if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes') if (GETPOST('action') == 'confirm_close' && GETPOST('confirm') == 'yes')
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET["id"]); $project->fetch(GETPOST("id"));
$result = $project->setClose($user, $conf->projet->outputdir); $result = $project->setClose($user, $conf->projet->outputdir);
if ($result <= 0) if ($result <= 0)
{ {
@ -195,10 +195,10 @@ if ($_REQUEST['action'] == 'confirm_close' && $_REQUEST['confirm'] == 'yes')
} }
} }
if ($_REQUEST['action'] == 'confirm_reopen' && $_REQUEST['confirm'] == 'yes') if (GETPOST('action') == 'confirm_reopen' && GETPOST('confirm') == 'yes')
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET["id"]); $project->fetch(GETPOST("id"));
$result = $project->setValid($user, $conf->projet->outputdir); $result = $project->setValid($user, $conf->projet->outputdir);
if ($result <= 0) if ($result <= 0)
{ {
@ -206,10 +206,10 @@ if ($_REQUEST['action'] == 'confirm_reopen' && $_REQUEST['confirm'] == 'yes')
} }
} }
if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == "yes" && $user->rights->projet->supprimer) if (GETPOST("action") == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer)
{ {
$project = new Project($db); $project = new Project($db);
$project->fetch($_GET["id"]); $project->fetch(GETPOST("id"));
$result=$project->delete($user); $result=$project->delete($user);
if ($result > 0) if ($result > 0)
{ {
@ -271,7 +271,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
// Customer // Customer
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
print $html->select_societes($_REQUEST["socid"],'socid','',1,1); print $html->select_societes(GETPOST("socid"),'socid','',1,1);
print '</td></tr>'; print '</td></tr>';
// Public // Public
@ -407,8 +407,11 @@ else
// Ref // Ref
print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>'; print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>';
// Define a complementary filter for search of next/prev ref. // Define a complementary filter for search of next/prev ref.
if (! $user->rights->projet->all->lire)
{
$projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1); $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,1);
$project->next_prev_filter=" rowid in (".$projectsListId.")"; $project->next_prev_filter=" rowid in (".$projectsListId.")";
}
print $html->showrefnav($project,'ref','',1,'ref','ref'); print $html->showrefnav($project,'ref','',1,'ref','ref');
print '</td></tr>'; print '</td></tr>';
@ -448,7 +451,7 @@ else
print '</table>'; print '</table>';
} }
print '</div>'; dol_fiche_end();
/* /*
* Boutons actions * Boutons actions