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) »
  • compId, compAction, compContext
Pages: [1]

Author Topic: compId, compAction, compContext  (Read 1083 times)

jakecivi

  • I post frequently
  • ***
  • Posts: 140
  • Karma: 0
compId, compAction, compContext
May 31, 2012, 10:17:02 am
What is the purpose of compId, compAction, and compContext when editing an event participant's related contributions and in general?

I'm building something to be used similarly to Drupal's 'destination' URL query string argument for editing an event particiapnt's contributions and returning to the correct page.

I'm currently adding my own args to the end of the URL, but I wonder if I can use the existing compId, compAction, compContext to do what I'm trying to do.

Here's the current setup: I've used jquery to add a URL arg to the contribution View, Edit, and Delete links called "return_action" , and if it's set to either 'view' or 'edit', it will drupal_goto the View Participant page with the corresponding action set.  I'm also using an arg called "participant_id"  in an "add a payment" link which goes to the new contribution page, and then the New Contribution page, if the participant_id is set, the buildForm hook sets defaults and freezes the Contact and Source fields, the pre hook sets the fee level to "Admin added", and the post hook creates a participant_payment record linking the participant_id that was set in the URL with the new contribution's id.

jakecivi

  • I post frequently
  • ***
  • Posts: 140
  • Karma: 0
Re: compId, compAction, compContext
May 31, 2012, 12:53:26 pm
For the record, this is what dgg said in irc:

Quote
[1:30pm] dgg: [...] context indicates which contact tab to return to on save or cancel
[1:31pm] dgg: looks like compId is the primary key of the related transaction (i.e the participant record linked to that contribution)
[1:33pm] dgg: and i think compAction indicates the action (edit vs. view) that you're coming from - that's a guess based on some quick observations
[1:33pm] dgg: but in general there are action constants in civi - and 2 is update/edit, 4 is view
[1:33pm] dgg: hth


I have this question now:

About action constants being 2 and 4 (I understand it's a bitmask, from looking at the code) - is there a reason the numeric constants are used in the url for 'compAction', yet the words 'view' and 'update' are used in the url for 'action', as in the following url?
civicrm/contact/view/contribution?reset=1&action=update&id=51&cid=102&context=search&compId=109&compAction=4&compContext=participant

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: compId, compAction, compContext
May 31, 2012, 03:10:32 pm
Sometimes, "historical reason" is the main reason of something.

I don't know the specifics of that page, but the action param and how it's used in the templates to decide what to display is probably a good candidate for re-factoring.

Are you based in Europe? We have two sprints (around civicon) & one in nov. Both are good times to update some old code and improve it....

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

jakecivi

  • I post frequently
  • ***
  • Posts: 140
  • Karma: 0
Re: compId, compAction, compContext
May 31, 2012, 03:22:35 pm
I'm not in Europe... I'm in the US... would be interested in knowing dates and locations of sprints (and civicon), though.

jakecivi

  • I post frequently
  • ***
  • Posts: 140
  • Karma: 0
Re: compId, compAction, compContext
June 01, 2012, 12:27:32 pm
A bug on a related note:

Path 1: Starting from either 'view' or 'update' on a Participant page, click Edit on the related contribution.  The compId and compAction get put into the url of the resulting contribution edit page.  This is as it should be.

Path 2: Click View on the contribution instead of Edit, and the compId and compAction get added to the url.  Then click the big Edit button on the contribution record.  You get to the exact same page as clicking directly on Edit from the participant page in Path 1, but the compId and compAction do not get carried over.  This is a bug; they should persist if they're present in the same way that 'context=participant' persists.

jakecivi

  • I post frequently
  • ***
  • Posts: 140
  • Karma: 0
Re: compId, compAction, compContext
June 08, 2012, 09:57:31 am
Further note about 'action' being numeric or a string:

Look at this line from CRM_Utils_Request::retrieve:

Code: [Select]
        // minor hack for action
        if ( $name == 'action' && is_string( $value ) ) {
            $value = CRM_Core_Action::resolve( $value );
        }

It looks like 'action' gets special treatment.  If it's a string, it gets to converted to its numeric constant (or an array of constants if it's a string of multiple actions separated by '|' ?) before anything else sees it.

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

This forum was archived on 2017-11-26.