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) »
  • Backporting apiv3
Pages: [1]

Author Topic: Backporting apiv3  (Read 2420 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Backporting apiv3
March 25, 2011, 01:33:46 pm
Currently before I start on any custom code I backport the api v3 which obviously saves me time & the customer money + means the code is future proof. (NB - I have mostly been working on 3.3 installs so haven't tried backporting to older versions than that)

But, I'm not sure how to backport {CRM_api}. I don't use REST much but would be good to know how to backport that too.

To backport apiv3 I :

from the api directory in code base
svn co http://svn.civicrm.org/civicrm/trunk/api/api.php
svn co http://svn.civicrm.org/civicrm/trunk/api/v3

(and then use write code per http://svn.civicrm.org/civicrm/trunk/api/v3/examples)

Xavier - can you please give me the extra steps to backport?
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: Backporting apiv3
March 25, 2011, 01:50:08 pm
Hi,

If you copy CRM/Core/Smarty/plugins/function.crmAPI.php it should be enough.

For the rest interface, CRM/Utils/REST.php at least, and might be something else too ?

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: Backporting apiv3
March 30, 2011, 07:15:33 pm
Just noting that getting this is my 'backport script' (since I seem to be doing it all the time)

Code: [Select]
cd CRM/Core/Smarty/plugins
wget http://svn.civicrm.org/civicrm/trunk/CRM/Core/Smarty/plugins/function.crmAPI.php
cd ../../../..
svn co http://svn.civicrm.org/civicrm/trunk/api/
svn co http://svn.civicrm.org/civicrm/trunk/api/v3

(haven't done REST yet but works a treat otherwise)
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: Backporting apiv3
April 03, 2011, 03:08:39 am
REST should be replacing CRM/Utils/REST.php only (haven't tried, if someone tries, please confirm)
-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: Backporting apiv3
April 06, 2011, 03:48:16 pm
API v3 doco http://wiki.civicrm.org/confluence/display/CRMDOC40/CiviCRM+Public+APIs
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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Backporting apiv3
April 26, 2011, 09:29:12 pm
This patch is required to backport to 3.2.5 or earlier

Code: [Select]
Index: CRM/Core/Error.php
===================================================================
--- CRM/Core/Error.php (revision 989)
+++ CRM/Core/Error.php (working copy)
@@ -467,7 +467,14 @@
         $error->_errors = array( ) ;
         $error->_errorsByLevel = array( ) ;
     }
-
+    /* used for the API, rise the exception instead of catching/fatal it */
+    public static function setRaiseException( ) {
+        PEAR::setErrorHandling( PEAR_ERROR_CALLBACK,  array( 'CRM_Core_Error', 'exceptionHandler' ) );
+    }
+   
+    public static function exceptionHandler ($pearError) {
+        throw new PEAR_Exception($pearError->getMessage(),$pearError);   
+    }
     public static function ignoreException( $callback = null ) {
         if ( ! $callback ) {
             $callback = array( 'CRM_Core_Error', 'nullHandler' );
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: Backporting apiv3
May 09, 2011, 01:52:35 am
you also need to copy

CRM/Core/DAO/.listAll.php

and if backporting from 4.0.1

CRM/Core/DAO/.permissions.php
-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: Backporting apiv3
May 17, 2011, 02:06:02 pm
Need this function in CRM/Utils/Hook.php

    /**
     * This hook is called when API permissions are checked (cf. civicrm_api3_api_check_permission()
     * in api/v3/utils.php and _civicrm_api3_permissions() in CRM/Core/DAO/.permissions.php).
     *
     * @param string $entity       the API entity (like contact)
     * @param string $action       the API action (like get)
     * @param array &$params       the API parameters
     * @param array &$permisisons  the associative permissions array (probably to be altered by this hook)
     */
    static function alterAPIPermissions($entity, $action, &$params, &$permissions)
    {
        $config = CRM_Core_Config::singleton();
        require_once(str_replace('_', DIRECTORY_SEPARATOR, $config->userHookClass) . '.php');
        $null =& CRM_Core_DAO::$_nullObject;
        return eval("return {$config->userHookClass}::invoke(4, \$entity, \$action, \$params, \$permissions, \$null, 'civicrm_alterAPIPermissions');");
    }
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) »
  • Backporting apiv3

This forum was archived on 2017-11-26.