Fix: A lot of fix in project permissions

This commit is contained in:
Laurent Destailleur 2010-02-21 17:01:45 +00:00
parent fdda3198e1
commit bda51b47a6
9 changed files with 43 additions and 33 deletions

View File

@ -211,7 +211,7 @@ function select_projects($socid, $selected='', $htmlname='projectid')
* @param unknown_type $tasksrole * @param unknown_type $tasksrole
* @return unknown * @return unknown
*/ */
function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole) function PLinesb(&$inc, $parent, $lines, &$level, &$projectsrole)
{ {
global $user, $bc, $langs; global $user, $bc, $langs;
global $form; global $form;
@ -235,6 +235,8 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole)
print "<td>"; print "<td>";
$projectstatic->id=$lines[$i]->projectid; $projectstatic->id=$lines[$i]->projectid;
$projectstatic->ref=$lines[$i]->projectref; $projectstatic->ref=$lines[$i]->projectref;
$projectstatic->public=$lines[$i]->public;
$projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->projectid];
print $projectstatic->getNomUrl(1); print $projectstatic->getNomUrl(1);
print "</td>"; print "</td>";
@ -262,14 +264,17 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole)
print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n"; print '<td align="right">'.$heure."&nbsp;h&nbsp;".$minutes."</td>\n";
$disabled=1; $disabled=1;
//print "x".$lines[$i]->projectid;
//var_dump($lines[$i]);
//var_dump($projectsrole[$lines[$i]->projectid]);
// If at least one role for project // If at least one role for project
if (! empty($tasksrole[$lines[$i]->id]) if ($lines[$i]->public || ! empty($projectsrole[$lines[$i]->projectid])) $disabled=0;
&& sizeof($tasksrole[$lines[$i]->id]) > 0) $disabled=0;
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
print $form->select_date('',$lines[$i]->id,'','','',"addtime"); print $form->select_date('',$lines[$i]->id,'','','',"addtime");
print '&nbsp;<input size="4" type="text" class="flat"'.($disabled?' disabled="true"':'').' name="task'.$lines[$i]->id.'" value="">'; print '&nbsp;<input size="4" type="text" class="flat"'.($disabled?' disabled="true"':'').' name="task'.$lines[$i]->id.'" value="">';
print '&nbsp;<input type="submit" class="button"'.($disabled?' disabled="true"':'').' value="'.$langs->trans("Add").'">'; print '&nbsp;<input type="submit" class="button"'.($disabled?' disabled="true"':'').' value="'.$langs->trans("Add").'">';
if ((! $lines[$i]->public) && $disabled) print '('.$langs->trans("YouAreNotContactOfProject").')';
print '</td>'; print '</td>';
print "<td>&nbsp;"; print "<td>&nbsp;";
print '</td>'; print '</td>';
@ -277,7 +282,7 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole)
print "</tr>\n"; print "</tr>\n";
$inc++; $inc++;
$level++; $level++;
if ($lines[$i]->id) PLinesb($inc, $lines[$i]->id, $lines, $level, $tasksrole); if ($lines[$i]->id) PLinesb($inc, $lines[$i]->id, $lines, $level, $projectsrole);
$level--; $level--;
} }
else else
@ -298,7 +303,7 @@ function PLinesb(&$inc, $parent, $lines, &$level, &$tasksrole)
* @param $level Level of task * @param $level Level of task
* @param $var Color * @param $var Color
* @param $showproject Show project columns * @param $showproject Show project columns
* @param $taskrole Array of tasks filtered on a particular user * @param $taskrole Array of roles of user for each tasks
*/ */
function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole) function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole)
{ {
@ -358,9 +363,11 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole
if ($showproject) if ($showproject)
{ {
print "<td>"; print "<td>";
//var_dump($taskrole);
if ($showlineingray) print '<i>'; if ($showlineingray) print '<i>';
$projectstatic->id=$lines[$i]->projectid; $projectstatic->id=$lines[$i]->projectid;
$projectstatic->ref=$lines[$i]->projectref; $projectstatic->ref=$lines[$i]->projectref;
$projectstatic->public=$lines[$i]->public;
print $projectstatic->getNomUrl(1); print $projectstatic->getNomUrl(1);
if ($showlineingray) print '</i>'; if ($showlineingray) print '</i>';
print "</td>"; print "</td>";
@ -376,6 +383,7 @@ function PLines(&$inc, $parent, &$lines, &$level, $var, $showproject, &$taskrole
{ {
$taskstatic->id=$lines[$i]->id; $taskstatic->id=$lines[$i]->id;
$taskstatic->ref=$lines[$i]->id; $taskstatic->ref=$lines[$i]->id;
$taskstatic->label=($taskrole[$lines[$i]->id]?$langs->trans("YourRole").': '.$taskrole[$lines[$i]->id]:'');
print $taskstatic->getNomUrl(1); print $taskstatic->getNomUrl(1);
} }
print '</td>'; print '</td>';

View File

@ -112,9 +112,9 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorde
if ($mesg) print $mesg; if ($mesg) print $mesg;
$tasksarray=$task->getTasksArray(0,0,$project->id,$socid); $tasksarray=$task->getTasksArray(0,0,$project->id,$socid);
$tasksrole=$task->getUserRolesForProjectsOrTasks($user,0,$project->id,0); $projectsrole=$task->getUserRolesForProjectsOrTasks($user,0,$project->id,0);
//var_dump($tasksarray); //var_dump($tasksarray);
//var_dump($tasksrole); //var_dump($projectsrole);
print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'">'; print '<form name="addtime" method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$project->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -128,7 +128,7 @@ print '<td>'.$langs->trans("LabelTask").'</td>';
print '<td align="right">'.$langs->trans("TimeSpent").'</td>'; print '<td align="right">'.$langs->trans("TimeSpent").'</td>';
print '<td colspan="2">'.$langs->trans("AddDuration").'</td>'; print '<td colspan="2">'.$langs->trans("AddDuration").'</td>';
print "</tr>\n"; print "</tr>\n";
PLinesb($j, 0, $tasksarray, $level, $tasksrole); PLinesb($j, 0, $tasksarray, $level, $projectsrole);
print '</form>'; print '</form>';

View File

@ -179,7 +179,7 @@ if ($id > 0 || ! empty($ref))
$userAccess = $project->restrictedProjectArea($user); $userAccess = $project->restrictedProjectArea($user);
$head = project_prepare_head($project); $head = project_prepare_head($project);
dol_fiche_head($head, 'contact', $langs->trans("Project"), 0, 'project'); dol_fiche_head($head, 'contact', $langs->trans("Project"), 0, ($project->public?'projectpub':'project'));
/* /*

View File

@ -73,7 +73,7 @@ $project->societe->fetch($project->societe->id);
$userAccess = $project->restrictedProjectArea($user); $userAccess = $project->restrictedProjectArea($user);
$head=project_prepare_head($project); $head=project_prepare_head($project);
dol_fiche_head($head, 'element', $langs->trans("Project"),0,'project'); dol_fiche_head($head, 'element', $langs->trans("Project"),0,($project->public?'projectpub':'project'));
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -318,7 +318,7 @@ else
$userAccess = $project->restrictedProjectArea($user); $userAccess = $project->restrictedProjectArea($user);
$head=project_prepare_head($project); $head=project_prepare_head($project);
dol_fiche_head($head, 'project', $langs->trans("Project"),0,'project'); dol_fiche_head($head, 'project', $langs->trans("Project"),0,($project->public?'projectpub':'project'));
// Confirmation validation // Confirmation validation
if ($_GET['action'] == 'validate') if ($_GET['action'] == 'validate')

View File

@ -109,7 +109,7 @@ if ($id > 0 || ! empty($ref))
$userAccess = $project->restrictedProjectArea($user); $userAccess = $project->restrictedProjectArea($user);
$head = project_prepare_head($project); $head = project_prepare_head($project);
dol_fiche_head($head, 'note', $langs->trans('Project'), 0, 'project'); dol_fiche_head($head, 'note', $langs->trans('Project'), 0, ($project->public?'projectpub':'project'));
print '<table class="border" width="100%">'; print '<table class="border" width="100%">';

View File

@ -519,9 +519,10 @@ class Project extends CommonObject
$lien = '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$this->id.'">'; $lien = '<a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$this->id.'">';
$lienfin='</a>'; $lienfin='</a>';
$picto='project'; $picto='projectpub';
if (! $this->public) $picto='project';
$label=$langs->trans("ShowProject").': '.$this->ref; $label=$langs->trans("ShowProject").': '.$this->ref.($this->label?' - '.$this->label:'');
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto && $withpicto != 2) $result.=' ';

View File

@ -206,7 +206,7 @@ else
if ($_REQUEST["mode"]=='mine') $tab='mytasks'; if ($_REQUEST["mode"]=='mine') $tab='mytasks';
$head=project_prepare_head($project); $head=project_prepare_head($project);
dol_fiche_head($head, $tab, $langs->trans("Project"),0,'project'); dol_fiche_head($head, $tab, $langs->trans("Project"),0,($project->public?'projectpub':'project'));
$param=($_REQUEST["mode"]=='mine'?'&mode=mine':''); $param=($_REQUEST["mode"]=='mine'?'&mode=mine':'');

View File

@ -398,7 +398,7 @@ class Task extends CommonObject
$picto='projecttask'; $picto='projecttask';
$label=$langs->trans("ShowTask").': '.$this->ref; $label=$langs->trans("ShowTask").': '.$this->ref.($this->label?' - '.$this->label:'');
if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin); if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
if ($withpicto && $withpicto != 2) $result.=' '; if ($withpicto && $withpicto != 2) $result.=' ';
@ -520,6 +520,7 @@ class Task extends CommonObject
*/ */
function getUserRolesForProjectsOrTasks($userp,$usert,$projectid=0,$taskid=0) function getUserRolesForProjectsOrTasks($userp,$usert,$projectid=0,$taskid=0)
{ {
$projectsrole = array();
$tasksrole = array(); $tasksrole = array();
dol_syslog("Task::getUserRolesForProjectsOrTasks userp=".is_object($userp)." usert=".is_object($usert)." projectid=".$projectid." taskid=".$taskid); dol_syslog("Task::getUserRolesForProjectsOrTasks userp=".is_object($userp)." usert=".is_object($usert)." projectid=".$projectid." taskid=".$taskid);
@ -531,8 +532,8 @@ class Task extends CommonObject
return -1; return -1;
} }
/* Liste des taches et role sur la tache du user courant dans $tasksrole */ /* Liste des taches et role sur les projets ou taches */
$sql = "SELECT ec.element_id, ctc.code"; $sql = "SELECT pt.rowid as pid, ec.element_id, ctc.code";
if ($userp) $sql.= " FROM ".MAIN_DB_PREFIX."projet as pt"; if ($userp) $sql.= " FROM ".MAIN_DB_PREFIX."projet as pt";
if ($usert) $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt"; if ($usert) $sql.= " FROM ".MAIN_DB_PREFIX."projet_task as pt";
$sql.= ", ".MAIN_DB_PREFIX."element_contact as ec"; $sql.= ", ".MAIN_DB_PREFIX."element_contact as ec";
@ -546,8 +547,8 @@ class Task extends CommonObject
$sql.= " AND ec.statut = 4"; $sql.= " AND ec.statut = 4";
if ($projectid) if ($projectid)
{ {
if ($userp || $usert) $sql.= " AND pt.fk_projet = ".$projectid; if ($userp) $sql.= " AND pt.rowid = ".$projectid;
//if ($usert) $sql.= " AND pt.rowid = ".$taskid; //if ($usert) $sql.= " AND pt.fk_projet = ".$projectid;
} }
if ($taskid) if ($taskid)
{ {
@ -564,9 +565,9 @@ class Task extends CommonObject
$i = 0; $i = 0;
while ($i < $num) while ($i < $num)
{ {
$row = $this->db->fetch_row($resql); $obj = $this->db->fetch_object($resql);
if (empty($tasksrole[$row[0]])) $tasksrole[$row[0]] = $row[1]; if (empty($projectsrole[$obj->pid])) $projectsrole[$obj->pid] = $obj->code;
else $tasksrole[$row[0]].=','.$row[1]; else $projectsrole[$obj->pid].=','.$obj->code;
$i++; $i++;
} }
$this->db->free($resql); $this->db->free($resql);
@ -576,7 +577,7 @@ class Task extends CommonObject
dol_print_error($this->db); dol_print_error($this->db);
} }
return $tasksrole; return $projectsrole;
} }
/** /**