X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FResources.php;h=d12afab2d06dbc48d90a69ccd4b38fcc4a7bde40;hb=491fe45a865fd4177204b44877315b2ebad9f2c3;hp=fae2d0b2c37ac734c7c748678bb63a0786e5f0bb;hpb=49e6b05c38cd1a91b66a531cb201d081b25b8061;p=civicrm-core.git diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index fae2d0b2c3..d12afab2d0 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -3,7 +3,7 @@ +--------------------------------------------------------------------+ | CiviCRM version 4.6 | +--------------------------------------------------------------------+ - | Copyright CiviCRM LLC (c) 2004-2014 | + | Copyright CiviCRM LLC (c) 2004-2015 | +--------------------------------------------------------------------+ | This file is a part of CiviCRM. | | | @@ -37,7 +37,7 @@ * should incorporte services for aggregation, minimization, etc. * * @package CRM - * @copyright CiviCRM LLC (c) 2004-2014 + * @copyright CiviCRM LLC (c) 2004-2015 * $Id$ * */ @@ -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