CRM-10317 Add sensible defaults/spec for UFGroup create api

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.2.0
    • Fix Version/s: 4.2.0
    • Component/s: None
    • Labels:
      None

      Description

      I went back to the discussion we had about #now & other macros to try to populate UFGroup.create properly (who created & when)

      I wrote the spec using the "normal" $session & date() functions, works ok.

      Assigning to you see if you get a better idea (eg. obviously, setting this default is in the form & not in the bao, hence the duplication)

      Also, I'm wondering if it's a good idea to let (when using ajax) the caller set the owner/date they want, but that's a way more general problem than the UFGroup only. We might need to introduce a new api.override that applies only is ajax (or check_permission in general)?

        Attachments

          Activity

          [CRM-10317] Add sensible defaults/spec for UFGroup create api
          xavier dutoit added a comment -

          So pretty trivial

          function _civicrm_api3_uf_group_create_spec(&$params)

          { $session = CRM_Core_Session::singleton(); $params['title']['api.required'] = 1; $params['is_active']['api.default'] = 1; $params['is_update_dupe']['api.default'] = 1; $params['created_id']['api.default'] = $session->get('userID'); $params['created_date']['api.default'] = date('YmdHis'); }

          but seems to do what I wanted

          Eileen McNaughton added a comment -

          Try

          $params['created_id']['api.default'] = 'user_contact_id';
          $params['created_date']['api.default'] = 'now';

          now is valid for date - as is any other strtotime parsable string -e.g 'last saturday next month' is also valid.
          user_contact_id was added by Erik into the _civicrm_api3_validate_integer function

          We had a lot of talk about macros & scope creep on this - but none of the other potential macros seem to really be of much importance. The is_primary ones I pushed into the BAO

          Eileen McNaughton added a comment -

          Is that the input you needed?

          xavier dutoit added a comment -

          Works fine with now & user_contact_id, using them

            People

            • Assignee:
              xavier dutoit
              Reporter:
              xavier dutoit

              Dates

              • Created:
                Updated:
                Resolved: