Please take our Survey
logo       

Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

mantisbt/core custom_field_api.php,1.44,1.45 custom_function_api.php,1.11,1: msg#00034

bug-tracking.mantis.cvs

Subject: mantisbt/core custom_field_api.php,1.44,1.45 custom_function_api.php,1.11,1.12

Update of /cvsroot/mantisbt/mantisbt/core
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2968/core

Modified Files:
custom_field_api.php custom_function_api.php
Log Message:
Support for custom values for dynamically generated possible values. This can
be done by setting the possible values field of the custom field to
"=<custom_func>" rather than "fixed_a|fixed_b|fixed_c". There are two
implemented examples, "=versions_enum" and "=categories_enum". See
core/custom_function_api.php.

Index: custom_function_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/custom_function_api.php,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- custom_function_api.php 17 Dec 2004 02:42:09 -0000 1.11
+++ custom_function_api.php 22 Jan 2005 02:20:23 -0000 1.12
@@ -136,4 +136,39 @@
}
}

+ # --------------------
+ # Construct an enumeration for all versions for the current project.
+ # The enumeration will be empty if current project is ALL PROJECTS.
+ # Enumerations format is: "abc|lmn|xyz"
+ # To use this in a custom field type "=versions_enum" in the possible
values field.
+ function custom_function_default_versions_enum() {
+ $t_versions = version_get_all_rows(
helper_get_current_project() );
+
+ $t_enum = array();
+ foreach( $t_versions as $t_version ) {
+ $t_enum[] = $t_version['version'];
+ }
+
+ $t_possible_values = implode( '|', $t_enum );
+
+ return $t_possible_values;
+ }
+
+ # --------------------
+ # Construct an enumeration for all categories for the current project.
+ # The enumeration will be empty if current project is ALL PROJECTS.
+ # Enumerations format is: "abc|lmn|xyz"
+ # To use this in a custom field type "=categories_enum" in the possible
values field.
+ function custom_function_default_categories_enum() {
+ $t_categories = category_get_all_rows(
helper_get_current_project() );
+
+ $t_enum = array();
+ foreach( $t_categories as $t_category ) {
+ $t_enum[] = $t_category['category'];
+ }
+
+ $t_possible_values = implode( '|', $t_enum );
+
+ return $t_possible_values;
+ }
?>
\ No newline at end of file

Index: custom_field_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/custom_field_api.php,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- custom_field_api.php 15 Dec 2004 11:08:32 -0000 1.44
+++ custom_field_api.php 22 Jan 2005 02:20:23 -0000 1.45
@@ -12,6 +12,7 @@
$t_core_dir = dirname( __FILE__ ).DIRECTORY_SEPARATOR;

require_once( $t_core_dir . 'bug_api.php' );
+ require_once( $t_core_dir . 'helper_api.php' );

### Custom Fields API ###

@@ -852,6 +853,20 @@
}

# --------------------
+ # $p_possible_values: possible values to be pre-processed. If it has
enum values,
+ # it will be left as is. If it has a method, it
will be replaced
+ # by the list.
+ function custom_field_prepare_possible_values( $p_possible_values ) {
+ $t_possible_values = $p_possible_values;
+
+ if ( !is_blank( $t_possible_values ) && ( $t_possible_values[0]
== '=' ) ) {
+ $t_possible_values = helper_call_custom_function(
substr( $t_possible_values, 1 ), array() );
+ }
+
+ return $t_possible_values;
+ }
+
+ # --------------------
# Get All Possible Values for a Field.
function custom_field_distinct_values( $p_field_id, $p_project_id =
ALL_PROJECTS ) {
$c_field_id =
db_prepare_int( $p_field_id );
@@ -878,7 +893,9 @@
CUSTOM_FIELD_TYPE_LIST == $row['type'] ||
CUSTOM_FIELD_TYPE_MULTILIST == $row['type']
) {
- $t_values_arr = explode( '|', $row['possible_values'] );
+ $t_possible_values =
custom_field_prepare_possible_values( $row['possible_values'] );
+
+ $t_values_arr = explode( '|', $t_possible_values );

foreach( $t_values_arr as $t_option ) {
array_push( $t_return_arr, $t_option );
@@ -1079,7 +1096,7 @@
case CUSTOM_FIELD_TYPE_ENUM:
case CUSTOM_FIELD_TYPE_LIST:
case CUSTOM_FIELD_TYPE_MULTILIST:
- $t_values = explode( '|',
$p_field_def['possible_values'] );
+ $t_values = explode( '|',
custom_field_prepare_possible_values( $p_field_def['possible_values'] ) );
$t_list_size = $t_possible_values_count = count(
$t_values );

if ( $t_possible_values_count > 5 ) {
@@ -1107,7 +1124,7 @@
echo '</select>';
break;
case CUSTOM_FIELD_TYPE_CHECKBOX:
- $t_values = explode( '|',
$p_field_def['possible_values'] );
+ $t_values = explode( '|',
custom_field_prepare_possible_values( $p_field_def['possible_values'] ) );
$t_checked_values = explode( '|', $t_custom_field_value
);
foreach( $t_values as $t_option ) {
echo '<input type="checkbox"
name="custom_field_' . $t_id . '[]"';



-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
video.h264.deve...    technology.erps...    drivers.hostap/...    user-groups.lin...    games.railroad-...    handhelds.linux...    lang.harbour.de...    recreation.radi...    culture.publica...    xfree86.devel/2...    music.john-cage...    otrs.cvs/2003-0...    network.e-smith...    asplinux.suppor...    qnx.openqnx.dev...    ietf.nfsv4/2005...    editors.vim/200...    kde.devel.kopet...    web.zope.zwiki....    freebsd.devel.m...    java.xdoclet.de...    php.simpletest....    bacula.user/200...    security.virus....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe

Navigation