more module updates

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-20 18:07:22 +02:00
parent 134c8b8338
commit 55b23a2cec
21 changed files with 370 additions and 708 deletions

View File

@@ -29,7 +29,7 @@ function uuid_schema_field_definition() {
}
/**
* Implements of hook_schema_alter().
* Implements hook_schema_alter().
*/
function uuid_schema_alter(&$schema = array()) {
$field = uuid_schema_field_definition();
@@ -230,3 +230,45 @@ function uuid_update_7102() {
_uuid_install_uuid_fields();
uuid_sync_all();
}
/**
* Modify the labels of all example entities created by the now removed
* uuid_default_entities_example.module to make it clear they're examples.
* Also remove the administrator role of any example user.
*/
function uuid_update_7103() {
// These are UUIDs of all the example entities that might exist after having
// installed uuid_default_entities_example.module.
$info = entity_get_info();
$uuids = array(
'node' => array(
'b0558664-c94b-3674-d9df-3e1696b2e471',
'5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837',
),
'user' => array(
'7cf875e6-dc15-4404-f190-5a7c3e91d14c',
),
);
// we can't assume taxonomy is enabled
if (isset($info['taxonomy_term'])) {
$uuids['taxonomy_term'] = array(
'bcb92ce8-2236-e264-65c8-0c163ae716d1',
'4293a15c-531a-6164-7d1b-668ed019a6bd',
'af738a46-f278-cf84-d94d-9e03879fd71e',
);
}
foreach (array_keys($uuids) as $entity_type) {
$info = entity_get_info($entity_type);
$entity_ids = entity_get_id_by_uuid($entity_type, $uuids[$entity_type]);
$entities = entity_load($entity_type, $entity_ids);
foreach ($entities as $entity) {
// Update the label to make it clear this is example content.
$entity->{$info['entity keys']['label']} = $entity->{$info['entity keys']['label']} . ' (UUID example)';
// Remove the administrator role from any user.
if ($entity_type == 'user' && $rid = array_search('administrator', $entity->roles)) {
unset($entity->roles[$rid]);
}
entity_save($entity);
}
}
}