user.variable.inc 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. /**
  3. * @file
  4. * Variable API module. Definition for Drupal core variables
  5. */
  6. /**
  7. * User module variables
  8. */
  9. function user_variable_info($options) {
  10. // $variables = array('#type' => 'fieldset', 'title' => t('User registration settings'));
  11. $variables['user_register'] = array(
  12. 'type' => 'select',
  13. 'title' => t('Public registrations'),
  14. 'default' => 1,
  15. 'options' => TRUE,
  16. 'options callback' => 'user_variable_option_list',
  17. 'group' => 'user_settings',
  18. );
  19. $variables['user_email_verification'] = array(
  20. 'type' => 'boolean',
  21. 'title' => t('Require e-mail verification when a visitor creates an account', array(), $options),
  22. 'default' => TRUE,
  23. 'description' => t('If this box is checked, new users will be required to validate their e-mail address prior to logging into the site, and will be assigned a system-generated password. With it unchecked, users will be logged in immediately upon registering, and may select their own passwords during registration.', array(), $options),
  24. 'group' => 'user_settings',
  25. );
  26. $variables['user_registration_help'] = array(
  27. 'type' => 'text',
  28. 'title' => t('User registration guidelines', array(), $options),
  29. 'default' => '',
  30. 'description' => t('This text is displayed at the top of the user registration form and is useful for helping or instructing your users.', array(), $options),
  31. 'group' => 'user_settings',
  32. );
  33. // User e-mail settings.
  34. // These email tokens are shared for all settings, so just define
  35. // the list once to help ensure they stay in sync.
  36. $email_token_help = ' ' . t('Available variables are: [site:name], [site:url], [user:name], [user:mail], [site:login-url], [site:url-brief], [user:edit-url], [user:one-time-login-url], [user:cancel-url].', array(), $options);
  37. $variables['user_mail_register_admin_created_[mail_part]'] = array(
  38. 'type' => 'user_mail',
  39. 'title' => t('Welcome, new user created by administrator', array(), $options),
  40. 'description' => t('Customize welcome e-mail messages sent to new member accounts created by an administrator.', array(), $options) . $email_token_help,
  41. 'group' => 'user_mails',
  42. );
  43. $variables['user_mail_register_no_approval_required_[mail_part]'] = array(
  44. 'type' => 'user_mail',
  45. 'title' => t('Welcome, no approval required', array(), $options),
  46. 'description' => t('Customize welcome e-mail messages sent to new members upon registering, when no administrator approval is required.', array(), $options) . $email_token_help,
  47. 'group' => 'user_mails',
  48. );
  49. $variables['user_mail_register_pending_approval_[mail_part]'] = array(
  50. 'type' => 'user_mail',
  51. 'title' => t('Welcome, awaiting administrator approval', array(), $options),
  52. 'description' => t('Customize welcome e-mail messages sent to new members upon registering, when administrative approval is required.', array(), $options) . $email_token_help,
  53. 'group' => 'user_mails',
  54. );
  55. $variables['user_mail_password_reset_[mail_part]'] = array(
  56. 'type' => 'user_mail',
  57. 'title' => t('Password recovery email'),
  58. 'description' => t('Customize e-mail messages sent to users who request a new password.') . $email_token_help,
  59. 'group' => 'user_mails',
  60. );
  61. $variables['user_mail_status_activated_[mail_part]'] = array(
  62. 'type' => 'user_mail',
  63. 'title' => t('Account activation email', array(), $options),
  64. 'description' => t('Enable and customize e-mail messages sent to users upon account activation (when an administrator activates an account of a user who has already registered, on a site where administrative approval is required).', array(), $options) . $email_token_help,
  65. 'group' => 'user_mails',
  66. );
  67. $variables['user_mail_status_activated_notify'] = array(
  68. 'type' => 'boolean',
  69. 'title' => t('Notify user when account is activated.', array(), $options),
  70. 'default' => TRUE,
  71. 'group' => 'user_settings',
  72. );
  73. $variables['user_mail_status_blocked_[mail_part]'] = array(
  74. 'type' => 'user_mail',
  75. 'title' => t('Account blocked email', array(), $options),
  76. 'description' => t('Enable and customize e-mail messages sent to users when their accounts are blocked.') . $email_token_help,
  77. 'group' => 'user_mails',
  78. );
  79. $variables['user_mail_status_blocked_notify'] = array(
  80. 'type' => 'boolean',
  81. 'title' => t('Notify user when account is blocked.', array(), $options),
  82. 'default' => FALSE,
  83. 'group' => 'user_settings',
  84. );
  85. $variables['user_mail_cancel_confirm_[mail_part]'] = array(
  86. 'type' => 'user_mail',
  87. 'title' => t('Account cancellation confirmation'),
  88. 'description' => t('Edit the e-mail messages sent to users when they attempt to cancel their accounts.', array(), $options) . $email_token_help,
  89. 'group' => 'user_mails',
  90. );
  91. $variables['user_mail_status_canceled_[mail_part]'] = array(
  92. 'type' => 'user_mail',
  93. 'title' => t('Account deleted email'),
  94. 'description' => t('Enable and customize e-mail messages sent to users when their accounts are deleted.', array(), $options) . $email_token_help,
  95. 'group' => 'user_mails',
  96. );
  97. $variables['user_mail_status_deleted_notify'] = array(
  98. 'type' => 'boolean',
  99. 'title' => t('Notify user when account is deleted.', array(), $options),
  100. 'default' => FALSE,
  101. 'group' => 'user_settings',
  102. );
  103. // User signatures.
  104. $variables['user_signatures'] = array(
  105. 'type' => 'enable',
  106. 'title' => t('Signature support'),
  107. 'default' => 0,
  108. 'group' => 'user_settings',
  109. );
  110. // Picture support
  111. $picture_support = variable_get('user_pictures', 0);
  112. $form['user_pictures'] = array(
  113. 'type' => 'enable',
  114. 'title' => t('Picture support', array(), $options),
  115. 'default' => 0,
  116. 'group' => 'user_settings',
  117. );
  118. $variables['user_picture_path'] = array(
  119. 'type' => 'file_path',
  120. 'title' => t('Picture directory', array(), $options),
  121. 'default' => 'pictures',
  122. 'element' => array('#size' => 30, '#maxlength' => 255),
  123. 'description' => t('Subdirectory in the file upload directory where pictures will be stored.', array(), $options),
  124. 'group' => 'user_settings',
  125. );
  126. $variables['user_picture_default'] = array(
  127. 'type' => 'url',
  128. 'title' => t('Default picture', array(), $options),
  129. 'default' => '',
  130. 'description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.', array(), $options),
  131. 'group' => 'user_settings',
  132. );
  133. $variables['user_picture_dimensions'] = array(
  134. 'type' => 'string',
  135. 'title' => t('Picture maximum dimensions', array(), $options),
  136. 'default' => '85x85',
  137. 'description' => t('Maximum dimensions for pictures, in pixels.', array(), $options),
  138. 'element' => array('#size' => 15, '#maxlength' => 10),
  139. 'group' => 'user_settings',
  140. );
  141. $variables['user_picture_file_size'] = array(
  142. 'type' => 'number',
  143. 'title' => t('Picture maximum file size', array(), $options),
  144. 'default' => 30,
  145. 'description' => t('Maximum file size for pictures, in kB.', array(), $options),
  146. 'group' => 'user_settings',
  147. );
  148. $variables['user_picture_guidelines'] = array(
  149. 'type' => 'text',
  150. 'title' => t('Picture guidelines', array(), $options),
  151. 'default' => '',
  152. 'description' => t("This text is displayed at the picture upload form in addition to the default guidelines. It's useful for helping or instructing your users.", array(), $options),
  153. 'group' => 'user_settings',
  154. );
  155. return $variables;
  156. }
  157. /**
  158. * Node module variable groups
  159. */
  160. function user_variable_group_info() {
  161. $groups['user_settings'] = array(
  162. 'title' => t('User settings'),
  163. 'description' => t('User settings'),
  164. 'access' => 'administer users',
  165. 'path' => 'admin/user/settings',
  166. );
  167. $groups['user_mails'] = array(
  168. 'title' => t('User emails'),
  169. 'description' => t('User emails'),
  170. 'access' => 'administer users',
  171. 'path' => 'admin/user/settings',
  172. );
  173. return $groups;
  174. }
  175. /**
  176. * Implements hook_variable_type_info().
  177. */
  178. function user_variable_type_info() {
  179. $types['user_mail'] = array(
  180. 'title' => t('User mail text'),
  181. 'type' => 'mail_text',
  182. 'repeat' => array(
  183. 'default callback' => 'user_variable_mail_default',
  184. ),
  185. );
  186. return $types;
  187. }
  188. /**
  189. * Default callback for user mail variables
  190. */
  191. function user_variable_mail_default($variable, $options) {
  192. // Remove 'user_mail_' prefix
  193. $name = substr($variable['name'], 10);
  194. return _user_mail_text($name, $options['language']);
  195. }
  196. /**
  197. * Implements hook_variable_option_list().
  198. */
  199. function user_variable_option_list($variable, $options = array()) {
  200. switch ($variable['name']) {
  201. case 'user_register':
  202. return array(
  203. t('Only site administrators can create new user accounts.', array(), $options),
  204. t('Visitors can create accounts and no administrator approval is required.', array(), $options),
  205. t('Visitors can create accounts but administrator approval is required.', array(), $options)
  206. );
  207. }
  208. }