diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index e1f2d7104b8..e4b672d355d 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -914,7 +914,7 @@ if ($id > 0 || ! empty($ref)) print ''; - if ($_GET['action'] != 'classer' && $commande->brouillon) print ''; + if ($_GET['action'] != 'classer') print ''; print '
'; print $langs->trans('Project'); print ''.img_edit($langs->trans('SetProject')).''.img_edit($langs->trans('SetProject')).'
'; print ''; if ($_GET['action'] == 'classer') diff --git a/htdocs/includes/menus/barre_left/eldy.lib.php b/htdocs/includes/menus/barre_left/eldy.lib.php index a0a06f930d6..5b066fc71a6 100644 --- a/htdocs/includes/menus/barre_left/eldy.lib.php +++ b/htdocs/includes/menus/barre_left/eldy.lib.php @@ -712,23 +712,27 @@ function print_left_eldy_menu($db,$menu_array) { $langs->load("projects"); + // Project affected to user $newmenu->add(DOL_URL_ROOT."/projet/index.php?leftmenu=projects&mode=mine", $langs->trans("MyProjects"), 0, $user->rights->projet->lire); $newmenu->add(DOL_URL_ROOT."/projet/fiche.php?leftmenu=projects&action=create&mode=mine", $langs->trans("NewProject"), 1, $user->rights->projet->creer); $newmenu->add(DOL_URL_ROOT."/projet/liste.php?leftmenu=projects&mode=mine", $langs->trans("List"), 1, $user->rights->projet->lire); - $newmenu->add(DOL_URL_ROOT."/projet/index.php?leftmenu=projects", $langs->trans("Projects"), 0, $user->rights->projet->lire && $user->rights->projet->all->lire); - $newmenu->add(DOL_URL_ROOT."/projet/fiche.php?leftmenu=projects&action=create", $langs->trans("NewProject"), 1, $user->rights->projet->creer && $user->rights->projet->all->creer); - $newmenu->add(DOL_URL_ROOT."/projet/liste.php?leftmenu=projects", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->all->lire); + // All project i have permission on + $newmenu->add(DOL_URL_ROOT."/projet/index.php?leftmenu=projects", $langs->trans("Projects"), 0, $user->rights->projet->lire && $user->rights->projet->lire); + $newmenu->add(DOL_URL_ROOT."/projet/fiche.php?leftmenu=projects&action=create", $langs->trans("NewProject"), 1, $user->rights->projet->creer && $user->rights->projet->creer); + $newmenu->add(DOL_URL_ROOT."/projet/liste.php?leftmenu=projects", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->lire); + // Project affected to user $newmenu->add(DOL_URL_ROOT."/projet/activity/index.php?mode=mine", $langs->trans("MyActivities"), 0, $user->rights->projet->lire); $newmenu->add(DOL_URL_ROOT."/projet/tasks/fiche.php?action=create&mode=mine", $langs->trans("NewTask"), 1, $user->rights->projet->creer); $newmenu->add(DOL_URL_ROOT."/projet/tasks/index.php?mode=mine", $langs->trans("List"), 1, $user->rights->projet->lire); $newmenu->add(DOL_URL_ROOT."/projet/activity/list.php?mode=mine", $langs->trans("NewTimeSpent"), 1, $user->rights->projet->creer); - $newmenu->add(DOL_URL_ROOT."/projet/activity/index.php", $langs->trans("Activities"), 0, $user->rights->projet->lire && $user->rights->projet->all->lire); - $newmenu->add(DOL_URL_ROOT."/projet/tasks/fiche.php?action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer && $user->rights->projet->all->creer); - $newmenu->add(DOL_URL_ROOT."/projet/tasks/index.php", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->all->lire); - $newmenu->add(DOL_URL_ROOT."/projet/activity/list.php", $langs->trans("NewTimeSpent"), 1, $user->rights->projet->creer && $user->rights->projet->all->creer); + // All project i have permission on + $newmenu->add(DOL_URL_ROOT."/projet/activity/index.php", $langs->trans("Activities"), 0, $user->rights->projet->lire && $user->rights->projet->lire); + $newmenu->add(DOL_URL_ROOT."/projet/tasks/fiche.php?action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer && $user->rights->projet->creer); + $newmenu->add(DOL_URL_ROOT."/projet/tasks/index.php", $langs->trans("List"), 1, $user->rights->projet->lire && $user->rights->projet->lire); + $newmenu->add(DOL_URL_ROOT."/projet/activity/list.php", $langs->trans("NewTimeSpent"), 1, $user->rights->projet->creer && $user->rights->projet->creer); } } diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php index 66b7cc7a02b..7fef80cf6fb 100644 --- a/htdocs/lib/project.lib.php +++ b/htdocs/lib/project.lib.php @@ -165,20 +165,28 @@ function task_prepare_head($object) /** - * \brief Show a combo list with projects qualified for a third party) - * \param socid Id third party (-1=all, 0=projects not linked to a third party, id=projects not linked or linked to third party id) + * \brief Show a combo list with projects qualified for a third party + * \param socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id) * \param selected Id project preselected * \param htmlname Nom de la zone html - * \return int Nbre de projet si ok, <0 si ko + * \return int Nbre of project if OK, <0 if KO */ function select_projects($socid=-1, $selected='', $htmlname='projectid') { global $db,$user,$conf,$langs; + $projectstatic=new Project($db); + $projectsListId = ''; + if (empty($user->rights->projet->all->lire)) + { + $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); + } + // On recherche les projets $sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public'; $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p'; $sql.= " WHERE p.entity = ".$conf->entity; + if ($projectsListId) $sql.= " AND p.rowid in (".$projectsListId.")"; if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc='0' OR p.fk_soc IS NULL)"; $sql.= " ORDER BY p.title ASC"; @@ -211,6 +219,8 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid') print ' disabled="true"'; $labeltoshow.=' - '.$langs->trans("Draft"); } + //if ($obj->public) $labeltoshow.=' ('.$langs->trans("Public").')'; + //else $labeltoshow.=' ('.$langs->trans("Private").')'; print '>'.$labeltoshow.''; } $i++; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 33f24b02b07..7d5c3aa9bff 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -742,12 +742,14 @@ class Project extends CommonObject } /** - * Return array of projects authorized for a user + * Return array of projects affected to a user, authorized to a user, or all projects * - * @param unknown_type $user - * @return unknown + * @param user User object + * @param mode 0=All project I have permission on, 1=Affected to me only, 2=Will return list of all projects + * @param list 0=Return array,1=Return string list + * @return array or string */ - function getProjectsAuthorizedForUser($user,$mine=0,$list=0) + function getProjectsAuthorizedForUser($user,$mode=0,$list=0) { global $conf; @@ -760,14 +762,18 @@ class Project extends CommonObject $sql.= ", ".MAIN_DB_PREFIX."c_type_contact as ctc"; $sql.= " WHERE p.entity = ".$conf->entity; - if ($mine) + if ($mode == 2) + { + // No filter. Use this if user has permission to see all project + } + if ($mode == 1) { $sql.= " AND ec.element_id = p.rowid"; $sql.= " AND ctc.rowid = ec.fk_c_type_contact"; $sql.= " AND ctc.element = '".$this->element."'"; $sql.= " AND ec.fk_socpeople = ".$user->id; } - else + if ($mode == 0) { $sql.= " AND ( p.public = 1"; $sql.= " OR p.fk_user_creat = ".$user->id; diff --git a/htdocs/projet/contact.php b/htdocs/projet/contact.php index 7783583f8cf..24de6cea62e 100644 --- a/htdocs/projet/contact.php +++ b/htdocs/projet/contact.php @@ -42,7 +42,7 @@ if (empty($user->rights->projet->all->lire)) $_REQUEST["mode"]='mine'; } $mine = $_REQUEST['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 if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 1ee83a0ead4..272936e5568 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -42,7 +42,7 @@ if (empty($user->rights->projet->all->lire)) $_REQUEST["mode"]='mine'; } $mine = $_REQUEST['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 $socid=0; $id = isset($_GET["id"])?$_GET["id"]:''; if ($user->societe_id) $socid=$user->societe_id; diff --git a/htdocs/projet/element.php b/htdocs/projet/element.php index 87617117162..3efd230d1e3 100644 --- a/htdocs/projet/element.php +++ b/htdocs/projet/element.php @@ -64,7 +64,7 @@ if (empty($user->rights->projet->all->lire)) $_REQUEST["mode"]='mine'; } $mine = $_REQUEST['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 if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index ea9b2cee173..7c830b398c8 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -55,7 +55,7 @@ if (empty($user->rights->projet->all->lire)) $_REQUEST["mode"]='mine'; } $mine = $_REQUEST['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 if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); diff --git a/htdocs/projet/ganttview.php b/htdocs/projet/ganttview.php index 1b539081e8f..0fa9dcb3ae2 100644 --- a/htdocs/projet/ganttview.php +++ b/htdocs/projet/ganttview.php @@ -46,7 +46,7 @@ if (empty($user->rights->projet->all->lire)) $_REQUEST["mode"]='mine'; } $mine = $_REQUEST['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 if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); diff --git a/htdocs/projet/index.php b/htdocs/projet/index.php index f61312de7f0..76325a52eb5 100644 --- a/htdocs/projet/index.php +++ b/htdocs/projet/index.php @@ -35,7 +35,7 @@ $langs->load("projects"); $mine = $_REQUEST['mode']=='mine' ? 1 : 0; // Security check -if (! $user->rights->projet->all->lire) $mine=1; // Special for projects +//if (! $user->rights->projet->all->lire) $mine=1; // Special for projects if ($user->societe_id > 0) $socid = $user->societe_id; if (!$user->rights->projet->lire) accessforbidden(); @@ -57,6 +57,7 @@ if ($mine) $text=$langs->trans("MyProjects"); print_fiche_titre($text); +// Show description of content if ($mine) print $langs->trans("MyProjectsDesc").'

'; else { diff --git a/htdocs/projet/liste.php b/htdocs/projet/liste.php index 71ba379fbc8..0bdc1c882a2 100644 --- a/htdocs/projet/liste.php +++ b/htdocs/projet/liste.php @@ -107,6 +107,14 @@ if ($resql) if ($mine) $text=$langs->trans('MyProjects'); print_barre_liste($text, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num); + // Show description of content + if ($mine) print $langs->trans("MyProjectsDesc").'

'; + else + { + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'

'; + else print $langs->trans("ProjectsPublicDesc").'

'; + } + print ''; print ''; print_liste_field_titre($langs->trans("Ref"),$_SERVER["PHP_SELF"],"p.ref","","","",$sortfield,$sortorder); diff --git a/htdocs/projet/note.php b/htdocs/projet/note.php index 5655ba6fd2b..1ebb7ac8eca 100644 --- a/htdocs/projet/note.php +++ b/htdocs/projet/note.php @@ -39,7 +39,7 @@ if (empty($user->rights->projet->all->lire)) $_REQUEST["mode"]='mine'; } $mine = $_REQUEST['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 if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $id); diff --git a/htdocs/projet/tasks/fiche.php b/htdocs/projet/tasks/fiche.php index 73b5eec3805..5f15c6abb3d 100644 --- a/htdocs/projet/tasks/fiche.php +++ b/htdocs/projet/tasks/fiche.php @@ -43,7 +43,7 @@ if (empty($user->rights->projet->all->lire)) $_REQUEST["mode"]='mine'; } $mine = $_REQUEST['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 if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index dc2f345c1ce..348035bbb89 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -48,10 +48,11 @@ $page = $page == -1 ? 0 : $page; /* * View */ + $mine = $_REQUEST['mode']=='mine' ? 1 : 0; -$title=$langs->trans("Tasks"); -if ($mine) $title=$langs->trans("MyTasks"); +$title=$langs->trans("Activities"); +if ($mine) $title=$langs->trans("MyActivities"); llxHeader("",$title,"Projet"); @@ -68,6 +69,15 @@ if ($_GET["id"]) print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num); +// Show description of content +if ($mine) print $langs->trans("MyProjectsDesc").'

'; +else +{ + if ($user->rights->projet->all->lire && ! $socid) print $langs->trans("ProjectsDesc").'

'; + else print $langs->trans("ProjectsPublicDesc").'

'; +} + + // 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).