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) »
  • Joomla1.6/civicrm4 - cant get hooks to work
Pages: [1]

Author Topic: Joomla1.6/civicrm4 - cant get hooks to work  (Read 889 times)

tac12

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 4.3.5
  • CMS version: Drupal6
  • MySQL version: 5.1.69
  • PHP version: 5.3.3
Joomla1.6/civicrm4 - cant get hooks to work
May 08, 2011, 03:18:13 am
This code work on drupal7/civicrm4 but not joomla1.6/civicrm4 - where am I going wrong:


more /var/www/html/member/media/civicrm/custom/civicrmHooks.php

function joomla_civicrm_post( $op, $objectName, $objectId, &$objectRef ) {
civicrm_initialize( true );
require_once 'CRM/Core/Config.php';
$config =& CRM_Core_Config::singleton( );

require_once "api/v2/Contact.php";
require_once "api/v2/Relationship.php";
require_once "api/v2/GroupContact.php";
// configuration stuff
    $customId = 8;
    $relationId = 1;
    if ($objectName == 'Individual' && $op == 'create') {
        $session   =& CRM_Core_Session::singleton( );
        $parentId = $session->get( 'userID' );
        $childId = $objectId;
     // assign to the custom field
        $customParams = array("entityID" => $objectId,
            "custom_$customId" => $parentId);
        require_once 'CRM/Core/BAO/CustomValueTable.php';
        CRM_Core_BAO_CustomValueTable::setValues( $customParams );
     // create the relationship
        add_relationship($childId,$parentId,$relationId);
}}


function add_relationship($contactaID,$contactbID,$relationshipType) {

        $relationshipParams = array(
                    'contact_id_a'         => $contactaID,
                    'contact_id_b'         => $contactbID,
                    'relationship_type_id' => $relationshipType,
                    'is_permission_b_a'    => 1,
                    'is_active'            => 1
                    );
        $relationshipCreate = & civicrm_relationship_create( $relationshipParams );
        if ( civicrm_error ( $relationshipCreate )) {
                return $relationshipCreate['error_message'];
        }
}

tac12

  • I’m new here
  • *
  • Posts: 17
  • Karma: 0
  • CiviCRM version: 4.3.5
  • CMS version: Drupal6
  • MySQL version: 5.1.69
  • PHP version: 5.3.3
Re: Joomla1.6/civicrm4 - cant get hooks to work
May 15, 2011, 10:11:34 am
I'll answer my own post,  the hooking process of course is now different.  The documentation has been updated to show that hooks are now implemented as joomla plugins.

I now have my hook to allow a parent to update their child's info and for their ID to be stored in the child's custom data and then create the parent->child relationship.

Thanks for updating the docs,  I was about to give up!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Joomla1.6/civicrm4 - cant get hooks to work

This forum was archived on 2017-11-26.