X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FResources.php;h=89bcdd9632f0b207b649047a0ea2a833ee0c1bd7;hb=3426f10d5d829b79d6902521881bfc15b9f990b0;hp=f160634176e937e937b04448cdce72503a988212;hpb=414b3228db09432f1e389a89f9fb9e3f22d0f2da;p=civicrm-core.git diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index f160634176..89bcdd9632 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -99,7 +99,7 @@ class CRM_Core_Resources { public $ajaxPopupsEnabled; /** - * Get or set the single instance of CRM_Core_Resources + * Get or set the single instance of CRM_Core_Resources. * * @param CRM_Core_Resources $instance * New copy of the manager. @@ -125,7 +125,7 @@ class CRM_Core_Resources { } /** - * Construct a resource manager + * Construct a resource manager. * * @param CRM_Extension_Mapper $extMapper * Map extension names to their base path or URLs. @@ -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