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) »
  • Adding fields to "Edit Contact Information" screen for related contacts
Pages: 1 [2]

Author Topic: Adding fields to "Edit Contact Information" screen for related contacts  (Read 10484 times)

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: Adding fields to "Edit Contact Information" screen for related contacts
August 28, 2010, 02:18:38 pm

what version?

in 3.2.2 (maybe 3.2.x) there is a bug with the relationship permissioning code. This will be fixed in 3.2.3

http://issues.civicrm.org/jira/browse/CRM-6754

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

andyw

  • I post occasionally
  • **
  • Posts: 82
  • Karma: 4
  • CiviCRM version: 4.x
  • CMS version: Drupal, Joomla
Re: Adding fields to "Edit Contact Information" screen for related contacts
September 01, 2010, 09:33:13 am
I seem to be getting the same problem as Roland-ST, in that after following Lobo's instructions for adding a link to edit an Organization-based profile to the Dashboard, the link ends up redirecting you to the homepage.

Nor does it appear to relate to issue CRM-6754, as the relationship is clearly there (it's doesn't disappear as indicated in the description of that issue).

And, likewise, if I add /administrator to the beginning of the URL, I can preview the profile through Joomla's admin.

I'm using CiviCRM 3.1.5 on Joomla 1.5.8
Andrew Walker, Developer at Circle Interactive

Roland-ST

  • I post occasionally
  • **
  • Posts: 41
  • Karma: 0
Re: Adding fields to "Edit Contact Information" screen for related contacts
September 16, 2010, 06:06:42 am
Lobo, I used CiviCrm 3.1.5 on Joomla 1.5.18. Do you think CiviCrm update will solve the issue?

crawdaddyFL

  • I’m new here
  • *
  • Posts: 11
  • Karma: 2
  • CiviCRM version: 4.1.3
  • CMS version: Joomla 2.5.6
  • MySQL version: 5.1.63
  • PHP version: 5.2.17
Re: Adding fields to "Edit Contact Information" screen for related contacts
August 25, 2012, 01:57:49 pm
Old topic but resurfacing it in hopes someone got through it - experiencing the same issue with Joomla 2.5.6 / Civi 4.1.3. 

Lobo's suggested change to the Edit Relationship link causes a redirect to the homepage.  When I go back to my own dashboard after the redirect, I get the "You do not have permission to edit this contact record. Contact the site administrator if you need assistance." message.

Like the others, it works when adding /administrator to the URL. 


crawdaddyFL

  • I’m new here
  • *
  • Posts: 11
  • Karma: 2
  • CiviCRM version: 4.1.3
  • CMS version: Joomla 2.5.6
  • MySQL version: 5.1.63
  • PHP version: 5.2.17
Re: Adding fields to "Edit Contact Information" screen for related contacts
August 26, 2012, 06:28:10 am
Problem is the checksum isn't included in the profile edit URL.  It can be quickly shown to work by adding a call to generate the checksum for a known contact ID with permissioned relationship in the CRM/Contact/Page/View/UserDashBoard.php links() method, then adding the checksum to the query string (param 'cs'):

Code: [Select]
  static
  function &links() {
    if (!(self::$_links)) {
      $disableExtra = ts('Are you sure you want to disable this relationship?');

      require_once 'CRM/Contact/BAO/Contact/Utils.php';
      $checksum = CRM_Contact_BAO_Contact_Utils::generateChecksum(168);

...

        CRM_Core_Action::UPDATE => array(
          'name' => ts('Edit this Profile'),
          'url' =>  'civicrm/profile/edit',
          'qs' => 'reset=1&gid=1&id=%%cbid%%&rcid=%%cid%%&cs='.$checksum,
 
...
 

But this isn't the right place for the code, since we don't have access to the related contact IDs at this point (the %%cbid%% variable is substituted later).  Now looking where to put it for real (in the template?).

crawdaddyFL

  • I’m new here
  • *
  • Posts: 11
  • Karma: 2
  • CiviCRM version: 4.1.3
  • CMS version: Joomla 2.5.6
  • MySQL version: 5.1.63
  • PHP version: 5.2.17
Re: Adding fields to "Edit Contact Information" screen for related contacts
August 26, 2012, 02:27:06 pm
Here's how I fixed this - no doubt other, possibly cleaner ways, but this works for me.

Step 1:
Create an override copy of CRM/Contact/BAO/Relationship.php.  Around line 976 (Civi 4.1.3) in the getRelationship function, after the link variable replacement array definition, add a call to generate the checksum.  This expects the checksum to be referenced via the variable 'cs', and only generates the checksum when the permissionedContact function parameter is TRUE.  This is a half-hearted attempt at limiting the checksum generation; I'm sure it'll still be called unnecessarily.

Code: [Select]
  static
  function getRelationship($contactId = NULL,
...
        if ($links) {
          $replace = array(
            'id' => $rid,
            'rtype' => $values[$rid]['rtype'],
            'cid' => $contactId,
            'cbid' => $values[$rid]['cid'],
            'caseid' => $values[$rid]['case_id'],
            'clientid' => $contactId,
          );
// new code below
          if($permissionedContact) {
            require_once 'CRM/Contact/BAO/Contact/Utils.php';
            $replace['cs'] = CRM_Contact_BAO_Contact_Utils::generateChecksum($values[$rid]['cid']);
          }
...

Step 2:
Create an override copy of CRM/Contact/Page/View/UserDashBoard.php.  In the links() function, modify the URL to be a profile edit, and the Update action to add the checksum to the query string:

Code: [Select]
  static
  function &links() {
 ...
      self::$_links = array(
        CRM_Core_Action::UPDATE => array(
          'title' => ts('Edit Relationship'),
          'name' => ts('Edit Contact Information'),
          //'url' => 'civicrm/contact/relatedcontact',
          //'qs' => 'action=update&reset=1&cid=%%cbid%%&rcid=%%cid%%',
          'url' =>  'civicrm/profile/edit',
          'qs' => 'reset=1&gid=1&id=%%cbid%%&rcid=%%cid%%&cs=%%cs%%',
        ),
...

Pages: 1 [2]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Adding fields to "Edit Contact Information" screen for related contacts

This forum was archived on 2017-11-26.