CiviCRM
  1. CiviCRM
  2. CRM-10540

Add option to API to retrieve templates

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.1.2
    • Fix Version/s: 4.2.0
    • Component/s: CiviEvent
    • Labels:
      None
    • Is MIH?:
      No
    • Code Sprint:
      No

      Description

      civicrm/api/v3/Events.php includes this line...

      $eventDAO->whereAdd( '( is_template IS NULL ) OR ( is_template = 0 )' );

      That makes it impossible to return event templates. This patch makes that line the default, but allows you to include is_template=1 in the query to get a list of event templates.

        Activity

        Hide
        Donald A. Lobo added a comment -

        the v3 code has changed a bit in 4.2. I modifed the patch and renamed the option to isTemplate to keep it similar to isCurrent

        lobo
        Show
        Donald A. Lobo added a comment - the v3 code has changed a bit in 4.2. I modifed the patch and renamed the option to isTemplate to keep it similar to isCurrent lobo
        Hide
        Eileen McNaughton added a comment -
        Hi,

        I think that since is_template is the field name & the param 'isTemplate' does the same as passing in the fieldname would normally do (it's not doing something tricky & special) we should stick with 'is_template' - normally the api uses the same names as the fields.
        Show
        Eileen McNaughton added a comment - Hi, I think that since is_template is the field name & the param 'isTemplate' does the same as passing in the fieldname would normally do (it's not doing something tricky & special) we should stick with 'is_template' - normally the api uses the same names as the fields.
        Hide
        Donald A. Lobo added a comment -

        ok, made the fix and renamed it to is_tempalte
        Show
        Donald A. Lobo added a comment - ok, made the fix and renamed it to is_tempalte
        Hide
        Eileen McNaughton added a comment -
        but hopefully not spelt like that :-)
        Show
        Eileen McNaughton added a comment - but hopefully not spelt like that :-)
        Hide
        Kevin Reynen added a comment -
        Just started testing beta2 are got this error...

        Parse error: syntax error, unexpected '}' in modules/civicrm/api/v3/Event.php on line 134

        When I looked at line 134, I was disappointed to see that changes made based on my patch were causing the error. Somehow when the change was made a ; was missed after $eventDAO->whereAdd( '( is_template = 1 )' ). Should be...

          if (CRM_Utils_Array::value('is_template', $params)) {
            $eventDAO->whereAdd( '( is_template = 1 )' );
          }

        It doesn't look like I can change the status of this issue in Jira. Should I open a new issue?
        Show
        Kevin Reynen added a comment - Just started testing beta2 are got this error... Parse error: syntax error, unexpected '}' in modules/civicrm/api/v3/Event.php on line 134 When I looked at line 134, I was disappointed to see that changes made based on my patch were causing the error. Somehow when the change was made a ; was missed after $eventDAO->whereAdd( '( is_template = 1 )' ). Should be...   if (CRM_Utils_Array::value('is_template', $params)) {     $eventDAO->whereAdd( '( is_template = 1 )' );   } It doesn't look like I can change the status of this issue in Jira. Should I open a new issue?
        Hide
        Donald A. Lobo added a comment -

        argh

        my fault, i should have done a better job with the patching :( Also we had a snafu and did not check that the tests passed before the release (which would have also caught this issue)

        committed the fix

        lobo
        Show
        Donald A. Lobo added a comment - argh my fault, i should have done a better job with the patching :( Also we had a snafu and did not check that the tests passed before the release (which would have also caught this issue) committed the fix lobo
        Hide
        Rob Malerman added a comment -
        Lobo,

        Is it possible to update the patch for 4.3? Seems to still be an issue with B5 but Events.php appears to this untrained newbe eye to be different.

        Rob
        Show
        Rob Malerman added a comment - Lobo, Is it possible to update the patch for 4.3? Seems to still be an issue with B5 but Events.php appears to this untrained newbe eye to be different. Rob
        Hide
        Donald A. Lobo added a comment -

        this code is present in 4.3. PLease discuss on forums
        Show
        Donald A. Lobo added a comment - this code is present in 4.3. PLease discuss on forums

          People

          • Assignee:
            Donald A. Lobo
            Reporter:
            Kevin Reynen
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development