Index: includes/module.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/module.inc,v retrieving revision 1.124 diff -u -r1.124 module.inc --- includes/module.inc 21 Aug 2008 19:36:36 -0000 1.124 +++ includes/module.inc 18 Sep 2008 13:01:27 -0000 @@ -441,6 +441,9 @@ $module = $args[0]; $hook = $args[1]; unset($args[0], $args[1]); + if ($hook == 'user') { + $hook .= '_' . array_shift($args); + } if (module_hook($module, $hook)) { return call_user_func_array($module . '_' . $hook, $args); } @@ -460,6 +463,9 @@ $args = func_get_args(); $hook = $args[0]; unset($args[0]); + if ($hook == 'user') { + $hook .= '_' . array_shift($args); + } $return = array(); foreach (module_implements($hook) as $module) { $function = $module . '_' . $hook; Index: modules/block/block.module =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.module,v retrieving revision 1.309 diff -u -r1.309 block.module --- modules/block/block.module 21 Aug 2008 19:36:36 -0000 1.309 +++ modules/block/block.module 18 Sep 2008 13:01:28 -0000 @@ -337,39 +337,30 @@ return TRUE; } -/** - * Implementation of hook_user(). - * - * Allow users to decide which custom blocks to display when they visit - * the site. - */ -function block_user($type, $edit, &$account, $category = NULL) { - switch ($type) { - case 'form': - if ($category == 'account') { - $rids = array_keys($account->roles); - $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids); - $form['block'] = array('#type' => 'fieldset', '#title' => t('Block configuration'), '#weight' => 3, '#collapsible' => TRUE, '#tree' => TRUE); - while ($block = db_fetch_object($result)) { - $data = module_invoke($block->module, 'block', 'list'); - if ($data[$block->delta]['info']) { - $return = TRUE; - $form['block'][$block->module][$block->delta] = array('#type' => 'checkbox', '#title' => check_plain($data[$block->delta]['info']), '#default_value' => isset($account->block[$block->module][$block->delta]) ? $account->block[$block->module][$block->delta] : ($block->custom == 1)); - } - } - - if (!empty($return)) { - return $form; - } +function block_user_form(&$edit, &$account, $category = NULL) { + if ($category == 'account') { + $rids = array_keys($account->roles); + $result = db_query("SELECT DISTINCT b.* FROM {blocks} b LEFT JOIN {blocks_roles} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom != 0 AND (r.rid IN (" . db_placeholders($rids) . ") OR r.rid IS NULL) ORDER BY b.weight, b.module", $rids); + $form['block'] = array('#type' => 'fieldset', '#title' => t('Block configuration'), '#weight' => 3, '#collapsible' => TRUE, '#tree' => TRUE); + while ($block = db_fetch_object($result)) { + $data = module_invoke($block->module, 'block', 'list'); + if ($data[$block->delta]['info']) { + $return = TRUE; + $form['block'][$block->module][$block->delta] = array('#type' => 'checkbox', '#title' => check_plain($data[$block->delta]['info']), '#default_value' => isset($account->block[$block->module][$block->delta]) ? $account->block[$block->module][$block->delta] : ($block->custom == 1)); } + } - break; - case 'validate': - if (empty($edit['block'])) { - $edit['block'] = array(); - } - return $edit; + if (!empty($return)) { + return $form; + } + } +} + +function block_user_validate(&$edit, &$account, $category = NULL) { + if (empty($edit['block'])) { + $edit['block'] = array(); } + return $edit; } /** Index: modules/blog/blog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v retrieving revision 1.309 diff -u -r1.309 blog.module --- modules/blog/blog.module 22 Jul 2008 20:00:55 -0000 1.309 +++ modules/blog/blog.module 18 Sep 2008 13:01:28 -0000 @@ -41,11 +41,8 @@ } } -/** - * Implementation of hook_user(). - */ -function blog_user($type, &$edit, &$user) { - if ($type == 'view' && user_access('create blog content', $user)) { +function blog_user_view(&$edit, &$user, $category) { + if (user_access('create blog content', $user)) { $user->content['summary']['blog'] = array( '#type' => 'user_profile_item', '#title' => t('Blog'), Index: modules/comment/comment.module =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.module,v retrieving revision 1.650 diff -u -r1.650 comment.module --- modules/comment/comment.module 17 Sep 2008 20:37:31 -0000 1.650 +++ modules/comment/comment.module 18 Sep 2008 13:01:29 -0000 @@ -601,15 +601,19 @@ } } +function comment_user_delete(&$edit, &$user, $category = NULL) { + db_query('UPDATE {comments} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE {node_comment_statistics} SET last_comment_uid = 0 WHERE last_comment_uid = %d', $user->uid); +} + /** * Implementation of hook_user(). - */ -function comment_user($type, $edit, &$user, $category = NULL) { +function comment_user($type, &$edit, &$user, $category = NULL) { if ($type == 'delete') { - db_query('UPDATE {comments} SET uid = 0 WHERE uid = %d', $user->uid); - db_query('UPDATE {node_comment_statistics} SET last_comment_uid = 0 WHERE last_comment_uid = %d', $user->uid); + comment_user_delete($edit, $user, $category); } } + */ /** * This is *not* a hook_access() implementation. This function is called Index: modules/contact/contact.module =================================================================== RCS file: /cvs/drupal/drupal/modules/contact/contact.module,v retrieving revision 1.109 diff -u -r1.109 contact.module --- modules/contact/contact.module 17 Sep 2008 20:37:32 -0000 1.109 +++ modules/contact/contact.module 18 Sep 2008 13:01:29 -0000 @@ -129,13 +129,8 @@ return empty($contact) ? FALSE : $contact; } -/** - * Implementation of hook_user(). - * - * Allows the user the option of enabling/disabling his personal contact form. - */ -function contact_user($type, &$edit, &$user, $category = NULL) { - if ($type == 'form' && $category == 'account') { +function contact_user_form(&$edit, &$user, $category = NULL) { + if ($category == 'account') { $form['contact'] = array('#type' => 'fieldset', '#title' => t('Contact settings'), '#weight' => 5, @@ -148,12 +143,14 @@ ); return $form; } - elseif ($type == 'validate') { - return array('contact' => isset($edit['contact']) ? $edit['contact'] : FALSE); - } - elseif ($type == 'insert') { - $edit['contact'] = variable_get('contact_default_status', 1); - } +} + +function contact_user_insert(&$edit, &$user, $category = NULL) { + $edit['contact'] = variable_get('contact_default_status', 1); +} + +function contact_user_validate(&$edit, &$user, $category = NULL) { + return array('contact' => isset($edit['contact']) ? $edit['contact'] : FALSE); } /** Index: modules/dblog/dblog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/dblog/dblog.module,v retrieving revision 1.27 diff -u -r1.27 dblog.module --- modules/dblog/dblog.module 21 Aug 2008 19:36:37 -0000 1.27 +++ modules/dblog/dblog.module 18 Sep 2008 13:01:29 -0000 @@ -100,13 +100,8 @@ db_query('DELETE FROM {watchdog} WHERE wid <= %d', $max - variable_get('dblog_row_limit', 1000)); } -/** - * Implementation of hook_user(). - */ -function dblog_user($op, &$edit, &$user) { - if ($op == 'delete') { - db_query('UPDATE {watchdog} SET uid = 0 WHERE uid = %d', $user->uid); - } +function dblog_user_delete(&$edit, &$user) { + db_query('UPDATE {watchdog} SET uid = 0 WHERE uid = %d', $user->uid); } function _dblog_get_message_types() { Index: modules/locale/locale.module =================================================================== RCS file: /cvs/drupal/drupal/modules/locale/locale.module,v retrieving revision 1.222 diff -u -r1.222 locale.module --- modules/locale/locale.module 8 Sep 2008 15:36:30 -0000 1.222 +++ modules/locale/locale.module 18 Sep 2008 13:01:29 -0000 @@ -211,43 +211,51 @@ } } -/** - * Implementation of hook_user(). - */ -function locale_user($type, $edit, &$user, $category = NULL) { - global $language; +function locale_user_register(&$edit, &$user, $category = NULL) { + // If we have more then one language and either creating a user on the + // admin interface or edit the user, show the language selector. + if (variable_get('language_count', 1) > 1 && user_access('administer users')) { + return locale_language_selector_form($user); + } +} +function locale_user_form(&$edit, &$user, $category = NULL) { // If we have more then one language and either creating a user on the // admin interface or edit the user, show the language selector. - if (variable_get('language_count', 1) > 1 && ($type == 'register' && user_access('administer users') || $type == 'form' && $category == 'account' )) { - $languages = language_list('enabled'); - $languages = $languages[1]; + if (variable_get('language_count', 1) > 1 && $category == 'account') { + return locale_language_selector_form($user); + } +} - // If the user is being created, we set the user language to the page language. - $user_preferred_language = $user ? user_preferred_language($user) : $language; +function locale_language_selector_form($user) { + global $language; + $languages = language_list('enabled'); + $languages = $languages[1]; - $names = array(); - foreach ($languages as $langcode => $item) { - $name = t($item->name); - $names[$langcode] = $name . ($item->native != $name ? ' (' . $item->native . ')' : ''); - } - $form['locale'] = array( - '#type' => 'fieldset', - '#title' => t('Language settings'), - '#weight' => 1, - ); - - // Get language negotiation settings. - $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE); - $form['locale']['language'] = array( - '#type' => (count($names) <= 5 ? 'radios' : 'select'), - '#title' => t('Language'), - '#default_value' => $user_preferred_language->language, - '#options' => $names, - '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? t("This account's default language for e-mails, and preferred language for site presentation.") : t("This account's default language for e-mails."), - ); - return $form; - } + // If the user is being created, we set the user language to the page language. + $user_preferred_language = $user ? user_preferred_language($user) : $language; + + $names = array(); + foreach ($languages as $langcode => $item) { + $name = t($item->name); + $names[$langcode] = $name . ($item->native != $name ? ' (' . $item->native . ')' : ''); + } + $form['locale'] = array( + '#type' => 'fieldset', + '#title' => t('Language settings'), + '#weight' => 1, + ); + + // Get language negotiation settings. + $mode = variable_get('language_negotiation', LANGUAGE_NEGOTIATION_NONE); + $form['locale']['language'] = array( + '#type' => (count($names) <= 5 ? 'radios' : 'select'), + '#title' => t('Language'), + '#default_value' => $user_preferred_language->language, + '#options' => $names, + '#description' => ($mode == LANGUAGE_NEGOTIATION_PATH) ? t("This account's default language for e-mails, and preferred language for site presentation.") : t("This account's default language for e-mails."), + ); + return $form; } /** Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.977 diff -u -r1.977 node.module --- modules/node/node.module 17 Sep 2008 20:37:32 -0000 1.977 +++ modules/node/node.module 18 Sep 2008 13:01:30 -0000 @@ -1378,14 +1378,9 @@ return $ranking; } -/** - * Implementation of hook_user(). - */ -function node_user($op, &$edit, &$user) { - if ($op == 'delete') { - db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid); - db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid); - } +function node_user_delete(&$edit, &$user) { + db_query('UPDATE {node} SET uid = 0 WHERE uid = %d', $user->uid); + db_query('UPDATE {node_revisions} SET uid = 0 WHERE uid = %d', $user->uid); } /** Index: modules/openid/openid.module =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.module,v retrieving revision 1.29 diff -u -r1.29 openid.module --- modules/openid/openid.module 17 Sep 2008 07:11:57 -0000 1.29 +++ modules/openid/openid.module 18 Sep 2008 13:01:31 -0000 @@ -57,11 +57,8 @@ } } -/** - * Implementation of hook_user(). - */ -function openid_user($op, &$edit, &$account, $category = NULL) { - if ($op == 'insert' && isset($_SESSION['openid']['values'])) { +function openid_user_insert(&$edit, &$account, $category = NULL) { + if (isset($_SESSION['openid']['values'])) { // The user has registered after trying to login via OpenID. if (variable_get('user_email_verification', TRUE)) { drupal_set_message(t('Once you have verified your email address, you may log in via OpenID.')); @@ -71,6 +68,15 @@ } /** + * Implementation of hook_user(). +function openid_user($op, &$edit, &$account, $category = NULL) { + if ($op == 'insert') { + openid_user_insert($edit, $account, $category); + } +} + */ + +/** * Implementation of hook_form_alter(). Adds OpenID login to the login forms. */ function openid_form_alter(&$form, $form_state, $form_id) { Index: modules/poll/poll.module =================================================================== RCS file: /cvs/drupal/drupal/modules/poll/poll.module,v retrieving revision 1.272 diff -u -r1.272 poll.module --- modules/poll/poll.module 17 Sep 2008 07:11:57 -0000 1.272 +++ modules/poll/poll.module 18 Sep 2008 13:01:31 -0000 @@ -822,11 +822,7 @@ db_query("UPDATE {poll_choices} SET chvotes = chvotes - 1 WHERE chid = %d", $node->vote); } -/** - * Implementation of hook_user(). - */ -function poll_user($op, &$edit, &$user) { - if ($op == 'delete') { - db_query('UPDATE {poll_votes} SET uid = 0 WHERE uid = %d', $user->uid); - } +function poll_user_delete(&$edit, &$user) { + db_query('UPDATE {poll_votes} SET uid = 0 WHERE uid = %d', $user->uid); } + Index: modules/profile/profile.module =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.module,v retrieving revision 1.244 diff -u -r1.244 profile.module --- modules/profile/profile.module 5 Sep 2008 09:25:52 -0000 1.244 +++ modules/profile/profile.module 18 Sep 2008 13:01:31 -0000 @@ -193,30 +193,40 @@ } } -/** - * Implementation of hook_user(). - */ -function profile_user($type, &$edit, &$user, $category = NULL) { - switch ($type) { - case 'load': - return profile_load_profile($user); - case 'register': - return profile_form_profile($edit, $user, $category, TRUE); - case 'update': - return profile_save_profile($edit, $user, $category); - case 'insert': - return profile_save_profile($edit, $user, $category, TRUE); - case 'view': - return profile_view_profile($user); - case 'form': - return profile_form_profile($edit, $user, $category); - case 'validate': - return profile_validate_profile($edit, $category); - case 'categories': - return profile_categories(); - case 'delete': - db_query('DELETE FROM {profile_values} WHERE uid = %d', $user->uid); - } +function profile_user_load(&$edit, &$user, $category = NULL) { + return profile_load_profile($user); +} + +function profile_user_register(&$edit, &$user, $category = NULL) { + return profile_form_profile($edit, $user, $category, TRUE); +} + +function profile_user_update(&$edit, &$user, $category = NULL) { + return profile_save_profile($edit, $user, $category); +} + +function profile_user_insert(&$edit, &$user, $category = NULL) { + return profile_save_profile($edit, $user, $category, TRUE); +} + +function profile_user_view(&$edit, &$user, $category = NULL) { + return profile_view_profile($user); +} + +function profile_user_form(&$edit, &$user, $category = NULL) { + return profile_form_profile($edit, $user, $category); +} + +function profile_user_validate(&$edit, &$user, $category = NULL) { + return profile_validate_profile($edit, $category); +} + +function profile_user_categories(&$edit, &$user, $category = NULL) { + return profile_categories(); +} + +function profile_user_delete(&$edit, &$user, $category = NULL) { + db_query('DELETE FROM {profile_values} WHERE uid = %d', $user->uid); } function profile_load_profile(&$user) { Index: modules/statistics/statistics.module =================================================================== RCS file: /cvs/drupal/drupal/modules/statistics/statistics.module,v retrieving revision 1.283 diff -u -r1.283 statistics.module --- modules/statistics/statistics.module 17 Sep 2008 07:11:58 -0000 1.283 +++ modules/statistics/statistics.module 18 Sep 2008 13:01:32 -0000 @@ -173,13 +173,8 @@ return $items; } -/** - * Implementation of hook_user(). - */ -function statistics_user($op, &$edit, &$user) { - if ($op == 'delete') { - db_query('UPDATE {accesslog} SET uid = 0 WHERE uid = %d', $user->uid); - } +function statistics_user_delete(&$edit, &$user, $category) { + db_query('UPDATE {accesslog} SET uid = 0 WHERE uid = %d', $user->uid); } /** Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.622 diff -u -r1.622 system.module --- modules/system/system.module 17 Sep 2008 20:37:32 -0000 1.622 +++ modules/system/system.module 18 Sep 2008 13:01:32 -0000 @@ -710,13 +710,8 @@ $variables['head'] = drupal_get_html_head(); } -/** - * Implementation of hook_user(). - * - * Allows users to individually set their theme and time zone. - */ -function system_user($type, $edit, &$user, $category = NULL) { - if ($type == 'form' && $category == 'account') { +function system_user_form(&$edit, &$user, $category = NULL) { + if ($category == 'account') { $form['theme_select'] = system_theme_select_form(t('Selecting a different theme will change the look and feel of the site.'), isset($edit['theme']) ? $edit['theme'] : NULL, 2); if (variable_get('configurable_timezones', 1)) { Index: modules/trigger/trigger.module =================================================================== RCS file: /cvs/drupal/drupal/modules/trigger/trigger.module,v retrieving revision 1.18 diff -u -r1.18 trigger.module --- modules/trigger/trigger.module 21 Aug 2008 19:36:38 -0000 1.18 +++ modules/trigger/trigger.module 18 Sep 2008 13:01:33 -0000 @@ -346,10 +346,34 @@ } } +function trigger_user_login(&$edit, &$account, $category) { + _trigger_user('login', $edit, $account, $category); +} + +function trigger_user_logout(&$edit, &$account, $category) { + _trigger_user('logout', $edit, $account, $category); +} + +function trigger_user_insert(&$edit, &$account, $category) { + _trigger_user('insert', $edit, $account, $category); +} + +function trigger_user_update(&$edit, &$account, $category) { + _trigger_user('update', $edit, $account, $category); +} + +function trigger_user_delete(&$edit, &$account, $category) { + _trigger_user('delete', $edit, $account, $category); +} + +function trigger_user_view(&$edit, &$account, $category) { + _trigger_user('view', $edit, $account, $category); +} + /** - * Implementation of hook_user(). + * Nasty, nasty hack to just make it work with new entry points. */ -function trigger_user($op, &$edit, &$account, $category = NULL) { +function _trigger_user($op, &$edit, &$account, $category = NULL) { // Keep objects for reuse so that changes actions make to objects can persist. static $objects; // We support a subset of operations. Index: modules/user/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.module,v retrieving revision 1.922 diff -u -r1.922 user.module --- modules/user/user.module 17 Sep 2008 07:11:59 -0000 1.922 +++ modules/user/user.module 18 Sep 2008 13:01:34 -0000 @@ -24,9 +24,9 @@ */ function user_module_invoke($type, &$array, &$user, $category = NULL) { foreach (module_list() as $module) { - $function = $module . '_user'; + $function = $module . '_user_' . $type; if (function_exists($function)) { - $function($type, $array, $user, $category); + $function($array, $user, $category); } } } @@ -632,46 +632,60 @@ ); } +function user_user_view(&$edit, &$account, $category = NULL) { + $account->content['user_picture'] = array( + '#value' => theme('user_picture', $account), + '#weight' => -10, + ); + if (!isset($account->content['summary'])) { + $account->content['summary'] = array(); + } + $account->content['summary'] += array( + '#type' => 'user_profile_category', + '#attributes' => array('class' => 'user-member'), + '#weight' => 5, + '#title' => t('History'), + ); + $account->content['summary']['member_for'] = array( + '#type' => 'user_profile_item', + '#title' => t('Member for'), + '#markup' => format_interval(REQUEST_TIME - $account->created), + ); +} + /** - * Implementation of hook_user(). + * Implementation of hook_user_form. */ -function user_user($type, &$edit, &$account, $category = NULL) { - if ($type == 'view') { - $account->content['user_picture'] = array( - '#value' => theme('user_picture', $account), - '#weight' => -10, - ); - if (!isset($account->content['summary'])) { - $account->content['summary'] = array(); - } - $account->content['summary'] += array( - '#type' => 'user_profile_category', - '#attributes' => array('class' => 'user-member'), - '#weight' => 5, - '#title' => t('History'), - ); - $account->content['summary']['member_for'] = array( - '#type' => 'user_profile_item', - '#title' => t('Member for'), - '#markup' => format_interval(REQUEST_TIME - $account->created), - ); - } - if ($type == 'form' && $category == 'account') { +function user_user_form(&$edit, &$account, $category = NULL) { + if ($category == 'account') { $form_state = array(); return user_edit_form($form_state, arg(1), $edit); } +} - if ($type == 'validate' && $category == 'account') { +/** + * Implementation of hook_user_validate. + */ +function user_user_validate(&$edit, &$account, $category = NULL) { + if ($category == 'account') { return _user_edit_validate(arg(1), $edit); } +} - if ($type == 'submit' && $category == 'account') { +/** + * Implementation of hook_user_submit. + */ +function user_user_submit(&$edit, &$account, $category = NULL) { + if ($category == 'account') { return _user_edit_submit(arg(1), $edit); } +} - if ($type == 'categories') { +/** + * Implementation of hook_user_categories. + */ +function user_user_categories(&$edit, &$account, $category = NULL) { return array(array('name' => 'account', 'title' => t('Account settings'), 'weight' => 1)); - } } function user_login_block() {