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) »
  • relationship api doesn't respect is_active
Pages: [1]

Author Topic: relationship api doesn't respect is_active  (Read 1246 times)

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
relationship api doesn't respect is_active
January 25, 2012, 07:22:21 am
looks like the get relationship API ignores 'is_active' when passed in the params array.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: relationship api doesn't respect is_active
January 25, 2012, 09:22:12 am
Probably indeed,

Would be great if you find what's the parameter/way of calling the BAO under, then transforming the param is probably trivial

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: relationship api doesn't respect is_active
January 25, 2012, 11:45:31 pm
Relationship API has a v2 behaviour & a v3 behaviour. v2 behaviour occurs when 'contact_id' is passed in.

v3 behaviour (added later to the api copied from v2) should do a pretty basic query & respect 'is_active'  - but perhaps not by default - which would be easily remedied by adding / editing the civicrm_api3_relationship_get_spec function
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

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: relationship api doesn't respect is_active
January 26, 2012, 12:26:04 am
Hi,

Just tested and it works if you use contact_id_a or contact_id_b and is_active.

On the "old" version (triggered when using contact_id), you can use the status_id param:

        PAST              =  1,
        DISABLED          =  2,
        CURRENT           =  4,
        INACTIVE          =  8;


Ok, doesn't exactly match the is_active (disabled is either is_active=0 or end_date < now()), but getting closer, isn't it?

Anyway, my big question: how do we document that?

we could/must add contact_id and status_id in the get_field, but how to document that using contact_id vs contact_id_a|b is going to trigger a different behaviour?

X+

P.S. Refactoring the relationship BAO and co would probably make sense, but likely a patch welcome project.
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: relationship api doesn't respect is_active
January 26, 2012, 05:06:44 am
Yep, I guess that's the sort of thing that people get out of looking at the php generated docs - discussion of the oddities about an API that we haven't been able to get rid of yet.
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) »
  • relationship api doesn't respect is_active

This forum was archived on 2017-11-26.