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

Author Topic: postProcess frustration  (Read 632 times)

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
postProcess frustration
June 23, 2011, 06:00:34 am
I find myself frequently wrestling with the postProcess hook because the form object passed to it doesn't quite give me what I need (there are other issues as well, but this is the primary one).

case in point:
I have an on-behalf-of membership signup form. I need to collect additional fields for the org record (running 3.3.x -- yes, I know we now have or soon will have the ability to control on behalf of forms via profiles; I have other things i need to do, like tag the record programmatically). No problem adding the fields to the form, and I can retrieve them in the params array via postProcess form object.

my problem? the form object doesn't store the organization id. it stores the related_contact id (for the individual connected with the org) and it stores the membership id and such; but not the org id. so unless i do a lookup on the membership id or something, i don't have access to the org id to proceed with the various data work.

i think the issue is that we unset the org id so that it doesn't get confused with the indiv contact id, and then never add it back into the form object. quite frustrating.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: postProcess frustration
June 23, 2011, 06:03:21 am
so in Confirm.php, around 478 (v3.3.5) -- we unset the org fields from the params array.
but they have distinct keys -- why do we need to unset them? i understand why we set a new array for processing them, but why unset? they shouldn't conflict with the indiv record.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: postProcess frustration
June 23, 2011, 06:11:18 am
ok, so I'm walking through Confirm.php
we do set the contact ID in the session. so I am able to retrieve it from there when inside the postProcess hook. but i really think that data should be added back to the form object -- it's integral to the form operation.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: postProcess frustration
June 23, 2011, 06:17:53 am
Agree, having a context in the hooks is something that is missing, painfully.

Why do you store that on the session? Put it in a global variable should be "as good".

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

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: postProcess frustration
June 23, 2011, 06:46:58 am
by "we do" I mean -- the Confirm.php script stores the contactID in the session. comments state its for future use, such as the tell a friend pages.

so I was just indicating that I do have a way of pulling the org ID via the session when in the hook, without having to override core or doing a lookup using the mem id value.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

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: postProcess frustration
June 23, 2011, 07:25:22 am

This is primarily a legacy issue more than anything else :(

We need to start moving towards converting some of the "local" variables in functions for the DB objects created in postProcess to class variables in the form and set it. This will allow down-stream modules to use and manipulate the DB as needed.

If interested, ping me on IRC and we can fix this one for the next 3.4.x release

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

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • postProcess frustration

This forum was archived on 2017-11-26.