Projet

Général

Profil

Révision e7101f36

Ajouté par Julien Enselme il y a environ 9 ans

Update uuid 1.0-alpha5 1.0-alpha6

Voir les différences:

drupal7/sites/all/modules/uuid/uuid.install
29 29
}
30 30

  
31 31
/**
32
 * Implements of hook_schema_alter().
32
 * Implements hook_schema_alter().
33 33
 */
34 34
function uuid_schema_alter(&$schema = array()) {
35 35
  $field = uuid_schema_field_definition();
......
230 230
  _uuid_install_uuid_fields();
231 231
  uuid_sync_all();
232 232
}
233

  
234
/**
235
 * Modify the labels of all example entities created by the now removed
236
 * uuid_default_entities_example.module to make it clear they're examples.
237
 * Also remove the administrator role of any example user.
238
 */
239
function uuid_update_7103() {
240
  // These are UUIDs of all the example entities that might exist after having
241
  // installed uuid_default_entities_example.module.
242
  $info = entity_get_info();
243
  $uuids = array(
244
    'node' => array(
245
      'b0558664-c94b-3674-d9df-3e1696b2e471',
246
      '5e3d8bbe-a1f2-f2d4-fdc0-71e6c23aa837',
247
    ),
248
    'user' => array(
249
      '7cf875e6-dc15-4404-f190-5a7c3e91d14c',
250
    ),
251
  );
252
  // we can't assume taxonomy is enabled
253
  if (isset($info['taxonomy_term'])) {
254
    $uuids['taxonomy_term'] = array(
255
      'bcb92ce8-2236-e264-65c8-0c163ae716d1',
256
      '4293a15c-531a-6164-7d1b-668ed019a6bd',
257
      'af738a46-f278-cf84-d94d-9e03879fd71e',
258
    );
259
  }
260
  foreach (array_keys($uuids) as $entity_type) {
261
    $info = entity_get_info($entity_type);
262
    $entity_ids = entity_get_id_by_uuid($entity_type, $uuids[$entity_type]);
263
    $entities = entity_load($entity_type, $entity_ids);
264
    foreach ($entities as $entity) {
265
      // Update the label to make it clear this is example content.
266
      $entity->{$info['entity keys']['label']} = $entity->{$info['entity keys']['label']} . ' (UUID example)';
267
      // Remove the administrator role from any user.
268
      if ($entity_type == 'user' && $rid = array_search('administrator', $entity->roles)) {
269
        unset($entity->roles[$rid]);
270
      }
271
      entity_save($entity);
272
    }
273
  }
274
}

Formats disponibles : Unified diff