Custom Fields - Bug fix and Case Mods

Plugins
MarkH
2007-02-08
2013-04-26
  • MarkH
    MarkH
    2007-02-08

    I've modded the custom_fields setup.php file to allow custom fields to be added to cases. It is very similar to the opportunities implementation although there are some slight but significant differences.

    As part of this activity I also found a bug in the custom_fields connect() function which is used by many parts of the custom_fields code to return an active DB connection. The existing code fails in some circumstances (it certainly stopped the cases mod).

    I have included the diff output for the various patches (setup.php, custom_fields.sql, cf_functions.php). I think it would be good to add these in to the standard custom_fields plugin.

    Mark.

    SETUP.PHP

    8,10d7
    <  *
    <  * Diginus patch to include CASES additional fields.
    <  *
    16,28d12
    <
    <     // Add additonal fields hooks to the Cases screens (MAH)
    <     $xrms_plugin_hooks['case_one']['custom_fields']
    <       = 'cf_case_inline_display';
    <     $xrms_plugin_hooks['case_edit_form']['custom_fields']
    <       = 'cf_case_inline_edit';
    <     $xrms_plugin_hooks['case_new_form']['custom_fields']
    <       = 'cf_case_inline_edit';
    <     $xrms_plugin_hooks['case_new_2']['custom_fields']
    <       = 'cf_case_inline_edit_2';
    <     $xrms_plugin_hooks['case_edit_2']['custom_fields']
    <       = 'cf_case_inline_edit_2';
    <
    35d18
    <
    42d24
    <
    49d30
    <
    211,239d191
    <
    < // Add additional function hooks for the CASES custom fields
    < //
    < function cf_case_inline_display () {
    <     global $xrms_file_root, $case_id;
    <     include_once("$xrms_file_root/plugins/custom_fields/display_functions.php");
    <     $display_html=get_display("case_accounting", $case_id, "");
    <     echo $display_html;
    <     return;
    < }
    <
    < function cf_case_inline_edit () {
    <     global $xrms_file_root, $case_id;
    <     include_once("$xrms_file_root/plugins/custom_fields/display_functions.php");
    <     $display_html=get_inline_edit("case_accounting", $case_id, "");
    <     echo $display_html;
    <     return;
    < }
    <
    < function cf_case_inline_edit_2 () {
    <     global $xrms_file_root, $case_id;
    <     include_once("$xrms_file_root/plugins/custom_fields/display_functions.php");
    <     $display_html=do_inline_edit_save("case_accounting", $case_id, "");
    <     echo $display_html;
    <     return;
    < }
    <
    <
    <
    242,247d193
    <  *
    <  * Revision 2007/02/08 Diginus
    <  * Added hooks for cases additional fields and associated functions.
    <  * Also added necessary "inline" type into SQL script.
    <  * Corrected bug in connect() function.
    <  *
    271,272c217
    < ?>
    <
    ---
    > ?>
    \ No newline at end of file

    CF_FUNCTIONS.PHP

    20,22c20
    <       // Diginus patch - Make sure $con is actually an open connection if defined
    <       //
    <       if ( !$con  || !$con->IsConnected() ) {
    ---
    >       if (!$con) {
    57d54
    <

    CUSTOM_FIELDS.SQL

    107,114d106
    <
    < --
    < -- need add these values to add capabilities in CASES inline custom fields
    < --
    <
    < INSERT INTO `cf_objects` VALUES (4, 'Case Accounting', 'case_accounting', 0, 'a');
    < INSERT INTO `cf_types` VALUES (9, 'a', 'case_accounting', 'inline');
    <

     
    • Brian Peterson
      Brian Peterson
      2007-02-08

      Could you please port the patch to the Patches tracker or email it to me?  All formatting is lost if you try to cut and paste a patch from the forums.

      These look reasonable, and I'll test and apply them as soon as I can.

      Thanks for contributing to XRMS!

      Regards,

         - Brian