2 /*=====================================================================*\
3 || ################################################################### ||
4 || # BugStrike [#]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 \*=====================================================================*/
13 require_once('./global.php');
14 require_once('./includes/functions_datastore.php');
16 if (!can_perform('canadminversions'))
21 function construct_option_list($type, $id, $edit, $addcomponent, $addversion, $delete, $displayorder)
25 $type_display = $type;
26 $type = (($type == 'component') ?
'product' : $type);
27 $type_action = (($type == 'version') ?
'versionid' : 'productid');
31 $opt .= '<option value="product.php?do=edit' . $type . '&' . $type_action . '=' . $id . '">' . $bugsys->lang
->string('Edit') . ' ' . $type_display . '</option>';
36 $opt .= '<option value="product.php?do=delete' . $type . '&' . $type_action . '=' . $id . '">' . $bugsys->lang
->string('Delete') . ' ' . $type_display . '</option>';
41 $opt .= '<option value="product.php?do=addproduct&productid=' . $id . '">' . $bugsys->lang
->string('Add Component') . '</option>';
46 $opt .= '<option value="product.php?do=addversion&productid=' . $id . '">' . $bugsys->lang
->string('Add Version') . '</option>';
49 $type = strtolower($type);
51 $name = $type . '_' . $id;
53 $displayorder = (($displayorder != -1) ?
'<input type="text" name="displayorder[' . $name . ']" value="' . $displayorder . '" size="4" /> ' : '');
55 return $displayorder . '<select id="' . $name . '" name="' . $name . '" onchange="exec_action(\'' . $name . '\')">' . $opt . '</select> <input type="button" name="gobutton" value=" ' . $bugsys->lang
->string('Go') . ' " onclick="exec_action(\'' . $name . '\')" />';
58 // ###################################################################
60 if (empty($_REQUEST['do']))
62 $_REQUEST['do'] = 'modify';
65 // ###################################################################
67 if ($_REQUEST['do'] == 'killversion')
69 $db->query("DELETE FROM " . TABLE_PREFIX
. "version WHERE versionid = " . intval($bugsys->in
['versionid']));
70 $db->query("DELETE FROM " . TABLE_PREFIX
. "bug WHERE versionid = " . intval($bugsys->in
['versionid']));
74 $admin->redirect('product.php?do=modify');
77 // ###################################################################
79 if ($_REQUEST['do'] == 'deleteversion')
81 $admin->page_confirm($lang->string('Are you sure you want to delete this version? Doing so will do x to the bugs with this version.'), 'product.php?do=killversion&versionid=' . intval($bugsys->in
['versionid']));
84 // ###################################################################
86 if ($_REQUEST['do'] == 'insertversion')
88 $db->query("INSERT INTO " . TABLE_PREFIX
. "version (productid, version, displayorder) VALUES (" . intval($bugsys->in
['productid']) . ", '" . $bugsys->in
['version'] . "', " . intval($bugsys->in
['displayorder']) . ")");
90 $admin->redirect('product.php?do=modify');
93 // ###################################################################
95 if ($_REQUEST['do'] == 'addversion')
97 $admin->page_start($lang->string('Add Version'));
99 if ($bugsys->in
['productid'] != -1)
101 $product = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']));
102 if (!is_array($product))
104 $admin->error($lang->getlex('error_invalid_id'));
109 $bugsys->in
['productid'] = 0;
112 $admin->form_start('product.php', 'insertversion');
113 $admin->form_hidden_field('productid', intval($bugsys->in
['productid']));
114 $admin->table_start();
115 $admin->table_head($lang->string('Add New Version'));
116 $admin->row_input($lang->string('Version Number<div><dfn>This is the version string for this product.</dfn></div>'), 'version');
117 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the versions are displayed.</dfn></div>'), 'displayorder');
118 $admin->row_submit();
125 // ###################################################################
127 if ($_REQUEST['do'] == 'updateversion')
129 if (empty($bugsys->in
['version']))
131 $admin->error($lang->string('Please fill in a version number.'));
134 $db->query("UPDATE " . TABLE_PREFIX
. "version SET version = '" . $bugsys->in
['version'] . "', displayorder = " . intval($bugsys->in
['displayorder']) . " WHERE versionid = " . intval($bugsys->in
['versionid']));
137 $admin->redirect('product.php?do=modify');
140 // ###################################################################
142 if ($_REQUEST['do'] == 'editversion')
144 $admin->page_start($lang->string('Edit Version'));
146 $version = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "version WHERE versionid = " . intval($bugsys->in
['versionid']));
147 if (!is_array($version))
149 $admin->error($lang->getlex('error_invalid_id'));
152 $admin->form_start('product.php', 'updateversion');
153 $admin->form_hidden_field('versionid', $version['versionid']);
154 $admin->table_start();
155 $admin->table_head(sprintf($lang->string('Edit Version - %1$s'), $version['version']));
156 $admin->row_input($lang->string('Version Number<div><dfn>This is the version string for this product.</dfn></div>'), 'version', $version['version']);
157 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the versions are displayed.</dfn></div>'), 'displayorder', $version['displayorder']);
158 $admin->row_submit();
165 // ###################################################################
167 if ($_REQUEST['do'] == 'killproduct')
169 $allprods = $db->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']) . " OR componentmother = " . intval($bugsys->in
['productid']));
170 while ($prod = $db->fetch_array($allprods))
172 $list[] = $prod['productid'];
175 $db->query("DELETE FROM " . TABLE_PREFIX
. "product WHERE productid IN (" . implode(', ', $list) . ")");
176 $db->query("DELETE FROM " . TABLE_PREFIX
. "version WHERE productid IN (" . implode(', ', $list) . ")");
177 $db->query("DELETE FROM " . TABLE_PREFIX
. "bug WHERE productid IN (" . implode(', ', $list) . ")");
181 $admin->redirect('product.php?do=modify');
184 // ###################################################################
186 if ($_REQUEST['do'] == 'deleteproduct')
188 $admin->page_confirm($lang->string('Are you sure you want to delete this product and all of it\'s sub-versions and components (as well as any bugs contained within those groups)?'), 'product.php?do=killproduct&productid=' . intval($bugsys->in
['productid']));
191 // ###################################################################
193 if ($_REQUEST['do'] == 'insertproduct')
195 if (empty($bugsys->in
['shortname']) OR empty($bugsys->in
['title']))
197 $admin->error($lang->string('Please go back and fill in both fields.'));
201 INSERT INTO " . TABLE_PREFIX
. "product
202 (shortname, title, componentmother, description, displayorder)
204 ('" . $bugsys->in
['shortname'] . "', '" . $bugsys->in
['title'] . "',
205 " . intval($bugsys->in
['componentmother']) . ", '" . $bugsys->in
['description'] . "', " . intval($bugsys->in
['displayorder']) . ")"
209 $admin->redirect('product.php?do=modify');
212 // ###################################################################
214 if ($_REQUEST['do'] == 'addproduct')
216 $admin->page_start($lang->string('Add New Product'));
218 $admin->form_start('product.php', 'insertproduct');
219 $admin->form_hidden_field('componentmother', intval($bugsys->in
['productid']));
220 $admin->table_start();
221 $admin->table_head($lang->string('Add Product'));
222 $admin->row_input($lang->string('Short Name<div><dfn>The name that can be used to submit email reports. This should be unique.</dfn></div>'), 'shortname');
223 $admin->row_input($lang->string('Title'), 'title');
224 $admin->row_textarea($lang->string('Description<div><dfn>A short description of this product.</dfn></div>'), 'description');
225 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the products are displayed.</dfn></div>'), 'displayorder');
226 $admin->row_submit();
233 // ###################################################################
235 if ($_REQUEST['do'] == 'updateproduct')
237 if (empty($bugsys->in
['shortname']) OR empty($bugsys->in
['title']))
239 $admin->error($lang->string('Please go back and fill in both fields.'));
242 if (empty($bugsys->in
['productid']))
244 $admin->error($lang->getlex('error_invalid_id'));
247 $db->query("UPDATE " . TABLE_PREFIX
. "product SET title = '" . $bugsys->in
['title'] . "', shortname = '" . $bugsys->in
['shortname'] . "', description = '" . $bugsys->in
['description'] . "', displayorder = " . intval($bugsys->in
['displayorder']) . " WHERE productid = " . intval($bugsys->in
['productid']));
250 $admin->redirect('product.php?do=modify');
253 // ###################################################################
255 if ($_REQUEST['do'] == 'editproduct')
257 $admin->page_start($lang->string('Edit Product'));
259 $product = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']));
260 if (!is_array($product))
262 $admin->error($lang->getlex('error_invalid_id'));
265 $admin->form_start('product.php', 'updateproduct');
266 $admin->form_hidden_field('productid', $product['productid']);
267 $admin->table_start();
268 $admin->table_head(sprintf($lang->string('Edit Product - %1$s'), $product['title']));
269 $admin->row_input($lang->string('Title'), 'title', $product['title']);
270 $admin->row_input($lang->string('Short Name<div><dfn>The name that can be used to submit email reports. This should be unique.</dfn></div>'), 'shortname', $product['shortname']);
271 $admin->row_textarea($lang->string('Description<div><dfn>A short description of this product.</dfn></div>'), 'description', $product['description']);
272 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the products are displayed.</dfn></div>'), 'displayorder', $product['displayorder']);
273 $admin->row_submit();
280 // ###################################################################
282 if ($_POST['do'] == 'displayorder')
284 foreach ((array)$_POST['displayorder'] AS $namebit => $displayorder)
286 $name = explode('_', $namebit);
287 if ($name[0] == 'product' OR $name[0] == 'version')
289 $id = intval($name[1]);
290 $order = intval($displayorder);
291 $db->query("UPDATE " . TABLE_PREFIX
. "$name[0] SET displayorder = $order WHERE $name[0]id = $id");
296 $admin->redirect('product.php?do=modify');
299 // ###################################################################
301 if ($_REQUEST['do'] == 'modify')
303 $admin->page_start($lang->string('Products and Versions'));
306 <script type
="text/javascript">
308 function exec_action(name
)
310 window
.location
= document
.getElementById(name
).value
;
316 $admin->page_code($javascript);
318 $admin->form_start('product.php', 'displayorder');
320 $products = $db->query("SELECT * FROM " . TABLE_PREFIX
. "product ORDER BY displayorder ASC");
321 while ($prod = $db->fetch_array($products))
323 if (!$prod['componentmother'])
325 $product["$prod[productid]"] = $prod;
329 $component["$prod[componentmother]"][] = $prod;
331 $version["$prod[productid]"] = array();
333 $products = (array)$product;
335 $versions = $db->query("SELECT * FROM " . TABLE_PREFIX
. "version ORDER BY displayorder ASC");
336 while ($vers = $db->fetch_array($versions))
338 $version["$vers[productid]"]["$vers[versionid]"] = $vers;
340 $versions = (array)$version;
342 $admin->table_start();
343 $admin->table_head($lang->string('Products / Versions'));
345 // Handle our global versions
346 if (is_array($versions['0']))
348 $admin->row_text($lang->string('Global Versions'), construct_option_list($lang->string('Product'), -1, 0, 0, 1, 0, -1), 'middle', 2, 'alt3');
349 foreach ($versions['0'] AS $version)
351 $admin->row_text('-- ' . $version['version'], construct_option_list($lang->string('Version'), $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
355 // Now let's do the rest of the versions
356 foreach ($products AS $product)
359 $admin->row_text("<a href=\"product.php?do=editproduct&productid=$product[productid]\">$product[title]</a>", construct_option_list($lang->string('Product'), $product['productid'], 1, 1, 1, 1, $product['displayorder']), 'middle', 2, 'alt3');
362 foreach ($versions["$product[productid]"] AS $version)
364 $admin->row_text('-- ' . $version['version'], construct_option_list($lang->string('Version'), $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
368 foreach ((array)$component["$product[productid]"] AS $comp)
370 $admin->row_text("-- <a href=\"product.php?do=editproduct&productid=$comp[productid]\">$comp[title]</a>", construct_option_list($lang->string('Component'), $comp['productid'], 1, 0, 1, 1, $comp['displayorder']), 'middle', 2, 'alt1');
372 // Component versions
373 foreach ($versions["$comp[productid]"] AS $version)
375 $admin->row_text('---- ' . $version['version'], construct_option_list($lang->string('Version'), $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
380 $admin->row_span('<input type="submit" name="button" value=" ' . $lang->string('Save Display Order') . ' " accesskey="s" /> <a href="product.php?do=addproduct">[' . $lang->string('Add New Product') . ']</a>', 'tfoot', 'center');
389 /*=====================================================================*\
390 || ###################################################################
393 || ###################################################################
394 \*=====================================================================*/