$module_files = CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles();
if ($this->userPermissionClass->isModulePermissionSupported()) {
// Can store permissions -- so do it!
- foreach ($module_files as $module_file) {
- // Consider corner case: Cleaning up old module permissions that have been removed
- // by unversioned source-code changes.
- $this->userPermissionClass->upgradePermissions(
- $module_file['prefix'],
- $this->userPermissionClass->getModulePermissions($module_file['prefix'])
- );
- }
+ $this->userPermissionClass->upgradePermissions(
+ CRM_Core_Permission::basicPermissions()
+ );
} else {
// Cannot store permissions -- warn if any modules require them
$modules_with_perms = array();
}
/**
- * Ensure that all cached permissions associated with the given module are
- * actually defined by that module. This is useful during module upgrade
- * when the newer module version has removed permission that were defined
- * in the older version.
+ * Ensure that the CMS supports all the permissions defined by CiviCRM
+ * and its extensions. If there are stale permissions, they should be
+ * deleted. This is useful during module upgrade when the newer module
+ * version has removed permission that were defined in the older version.
*
- * @param string $module short-name
- * @param array $modulePermissions same format as CRM_Core_Permission::getCorePermissions().
+ * @param array $permissions same format as CRM_Core_Permission::getCorePermissions().
* @see CRM_Core_Permission::getCorePermissions
*/
- function upgradePermissions($module, $modulePermissions) {
+ function upgradePermissions($permissions) {
throw new CRM_Core_Exception("Unimplemented method: CRM_Core_Permission_*::upgradePermissions");
}
/**
* {@inheritdoc}
*/
- function upgradePermissions($module, $module_permissions) {
- // Construct a delete query to remove permissions for this module.
- $query = db_delete('role_permission')
- ->condition('permission', "$module|%", 'LIKE')
- ->condition('module', 'civicrm');
- // Only if the module defines any permissions, exempt those from the delete
- // process. This approach allows us to delete all permissions for the module
- // even if the hook_civicrm_permisssion() implementation has been removed.
- if (!empty($module_permissions)) {
- $query->condition('permission', array_keys($module_permissions), 'NOT IN');
+ function upgradePermissions($permissions) {
+ if (empty($permissions)) {
+ throw new CRM_Core_Exception("Cannot upgrade permissions: permission list missing");
}
+ $query = db_delete('role_permission')
+ ->condition('module', 'civicrm')
+ ->condition('permission', array_keys($permissions), 'NOT IN');
$query->execute();
}
}
*
* Does nothing in Drupal 6.
*/
- function upgradePermissions($module, $modulePermissions) {
+ function upgradePermissions($permissions) {
}
/**