X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FResources.php;h=d12afab2d06dbc48d90a69ccd4b38fcc4a7bde40;hb=491fe45a865fd4177204b44877315b2ebad9f2c3;hp=872c00a72827cd13a9cd3cecda8e43a5fe6679b3;hpb=8d7a9d07300f31c5ae3b25188e27a1d8711654cd;p=civicrm-core.git diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index 872c00a728..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. | | | @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * This class facilitates the loading of resources @@ -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$ * */ @@ -58,9 +58,9 @@ class CRM_Core_Resources { private $extMapper = NULL; /** - * @var CRM_Utils_Cache_Interface + * @var CRM_Core_Resources_Strings */ - private $cache = NULL; + private $strings = NULL; /** * @var array free-form data tree @@ -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. @@ -135,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); @@ -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