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)
23 $type_display = substr_replace($type, strtoupper($type{0}), 0, 1);
24 $type = (($type == 'component') ? 'product' : $type);
25 $type_action = (($type == 'version') ? 'versionid' : 'productid');
29 $opt .= '<option value="product.php?do=edit' . $type . '&' . $type_action . '=' . $id . '">Edit ' . $type_display . '</option>';
34 $opt .= '<option value="product.php?do=delete' . $type . '&' . $type_action . '=' . $id . '">Delete ' . $type_display . '</option>';
39 $opt .= '<option value="product.php?do=addproduct&productid=' . $id . '">' . lang
::p('add_component') . '</option>';
44 $opt .= '<option value="product.php?do=addversion&productid=' . $id . '">' . lang
::p('add_version') . '</option>';
47 $type = strtolower($type);
49 $name = $type . '_' . $id;
51 $displayorder = (($displayorder != -1) ? '<input type="text" name="displayorder[' . $name . ']" value="' . $displayorder . '" size="4" /> ' : '');
53 return $displayorder . '<select id="' . $name . '" name="' . $name . '" onchange="exec_action(\'' . $name . '\')">' . $opt . '</select> <input type="button" name="gobutton" value=" ' . lang
::p('go') . ' " onclick="exec_action(\'' . $name . '\')" />';
56 // ###################################################################
58 if (empty($_REQUEST['do']))
60 $_REQUEST['do'] = 'modify';
63 // ###################################################################
65 if ($_REQUEST['do'] == 'killversion')
67 $db->query("DELETE FROM " . TABLE_PREFIX
. "version WHERE versionid = " . intval($bugsys->in
['versionid']));
68 // #*# figure out what we do with bugs
72 $admin->redirect('product.php?do=modify');
75 // ###################################################################
77 if ($_REQUEST['do'] == 'deleteversion')
79 $admin->page_confirm(lang
::p('confirm_delete_version'), 'product.php?do=killversion&versionid=' . intval($bugsys->in
['versionid']));
82 // ###################################################################
84 if ($_REQUEST['do'] == 'insertversion')
86 $db->query("INSERT INTO " . TABLE_PREFIX
. "version (productid, version, displayorder) VALUES (" . intval($bugsys->in
['productid']) . ", '" . $bugsys->in
['version'] . "', " . intval($bugsys->in
['displayorder']) . ")");
88 $admin->redirect('product.php?do=modify');
91 // ###################################################################
93 if ($_REQUEST['do'] == 'addversion')
95 $admin->page_start(lang
::p('add_version'));
97 if ($bugsys->in
['productid'] != -1)
99 $product = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']));
100 if (!is_array($product))
102 $admin->error(lang
::p('error_invalid_id'));
107 $bugsys->in
['productid'] = 0;
110 $admin->form_start('product.php', 'insertversion');
111 $admin->form_hidden_field('productid', intval($bugsys->in
['productid']));
112 $admin->table_start();
113 $admin->table_head(lang
::p('add_new_version'));
114 $admin->row_input(lang
::p('version_title'), 'version');
115 $admin->row_input(lang
::p('version_display_order'), 'displayorder');
116 $admin->row_submit();
123 // ###################################################################
125 if ($_REQUEST['do'] == 'updateversion')
127 if (empty($bugsys->in
['version']))
129 $admin->error(lang
::p('fill_in_version_number'));
132 $db->query("UPDATE " . TABLE_PREFIX
. "version SET version = '" . $bugsys->in
['version'] . "', displayorder = " . intval($bugsys->in
['displayorder']) . " WHERE versionid = " . intval($bugsys->in
['versionid']));
135 $admin->redirect('product.php?do=modify');
138 // ###################################################################
140 if ($_REQUEST['do'] == 'editversion')
142 $admin->page_start(lang
::p('edit_version'));
144 $version = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "version WHERE versionid = " . intval($bugsys->in
['versionid']));
145 if (!is_array($version))
147 $admin->error(lang
::p('error_invalid_id'));
150 $admin->form_start('product.php', 'updateversion');
151 $admin->form_hidden_field('versionid', $version['versionid']);
152 $admin->table_start();
153 $admin->table_head(lang
::p('edit_version_title', $version['version']));
154 $admin->row_input(lang
::p('version_title'), 'version', $version['version']);
155 $admin->row_input(lang
::p('version_display_order'), 'displayorder', $version['displayorder']);
156 $admin->row_submit();
163 // ###################################################################
165 if ($_REQUEST['do'] == 'killproduct')
167 $allprods = $db->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']) . " OR componentmother = " . intval($bugsys->in
['productid']));
168 while ($prod = $db->fetch_array($allprods))
170 $list[] = $prod['productid'];
173 $db->query("DELETE FROM " . TABLE_PREFIX
. "product WHERE productid IN (" . implode(', ', $list) . ")");
174 $db->query("DELETE FROM " . TABLE_PREFIX
. "version WHERE productid IN (" . implode(', ', $list) . ")");
175 // #*# do bug kills here
179 $admin->redirect('product.php?do=modify');
182 // ###################################################################
184 if ($_REQUEST['do'] == 'deleteproduct')
186 $admin->page_confirm(lang
::p('confirm_delete_product'), 'product.php?do=killproduct&productid=' . intval($bugsys->in
['productid']));
189 // ###################################################################
191 if ($_REQUEST['do'] == 'insertproduct')
193 if (empty($bugsys->in
['shortname']) OR empty($bugsys->in
['title']))
195 $admin->error(lang
::p('go_back_and_fill_both_fields'));
199 INSERT INTO " . TABLE_PREFIX
. "product
200 (shortname, title, componentmother, description, displayorder)
202 ('" . $bugsys->in
['shortname'] . "', '" . $bugsys->in
['title'] . "',
203 " . intval($bugsys->in
['componentmother']) . ", '" . $bugsys->in
['description'] . "', " . intval($bugsys->in
['displayorder']) . ")"
207 $admin->redirect('product.php?do=modify');
210 // ###################################################################
212 if ($_REQUEST['do'] == 'addproduct')
214 $admin->page_start(lang
::p('add_new_product'));
216 $admin->form_start('product.php', 'insertproduct');
217 $admin->form_hidden_field('componentmother', intval($bugsys->in
['productid']));
218 $admin->table_start();
219 $admin->table_head(lang
::p('add_product'));
220 $admin->row_input(lang
::p('product_shortname'), 'shortname');
221 $admin->row_input(lang
::p('product_title'), 'title');
222 $admin->row_textarea(lang
::p('product_description'), 'description');
223 $admin->row_input(lang
::p('product_display_order'), 'displayorder');
224 $admin->row_submit();
231 // ###################################################################
233 if ($_REQUEST['do'] == 'updateproduct')
235 if (empty($bugsys->in
['shortname']) OR empty($bugsys->in
['title']))
237 $admin->error(lang
::p('go_back_and_fill_both_fields'));
240 if (empty($bugsys->in
['productid']))
242 $admin->error(lang
::p('error_invalid_id'));
245 $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']));
248 $admin->redirect('product.php?do=modify');
251 // ###################################################################
253 if ($_REQUEST['do'] == 'editproduct')
255 $admin->page_start(lang
::p('edit_product'));
257 $product = $db->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = " . intval($bugsys->in
['productid']));
258 if (!is_array($product))
260 $admin->error(lang
::p('error_invalid_id'));
263 $admin->form_start('product.php', 'updateproduct');
264 $admin->form_hidden_field('productid', $product['productid']);
265 $admin->table_start();
266 $admin->table_head(lang
::p('edit_product_title', $product['title']));
267 $admin->row_input(lang
::p('product_title'), 'title', $product['title']);
268 $admin->row_input(lang
::p('product_shortname'), 'shortname', $product['shortname']);
269 $admin->row_textarea(lang
::p('product_description'), 'description', $product['description']);
270 $admin->row_input(lang
::p('product_display_order'), 'displayorder', $product['displayorder']);
271 $admin->row_submit();
278 // ###################################################################
280 if ($_POST['do'] == 'displayorder')
282 foreach ((array)$_POST['displayorder'] AS $namebit => $displayorder)
284 $name = explode('_', $namebit);
285 if ($name[0] == 'product' OR $name[0] == 'version')
287 $id = intval($name[1]);
288 $order = intval($displayorder);
289 $db->query("UPDATE " . TABLE_PREFIX
. "$name[0] SET displayorder = $order WHERE $name[0]id = $id");
294 $admin->redirect('product.php?do=modify');
297 // ###################################################################
299 if ($_REQUEST['do'] == 'modify')
301 $admin->page_start(lang::p('products_and_versions'));
304 <script type="text
/javascript
">
306 function exec_action(name)
308 window.location = document.getElementById(name).value;
314 $admin->page_code($javascript);
316 $admin->form_start('product.php', 'displayorder');
318 $products = $db->query("SELECT
* FROM
" . TABLE_PREFIX . "product ORDER BY displayorder ASC
");
319 while ($prod = $db->fetch_array($products))
321 if (!$prod['componentmother'])
323 $product["$prod[productid
]"] = $prod;
327 $component["$prod[componentmother
]"][] = $prod;
329 $version["$prod[productid
]"] = array();
331 $products = (array)$product;
333 $versions = $db->query("SELECT
* FROM
" . TABLE_PREFIX . "version ORDER BY displayorder ASC
");
334 while ($vers = $db->fetch_array($versions))
336 $version["$vers[productid
]"]["$vers[versionid
]"] = $vers;
338 $versions = (array)$version;
340 $admin->table_start();
341 $admin->table_head(lang::p('products_versions'));
343 // Handle our global versions
344 if (is_array($versions['0']))
346 $admin->row_text(lang::p('global_versions'), construct_option_list('product', -1, 0, 0, 1, 0, -1), 'middle', 2, 'alt3');
347 foreach ($versions['0'] AS $version)
349 $admin->row_text('-- ' . $version['version'], construct_option_list('version', $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
353 // Now let's do the rest of the versions
354 foreach ($products AS $product)
357 $admin->row_text("<a href
=\"product
.php
?do=editproduct
&
;productid
=$product[productid
]\">$product[title
]</a
>", construct_option_list('product', $product['productid'], 1, 1, 1, 1, $product['displayorder']), 'middle', 2, 'alt3');
360 foreach ($versions["$product[productid
]"] AS $version)
362 $admin->row_text('-- ' . $version['version'], construct_option_list('version', $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
366 foreach ((array)$component["$product[productid
]"] AS $comp)
368 $admin->row_text("-- <a href
=\"product
.php
?do=editproduct
&
;productid
=$comp[productid
]\">$comp[title
]</a
>", construct_option_list('component', $comp['productid'], 1, 0, 1, 1, $comp['displayorder']), 'middle', 2, 'alt1');
370 // Component versions
371 foreach ($versions["$comp[productid
]"] AS $version)
373 $admin->row_text('---- ' . $version['version'], construct_option_list('version', $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
378 $admin->row_span('<input type="submit
" name="button
" value=" ' . lang::p('save_display_order
') . ' " accesskey="s
" /> <input type="button
" name="addproduct
" value=" ' . lang::p('add_new_product
') . ' " onclick="window
.location
= \'product
.php
?do=addproduct\'
;" />', 'tfoot', 'center');
387 /*=====================================================================*\
388 || ###################################################################
391 || ###################################################################
392 \*=====================================================================*/