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.53,1.54 filter_api.php,1.113,1.114: msg#00006

bug-tracking.mantis.cvs

Subject: mantisbt/core custom_field_api.php,1.53,1.54 filter_api.php,1.113,1.114

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

Modified Files:
custom_field_api.php filter_api.php
Log Message:
fix for 0005696: Custom Field not shown in manage_custom_field_page.php after
creation
- originated from confugion / merging of custom_field_get_ids() and
custom_field_get_linked_ids. The former will now always return all ids.
The latter can take a project id (or array of project ids) and returns
only those fields linked to the project


Index: custom_field_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/custom_field_api.php,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- custom_field_api.php 1 Jun 2005 13:28:20 -0000 1.53
+++ custom_field_api.php 3 Jun 2005 16:03:14 -0000 1.54
@@ -596,8 +596,10 @@
}

# --------------------
- # Return an array all custom field ids
- function custom_field_get_ids( $p_project_id = ALL_PROJECTS ) {
+ # Return an array of ids of custom fields bound to the specified project
+ #
+ # The ids will be sorted based on the sequence number associated with
the binding
+ function custom_field_get_linked_ids( $p_project_id = ALL_PROJECTS ) {
$t_custom_field_table = config_get(
'mantis_custom_field_table' );
$t_custom_field_project_table = config_get(
'mantis_custom_field_project_table' );

@@ -626,22 +628,31 @@
# or private projects where the user is implicitly listed
$query = "SELECT distinct cft.id as id, cft.name as name
FROM $t_custom_field_table as cft
- JOIN $t_custom_field_project_table as cfpt
- JOIN $t_project_table as pt
- LEFT JOIN $t_project_user_list_table as pult
+ JOIN $t_custom_field_project_table cfpt
+ JOIN $t_project_table pt
+ LEFT JOIN $t_project_user_list_table pult
on cfpt.project_id = pult.project_id and pult.user_id
= $t_user_id
- JOIN $t_user_table as ut
+ JOIN $t_user_table ut
WHERE cft.id = cfpt.field_id AND cfpt.project_id = pt.id AND
ut.id = $t_user_id AND
( pt.view_state = $t_pub OR
( pt.view_state = $t_priv and pult.user_id = $t_user_id )
OR
( pult.user_id is null and ut.access_level
$t_access_clause ) )
- ORDER BY name ASC";
+ ORDER BY cfpt.sequence ASC, cft.name ASC";
} else {
- $query = "SELECT $t_custom_field_table.id,
$t_custom_field_table.name
- FROM $t_custom_field_table,
$t_custom_field_project_table
- WHERE
$t_custom_field_project_table.project_id = '$p_project_id' AND
-
$t_custom_field_table.id = $t_custom_field_project_table.field_id
- ORDER BY name ASC";
+ if ( is_array( $p_project_id ) ) {
+ if ( 1 == count( $p_project_id ) ) {
+ $t_project_clause = "= " . array_shift(
$p_project_id ) . " ";
+ } else {
+ $t_project_clause = "IN (" . implode( ',', $p_project_id )
. ")";
+ }
+ } else {
+ $t_project_clause = "= $p_project_id ";
+ }
+ $query = "SELECT cft.id, cft.name, cfpt.sequence
+ FROM $t_custom_field_table cft,
$t_custom_field_project_table cfpt
+ WHERE cfpt.project_id
$t_project_clause AND
+ cft.id = cfpt.field_id
+ ORDER BY sequence ASC, name ASC";
}
$result = db_query( $query );
$t_row_count = db_num_rows( $result );
@@ -657,19 +668,12 @@
}

# --------------------
- # Return an array of ids of custom fields bound to the specified project
- #
- # The ids will be sorted based on the sequence number associated with
the binding
- function custom_field_get_linked_ids( $p_project_id ) {
- $c_project_id = db_prepare_int( $p_project_id );
-
- $t_custom_field_project_table = config_get(
'mantis_custom_field_project_table' );
+ # Return an array all custom field ids sorted by name
+ function custom_field_get_ids( ) {
$t_custom_field_table = config_get(
'mantis_custom_field_table' );
- $query = "SELECT field_id
- FROM $t_custom_field_project_table p,
$t_custom_field_table f
- WHERE p.project_id='$c_project_id' AND
- p.field_id=f.id
- ORDER BY p.sequence ASC, f.name ASC";
+ $query = "SELECT id, name
+ FROM $t_custom_field_table
+ ORDER BY name ASC";
$result = db_query( $query );
$t_row_count = db_num_rows( $result );
$t_ids = array();
@@ -677,7 +681,7 @@
for ( $i=0 ; $i < $t_row_count ; $i++ ) {
$row = db_fetch_array( $result );

- array_push( $t_ids, $row['field_id'] );
+ array_push( $t_ids, $row['id'] );
}

return $t_ids;

Index: filter_api.php
===================================================================
RCS file: /cvsroot/mantisbt/mantisbt/core/filter_api.php,v
retrieving revision 1.113
retrieving revision 1.114
diff -u -d -r1.113 -r1.114
--- filter_api.php 3 Jun 2005 14:04:58 -0000 1.113
+++ filter_api.php 3 Jun 2005 16:03:14 -0000 1.114
@@ -592,7 +592,7 @@
# custom field filters
if( ON == config_get( 'filter_by_custom_fields' ) ) {
# custom field filtering
- $t_custom_fields = custom_field_get_ids(); # @@@@
Shouldn't the filter be on project specific custom fields?
+ $t_custom_fields = custom_field_get_linked_ids(
$t_project_id );

foreach( $t_custom_fields as $t_cfid ) {
$t_first_time = true;
@@ -1011,7 +1011,7 @@
$t_per_row = 0;

if ( ON == config_get( 'filter_by_custom_fields' ) ) {
- $t_custom_fields = custom_field_get_ids(
$t_project_id );
+ $t_custom_fields = custom_field_get_linked_ids(
$t_project_id );

foreach ( $t_custom_fields as $t_cfid ) {
$t_field_info = custom_field_cache_row(
$t_cfid, true );
@@ -2306,7 +2306,7 @@
$p_filter_arr['relationship_bug'] = gpc_get_int(
'relationship_bug', 0 );
}

- $t_custom_fields = custom_field_get_ids();
+ $t_custom_fields = custom_field_get_ids(); # @@@
(thraxisp) This should really be the linked ids, but we don't know the project
$f_custom_fields_data = array();
if ( is_array( $t_custom_fields ) && ( sizeof( $t_custom_fields
) > 0 ) ) {
foreach( $t_custom_fields as $t_cfid ) {



-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005


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

Recently Viewed:
user-groups.jax...    php.zend.framew...    os.solaris.open...    web.quixote.use...    java.openjdk.ho...    ietf.secmech/20...    gnu.glpk/2004-0...    recreation.cars...    network.smokepi...    linux.drivers.i...    cms.opencms.dev...    fonts.gfontview...    text.xml.soap.u...    voip.nist-sip/2...    debian.ports.hp...    xfree86.interna...    science.biology...    qnx.openqnx.dev...    mail.sylpheed.c...    busybox/bios/20...    emulators.kvm.s...    hardware.openco...    apple.fink.begi...    kde.german/2006...   
Home | 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