@@ -774,93 +774,225 @@ $g_status_enum_workflow[CLOSED] ='20:feedback,50:assigned';
774
774
</para>
775
775
</section>
776
776
777
- <section id="admin.customize.customfuncs">
778
- <title>Custom Functions</title>
779
-
780
- <para>Custom functions are used to extend the functionality of
781
- MantisBT by integrating user writtenfunctions into the issue
782
- processing at strategic places. This allows the system
783
- administrator to changethe functionality without re-writing parts
784
- of the internals of the code.
785
- </para>
786
- <para>User versions of these functions are
787
- placed in a file called custom_functions_inc.php in the
788
- root directory of MantisBT. This is the same place that the
789
- "config_inc.php" file modifying MantisBT defaults is placed. In normal
790
- processing, MantisBT will look for override functions and execute
791
- them instead of the provided default functions.</para>
792
- <para>Custom functions have
793
- names like custom_function_override_descriptive_name where
794
- descriptive namedescribed the particular function. The specific
795
- functions are described below. The simplest way tocreate a custom
796
- function is to copy the default function, named
797
- custom_function_default_descriptive_namefrom the
798
- core/custom_function_api.php file to your override file
799
- (custom_functions_inc.php), andrename it. The specific
800
- functionality you need can then be coded into the override
801
- function.
802
- </para>
803
-
804
- <section id="admin.customize.customfuncs.defined">
805
- <title>Defined Functions</title>
806
-
807
- <para>custom_function_default_changelog_include_issue( $p_issue_id
808
- ) returns true or false if the issue if to be included in the
809
- Changelog. custom_function_default_changelog_print_issue( $p_issue_id
810
- ) returns a formatted string to be included for the issue in the
811
- Changelog. custom_function_default_issue_update_validate( $p_issue_id,
812
- $p_file, $p_new_version ) registers a checkin in source control in
813
- MantisBT custom_function_default_issue_update_validate( $p_issue_id,
814
- $p_new_bug, $p_bug_note_text ) validate issue field settings before
815
- an update occurs. It returns true or fails with an
816
- error.custom_function_default_issue_update_notify( $p_issue_id )
817
- notify after an issue has been
818
- updated. custom_function_default_issue_create_validate( $p_new_bug )
819
- validate issue field settings before an issue is created. It returns
820
- true or fails with an
821
- error.custom_function_default_issue_create_notify( $p_issue_id )
822
- notify after an issue has been
823
- opened. custom_function_default_issue_delete_validate( $p_issue_id )
824
- validate issue field settings before an issue can be deleted. It
825
- returns true or fails with an
826
- error.custom_function_default_issue_delete_notify( $p_issue_id )
827
- notify after an issue has been deleted
828
- </para>
829
- </section>
830
-
831
- <section id="admin.customize.customfuncs.example">
832
- <title>Example Custom Function</title>
833
-
834
- <para>The following function is used to validate an issue before
835
- it is resolved.
836
- <programlisting width="102"><![CDATA[<?php
837
- # --------------------
838
- # Hook to validate Validate field settings before resolving
839
- # verify that the resolution is not set to OPEN
840
- # verify that the fixed in version is set (if versions of the product exist)
777
+ <section id="admin.customize.customfuncs">
778
+ <title>Custom Functions</title>
779
+
780
+ <para>Custom functions are used to extend the functionality of
781
+ MantisBT by integrating user-written functions into the issue
782
+ processing at strategic places. This allows the system
783
+ administrator to change the functionality without touching
784
+ MantisBT's core.
785
+ </para>
786
+ <para>Default Custom Functions are defined in the API file
787
+ <filename>core/custom_function_api.php</filename>
788
+ , and are named
789
+ <emphasis>custom_function_default_descriptive_name</emphasis>,
790
+ where <emphasis>descriptive_name</emphasis> describes the
791
+ particular function.
792
+ <link linkend="admin.customize.customfuncs.defined">See below</link>
793
+ for a description of the specific functions.
794
+ </para>
795
+ <para>User versions of these functions (overrides) are named like
796
+ <emphasis>custom_function_override_descriptive_name</emphasis>,
797
+ and placed in a file called
798
+ <filename>custom_constants_inc.php</filename> that must be saved in
799
+ MantisBT's root directory (This is the same place where the
800
+ <filename>config_inc.php</filename> file resides).
801
+ In normal processing, the system will look for override functions
802
+ and execute them instead of the provided default functions.
803
+ </para>
804
+ <para>The simplest way to create a custom function is to copy the
805
+ default one from the api to your override file
806
+ (<filename>custom_constants_inc.php</filename>), and rename it
807
+ (i.e. replacing 'default' by 'override').
808
+ The specific functionality you need can then be coded into the
809
+ override function.
810
+ </para>
841
811
812
+ <section id="admin.customize.customfuncs.defined">
813
+ <title>Default Custom Functions</title>
814
+
815
+ <para>Refer to <filename>core/custom_functions_api.php</filename>
816
+ for further details.
817
+ </para>
818
+
819
+ <informaltable>
820
+ <tgroup cols="3">
821
+ <thead>
822
+ <row>
823
+ <entry>Custom Function Name</entry>
824
+ <entry>Description</entry>
825
+ <entry>Return value</entry>
826
+ </row>
827
+ </thead>
828
+ <tbody>
829
+ <row>
830
+ <entry>custom_function_default_auth_can_change_password()</entry>
831
+ <entry>Determines whether MantisBT can update the password</entry>
832
+ <entry>True if yes, False if not</entry>
833
+ </row>
834
+ <row>
835
+ <entry>custom_function_default_changelog_include_issue( $p_issue_id )</entry>
836
+ <entry>Determines whether the specified issue should be included in the Changelog or not.</entry>
837
+ <entry>True to include, False to exclude</entry>
838
+ </row>
839
+ <row>
840
+ <entry>custom_function_default_changelog_print_issue( $p_issue_id, $p_issue_level = 0 )</entry>
841
+ <entry>Prints one entry in the Changelog</entry>
842
+ <entry>None</entry>
843
+ </row>
844
+ <row>
845
+ <entry>custom_function_default_checkin( $p_issue_id, $p_comment, $p_file, $p_new_version, $p_fixed )</entry>
846
+ <entry>Register a checkin in source control by adding a history entry and a note</entry>
847
+ <entry>None</entry>
848
+ </row>
849
+ <row>
850
+ <entry>custom_function_default_enum_categories()</entry>
851
+ <entry>Build a list of all categories for the current project</entry>
852
+ <entry>Enumeration, delimited by "|"</entry>
853
+ </row>
854
+ <row>
855
+ <entry>custom_function_default_enum_future_versions()</entry>
856
+ <entry>Build a list of all future versions for the current project</entry>
857
+ <entry>Enumeration, delimited by "|"</entry>
858
+ </row>
859
+ <row>
860
+ <entry>custom_function_default_enum_released_versions()</entry>
861
+ <entry>Build a list of all released versions for the current project</entry>
862
+ <entry>Enumeration, delimited by "|"</entry>
863
+ </row>
864
+ <row>
865
+ <entry>custom_function_default_enum_versions()</entry>
866
+ <entry>Build a list of all versions for the current project</entry>
867
+ <entry>Enumeration, delimited by "|"</entry>
868
+ </row>
869
+ <row>
870
+ <entry>custom_function_default_format_issue_summary( $p_issue_id, $p_context = 0 )</entry>
871
+ <entry>Format the bug summary</entry>
872
+ <entry>Formatted string</entry>
873
+ </row>
874
+ <row>
875
+ <entry>custom_function_default_get_columns_to_view( $p_columns_target = COLUMNS_TARGET_VIEW_PAGE, $p_user_id = null )</entry>
876
+ <entry>Defines which columsn should be displayed</entry>
877
+ <entry>Array of the column names</entry>
878
+ </row>
879
+ <row>
880
+ <entry>custom_function_default_issue_create_notify( $p_issue_id )</entry>
881
+ <entry>Notify after an issue has been created</entry>
882
+ <entry>In case of invalid data, this function should call trigger_error()</entry>
883
+ </row>
884
+ <row>
885
+ <entry>custom_function_default_issue_create_validate( $p_new_issue_data )</entry>
886
+ <entry>Validate field settings before creating an issue</entry>
887
+ <entry>In case of invalid data, this function should call trigger_error()</entry>
888
+ </row>
889
+ <row>
890
+ <entry>custom_function_default_issue_delete_notify( $p_issue_data )</entry>
891
+ <entry>Notify after an issue has been deleted</entry>
892
+ <entry>In case of invalid data, this function should call trigger_error()</entry>
893
+ </row>
894
+ <row>
895
+ <entry>custom_function_default_issue_delete_validate( $p_issue_id )</entry>
896
+ <entry>Validate field settings before deleting an issue</entry>
897
+ <entry>In case of invalid data, this function should call trigger_error()</entry>
898
+ </row>
899
+ <row>
900
+ <entry>custom_function_default_issue_update_notify( $p_issue_id )</entry>
901
+ <entry>Notify after an issue has been updated</entry>
902
+ <entry>In case of invalid data, this function should call trigger_error()</entry>
903
+ </row>
904
+ <row>
905
+ <entry>custom_function_default_issue_update_validate( $p_issue_id, $p_new_issue_data, $p_bugnote_text )</entry>
906
+ <entry>Validate field issue data before updating</entry>
907
+ <entry>In case of invalid data, this function should call trigger_error()</entry>
908
+ </row>
909
+ <row>
910
+ <entry>custom_function_default_print_bug_view_page_custom_buttons( $p_bug_id )</entry>
911
+ <entry>Prints the custom buttons on the current view page</entry>
912
+ <entry>None</entry>
913
+ </row>
914
+ <row>
915
+ <entry>custom_function_default_print_column_title( $p_column, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE )</entry>
916
+ <entry>Print a column's title based on its name</entry>
917
+ <entry>None</entry>
918
+ </row>
919
+ <row>
920
+ <entry>custom_function_default_print_column_value( $p_column, $p_bug, $p_columns_target = COLUMNS_TARGET_VIEW_PAGE )</entry>
921
+ <entry>Print a column's value based on its name</entry>
922
+ <entry>None</entry>
923
+ </row>
924
+ <row>
925
+ <entry>custom_function_default_roadmap_include_issue( $p_issue_id )</entry>
926
+ <entry>Determines whether the specified issue should be included in the Roadmap or not.</entry>
927
+ <entry>True to include, False to exclude</entry>
928
+ </row>
929
+ <row>
930
+ <entry>custom_function_default_roadmap_print_issue( $p_issue_id, $p_issue_level = 0 )</entry>
931
+ <entry>Prints one entry in the Roadmap</entry>
932
+ <entry>None</entry>
933
+ </row>
934
+ </tbody>
935
+ </tgroup>
936
+ </informaltable>
937
+
938
+ </section>
939
+
940
+ <section id="admin.customize.customfuncs.example">
941
+ <title>Example Custom Function Override</title>
942
+
943
+ <para>The following function is used to validate an issue before
944
+ it is resolved.
945
+ </para>
946
+
947
+ <programlisting width="102"><![CDATA[<?php
948
+
949
+ /**
950
+ * Hook to validate Validate field settings before resolving
951
+ * verify that the resolution is not set to OPEN
952
+ * verify that the fixed in version is set (if versions of the product exist)
953
+ */
842
954
function custom_function_override_issue_update_validate( $p_issue_id, $p_bug_data, $p_bugnote_text ) {
843
- if ( $p_bug_data->status == RESOLVED ) {
844
- if ( $p_bug_data->resolution == OPEN ) {
845
- error_parameters( 'the resolution cannot be open to resolve the issue' );
846
- trigger_error( ERROR_BUG_VALIDATE_FAILURE, ERROR );
847
- }
848
- $t_version_count = count( version_get_all_rows( $p_bug_data->project_id ) );
849
- if ( ( $t_version_count > 0 ) && ( $p_bug_data->fixed_in_version == '' ) ) {
850
- error_parameters( 'fixed in version must be set to resolve the issue' );
851
- trigger_error( ERROR_BUG_VALIDATE_FAILURE, ERROR );
852
- }
853
- }
955
+ if ( $p_bug_data->status == RESOLVED ) {
956
+ if ( $p_bug_data->resolution == OPEN ) {
957
+ error_parameters( 'the resolution cannot be open to resolve the issue' );
958
+ trigger_error( ERROR_BUG_VALIDATE_FAILURE, ERROR );
959
+ }
960
+ $t_version_count = count( version_get_all_rows( $p_bug_data->project_id ) );
961
+ if ( ( $t_version_count > 0 ) && ( $p_bug_data->fixed_in_version == '' ) ) {
962
+ error_parameters( 'fixed in version must be set to resolve the issue' );
963
+ trigger_error( ERROR_BUG_VALIDATE_FAILURE, ERROR );
964
+ }
965
+ }
854
966
}
967
+
855
968
?>]]>
856
- </programlisting>
857
- The errors will also need to be defined by adding the following to <filename>custom_constants_inc.php</filename>
858
- <programlisting>
859
- define ( 'ERROR_VALIDATE_FAILURE', 2000 );
860
- To custom_strings_inc.php
861
- $MANTIS_ERROR['ERROR_VALIDATE_FAILURE'] = 'This change cannot be made because %s';
862
- </programlisting>
863
- </para>
864
- </section>
865
- </section>
969
+ </programlisting>
970
+
971
+ <para>The errors will also need to be defined, by modifying the
972
+ following files
973
+ </para>
974
+
975
+ <itemizedlist>
976
+ <listitem>
977
+ <para><filename>custom_constants_inc.php</filename>
978
+ </para>
979
+
980
+ <programlisting>
981
+ define( 'ERROR_VALIDATE_FAILURE', 2000 );
982
+ </programlisting>
983
+ </listitem>
984
+
985
+ <listitem>
986
+ <para><filename>custom_strings_inc.php</filename>
987
+ </para>
988
+
989
+ <programlisting>
990
+ $MANTIS_ERROR['ERROR_VALIDATE_FAILURE'] = 'This change cannot be made because %s';
991
+ </programlisting>
992
+ </listitem>
993
+ </itemizedlist>
994
+
995
+ </section>
996
+ </section>
997
+
866
998
</chapter>
0 commit comments