]>
src.bluestatic.org Git - bugdar.git/blob - functions_product.php
33544f5f7dfca12652f59cc1885867d706700be4
2 /*=====================================================================*\
3 || ################################################################### ||
4 || # Bugdar [#]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 = '--')
26 foreach ($bugsys->datastore
['product'] AS $product)
28 if ($product['componentmother'])
30 $components["$product[componentmother]"]["$product[productid]"] = $product;
34 $products["$product[productid]"] = $product;
38 foreach ($bugsys->datastore
['version'] AS $version)
40 $versions["$version[productid]"]["$version[versionid]"] = $version;
43 foreach ($products AS $product)
45 if (!can_perform($action, $product['productid']) OR !can_perform('canviewbugs', $product['productid']))
51 $valuepfx = "p$product[productid]";
53 // construct global options
54 $OPTIONS .= construct_pcv_select_global_version($product['productid'], 0, $versions, 0, $prefix, $select);
56 // any immediate versions
57 if (is_array($versions["$product[productid]"]))
59 foreach ($versions["$product[productid]"] AS $version)
61 $OPTIONS .= construct_option($version['version'], "{$valuepfx}c0v$version[versionid]", $select, 0, $prefix);
65 // add it as an optgroup
66 $HTML .= construct_optgroup($product['title'], 0, $OPTIONS, $prefix);
69 // components (can't be a nested <optgroup> - it's not valid)
70 if (is_array($components["$product[productid]"]))
72 foreach ($components["$product[productid]"] AS $component)
75 $valuepfx .= "c$component[productid]";
77 // construct global options
78 $OPTIONS .= construct_pcv_select_global_version($component['componentmother'], $component['productid'], $versions, 1, $prefix, $select);
81 if (is_array($versions["$component[componentmother]"]))
83 foreach ($versions["$component[componentmother]"] AS $version)
85 $OPTIONS .= construct_option($version['version'], "{$valuepfx}v$version[versionid]", $select, 1, $prefix);
90 if (is_array($versions["$component[productid]"]))
92 foreach ($versions["$component[productid]"] AS $version)
94 $OPTIONS .= construct_option($version['version'], "{$valuepfx}v$version[versionid]", $select, 1, $prefix);
99 $HTML .= construct_optgroup($component['title'], 1, $OPTIONS, $prefix);
108 // ############ Start construct_pcv_select_global_version ############
109 function construct_pcv_select_global_version($product = 0, $component = 0, $versions = array(), $depth, $prefix = '', $select = '')
112 if (is_array($versions['0']))
114 foreach ($versions['0'] AS $version)
116 $global_versions_html .= construct_option($version['version'], "p{$product}c{$component}v$version[versionid]", $select, $depth, $prefix);
119 return $global_versions_html;
122 // ###################### Start construct_option #####################
123 function construct_option($title, $value, $selectmatch, $depth, $prefix)
127 $selected = ($selectmatch == $value);
129 $label = fetch_depth_mark($depth, $prefix) . ' ' . $title;
131 eval('$OPTIONS = "' . $bugsys->template
->fetch('selectoption') . '";');
135 // ##################### Start construct_optgroup ####################
136 function construct_optgroup($label, $depth, $optbits, $prefix)
140 $glabel = fetch_depth_mark($depth, $prefix) . ' ' . $label;
142 eval('$HTML = "' . $bugsys->template
->fetch('selectoptgroup') . '";');
146 // ###################### Start fetch_depth_mark #####################
147 function fetch_depth_mark($depth, $mark)
151 for ($i = 0; $i <= $depth; $i++
)
159 // ###################### Start parse_pcv_select #####################
160 function parse_pcv_select($input, $validate = false)
164 $input = trim($input);
166 if (preg_match('#^p(\d+?)c(\d+?)v(\d+?)$#', $input) == 0)
171 $trio = preg_split('#(p|c|v)#i', $input, -1, PREG_SPLIT_NO_EMPTY
);
172 if (count($trio) != 3)
177 $pcv = array('product' => intval($trio[0]), 'component' => intval($trio[1]), 'version' => intval($trio[2]));
185 // -------------------------------------------------------------------
187 $product = $bugsys->datastore
['product'][ $pcv['product'] ];
192 $version = $bugsys->datastore
['version'][ $pcv['version'] ];
198 if ($pcv['component'] == 0)
200 // not global version and version.productid != product.productid
201 if ($version['productid'] != 0 AND $version['productid'] != $product['productid'])
209 $component = $bugsys->datastore
['product'][ $pcv['component'] ];
210 // component has the right mother
211 if ($component['componentmother'] == $product['productid'])
213 // version.productid != {component.productid | product.productid}
214 if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
225 if (!can_perform('canviewbugs', $product['productid']))
235 /*=====================================================================*\
236 || ###################################################################
239 || ###################################################################
240 \*=====================================================================*/