]>
src.bluestatic.org Git - bugdar.git/blob - includes/functions_product.php
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 // #################### Start construct_pcv_select ###################
14 // constructs a product/component/version select with one go :-)
15 // NB: need to make sure we have the option to turn off just p/c selection without v
16 function construct_pcv_select($action = 'canviewbugs', $select = '', $prefix = '--')
27 foreach ($bugsys->datastore
['product'] AS $product)
29 if ($product['componentmother'])
31 $components["$product[componentmother]"]["$product[productid]"] = $product;
35 $products["$product[productid]"] = $product;
39 foreach ($bugsys->datastore
['version'] AS $version)
41 $versions["$version[productid]"]["$version[versionid]"] = $version;
44 foreach ($products AS $product)
46 if (!can_perform($action, $product['productid']) OR !can_perform('canviewbugs', $product['productid']))
52 $valuepfx = "p$product[productid]";
54 // construct global options
55 $OPTIONS .= construct_pcv_select_global_version($product['productid'], 0, $versions, 0, $prefix, $select);
57 // any immediate versions
58 if (is_array($versions["$product[productid]"]))
60 foreach ($versions["$product[productid]"] AS $version)
62 $OPTIONS .= construct_option($version['version'], "{$valuepfx}c0v$version[versionid]", $select, 0, $prefix);
66 // add it as an optgroup
67 $HTML .= construct_optgroup($product['title'], 0, $OPTIONS, $prefix);
70 // components (can't be a nested <optgroup> - it's not valid)
71 if (is_array($components["$product[productid]"]))
73 foreach ($components["$product[productid]"] AS $component)
76 $valuepfx .= "c$component[productid]";
78 // construct global options
79 $OPTIONS .= construct_pcv_select_global_version($component['componentmother'], $component['productid'], $versions, 1, $prefix, $select);
82 if (is_array($versions["$component[productid]"]))
84 foreach ($versions["$component[productid]"] AS $version)
86 $OPTIONS .= construct_option($version['version'], "{$valuepfx}v$version[versionid]", $select, 1, $prefix);
91 $HTML .= construct_optgroup($component['title'], 1, $OPTIONS, $prefix);
100 // ############ Start construct_pcv_select_global_version ############
101 function construct_pcv_select_global_version($product = 0, $component = 0, $versions = array(), $depth, $prefix = '', $select = '')
104 if (is_array($versions['0']))
106 foreach ($versions['0'] AS $version)
108 $global_versions_html .= construct_option($version['version'], "p{$product}c{$component}v$version[versionid]", $select, $depth, $prefix);
111 return $global_versions_html;
114 // ###################### Start construct_option #####################
115 function construct_option($title, $value, $selectmatch, $depth, $prefix)
119 $selected = ($selectmatch == $value);
121 $label = fetch_depth_mark($depth, $prefix) . ' ' . $title;
123 eval('$OPTIONS = "' . $bugsys->template
->fetch('selectoption') . '";');
127 // ##################### Start construct_optgroup ####################
128 function construct_optgroup($label, $depth, $optbits, $prefix)
132 $glabel = fetch_depth_mark($depth, $prefix) . ' ' . $label;
134 eval('$HTML = "' . $bugsys->template
->fetch('selectoptgroup') . '";');
138 // ###################### Start fetch_depth_mark #####################
139 function fetch_depth_mark($depth, $mark)
143 for ($i = 0; $i <= $depth; $i++
)
151 // ###################### Start parse_pcv_select #####################
152 function parse_pcv_select($input, $validate = false)
156 $input = trim($input);
158 if (preg_match('#^p(\d+?)c(\d+?)v(\d+?)$#', $input) == 0)
163 $trio = preg_split('#(p|c|v)#i', $input, -1, PREG_SPLIT_NO_EMPTY
);
164 if (count($trio) != 3)
169 $pcv = array('product' => intval($trio[0]), 'component' => intval($trio[1]), 'version' => intval($trio[2]));
177 // -------------------------------------------------------------------
179 $product = $bugsys->datastore
['product'][ $pcv['product'] ];
184 $version = $bugsys->datastore
['version'][ $pcv['version'] ];
190 if ($pcv['component'] == 0)
192 // not global version and version.productid != product.productid
193 if ($version['productid'] != 0 AND $version['productid'] != $product['productid'])
201 $component = $bugsys->datastore
['product'][ $pcv['component'] ];
202 // component has the right mother
203 if ($component['componentmother'] == $product['productid'])
205 // version.productid != {component.productid | product.productid}
206 if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
217 if (!can_perform('canviewbugs', $product['productid']))
227 /*=====================================================================*\
228 || ###################################################################
231 || ###################################################################
232 \*=====================================================================*/