3 * Task Mgr And Tracker Integration
5 * Copyright 2003 GForge, LLC
6 * Copyright (C) 2011 Alain Peyrat - Alcatel-Lucent
7 * Copyright 2012, 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';
33 $group_project_id = getIntFromRequest('group_project_id');
34 $project_task_id = getIntFromRequest('project_task_id');
35 $aid = getIntFromRequest('aid');
37 $a = new Artifact($ath, $aid);
39 if (!$a || !is_object($a)) {
40 exit_error(_('Artifact Could Not Be Created'),'tracker');
44 // Add a relationship from this artifact to an existing task
46 if (getStringFromRequest('add_to_task')) {
47 $offset = getStringFromRequest('offset');
48 $_order = getStringFromRequest('_order');
49 $max_rows = getIntFromRequest('max_rows');
50 $set = getStringFromRequest('set');
51 $_assigned_to = getStringFromRequest('_assigned_to');
52 $_status = getStringFromRequest('_status');
53 $_category_id = getIntFromRequest('_category_id');
55 // $group object is created in tracker.php
57 $pg=new ProjectGroup($group,$group_project_id);
58 if (!$pg || !is_object($pg)) {
59 exit_error(_('Could Not Get ProjectGroup'),'tracker');
60 } elseif ($pg->isError()) {
61 exit_error($pg->getErrorMessage(),'tracker');
64 $ptf = new ProjectTaskFactory($pg);
65 if (!$ptf || !is_object($ptf)) {
66 exit_error(_('Could Not Get ProjectTaskFactory'),'tracker');
67 } elseif ($ptf->isError()) {
68 exit_error($ptf->getErrorMessage(),'tracker');
71 $ptf->setup($offset,$_order,$max_rows,$set,$_assigned_to,$_status,$_category_id);
72 if ($ptf->isError()) {
73 exit_error($ptf->getErrorMessage(),'tracker');
76 $pt_arr =& $ptf->getTasks();
78 if ($ptf->isError()) {
79 exit_error($ptf->getErrorMessage(),'tracker');
81 exit_error(_('No Available Tasks Found'),'tracker');
85 $related_tasks = $a->getRelatedTasks();
87 while ($row = db_fetch_array($related_tasks)) {
88 $skip[$row['project_task_id']] = true;
91 foreach($pt_arr as $p) {
93 if (!isset($skip[$id])) {
98 exit_error(_('No Available Tasks Found'));
101 $ath->header(array('titlevals'=>array($ath->getName()),
102 'atid'=>$ath->getID(),
103 'title'=>_('Build Relationship Between Tracker Items and Tasks')));
106 <form name="foo" action="'. getStringFromServer('PHP_SELF') .'?func=taskmgr&group_id='.$group_id.'&atid='.$atid.'&aid='.$aid.'" method="post">
107 <p><strong>'._('Tracker Item').':</strong> [#'.$a->getID().'] '.$a->getSummary().'</p>
108 <p><strong>'._('Tasks Project').':</strong><br />';
109 echo $pg->getName().'
110 <input type="hidden" name="group_project_id" value="'.$pg->getID().'" /></p>
112 <strong>'._('Task').':</strong></p>
113 <select name="project_task_id">';
114 foreach($tasks as $task) {
115 echo '<option value="'.$task->getID().'">'.$task->getSummary().'</option>';
117 echo '</select><br />
118 <input type="submit" name="done_adding" value="'._('Add Relationship to Selected Task') . '" />
122 // Add the relationship and display finished message
124 } elseif (getStringFromRequest('done_adding')) {
126 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());
129 // Create a new task and relate it to this artifact
131 } elseif (getStringFromRequest('new_task')) {
133 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());
136 // Show the list of ProjectGroups available
140 $pgf = new ProjectGroupFactory($group);
141 if (!$pgf || !is_object($pgf)) {
142 exit_error(_('Could Not Get Factory'),'tracker');
143 } elseif ($pgf->isError()) {
144 exit_error($pgf->getErrorMessage(),'tracker');
147 $pg_arr = $pgf->getProjectGroups();
149 if ($pgf->isError()) {
150 exit_error($pgf->getErrorMessage(),'tracker');
152 exit_error(_('No Existing Project Groups Found'),'tracker');
156 $ath->header(array('titlevals'=>array($ath->getName()),
157 'atid'=>$ath->getID(),
158 'title'=>_('Build Relationship Between Tracker Items and Tasks')));
160 echo '<form name="foo" action="'. getStringFromServer('PHP_SELF') .'?func=taskmgr&group_id='.$group_id.'&atid='.$atid.'&aid='.$aid.'" method="post">
161 <p><strong>'._('Tracker Item').':</strong> [#'.$a->getID().'] '.$a->getSummary().'</p>
162 <p><strong>'._('Tasks Project').':</strong></p>
163 <select name="group_project_id">';
164 for ($i=0; $i<count($pg_arr); $i++) {
165 echo '<option value="'.$pg_arr[$i]->getID().'">'.$pg_arr[$i]->getName().'</option>';
169 <input type="submit" name="add_to_task" value="'._('Add Relation to Existing Task').'" />
170 <input type="submit" name="new_task" value="'._('Create New Task').'" />
176 $ath->footer(array());