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) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • CiviCRM post hook not all event object properties available at operation create
Pages: [1]

Author Topic: CiviCRM post hook not all event object properties available at operation create  (Read 1153 times)

elshae

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 3.3.3
  • CMS version: Drupal 6.19
  • MySQL version: 5.1.50
  • PHP version: 5.2.14
CiviCRM post hook not all event object properties available at operation create
June 15, 2011, 07:59:48 am
Hello CiviCRM,

I am attempting to write a module that will create a Drupal event node when a CiviCRM event object is created.  However, I am seeing that the civicrm_post hook is not providing me with all the available event properties that I can view in the smarty debug console, some of these being event_title and event_description.  I also notice that when an event is created it is done in tabs.  The first tab is where one gives the event a title and description, another tab is for specifying the event address.  This will be possibly problematic to my cause because my original intent was to pull all of the event info and use it to create the Drupal node, but with my current code the Drupal node is created as soon as the first tab is complete which does not include the address information etc.

IS there any way I can accomplish my goal?  I appreciate all your time and help.

(I wanted to wrap it in code tags but I got an error saying "not allowed to post external links")

function eventsfromcivi_civicrm_post( $op, $objectName, $objectId, &$objectRef ){
   if ($objectName == 'Event'){
      if ($op == 'create'){
         module_load_include('inc', 'node', 'node.pages');
         $new_event_node = array('type' => 'event');
         $form_state = array();
         $form_state['values']['title'] = $objectRef->title; // $objectRef->event_title does not work
         $form_state['values']['body'] = $objectRef->description; // $objectRef->event_description does not work
         $form_state['values']['uid'] = 1;
         $form_state['values']['name'] = "admin";
         $form_state['values']['status'] = 1; //1 = published
         $form_state['values']['op'] = t('Save');
      
         $result = drupal_execute('event_node_form', $form_state, (object)$new_event_node);
      }// if ($op == 'create')
   
   }//if ($objectName == 'Event')

}// function eventsfromcivi_civicrm_post

elshae

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 3.3.3
  • CMS version: Drupal 6.19
  • MySQL version: 5.1.50
  • PHP version: 5.2.14
Re: CiviCRM post hook not all event object properties available at operation create
June 15, 2011, 09:31:17 am
Ok I am updating this post as I have found out from chatting on the IRC (thank you FatherShawn) that I could not retrieve all the information at the 'create' operation in the post hook.  Instead I  should save the ID and then later use the event API's to get the rest of the info which is ok.  However, I notice two new issues with this:

1.  The event and location API are seperate and I am not seeing any param that ties them together.  How can I know which location info I could call for the event in question.
2.  I need to process all this when the 'save and done' button has been pressed for an event object.  Looking through the API I have not yet found a way to fire an event when that button is pressed :/

Thanks again for your time and interest

elshae

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviCRM post hook not all event object properties available at operation create
June 16, 2011, 08:26:27 am
Quote
1.  The event and location API are seperate and I am not seeing any param that ties them together.  How can I know which location info I could call for the event in question.
civicrm_event table has "loc_block_id" column and address etc information is stored civicrm_loc_block table


Quote
2.  I need to process all this when the 'save and done' button has been pressed for an event object.  Looking through the API I have not yet found a way to fire an event when that button is pressed :/
"Save and Done" should call post hook.

HTh
Kurund
Found this reply helpful? Support CiviCRM

elshae

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 3.3.3
  • CMS version: Drupal 6.19
  • MySQL version: 5.1.50
  • PHP version: 5.2.14
Re: CiviCRM post hook not all event object properties available at operation create
June 16, 2011, 08:32:19 am
Thanks for your reply Kurund.  It seems through the event API I cannot get variables that correspond to that table info.  Does this mean I would actually have to go and query the table?  I just feel like there has to be a way through the API...

Also when creating an event the 'create' operation seems to be triggered as soon as I hit the continue button on the first page.  I am not given the option to hit save and done until I am taken to the other tabs of the event i.e. location, online registration etc...

Sorry if I am just overlooking something really obvious,

elshae

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: CiviCRM post hook not all event object properties available at operation create
June 16, 2011, 09:16:12 pm
elshae:

I tried your above on 3.4.x and seems to be calling post hook. Can you check if you have enabled "eventsfromcivi" module etc.

HTh
Kurund
Found this reply helpful? Support CiviCRM

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: CiviCRM post hook not all event object properties available at operation create
June 16, 2011, 09:59:37 pm
You might be able to add 'return.loc_block_id' => 1 & get it back from your GET.

I have also noticed the event post hook is pretty stingy about what data it passes on - I have been missing 'created_id'.
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

elshae

  • I’m new here
  • *
  • Posts: 4
  • Karma: 0
  • CiviCRM version: 3.3.3
  • CMS version: Drupal 6.19
  • MySQL version: 5.1.50
  • PHP version: 5.2.14
Re: CiviCRM post hook not all event object properties available at operation create
June 17, 2011, 01:05:03 pm
I have updated to 3.4.3 and still this information does not save on the 'create' operation, but more like the 'edit' operation.

I see this loc_block_id but I am not sure what it is, is that supposed to be the id of the location for the event?  How can I fetch the event's location?  Still have not been able to figure this out :/

Thanks,

elshae

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Drupal Modules (Moderator: Donald Lobo) »
  • CiviCRM post hook not all event object properties available at operation create

This forum was archived on 2017-11-26.