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 (Moderator: Donald Lobo) »
  • API Migration from 1.x to 2.x
Pages: 1 [2]

Author Topic: API Migration from 1.x to 2.x  (Read 19721 times)

dalin

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 8
  • CiviCRM version: many
  • CMS version: Drupal 6
  • MySQL version: 5.0
  • PHP version: 5.2
Re: API Migration from 1.x to 2.x
April 13, 2008, 05:39:55 pm
Quote from: Dave Greenberg on April 11, 2008, 09:27:23 am
If you've figure out how to do something that wasn't clearly documented already, PLEASE continue to improve the relevant wiki API doc pages with tips, snippet examples, and/or links to an examples in the unit test files in the our svn repository - to make things a bit easier for folks going forward!

We're way ahead of you on that one Dave G.  ;)
--
Dave Hansen-Lange
Web Developer
Advomatic LLC
http://advomatic.com
Hong Kong office

kindermaur

  • I’m new here
  • *
  • Posts: 16
  • Karma: 0
Re: API Migration from 1.x to 2.x
April 15, 2008, 04:59:24 pm
In my first attempt to use the CiviCRM API (2.0), it appears that there is either missing functionality in api/v2/Relationship.php (no civicrm_relationship_get()), or a conflict between the contacts expected by api/Relationship.php and those returned by api/v2/Contact.php (civicrm_contact_search() or civicrm_contact_get()).

I'm just trying to get a contact with the contact_id, and then get the relationships of that contact. Any guidance/recommendations on what API calls I should use to accomplish this?

dalin

  • I post occasionally
  • **
  • Posts: 89
  • Karma: 8
  • CiviCRM version: many
  • CMS version: Drupal 6
  • MySQL version: 5.0
  • PHP version: 5.2
Re: API Migration from 1.x to 2.x
April 15, 2008, 07:45:46 pm
Quote from: kindermaur on April 15, 2008, 04:59:24 pm
In my first attempt to use the CiviCRM API (2.0), it appears that there is either missing functionality in api/v2/Relationship.php (no civicrm_relationship_get()), or a conflict between the contacts expected by api/Relationship.php and those returned by api/v2/Contact.php (civicrm_contact_search() or civicrm_contact_get()).

I'm just trying to get a contact with the contact_id, and then get the relationships of that contact. Any guidance/recommendations on what API calls I should use to accomplish this?

Yes it looks like you're right, there is no way to look up a relationship in API v2.  I would suggest filing a bug for this.  You can still call the function directly:
Code: [Select]
require_once('CRM/Contact/BAO/Relationship.php');
$relationships =&  CRM_Contact_BAO_Relationship::getRelationship($contact_id);
--
Dave Hansen-Lange
Web Developer
Advomatic LLC
http://advomatic.com
Hong Kong office

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: API Migration from 1.x to 2.x
April 15, 2008, 08:35:08 pm

Please do not file an issue for this one :)

We are moving away from providing simple procedural wrappers for functions in the BAO. We'd like folks to call the BAO functions directly.

We'll start improving the documentation for the BAO functions to make them easier to use

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

quinn

  • Guest
Re: API Migration from 1.x to 2.x
February 25, 2009, 03:03:19 pm
i'm using a function called 'crm_uf_get_profile_groups' which doesn't seem to exist anymore. what replaced this?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: API Migration from 1.x to 2.x
February 25, 2009, 05:57:29 pm

check api/v2/UFGroup.php, function civicrm_uf_profile_groups_get

lobo


A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Clifford Meece

  • I’m new here
  • *
  • Posts: 15
  • Karma: 0
Re: API Migration from 1.x to 2.x
June 03, 2010, 07:28:25 am
I'm working with a drupal module called 'petition' and realized that it uses the civicrm v1 api.  Luckily there is a civicrm20compat module, and using it (and modifying petition appropriately) I was able to get it to partially work.

Then I discovered that the function crm_create_activity_history is not defined, and not 'mapped' in civicrm20compat.  So I applied a patch I found that is meant to fix that situation, by calling something like $history = CRM_Core_BAO_History::create($params, $ids, 'Activity');

Of course, then I get this:

Fatal error: Class 'CRM_Core_BAO_History' not found in /vol/home/organizations/abeedoo.com/platforms/drupal-6.16/sites/ilraiseyourhand.org/modules/civicrm20compat/civicrm20compat.module on line 106

So what to do now?  I didn't find 'CRM_Core_BAO_History' anywhere.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: API Migration from 1.x to 2.x
June 03, 2010, 09:39:55 am
Clifford - The 'activity history' object was obsoleted in 2.0 - all activities are stored in the activity object. I suspect the effort involved in just migrating the API calls in the Petition module to use current v2 api's will be equivalent (or perhaps less) than trying to make the v1 + compat20 approach work - and the end result should be cleaner. We are doing a much better job of maintaining backwards compatibility with the v2 series.

Jump on IRC (#civicrm on freenode.net) to discuss further / if you get stuck.
Protect your investment in CiviCRM by  becoming a Member!

Clifford Meece

  • I’m new here
  • *
  • Posts: 15
  • Karma: 0
Re: API Migration from 1.x to 2.x
June 03, 2010, 09:51:38 am
Quote from: Dave Greenberg on June 03, 2010, 09:39:55 am
Clifford - The 'activity history' object was obsoleted in 2.0 - all activities are stored in the activity object. I suspect the effort involved in just migrating the API calls in the Petition module to use current v2 api's will be equivalent (or perhaps less) than trying to make the v1 + compat20 approach work - and the end result should be cleaner. We are doing a much better job of maintaining backwards compatibility with the v2 series.

Jump on IRC (#civicrm on freenode.net) to discuss further / if you get stuck.

Thanks for the response.  In this particular case, can you suggest how one might replace the crm_create_activity_history function.  Do you have a code snippet as an example? 

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 Migration from 1.x to 2.x
June 03, 2010, 10:12:40 am
What was that API supposed to do ?

BTW, I'm working on a CiviPetition module, that should be quite groovy ;)

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

Clifford Meece

  • I’m new here
  • *
  • Posts: 15
  • Karma: 0
Re: API Migration from 1.x to 2.x
June 03, 2010, 10:14:46 am
Quote from: xavier on June 03, 2010, 10:12:40 am
What was that API supposed to do ?

BTW, I'm working on a CiviPetition module, that should be quite groovy ;)

X+

Well, I definitely be interested in that!  It's sorely lacking in civicrm, IMO.  One of the first things advocacy groups do is put up online petitions.  Is it ready to be testable?  If it needs work, I'd rather put my energy into that than into updating drupal petition to use v2 api.

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • API Migration from 1.x to 2.x

This forum was archived on 2017-11-26.