r743: Adding explain for autoactions
[bugdar.git] / explain.php
1 <?php
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
7 || # This file may not be reproduced in any way without permission. # ||
8 || # --------------------------------------------------------------- # ||
9 || # User License Agreement at http://www.iris-studios.com/license/ # ||
10 || ################################################################### ||
11 \*=====================================================================*/
12
13 $fetchtemplates = array(
14 'explain_product',
15 'explain_autoaction',
16 'explain_row'
17 );
18
19 define('SVN', '$Id$');
20
21 $focus['showreport'] = 'focus';
22
23 require_once('./global.php');
24
25 // ###################################################################
26
27 if (empty($_REQUEST['do']))
28 {
29 $_REQUEST['do'] = 'products';
30 }
31
32 // ###################################################################
33
34 if ($_REQUEST['do'] == 'products')
35 {
36 foreach ($bugsys->datastore['product'] AS $product)
37 {
38 if ($product['componentmother'])
39 {
40 $components["$product[componentmother]"]["$product[productid]"] = $product;
41 }
42 else
43 {
44 $products["$product[productid]"] = $product;
45 }
46 }
47
48 foreach ($bugsys->datastore['version'] AS $version)
49 {
50 $versions["$version[productid]"]["$version[versionid]"] = $version;
51 }
52
53 // global versions
54 foreach ($versions['0'] AS $version)
55 {
56 $left = $version['version'];
57 $right = null;
58 eval('$globalversions .= "' . $template->fetch('explain_row') . '";');
59 }
60
61 foreach ($products AS $product)
62 {
63 $left = $product['title'];
64 $right = $product['description'];
65 $trextra = ' style="background-color: ' . $stylevar['alt_colour'] . '"';
66 eval('$productlist .= "' . $template->fetch('explain_row') . '";');
67
68 foreach ($components["$product[productid]"] AS $component)
69 {
70 $left = '&nbsp; &rsaquo; &nbsp; ' . $component['title'];
71 $right = $component['description'];
72 $trextra = '';
73 eval('$productlist .= "' . $template->fetch('explain_row') . '";');
74 }
75 }
76
77 eval('$template->flush("' . $template->fetch('explain_product') . '");');
78 }
79
80 // ###################################################################
81
82 if ($_REQUEST['do'] == 'autoactions')
83 {
84 $fields_fetch = $bugsys->db->query("
85 SELECT bugfield.*, permission.mask
86 FROM " . TABLE_PREFIX . "bugfield AS bugfield
87 LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
88 ON (bugfield.fieldid = permission.fieldid)
89 WHERE (permission.mask = 2 OR permission.mask = 1)
90 AND permission.usergroupid = {$bugsys->userinfo['usergroupid']}"
91 );
92 while ($field = $bugsys->db->fetch_array($fields_fetch))
93 {
94 $fields["$field[fieldid]"] = $field;
95 }
96
97 foreach ($bugsys->datastore['autoaction'] AS $autoaction)
98 {
99 $autoaction['fieldchanges'] = unserialize($autoaction['fieldchanges']);
100
101 $left = $autoaction['name'];
102 $right = $autoaction['description'];
103 $trextra = ' class="listinghead"';
104
105 eval('$autoactions .= "' . $template->fetch('explain_row') . '";');
106
107 if ($autoaction['comment'])
108 {
109 $left = $lang->string('Add Comment');
110 $right = $autoaction['comment'];
111 $trextra = ' style="background-color: ' . $stylevar['alt_colour'] . '"';
112
113 eval('$autoactions .= "' . $template->fetch('explain_row') . '";');
114 }
115
116 $trextra = '';
117
118 foreach ($autoaction['fieldchanges']['builtin'] AS $name => $value)
119 {
120 $left = $name;
121 $right = $bugsys->datastore["$left"]["$value"]["$left"];
122 eval('$autoactions .= "' . $template->fetch('explain_row') . '";');
123 }
124
125 foreach ($autoaction['fieldchanges']['custom'] AS $id => $value)
126 {
127 if (!$fields["$id"])
128 {
129 continue;
130 }
131
132 $left = $fields["$id"]['name'] . ' ' . sprintf($lang->string('(Custom #%1$d, type: %2$s)'), $id, $fields["$id"]['type']);
133 $right = $value;
134 eval('$autoactions .= "' . $template->fetch('explain_row') . '";');
135 }
136 }
137
138 eval('$template->flush("' . $template->fetch('explain_autoaction') . '");');
139 }
140
141 /*=====================================================================*\
142 || ###################################################################
143 || # $HeadURL$
144 || # $Id$
145 || ###################################################################
146 \*=====================================================================*/
147 ?>