1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* @file
|
5
|
* Administration functions for the uuid module.
|
6
|
*/
|
7
|
|
8
|
/**
|
9
|
* Menu callback: options for UUID.
|
10
|
*/
|
11
|
function uuid_admin_form() {
|
12
|
$form = array();
|
13
|
|
14
|
$form['sync'] = array(
|
15
|
'#type' => 'fieldset',
|
16
|
'#title' => t('Synchronization'),
|
17
|
);
|
18
|
|
19
|
$form['sync']['submit'] = array(
|
20
|
'#type' => 'submit',
|
21
|
'#value' => t('Create missing UUIDs'),
|
22
|
'#submit' => array('uuid_admin_sync_submit'),
|
23
|
);
|
24
|
|
25
|
return system_settings_form($form);
|
26
|
}
|
27
|
|
28
|
/**
|
29
|
* Submit handler for the UUID sync.
|
30
|
*/
|
31
|
function uuid_admin_sync_submit() {
|
32
|
uuid_sync_all();
|
33
|
drupal_set_message(t('Generated missing UUIDs.'));
|
34
|
}
|
35
|
|
36
|
/**
|
37
|
* Page callback to display Devel information about a UUID entity.
|
38
|
*/
|
39
|
function uuid_devel_load_by_uuid($entity_type, $entity) {
|
40
|
$info = entity_get_info($entity_type);
|
41
|
if (isset($info['uuid']) && $info['uuid'] == TRUE && !empty($info['entity keys']['uuid'])) {
|
42
|
// Get the keys for local ID and UUID.
|
43
|
$uuid_key = $info['entity keys']['uuid'];
|
44
|
$uuid_entities = entity_uuid_load($entity_type, array($entity->{$uuid_key}));
|
45
|
return kdevel_print_object(reset($uuid_entities), '$' . $entity_type . '->');
|
46
|
}
|
47
|
else {
|
48
|
return t("This entity doesn't support UUID.");
|
49
|
}
|
50
|
}
|