From 33777e4af01007616c8f9188d07479762a001e4a Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Tue, 7 May 2013 12:06:07 +0530 Subject: [PATCH] CRM-12503 --- CRM/Campaign/Info.php | 2 +- CRM/Case/Info.php | 2 +- CRM/Contribute/Info.php | 2 +- CRM/Core/Component/Info.php | 4 +++- CRM/Core/Permission.php | 3 ++- CRM/Event/Info.php | 2 +- CRM/Grant/Info.php | 2 +- CRM/Mailing/Info.php | 4 ++-- CRM/Member/Info.php | 2 +- CRM/Pledge/Info.php | 2 +- CRM/Report/Info.php | 2 +- 11 files changed, 15 insertions(+), 12 deletions(-) diff --git a/CRM/Campaign/Info.php b/CRM/Campaign/Info.php index b862f32a01..adc019fb11 100644 --- a/CRM/Campaign/Info.php +++ b/CRM/Campaign/Info.php @@ -53,7 +53,7 @@ class CRM_Campaign_Info extends CRM_Core_Component_Info { // docs inherited from interface - public function getPermissions() { + public function getPermissions($getAllUnconditionally = FALSE) { return array( 'administer CiviCampaign', 'manage campaign', diff --git a/CRM/Case/Info.php b/CRM/Case/Info.php index 3e73073268..40c8b15cb6 100644 --- a/CRM/Case/Info.php +++ b/CRM/Case/Info.php @@ -53,7 +53,7 @@ class CRM_Case_Info extends CRM_Core_Component_Info { } // docs inherited from interface - public function getPermissions() { + public function getPermissions($getAllUnconditionally = FALSE) { return array( 'delete in CiviCase', 'administer CiviCase', diff --git a/CRM/Contribute/Info.php b/CRM/Contribute/Info.php index 5edfad758c..f1e46478c3 100644 --- a/CRM/Contribute/Info.php +++ b/CRM/Contribute/Info.php @@ -53,7 +53,7 @@ class CRM_Contribute_Info extends CRM_Core_Component_Info { } // docs inherited from interface - public function getPermissions() { + public function getPermissions($getAllUnconditionally = FALSE) { return array( 'access CiviContribute', 'edit contributions', diff --git a/CRM/Core/Component/Info.php b/CRM/Core/Component/Info.php index 8d276b84df..c53dae9a7a 100644 --- a/CRM/Core/Component/Info.php +++ b/CRM/Core/Component/Info.php @@ -131,11 +131,13 @@ abstract class CRM_Core_Component_Info { * Needs to be implemented in component's information * class. * + * NOTE: if using conditionally permission return, + * implementation of $getAllUnconditionally is required. * @return array|null collection of permissions, null if none * @access public * */ - abstract public function getPermissions(); + abstract public function getPermissions($getAllUnconditionally = FALSE); /** * Provides information about user dashboard element diff --git a/CRM/Core/Permission.php b/CRM/Core/Permission.php index cce8ca7200..e27da5830f 100644 --- a/CRM/Core/Permission.php +++ b/CRM/Core/Permission.php @@ -540,7 +540,8 @@ class CRM_Core_Permission { if (empty($allCompPermissions)) { $components = CRM_Core_Component::getComponents(); foreach ($components as $name => $comp) { - $allCompPermissions[$name] = $comp->getPermissions(); + //get all permissions of each components unconditionally + $allCompPermissions[$name] = $comp->getPermissions(TRUE); } } diff --git a/CRM/Event/Info.php b/CRM/Event/Info.php index e3b595c9e3..f89ecf8cb4 100644 --- a/CRM/Event/Info.php +++ b/CRM/Event/Info.php @@ -52,7 +52,7 @@ class CRM_Event_Info extends CRM_Core_Component_Info { } // docs inherited from interface - public function getPermissions() { + public function getPermissions($getAllUnconditionally = FALSE) { return array( 'access CiviEvent', 'edit event participants', diff --git a/CRM/Grant/Info.php b/CRM/Grant/Info.php index a1822e6a79..a6903399c5 100644 --- a/CRM/Grant/Info.php +++ b/CRM/Grant/Info.php @@ -54,7 +54,7 @@ class CRM_Grant_Info extends CRM_Core_Component_Info { // docs inherited from interface - public function getPermissions() { + public function getPermissions($getAllUnconditionally = FALSE) { return array( 'access CiviGrant', 'edit grants', diff --git a/CRM/Mailing/Info.php b/CRM/Mailing/Info.php index db210f6682..a4aaf5eda3 100644 --- a/CRM/Mailing/Info.php +++ b/CRM/Mailing/Info.php @@ -78,7 +78,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { } // docs inherited from interface - public function getPermissions() { + public function getPermissions($getAllUnconditionally = FALSE) { $permissions = array( 'access CiviMail', 'access CiviMail subscribe/unsubscribe pages', @@ -86,7 +86,7 @@ class CRM_Mailing_Info extends CRM_Core_Component_Info { 'view public CiviMail content', ); - if (self::workflowEnabled()) { + if (self::workflowEnabled() || $getAllUnconditionally) { $permissions[] = 'create mailings'; $permissions[] = 'schedule mailings'; $permissions[] = 'approve mailings'; diff --git a/CRM/Member/Info.php b/CRM/Member/Info.php index fe621fa432..9636402638 100644 --- a/CRM/Member/Info.php +++ b/CRM/Member/Info.php @@ -53,7 +53,7 @@ class CRM_Member_Info extends CRM_Core_Component_Info { // docs inherited from interface - public function getPermissions() { + public function getPermissions($getAllUnconditionally = FALSE) { return array( 'access CiviMember', 'edit memberships', diff --git a/CRM/Pledge/Info.php b/CRM/Pledge/Info.php index f54a3b4e7c..2906464d87 100644 --- a/CRM/Pledge/Info.php +++ b/CRM/Pledge/Info.php @@ -53,7 +53,7 @@ class CRM_Pledge_Info extends CRM_Core_Component_Info { // docs inherited from interface - public function getPermissions() { + public function getPermissions($getAllUnconditionally = FALSE) { return array( 'access CiviPledge', 'edit pledges', diff --git a/CRM/Report/Info.php b/CRM/Report/Info.php index aa6dc4cc91..94542eb201 100644 --- a/CRM/Report/Info.php +++ b/CRM/Report/Info.php @@ -55,7 +55,7 @@ class CRM_Report_Info extends CRM_Core_Component_Info { // docs inherited from interface - public function getPermissions() { + public function getPermissions($getAllUnconditionally = FALSE) { return array('access CiviReport', 'access Report Criteria', 'administer reserved reports', 'administer Reports'); } -- 2.25.1