Issue #1291100 by moshe weitzman, David_Rothstein: Remove category system from user edit and view.
parent
cde51eae5d
commit
70b8337cdc
|
@ -572,7 +572,6 @@ function block_custom_block_save($edit, $delta) {
|
|||
* Implements hook_form_FORM_ID_alter().
|
||||
*/
|
||||
function block_form_user_profile_form_alter(&$form, &$form_state) {
|
||||
if ($form['#user_category'] == 'account') {
|
||||
$account = $form['#user'];
|
||||
$rids = array_keys($account->roles);
|
||||
$result = db_query("SELECT DISTINCT b.* FROM {block} b LEFT JOIN {block_role} r ON b.module = r.module AND b.delta = r.delta WHERE b.status = 1 AND b.custom <> 0 AND (r.rid IN (:rids) OR r.rid IS NULL) ORDER BY b.weight, b.module", array(':rids' => $rids));
|
||||
|
@ -601,12 +600,11 @@ function block_form_user_profile_form_alter(&$form, &$form_state) {
|
|||
$form['block'] += $blocks;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_presave().
|
||||
*/
|
||||
function block_user_presave(&$edit, $account, $category) {
|
||||
function block_user_presave(&$edit, $account) {
|
||||
if (isset($edit['block'])) {
|
||||
$edit['data']['block'] = $edit['block'];
|
||||
}
|
||||
|
|
|
@ -213,14 +213,13 @@ function contact_mail($key, &$message, $params) {
|
|||
* Add the enable personal contact form to an individual user's account page.
|
||||
*/
|
||||
function contact_form_user_profile_form_alter(&$form, &$form_state) {
|
||||
if ($form['#user_category'] == 'account') {
|
||||
$account = $form['#user'];
|
||||
$form['contact'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Contact settings'),
|
||||
'#weight' => 5,
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
$account = $form['#user'];
|
||||
$form['contact']['contact'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Personal contact form'),
|
||||
|
@ -228,12 +227,11 @@ function contact_form_user_profile_form_alter(&$form, &$form_state) {
|
|||
'#description' => t('Allow other users to contact you via a <a href="@url">personal contact form</a> which keeps your e-mail address hidden. Note that some privileged users such as site administrators are still able to contact you even if you choose to disable this feature.', array('@url' => url("user/$account->uid/contact"))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_presave().
|
||||
*/
|
||||
function contact_user_presave(&$edit, $account, $category) {
|
||||
function contact_user_presave(&$edit, $account) {
|
||||
$edit['data']['contact'] = isset($edit['contact']) ? $edit['contact'] : variable_get('contact_default_status', 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -275,7 +275,7 @@ function language_load($langcode) {
|
|||
* @ingroup forms
|
||||
* @see locale_form_alter()
|
||||
*/
|
||||
function locale_language_selector_form(&$form, &$form_state, $user) {
|
||||
function locale_language_selector_form($user) {
|
||||
global $language;
|
||||
$languages = language_list('enabled');
|
||||
$languages = $languages[1];
|
||||
|
@ -287,15 +287,13 @@ function locale_language_selector_form(&$form, &$form_state, $user) {
|
|||
foreach ($languages as $langcode => $item) {
|
||||
$names[$langcode] = $item->name;
|
||||
}
|
||||
// Get language negotiation settings.
|
||||
$mode = language_negotiation_get(LANGUAGE_TYPE_INTERFACE) != LANGUAGE_NEGOTIATION_DEFAULT;
|
||||
$form['locale'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Language settings'),
|
||||
'#weight' => 1,
|
||||
'#access' => ($form['#user_category'] == 'account' || ($form['#user_category'] == 'register' && user_access('administer users'))),
|
||||
);
|
||||
|
||||
// Get language negotiation settings.
|
||||
$mode = language_negotiation_get(LANGUAGE_TYPE_INTERFACE) != LANGUAGE_NEGOTIATION_DEFAULT;
|
||||
$form['locale']['language'] = array(
|
||||
'#type' => (count($names) <= 5 ? 'radios' : 'select'),
|
||||
'#title' => t('Language'),
|
||||
|
@ -303,6 +301,7 @@ function locale_language_selector_form(&$form, &$form_state, $user) {
|
|||
'#options' => $names,
|
||||
'#description' => $mode ? 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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,8 +339,12 @@ function locale_form_alter(&$form, &$form_state, $form_id) {
|
|||
if (drupal_multilingual()) {
|
||||
// Display language selector when either creating a user on the admin
|
||||
// interface or editing a user account.
|
||||
if ($form_id == 'user_register_form' || ($form_id == 'user_profile_form' && $form['#user_category'] == 'account')) {
|
||||
locale_language_selector_form($form, $form_state, $form['#user']);
|
||||
if ($form_id == 'user_register_form' || $form_id == 'user_profile_form') {
|
||||
$selector = locale_language_selector_form($form['#user']);
|
||||
if ($form_id == 'user_register_form') {
|
||||
$selector['locale']['#access'] = user_access('administer users');
|
||||
}
|
||||
$form += $selector;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1587,7 +1587,7 @@ class LocaleUserLanguageFunctionalTest extends DrupalWebTestCase {
|
|||
$path = 'user/' . $web_user->uid . '/edit';
|
||||
$this->drupalGet($path);
|
||||
// Ensure language settings fieldset is available.
|
||||
$this->assertText(t('Language settings'), t('Language settings available.'));
|
||||
$this->assertText(t('Language'), t('Language selector available.'));
|
||||
// Ensure custom language is present.
|
||||
$this->assertText($name, t('Language present on form.'));
|
||||
// Ensure disabled language isn't present.
|
||||
|
|
|
@ -83,7 +83,7 @@ function openid_help($path, $arg) {
|
|||
/**
|
||||
* Implements hook_user_insert().
|
||||
*/
|
||||
function openid_user_insert(&$edit, $account, $category) {
|
||||
function openid_user_insert(&$edit, $account) {
|
||||
if (!empty($edit['openid_claimed_id'])) {
|
||||
// The user has registered after trying to log in via OpenID.
|
||||
if (variable_get('user_email_verification', TRUE)) {
|
||||
|
|
|
@ -82,7 +82,6 @@ function overlay_theme() {
|
|||
* Implements hook_form_FORM_ID_alter().
|
||||
*/
|
||||
function overlay_form_user_profile_form_alter(&$form, &$form_state) {
|
||||
if ($form['#user_category'] == 'account') {
|
||||
$account = $form['#user'];
|
||||
if (user_access('access overlay', $account)) {
|
||||
$form['overlay_control'] = array(
|
||||
|
@ -91,7 +90,6 @@ function overlay_form_user_profile_form_alter(&$form, &$form_state) {
|
|||
'#weight' => 4,
|
||||
'#collapsible' => TRUE,
|
||||
);
|
||||
|
||||
$form['overlay_control']['overlay'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Use the overlay for administrative pages.'),
|
||||
|
@ -100,12 +98,11 @@ function overlay_form_user_profile_form_alter(&$form, &$form_state) {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_presave().
|
||||
*/
|
||||
function overlay_user_presave(&$edit, $account, $category) {
|
||||
function overlay_user_presave(&$edit, $account) {
|
||||
if (isset($edit['overlay'])) {
|
||||
$edit['data']['overlay'] = $edit['overlay'];
|
||||
}
|
||||
|
|
|
@ -1944,13 +1944,11 @@ function system_custom_theme() {
|
|||
* Implements hook_form_FORM_ID_alter().
|
||||
*/
|
||||
function system_form_user_profile_form_alter(&$form, &$form_state) {
|
||||
if ($form['#user_category'] == 'account') {
|
||||
if (variable_get('configurable_timezones', 1)) {
|
||||
system_user_timezone($form, $form_state);
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter().
|
||||
|
@ -1987,7 +1985,6 @@ function system_user_timezone(&$form, &$form_state) {
|
|||
global $user;
|
||||
|
||||
$account = $form['#user'];
|
||||
|
||||
$form['timezone'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Locale settings'),
|
||||
|
|
|
@ -463,8 +463,8 @@ function _trigger_normalize_user_context($type, $account) {
|
|||
/**
|
||||
* Implements hook_user_login().
|
||||
*/
|
||||
function trigger_user_login(&$edit, $account, $category) {
|
||||
_trigger_user('user_login', $edit, $account, $category);
|
||||
function trigger_user_login(&$edit, $account) {
|
||||
_trigger_user('user_login', $edit, $account);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -478,15 +478,15 @@ function trigger_user_logout($account) {
|
|||
/**
|
||||
* Implements hook_user_insert().
|
||||
*/
|
||||
function trigger_user_insert(&$edit, $account, $category) {
|
||||
_trigger_user('user_insert', $edit, $account, $category);
|
||||
function trigger_user_insert(&$edit, $account) {
|
||||
_trigger_user('user_insert', $edit, $account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_update().
|
||||
*/
|
||||
function trigger_user_update(&$edit, $account, $category) {
|
||||
_trigger_user('user_update', $edit, $account, $category);
|
||||
function trigger_user_update(&$edit, $account) {
|
||||
_trigger_user('user_update', $edit, $account);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -505,7 +505,7 @@ function trigger_user_cancel($edit, $account, $method) {
|
|||
*/
|
||||
function trigger_user_delete($account) {
|
||||
$edit = array();
|
||||
_trigger_user('user_delete', $edit, $account, NULL);
|
||||
_trigger_user('user_delete', $edit, $account);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -513,13 +513,13 @@ function trigger_user_delete($account) {
|
|||
*/
|
||||
function trigger_user_view($account) {
|
||||
$edit = NULL;
|
||||
_trigger_user('user_view', $edit, $account, NULL);
|
||||
_trigger_user('user_view', $edit, $account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calls action functions for user triggers.
|
||||
*/
|
||||
function _trigger_user($hook, &$edit, $account, $category = NULL) {
|
||||
function _trigger_user($hook, &$edit, $account, $method = NULL) {
|
||||
// Keep objects for reuse so that changes actions make to objects can persist.
|
||||
static $objects;
|
||||
$aids = trigger_get_assigned_actions($hook);
|
||||
|
@ -538,7 +538,7 @@ function _trigger_user($hook, &$edit, $account, $category = NULL) {
|
|||
actions_do($aid, $objects[$type], $context);
|
||||
}
|
||||
else {
|
||||
actions_do($aid, $account, $context, $category);
|
||||
actions_do($aid, $account, $context, $method);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to present profile categories (groups of
|
||||
* profile items).
|
||||
*
|
||||
* Categories are defined when configuring user profile fields for the site.
|
||||
* It can also be defined by modules. All profile items for a category will be
|
||||
* output through the $profile_items variable.
|
||||
*
|
||||
* @see user-profile-item.tpl.php
|
||||
* where each profile item is rendered. It is implemented as a definition
|
||||
* list by default.
|
||||
* @see user-profile.tpl.php
|
||||
* where all items and categories are collected and printed out.
|
||||
*
|
||||
* Available variables:
|
||||
* - $title: Category title for the group of items.
|
||||
* - $profile_items: All the items for the group rendered through
|
||||
* user-profile-item.tpl.php.
|
||||
* - $attributes: HTML attributes. Usually renders classes.
|
||||
*
|
||||
* @see template_preprocess_user_profile_category()
|
||||
*/
|
||||
?>
|
||||
<section class="<?php print $classes; ?>">
|
||||
<?php if ($title): ?>
|
||||
<h2><?php print $title; ?></h2>
|
||||
<?php endif; ?>
|
||||
|
||||
<dl<?php print $attributes; ?>>
|
||||
<?php print $profile_items; ?>
|
||||
</dl>
|
||||
</section>
|
|
@ -1,26 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to present profile items (values from user
|
||||
* account profile fields or modules).
|
||||
*
|
||||
* This template is used to loop through and render each field configured
|
||||
* for the user's account. It can also be the data from modules. The output is
|
||||
* grouped by categories.
|
||||
*
|
||||
* @see user-profile-category.tpl.php
|
||||
* for the parent markup. Implemented as a definition list by default.
|
||||
* @see user-profile.tpl.php
|
||||
* where all items and categories are collected and printed out.
|
||||
*
|
||||
* Available variables:
|
||||
* - $title: Field title for the profile item.
|
||||
* - $value: User defined value for the profile item or data from a module.
|
||||
* - $attributes: HTML attributes. Usually renders classes.
|
||||
*
|
||||
* @see template_preprocess_user_profile_item()
|
||||
*/
|
||||
?>
|
||||
<dt<?php print $attributes; ?>><?php print $title; ?></dt>
|
||||
<dd<?php print $attributes; ?>><?php print $value; ?></dd>
|
|
@ -11,7 +11,7 @@
|
|||
* such as render($user_profile['user_picture']). Always call
|
||||
* render($user_profile) at the end in order to print all remaining items. If
|
||||
* the item is a category, it will contain all its profile items. By default,
|
||||
* $user_profile['summary'] is provided, which contains data on the user's
|
||||
* $user_profile['member_for'] is provided, which contains data on the user's
|
||||
* history. Other data can be included by modules. $user_profile['user_picture']
|
||||
* is available for showing the account picture.
|
||||
*
|
||||
|
@ -25,10 +25,6 @@
|
|||
* field language, e.g. $account->field_example['en'], thus overriding any
|
||||
* language negotiation rule that was previously applied.
|
||||
*
|
||||
* @see user-profile-category.tpl.php
|
||||
* Where the html is handled for the group.
|
||||
* @see user-profile-item.tpl.php
|
||||
* Where the html is handled for each item in the group.
|
||||
* @see template_preprocess_user_profile()
|
||||
*/
|
||||
?>
|
||||
|
|
|
@ -182,29 +182,6 @@ function hook_user_operations() {
|
|||
return $operations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a list of user setting or profile information categories.
|
||||
*
|
||||
* @return
|
||||
* An array of associative arrays. Each inner array has elements:
|
||||
* - "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.
|
||||
* - "access callback": Name of the access callback function to use to
|
||||
* determine whether the user can edit the category. Defaults to using
|
||||
* user_edit_access(). See hook_menu() for more information on access
|
||||
* callbacks.
|
||||
* - "access arguments": Arguments for the access callback function. Defaults
|
||||
* to array(1).
|
||||
*/
|
||||
function hook_user_categories() {
|
||||
return array(array(
|
||||
'name' => 'account',
|
||||
'title' => t('Account settings'),
|
||||
'weight' => 1,
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* A user account is about to be created or updated.
|
||||
*
|
||||
|
@ -217,13 +194,11 @@ function hook_user_categories() {
|
|||
* The array of form values submitted by the user.
|
||||
* @param $account
|
||||
* The user object on which the operation is performed.
|
||||
* @param $category
|
||||
* The active category of user information being edited.
|
||||
*
|
||||
* @see hook_user_insert()
|
||||
* @see hook_user_update()
|
||||
*/
|
||||
function hook_user_presave(&$edit, $account, $category) {
|
||||
function hook_user_presave(&$edit, $account) {
|
||||
// Make sure that our form value 'mymodule_foo' is stored as 'mymodule_bar'.
|
||||
if (isset($edit['mymodule_foo'])) {
|
||||
$edit['data']['my_module_foo'] = $edit['my_module_foo'];
|
||||
|
@ -240,13 +215,11 @@ function hook_user_presave(&$edit, $account, $category) {
|
|||
* 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.
|
||||
*
|
||||
* @see hook_user_presave()
|
||||
* @see hook_user_update()
|
||||
*/
|
||||
function hook_user_insert(&$edit, $account, $category) {
|
||||
function hook_user_insert(&$edit, $account) {
|
||||
db_insert('mytable')
|
||||
->fields(array(
|
||||
'myfield' => $edit['myfield'],
|
||||
|
@ -265,13 +238,11 @@ function hook_user_insert(&$edit, $account, $category) {
|
|||
* The array of form values submitted by the user.
|
||||
* @param $account
|
||||
* The user object on which the operation is performed.
|
||||
* @param $category
|
||||
* The active category of user information being edited.
|
||||
*
|
||||
* @see hook_user_presave()
|
||||
* @see hook_user_insert()
|
||||
*/
|
||||
function hook_user_update(&$edit, $account, $category) {
|
||||
function hook_user_update(&$edit, $account) {
|
||||
db_insert('user_changes')
|
||||
->fields(array(
|
||||
'uid' => $account->uid,
|
||||
|
@ -331,17 +302,8 @@ function hook_user_view($account, $view_mode, $langcode) {
|
|||
'#markup' => theme('user_picture', array('account' => $account)),
|
||||
'#weight' => -10,
|
||||
);
|
||||
if (!isset($account->content['summary'])) {
|
||||
$account->content['summary'] = array();
|
||||
}
|
||||
$account->content['summary'] += array(
|
||||
'#type' => 'user_profile_category',
|
||||
'#attributes' => array('class' => array('user-member')),
|
||||
'#weight' => 5,
|
||||
'#title' => t('History'),
|
||||
);
|
||||
$account->content['summary']['member_for'] = array(
|
||||
'#type' => 'user_profile_item',
|
||||
$account->content['member_for'] = array(
|
||||
'#type' => 'item',
|
||||
'#title' => t('Member for'),
|
||||
'#markup' => format_interval(REQUEST_TIME - $account->created),
|
||||
);
|
||||
|
|
|
@ -335,3 +335,24 @@ function user_install() {
|
|||
->execute();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @addtogroup updates-7.x-to-8.x
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The 'Member for' extra field has moved one level up in the array.
|
||||
*/
|
||||
function user_update_8000() {
|
||||
$settings = field_bundle_settings('user', 'user');
|
||||
if (isset($settings['extra_fields']['display']['summary'])) {
|
||||
$settings['extra_fields']['display']['member_for'] = $settings['extra_fields']['display']['summary'];
|
||||
unset($settings['extra_fields']['display']['summary']);
|
||||
field_bundle_settings('user', 'user', $settings);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-7.x-to-8.x"
|
||||
*/
|
||||
|
|
|
@ -92,13 +92,11 @@ function user_help($path, $arg) {
|
|||
* @param $account
|
||||
* The user account object to be passed as the second parameter of the hook
|
||||
* function.
|
||||
* @param $category
|
||||
* The category of user information being acted upon.
|
||||
*/
|
||||
function user_module_invoke($type, &$edit, $account, $category = NULL) {
|
||||
function user_module_invoke($type, &$edit, $account) {
|
||||
foreach (module_implements('user_' . $type) as $module) {
|
||||
$function = $module . '_user_' . $type;
|
||||
$function($edit, $account, $category);
|
||||
$function($edit, $account);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,16 +114,6 @@ function user_theme() {
|
|||
'template' => 'user-profile',
|
||||
'file' => 'user.pages.inc',
|
||||
),
|
||||
'user_profile_category' => array(
|
||||
'render element' => 'element',
|
||||
'template' => 'user-profile-category',
|
||||
'file' => 'user.pages.inc',
|
||||
),
|
||||
'user_profile_item' => array(
|
||||
'render element' => 'element',
|
||||
'template' => 'user-profile-item',
|
||||
'file' => 'user.pages.inc',
|
||||
),
|
||||
'user_list' => array(
|
||||
'variables' => array('users' => NULL, 'title' => NULL),
|
||||
),
|
||||
|
@ -239,9 +227,9 @@ function user_field_extra_fields() {
|
|||
),
|
||||
),
|
||||
'display' => array(
|
||||
'summary' => array(
|
||||
'label' => t('History'),
|
||||
'description' => t('User module history view element.'),
|
||||
'member_for' => array(
|
||||
'label' => t('Member for'),
|
||||
'description' => t('User module \'member for\' view element.'),
|
||||
'weight' => 5,
|
||||
),
|
||||
),
|
||||
|
@ -379,15 +367,13 @@ function user_load_by_name($name) {
|
|||
* An array of fields and values to save. For example array('name'
|
||||
* => 'My name'). Key / value pairs added to the $edit['data'] will be
|
||||
* serialized and saved in the {users.data} column.
|
||||
* @param $category
|
||||
* (optional) The category for storing profile information in.
|
||||
*
|
||||
* @return
|
||||
* A fully-loaded $user object upon successful save or FALSE if the save failed.
|
||||
*
|
||||
* @todo D8: Drop $edit and fix user_save() to be consistent with others.
|
||||
*/
|
||||
function user_save($account, $edit = array(), $category = 'account') {
|
||||
function user_save($account, $edit = array()) {
|
||||
$transaction = db_transaction();
|
||||
try {
|
||||
if (!empty($edit['pass'])) {
|
||||
|
@ -425,7 +411,7 @@ function user_save($account, $edit = array(), $category = 'account') {
|
|||
}
|
||||
|
||||
// Invoke hook_user_presave() for all modules.
|
||||
user_module_invoke('presave', $edit, $account, $category);
|
||||
user_module_invoke('presave', $edit, $account);
|
||||
|
||||
// Invoke presave operations of Field Attach API and Entity API. Those APIs
|
||||
// require a fully-fledged and updated entity object. Therefore, we need to
|
||||
|
@ -523,7 +509,7 @@ function user_save($account, $edit = array(), $category = 'account') {
|
|||
$edit[$key] = $value;
|
||||
}
|
||||
}
|
||||
user_module_invoke('update', $edit, $account, $category);
|
||||
user_module_invoke('update', $edit, $account);
|
||||
module_invoke_all('entity_update', $account, 'user');
|
||||
}
|
||||
else {
|
||||
|
@ -548,7 +534,7 @@ function user_save($account, $edit = array(), $category = 'account') {
|
|||
|
||||
field_attach_insert('user', $account);
|
||||
$edit = (array) $account;
|
||||
user_module_invoke('insert', $edit, $account, $category);
|
||||
user_module_invoke('insert', $edit, $account);
|
||||
module_invoke_all('entity_insert', $account, 'user');
|
||||
|
||||
// Save user roles.
|
||||
|
@ -920,19 +906,6 @@ function user_search_execute($keys = NULL, $conditions = NULL) {
|
|||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_element_info().
|
||||
*/
|
||||
function user_element_info() {
|
||||
$types['user_profile_category'] = array(
|
||||
'#theme_wrappers' => array('user_profile_category'),
|
||||
);
|
||||
$types['user_profile_item'] = array(
|
||||
'#theme' => 'user_profile_item',
|
||||
);
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_view().
|
||||
*/
|
||||
|
@ -941,19 +914,11 @@ function user_user_view($account) {
|
|||
'#markup' => theme('user_picture', array('account' => $account)),
|
||||
'#weight' => -10,
|
||||
);
|
||||
if (!isset($account->content['summary'])) {
|
||||
$account->content['summary'] = array();
|
||||
}
|
||||
$account->content['summary'] += array(
|
||||
'#type' => 'user_profile_category',
|
||||
'#attributes' => array('class' => array('user-member')),
|
||||
'#weight' => 5,
|
||||
'#title' => t('History'),
|
||||
);
|
||||
$account->content['summary']['member_for'] = array(
|
||||
'#type' => 'user_profile_item',
|
||||
$account->content['member_for'] = array(
|
||||
'#type' => 'item',
|
||||
'#title' => t('Member for'),
|
||||
'#markup' => format_interval(REQUEST_TIME - $account->created),
|
||||
'#weight' => 5,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1167,7 +1132,6 @@ function user_validate_current_pass(&$form, &$form_state) {
|
|||
* @see user_account_form()
|
||||
*/
|
||||
function user_account_form_validate($form, &$form_state) {
|
||||
if ($form['#user_category'] == 'account' || $form['#user_category'] == 'register') {
|
||||
$account = $form['#user'];
|
||||
// Validate new or changing username.
|
||||
if (isset($form_state['values']['name'])) {
|
||||
|
@ -1212,13 +1176,11 @@ function user_account_form_validate($form, &$form_state) {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_presave().
|
||||
*/
|
||||
function user_user_presave(&$edit, $account, $category) {
|
||||
if ($category == 'account' || $category == 'register') {
|
||||
function user_user_presave(&$edit, $account) {
|
||||
if (!empty($edit['picture_upload'])) {
|
||||
$edit['picture'] = $edit['picture_upload'];
|
||||
}
|
||||
|
@ -1230,7 +1192,6 @@ function user_user_presave(&$edit, $account, $category) {
|
|||
if (isset($edit['roles'])) {
|
||||
$edit['roles'] = array_filter($edit['roles']);
|
||||
}
|
||||
}
|
||||
|
||||
// Move account cancellation information into $user->data.
|
||||
foreach (array('user_cancel_method', 'user_cancel_notify') as $key) {
|
||||
|
@ -1240,17 +1201,6 @@ function user_user_presave(&$edit, $account, $category) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_user_categories().
|
||||
*/
|
||||
function user_user_categories() {
|
||||
return array(array(
|
||||
'name' => 'account',
|
||||
'title' => t('Account settings'),
|
||||
'weight' => 1,
|
||||
));
|
||||
}
|
||||
|
||||
function user_login_block($form) {
|
||||
$form['#action'] = url($_GET['q'], array('query' => drupal_get_destination()));
|
||||
$form['#id'] = 'user-login-form';
|
||||
|
@ -1734,33 +1684,6 @@ function user_menu() {
|
|||
'type' => MENU_LOCAL_TASK,
|
||||
'file' => 'user.pages.inc',
|
||||
);
|
||||
|
||||
$items['user/%user_category/edit/account'] = array(
|
||||
'title' => 'Account',
|
||||
'type' => MENU_DEFAULT_LOCAL_TASK,
|
||||
'load arguments' => array('%map', '%index'),
|
||||
);
|
||||
|
||||
if (($categories = _user_categories()) && (count($categories) > 1)) {
|
||||
foreach ($categories as $key => $category) {
|
||||
// 'account' is already handled by the MENU_DEFAULT_LOCAL_TASK.
|
||||
if ($category['name'] != 'account') {
|
||||
$items['user/%user_category/edit/' . $category['name']] = array(
|
||||
'title callback' => 'check_plain',
|
||||
'title arguments' => array($category['title']),
|
||||
'page callback' => 'drupal_get_form',
|
||||
'page arguments' => array('user_profile_form', 1, 3),
|
||||
'access callback' => isset($category['access callback']) ? $category['access callback'] : 'user_edit_access',
|
||||
'access arguments' => isset($category['access arguments']) ? $category['access arguments'] : array(1),
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
'weight' => $category['weight'],
|
||||
'load arguments' => array('%map', '%index'),
|
||||
'tab_parent' => 'user/%/edit',
|
||||
'file' => 'user.pages.inc',
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $items;
|
||||
}
|
||||
|
||||
|
@ -1878,44 +1801,6 @@ function user_uid_optional_load($uid = NULL) {
|
|||
return user_load($uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a user object after checking if any profile category in the path exists.
|
||||
*/
|
||||
function user_category_load($uid, &$map, $index) {
|
||||
static $user_categories, $accounts;
|
||||
|
||||
// Cache $account - this load function will get called for each profile tab.
|
||||
if (!isset($accounts[$uid])) {
|
||||
$accounts[$uid] = user_load($uid);
|
||||
}
|
||||
$valid = TRUE;
|
||||
if ($account = $accounts[$uid]) {
|
||||
// Since the path is like user/%/edit/category_name, the category name will
|
||||
// be at a position 2 beyond the index corresponding to the % wildcard.
|
||||
$category_index = $index + 2;
|
||||
// Valid categories may contain slashes, and hence need to be imploded.
|
||||
$category_path = implode('/', array_slice($map, $category_index));
|
||||
if ($category_path) {
|
||||
// Check that the requested category exists.
|
||||
$valid = FALSE;
|
||||
if (!isset($user_categories)) {
|
||||
$user_categories = _user_categories();
|
||||
}
|
||||
foreach ($user_categories as $category) {
|
||||
if ($category['name'] == $category_path) {
|
||||
$valid = TRUE;
|
||||
// Truncate the map array in case the category name had slashes.
|
||||
$map = array_slice($map, 0, $category_index);
|
||||
// Assign the imploded category name to the last map element.
|
||||
$map[$category_index] = $category_path;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $valid ? $account : FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns $arg or the user ID of the current user if $arg is '%' or empty.
|
||||
*
|
||||
|
@ -2461,14 +2346,10 @@ function user_view_page($account) {
|
|||
*
|
||||
* When viewing a user profile, the $page array contains:
|
||||
*
|
||||
* - $page['content']['Profile Category']:
|
||||
* Profile categories keyed by their human-readable names.
|
||||
* - $page['content']['Profile Category']['profile_machine_name']:
|
||||
* Profile fields keyed by their machine-readable names.
|
||||
* - $page['content']['user_picture']:
|
||||
* User's rendered picture.
|
||||
* - $page['content']['summary']:
|
||||
* Contains the default "History" profile data for a user.
|
||||
* - $page['content']['member_for']:
|
||||
* Contains the default "Member for" profile data for a user.
|
||||
* - $page['content']['#account']:
|
||||
* The user account of the profile being viewed.
|
||||
*
|
||||
|
@ -3274,22 +3155,6 @@ function user_multiple_cancel_confirm_submit($form, &$form_state) {
|
|||
$form_state['redirect'] = 'admin/people';
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a list of all user setting/information categories and sort them by weight.
|
||||
*/
|
||||
function _user_categories() {
|
||||
$categories = module_invoke_all('user_categories');
|
||||
usort($categories, '_user_sort');
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
function _user_sort($a, $b) {
|
||||
$a = (array) $a + array('weight' => 0, 'title' => '');
|
||||
$b = (array) $b + array('weight' => 0, 'title' => '');
|
||||
return $a['weight'] < $b['weight'] ? -1 : ($a['weight'] > $b['weight'] ? 1 : ($a['title'] < $b['title'] ? -1 : 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* List user administration filters that can be applied.
|
||||
*/
|
||||
|
@ -3676,7 +3541,6 @@ function user_register_form($form, &$form_state) {
|
|||
}
|
||||
|
||||
$form['#user'] = drupal_anonymous_user();
|
||||
$form['#user_category'] = 'register';
|
||||
|
||||
$form['#attached']['library'][] = array('system', 'jquery.cookie');
|
||||
$form['#attributes']['class'][] = 'user-info-from-cookie';
|
||||
|
|
|
@ -198,42 +198,7 @@ function template_preprocess_user_profile(&$variables) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Process variables for user-profile-item.tpl.php.
|
||||
*
|
||||
* The $variables array contains the following arguments:
|
||||
* - $element
|
||||
*
|
||||
* @see user-profile-item.tpl.php
|
||||
*/
|
||||
function template_preprocess_user_profile_item(&$variables) {
|
||||
$variables['title'] = $variables['element']['#title'];
|
||||
$variables['value'] = $variables['element']['#markup'];
|
||||
$variables['attributes'] = '';
|
||||
if (isset($variables['element']['#attributes'])) {
|
||||
$variables['attributes'] = drupal_attributes($variables['element']['#attributes']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Process variables for user-profile-category.tpl.php.
|
||||
*
|
||||
* The $variables array contains the following arguments:
|
||||
* - $element
|
||||
*
|
||||
* @see user-profile-category.tpl.php
|
||||
*/
|
||||
function template_preprocess_user_profile_category(&$variables) {
|
||||
$variables['title'] = check_plain($variables['element']['#title']);
|
||||
$variables['classes_array'][] = 'user-profile-category-' . drupal_html_class($variables['title']);
|
||||
$variables['profile_items'] = $variables['element']['#children'];
|
||||
$variables['attributes'] = '';
|
||||
if (isset($variables['element']['#attributes'])) {
|
||||
$variables['attributes'] = drupal_attributes($variables['element']['#attributes']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form builder; edit a user account or one of their profile categories.
|
||||
* Form builder; edit a user account.
|
||||
*
|
||||
* @ingroup forms
|
||||
* @see user_account_form()
|
||||
|
@ -242,7 +207,7 @@ function template_preprocess_user_profile_category(&$variables) {
|
|||
* @see user_profile_form_submit()
|
||||
* @see user_cancel_confirm_form_submit()
|
||||
*/
|
||||
function user_profile_form($form, &$form_state, $account, $category = 'account') {
|
||||
function user_profile_form($form, &$form_state, $account) {
|
||||
global $user;
|
||||
|
||||
// During initial form build, add the entity to the form state for use during
|
||||
|
@ -258,27 +223,23 @@ function user_profile_form($form, &$form_state, $account, $category = 'account')
|
|||
// @todo Legacy support. Modules are encouraged to access the entity using
|
||||
// $form_state. Remove in Drupal 8.
|
||||
$form['#user'] = $account;
|
||||
$form['#user_category'] = $category;
|
||||
|
||||
if ($category == 'account') {
|
||||
|
||||
user_account_form($form, $form_state);
|
||||
// Attach field widgets.
|
||||
field_attach_form('user', $account, $form, $form_state);
|
||||
}
|
||||
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
$form['actions']['submit'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Save'),
|
||||
);
|
||||
if ($category == 'account') {
|
||||
$form['actions']['cancel'] = array(
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Cancel account'),
|
||||
'#submit' => array('user_edit_cancel_submit'),
|
||||
'#access' => $account->uid > 1 && (($account->uid == $user->uid && user_access('cancel account')) || user_access('administer users')),
|
||||
);
|
||||
}
|
||||
|
||||
$form['#validate'][] = 'user_profile_form_validate';
|
||||
// Add the final user profile form submit handler.
|
||||
|
@ -299,7 +260,6 @@ function user_profile_form_validate($form, &$form_state) {
|
|||
*/
|
||||
function user_profile_form_submit($form, &$form_state) {
|
||||
$account = $form_state['user'];
|
||||
$category = $form['#user_category'];
|
||||
// Remove unneeded values.
|
||||
form_state_values_clean($form_state);
|
||||
|
||||
|
@ -315,10 +275,10 @@ function user_profile_form_submit($form, &$form_state) {
|
|||
// this form by taking over all values, which appear in the form values too.
|
||||
$edit = array_intersect_key((array) $account, $form_state['values']);
|
||||
|
||||
user_save($account_unchanged, $edit, $category);
|
||||
user_save($account_unchanged, $edit);
|
||||
$form_state['values']['uid'] = $account->uid;
|
||||
|
||||
if ($category == 'account' && !empty($edit['pass'])) {
|
||||
if (!empty($edit['pass'])) {
|
||||
// Remove the password reset tag since a new password was saved.
|
||||
unset($_SESSION['pass_reset_'. $account->uid]);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue