Mantis Logo
Mantis Manual
Manual
Customizing Mantis

Custom Fields
Enumerations
Email Notifications
Customizing Status Values
LDAP
Custom Functions


Partner Links


Custom Fields
Last Modified: December 15, 2003 02:12AM
(0.18.0)
Description

There have been multiple requests to add certain fields to Mantis bugs. These requests were not realised because of the concern that they might over complicate the usage of Mantis while not add value for most users.

Hence, Mantis 0.18.0 introduces custom fields to enable project managers to define extra fields for their projects.

Following are some facts about the implementation of custom fields in Mantis:
  • Custom fields are defined system wide.
  • Custom fields can be linked to multiple projects.
  • The sequence of displaying custom fields can be different per project.
  • Custom fields must be defined by users with access level ADMINISTRATOR.
  • Custom fields can be linked to projects by users with access level MANAGER or above (by default, this can be configurable).
  • Number of custom fields is not restricted.

The definition of a custom field includes the following logical attributes:
  • Caption variable name (eg: This is the value that is supplied to lang_get() API, or displayed as-is if not found in language file).
  • Custom field type (string, numeric, float, enum, email)
  • Enumeration possible values (eg: RED|YELLOW|BLUE).
    Use the pipe ('|') character to separate possible values for an enumeration. One of the possible values can be an empty string.
  • Default value.
  • Minimum/maximum length for the custom field value (use 0 to disable).
  • Regular expression to use for validating user input (use ereg() syntax).
  • Advanced? no: Show in simple/advanced pages, yes: Show only in advanced pages.
  • All custom fields are currently saved to a field of type VARCHAR(255) in the database. However, in future releases, it is possible to support custom fields of different types (eg: memo, date, datetime, file).
  • Read Access level: Minimum access level for users to be able to see the value of the custom field.
  • Write Access level: Minimum access level for users to be able to edit the value of the custom field.

If the value of a custom field for a certain defect is not found, the default value is assumed.

Adding/Editing Custom Fields Definitions
  • The logged in user needs manage_custom_fields_threshold access level.
  • Select "Manage" from the main menu.
  • Select "Manage Custom Fields" from the management menu.
  • Click on the name of an existing custom field to edit its information.
  • Enter the name of the new custom field then click "New Custom Field" to add a new field.

Linking/Unlinking/Ordering Existing Custom Fields in Projects
  • The logged in user needs to have access level that is greater than or equal to $g_custom_field_link_threshold and $g_manage_project_threshold.
  • Select "Manage" from the main menu.
  • Select "Manage Projects" in case you are administrator.
  • Select the name of the project to manage.
  • Scroll down to the "Custom Fields" box.
  • Select the field to add from the list, then click "Add This Existing Custom Field".
  • To change the order of the custom fields, edit the "Sequence" value and click update. Custom fields with smaller values are displayed first.
  • To unlink a custom field, click on "Remove" link next to the field.

    Unlinking a custom field will not delete the values that are associated with the bugs for this field. These values are only deleted if the custom field definition is removed (not unlinked!) from the database. This is useful if you decide to re-link the custom field. These values may also re-appear if bugs are moved to another project which has this field linked.

Moving Bugs

When a bug is moved from one project to another, custom fields that are not defined for the new project are not deleted. These fields will re-appear with their correct values if the bug is moved back to the original project, or if these custom fields are linked to the new project.

Custom Severities, Priorites, Statuses, ...etc

This is a completely different issue. See Enumerations for more details about this issue.

Possible Future Enhancements
  • Make custom field searchable.
  • Ability to filter on values of custom fields.
  • Support more field types: date, datetime, memo, file.
  • Support custom fields in resolve/close bugs pages.
  • Control the visibility / mandatory state of custom fields depending on the stage in which the bug is at (eg: reporting, updating, resolving, closing).
  • Ability to export custom fields to csv, Excel, Word.
  • Ability to make a custom field visible in View Bugs page (this also applies for non-custom fields).
  • Ability to filter on custom fields in View Bugs page (this also applies for non-custom fields that are not supported in the filter.
  • Support populating custom fields from LDAP.
  • Support populating custom fields via a SELECT SQL query. The query can use a set of variables like be a $sql_user_id, $sql_project_id, $sql_xxx.

If you are interested in any of the above enhancements and have the time/skills required to implemented it, please contact the development team to make sure that your work can be integrated into Mantis future releases.

User Contributed Notes
Custom Fields
Add Notes About Notes
piccioli@netseven.it
08-Nov-2003 6:06
#23
[Editor] Although the above list of future enhancements was not meant to be comprehensive, it is now updated to include the filtering feature.

---

I suggest you (for the future versions) to add the possibility to set a custom field as filter in the view Bug page.

   Alessio
mulrich@bctNO-techSPAMogy.com
20-Nov-2003 11:17
#25
[Editor] Filtering custom fields is now implemented and will be available in Mantis 0.19.0. However, search is not yet implemented.

--> Make custom field searchable. <--

For me this really would be the next thing to do in the system.
This is what my [Mantis] users requested already.

Also, I agree with above, the ability to filter in View Bug Page would be very good too...

The approach that has been choosen so far for custom fields seems to work fine here.
g906705@alumni.nthu.edu.tw
27-Nov-2003 21:41
#29
Will the customized fields be added into the print options, too?
bottenhoopNOFREAKINGSPAM@hotmailfrombill.com
04-Dec-2003 8:44
#31
[Editor] There is already a feature request in the bugtracker for supporting date custom fields. For more details see http://mantis.calaquendi.net/bug_view_advanced_page.php?bug_id=0002984

---

I was asked to add a date field. so the planning date for a bug to be fixed could be added. Any idea's of how to do that?
rabbe.kurten@rkrealtidssystem.com
10-Dec-2003 8:06
#33
[Editor] This issue is now added to the bug tracker. For more details, see http://mantis.calaquendi.net/bug_view_advanced_page.php?bug_id=0003460

---

I can get the custom fields ordered between themselves OK, but how do I get them into the ordinary tab sequence. When I press the tab key within a custom field I jump somewhere into one of the ordinary fields depending on where I was before going into the custom field. Is there a solution to this problem?
Rabbe Kurtén, Stockholm
enno@despammed.com
04-Mar-2004 15:45
#81
[Editor] Custom field names are already customisable. This can be done for a custom field named my_custom_field by defining $s_my_custom_field in custom_strings_inc.php.

Making custom fields localizable would be on my list of enhancements.
alex.vanderlinden@atosorigin.com
27-Apr-2004 2:27
#125
Adding the Custom Fields to the export/print functionality would be of great value!
vishwanath@qsgsoft.com
10-Jun-2004 0:22
#152
Please help me to "Customization of terminology". for eg:
then name Category need to be changed as "Bug Category"
antoineder@yahoo.com
29-Nov-2004 9:58
#274
I want to apply filters on values of custom fields.
and do some exports liked to custom fields to csv, Excel, Word.

I have allready implemented my custom field, but i don't understand how to make it active in my process.
Zeevikn@gonetworks.com
19-Dec-2004 8:39
#293
Hi

Is there a way to make a custom field options selection, depends ona categtory selection ?

i.e.
If I select category-1, the custom_field options are 1,2,3
If I select category-2, the custom_field options are A,B,C
??

The general prpuse is to get a three-level system, each level options depends on the "parent" level chosen.

Thanks,
Zeevik Neuman
Go Networks.
imran@imranaziz.net
21-Dec-2004 9:38
#297
How a custom field can be added to main "view issues" report?
lavin@N-OS-P-AMcanit.se
27-Dec-2004 8:38
#300
It would be good if selected custom fields could be included when viewing issues (view_all_bug_page). This would make them much more useful, for example when having a "Deadline" custom field since those are more flexible than the priority field.
yourname@example.com
03-Jan-2005 12:23
#306
As of Mantis 0.19.2, it is important that people considering the use of Mantis realize that Custom Fields *are not* available in Printing Options when generating reports.

So, if you hope to use Mantis to generate reports *and* use custom fields, you should think again.
SPAMdmiller2SPAM@luxotticaJUNKretailBLAH.com
05-Jan-2005 10:48
#308
One enhancement I added to our install of Mantis was limiting the size of cuxtom field textboxes if a maximum length is indicated in the custom field setup.

The maxlength attribute was set, but it just seemed silly to have a size=80 textbox for a field that could only ever have 4 digits.

I've never really worked a whole lot with open source or sourceforge or anything, so I'm not really sure how, if or where I should post my changes. Anyone is welcome to use them and TPTB are welcome to use them in any future release of Mantis.

I changed custom_field_api.php round about line 1119

                case CUSTOM_FIELD_TYPE_NUMERIC:
                case CUSTOM_FIELD_TYPE_FLOAT:
                case CUSTOM_FIELD_TYPE_EMAIL:
                case CUSTOM_FIELD_TYPE_STRING:
                        echo '<input type="text" name="custom_field_' . t_id . '"';
                        if ((0 < $p_field_def['length_max']) &&
                            ($p_field_def['length_max'] < 80)) {
                                echo ' size="' .
$p_field_def['length_max'] . '"';
                        } else {
                        echo ' size="80"';
                        }
                        if( 0 < $p_field_def['length_max'] ) {
                                echo ' maxlength="' .
$p_field_def['length_max'] . '"';
                        } else {
                                echo ' maxlength="255"';
                        }



Apologies if the formatting isn't quite right - but you should get the picture.
pl@techusers.com
13-Jan-2005 16:10
#323
I wanted to add a custom field that held an enumerated list of customers to identify the customer with the reported issue. However, the length of the input field is only 255 characters and is not nearly enough for even a list of customer numbers, much less customer names. (sigh)

It would be *great* to have the ability to define a custom field that draws its list of enumerated values from a database table since it's using a db already.
m_rufo@yahoo.es
07-Apr-2005 12:49
#404
Regarding notes #31 and #33 I have tried to enter in the URL but the page is not found.How can I get this information?
rudy.fontaine@valeo.com
22-Apr-2005 8:49
#416
I do not know how to have a 'multiline' custom fields as the field description
dctemp1@NSPags.ro
20-May-2005 4:21
#438
I would like to have the possibility to set
Required On Report, Required On Update, Required On Resolve, Required On Close properties differently for each project.

There are cases in which a custom field is Mandatory to be filled in when reporting an issue for a project but not mandatory for other project.

Thanks,
Dan Cristian
b.giraudier AT focal.NOSPAMfr
21-Jun-2005 11:34
#480
Is there a problem with Custom fields in v.1.0.0a3?
I can create a new custom field and edit it immediatly after its creation (automatic redirection) but the table containing custom fields in the Manage Custom fields page is still empty after validation.
A new custom field entry is created in the mantis_custom_field_table but it won't appear : neither in the Manage Custom Field page nor in the Manage Project page.

I can't find why this is happening while it is working with other versions (tested with 0.19.2 and 1.0.0a2).
masala@web.de
24-Jun-2005 6:03
#486
Got the same problem and I guess the reason is somewhere in
function custom_field_get_ids() from file core/custom_field_api.php. Perhaps someone more experienced in PHP should take a look on that. My PHP knowledge is tiny and it would take some time to get into it right now.
tryweb@ichiayi.com
06-Jul-2005 12:29
#501
After traced manage_proj_edit_page.php & custom_field_api.php, I think the problem should be from the table, mantis_custom_field_project_table, no row.

In custom_field_api.php -> function custom_field_get_ids
the SQL statement need to join mantis_custom_field_project_table; however, there is no row in the table.

I hope the information is helpful for developers.
tryweb@ichiayi.com
06-Jul-2005 13:14
#502
Actually I just had solved the problem.

Just update custom_field_api.php (mantis/core/)

search the key word : "function custom_field_get_ids"

update 1:
 if ( ALL_PROJECTS == $p_project_id ) <-- before update
 if ( ALL_PROJECTS != $p_project_id ) <-- after update

Update 2:
$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"; <-- brfore update

$query = "SELECT $t_custom_field_table.id, $t_custom_field_table.name
 FROM $t_custom_field_table
 ORDER BY name ASC"; <-- after update


Jonathan Tsai.
cedric3c@yahoo.fr
08-Jul-2005 9:11
#510
OK but how do you use it? I'm still unable with this to make it to appear in a bug report... :(
hbourchi@yahoo.com
15-Jul-2005 9:00
#524
Okay, after implementing the changes, mentioned by TryWeb and making a new custom field, go to your project configuration: Manage --> Manage Projects (choose your desired project here) ---> Custom Fields ---> Add this existing custom field.

It shoud work now.
bingfei001@yahoo.com.cn
22-Jul-2005 4:50
#530
For a custom field, can it is implemented by Combobox instead of EditBox?
marcg
01-Aug-2005 14:35
#547
Hi!

I've managed to display custom fields in the print_all_bug_page_excel.php by adding these lines:

        <?php
        // Added by marcg to display custom fields
$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 );
?>
<td class=xl2216681 nowrap style='border-top:none;border-left:none'>
                <?php echo lang_get_defaulted( $t_def['name'] ) ?>:
                <?php print_custom_field_value( $t_def, $t_id, $v_id ); ?>
        </td>
<?php
} // foreach
?>


in line 230 (just after the status is printed), but you could put it whatever.

You also have to include this:

require_once( $t_core_path.'custom_field_api.php' );

in line 30 to get access to custom field API.

Hope it helps.

By the way, it would be great if the Excel export could have column headers, maybe I'll add this in the future, too.

Using Mantis 1.0.0rc1
kan.izh-dog-gmail.com
09-Sep-2005 11:38
#599
Is it possible to do some aggregate functions for custom fields? Or is there other way to do a field "spent hours to fix item"? This field should be summarizing for items filtered by some criteria. Is it possible?
t.koerner@_NOSPAM_123tk.de
12-Oct-2005 11:33
#645
Hi,

I recently had to install mantis 1.0.0 RC2 at a customers site.

There were some feature lacks, that gave you no access to the print_all_bug_options_page.php from print_all_bug_page.php
I had also no access to custom fields from print_all_bug_options_page.php, so that I could not select them to print in print_all_bug_page_excel.php

However, since this functions are essential to my customer, I had to add those features.

In order to do this, I had to do the patches, which are shown below.

If you are interested, you can download the patched files from http://www.123tk.de/downloads/mantis
They are available for free. It would be nice, if those patches could be merged to the RC3.

All changes are documented.

If you have some questions, feel free to mail.

Patches:

--- Documents/downloads/mantis-1.0.0rc2/print_all_bug_page_excel.php 2005-08-18 17:33:28.000000000 +0200
+++ public_html/cvs_projects/mantis/packages/custom_fields_options_patch/print_all_bug_page_excel.php 2005-10-12 15:07:28.000000000 +0200
@@ -15,13 +15,32 @@
  # The IE icon allows to see or directly print the same result
 ?>
 <?php
- require_once( 'core.php' );
+
+ /**
+ * Array which will store the custom field names
+ *
+ * @author Thorsten Körner
+ * @since 12.10.2005
+ */
+ $cappu_field_names = array();
+
+ require_once( 'core.php' );
 
  $t_core_path = config_get( 'core_path' );
 
  require_once( $t_core_path.'current_user_api.php' );
  require_once( $t_core_path.'bug_api.php' );
  require_once( $t_core_path.'string_api.php' );
+
+
+ /**
+ * Added to give access to the custom fields functions
+ *
+ * @author Thorsten Körner
+ * @since 12.10.2005
+ */
+ require_once( $t_core_path.'custom_field_api.php' );
+
 ?>
 <?php require( 'print_all_bug_options_inc.php' ) ?>
 <?php auth_ensure_user_authenticated() ?>
@@ -99,8 +118,28 @@
  if ( $f_type_page != 'html' ) {
  for ( $i=0 ; $i <$field_name_count ; $i++ ) {
  if ( isset( $t_prefs[$i] ) && ( 1 == $t_prefs[$i] ) ) { ?>
- <td class=xl2316681 style='border-left:none'><?php echo lang_get( $t_field_name_arr[$i] ) ?></td>
+ <td class=xl2316681 style='border-left:none'>
+
+ <?php
+ /**
+ * language output set to lang_get_defaulted, because otherwise the names
+ * of custom fields will send a warning
+ *
+ * @author Thorsten Körner
+ * @since 12.10.2005
+ */
+ echo lang_get_defaulted( $t_field_name_arr[$i] )
+ ?></td>
 <?php
+
+
+ /**
+ * Now lets store the current custom field name
+ *
+ * @author Thorsten Körner
+ * @since 12.10.2005
+ */
+ array_push($cappu_field_names ,lang_get_defaulted( $t_field_name_arr[$i]));
  } //if isset
  } //for
  } //if
@@ -353,6 +392,7 @@
  }# if index
  $name_index++;
 ?>
+
 <?php # Bugnotes BEGIN (3 rows) ?>
 <td colspan="3">
 <?php # print bugnotes
@@ -440,6 +480,34 @@
  } # end for bugnote
  ?>
 <?php # Bugnotes END ?>
+</td>
+
+<?php
+ /**
+ * Get custom fields
+ *
+ * Get custom fields for Excel output
+ * Only fields which are selected on printing options will
+ * be sent to output. This step is adopted from an idea by marcg.
+ * This lines should be the last which are called for output.
+ *
+ * @author thorsten Thorsten Körner <t.koerner@123tk.de>
+ * @since version 1.0.0rc2_123tk.de - 12.10.2005
+ * @return array $t_ids array with ids of custom fields
+ */
+ $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 );
+ if(in_array(lang_get_defaulted( $t_def['name'] ),$cappu_field_names)) {
+ ?>
+ <td class=xl2216681 nowrap style='border-top:none;border-left:none'>
+ <?php print_custom_field_value( $t_def, $t_id, $v_id ); ?>
+ </td>
+ <?php
+ } // if
+ } // foreach
+ ?>
+
 
 </tr>
 <?php

##########################################################
##########################################################
##########################################################

--- Documents/downloads/mantis-1.0.0rc2/print_all_bug_page.php 2005-05-25 01:22:48.000000000 +0200
+++ public_html/cvs_projects/mantis/packages/custom_fields_options_patch/print_all_bug_page.php 2005-10-12 15:19:44.000000000 +0200
@@ -115,6 +115,19 @@
 
 <tr>
  <td colspan="<?php echo $t_num_of_columns ?>">
+
+ <?php
+ /**
+ * Add a table with two columns and some missing links
+ * to access pages like the printing options page
+ *
+ * @author Thorsten Körner
+ * @since 12.10.2005
+ */
+ ?>
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="50%">
 <?php
  if ( 'DESC' == $f_dir ) {
  $t_new_dir = 'ASC';
@@ -141,7 +154,13 @@
  '" ' . $t_icon[2] . '>' .
  '<img src="' . $t_icon_path . $t_icon[3] . '" border="0" align="absmiddle" alt="' . $t_icon[4] . '"></a> ';
  }
+ echo '</td><td width="50%" align="right">';
+ echo ' <a href="my_view_page.php">['.lang_get( 'my_view_link' ).']</a>';
+ echo ' <a href="print_all_bug_options_page.php">['.lang_get( 'printing_options_link' ).']</a>';
+ echo ' <a href="view_all_bug_page.php">['.lang_get( 'view_bugs_link' ).']</a>';
+ echo ' <a href="summary_page.php">['.lang_get( 'summary_link' ).']</a>';
 ?>
+ </td></tr></table>
  </td>
 </tr>
 <?php #<SQLI> ?>

##########################################################
##########################################################
##########################################################



--- Documents/downloads/mantis-1.0.0rc2/print_all_bug_options_inc.php 2004-08-10 12:46:12.000000000 +0200
+++ public_html/cvs_projects/mantis/packages/custom_fields_options_patch/print_all_bug_options_inc.php 2005-10-12 15:10:12.000000000 +0200
@@ -19,7 +19,7 @@
 function get_field_names()
 {
  #currently 27 fields
- return $t_arr = array (
+ $t_arr = array (
  'id',
  'category',
  'severity',
@@ -47,6 +47,18 @@
  'bugnote_title',
  'bugnote_date',
  'bugnote_description' );
+ /**
+ * Now lets store the current custom field name in the $t_arr array
+ *
+ * @author Thorsten Körner
+ * @since 12.10.2005
+ */
+ $t_related_custom_field_ids = custom_field_get_linked_ids_prefs( $v_project_id );
+ foreach( $t_related_custom_field_ids as $t_id ) {
+ $t_def = custom_field_get_definition( $t_id );
+ array_push($t_arr, $t_def['name']);
+ }
+ return $t_arr;
 }
 
 
@@ -107,7 +119,6 @@
  # putting the query result into an array with the same size as $t_fields_arr
  $row = db_fetch_array( $result );
  $t_prefs = $row['print_pref'];
-
 ?>
 
 <?php # Account Preferences Form BEGIN ?>
@@ -115,8 +126,6 @@
 <br />
 <div align="center">
 <form method="post" action="print_all_bug_options_update.php">
-<input type="hidden" name="user_id" value="<?php echo $p_user_id ?>" />
-<input type="hidden" name="redirect_url" value="<?php echo string_attribute( $p_redirect_url ) ?>" />
 <table class="width75" cellspacing="1">
 <tr>
  <td class="form-title">
@@ -134,21 +143,44 @@
 ?>
 
  <td class="category">
- <?php echo lang_get( $t_field_name_arr[$i] ) ?>
+
+ <?php
+ /**
+ * language output set to lang_get_defaulted, because otherwise the names
+ * of custom fields will send a warning
+ *
+ * @author Thorsten Körner
+ * @since 12.10.2005
+ */
+ echo lang_get_defaulted( $t_field_name_arr[$i] )
+ ?>
  </td>
  <td>
- <input type="checkbox" name="<?php echo 'print_' . $t_field_name_arr[$i]; ?>"
+ <?php
+ /**
+ * names of all checkboxes set to lowercase without whitespaces
+ * otherwise you will run into trouble when using Uppercase letters
+ * in the names of custom fields
+ *
+ * @author Thorsten Körner
+ * @since 12.10.2005
+ */
+ ?>
+ <input type="checkbox" name="<?php echo 'print_' . strtolower(str_replace(' ', '_', $t_field_name_arr[$i])); ?>"
  <?php if ( isset( $t_prefs[$i] ) && ( $t_prefs[$i]==1 ) ) echo 'checked="checked"' ?> />
  </td>
 </tr>
 
 <?php
 }
-?>
+ ?>
+
 <tr>
  <td>&nbsp;</td>
  <td>
- <input type="submit" class="button" value="<?php echo lang_get( 'update_prefs_button' ) ?>" />
+ <input type="hidden" name="user_id" value="<?php echo $p_user_id ?>" />
+ <input type="hidden" name="redirect_url" value="<?php echo string_attribute( $p_redirect_url ) ?>" />
+ <input type="submit" class="button" value="<?php echo lang_get( 'update_prefs_button' ) ?>" />
  </td>
 </tr>
 </table>





##########################################################
##########################################################
##########################################################







--- Documents/downloads/mantis-1.0.0rc2/core/custom_field_api.php 2005-07-19 20:28:50.000000000 +0200
+++ public_html/cvs_projects/mantis/packages/custom_fields_options_patch/core/custom_field_api.php 2005-10-12 14:53:09.000000000 +0200
@@ -594,12 +594,95 @@
 
  return $row['id'];
  }
+ # --------------------
+ # 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' );
+
+ if ( ALL_PROJECTS == $p_project_id ) {
+ $t_project_user_list_table = config_get( 'mantis_project_user_list_table' );
+ $t_project_table = config_get( 'mantis_project_table' );
+ $t_user_table = config_get( 'mantis_user_table' );
+ $t_user_id = auth_get_current_user_id();
+ $t_pub = VS_PUBLIC;
+ $t_priv = VS_PRIVATE;
+
+ $t_private_access = config_get( 'private_project_threshold' );
+ if ( is_array( $t_private_access ) ) {
+ if ( 1 == count( $t_private_access ) ) {
+ $t_access_clause = "= " . array_shift( $t_private_access ) . " ";
+ } else {
+ $t_access_clause = "IN (" . implode( ',', $t_private_access ) . ";)";
+ }
+ } else {
+ $t_access_clause = ">= $t_private_access ";
+ }
+
+
+ # select only the ids that the user has some access to
+ # e.g., all fields in public projects, or private projects where the user is listed
+ # or private projects where the user is implicitly listed
+ $query = "SELECT cft.id as id, cft.name as name
+ FROM $t_custom_field_table as cft, $t_user_table ut, $t_project_table pt, $t_custom_field_project_table cfpt
+ LEFT JOIN $t_project_user_list_table pult
+ on cfpt.project_id = pult.project_id and pult.user_id = $t_user_id
+ 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 ) )
+ GROUP BY cft.id, cft.name
+ ORDER BY cft.name ASC";
+ } else {
+ 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 );
+ $t_ids = array();
+
+ for ( $i=0 ; $i < $t_row_count ; $i++ ) {
+ $row = db_fetch_array( $result );
+
+ array_push( $t_ids, $row['id'] );
+ }
+
+ return $t_ids;
+ }
 
  # --------------------
  # 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 ) {
+ # The ids will be sorted by id
+
+ /**
+ * Get custom fields
+ *
+ * Get custom fields for reports and printing options page
+ * This function is a copy of custom_field_get_linked_ids except that the
+ * result is ordered by id. This step is required because you will get
+ * wrong printing options when a new custom field is added and it is
+ * is not the last one in alphabetical order.
+ *
+ * @author thorsten Thorsten Körner <t.koerner@123tk.de>
+ * @since 12.10.2005
+ * @return array $t_ids array with ids of custom fields
+ */
+ function custom_field_get_linked_ids_prefs( $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' );
 
@@ -635,7 +718,7 @@
                     ( 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 ) )
                 GROUP BY cft.id, cft.name
- ORDER BY cft.name ASC";
+ ORDER BY cft.id ASC";
  } else {
             if ( is_array( $p_project_id ) ) {
                 if ( 1 == count( $p_project_id ) ) {
@@ -650,7 +733,7 @@
  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";
+ ORDER BY cft.id ASC, sequence ASC, name ASC";
  }
  $result = db_query( $query );
  $t_row_count = db_num_rows( $result );



##########################################################
##########################################################
##########################################################

At last, alter the database table mantis_user_print_pref_table:
ALTER TABLE `mantis_user_print_pref_table` CHANGE `print_pref` `print_pref` VARCHAR( 255 ) NOT NULL


Thorsten Körner

   /\/`) Thorsten Körner | e-Commerce-Consulting
  /\/_/ t.koerner@123tk.de | http://www.123tk.de
 /\/_/ Software-Entwicklung | Qualitäts-Sicherung
 \/_/ Service-Providing | Hosting | Beratung
 / Tel.: 0175 / 564 9 564
tom@NOcumbriankitchen.co.ukSPAM
28-Oct-2005 5:55
#683
Is there any way of adding custom fields to all projects?
Or could I put in an request for a new field that I thing would be really useful for many people?
I have a custom field for the release tag (CVS tag that the fix / enhancement went into), and I add this to all code projects, and it has to be filled in on resolution / close. Can I make this automatically add to projects at create time, or do I have to remember to do it manually for each project?
Thanks
maehrn@maehrn.com
04-Nov-2005 5:33
#694
I have custom fields of type enumeration.

When i update an issue not the right value (the one written to the db) is displayed in the enum. It displays always the first value. How can i fix this?
douglas.barrios@grupof.com.gt
23-Jan-2006 11:31
#837
I am using Mantis 1.0 rc3, and I would like to know if there is a way to export custom fields in a CSV format to use them in Excell?
Thanks.
It would be great to have custom fields in your report
25-Jan-2006 13:33
#841
The ability to have a custom field on your report would be a tremendous value. Can you sprinkle some pixie dust and make it so? :) LOVE Mantis. thanks so much
mantis_cacp _ yahoo _ fr
06-Mar-2006 8:00
#911
Hello,

I vote to have custom fields in export, and to can populate it by ldap/sql

Bye.
kelvin.tang@hotmail.com
17-Mar-2006 7:10
#944
Being able to customize what items (including Custom Fields) to be exported in CVS format is also what I'm looking for. That would make Mantis more perfect than today.
gael.demonneron@NOSPAMvitecmm.com
21-Mar-2006 5:16
#956
Could it be possible to have some relationship between custom fields

Example :

I want to have a checkbox (or list) of value.
If I select Item 1, I want have some values in a custom field "my_field_2"
If I select Item 2, I want have other values in the "my_field_2" OR disable "my_field_2" and active "my_field_3"
michaelvai@msn.com
30-May-2006 2:40
#1100
my english is poor but what i wonder if it is possible to CSVexport custum field??
damienouebeNO@SPAMlaposte.net
10-Jul-2006 8:18
#1183
I've found how to add custom fields to a project, but how can I order them ? In particular, I'd like to show them *before* regular fields (summary...). Any way to do that other than hack the view.php file ?

And what is the "suite" (next) field when you assign a custom field to a project ?
anonymous@example.com
12-Jul-2006 10:59
#1191
To add the fields to the CSV export / customize the order in which you view them, look at the notes on the 'View Bugs' page (specifically note 932).
polzin_spamprotect_@gmx.de
02-Aug-2006 11:36
#1206
Automatic enumeration-value is feature that seems not yet documented:

You can use functions for generating the enumation-values, e.g. by specifing "=versions" as enumeration-value.

See http://www.mantisbt.org/mantis/view.php?id=5180
alexanser.jesse@credit-suisse.com
03-Aug-2006 8:27
#1210
This forum-thread shows how to export the custom-fields for each project: http://forums.mantisbt.org/viewtopic.php?t=400
The only thing that needed changing was the file-name in the second posting (1232 by hgaland): it must be custom_functions_inc.php (note the s in functions).
fix@the.website.pleeeease
19-Oct-2006 1:21
#1274
that forum thread, (like nearly every other linked forum thread) isn't there. it's really hard to find answers when there this many DEAD LINKS.
sanjyot.sonawane@rediffmail.com
27-Nov-2006 7:19
#1307
 Adding the custom feild does not work
As per the instructions in manual also , it is not viewed in both the reports type(simple & Advanced)
As per the information in this link
http://manual.mantisbt.org/manual.customizing.mantis.custom.fields.php

Adding/Editing Custom Fields Definitions

    * The logged in user needs manage_custom_fields_threshold access level.
    * Select "Manage" from the main menu.
    * Select "Manage Custom Fields" from the management menu.
    * Click on the name of an existing custom field to edit its information.
    * Enter the name of the new custom field then click "New Custom Field" to add a new field.

Note= This information is very in sufficient , As it is said that click on the existing custom feild edit it with your new name and then click "New Custom Field" to add a new field but where is the option called
"New Custom Field"

Really Pathetic , This shows how open source application works very bad........
Victor @ Mantis
29-Nov-2006 3:45
#1309
sanjyot, you need to link the custom fields. See linking/unlinking above in the documentation.

P.S. I would appreciate if you respect the effort put into open source. If you don't find a project documented up-to-your requirements/needs, please move on, but don't criticize people in a negative way.
jody.teren@investec.co.uk
05-Jan-2007 8:21
#1338
Hi

I am having difficulty creating a new custom field with type = list. This will used as a drop down list by the end user when reporting an issue.

I have tried

"system A", "system B"
"system A" "system B"
'system A', 'system B'
'system A' 'system B'
etc

any ideas?
Ron
08-Jan-2007 11:48
#1341
In response to #1338

The format for a type=list possible value field is

Val1|Val2|Val3


Pipe '|' is the delimeter.
rk
27-Jan-2007 12:45
#1366
Can I set default value for date custom field? today(), today()+7 ?
Add Notes About Notes
Last updated: Sat, 17 May 2008 - 8:50:19

Mantis @ SourceForge