81d1682b9a8e39fe796d6fb0ad028bf8305e52bc
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 = strtolower($type);
27 $type = ($type == 'component' ?
'product' : $type);
28 $type_action = (($type == 'version') ?
'versionid' : 'productid');
32 $opt .= '<option value="product.php?do=edit' . $type . '&' . $type_action . '=' . $id . '">' . sprintf($bugsys->lang
->string('Edit %1$s'), $type_display) . '</option>';
37 $opt .= '<option value="product.php?do=delete' . $type . '&' . $type_action . '=' . $id . '">' . sprintf($bugsys->lang
->string('Delete %1$s'), $type_display) . '</option>';
42 $opt .= '<option value="product.php?do=addproduct&productid=' . $id . '">' . $bugsys->lang
->string('Add Component') . '</option>';
47 $opt .= '<option value="product.php?do=addversion&productid=' . $id . '">' . $bugsys->lang
->string('Add Version') . '</option>';
50 $type = strtolower($type);
52 $name = $type . '_' . $id;
54 $displayorder = (($displayorder != -1) ?
'<input type="text" name="displayorder[' . $name . ']" value="' . $displayorder . '" size="4" class="input" /> ' : '');
56 return $displayorder . '<select id="' . $name . '" name="' . $name . '" onchange="exec_action(\'' . $name . '\')" class="input">' . $opt . '</select> <input type="button" class="button" name="gobutton" value=" ' . $bugsys->lang
->string('Go') . ' " onclick="exec_action(\'' . $name . '\')" />';
59 // ###################################################################
61 if (empty($_REQUEST['do']))
63 $_REQUEST['do'] = 'modify';
66 // ###################################################################
68 if ($_REQUEST['do'] == 'killversion')
70 $db->query("DELETE FROM " . TABLE_PREFIX
. "version WHERE versionid = " . intval($bugsys->in
['versionid']));
71 $db->query("DELETE FROM " . TABLE_PREFIX
. "bug WHERE versionid = " . intval($bugsys->in
['versionid']));
75 $admin->redirect('product.php?do=modify');
78 // ###################################################################
80 if ($_REQUEST['do'] == 'deleteversion')
82 $admin->page_confirm($lang->string('Are you sure you want to delete this version? Doing so will do delete all the bugs with this version.'), 'product.php?do=killversion&versionid=' . intval($bugsys->in
['versionid']));
85 // ###################################################################
87 if ($_REQUEST['do'] == 'insertversion')
89 $db->query("INSERT INTO " . TABLE_PREFIX
. "version (productid, version, displayorder) VALUES (" . intval($bugsys->in
['productid']) . ", '" . $bugsys->in
['version'] . "', " . intval($bugsys->in
['displayorder']) . ")");
91 $admin->redirect('product.php?do=modify');
94 // ###################################################################
96 if ($_REQUEST['do'] == 'addversion')
98 $admin->page_start($lang->string('Add Version'));
100 if ($bugsys->in
['productid'] != -1)
102 $product = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']));
103 if (!is_array($product))
105 $admin->error($lang->getlex('error_invalid_id'));
110 $bugsys->in
['productid'] = 0;
113 $admin->form_start('product.php', 'insertversion');
114 $admin->form_hidden_field('productid', intval($bugsys->in
['productid']));
115 $admin->table_start();
116 $admin->table_head($lang->string('Add New Version'), 2, 'products_and_versions');
117 $admin->row_input($lang->string('Version Number<div><dfn>This is the version string for this product.</dfn></div>'), 'version');
118 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the versions are displayed.</dfn></div>'), 'displayorder');
119 $admin->row_submit();
126 // ###################################################################
128 if ($_REQUEST['do'] == 'updateversion')
130 if (empty($bugsys->in
['version']))
132 $admin->error($lang->string('Please fill in a version number.'));
135 $db->query("UPDATE " . TABLE_PREFIX
. "version SET version = '" . $bugsys->in
['version'] . "', displayorder = " . intval($bugsys->in
['displayorder']) . " WHERE versionid = " . intval($bugsys->in
['versionid']));
138 $admin->redirect('product.php?do=modify');
141 // ###################################################################
143 if ($_REQUEST['do'] == 'editversion')
145 $admin->page_start($lang->string('Edit Version'));
147 $version = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "version WHERE versionid = " . intval($bugsys->in
['versionid']));
148 if (!is_array($version))
150 $admin->error($lang->getlex('error_invalid_id'));
153 $admin->form_start('product.php', 'updateversion');
154 $admin->form_hidden_field('versionid', $version['versionid']);
155 $admin->table_start();
156 $admin->table_head(sprintf($lang->string('Edit Version - %1$s'), $version['version']), 2, 'products_and_versions');
157 $admin->row_input($lang->string('Version Number<div><dfn>This is the version string for this product.</dfn></div>'), 'version', $version['version']);
158 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the versions are displayed.</dfn></div>'), 'displayorder', $version['displayorder']);
159 $admin->row_submit();
166 // ###################################################################
168 if ($_REQUEST['do'] == 'killproduct')
170 $allprods = $db->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']) . " OR componentmother = " . intval($bugsys->in
['productid']));
171 while ($prod = $db->fetch_array($allprods))
173 $list[] = $prod['productid'];
176 $db->query("DELETE FROM " . TABLE_PREFIX
. "product WHERE productid IN (" . implode(', ', $list) . ")");
177 $db->query("DELETE FROM " . TABLE_PREFIX
. "version WHERE productid IN (" . implode(', ', $list) . ")");
178 $db->query("DELETE FROM " . TABLE_PREFIX
. "bug WHERE productid IN (" . implode(', ', $list) . ")");
182 $admin->redirect('product.php?do=modify');
185 // ###################################################################
187 if ($_REQUEST['do'] == 'deleteproduct')
189 $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']));
192 // ###################################################################
194 if ($_REQUEST['do'] == 'insertproduct')
196 if (empty($bugsys->in
['title']))
198 $admin->error($lang->string('Please go back and fill in the title field.'));
202 INSERT INTO " . TABLE_PREFIX
. "product
203 (title, componentmother, description, displayorder)
205 ('" . $bugsys->in
['title'] . "', " . intval($bugsys->in
['componentmother']) . ",
206 '" . $bugsys->in
['description'] . "', " . intval($bugsys->in
['displayorder']) . "
211 $admin->redirect('product.php?do=modify');
214 // ###################################################################
216 if ($_REQUEST['do'] == 'addproduct')
218 $admin->page_start($lang->string('Add New Product'));
220 $admin->form_start('product.php', 'insertproduct');
221 $admin->form_hidden_field('componentmother', intval($bugsys->in
['productid']));
222 $admin->table_start();
223 $admin->table_head($lang->string('Add Product'), 2, 'products_and_versions');
224 $admin->row_input($lang->string('Title'), 'title');
225 $admin->row_textarea($lang->string('Description<div><dfn>A short description of this product.</dfn></div>'), 'description');
226 $admin->row_input($lang->string('Display Order<div><dfn>The order in which the products are displayed.</dfn></div>'), 'displayorder');
227 $admin->row_submit();
234 // ###################################################################
236 if ($_REQUEST['do'] == 'updateproduct')
238 if (empty($bugsys->in
['title']))
240 $admin->error($lang->string('Please go back and fill in the title field.'));
243 if (empty($bugsys->in
['productid']))
245 $admin->error($lang->getlex('error_invalid_id'));
248 $db->query("UPDATE " . TABLE_PREFIX
. "product SET title = '" . $bugsys->in
['title'] . "', description = '" . $bugsys->in
['description'] . "', displayorder = " . intval($bugsys->in
['displayorder']) . " WHERE productid = " . intval($bugsys->in
['productid']));
251 $admin->redirect('product.php?do=modify');
254 // ###################################################################
256 if ($_REQUEST['do'] == 'editproduct')
258 $admin->page_start($lang->string('Edit Product'));
260 $product = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']));
261 if (!is_array($product))
263 $admin->error($lang->getlex('error_invalid_id'));
266 $admin->form_start('product.php', 'updateproduct');
267 $admin->form_hidden_field('productid', $product['productid']);
268 $admin->table_start();
269 $admin->table_head(sprintf($lang->string('Edit Product - %1$s'), $product['title']), 2, 'products_and_versions');
270 $admin->row_input($lang->string('Title'), 'title', $product['title']);
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'), 2, 'products_and_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_submit('<a href="product.php?do=addproduct">[' . $lang->string('Add New Product') . ']</a>', $lang->string('Save Display Order'), null
);
389 /*=====================================================================*\
390 || ###################################################################
393 || ###################################################################
394 \*=====================================================================*/