3 * Task Mgr And Tracker Integration
5 * Copyright 2003 GForge, LLC
6 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
7 * http://fusionforge.org
9 * This file is part of FusionForge. FusionForge is free software;
10 * you can redistribute it and/or modify it under the terms of the
11 * GNU General Public License as published by the Free Software
12 * Foundation; either version 2 of the Licence, or (at your option)
15 * FusionForge is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License along
21 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 require_once $gfcommon.'pm/ProjectGroupFactory.class.php';
26 require_once $gfcommon.'pm/ProjectTaskFactory.class.php';
28 $group_project_id = getIntFromRequest('group_project_id');
29 $project_task_id = getIntFromRequest('project_task_id');
30 $aid = getIntFromRequest('aid');
32 $a=new Artifact($ath,$aid);
33 if (!$a || !is_object($a)) {
34 exit_error(_('Artifact Could Not Be Created'),'tracker');
38 // Add a relationship from this artifact to an existing task
40 if (getStringFromRequest('add_to_task')) {
41 $offset = getStringFromRequest('offset');
42 $_order = getStringFromRequest('_order');
43 $max_rows = getIntFromRequest('max_rows');
44 $set = getStringFromRequest('set');
45 $_assigned_to = getStringFromRequest('_assigned_to');
46 $_status = getStringFromRequest('_status');
47 $_category_id = getIntFromRequest('_category_id');
49 // $group object is created in tracker.php
51 $pg=new ProjectGroup($group,$group_project_id);
52 if (!$pg || !is_object($pg)) {
53 exit_error(_('Could Not Get ProjectGroup'),'tracker');
54 } elseif ($pg->isError()) {
55 exit_error($pg->getErrorMessage(),'tracker');
58 $ptf = new ProjectTaskFactory($pg);
59 if (!$ptf || !is_object($ptf)) {
60 exit_error(_('Could Not Get ProjectTaskFactory'),'tracker');
61 } elseif ($ptf->isError()) {
62 exit_error($ptf->getErrorMessage(),'tracker');
65 $ptf->setup($offset,$_order,$max_rows,$set,$_assigned_to,$_status,$_category_id);
66 if ($ptf->isError()) {
67 exit_error($ptf->getErrorMessage(),'tracker');
70 $pt_arr =& $ptf->getTasks();
72 if ($ptf->isError()) {
73 exit_error($ptf->getErrorMessage(),'tracker');
75 exit_error(_('No Available Tasks Found'),'tracker');
79 $related_tasks = $a->getRelatedTasks();
81 while ($row = db_fetch_array($related_tasks)) {
82 $skip[$row['project_task_id']] = true;
85 foreach($pt_arr as $p) {
87 if (!isset($skip[$id])) {
92 exit_error(_('No Available Tasks Found'));
95 $ath->header(array('titlevals'=>array($ath->getName()),
96 'atid'=>$ath->getID(),
97 'title'=>_('Build Relationship Between Tracker Items and Tasks')));
100 <form name="foo" action="'. getStringFromServer('PHP_SELF') .'?func=taskmgr&group_id='.$group_id.'&atid='.$atid.'&aid='.$aid.'" method="post">
101 <p><strong>'._('Tracker Item').':</strong> [#'.$a->getID().'] '.$a->getSummary().'</p>
102 <p><strong>'._('Tasks Project').':</strong><br />';
103 echo $pg->getName().'
104 <input type="hidden" name="group_project_id" value="'.$pg->getID().'" /></p>
106 <strong>'._('Task').':</strong></p>
107 <select name="project_task_id">';
108 foreach($tasks as $task) {
109 echo '<option value="'.$task->getID().'">'.$task->getSummary().'</option>';
111 echo '</select><br />
112 <input type="submit" name="done_adding" value="'._('Add Relationship to Selected Task') . '" />
116 // Add the relationship and display finished message
118 } elseif (getStringFromRequest('done_adding')) {
120 session_redirect('/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id.'&project_task_id='.$project_task_id.'&func=addartifact&add_artifact_id='. $a->getID());
123 // Create a new task and relate it to this artifact
125 } elseif (getStringFromRequest('new_task')) {
127 session_redirect ('/pm/task.php?group_id='.$group_id.'&group_project_id='.$group_project_id.'&func=addtask&related_artifact_summary='. urlencode($a->getSummary()) .'&related_artifact_id='. $a->getID());
130 // Show the list of ProjectGroups available
134 $pgf=new ProjectGroupFactory($group);
135 if (!$pgf || !is_object($pgf)) {
136 exit_error(_('Could Not Get Factory'),'tracker');
137 } elseif ($pgf->isError()) {
138 exit_error($pgf->getErrorMessage(),'tracker');
141 $pg_arr = $pgf->getProjectGroups();
143 if ($pgf->isError()) {
144 exit_error($pgf->getErrorMessage(),'tracker');
146 exit_error(_('No Existing Project Groups Found'),'tracker');
150 $ath->header(array('titlevals'=>array($ath->getName()),
151 'atid'=>$ath->getID(),
152 'title'=>_('Build Relationship Between Tracker Items and Tasks')));
154 echo '<form name="foo" action="'. getStringFromServer('PHP_SELF') .'?func=taskmgr&group_id='.$group_id.'&atid='.$atid.'&aid='.$aid.'" method="post">
155 <p><strong>'._('Tracker Item').':</strong> [#'.$a->getID().'] '.$a->getSummary().'</p>
156 <p><strong>'._('Tasks Project').':</strong></p>
157 <select name="group_project_id">';
158 for ($i=0; $i<count($pg_arr); $i++) {
159 echo '<option value="'.$pg_arr[$i]->getID().'">'.$pg_arr[$i]->getName().'</option>';
163 <input type="submit" name="add_to_task" value="'._('Add Relation to Existing Task').'" />
164 <input type="submit" name="new_task" value="'._('Create New Task').'" />
170 $ath->footer(array());