function pmpermission_migrate_legacy_permissions in Drupal PM (Project Management) 7.2
Handles migration of legacy permissions for a given sub-module.
1 call to pmpermission_migrate_legacy_permissions()
- pmpermission_migrate_execute in pmpermission/
includes/ pmpermission.migrate.inc - Helper function to migrate permission defined by submodules.
File
- pmpermission/
includes/ pmpermission.migrate.inc, line 202 - Migration functions for the PM Permission module.
Code
function pmpermission_migrate_legacy_permissions($module_name) {
// Enable Permission to be defined by pmpermission.
// Handover legacy permission to pmpermission based implementations.
$map = pmpermission_migrate_get_legacy_permission_map();
$permissions = $map[$module_name];
foreach ($permissions as $old => $new) {
switch ($new) {
case PMPERMISSION_OBSOLETE:
drupal_set_message(t('Permission "@name" is obsolete and won\'t be migrated.', array(
'@name' => $old,
)), 'warning');
break;
case PMPERMISSION_CANNOT_BE_PORTED:
drupal_set_message(t('Permission "@name" cannot be ported.', array(
'@name' => $old,
)), 'error');
break;
case PMPERMISSION_UNCHANGED:
break;
default:
$rids = _pmpermission_migrate_get_all_roles_having_permission($old);
$permission = array(
// Revoke old permission (deletes the record) by setting to 0.
$old => 0,
$new => TRUE,
);
foreach ($rids as $rid => $role_name) {
user_role_change_permissions($rid, $permission);
}
// All permission adjustment used by pmpermission module requires node
// access to be rebuilt.
node_access_needs_rebuild(TRUE);
break;
}
}
}