user.info.inc 3.8 KB

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