X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FResources.php;h=89bcdd9632f0b207b649047a0ea2a833ee0c1bd7;hb=3426f10d5d829b79d6902521881bfc15b9f990b0;hp=7707c12652f2006ee6b58caa86cd2440829b89e9;hpb=fd7dc3f34a9605552866688ff9d3f8f75de70c3c;p=civicrm-core.git diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 7707c12652..89bcdd9632 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -1,29 +1,29 @@ 'js-strings', - 'prefetch' => FALSE, - )); + 'group' => 'js-strings', + 'prefetch' => FALSE, + )); self::$_singleton = new CRM_Core_Resources( $sys->getMapper(), $cache, @@ -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