X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FResources.php;h=d12afab2d06dbc48d90a69ccd4b38fcc4a7bde40;hb=491fe45a865fd4177204b44877315b2ebad9f2c3;hp=97f03f5d84f55f4e6177ca435a73bf84890a964f;hpb=2b67e46a47da4c0bcf1a49e696cef81eadd3555c;p=civicrm-core.git diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 97f03f5d84..d12afab2d0 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, @@ -126,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. @@ -136,7 +135,7 @@ class CRM_Core_Resources { */ public function __construct($extMapper, $cache, $cacheCodeKey = NULL) { $this->extMapper = $extMapper; - $this->cache = $cache; + $this->strings = new CRM_Core_Resources_Strings($cache); $this->cacheCodeKey = $cacheCodeKey; if ($cacheCodeKey !== NULL) { $this->cacheCode = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, $cacheCodeKey); @@ -149,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