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($select = '', $prefix = '--')
27 $selected = ' selected="selected"';
29 foreach ($bugsys->datastore
['product'] AS $product)
31 if ($product['componentmother'])
33 $components["$product[componentmother]"]["$product[productid]"] = $product;
37 $products["$product[productid]"] = $product;
41 foreach ($bugsys->datastore
['version'] AS $version)
43 $versions["$version[productid]"]["$version[versionid]"] = $version;
46 foreach ($products AS $product)
49 $valuepfx = "p$product[productid]";
50 $row['value'] = "{$valuepfx}c0v0";
51 $row['title'] = $product['title'];
52 $row['optgroup'] = true
;
53 $row['description'] = $product['description'];
54 $show['input'] = false
;
56 eval('$HTML .= "' . $bugsys->template
->fetch('pcv_select_row') . '";');
57 $HTML .= construct_pcv_select_global_version($product['productid'], 0, $versions, $prefix, $select);
58 if (is_array($versions["$product[productid]"]))
60 foreach ($versions["$product[productid]"] AS $version)
62 $row['prefix'] = $prefix . $prefix . ' ';
63 $row['value'] = "{$valuepfx}c0v$version[versionid]";
64 $row['title'] = $version['version'];
65 $row['optgroup'] = false
;
66 $row['selected'] = (($select == $row['value']) ?
$selected : '');
67 $row['description'] = '';
68 $show['input'] = true
;
69 eval('$HTML .= "' . $bugsys->template
->fetch('pcv_select_row') . '";');
73 if (is_array($components["$product[productid]"]))
75 foreach ($components["$product[productid]"] AS $component)
77 $row['prefix'] = $prefix . ' ';
78 $valuepfx .= "c$component[productid]";
79 $row['value'] = "{$valuepfx}v0";
80 $row['selected'] = (($select == $row['value']) ?
$selected : '');
81 $row['title'] = $component['title'];
83 $row['optgroup'] = true
;
85 $row['description'] = $component['description'];
86 $show['input'] = false
;
87 eval('$HTML .= "' . $bugsys->template
->fetch('pcv_select_row') . '";');
88 $HTML .= construct_pcv_select_global_version($component['componentmother'], $component['productid'], $versions, $prefix, $select);
89 if (is_array($versions["$component[productid]"]))
91 foreach ($versions["$component[productid]"] AS $version)
93 $show['input'] = true
;
94 $row['prefix'] = $prefix . $prefix . ' ';
95 $row['value'] = "{$valuepfx}v$version[versionid]";
96 $row['selected'] = (($select == $row['value']) ?
$selected : '');
97 $row['title'] = $version['version'];
98 $row['optgroup'] = false
;
99 $row['description'] = '';
100 eval('$HTML .= "' . $bugsys->template
->fetch('pcv_select_row') . '";');
104 $row['optgroup'] = true
;
106 eval('$HTML .= "' . $bugsys->template
->fetch('pcv_select_row') . '";');
108 $row['optgroup'] = true
;
110 eval('$HTML .= "' . $bugsys->template
->fetch('pcv_select_row') . '";');
116 // ############ Start construct_pcv_select_global_version ############
117 function construct_pcv_select_global_version($product = 0, $component = 0, $versions = array(), $prefix = '', $select = '')
120 if (is_array($versions['0']))
122 foreach ($versions['0'] AS $version)
124 $row['prefix'] = $prefix . $prefix. ' ';
125 $row['typeselect'] = $type;
126 $row['value'] = "p{$product}c{$component}v$version[versionid]";
127 $row['selected'] = (($select == $row['value']) ?
' selected="selected"' : '');
128 $row['title'] = $version['version'];
129 $row['optgroup'] = false
;
130 $row['description'] = '';
131 $show['input'] = true
;
132 eval('$global_versions_html .= "' . $bugsys->template
->fetch('pcv_select_row') . '";');
135 return $global_versions_html;
138 // ###################### Start parse_pcv_select #####################
139 function parse_pcv_select($input, $validate = false
)
143 $input = trim($input);
146 yummy regex tests....
147 var_dump(preg_match('#^p(\d+?)c(\d+?)v(\d+?)$#', $input));
148 var_dump(preg_match('#^p(\d.+?)c(\d.+?)v(\d.+?)$#', $input));
149 var_dump(preg_match('#^p([0-9]+?)c([0-9]+?)v([0-9]+?)$#', $input));
150 var_dump(preg_match('#^p([0-9].+?)c([0-9].+?)v([0-9].+?)$#', $input));
153 if (preg_match('#^p(\d+?)c(\d+?)v(\d+?)$#', $input) == 0)
158 $trio = preg_split('#(p|c|v)#i', $input, -1, PREG_SPLIT_NO_EMPTY
);
159 if (count($trio) != 3)
164 $pcv = array('product' => intval($trio[0]), 'component' => intval($trio[1]), 'version' => intval($trio[2]));
172 // -------------------------------------------------------------------
174 $product = $bugsys->datastore
['product'][ $pcv['product'] ];
179 $version = $bugsys->datastore
['version'][ $pcv['version'] ];
185 if ($pcv['component'] == 0)
187 // not global version and version.productid != product.productid
188 if ($version['productid'] != 0 AND $version['productid'] != $product['productid'])
196 $component = $bugsys->datastore
['product'][ $pcv['component'] ];
197 // component has the right mother
198 if ($component['componentmother'] == $product['productid'])
200 // version.productid != {component.productid | product.productid}
201 if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0)
217 /*=====================================================================*\
218 || ###################################################################
221 || ###################################################################
222 \*=====================================================================*/