3 * Task Mgr And Tracker Integration
5 * Copyright 2003 GForge, LLC
6 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
7 * Copyright 2012,2015, Franck Villaume - TrivialDev
8 * http://fusionforge.org
10 * This file is part of FusionForge. FusionForge is free software;
11 * you can redistribute it and/or modify it under the terms of the
12 * GNU General Public License as published by the Free Software
13 * Foundation; either version 2 of the Licence, or (at your option)
16 * FusionForge is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 require_once $gfcommon.'pm/ProjectGroupFactory.class.php';
27 require_once $gfcommon.'pm/ProjectTaskFactory.class.php';
34 $group_project_id = getIntFromRequest('group_project_id');
35 $project_task_id = getIntFromRequest('project_task_id');
36 $aid = getIntFromRequest('aid');
38 $a = new Artifact($ath, $aid);
40 if (!$a || !is_object($a)) {
41 exit_error(_('Artifact Could Not Be Created'),'tracker');
45 // Add a relationship from this artifact to an existing task
47 if (getStringFromRequest('add_to_task')) {
48 $offset = getStringFromRequest('offset');
49 $_order = getStringFromRequest('_order');
50 $max_rows = getIntFromRequest('max_rows');
51 $set = getStringFromRequest('set');
52 $_assigned_to = getStringFromRequest('_assigned_to');
53 $_status = getStringFromRequest('_status');
54 $_category_id = getIntFromRequest('_category_id');
56 // $group object is created in tracker.php
58 $pg=new ProjectGroup($group,$group_project_id);
59 if (!$pg || !is_object($pg)) {
60 exit_error(_('Could Not Get ProjectGroup'),'tracker');
61 } elseif ($pg->isError()) {
62 exit_error($pg->getErrorMessage(),'tracker');
65 $ptf = new ProjectTaskFactory($pg);
66 if (!$ptf || !is_object($ptf)) {
67 exit_error(_('Could Not Get ProjectTaskFactory'),'tracker');
68 } elseif ($ptf->isError()) {
69 exit_error($ptf->getErrorMessage(),'tracker');
72 $ptf->setup($offset,$_order,$max_rows,$set,$_assigned_to,$_status,$_category_id);
73 if ($ptf->isError()) {
74 exit_error($ptf->getErrorMessage(),'tracker');
77 $pt_arr =& $ptf->getTasks();
79 if ($ptf->isError()) {
80 exit_error($ptf->getErrorMessage(),'tracker');
82 exit_error(_('No Available Tasks Found'),'tracker');
86 $related_tasks = $a->getRelatedTasks();
88 while ($row = db_fetch_array($related_tasks)) {
89 $skip[$row['project_task_id']] = true;
92 foreach($pt_arr as $p) {
94 if (!isset($skip[$id])) {
99 exit_error(_('No Available Tasks Found'));
102 $ath->header(array('titlevals'=>array($ath->getName()),
103 'atid'=>$ath->getID(),
104 'title'=>_('Build Relationship Between Tracker Items and Tasks'),
107 echo $HTML->openForm(array('name' => 'foo', 'action' => '/tracker/?func=taskmgr&group_id='.$group_id.'&atid='.$atid.'&aid='.$aid, 'method' => 'post'));
109 <p><strong>'._('Tracker Item')._(':').'</strong> [#'.$a->getID().'] '.$a->getSummary().'</p>
110 <p><strong>'._('Tasks Project')._(':').'</strong><br />';
111 echo $pg->getName().'
112 <input type="hidden" name="group_project_id" value="'.$pg->getID().'" /></p>
114 <strong>'._('Task')._(':').'</strong></p>
115 <select name="project_task_id">';
116 foreach($tasks as $task) {
117 echo '<option value="'.$task->getID().'">'.$task->getSummary().'</option>';
119 echo '</select><br />
120 <input type="submit" name="done_adding" value="'._('Add Relationship to Selected Task') . '" />';
121 echo $HTML->closeForm();
124 // Add the relationship and display finished message
126 } elseif (getStringFromRequest('done_adding')) {
128 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());
131 // Create a new task and relate it to this artifact
133 } elseif (getStringFromRequest('new_task')) {
135 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());
138 // Show the list of ProjectGroups available
142 $pgf = new ProjectGroupFactory($group);
143 if (!$pgf || !is_object($pgf)) {
144 exit_error(_('Could Not Get Factory'),'tracker');
145 } elseif ($pgf->isError()) {
146 exit_error($pgf->getErrorMessage(),'tracker');
149 $pg_arr = $pgf->getProjectGroups();
151 if ($pgf->isError()) {
152 exit_error($pgf->getErrorMessage(),'tracker');
154 exit_error(_('No Existing Project Groups Found'),'tracker');
158 $ath->header(array('titlevals'=>array($ath->getName()),
159 'atid'=>$ath->getID(),
160 'title'=>_('Build Relationship Between Tracker Items and Tasks'),
163 echo $HTML->openForm(array('name' => 'foo', 'action' => '/tracker/?func=taskmgr&group_id='.$group_id.'&atid='.$atid.'&aid='.$aid, 'method' => 'post'));
165 <p><strong>'._('Tracker Item')._(':').'</strong> [#'.$a->getID().'] '.$a->getSummary().'</p>
166 <p><strong>'._('Tasks Project')._(':').'</strong></p>
167 <select name="group_project_id">';
168 for ($i=0; $i<count($pg_arr); $i++) {
169 echo '<option value="'.$pg_arr[$i]->getID().'">'.$pg_arr[$i]->getName().'</option>';
173 <input type="submit" name="add_to_task" value="'._('Add Relation to Existing Task').'" />
174 <input type="submit" name="new_task" value="'._('Create New Task').'" />
176 echo $HTML->closeForm();