From: <vb...@us...> - 2003-01-09 03:59:20
|
Update of /cvsroot/mantisbt/mantisbt/core In directory sc8-pr-cvs1:/tmp/cvs-serv4496/core Modified Files: custom_field_api.php email_api.php project_api.php Log Message: The aim of this commit is to use consistent terminology in custom_field_api.php: a. Use Create / Destroy for custom field definitions b. Use Link / Unlink to link/unlink fields to projects Following were the changes: - Merged some error checking from custom_field_bind() to custom_field_add() - Delete custom_field_bind() which was a duplicate of custom_field_add() - Renamed custom_field_add() to custom_field_link() - Renamed custom_field_remove() to custom_field_unlink() - Renamed custom_field_delete_associations() to custom_field_unlink_all() - Renamed custom_field_in_project() to custom_field_is_linked() - Renamed custom_field_delete() to custom_field_destroy() - Renamed custom_field_get_bound_ids() to custom_field_get_linked_ids() Index: custom_field_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/custom_field_api.php,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- custom_field_api.php 8 Jan 2003 05:55:26 -0000 1.11 +++ custom_field_api.php 9 Jan 2003 03:59:17 -0000 1.12 @@ -67,8 +67,7 @@ # Check to see whether the field is included in the given project # return true if the field is included, false otherwise # - # @@@ Rename to custom_field_is_linked() - function custom_field_in_project( $p_field_id, $p_project_id ) { + function custom_field_is_linked( $p_field_id, $p_project_id ) { $c_project_id = db_prepare_int( $p_project_id ); $c_field_id = db_prepare_int( $p_field_id ); @@ -214,36 +213,6 @@ } # -------------------- - # bind a custom field with the id $p_field_id to the - # project $p_project_id - # return true on success - # return false if an error occures (e.g. non existing id) - # - # @@@ Seems to be a duplicate to custom_field_add() - function custom_field_bind( $p_field_id, $p_project_id ) { - $c_field_id = db_prepare_int( $p_field_id ); - $c_project_id = db_prepare_int( $p_project_id ); - - custom_field_ensure_exists( $p_field_id ); - project_ensure_exists( $p_project_id ); - - if( custom_field_in_project( $p_field_id, $p_project_id ) ) { - return false; - } - $t_custom_field_project_table = config_get( 'mantis_custom_field_project_table' ); - $query = "INSERT INTO - $t_custom_field_project_table - ( field_id, project_id ) - VALUES - ( '$c_field_id', '$c_project_id' )"; - - db_query( $query ); - # db_qery returns false if there's a problem - - return true; - } - - # -------------------- # Update the field definition # return true on success, false on failure function custom_field_update( $p_field_id, $p_def_array ) { @@ -359,15 +328,16 @@ # -------------------- # Add a custom field to a project - # return true on success, false on failure - # - # @@@ Should be renamed to custom_field_link() - function custom_field_add( $p_field_id, $p_project_id ) { + # return true on success, false on failure or if already added + function custom_field_link( $p_field_id, $p_project_id ) { $c_field_id = db_prepare_int( $p_field_id ); $c_project_id = db_prepare_int( $p_project_id ); - if ( custom_field_in_project( $p_field_id, $p_project_id ) ) { - return true; + custom_field_ensure_exists( $p_field_id ); + project_ensure_exists( $p_project_id ); + + if ( custom_field_is_linked( $p_field_id, $p_project_id ) ) { + return false; } $t_custom_field_project_table = config_get( 'mantis_custom_field_project_table' ); @@ -388,9 +358,7 @@ # The values for the custom fields are not deleted. This is to allow for the # case where a bug is moved to another project that has the field, or the # field is linked again to the project. - # - # @@@ Should be renamed to custom_field_unlink() - function custom_field_remove( $p_field_id, $p_project_id ) { + function custom_field_unlink( $p_field_id, $p_project_id ) { $c_field_id = db_prepare_int( $p_field_id ); $c_project_id = db_prepare_int( $p_project_id ); @@ -408,9 +376,7 @@ # Delete the field definition and all associated values and project # associations # return true on success, false on failure - # - # @@@ Should be renamed to custom_field_destroy() - function custom_field_delete( $p_field_id ) { + function custom_field_destroy( $p_field_id ) { $c_field_id = db_prepare_int( $p_field_id ); # delete all values @@ -443,9 +409,7 @@ # return true on success, false on failure # # To be called from within project_delete(). - # - # @@@ custom_field_unlink_all() - function custom_field_delete_associations( $p_project_id ) { + function custom_field_unlink_all( $p_project_id ) { $c_project_id = db_prepare_int( $p_project_id ); # delete all project associations @@ -505,9 +469,7 @@ # 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 - # - # @@@ Rename to custom_field_get_linked_ids() - function custom_field_get_bound_ids( $p_project_id ) { + 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' ); Index: email_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/email_api.php,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- email_api.php 3 Jan 2003 03:24:24 -0000 1.37 +++ email_api.php 9 Jan 2003 03:59:17 -0000 1.38 @@ -490,7 +490,7 @@ # @@@ Add support for access levels, possible only send the ones that are available for access level EVERYBODY if ( ON == config_get( 'use_experimental_custom_fields' ) ) { - $t_related_custom_field_ids = custom_field_get_bound_ids( $v_project_id ); + $t_related_custom_field_ids = custom_field_get_linked_ids( $v_project_id ); foreach( $t_related_custom_field_ids as $t_id ) { $t_def = custom_field_get_definition( $t_id ); Index: project_api.php =================================================================== RCS file: /cvsroot/mantisbt/mantisbt/core/project_api.php,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- project_api.php 3 Jan 2003 03:24:25 -0000 1.23 +++ project_api.php 9 Jan 2003 03:59:17 -0000 1.24 @@ -197,7 +197,7 @@ # Delete associations with custom field definitions. if ( ON == config_get( 'use_experimental_custom_fields' ) ) { - custom_field_delete_associations( $p_project_id ); + custom_field_unlink_all( $p_project_id ); } # Delete the project categories |