0

In the CiviCRM Case View, I want to add another column to the Activities table. Right now, the last column contains some links ("View", "Edit", "Delete") and one link to an attached document if existent. I want to split this last column in two, so the link to attachments and the other links are in two different columns.

Therefore, I doubled the last column inside the sites/all/modules/civicrm/templates/CRM/Case/Form/ActivityTab.tpl template:

<th data-data="links" data-orderable="false" class="crm-case-activities-status">&nbsp;</th>
<th data-data="links" data-orderable="false" class="crm-case-activities-status">&nbsp;</th>

Then, I adapted the first column like this:

<th data-data="links" class="crm-case-activities-status">&nbsp;Dokumente </th>
<th data-data="links" data-orderable="false" class="crm-case-activities-status">&nbsp;</th>

Now, I am stuck at the content part. Does anyone know from which location "links" is called or created? I read that the html "data" attribute can be used by a JavaScript script. As I need only the links to any attached documents, but not the others, I would need to alter that script.

Edit: Alternatively, it would be helpful to know where the Activity table is created (<table id="case_id_{$caseid}" class="nestedActivitySelector crm-ajax-table" data-page-length="100">).

Edit: Reading Demerit's answer, I have checked the addCaseActivityLinks() function. To adapt it for my documents column, I thought about copying the function, renaming it, adapting it, and make the ActivityTab.tpl call it inside my document tag. Another solution would be to use an existing param of the addCaseActivityLinks() function in order to determine with which value of data-data the function has been called (data-data="links" or data-data="documents"). These existing params are: $caseID, $contactID, $userID, $context, $dao, $allowView = TRUE

I think I am still missing understanding of how/where the addCaseActivityLinks() function is called, so I would be able to implement one of the abovementioned solutions. I searched the whole project for a fucntion call, but couldn't find one. Any hint anyone?

2

Finally, I solved the problem like this:

  1. sites/all/modules/civicrm/templates/CRM/Case/Form/ActivityTab.tpl -> add another cell to the activity table: <th data-data="document_links" data-orderable="false" class="crm-case-activities-status">&nbsp;Dokumente </th>
  2. sites/all/modules/civicrm/CRM/Case/Selector/Search.php -> add the function addDocumentLinks() that is basically only the document-link part of the original function addCaseActivityLinks():
public static function addDocumentLinks($caseID, $contactID, $userID, $context, $dao, $allowView = TRUE) {
$caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted');
$actionLinks = self::actionLinks();
// Check logged in user for permission.
if (CRM_Case_BAO_Case::checkPermission($dao->id, 'view', $dao->activity_type_id, $userID)) {
$permissions[] = CRM_Core_Permission::VIEW;
  }
if (!$allowView) {
unset($actionLinks[CRM_Core_Action::VIEW]);
  }
$linksMarkup = "";
// if there are file attachments we will return how many and, if only one, add a link to it
if (!empty($dao->attachment_ids)) {
$linksMarkup .= implode(' ', CRM_Core_BAO_File::paperIconAttachment('civicrm_activity', $dao->id));
  }
return $linksMarkup;
}
  1. sites/all/modules/civicrm/CRM/Case/Selector/Search.php -> delete the document-link part from the original function addCaseActivityLinks():
public static function addCaseActivityLinks($caseID, $contactID, $userID, $context, $dao, $allowView = TRUE) {
$caseDeleted = CRM_Core_DAO::getFieldValue('CRM_Case_DAO_Case', $caseID, 'is_deleted');
$actionLinks = self::actionLinks();
// Check logged in user for permission.
if (CRM_Case_BAO_Case::checkPermission($dao->id, 'view', $dao->activity_type_id, $userID)) {
$permissions[] = CRM_Core_Permission::VIEW;
  }
if (!$allowView) {
unset($actionLinks[CRM_Core_Action::VIEW]);
  }
if (!$dao->deleted) {
// Activity is not deleted, allow user to edit/delete if they have permission
    // hide Edit link if:
    // 1. User does not have edit permission.
    // 2. Activity type is NOT editable (special case activities).CRM-5871
if (CRM_Case_BAO_Case::checkPermission($dao->id, 'edit', $dao->activity_type_id, $userID)) {
$permissions[] = CRM_Core_Permission::EDIT;
    }
if (in_array($dao->activity_type_id, CRM_Activity_BAO_Activity::getViewOnlyActivityTypeIDs())) {
unset($actionLinks[CRM_Core_Action::UPDATE]);
    }
if (CRM_Case_BAO_Case::checkPermission($dao->id, 'delete', $dao->activity_type_id, $userID)) {
$permissions[] = CRM_Core_Permission::DELETE;
    }
unset($actionLinks[CRM_Core_Action::RENEW]);
  }
$extraMask = 0;
if ($dao->deleted && !$caseDeleted
&& (CRM_Case_BAO_Case::checkPermission($dao->id, 'delete', $dao->activity_type_id, $userID))) {
// Case is not deleted but activity is.
    // Allow user to restore activity if they have delete permissions
unset($actionLinks[CRM_Core_Action::DELETE]);
$extraMask = CRM_Core_Action::RENEW;
  }
if (!CRM_Case_BAO_Case::checkPermission($dao->id, 'Move To Case', $dao->activity_type_id)) {
unset($actionLinks[CRM_Core_Action::DETACH]);
  }
if (!CRM_Case_BAO_Case::checkPermission($dao->id, 'Copy To Case', $dao->activity_type_id)) {
unset($actionLinks[CRM_Core_Action::COPY]);
  }
$actionMask = CRM_Core_Action::mask($permissions) | $extraMask;
$values = [
'aid' => $dao->id,
'cid' => $contactID,
'cxt' => empty($context) ? '' : "&context={$context}",
'caseid' => $caseID,
  ];
$linksMarkup = CRM_Core_Action::formLink($actionLinks,
$actionMask,
$values,
ts('more'),
FALSE,
'case.tab.row',
'Activity',
$dao->id
);

// deleted part

return $linksMarkup;
}
  1. sites/all/modules/civicrm/CRM/Case/BAO/Case.php -> add the function call for addDocumentLinks() inside the function getCaseActivity() inside the while loop while($dao->fetch()) { } (approx. line 1091):
$caseActivities[$caseActivityId]['document_links']
        = CRM_Case_Selector_Search::addDocumentLinks($caseID, $contactID, $userID, $context, $dao);
| improve this answer | |
1

It's in CRM/Case/Selector/Search.php in addCaseActivityLinks().

But on a more general note, between this and your other questions there's a lot of customizing going on and it may make upgrading difficult. At some point you might want to consider something like webform to customize forms or even going full custom and making your own pages/forms in an extension and using the api to pull in just the data you need.

| improve this answer | |
  • We are already using Drupal webform, but only for some menue pages. I'll take a closer look into that. The reason I am working in this nonperfect way right now is that the customized software should go into the next test phase with an NGO in a while. So I'd put all my changes in an extension (or similar solution) after that. – emma Oct 21 at 7:53
  • What about the Custom Template Dir and the Custom PHP Dir in /civicrm/admin/setting/path?reset=1 ? Would you recommend using them? – emma Oct 21 at 8:19
  • Only for small stuff that's easy to reapply after each upgrade, since you'll still need to merge in any core changes into your overridden file after every upgrade. (I haven't used this extension but see also github.com/artfulrobot/patchwork) – Demerit Oct 21 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.