From 66df602593230a2483d6538927fd66310c28c3f8 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Tue, 25 Nov 2008 02:37:33 +0000 Subject: #314870 by Rob Loach, drewish, catch, and sun: Add hook API documentation to Drupal core. --- modules/user/user.api.php | 126 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 modules/user/user.api.php (limited to 'modules/user/user.api.php') diff --git a/modules/user/user.api.php b/modules/user/user.api.php new file mode 100644 index 000000000..3b5855cf5 --- /dev/null +++ b/modules/user/user.api.php @@ -0,0 +1,126 @@ +content array. + * @param &$edit + * The array of form values submitted by the user. + * @param &$account + * The user object on which the operation is being performed. + * @param $category + * The active category of user information being edited. + * @return + * This varies depending on the operation. + * - "categories": A linear array of associative arrays. These arrays have + * keys: + * - "name": The internal name of the category. + * - "title": The human-readable, localized name of the category. + * - "weight": An integer specifying the category's sort ordering. + * - "delete": None. + * - "form", "register": A $form array containing the form elements to display. + * - "insert": None. + * - "load": None. + * - "login": None. + * - "logout": None. + * - "submit": None: + * - "update": None. + * - "validate": None. + * - "view": None. For an example see: user_user(). + */ +function hook_user($op, &$edit, &$account, $category = NULL) { + if ($op == 'form' && $category == 'account') { + $form['comment_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Comment settings'), + '#collapsible' => TRUE, + '#weight' => 4); + $form['comment_settings']['signature'] = array( + '#type' => 'textarea', + '#title' => t('Signature'), + '#default_value' => $edit['signature'], + '#description' => t('Your signature will be publicly displayed at the end of your comments.')); + return $form; + } +} + +/** + * Add mass user operations. + * + * This hook enables modules to inject custom operations into the mass operations + * dropdown found at admin/user/user, by associating a callback function with + * the operation, which is called when the form is submitted. The callback function + * receives one initial argument, which is an array of the checked users. + * + * @return + * An array of operations. Each operation is an associative array that may + * contain the following key-value pairs: + * - "label": Required. The label for the operation, displayed in the dropdown menu. + * - "callback": Required. The function to call for the operation. + * - "callback arguments": Optional. An array of additional arguments to pass to + * the callback function. + * + */ +function hook_user_operations() { + $operations = array( + 'unblock' => array( + 'label' => t('Unblock the selected users'), + 'callback' => 'user_user_operations_unblock', + ), + 'block' => array( + 'label' => t('Block the selected users'), + 'callback' => 'user_user_operations_block', + ), + 'delete' => array( + 'label' => t('Delete the selected users'), + ), + ); + return $operations; +} + +/** + * @} End of "addtogroup hooks". + */ -- cgit v1.2.3