Project

General

Profile

Paste
Download (3.84 KB) Statistics
| Branch: | Revision:

root / drupal7 / sites / all / modules / entity / modules / user.info.inc @ 7d7b5830

1
<?php
2

    
3
/**
4
 * @file
5
 * Provides info about the user entity.
6
 */
7

    
8
/**
9
 * Implements hook_entity_property_info() on top of user module.
10
 *
11
 * @see entity_entity_property_info()
12
 */
13
function entity_metadata_user_entity_property_info() {
14
  $info = array();
15
  // Add meta-data about the user properties.
16
  $properties = &$info['user']['properties'];
17

    
18
  $properties['uid'] = array(
19
    'label' => t("User ID"),
20
    'type' => 'integer',
21
    'description' => t("The unique ID of the user account."),
22
    'schema field' => 'uid',
23
  );
24
  $properties['name'] = array(
25
    'label' => t("Name"),
26
    'description' => t("The login name of the user account."),
27
    'getter callback' => 'entity_metadata_user_get_properties',
28
    'setter callback' => 'entity_property_verbatim_set',
29
    'sanitize' => 'filter_xss',
30
    'required' => TRUE,
31
    'access callback' => 'entity_metadata_user_properties_access',
32
    'schema field' => 'name',
33
  );
34
  $properties['mail'] = array(
35
    'label' => t("Email"),
36
    'description' => t("The email address of the user account."),
37
    'setter callback' => 'entity_property_verbatim_set',
38
    'validation callback' => 'valid_email_address',
39
    'required' => TRUE,
40
    'access callback' => 'entity_metadata_user_properties_access',
41
    'schema field' => 'mail',
42
  );
43
  $properties['url'] = array(
44
    'label' => t("URL"),
45
    'description' => t("The URL of the account profile page."),
46
    'getter callback' => 'entity_metadata_user_get_properties',
47
    'type' => 'uri',
48
    'computed' => TRUE,
49
  );
50
  $properties['edit_url'] = array(
51
    'label' => t("Edit URL"),
52
    'description' => t("The url of the account edit page."),
53
    'getter callback' => 'entity_metadata_user_get_properties',
54
    'type' => 'uri',
55
    'computed' => TRUE,
56
  );
57
  $properties['last_access'] = array(
58
    'label' => t("Last access"),
59
    'description' => t("The date the user last accessed the site."),
60
    'getter callback' => 'entity_metadata_user_get_properties',
61
    'type' => 'date',
62
    'access callback' => 'entity_metadata_user_properties_access',
63
    'schema field' => 'access',
64
  );
65
  $properties['last_login'] = array(
66
    'label' => t("Last login"),
67
    'description' => t("The date the user last logged in to the site."),
68
    'getter callback' => 'entity_metadata_user_get_properties',
69
    'type' => 'date',
70
    'access callback' => 'entity_metadata_user_properties_access',
71
    'schema field' => 'login',
72
  );
73
  $properties['created'] = array(
74
    'label' => t("Created"),
75
    'description' => t("The date the user account was created."),
76
    'type' => 'date',
77
    'schema field' => 'created',
78
    'setter permission' => 'administer users',
79
  );
80
  $properties['roles'] = array(
81
    'label' => t("User roles"),
82
    'description' => t("The roles of the user."),
83
    'type' => 'list<integer>',
84
    'getter callback' => 'entity_metadata_user_get_properties',
85
    'setter callback' => 'entity_metadata_user_set_properties',
86
    'options list' => 'entity_metadata_user_roles',
87
    'access callback' => 'entity_metadata_user_properties_access',
88
  );
89
  $properties['status'] = array(
90
    'label' => t("Status"),
91
    'description' => t("Whether the user is active or blocked."),
92
    'setter callback' => 'entity_property_verbatim_set',
93
    // Although the status is expected to be boolean, its schema suggests
94
    // it is an integer, so we follow the schema definition.
95
    'type' => 'integer',
96
    'options list' => 'entity_metadata_user_status_options_list',
97
    'access callback' => 'entity_metadata_user_properties_access',
98
    'schema field' => 'status',
99
  );
100
  $properties['theme'] = array(
101
    'label' => t("Default theme"),
102
    'description' => t("The user's default theme."),
103
    'getter callback' => 'entity_metadata_user_get_properties',
104
    'setter callback' => 'entity_property_verbatim_set',
105
    'access callback' => 'entity_metadata_user_properties_access',
106
    'schema field' => 'theme',
107
  );
108
  return $info;
109
}
110