Fix: limit view for external user
This commit is contained in:
parent
06b9e9cd24
commit
11e10a1c8c
@ -468,13 +468,13 @@ class Project extends CommonObject
|
||||
* @param mode 0=Return list of tasks and their projects, 1=Return projects and tasks if exists
|
||||
* @return array Array of tasks
|
||||
*/
|
||||
function getTasksArray($usert=0, $userp=0, $mode=0)
|
||||
function getTasksArray($usert=0, $userp=0, $mode=0, $socid=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$tasks = array();
|
||||
|
||||
//print $usert.'-'.$userp;
|
||||
//print $usert.'-'.$userp.'<br>';
|
||||
|
||||
// List of tasks
|
||||
$sql = "SELECT p.rowid as projectid, p.ref, p.title as ptitle,";
|
||||
@ -492,6 +492,7 @@ class Project extends CommonObject
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as up on p.fk_user_resp = up.rowid";
|
||||
$sql.= " WHERE t.fk_projet = p.rowid";
|
||||
$sql.= " AND p.entity = ".$conf->entity;
|
||||
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
|
||||
if ($this->id) $sql .= " AND t.fk_projet =".$this->id;
|
||||
if (is_object($usert)) $sql .= " AND ta.fk_projet_task = t.rowid AND ta.fk_user = ".$usert->id;
|
||||
if (is_object($userp)) $sql .= " AND (p.fk_user_resp = ".$userp->id." OR p.fk_user_resp IS NULL OR p.fk_user_resp = -1)";
|
||||
@ -513,12 +514,13 @@ class Project extends CommonObject
|
||||
}
|
||||
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as up on p.fk_user_resp = up.rowid";
|
||||
$sql.= " WHERE p.entity = ".$conf->entity;
|
||||
if ($socid) $sql.= " AND p.fk_soc = ".$socid;
|
||||
if ($this->id) $sql .= " AND t.fk_projet =".$this->id;
|
||||
if (is_object($usert)) $sql .= " AND t.fk_projet = p.rowid AND ta.fk_projet_task = t.rowid AND ta.fk_user = ".$usert->id;
|
||||
if (is_object($userp)) $sql .= " AND (p.fk_user_resp = ".$userp->id." OR p.fk_user_resp IS NULL OR p.fk_user_resp = -1)";
|
||||
$sql.= " ORDER BY p.ref, t.title";
|
||||
}
|
||||
|
||||
|
||||
dol_syslog("Project::getTasksArray sql=".$sql, LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2006-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2009 Regis Houssin <regis@dolibarr.fr>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +21,7 @@
|
||||
/**
|
||||
* \file htdocs/projet/tasks/index.php
|
||||
* \ingroup project
|
||||
* \brief Fiche t<EFBFBD>ches d'un projet
|
||||
* \brief Fiche taches d'un projet
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
@ -78,15 +79,15 @@ llxHeader("",$title,"Projet");
|
||||
print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num);
|
||||
|
||||
|
||||
$projet = new Project($db);
|
||||
$project = new Project($db);
|
||||
|
||||
|
||||
// Get list of tasks in tasksarray and taskarrayfiltered
|
||||
// We need all tasks (even not limited to a user because a task to user
|
||||
// can have a parent that is not affected to him).
|
||||
$tasksarray=$projet->getTasksArray(0, 0, 0);
|
||||
$tasksarray=$project->getTasksArray(0, 0, 0, $socid);
|
||||
// We load also tasks limited to a particular user
|
||||
$tasksrole=($_REQUEST["mode"]=='mine' ? $projet->getTasksRoleForUser($user) : '');
|
||||
$tasksrole=($_REQUEST["mode"]=='mine' ? $project->getTasksRoleForUser($user) : '');
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
@ -107,11 +108,12 @@ print '</div>';
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?action=create">'.$langs->trans('AddTask').'</a>';
|
||||
print '</div>';
|
||||
|
||||
|
||||
if ($user->rights->projet->creer)
|
||||
{
|
||||
print '<div class="tabsAction">';
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/tasks/fiche.php?action=create">'.$langs->trans('AddTask').'</a>';
|
||||
print '</div>';
|
||||
}
|
||||
|
||||
$db->close();
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user