Answers.Body: <p>sites/default/files/civicrm/templates_c is where temporary compiled files live. You could try instead editing templates/CRM/Case/Form/CaseView.tpl but there is no such thing as hasAccessToMyCases (where you've just replaced &quot;All&quot; with &quot;My&quot;) so you'd need to use something else. But also note this will break when you upgrade since the file will get replaced.</p>
  <p>What I would do is create an extension and in hook_civicrm_buildForm I would do something like:</p>
  <pre><code>if ($formName == 'CRM_Case_Form_CaseView') {
    $form-&gt;assign('hasAccessToAllCases',
      CRM_Core_Permission::check('access my cases and activities'));
  }
  </code></pre>
  <p>This would also give access to the Audit Report, but you're probably ok with that since it's just a variation of the Print Report. I vaguely remember the original reason for restricting being something like &quot;this would make it too easy for somebody to print it and then give it to an unauthorized person, either on purpose or inadvertently&quot;. It was a different era.</p>
  <p>But it may also allow access to other things it shouldn't. Would need to test.</p>
  <p>Then you also need to edit <a href="https://github.com/civicrm/civicrm-core/blob/58c72a10da01d86f790a62c54976cbf8726117d0/CRM/Case/xml/Menu/Case.xml#L114" rel="nofollow noreferrer">this line in CRM/Case/xml/Menu/Case.xml</a> which controls access to urls, and then clear civi caches after at Admin - System Settings - Cleanup Caches.</p>
  <p><code>&lt;access_arguments&gt;access all cases and activities&lt;/access_arguments&gt;</code></p>
  <p>change to</p>
  <p><code>&lt;access_arguments&gt;access my cases and activities&lt;/access_arguments&gt;</code></p>
  <p>Also when you get redirected like that, if you then visit any civi page it will show you the actual error.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-01T08:38:25.917Z
Answers.Text: In templates/CRM/Case/Form/CaseView.tpl there **is** such a thing as hasAccessToMyCases. It needs to be changed for the Print-Report button to appear.
Answers.UserDisplayName: emma
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-01T12:47:31.280Z
Answers.Text: There is hasAccessToAllCases not hasAccessToMyCases. The above code reassigns the former's value. For your 2nd edit above, you might be right there is somewhere else you need to also update.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-01T14:04:38.393Z
Answers.Text: Have updated with the other place you need to update, and I've actually tested it this time.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-10-05T08:38:15.147Z
Answers.Text: Now it works!! Thanks a lot!
Answers.UserDisplayName: emma
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-09-29T14:41:11.440Z
Answers.LastActivityDate: 2020-10-01T14:04:00.137Z
Answers.LastEditDate: 2020-10-01T14:04:00.137Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>I now created a small extension for that purpose: <a href="https://github.com/5knots/de.5knoten.access-to-print-report" rel="nofollow noreferrer">https://github.com/5knots/de.5knoten.access-to-print-report</a></p>
  <p>It is my first extension and I am open for any comments on that :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-11T17:43:10.137Z
Answers.Text: Nice. The extension has a couple copies of core files in its root directory that I don't think would do anything. Are they just there for your own reference?
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-10T12:07:02.670Z
Answers.LastActivityDate: 2020-12-10T12:18:42.903Z
Answers.LastEditDate: 2020-12-10T12:18:42.903Z
Answers.UserDisplayName: emma
Body: <p>I want to modify CiviCase so that every user with the right &quot;view my cases and activities&quot; can see and use the &quot;Print a Report&quot; button in the Case View.
  Right now, this is only granted to users with the &quot;view <strong>all</strong> cases and activities&quot; right.</p>
  <p>I modified a template (sites/default/files/civicrm/templates_c/en_US/%%64/643/643EC55F%%CaseView.tpl.php) where I found the &quot;Print Report&quot; link in the following code:</p>
  <pre><code>&lt;?php if ($this-&gt;_tpl_vars['hasAccessToMyCases']): ?&gt; &amp;nbsp;
  
            &lt;a class=&quot;crm-hover-button action-item no-popup&quot; href=&quot;&lt;?php echo CRM_Utils_System::crmURL(array('p' =&gt; 'civicrm/case/report/print','q' =&gt; &quot;all=1&amp;redact=0&amp;cid=&quot;.($this-&gt;_tpl_vars['contactID']).&quot;&amp;caseID=&quot;.($this-&gt;_tpl_vars['caseId']).&quot;&amp;asn=&quot;), $this);?&gt;
  &quot;&gt;&lt;i class=&quot;crm-i fa-print&quot; aria-hidden=&quot;true&quot;&gt;&lt;/i&gt; &lt;?php $this-&gt;_tag_stack[] = array('ts', array()); $_block_repeat=true;smarty_block_ts($this-&gt;_tag_stack[count($this-&gt;_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?&gt;Print Report&lt;?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_ts($this-&gt;_tag_stack[count($this-&gt;_tag_stack)-1][1], $_block_content, $this, $_block_repeat); }  array_pop($this-&gt;_tag_stack); ?&gt;&lt;/a&gt;
          &lt;?php endif; ?&gt;
  </code></pre>
  <p>and changed the condition to:</p>
  <pre><code>&lt;?php if ($this-&gt;_tpl_vars['hasAccessToMyCases']): ?&gt; &amp;nbsp;
  </code></pre>
  <p>Now, the &quot;Print Report&quot; button appears also when I log in as a user that has only &quot;view my cases and activities&quot; rights. But when I click on it, I get redirected to the (non-logged-in) startpage.</p>
  <p>Does anybody have an idea what else needs to be changed?</p>
  <p><em>Edit</em>:
  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.</p>
  <p><em>Edit:</em>
  I think the problem is that I am setting the permission to &quot;view all cases and activities&quot; 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 <code>sites/all/modules/civicrm/CRM/Report/Page/Report.php</code>.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-30T15:03:31.677Z
Comments.Text: I made a typo. Have updated. But I admit I haven't tested the solution, just pointing in a direction to go.
Comments.UserDisplayName: Demerit
Tags: <civicase><permissions>
Title: Change permission to "Print Report" in CiviCase
ThreadText: # Change permission to "Print Report" in CiviCase
  
  (Asked by: username_0 on 2020-09-29)
  
  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:
  _tpl_vars['hasAccessToMyCases']): ?>  
  
            _tpl_vars['contactID'])."&caseID=".($this->_tpl_vars['caseId'])."&asn="), $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_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); }  array_pop($this->_tag_stack); ?>
          
  
  and changed the condition to:
  _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 username_1'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.
  
  **Tags:** civicase, permissions
  
  > **Comments:**
  > **username_1**: I made a typo. Have updated. But I admit I haven't tested the solution, just pointing in a direction to go.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-09-29. Score: 1 | Accepted answer
  
  sites/default/files/civicrm/templates_c is where temporary compiled files live. You could try instead editing templates/CRM/Case/Form/CaseView.tpl but there is no such thing as hasAccessToMyCases (where you've just replaced "All" with "My") so you'd need to use something else. But also note this will break when you upgrade since the file will get replaced.
  What I would do is create an extension and in hook_civicrm_buildForm I would do something like:
  if ($formName == 'CRM_Case_Form_CaseView') {
    $form->assign('hasAccessToAllCases',
      CRM_Core_Permission::check('access my cases and activities'));
  }
  
  This would also give access to the Audit Report, but you're probably ok with that since it's just a variation of the Print Report. I vaguely remember the original reason for restricting being something like "this would make it too easy for somebody to print it and then give it to an unauthorized person, either on purpose or inadvertently". It was a different era.
  But it may also allow access to other things it shouldn't. Would need to test.
  Then you also need to edit this line in CRM/Case/xml/Menu/Case.xml which controls access to urls, and then clear civi caches after at Admin - System Settings - Cleanup Caches.
  access all cases and activities
  change to
  access my cases and activities
  Also when you get redirected like that, if you then visit any civi page it will show you the actual error.
  
  > **Comments:**
  > **username_0**: In templates/CRM/Case/Form/CaseView.tpl there **is** such a thing as hasAccessToMyCases. It needs to be changed for the Print-Report button to appear.  
  > **username_1**: There is hasAccessToAllCases not hasAccessToMyCases. The above code reassigns the former's value. For your 2nd edit above, you might be right there is somewhere else you need to also update.  
  > **username_1**: Have updated with the other place you need to update, and I've actually tested it this time.  
  > **username_0**: Now it works!! Thanks a lot!  
  
  ---
  
  ### Answer by username_0 on 2020-12-10. Score: 0
  
  I now created a small extension for that purpose: <https://github.com/5knots/de.5knoten.access-to-print-report>
  
  It is my first extension and I am open for any comments on that :)
  
  > **Comments:**
  > **username_1**: Nice. The extension has a couple copies of core files in its root directory that I don't think would do anything. Are they just there for your own reference?  
  
  ---
  
  