Use case: while using this module in ERPAL, I'm trying to create new relationship for having ownership of an organization. Individual and organizations may have ownership in any organizations, so relationship [Label: "Owner of"; Directional = 'checked'; Reverse label: "Owned by"; Unique = 'checked'; Source contact types = 'Any' (All CRM Core Contact bundles); Destination contact types = 'Organization'] was created and some additional fields (like sharecapital in EUR) were added.
While "Add a relationship" for a specific contact:
Relationship 'Owner of' works as designed for individual: can create ownership in any organization.
Relationship 'Owned by' works as designed for organizations: can create owner (individual or organization).
Relationship 'Owner of' do not show up.
During research it was found, that CRM Core module's file 'crm_core_relationship_ui.pages.inc' overwrites existing $relationship_types (line 195), while doing foreach (line 188).
foreach (array(0, 1) as $reverse) {
$relationship_types = crm_core_relationship_load_relationship_types($contact->type, $reverse);
foreach ($relationship_types as $relationship_type) {
if (user_access('create relation entities of bundle ' . $relationship_type->relation_type) || user_access('create relation entities of any contact relationship')) {
$contact_uri = $contact->uri();
$href = $contact_uri['path'] . '/relationships/add/' . $relationship_type->relation_type . '/' . $reverse;
$title = $reverse ? $relationship_type->reverse_label : $relationship_type->label;
$relationship_type_links[$relationship_type->relation_type] = array(
'title' => $title,
'href' => $href,
'localized_options' => array(),
'description' => t('Create %kind relationship.', array('%kind' => $title)),
);
}
}
}
Problem was solved, when I added '$reverse' value to $relationship_type_links array key:
$relationship_type_links[$relationship_type->relation_type . '_' . $reverse] = array(
Maybe it is working as designed, but in my case I had to change this line.
It's my first created issue, so sorry for any mistake.
Comments
Comment #2
sanka CreditAttribution: sanka commentedComment #3
RoSk0Hi there. And congratulate you with a great start in contributors life - it looks like you have found a bug and you know what is the solution. If you want to see your name in git attribution for this issue fix you should read this docs about patches https://www.drupal.org/patch and submit your patch properly.
Comment #4
grahlClosing outdated issue, please reopen if still relevant.