<path>civicrm/contribute/invoice</path>
<title>PDF Invoice</title>
<page_callback>CRM_Contribute_Form_Task_Invoice::getPrintPDF</page_callback>
- <access_arguments>access CiviContribute</access_arguments>
+ <access_callback>CRM_Core_Permission::checkDownloadInvoice</access_callback>
<page_type>1</page_type>
<weight>620</weight>
<component>CiviContribute</component>
'edit message templates' => array(
$prefix . ts('edit message templates'),
),
+ 'view my invoices' => array(
+ $prefix . ts('download my invoices'),
+ ts('Allow users to view/ download their own invoices'),
+ ),
);
if (!$descriptions) {
) ? TRUE : FALSE;
}
+ /**
+ * Verify if the user has permission to get the invoice.
+ *
+ * @return bool
+ * TRUE if the user has download all invoices permission or download my
+ * invoices permission and the invoice author is the current user.
+ */
+ public static function checkDownloadInvoice() {
+ global $user;
+ $cid = CRM_Core_BAO_UFMatch::getContactId($user->uid);
+ if (CRM_Core_Permission::check('access CiviContribute') ||
+ (CRM_Core_Permission::check('view my invoices') && $_GET['cid'] == $cid)
+ ) {
+ return TRUE;
+ }
+ return FALSE;
+ }
+
}