Fix DB_MySQL_PDO::escape_binary().
[bugdar.git] / explain.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2002-2007 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 $fetchtemplates = array(
23 'explain_product',
24 'explain_automation',
25 'explain_row'
26 );
27
28
29 $focus['showreport'] = 'focus';
30
31 require_once('./global.php');
32
33 // ###################################################################
34
35 if (empty($_REQUEST['do']))
36 {
37 $_REQUEST['do'] = 'products';
38 }
39
40 // ###################################################################
41
42 if ($_REQUEST['do'] == 'products')
43 {
44 if (!is_array(bugdar::$datastore['product']))
45 {
46 $message->error(T('There are no products set up.'));
47 }
48
49 foreach (bugdar::$datastore['product'] AS $product)
50 {
51 if ($product['parentid'])
52 {
53 $components["$product[componentmother]"]["$product[productid]"] = $product;
54 }
55 else
56 {
57 $products["$product[productid]"] = $product;
58 }
59 }
60
61 foreach (bugdar::$datastore['version'] AS $version)
62 {
63 $versions["$version[productid]"]["$version[versionid]"] = $version;
64 }
65
66 // global versions
67 if (is_array($versions['0']))
68 {
69 foreach ($versions['0'] AS $version)
70 {
71 $left = $version['version'];
72 $right = null;
73 eval('$globalversions .= "' . $template->fetch('explain_row') . '";');
74 }
75 }
76
77 foreach ($products AS $product)
78 {
79 $left = $product['title'];
80 $right = $product['description'];
81 $trextra = ' class="altcolor"';
82 eval('$productlist .= "' . $template->fetch('explain_row') . '";');
83
84 if (is_array($components["$product[productid]"]))
85 {
86 foreach ($components["$product[productid]"] AS $component)
87 {
88 $left = '&nbsp; &rsaquo; &nbsp; ' . $component['title'];
89 $right = $component['description'];
90 $trextra = '';
91 eval('$productlist .= "' . $template->fetch('explain_row') . '";');
92 }
93 }
94 }
95
96 eval('$template->flush("' . $template->fetch('explain_product') . '");');
97 }
98
99 // ###################################################################
100
101 if ($_REQUEST['do'] == 'automations')
102 {
103 $fields_fetch = $bugsys->db->query("
104 SELECT bugfield.*, MAX(permission.mask) AS mask
105 FROM " . TABLE_PREFIX . "bugfield AS bugfield
106 LEFT JOIN " . TABLE_PREFIX . "bugfieldpermission AS permission
107 ON (bugfield.fieldid = permission.fieldid)
108 WHERE (permission.mask = 2 OR permission.mask = 1)
109 AND permission.usergroupid IN ({$bugsys->userinfo['usergroupid']}" . (sizeof($bugsys->userinfo['groupids']) != 0 ? ',' . implode(',', $bugsys->userinfo['groupids']) : '') . ")
110 GROUP BY (bugfield.fieldid)
111 ");
112 while ($field = $bugsys->db->fetch_array($fields_fetch))
113 {
114 $fields["$field[fieldid]"] = $field;
115 }
116
117 if (is_array(bugdar::$datastore['automation']))
118 {
119 foreach (bugdar::$datastore['automation'] AS $automation)
120 {
121 $automation['fieldchanges'] = unserialize($automation['fieldchanges']);
122
123 $left = $automation['name'];
124 $right = $automation['description'];
125 $trextra = ' class="listinghead"';
126
127 eval('$automations .= "' . $template->fetch('explain_row') . '";');
128
129 if ($automation['comment'])
130 {
131 $left = T('Add Comment');
132 $right = $automation['comment'];
133 $trextra = ' class="altcolor"';
134
135 eval('$automations .= "' . $template->fetch('explain_row') . '";');
136 }
137
138 $trextra = '';
139
140 if (is_array($automation['fieldchanges']['builtin']))
141 {
142 foreach ($automation['fieldchanges']['builtin'] AS $name => $value)
143 {
144 $left = $name;
145 $right = bugdar::$datastore["$left"]["$value"]["$left"];
146 eval('$automations .= "' . $template->fetch('explain_row') . '";');
147 }
148 }
149
150 if (is_array($automation['fieldchanges']['custom']))
151 {
152 foreach ($automation['fieldchanges']['custom'] AS $id => $value)
153 {
154 if (!$fields["$id"])
155 {
156 continue;
157 }
158
159 $left = $fields["$id"]['name'] . ' ' . sprintf(T('(Custom #%1$d, type: %2$s)'), $id, $fields["$id"]['type']);
160 $right = $value;
161 eval('$automations .= "' . $template->fetch('explain_row') . '";');
162 }
163 }
164 }
165 }
166
167 eval('$template->flush("' . $template->fetch('explain_automation') . '");');
168 }
169