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) »
  • API v3 UFmatch( get ) vs CRM_Core_BAO_UFMatch::synchronizeUFMatch
Pages: [1]

Author Topic: API v3 UFmatch( get ) vs CRM_Core_BAO_UFMatch::synchronizeUFMatch  (Read 882 times)

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
API v3 UFmatch( get ) vs CRM_Core_BAO_UFMatch::synchronizeUFMatch
June 20, 2012, 02:29:50 am
I'm trying to bring some old code inline with the v3 APIs and have been looking at UFmatch.  If I do this

Code: [Select]
$UF_match_result = CRM_Core_BAO_UFMatch::synchronizeUFMatch( $user->name, $result->id, $user->email, 'Joomla' );
it will create a UFmatch entry if one does not exist and returns UFmatch data.

If I do this

Code: [Select]
$api_result = civicrm_api( 'uf_match','get',$params );
it works fine only if the civicrm_uf_match table already has an entry, but won't create a new match if one isn't found.

So:
  • is it safe to use CRM_Core_BAO_UFMatch::synchronizeUFMatch or will this get depreciated any time soon?
  • is there a better way to use the v3 API to the same effect

BTW this is in Joomla.

Thanks

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: API v3 UFmatch( get ) vs CRM_Core_BAO_UFMatch::synchronizeUFMatch
June 20, 2012, 02:56:07 am
Hi,

We don't have a synchronise action civicrm_api ('uf_match','synchronize').

It would be great to create a civicrm_api3_uf_match_synchronize in api/v3/UFMatch.php that wraps the call to the BAO but IMO, 'safe enough' to use the BAO (the comment above already mention being called by an external script).

The idea of having the wrapper added is that you can hopefully hide some of the complexity (eg. having to give the CMS name as a param) and have a single place where the BAO is called so if it changes in the future, that will hopefully be easier.
Not to mention the joy and proudness your grandchildren will have knowing you have contributed to the API v3 ;)

I don't understand why the name of the CMS is a parameter (instead of being taken from the config), so might or might not have an impact and be altered.


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

speleo

  • Ask me questions
  • ****
  • Posts: 396
  • Karma: 28
  • CiviCRM version: 4.3.1
  • CMS version: J! 2.5,9
  • MySQL version: 5.1
  • PHP version: 5.3.24
Re: API v3 UFmatch( get ) vs CRM_Core_BAO_UFMatch::synchronizeUFMatch
June 20, 2012, 05:46:18 am
xavier,

Many thanks for your swift response. I'm going to run with the BAO for now.  I'd love to tell my grandchildren about how I helped write part of an API but this is way beyond the realms of my experience. I currently updating a Joomla Authentication plugin that I wrote awhile back (using the v2 APIs) which a couple of people reported an issue with. 

http://wiki.civicrm.org/confluence/display/CRMDOC40/Joomla+CiviCRM+Membership+Authentication+and+ACL+Plugin

I'm not a coder so I'm pushing back the boundaries of my capabilities as it is but am more than happy to share the results.

Henry

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

This forum was archived on 2017-11-26.