CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • civicrm_membership_status_calc in v3 API
Pages: [1]

Author Topic: civicrm_membership_status_calc in v3 API  (Read 980 times)

snowball

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 3.4
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5
civicrm_membership_status_calc in v3 API
November 14, 2011, 03:43:23 am
How do I invoke equivalent functionality using the v3 generic API? I see there is an underlying function, civicrm_api3_membership_status_calc however my understanding is your not supposed to call such functions directly but go through the generic interface instead?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: civicrm_membership_status_calc in v3 API
November 14, 2011, 03:59:16 am
I think if you use create & don't pass in a status ID it will call it to calculate it (seemed to work for me the other day).
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

snowball

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 3.4
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5
Re: civicrm_membership_status_calc in v3 API
November 14, 2011, 07:04:22 am
Am updating rather than creating a membership, eyeballing the code behind this it looks to me like it doesn't automatically update the status

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: civicrm_membership_status_calc in v3 API
November 15, 2011, 02:57:26 am
This line is the culprit

  if ( CRM_Utils_Array::value( 'id', $params ) ) {
    //don't calculate dates on exisiting membership - expect API use to pass them in
    // or leave unchanged
    $params['skipStatusCal'] = 1;

Not sure what it should be though. In most cases that's what's wanted.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

snowball

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 3.4
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5
Re: civicrm_membership_status_calc in v3 API
November 15, 2011, 05:43:48 am
Yea but I'm not necessarily wanting to automatically do it as part of the update call to the API, I'm happy to call it manually after... I'm just not sure how best to do this as it doesn't appear to be exposed to the generic API...

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: civicrm_membership_status_calc in v3 API
November 15, 2011, 01:27:04 pm
Nah - it should be via the API call .

Potentially that line should be

  if ( CRM_Utils_Array::value( 'id', $params ) && !CRM_Utils_Array::value('skipStatusCalc', $params ) !== 0 ) {
    //don't calculate dates on exisiting membership - expect API use to pass them in
    // or leave unchanged
    $params['skipStatusCal'] = 1;

(syntax off the top of my head but if 'skipStatusCalc' is set to 0 then don't set to 1)

Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

snowball

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
  • CiviCRM version: 3.4
  • CMS version: Drupal 6
  • MySQL version: 5
  • PHP version: 5
Re: civicrm_membership_status_calc in v3 API
November 27, 2011, 08:12:17 am
Ok, in the mean time (using CiviCRM 4.0.7) what is the best way to use this functionality, given the API doesn't presently support it?

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: civicrm_membership_status_calc in v3 API
November 27, 2011, 01:09:58 pm
I would try tweaking the api around that line & then submit it as a patch (that way it won't break on upgrade) so that

if  (!empty($params['id']) && !isset($params['skipStatusCal'])){
$params['skipStatusCal'] = 1;
}

(something like that)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • civicrm_membership_status_calc in v3 API

This forum was archived on 2017-11-26.