I want to modify CiviCase so that every user with the right "view my cases and activities" can see and use the "Print a Report" button in the Case View. Right now, this is only granted to users with the "view all cases and activities" right.
I modified a template (sites/default/files/civicrm/templates_c/en_US/%%64/643/643EC55F%%CaseView.tpl.php) where I found the "Print Report" link in the following code:
<?php if ($this->_tpl_vars['hasAccessToMyCases']): ?>
<a class="crm-hover-button action-item no-popup" href="<?php echo CRM_Utils_System::crmURL(array('p' => 'civicrm/case/report/print','q' => "all=1&redact=0&cid=".($this->_tpl_vars['contactID'])."&caseID=".($this->_tpl_vars['caseId'])."&asn="), $this);?>
"><i class="crm-i fa-print" aria-hidden="true"></i> <?php $this->_tag_stack[] = array('ts', array()); $_block_repeat=true;smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?>Print Report<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); } array_pop($this->_tag_stack); ?></a>
<?php endif; ?>
and changed the condition to:
<?php if ($this->_tpl_vars['hasAccessToMyCases']): ?>
Now, the "Print Report" button appears also when I log in as a user that has only "view my cases and activities" rights. But when I click on it, I get redirected to the (non-logged-in) startpage.
Does anybody have an idea what else needs to be changed?
Edit: I created an extension including Demerit's code. It was necessary to additionally change the permission in the file templates/CRM/Case/Form/CaseView.tpl so the button will be visible in the first place. Though, the functionality doesn't work yet.
Edit:
I think the problem is that I am setting the permission to "view all cases and activities" only on the CaseView form, but not the page that opens when user clicks 'Print Report'. I suppose the permissions for that page are set in sites/all/modules/civicrm/CRM/Report/Page/Report.php
.