diff --git a/htdocs/projet/tasks/comment.php b/htdocs/projet/tasks/comment.php index aaa8bd0cd8916..76c5239fc1766 100644 --- a/htdocs/projet/tasks/comment.php +++ b/htdocs/projet/tasks/comment.php @@ -47,13 +47,6 @@ $project_ref = GETPOST('project_ref', 'alpha'); $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); -// Security check -$socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -if (!$user->rights->projet->lire) { - accessforbidden(); -} - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcommentcard', 'globalcard')); @@ -79,10 +72,21 @@ } } + +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +// Security check +$socid = 0; + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + + + /* * View -*/ - + */ llxHeader('', $langs->trans("CommentPage")); diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 3aa5c3b88305f..1f74d1bbc75a4 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -40,16 +40,17 @@ $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); +$object = new Task($db); +$projectstatic = new Project($db); + +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + // Security check $socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -//$result = restrictedArea($user, 'projet', $id, 'projet_task'); -if (!$user->rights->projet->lire) { - accessforbidden(); -} -$object = new Task($db); -$projectstatic = new Project($db); +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); /* diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index d9c49001dfc54..3a56a7a018aa8 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -37,21 +37,13 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +$mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $withproject = GETPOST('withproject', 'int'); $project_ref = GETPOST('project_ref', 'alpha'); -// Security check -$socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -//$result=restrictedArea($user,'projet',$id,''); -if (!$user->rights->projet->lire) { - accessforbidden(); -} - // Get parameters $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); @@ -73,6 +65,17 @@ $object = new Task($db); $projectstatic = new Project($db); +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +// Security check +$socid = 0; + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + + + /* * Actions */ @@ -92,25 +95,21 @@ } if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref) > 0) { - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { - $object->fetchComments(); - } - $projectstatic->fetch($object->fk_project); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } + $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } - $object->project = clone $projectstatic; + $object->project = clone $projectstatic; - $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref); - } else { - dol_print_error($db); - } + $upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref); } include DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php'; diff --git a/htdocs/projet/tasks/note.php b/htdocs/projet/tasks/note.php index 4d581afc30a42..3ad4aaa3b7b53 100644 --- a/htdocs/projet/tasks/note.php +++ b/htdocs/projet/tasks/note.php @@ -31,7 +31,7 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); -$mine = $_REQUEST['mode'] == 'mine' ? 1 : 0; +$mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); @@ -82,6 +82,12 @@ } } +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + $permissionnote = ($user->rights->projet->creer || $user->rights->projet->all->creer); diff --git a/htdocs/projet/tasks/task.php b/htdocs/projet/tasks/task.php index 780d387512e59..b31ba6f0e7be8 100644 --- a/htdocs/projet/tasks/task.php +++ b/htdocs/projet/tasks/task.php @@ -46,13 +46,6 @@ $project_ref = GETPOST('project_ref', 'alpha'); $planned_workload = ((GETPOST('planned_workloadhour', 'int') != '' || GETPOST('planned_workloadmin', 'int') != '') ? (GETPOST('planned_workloadhour', 'int') > 0 ?GETPOST('planned_workloadhour', 'int') * 3600 : 0) + (GETPOST('planned_workloadmin', 'int') > 0 ?GETPOST('planned_workloadmin', 'int') * 60 : 0) : ''); -// Security check -$socid = 0; -//if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. -if (!$user->rights->projet->lire) { - accessforbidden(); -} - // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('projecttaskcard', 'globalcard')); @@ -69,6 +62,17 @@ setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } +if ($id > 0 || $ref) { + $object->fetch($id, $ref); +} + +// Security check +$socid = 0; + +restrictedArea($user, 'projet', $object->fk_project, 'projet&project'); + + + /* * Actions */ @@ -85,7 +89,6 @@ setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors'); } if (!$error) { - $object->fetch($id, $ref); $object->oldcopy = clone $object; $tmparray = explode('_', $_POST['task_parent']); @@ -121,17 +124,15 @@ } if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->projet->supprimer) { - if ($object->fetch($id, $ref) >= 0) { - $result = $projectstatic->fetch($object->fk_project); - $projectstatic->fetch_thirdparty(); + $result = $projectstatic->fetch($object->fk_project); + $projectstatic->fetch_thirdparty(); - if ($object->delete($user) > 0) { - header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : '')); - exit; - } else { - setEventMessages($object->error, $object->errors, 'errors'); - $action = ''; - } + if ($object->delete($user) > 0) { + header('Location: '.DOL_URL_ROOT.'/projet/tasks.php?restore_lastsearch_values=1&id='.$projectstatic->id.($withproject ? '&withproject=1' : '')); + exit; + } else { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; } } @@ -149,8 +150,6 @@ // Build doc if ($action == 'builddoc' && $user->rights->projet->creer) { - $object->fetch($id, $ref); - // Save last template used to generate document if (GETPOST('model')) { $object->setDocModel($user, GETPOST('model', 'alpha')); @@ -172,17 +171,15 @@ if ($action == 'remove_file' && $user->rights->projet->creer) { require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if ($object->fetch($id, $ref) >= 0) { - $langs->load("other"); - $upload_dir = $conf->projet->dir_output; - $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file')); + $langs->load("other"); + $upload_dir = $conf->projet->dir_output; + $file = $upload_dir.'/'.dol_sanitizeFileName(GETPOST('file')); - $ret = dol_delete_file($file); - if ($ret) { - setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); - } else { - setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); - } + $ret = dol_delete_file($file); + if ($ret) { + setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs'); + } else { + setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors'); } } @@ -198,452 +195,450 @@ $formfile = new FormFile($db); if ($id > 0 || !empty($ref)) { - if ($object->fetch($id, $ref) > 0) { - $res = $object->fetch_optionals(); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { - $object->fetchComments(); - } + $res = $object->fetch_optionals(); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK) && method_exists($object, 'fetchComments') && empty($object->comments)) { + $object->fetchComments(); + } - $result = $projectstatic->fetch($object->fk_project); - if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { - $projectstatic->fetchComments(); - } - if (!empty($projectstatic->socid)) { - $projectstatic->fetch_thirdparty(); - } + $result = $projectstatic->fetch($object->fk_project); + if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($projectstatic, 'fetchComments') && empty($projectstatic->comments)) { + $projectstatic->fetchComments(); + } + if (!empty($projectstatic->socid)) { + $projectstatic->fetch_thirdparty(); + } - $object->project = clone $projectstatic; + $object->project = clone $projectstatic; - //$userWrite = $projectstatic->restrictedProjectArea($user, 'write'); + //$userWrite = $projectstatic->restrictedProjectArea($user, 'write'); - if (!empty($withproject)) { - // Tabs for project - $tab = 'tasks'; - $head = project_prepare_head($projectstatic); - print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); + if (!empty($withproject)) { + // Tabs for project + $tab = 'tasks'; + $head = project_prepare_head($projectstatic); + print dol_get_fiche_head($head, $tab, $langs->trans("Project"), -1, ($projectstatic->public ? 'projectpub' : 'project'), 0, '', ''); - $param = ($mode == 'mine' ? '&mode=mine' : ''); + $param = ($mode == 'mine' ? '&mode=mine' : ''); - // Project card + // Project card - $linkback = ''.$langs->trans("BackToList").''; + $linkback = ''.$langs->trans("BackToList").''; - $morehtmlref = '
'; - print $langs->trans("Usage"); - print ' | '; - print '';
- if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
- print 'usage_opportunity ? ' checked="checked"' : '')).'"> ';
- $htmltext = $langs->trans("ProjectFollowOpportunity");
- print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
- print ' '; - } - if (empty($conf->global->PROJECT_HIDE_TASKS)) { - print 'usage_task ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectFollowTasks"); - print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); - print ' '; - } - if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { - print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("ProjectBillTimeDescription"); - print $form->textwithpicto($langs->trans("BillTime"), $htmltext); - print ' '; - } - if (!empty($conf->eventorganization->enabled)) { - print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; - $htmltext = $langs->trans("EventOrganizationDescriptionLong"); - print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); - } - print ' |
'.$langs->trans("Visibility").' | '; - if ($projectstatic->public) { - print $langs->trans('SharedProject'); - } else { - print $langs->trans('PrivateProject'); - } - print ' |
'.$langs->trans("DateStart").' - '.$langs->trans("DateEnd").' | '; - $start = dol_print_date($projectstatic->date_start, 'day'); - print ($start ? $start : '?'); - $end = dol_print_date($projectstatic->date_end, 'day'); - print ' - '; - print ($end ? $end : '?'); - if ($projectstatic->hasDelay()) { - print img_warning("Late"); - } - print ' |
'.$langs->trans("Budget").' | '; - if (strcmp($projectstatic->budget_amount, '')) { - print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + // Usage + if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES) || empty($conf->global->PROJECT_HIDE_TASKS) || !empty($conf->eventorganization->enabled)) { + print ' |
'; + print $langs->trans("Usage"); + print ' | '; + print '';
+ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
+ print 'usage_opportunity ? ' checked="checked"' : '')).'"> ';
+ $htmltext = $langs->trans("ProjectFollowOpportunity");
+ print $form->textwithpicto($langs->trans("ProjectFollowOpportunity"), $htmltext);
+ print ' '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS)) { + print 'usage_task ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectFollowTasks"); + print $form->textwithpicto($langs->trans("ProjectFollowTasks"), $htmltext); + print ' '; + } + if (empty($conf->global->PROJECT_HIDE_TASKS) && !empty($conf->global->PROJECT_BILL_TIME_SPENT)) { + print 'usage_bill_time ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("ProjectBillTimeDescription"); + print $form->textwithpicto($langs->trans("BillTime"), $htmltext); + print ' '; + } + if (!empty($conf->eventorganization->enabled)) { + print 'usage_organize_event ? ' checked="checked"' : '')).'"> '; + $htmltext = $langs->trans("EventOrganizationDescriptionLong"); + print $form->textwithpicto($langs->trans("ManageOrganizeEvent"), $htmltext); } print ' |
'.$langs->trans("Budget").' | '; + if (strcmp($projectstatic->budget_amount, '')) { + print price($projectstatic->budget_amount, '', $langs, 1, 0, 0, $conf->currency); + } + print ' | '.$langs->trans("Description").' | '; - print nl2br($projectstatic->description); - print ' | '; + // Other attributes + $cols = 2; + //include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; - // Categories - if ($conf->categorie->enabled) { - print '
'.$langs->trans("Categories").' | '; - print $form->showCategories($projectstatic->id, 'project', 1); - print " |
'.$langs->trans("Description").' | '; + print nl2br($projectstatic->description); + print ' | '; - print '
'.$langs->trans("Categories").' | '; + print $form->showCategories($projectstatic->id, 'project', 1); + print " |