Skip to content

Commit

Permalink
CRM-20430 - Permission 'save Report Criteria'.
Browse files Browse the repository at this point in the history
If you don't have the permission, the 'save report' actions aren't shown
on the form of the report instance.

CRM-20430 - Check 'save Report Criteria' permission before saving a report instance.

Coding style issues.

Added a pre-commit message about the new permission.
  • Loading branch information
johanv authored and eileenmcnaughton committed May 11, 2018
1 parent ab72a9c commit 714515b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CRM/Core/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,9 @@ public static function getEntityActionPermissions() {
'create' => array('edit message templates'),
'update' => array('edit message templates'),
);

$permissions['report_template']['update'] = 'save Report Criteria';
$permissions['report_template']['create'] = 'save Report Criteria';
return $permissions;
}

Expand Down
33 changes: 22 additions & 11 deletions CRM/Report/BAO/ReportInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,24 +364,35 @@ public static function doFormDelete($instanceId, $bounceTo = 'civicrm/report/lis
* - general script-add.
*/
public static function getActionMetadata() {
$actions = array(
'report_instance.save' => array('title' => ts('Save')),
'report_instance.copy' => array(
$actions = array();
if (CRM_Core_Permission::check('save Report Criteria')) {
$actions['report_instance.save'] = array('title' => ts('Save'));
$actions['report_instance.copy'] = array(
'title' => ts('Save a Copy'),
'data' => array(
'is_confirm' => TRUE,
'confirm_title' => ts('Save a copy...'),
'confirm_refresh_fields' => json_encode(array(
'title' => array('selector' => '.crm-report-instanceForm-form-block-title', 'prepend' => ts('(Copy) ')),
'description' => array('selector' => '.crm-report-instanceForm-form-block-description', 'prepend' => ''),
'parent_id' => array('selector' => '.crm-report-instanceForm-form-block-parent_id', 'prepend' => ''),
'title' => array(
'selector' => '.crm-report-instanceForm-form-block-title',
'prepend' => ts('(Copy) '),
),
'description' => array(
'selector' => '.crm-report-instanceForm-form-block-description',
'prepend' => '',
),
'parent_id' => array(
'selector' => '.crm-report-instanceForm-form-block-parent_id',
'prepend' => '',
),
)),
),
),
'report_instance.print' => array('title' => ts('Print Report')),
'report_instance.pdf' => array('title' => ts('Print to PDF')),
'report_instance.csv' => array('title' => ts('Export as CSV')),
);
);
}
$actions['report_instance.print'] = array('title' => ts('Print Report'));
$actions['report_instance.pdf'] = array('title' => ts('Print to PDF'));
$actions['report_instance.csv'] = array('title' => ts('Export as CSV'));

if (CRM_Core_Permission::check('administer Reports')) {
$actions['report_instance.delete'] = array(
'title' => ts('Delete report'),
Expand Down
4 changes: 4 additions & 0 deletions CRM/Report/Info.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public function getPermissions($getAllUnconditionally = FALSE, $descriptions = F
ts('access Report Criteria'),
ts('Change report search criteria'),
),
'save Report Criteria' => array(
ts('save Report Criteria'),
ts('Save report search criteria'),
),
'administer private reports' => array(
ts('administer private reports'),
ts('Edit all private reports'),
Expand Down
1 change: 1 addition & 0 deletions CRM/Upgrade/Incremental/php/FiveThree.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CRM_Upgrade_Incremental_php_FiveThree extends CRM_Upgrade_Incremental_Base
* @param null $currentVer
*/
public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
$preUpgradeMessage .= '<p>' . ts('A new %1 permission has been added. It is not granted by default. If your users create reports, you may wish to review your permissions.', array(1 => 'save Report Criteria')) . '</p>';
// Example: Generate a pre-upgrade message.
// if ($rev == '5.12.34') {
// $preUpgradeMessage .= '<p>' . ts('A new permission has been added called %1 This Permission is now used to control access to the Manage Tags screen', array(1 => 'manage tags')) . '</p>';
Expand Down

0 comments on commit 714515b

Please sign in to comment.