3 * one-off script to mass-move tracker items
6 * Thorsten “mirabilos” Glaser <t.glaser@tarent.de>
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.
24 * Edit below; comments inline. This example moves a lot¹ of tracker
25 * items from the trackers with the atid 378 and 667 to 686 and from
26 * atid 209 to 688, keeping everything except the assignee (but see
27 * below for where to change to keep that too, IFF the assignees are
28 * all technicians in the destination trackers as well). The trackers
29 * must already have been (temporarily²) moved to the group in which
30 * the destination tracker lives in (but can be moved back afterwards).
32 * ① e.g. all open ones, got from the following SQL:
33 * SELECT artifact_id FROM artifact WHERE status_id=1 AND group_artifact_id=378;
35 * ② e.g. with the following SQL:
36 * UPDATE artifact_group_list SET group_id=145 WHERE group_artifact_id IN (378, 667, 209);
39 require '/usr/share/gforge/common/include/env.inc.php';
40 require_once $gfcommon."include/pre.php";
41 require_once $gfcommon.'tracker/Artifact.class.php';
42 require_once $gfcommon.'tracker/ArtifactFile.class.php';
43 require_once $gfwww.'tracker/include/ArtifactFileHtml.class.php';
44 require_once $gfcommon.'tracker/ArtifactType.class.php';
45 require_once $gfwww.'tracker/include/ArtifactTypeHtml.class.php';
46 require_once $gfwww.'tracker/include/ArtifactHtml.class.php';
47 require_once $gfcommon.'tracker/ArtifactCanned.class.php';
48 require_once $gfcommon.'tracker/ArtifactTypeFactory.class.php';
53 /* from tracker => array(item, item, …) */
201 foreach ($mvm as $srctrk => $srclist) {
202 /* destination tracker: here, selected by source tracker */
203 $dsttrk = ($srctrk == 209 ? 688 : 686);
204 foreach ($srclist as $srcitemid) {
205 $srcitem =& artifact_get_object($srcitemid);
206 if (!$srcitem || !is_object($srcitem) || $srcitem->isError()) {
207 echo "error item $srcitemid\n";
211 if (!$srcitem->update(
212 $srcitem->getPriority(), /* keep priority the same */
213 $srcitem->getStatusID(), /* keep status the same */
215 * assign them all to Nobody,
216 * since technicians may not match
218 100 /*$srcitem->getAssignedTo()*/,
219 false, /* keep summary the same */
220 100, /* no canned response */
221 false, /* keep details the same */
222 $dsttrk, /* move to this tracker */
223 /* and keep extra fields the same */
224 $srcitem->getExtraFieldData())) {
225 echo "item $srcitemid: " . $srcitem->getErrorMessage()."\n";