From: Tim Otten Date: Thu, 19 Feb 2015 05:37:20 +0000 (-0800) Subject: CRM_Core_Resources - Add API to export permission info X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=90efc4173df478220f61445c8d787466ad511c3d;p=civicrm-core.git CRM_Core_Resources - Add API to export permission info --- diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index fae2d0b2c3..b46698fac7 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -148,6 +148,29 @@ class CRM_Core_Resources { ); } + /** + * Export permission data to the client to enable smarter GUIs. + * + * Note: Application security stems from the server's enforcement + * of the security logic (e.g. in the API permissions). There's no way + * the client can use this info to make the app more secure; however, + * it can produce a better-tuned (non-broken) UI. + * + * @param array $permNames + * List of permission names to check/export. + * @return CRM_Core_Resources + */ + public function addPermissions($permNames) { + $permNames = (array) $permNames; + $perms = array(); + foreach ($permNames as $permName) { + $perms[$permName] = CRM_Core_Permission::check($permName); + } + return $this->addSetting(array( + 'permissions' => $perms, + )); + } + /** * Add a JavaScript file to the current page using