$t_key, 'name' => $t_translated, ); } return $t_result; } /** * Validates that the user has access to the enumeration values * * @param string $p_username * @param string $p_password * @return boolean true if the user has access, false otherwise */ function mci_validate_enum_access($p_username, $p_password) { $t_user_id = mci_check_login( $p_username, $p_password ); if( $t_user_id === false ) { return false; } if( !mci_has_readonly_access( $t_user_id ) ) { return false; } return true; } /** * Get a localized enumeration element. * * @param integer $p_enum_id The id of the enumeration element to retrieve. * @param String $p_enum_type The type of the enumeration element (e.g. 'status', 'reproducibility' etc.). * @param String $p_lang The language for the name field. * @return Array an Array containing the id and the name of the enumeration element. */ function mci_enum_get_array_by_id( $p_enum_id, $p_enum_type, $p_lang ) { $t_result = array(); $t_result['id'] = $p_enum_id; $t_result['name'] = mci_get_enum_element( $p_enum_type, $p_enum_id, $p_lang ); return $t_result; } /** * Get the enum id given the enum label. * * @param $p_enum_string The enum string to search in. * @param $p_label The label to search for. * * @return The id corresponding to the given label, or 0 if not found. */ function mci_get_enum_value_from_label( $p_enum_string, $p_label ) { $t_value = MantisEnum::getValue( $p_enum_string, $p_label ); if ( $t_value === false ) { return 0; } return $t_value; } /** * Get the enumeration id given an object ref. The id is set based on the following algorithm: * - id from objectref. * - id corresponding to name in object ref. * - default value for the specified enumeration, if exists in configuration. * - first id, if object ref doesn't contain an id or a name. * * @param string $p_enum The name of the enumeration as in the MantisBT configuration file * @param ObjectRef $p_object_ref An associate array with "id" and "name" keys. * @return enum id */ function mci_get_enum_id_from_objectref( $p_enum, $p_object_ref ) { $p_object_ref = SoapObjectsFactory::unwrapObject( $p_object_ref ); if( !is_null( $p_object_ref ) && isset( $p_object_ref['id'] ) && (int) $p_object_ref['id'] != 0 ) { $t_id = (int) $p_object_ref['id']; } else { $t_enum = config_get( $p_enum . '_enum_string' ); if( !is_null( $p_object_ref ) && isset( $p_object_ref['name'] ) && !is_blank( $p_object_ref['name'] ) ) { $t_id = mci_get_enum_value_from_label( $t_enum, $p_object_ref['name'] ); if( $t_id == 0 ) { $t_id = config_get( 'mc_' . $p_enum . '_enum_default_when_not_found' ); } } else { $t_default_id = config_get( 'default_bug_' . $p_enum, 0 ); if( $t_default_id == 0 ) { $t_array = mci_explode_to_objectref( $p_enum ); $t_id = (int) $t_array[0]['id']; } else { $t_id = $t_default_id; } } } return $t_id; }