lang->string('Guest'); } } // ################## Start construct_option_select ################## // creates a ' . implode("\n\t", $opts) . "\r"; } // ################### Start construct_user_display ################## // $userinfo needs userid, email, displayname, and showemail function construct_user_display($userinfo, $html = true) { global $bugsys; fetch_user_display_name($userinfo); if ($html) { eval('$username = "' . $bugsys->template->fetch('username_display') . '";'); } else { if ($userinfo['showemail']) { $username = sprintf($bugsys->lang->string('%1$s <%2$s>'), $userinfo['displayname'], $userinfo['email']); } else { $username = $userinfo['displayname']; } } return $username; } // ######################## Start can_perform ######################## // short-hand for bitwise & function can_perform($bitmask, $userinfo = null) { global $_PERMISSION; if (!isset($_PERMISSION["$bitmask"])) { trigger_error('Invalid bitmask "' . $bitmask . '" specified for can_perform() [includes/functions.php]', E_USER_WARNING); } if (!$userinfo) { global $bugsys; return ($bugsys->userinfo['permissions'] & $_PERMISSION["$bitmask"]); } return ($userinfo['permissions'] & $_PERMISSION["bitmask"]); } // #################### Start construct_pcv_select ################### // constructs a product/component/version select with one go :-) // NB: need to make sure we have the option to turn off just p/c selection without v function construct_pcv_select($select = '', $prefix = '--') { global $bugsys; static $HTML; if ($HTML) { return $HTML; } $selected = ' selected="selected"'; foreach ($bugsys->datastore['product'] AS $product) { if ($product['componentmother']) { $components["$product[componentmother]"]["$product[productid]"] = $product; } else { $products["$product[productid]"] = $product; } } foreach ($bugsys->datastore['version'] AS $version) { $versions["$version[productid]"]["$version[versionid]"] = $version; } foreach ($products AS $product) { $row['prefix'] = ''; $valuepfx = "p$product[productid]"; $row['value'] = "{$valuepfx}c0v0"; $row['title'] = $product['title']; $row['optgroup'] = true; $row['description'] = $product['description']; $show['input'] = false; $begin = true; eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";'); $HTML .= construct_pcv_select_global_version($product['productid'], 0, $versions, $prefix, $select); if (is_array($versions["$product[productid]"])) { foreach ($versions["$product[productid]"] AS $version) { $row['prefix'] = $prefix . $prefix . ' '; $row['value'] = "{$valuepfx}c0v$version[versionid]"; $row['title'] = $version['version']; $row['optgroup'] = false; $row['selected'] = (($select == $row['value']) ? $selected : ''); $row['description'] = ''; $show['input'] = true; eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";'); } } if (is_array($components["$product[productid]"])) { foreach ($components["$product[productid]"] AS $component) { $row['prefix'] = $prefix . ' '; $valuepfx .= "c$component[productid]"; $row['value'] = "{$valuepfx}v0"; $row['selected'] = (($select == $row['value']) ? $selected : ''); $row['title'] = $component['title']; $row['depth'] = 1; $row['optgroup'] = true; $begin = true; $row['description'] = $component['description']; $show['input'] = false; eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";'); $HTML .= construct_pcv_select_global_version($component['componentmother'], $component['productid'], $versions, $prefix, $select); if (is_array($versions["$component[productid]"])) { foreach ($versions["$component[productid]"] AS $version) { $show['input'] = true; $row['prefix'] = $prefix . $prefix . ' '; $row['value'] = "{$valuepfx}v$version[versionid]"; $row['selected'] = (($select == $row['value']) ? $selected : ''); $row['title'] = $version['version']; $row['optgroup'] = false; $row['description'] = ''; eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";'); } } } $row['optgroup'] = true; $begin = false; eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";'); } $row['optgroup'] = true; $begin = false; eval('$HTML .= "' . $bugsys->template->fetch('pcv_select_row') . '";'); } return $HTML; } // ############ Start construct_pcv_select_global_version ############ function construct_pcv_select_global_version($product = 0, $component = 0, $versions = array(), $prefix = '', $select = '') { global $bugsys; if (is_array($versions['0'])) { foreach ($versions['0'] AS $version) { $row['prefix'] = $prefix . $prefix. ' '; $row['typeselect'] = $type; $row['value'] = "p{$product}c{$component}v$version[versionid]"; $row['selected'] = (($select == $row['value']) ? ' selected="selected"' : ''); $row['title'] = $version['version']; $row['optgroup'] = false; $row['description'] = ''; $show['input'] = true; eval('$global_versions_html .= "' . $bugsys->template->fetch('pcv_select_row') . '";'); } } return $global_versions_html; } // ###################### Start parse_pcv_select ##################### function parse_pcv_select($input, $validate = false) { global $bugsys; $input = trim($input); /* yummy regex tests.... var_dump(preg_match('#^p(\d+?)c(\d+?)v(\d+?)$#', $input)); var_dump(preg_match('#^p(\d.+?)c(\d.+?)v(\d.+?)$#', $input)); var_dump(preg_match('#^p([0-9]+?)c([0-9]+?)v([0-9]+?)$#', $input)); var_dump(preg_match('#^p([0-9].+?)c([0-9].+?)v([0-9].+?)$#', $input)); */ if (preg_match('#^p(\d+?)c(\d+?)v(\d+?)$#', $input) == 0) { return false; } $trio = preg_split('#(p|c|v)#i', $input, -1, PREG_SPLIT_NO_EMPTY); if (count($trio) != 3) { return false; } $pcv = array('product' => intval($trio[0]), 'component' => intval($trio[1]), 'version' => intval($trio[2])); if (!$validate) { return $return; } else { // ------------------------------------------------------------------- // pcv validation $product = $bugsys->datastore['product'][ $pcv['product'] ]; if (!$product) { return false; } $version = $bugsys->datastore['version'][ $pcv['version'] ]; if (!$version) { return false; } // no component if ($pcv['component'] == 0) { // not global version and version.productid != product.productid if ($version['productid'] != 0 AND $version['productid'] != $product['productid']) { return false; } } // using a component else { $component = $bugsys->datastore['product'][ $pcv['component'] ]; // component has the right mother if ($component['componentmother'] == $product['productid']) { // version.productid != {component.productid | product.productid} if (($version['productid'] != $component['productid'] AND $version['productid'] != $product['productid']) AND $version['productid'] != 0) { return false; } } else { return false; } } return $pcv; } } // ################# Start construct_datastore_select ################ // loops through the specified datastore to create