2 /*=====================================================================*\
3 || ################################################################### ||
4 || # [#]app[#] [#]version[#]
5 || # --------------------------------------------------------------- # ||
6 || # All parts of this file are ©2003-[#]year[#] Iris Studios, Inc. No # ||
7 || # part of this file may be reproduced in any way: part or whole. # ||
8 || # --------------------------------------------------------------- # ||
9 || # ©2003 - [#]year[#] Iris Studios, Inc. | http://www.iris-studios.com # ||
10 || ################################################################### ||
11 \*=====================================================================*/
13 require_once('./global.php');
15 if (!($bugsys->userinfo
['permissions'] & CANADMINVERSIONS
))
20 function construct_option_list($type, $id, $edit, $addcomponent, $addversion, $delete, $displayorder)
22 $type_display = substr_replace($type, strtoupper($type{0}), 0, 1);
23 $type = iff($type == 'component', 'product', $type);
24 $type_action = iff($type == 'version', 'versionid', 'productid');
28 $opt .= '<option value="product.php?do=edit' . $type . '&' . $type_action . '=' . $id . '">Edit ' . $type_display . '</option>';
33 $opt .= '<option value="product.php?do=delete' . $type . '&' . $type_action . '=' . $id . '">Delete ' . $type_display . '</option>';
38 $opt .= '<option value="product.php?do=addproduct&productid=' . $id . '">Add Component</option>';
43 $opt .= '<option value="product.php?do=addversion&productid=' . $id . '">Add Version</option>';
46 $type = strtolower($type);
48 $name = $type . '_' . $id;
50 $displayorder = iff($displayorder != -1, '<input type="text" name="displayorder[' . $name . ']" value="' . $displayorder . '" size="4" /> ', '');
52 return $displayorder . '<select id="' . $name . '" name="' . $name . '" onchange="exec_action(\'' . $name . '\')">' . $opt . '</select> <input type="button" name="gobutton" value=" Go " onclick="exec_action(\'' . $name . '\')" />';
55 // ###################################################################
57 if (empty($_REQUEST['do']))
59 $_REQUEST['do'] = 'modify';
62 // ###################################################################
64 if ($_REQUEST['do'] == 'killversion')
66 sanitize(array('versionid' => INT));
68 $DB_sql->query("DELETE FROM " . TABLE_PREFIX
. "version WHERE versionid = $vars[versionid]");
69 // #*# figure out what we do with bugs
71 $admin->redirect('product.php?do=modify');
74 // ###################################################################
76 if ($_REQUEST['do'] == 'deleteversion')
78 sanitize(array('versionid' => INT));
79 $admin->page_confirm('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=' . $vars['versionid']);
82 // ###################################################################
84 if ($_REQUEST['do'] == 'insertversion')
86 sanitize(array('productid' => INT, 'version' => STR
, 'displayorder' => INT));
87 $DB_sql->query("INSERT INTO " . TABLE_PREFIX
. "version (productid, version, displayorder) VALUES ($vars[productid], '" . addslasheslike($vars['version']) . "', $vars[displayorder])");
88 $admin->redirect('product.php?do=modify');
91 // ###################################################################
93 if ($_REQUEST['do'] == 'addversion')
95 sanitize(array('productid' => INT));
97 $admin->page_start('Add Version');
99 if ($vars['productid'] != -1)
101 $product = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = $vars[productid]");
102 if (!is_array($product))
109 $vars['productid'] = 0;
112 $admin->form_start('product.php', 'insertversion');
113 $admin->form_hidden_field('productid', $vars['productid']);
114 $admin->table_start();
115 $admin->table_head('Add New Version');
116 $admin->row_input('Version Number<div><dfn>This is the version string for this product.</dfn></div>', 'version');
117 $admin->row_input('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 sanitize(array('versionid' => INT, 'version' => STR
, 'displayorder' => INT));
131 if (empty($vars['version']))
133 $admin->error('Please fill in a version number.');
136 $DB_sql->query("UPDATE " . TABLE_PREFIX
. "version SET version = '" . addslasheslike($vars['version']) . "', displayorder = $vars[displayorder] WHERE versionid = $vars[versionid]");
138 $admin->redirect('product.php?do=modify');
141 // ###################################################################
143 if ($_REQUEST['do'] == 'editversion')
145 sanitize(array('versionid' => INT));
147 $admin->page_start('Edit Version');
149 $version = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX
. "version WHERE versionid = $vars[versionid]");
150 if (!is_array($version))
155 $admin->form_start('product.php', 'updateversion');
156 $admin->form_hidden_field('versionid', $version['versionid']);
157 $admin->table_start();
158 $admin->table_head('Edit Version - ' . $version['version']);
159 $admin->row_input('Version Number<div><dfn>This is the version string for this product.</dfn></div>', 'version', $version['version']);
160 $admin->row_input('Display Order<div><dfn>The order in which the versions are displayed.</dfn></div>', 'displayorder', $version['displayorder']);
161 $admin->row_submit();
168 // ###################################################################
170 if ($_REQUEST['do'] == 'killproduct')
172 sanitize(array('productid' => INT));
174 $allprods = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = $vars[productid] OR componentmother = $vars[productid]");
175 while ($prod = $DB_sql->fetch_array($allprods))
177 $list[] = $prod['productid'];
180 $DB_sql->query("DELETE FROM " . TABLE_PREFIX
. "product WHERE productid IN (" . implode(', ', $list) . ")");
181 $DB_sql->query("DELETE FROM " . TABLE_PREFIX
. "version WHERE productid IN (" . implode(', ', $list) . ")");
182 // #*# do bug kills here
184 $admin->redirect('product.php?do=modify');
187 // ###################################################################
189 if ($_REQUEST['do'] == 'deleteproduct')
191 sanitize(array('productid' => INT));
192 $admin->page_confirm('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=' . $vars['productid']);
195 // ###################################################################
197 if ($_REQUEST['do'] == 'insertproduct')
199 sanitize(array('shortname' => STR
, 'title' => STR
, 'componentmother' => INT, 'description' => STR
, 'displayorder' => INT));
201 if (empty($vars['shortname']) OR empty($vars['title']))
203 $admin->error('please go back and enter both fields');
207 INSERT INTO " . TABLE_PREFIX
. "product
208 (shortname, title, componentmother, description, displayorder)
210 ('" . addslasheslike($vars['shortname']) . "', '" . addslasheslike($vars['title']) . "',
211 $vars[componentmother], '" . addslasheslike($vars['description']) . "', $vars[displayorder])");
213 $admin->redirect('product.php?do=modify');
216 // ###################################################################
218 if ($_REQUEST['do'] == 'addproduct')
220 sanitize(array('productid' => INT));
222 $admin->page_start('Add New Product');
224 $admin->form_start('product.php', 'insertproduct');
225 $admin->form_hidden_field('componentmother', $vars['productid']);
226 $admin->table_start();
227 $admin->table_head('Add Product');
228 $admin->row_input('Short Name<div><dfn>The name that can be used to submit email reports. This should be unique.</dfn></div>', 'shortname');
229 $admin->row_input('Product Title', 'title');
230 $admin->row_textarea('Description<div><dfn>A short description of this product.</dfn></div>', 'description');
231 $admin->row_input('Display Order<div><dfn>The order in which the products are displayed.</dfn></div>', 'displayorder');
232 $admin->row_submit();
239 // ###################################################################
241 if ($_REQUEST['do'] == 'updateproduct')
243 sanitize(array('productid' => INT, 'title' => STR
, 'shortname' => STR
, 'description' => STR
, 'displayorder' => INT));
245 if (empty($vars['shortname']) OR empty($vars['title']))
247 $admin->error('please go back and fill in both fields');
250 if (empty($vars['productid']))
255 $DB_sql->query("UPDATE " . TABLE_PREFIX
. "product SET title = '" . addslasheslike($vars['title']) . "', shortname = '" . addslasheslike($vars['shortname']) . "', description = '" . addslasheslike($vars['description']) . "', displayorder = $vars[displayorder] WHERE productid = $vars[productid]");
257 $admin->redirect('product.php?do=modify');
260 // ###################################################################
262 if ($_REQUEST['do'] == 'editproduct')
264 sanitize(array('productid' => INT));
266 $admin->page_start('Edit Product');
268 $product = $DB_sql->query_first("SELECT * FROM " . TABLE_PREFIX
. "product WHERE productid = $vars[productid]");
270 if (!is_array($product))
275 $admin->form_start('product.php', 'updateproduct');
276 $admin->form_hidden_field('productid', $product['productid']);
277 $admin->table_start();
278 $admin->table_head('Edit Product - ' . $product['title']);
279 $admin->row_input('Product Title', 'title', $product['title']);
280 $admin->row_input('Short Name<div><dfn>The name that can be used to submit email reports. This should be unique.</dfn></div>', 'shortname', $product['shortname']);
281 $admin->row_textarea('Description<div><dfn>A short description of this product.</dfn></div>', 'description', $product['description']);
282 $admin->row_input('Display Order<div><dfn>The order in which the products are displayed.</dfn></div>', 'displayorder', $product['displayorder']);
283 $admin->row_submit();
290 // ###################################################################
292 if ($_POST['do'] == 'displayorder')
294 foreach ((array)$_POST['displayorder'] AS $namebit => $displayorder)
296 $name = explode('_', $namebit);
297 if ($name[0] == 'product' OR $name[0] == 'version')
299 $id = intval($name[1]);
300 $order = intval($displayorder);
301 $DB_sql->query("UPDATE " . TABLE_PREFIX
. "$name[0] SET displayorder = $order WHERE $name[0]id = $id");
304 $admin->redirect('product.php?do=modify');
307 // ###################################################################
309 if ($_REQUEST['do'] == 'modify')
311 $admin->page_start('Products and Versions');
314 <script type
="text/javascript">
316 function exec_action(name
)
318 window
.location
= document
.getElementById(name
).value
;
324 $admin->page_code($javascript);
326 $admin->form_start('product.php', 'displayorder');
328 $products = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "product ORDER BY displayorder ASC");
329 while ($prod = $DB_sql->fetch_array($products))
331 if (!$prod['componentmother'])
333 $product["$prod[productid]"] = $prod;
337 $component["$prod[componentmother]"][] = $prod;
339 $version["$prod[productid]"] = array();
341 $products = (array)$product;
343 $versions = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX
. "version ORDER BY displayorder ASC");
344 while ($vers = $DB_sql->fetch_array($versions))
346 $version["$vers[productid]"]["$vers[versionid]"] = $vers;
348 $versions = (array)$version;
350 $admin->table_start();
351 $admin->table_head('Products / Versions');
353 // Handle our global versions
354 if (is_array($versions['0']))
356 $admin->row_text('Global Versions', construct_option_list('product', -1, 0, 0, 1, 0, -1), 'middle', 2, 'alt3');
357 foreach ($versions['0'] AS $version)
359 $admin->row_text('-- ' . $version['version'], construct_option_list('version', $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
363 // Now let's do the rest of the versions
364 foreach ($products AS $product)
367 $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');
370 foreach ($versions["$product[productid]"] AS $version)
372 $admin->row_text('-- ' . $version['version'], construct_option_list('version', $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
376 foreach ((array)$component["$product[productid]"] AS $comp)
378 $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');
380 // Component versions
381 foreach ($versions["$comp[productid]"] AS $version)
383 $admin->row_text('---- ' . $version['version'], construct_option_list('version', $version['versionid'], 1, 0, 0, 1, $version['displayorder']), 'middle', 2, 'alt2');
388 $admin->row_span('<input type="submit" name="button" value=" Save Display Order" accesskey="s" /> <input type="button" name="addproduct" value=" Add New Product " onclick="window.location = \'product.php?do=addproduct\';" />', 'tfoot', 'center');
397 /*=====================================================================*\
398 || ###################################################################
401 || ###################################################################
402 \*=====================================================================*/