diff --git a/core/modules/comment/comment.entity.inc b/core/modules/comment/comment.entity.inc index cb4d6d6..3c17843 100644 --- a/core/modules/comment/comment.entity.inc +++ b/core/modules/comment/comment.entity.inc @@ -106,7 +106,7 @@ class CommentStorageController extends EntityDatabaseStorageController { $query->addField('n', 'type', 'node_type'); $query->innerJoin('users', 'u', 'base.uid = u.uid'); $query->addField('u', 'name', 'registered_name'); - $query->fields('u', array('uid', 'signature', 'signature_format', 'picture')); + $query->fields('u', array('uid', 'signature', 'signature_format')); return $query; } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index c43e725..4696649 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -1046,6 +1046,17 @@ function comment_build_content(Comment $comment, Node $node, $view_mode = 'full' } /** + * Implements hook_entity_prepare_view(). + * + * Load user account objects into comment entities. + */ +function comment_entity_prepare_view($entities, $type) { + if ($type == 'comment') { + user_attach_accounts($entities); + } +} + +/** * Adds reply, edit, delete, etc. links, depending on user permissions. * * @param Comment $comment @@ -2120,7 +2131,14 @@ function template_preprocess_comment(&$variables) { $variables['changed'] = format_date($comment->changed); $variables['new'] = !empty($comment->new) ? t('new') : ''; - $variables['user_picture'] = theme_get_setting('toggle_comment_user_picture') ? theme('user_picture', array('account' => $comment)) : ''; + if (theme_get_setting('toggle_comment_user_picture')) { + // To change user picture settings (e.g., image style), edit the 'compact' + // view mode on the User entity. + $variables['user_picture'] = user_view($comment->account, 'compact'); + } + else { + $variables['user_picture'] = array(); + } $variables['signature'] = $comment->signature; $uri = entity_uri('comment', $comment); diff --git a/core/modules/comment/comment.test b/core/modules/comment/comment.test index 0441d6d..2ba1eb6 100644 --- a/core/modules/comment/comment.test +++ b/core/modules/comment/comment.test @@ -987,7 +987,7 @@ class CommentPreviewTest extends CommentHelperCase { $edit['signature[value]'] = '' . $test_signature. ''; $edit['signature[format]'] = 'filtered_html'; $image = current($this->drupalGetTestFiles('image')); - $edit['files[picture_upload]'] = drupal_realpath($image->uri); + $edit['files[field_user_picture_und_0]'] = drupal_realpath($image->uri); $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Save')); // As the web user, fill in the comment form and preview the comment. diff --git a/core/modules/comment/comment.tpl.php b/core/modules/comment/comment.tpl.php index e94e6e4..be7d20f 100644 --- a/core/modules/comment/comment.tpl.php +++ b/core/modules/comment/comment.tpl.php @@ -20,7 +20,8 @@ * - $permalink: Comment permalink. * - $submitted: Submission information created from $author and $created during * template_preprocess_comment(). - * - $user_picture: The comment author's picture from user-picture.tpl.php. + * - $user_picture: The comment author's picture. Use render($user_picture) to + * print it. * - $signature: Authors signature. * - $status: Comment status. Possible values are: * unpublished, published, or preview. @@ -68,7 +69,7 @@ diff --git a/core/modules/field/modules/field_sql_storage/field_sql_storage.install b/core/modules/field/modules/field_sql_storage/field_sql_storage.install index 2229ef4..24bdc05 100644 --- a/core/modules/field/modules/field_sql_storage/field_sql_storage.install +++ b/core/modules/field/modules/field_sql_storage/field_sql_storage.install @@ -118,11 +118,15 @@ function field_sql_storage_update_8000(&$sandbox) { $table_info = array($data_table => $primary_key_data, $revision_table => $primary_key_revision); foreach ($table_info as $table => $primary_key) { - db_drop_primary_key($table); - db_drop_index($table, 'language'); - db_change_field($table, 'language', 'langcode', $field_langcode); - db_add_primary_key($table, $primary_key); - db_add_index($table, 'langcode', $langcode_index); + // Do not attempt to rename the 'language' column for fields that already + // contain it (created during the upgrade before this update function). + if (db_field_exists($table, 'language')) { + db_drop_primary_key($table); + db_drop_index($table, 'language'); + db_change_field($table, 'language', 'langcode', $field_langcode); + db_add_primary_key($table, $primary_key); + db_add_index($table, 'langcode', $langcode_index); + } } } } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 5e1c3b3..41ab991 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1253,6 +1253,17 @@ function node_build_content(Node $node, $view_mode = 'full', $langcode = NULL) { } /** + * Implements hook_entity_prepare_view(). + * + * Load user account objects into node entities. + */ +function node_entity_prepare_view($entities, $type) { + if ($type == 'node') { + user_attach_accounts($entities); + } +} + +/** * Page callback: Generates an array which displays a node detail page. * * @param Drupal\node\Node $node @@ -1359,7 +1370,14 @@ function template_preprocess_node(&$variables) { if (variable_get('node_submitted_' . $node->type, TRUE)) { $variables['display_submitted'] = TRUE; $variables['submitted'] = t('Submitted by !username on !datetime', array('!username' => $variables['name'], '!datetime' => $variables['date'])); - $variables['user_picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', array('account' => $node)) : ''; + if (theme_get_setting('toggle_node_user_picture')) { + // To change user picture settings (e.g. image style), edit the 'compact' + // view mode on User entity. + $variables['user_picture'] = user_view($node->account, 'compact'); + } + else { + $variables['user_picture'] = array(); + } } else { $variables['display_submitted'] = FALSE; diff --git a/core/modules/node/node.pages.inc b/core/modules/node/node.pages.inc index 868acbd..d98e370 100644 --- a/core/modules/node/node.pages.inc +++ b/core/modules/node/node.pages.inc @@ -414,7 +414,6 @@ function node_preview(Node $node) { // user ID 0 denotes the anonymous user. if ($user = user_load_by_name($node->name)) { $node->uid = $user->uid; - $node->picture = $user->picture; } else { $node->uid = 0; // anonymous user @@ -423,7 +422,6 @@ function node_preview(Node $node) { elseif ($node->uid) { $user = user_load($node->uid); $node->name = $user->name; - $node->picture = $user->picture; } $node->changed = REQUEST_TIME; diff --git a/core/modules/node/node.tpl.php b/core/modules/node/node.tpl.php index c3db5ae..a53bdf4 100644 --- a/core/modules/node/node.tpl.php +++ b/core/modules/node/node.tpl.php @@ -10,7 +10,7 @@ * or print a subset such as render($content['field_example']). Use * hide($content['field_example']) to temporarily suppress the printing of a * given element. - * - $user_picture: The node author's picture from user-picture.tpl.php. + * - $user_picture: The node author's picture. Use render() to print it. * - $date: Formatted creation date. Preprocess functions can reformat it by * calling format_date() with the desired parameters on the $created variable. * - $name: Themed username of node author output from theme_username(). @@ -88,7 +88,7 @@ diff --git a/core/modules/system/system.admin.inc b/core/modules/system/system.admin.inc index 9619461..0f364c2 100644 --- a/core/modules/system/system.admin.inc +++ b/core/modules/system/system.admin.inc @@ -393,7 +393,7 @@ function system_theme_settings($form, &$form_state, $key = '') { // Some features are not always available $disabled = array(); - if (!variable_get('user_pictures', 0)) { + if (!user_picture_enabled()) { $disabled['toggle_node_user_picture'] = TRUE; $disabled['toggle_comment_user_picture'] = TRUE; } diff --git a/core/modules/user/lib/Drupal/user/UserStorageController.php b/core/modules/user/lib/Drupal/user/UserStorageController.php index bd0d9b9..a57a599 100644 --- a/core/modules/user/lib/Drupal/user/UserStorageController.php +++ b/core/modules/user/lib/Drupal/user/UserStorageController.php @@ -25,12 +25,7 @@ class UserStorageController extends EntityDatabaseStorageController { * Overrides EntityDatabaseStorageController::attachLoad(). */ function attachLoad(&$queried_users, $revision_id = FALSE) { - // Build an array of user picture IDs so that these can be fetched later. - $picture_fids = array(); foreach ($queried_users as $key => $record) { - if ($record->picture) { - $picture_fids[] = $record->picture; - } $queried_users[$key]->data = unserialize($record->data); $queried_users[$key]->roles = array(); if ($record->uid) { @@ -47,15 +42,6 @@ class UserStorageController extends EntityDatabaseStorageController { $queried_users[$record->uid]->roles[$record->rid] = $record->name; } - // Add the full file objects for user pictures if enabled. - if (!empty($picture_fids) && variable_get('user_pictures', 1) == 1) { - $pictures = file_load_multiple($picture_fids); - foreach ($queried_users as $entity) { - if (!empty($entity->picture) && isset($pictures[$entity->picture])) { - $entity->picture = $pictures[$entity->picture]; - } - } - } // Call the default attachLoad() method. This will add fields and call // hook_user_load(). parent::attachLoad($queried_users, $revision_id); @@ -100,46 +86,7 @@ class UserStorageController extends EntityDatabaseStorageController { } } - if (!empty($entity->picture_upload)) { - $entity->picture = $entity->picture_upload; - } - // Delete the picture if the submission indicates that it should be deleted - // and no replacement was submitted. - elseif (!empty($entity->picture_delete)) { - $entity->picture = 0; - file_usage_delete($entity->original->picture, 'user', 'user', $entity->uid); - file_delete($entity->original->picture); - } - if (!$entity->isNew()) { - // Process picture uploads. - if (!empty($entity->picture->fid) && (!isset($entity->original->picture->fid) || $entity->picture->fid != $entity->original->picture->fid)) { - $picture = $entity->picture; - // If the picture is a temporary file, move it to its final location - // and make it permanent. - if (!$picture->status) { - $info = image_get_info($picture->uri); - $picture_directory = file_default_scheme() . '://' . variable_get('user_picture_path', 'pictures'); - - // Prepare the pictures directory. - file_prepare_directory($picture_directory, FILE_CREATE_DIRECTORY); - $destination = file_stream_wrapper_uri_normalize($picture_directory . '/picture-' . $entity->uid . '-' . REQUEST_TIME . '.' . $info['extension']); - - // Move the temporary file into the final location. - if ($picture = file_move($picture, $destination, FILE_EXISTS_RENAME)) { - $picture->status = FILE_STATUS_PERMANENT; - $entity->picture = file_save($picture); - file_usage_add($picture, 'user', 'user', $entity->uid); - } - } - // Delete the previous picture if it was deleted or replaced. - if (!empty($entity->original->picture->fid)) { - file_usage_delete($entity->original->picture, 'user', 'user', $entity->uid); - file_delete($entity->original->picture); - } - } - $entity->picture = empty($entity->picture->fid) ? 0 : $entity->picture->fid; - // If the password is empty, that means it was not changed, so use the // original password. if (empty($entity->pass)) { diff --git a/core/modules/user/user-picture.tpl.php b/core/modules/user/user-picture.tpl.php deleted file mode 100644 index a33d266..0000000 --- a/core/modules/user/user-picture.tpl.php +++ /dev/null @@ -1,21 +0,0 @@ - - -
- -
- diff --git a/core/modules/user/user-profile.tpl.php b/core/modules/user/user-profile.tpl.php index 940d47f..4bf9d5c 100644 --- a/core/modules/user/user-profile.tpl.php +++ b/core/modules/user/user-profile.tpl.php @@ -8,12 +8,10 @@ * e.g., example.com/user/123. 123 being the users ID. * * Use render($user_profile) to print all profile items, or print a subset - * 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['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. + * such as render($content['field_example']). + * 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 + * history. Other data can be included by modules. * * Available variables: * - $user_profile: An array of profile items. Use render() to print them. diff --git a/core/modules/user/user-rtl.css b/core/modules/user/user-rtl.css index 642c943..cb828e1 100644 --- a/core/modules/user/user-rtl.css +++ b/core/modules/user/user-rtl.css @@ -26,9 +26,3 @@ div.password-confirm { .password-parent { clear: right; } - -/* Generated by user.module but used by profile.module: */ -.profile .user-picture { - float: left; - margin: 0 0 1em 1em; -} diff --git a/core/modules/user/user.admin.inc b/core/modules/user/user.admin.inc index 8de4fb9..fec1f33 100644 --- a/core/modules/user/user.admin.inc +++ b/core/modules/user/user.admin.inc @@ -342,80 +342,6 @@ function user_admin_settings() { '#title' => t('Enable signatures.'), '#default_value' => variable_get('user_signatures', 0), ); - // If picture support is enabled, check whether the picture directory exists. - if (variable_get('user_pictures', 0)) { - $picture_path = file_default_scheme() . '://' . variable_get('user_picture_path', 'pictures'); - if (!file_prepare_directory($picture_path, FILE_CREATE_DIRECTORY)) { - form_set_error('user_picture_path', t('The directory %directory does not exist or is not writable.', array('%directory' => $picture_path))); - watchdog('file system', 'The directory %directory does not exist or is not writable.', array('%directory' => $picture_path), WATCHDOG_ERROR); - } - } - $picture_support = variable_get('user_pictures', 0); - $form['personalization']['user_pictures'] = array( - '#type' => 'checkbox', - '#title' => t('Enable user pictures.'), - '#default_value' => $picture_support, - ); - drupal_add_js(drupal_get_path('module', 'user') . '/user.js'); - $form['personalization']['pictures'] = array( - '#type' => 'container', - '#states' => array( - // Hide the additional picture settings when user pictures are disabled. - 'invisible' => array( - 'input[name="user_pictures"]' => array('checked' => FALSE), - ), - ), - ); - $form['personalization']['pictures']['user_picture_path'] = array( - '#type' => 'textfield', - '#title' => t('Picture directory'), - '#default_value' => variable_get('user_picture_path', 'pictures'), - '#size' => 30, - '#maxlength' => 255, - '#description' => t('Subdirectory in the file upload directory where pictures will be stored.'), - ); - $form['personalization']['pictures']['user_picture_default'] = array( - '#type' => 'textfield', - '#title' => t('Default picture'), - '#default_value' => variable_get('user_picture_default', ''), - '#size' => 30, - '#maxlength' => 255, - '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'), - ); - if (module_exists('image')) { - $form['personalization']['pictures']['settings']['user_picture_style'] = array( - '#type' => 'select', - '#title' => t('Picture display style'), - '#options' => image_style_options(TRUE), - '#default_value' => variable_get('user_picture_style', ''), - '#description' => t('The style selected will be used on display, while the original image is retained. Styles may be configured in the Image styles administration area.', array('!url' => url('admin/config/media/image-styles'))), - ); - } - $form['personalization']['pictures']['user_picture_dimensions'] = array( - '#type' => 'textfield', - '#title' => t('Picture upload dimensions'), - '#default_value' => variable_get('user_picture_dimensions', '85x85'), - '#size' => 10, - '#maxlength' => 10, - '#field_suffix' => ' ' . t('pixels'), - '#description' => t('Pictures larger than this will be scaled down to this size.'), - ); - $form['personalization']['pictures']['user_picture_file_size'] = array( - '#type' => 'number', - '#title' => t('Picture upload file size'), - '#default_value' => variable_get('user_picture_file_size', '30'), - '#size' => 10, - '#maxlength' => 10, - '#min' => 0, - '#field_suffix' => ' ' . t('KB'), - '#description' => t('Maximum allowed file size for uploaded pictures. Upload size is normally limited only by the PHP maximum post and file upload settings, and images are automatically scaled down to the dimensions specified above.'), - ); - $form['personalization']['pictures']['user_picture_guidelines'] = array( - '#type' => 'textarea', - '#title' => t('Picture guidelines'), - '#default_value' => variable_get('user_picture_guidelines', ''), - '#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."), - ); $form['email_title'] = array( '#type' => 'item', @@ -1030,4 +956,3 @@ function user_admin_role_delete_confirm_submit($form, &$form_state) { drupal_set_message(t('The role has been deleted.')); $form_state['redirect'] = 'admin/people/permissions/roles'; } - diff --git a/core/modules/user/user.api.php b/core/modules/user/user.api.php index 1b8a253..ec24eac 100644 --- a/core/modules/user/user.api.php +++ b/core/modules/user/user.api.php @@ -333,12 +333,17 @@ function hook_user_logout($account) { * @see hook_entity_view() */ function hook_user_view($account, $view_mode, $langcode) { - $account->content['user_picture'] = array( - '#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', + '#title' => t('History'), + '#attributes' => array('class' => array('user-member')), + '#weight' => 5, ); - $account->content['member_for'] = array( - '#type' => 'item', + $account->content['summary']['member_for'] = array( + '#type' => 'user_profile_item', '#title' => t('Member for'), '#markup' => format_interval(REQUEST_TIME - $account->created), ); diff --git a/core/modules/user/user.css b/core/modules/user/user.css index bbfeb83..d4c3252 100644 --- a/core/modules/user/user.css +++ b/core/modules/user/user.css @@ -77,26 +77,3 @@ div.password-suggestions ul { margin: 0; width: 36.3em; } - -/* Generated by user.module but used by profile.module: */ -.profile { - clear: both; - margin: 1em 0; -} -.profile .user-picture { - float: right; /* LTR */ - margin: 0 1em 1em 0; /* LTR */ -} -.profile h2 { - border-bottom: 1px solid #ccc; -} -.profile dl { - margin: 0 0 1.5em 0; -} -.profile dt { - margin: 0 0 0.2em 0; - font-weight: bold; -} -.profile dd { - margin: 0 0 1em 0; -} diff --git a/core/modules/user/user.install b/core/modules/user/user.install index ce11aaf..b307281 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -218,12 +218,6 @@ function user_schema() { 'default' => '', 'description' => 'The {language}.langcode that the user prefers for receiving emails and viewing the site.', ), - 'picture' => array( - 'type' => 'int', - 'not null' => TRUE, - 'default' => 0, - 'description' => "Foreign key: {file_managed}.fid of user's picture.", - ), 'init' => array( 'type' => 'varchar', 'length' => 254, @@ -243,7 +237,6 @@ function user_schema() { 'access' => array('access'), 'created' => array('created'), 'mail' => array('mail'), - 'picture' => array('picture'), ), 'unique keys' => array( 'name' => array('name'), @@ -399,5 +392,133 @@ function user_update_8001() { } /** + * Create user picture field. + */ +function user_update_8002() { + _user_install_picture_field(array( + 'user_pictures' => variable_get('user_pictures', 0), + 'user_picture_path' => variable_get('user_picture_path', 'pictures'), + 'user_picture_default' => variable_get('user_picture_default', ''), + 'user_picture_style' => variable_get('user_picture_style', ''), + 'user_picture_dimensions' => variable_get('user_picture_dimensions', '85x85'), + 'user_picture_file_size' => variable_get('user_picture_file_size', '30') .' KB', + 'user_picture_guidelines' => variable_get('user_picture_guidelines', ''), + )); + variable_del('user_picture_path'); + variable_del('user_picture_default'); + variable_del('user_picture_style'); + variable_del('user_picture_dimensions'); + variable_del('user_picture_file_size'); + variable_del('user_picture_guidelines'); +} + +/** + * Migrate user pictures to Field API. + */ +function user_update_8003(&$sandbox) { + // Initialize total values to process. + if (!isset($sandbox['total'])) { + $sandbox['total'] = (int) db_query('SELECT COUNT(picture) FROM {users} WHERE picture > 0')->fetchField(); + $sandbox['processed'] = 0; + } + + // Retrieve next 20 rows to migrate. + $results = db_query_range('SELECT uid, picture FROM {users} WHERE picture > 0', 0, 20)->fetchAllKeyed(); + if ($uids = array_keys($results)) { + // @todo Must not use API functions invoking hooks. + $accounts = user_load_multiple($uids); + foreach ($results as $uid => $fid) { + if ($file = file_load($fid)) { + $accounts[$uid]->field_user_picture[LANGUAGE_NONE][0] = (array) $file; + $accounts[$uid]->save(); + } + } + } + + // Report status. + $sandbox['processed'] += count($results); + $sandbox['#finished'] = $sandbox['total'] ? 1 - $sandbox['processed'] / $sandbox['total'] : 1; + + // Delete {users}.picture after processing all values. + if ($sandbox['#finished'] == 1) { + db_drop_field('users', 'picture'); + } +} + +/** * @} End of "addtogroup updates-7.x-to-8.x" */ + +/** + * Creates a "User picture" image field for the User entity. + */ +function _user_install_picture_field($config = array()) { + $config += array( + 'user_pictures' => 0, + 'user_picture_path' => 'pictures', + 'user_picture_default' => '', + 'user_picture_style' => 'thumbnail', + 'user_picture_dimensions' => '85x85', + 'user_picture_file_size' => '30 KB', + 'user_picture_guidelines' => '', + ); + + $field = array( + 'field_name' => 'field_user_picture', + 'module' => 'image', + 'type' => 'image', + 'cardinality' => 1, + 'locked' => FALSE, + 'indexes' => array('fid' => array('fid')), + 'settings' => array( + 'uri_scheme' => 'public', + 'default_image' => FALSE, + ), + 'storage' => array( + 'type' => 'field_sql_storage', + 'settings' => array(), + ), + ); + _update_7000_field_create_field($field); + + $instance = array( + 'field_name' => 'field_user_picture', + 'entity_type' => 'user', + 'label' => 'Picture', + 'bundle' => 'user', + 'description' => st('Your virtual face or picture.'), + 'required' => FALSE, + 'settings' => array( + 'file_extensions' => 'png gif jpg jpeg', + 'file_directory' => $config['user_picture_path'], + 'max_filesize' => $config['user_picture_file_size'], + 'alt_field' => 0, + 'title_field' => 0, + 'max_resolution' => $config['user_picture_dimensions'], + 'min_resolution' => '', + 'default_image' => $config['user_picture_default'], + ), + 'widget' => array( + 'module' => 'image', + 'type' => 'image_image', + 'settings' => array( + 'progress_indicator' => 'throbber', + 'preview_image_style' => 'medium', + ), + 'weight' => -1, + ), + 'display' => array( + 'default' => array( + 'label' => 'hidden', + 'type' => $config['user_pictures'] ? 'image' : 'hidden', + 'settings' => array('image_style' => 'medium', 'image_link' => 'content'), + ), + 'compact' => array( + 'label' => 'hidden', + 'type' => $config['user_pictures'] ? 'image' : 'hidden', + 'settings' => array('image_style' => $config['user_picture_style'], 'image_link' => 'content'), + ), + ), + ); + _update_7000_field_create_instance($field, $instance); +} diff --git a/core/modules/user/user.module b/core/modules/user/user.module index 4219728..7b02a6a 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -51,7 +51,7 @@ function user_help($path, $arg) { $output .= '
' . t('User roles and permissions') . '
'; $output .= '
' . t('Roles are used to group and classify users; each user can be assigned one or more roles. By default there are two roles: anonymous user (users that are not logged in) and authenticated user (users that are registered and logged in). Depending on choices you made when you installed Drupal, the installation process may have defined more roles, and you can create additional custom roles on the Roles page. After creating roles, you can set permissions for each role on the Permissions page. Granting a permission allows users who have been assigned a particular role to perform an action on the site, such as viewing a particular type of content, editing or creating content, administering settings for a particular module, or using a particular function of the site (such as search).', array('@permissions_user' => url('admin/people/permissions'), '@roles' => url('admin/people/permissions/roles'))) . '
'; $output .= '
' . t('Account settings') . '
'; - $output .= '
' . t('The Account settings page allows you to manage settings for the displayed name of the anonymous user role, personal contact forms, user registration, and account cancellation. On this page you can also manage settings for account personalization (including signatures and user pictures), and adapt the text for the e-mail messages that are sent automatically during the user registration process.', array('@accounts' => url('admin/config/people/accounts'))) . '
'; + $output .= '
' . t('The Account settings page allows you to manage settings for the displayed name of the anonymous user role, personal contact forms, user registration, and account cancellation. On this page you can also manage settings for account personalization (including signatures), and adapt the text for the e-mail messages that are sent automatically during the user registration process.', array('@accounts' => url('admin/config/people/accounts'))) . '
'; $output .= ''; return $output; case 'admin/people/create': @@ -104,10 +104,6 @@ function user_module_invoke($type, &$edit, $account) { */ function user_theme() { return array( - 'user_picture' => array( - 'variables' => array('account' => NULL), - 'template' => 'user-picture', - ), 'user_profile' => array( 'render element' => 'elements', 'template' => 'user-profile', @@ -167,6 +163,10 @@ function user_entity_info() { 'label' => t('User account'), 'custom settings' => FALSE, ), + 'compact' => array( + 'label' => t('Compact'), + 'custom settings' => TRUE, + ), ), ), ); @@ -199,6 +199,44 @@ function user_label($entity_type, $entity) { } /** + * Populates $entity->account for each prepared entity. + * + * Called by hook_entity_prepare_view() implementations. + * + * @param array $entities + * The entities keyed by entity ID. + */ +function user_attach_accounts(array $entities) { + $uids = array(); + foreach ($entities as $entity) { + $uids[] = $entity->uid; + } + $uids = array_unique($uids); + $accounts = user_load_multiple($uids); + $anonymous = drupal_anonymous_user(); + foreach ($entities as $id => $entity) { + if (isset($accounts[$entity->uid])) { + $entities[$id]->account = $accounts[$entity->uid]; + } + else { + $entities[$id]->account = $anonymous; + } + } +} + +/** + * Returns whether this site supports the default user picture feature. + * + * This approach preserves compatibility with node/comment templates. Alternate + * user picture implementations (e.g., Gravatar) should provide their own + * add/edit/delete forms and populate the 'picture' variable during the + * preprocess stage. + */ +function user_picture_enabled() { + return (bool) field_info_instance('user', 'field_user_picture', 'user'); +} + +/** * Implements hook_field_info_alter(). */ function user_field_info_alter(&$info) { @@ -391,29 +429,6 @@ function user_validate_name($name) { } /** - * Validates an image uploaded by a user. - * - * @see user_account_form() - */ -function user_validate_picture(&$form, &$form_state) { - // If required, validate the uploaded picture. - $validators = array( - 'file_validate_is_image' => array(), - 'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')), - 'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024), - ); - - // Save the file as a temporary file. - $file = file_save_upload('picture_upload', $validators); - if ($file === FALSE) { - form_set_error('picture_upload', t("Failed to upload the picture image; the %directory directory doesn't exist or is not writable.", array('%directory' => variable_get('user_picture_path', 'pictures')))); - } - elseif ($file !== NULL) { - $form_state['values']['picture_upload'] = $file; - } -} - -/** * Generate a random alphanumeric password. */ function user_password($length = 10) { @@ -578,45 +593,6 @@ function user_permission() { } /** - * Implements hook_file_download(). - * - * Ensure that user pictures (avatars) are always downloadable. - */ -function user_file_download($uri) { - if (strpos(file_uri_target($uri), variable_get('user_picture_path', 'pictures') . '/picture-') === 0) { - $info = image_get_info($uri); - return array('Content-Type' => $info['mime_type']); - } -} - -/** - * Implements hook_file_move(). - */ -function user_file_move($file, $source) { - // If a user's picture is replaced with a new one, update the record in - // the users table. - if (isset($file->fid) && isset($source->fid) && $file->fid != $source->fid) { - db_update('users') - ->fields(array( - 'picture' => $file->fid, - )) - ->condition('picture', $source->fid) - ->execute(); - } -} - -/** - * Implements hook_file_predelete(). - */ -function user_file_predelete($file) { - // Remove any references to the file. - db_update('users') - ->fields(array('picture' => 0)) - ->condition('picture', $file->fid) - ->execute(); -} - -/** * Implements hook_search_info(). */ function user_search_info() { @@ -676,10 +652,6 @@ function user_search_execute($keys = NULL, $conditions = NULL) { * Implements hook_user_view(). */ function user_user_view($account) { - $account->content['user_picture'] = array( - '#markup' => theme('user_picture', array('account' => $account)), - '#weight' => -10, - ); $account->content['member_for'] = array( '#type' => 'item', '#title' => t('Member for'), @@ -693,7 +665,6 @@ function user_user_view($account) { * * @see user_account_form_validate() * @see user_validate_current_pass() - * @see user_validate_picture() * @see user_validate_mail() */ function user_account_form(&$form, &$form_state) { @@ -842,34 +813,6 @@ function user_account_form(&$form, &$form_state) { '#format' => isset($account->signature_format) ? $account->signature_format : NULL, ); - // Picture/avatar. - $form['picture'] = array( - '#type' => 'fieldset', - '#title' => t('Picture'), - '#weight' => 1, - '#access' => (!$register && variable_get('user_pictures', 0)), - ); - $form['picture']['picture'] = array( - '#type' => 'value', - '#value' => isset($account->picture) ? $account->picture : NULL, - ); - $form['picture']['picture_current'] = array( - '#markup' => theme('user_picture', array('account' => $account)), - ); - $form['picture']['picture_delete'] = array( - '#type' => 'checkbox', - '#title' => t('Delete picture'), - '#access' => !empty($account->picture->fid), - '#description' => t('Check this box to delete your current picture.'), - ); - $form['picture']['picture_upload'] = array( - '#type' => 'file', - '#title' => t('Upload picture'), - '#size' => 48, - '#description' => t('Your virtual face or picture. Pictures larger than @dimensions pixels will be scaled down.', array('@dimensions' => variable_get('user_picture_dimensions', '85x85'))) . ' ' . filter_xss_admin(variable_get('user_picture_guidelines', '')), - ); - $form['#validate'][] = 'user_validate_picture'; - if (module_exists('language') && language_multilingual()) { $languages = language_list(); @@ -1215,55 +1158,6 @@ function user_format_name($account) { } /** - * Process variables for user-picture.tpl.php. - * - * The $variables array contains the following arguments: - * - $account: A user, node or comment object with 'name', 'uid' and 'picture' - * fields. - * - * @see user-picture.tpl.php - */ -function template_preprocess_user_picture(&$variables) { - $variables['user_picture'] = ''; - if (variable_get('user_pictures', 0)) { - $account = $variables['account']; - if (!empty($account->picture)) { - // @TODO: Ideally this function would only be passed file objects, but - // since there's a lot of legacy code that JOINs the {users} table to - // {node} or {comments} and passes the results into this function if we - // a numeric value in the picture field we'll assume it's a file id - // and load it for them. Once we've got user_load_multiple() and - // comment_load_multiple() functions the user module will be able to load - // the picture files in mass during the object's load process. - if (is_numeric($account->picture)) { - $account->picture = file_load($account->picture); - } - if (!empty($account->picture->uri)) { - $filepath = $account->picture->uri; - } - } - elseif (variable_get('user_picture_default', '')) { - $filepath = variable_get('user_picture_default', ''); - } - if (isset($filepath)) { - $alt = t("@user's picture", array('@user' => user_format_name($account))); - // If the image does not have a valid Drupal scheme (for eg. HTTP), - // don't load image styles. - if (module_exists('image') && file_valid_uri($filepath) && $style = variable_get('user_picture_style', '')) { - $variables['user_picture'] = theme('image_style', array('style_name' => $style, 'uri' => $filepath, 'alt' => $alt, 'title' => $alt)); - } - else { - $variables['user_picture'] = theme('image', array('uri' => $filepath, 'alt' => $alt, 'title' => $alt)); - } - if (!empty($account->uid) && user_access('access user profiles')) { - $attributes = array('attributes' => array('title' => t('View user profile.')), 'html' => TRUE); - $variables['user_picture'] = l($variables['user_picture'], "user/$account->uid", $attributes); - } - } - } -} - -/** * Preprocesses variables for theme_username(). * * Modules that make any changes to variables like 'name' or 'extra' must insure @@ -2335,8 +2229,6 @@ function user_view_page($account) { * * When viewing a user profile, the $page array contains: * - * - $page['content']['user_picture']: - * User's rendered picture. * - $page['content']['member_for']: * Contains the default "Member for" profile data for a user. * - $page['content']['#account']: @@ -3386,6 +3278,9 @@ function user_form_process_password_confirm($element) { /** * Implements hook_node_load(). + * + * @todo Deprecated by node_entity_prepare_view(). Update code that depends on + * these properties. */ function user_node_load($nodes, $types) { // Build an array of all uids for node authors, keyed by nid. @@ -3394,37 +3289,17 @@ function user_node_load($nodes, $types) { $uids[$nid] = $node->uid; } - // Fetch name, picture, and data for these users. - $user_fields = db_query("SELECT uid, name, picture, data FROM {users} WHERE uid IN (:uids)", array(':uids' => $uids))->fetchAllAssoc('uid'); + // Fetch name and data for these users. + $user_fields = db_query("SELECT uid, name, data FROM {users} WHERE uid IN (:uids)", array(':uids' => $uids))->fetchAllAssoc('uid'); // Add these values back into the node objects. foreach ($uids as $nid => $uid) { $nodes[$nid]->name = $user_fields[$uid]->name; - $nodes[$nid]->picture = $user_fields[$uid]->picture; $nodes[$nid]->data = $user_fields[$uid]->data; } } /** - * Implements hook_image_style_delete(). - */ -function user_image_style_delete($style) { - // If a style is deleted, update the variables. - // Administrators choose a replacement style when deleting. - user_image_style_save($style); -} - -/** - * Implements hook_image_style_save(). - */ -function user_image_style_save($style) { - // If a style is renamed, update the variables that use it. - if (isset($style['old_name']) && $style['old_name'] == variable_get('user_picture_style', '')) { - variable_set('user_picture_style', $style['name']); - } -} - -/** * Implements hook_action_info(). */ function user_action_info() { diff --git a/core/modules/user/user.test b/core/modules/user/user.test index c911088..b2bef53 100644 --- a/core/modules/user/user.test +++ b/core/modules/user/user.test @@ -168,7 +168,6 @@ class UserRegistrationTestCase extends DrupalWebTestCase { $this->assertEqual($new_user->timezone, variable_get('date_default_timezone'), t('Correct time zone field.')); $this->assertEqual($new_user->langcode, language_default()->langcode, t('Correct language field.')); $this->assertEqual($new_user->preferred_langcode, language_default()->langcode, t('Correct preferred language field.')); - $this->assertEqual($new_user->picture, 0, t('Correct picture field.')); $this->assertEqual($new_user->init, $mail, t('Correct init field.')); } @@ -919,315 +918,112 @@ class UserCancelTestCase extends DrupalWebTestCase { } } +/** + * Tests user picture functionality. + * + * @todo Test public and private methods? + */ class UserPictureTestCase extends DrupalWebTestCase { - protected $user; - protected $_directory_test; - public static function getInfo() { return array( - 'name' => 'Upload user picture', - 'description' => 'Assure that dimension check, extension check and image scaling work as designed.', - 'group' => 'User' + 'name' => 'User pictures', + 'description' => 'Tests user picture functionality.', + 'group' => 'User', ); } function setUp() { - parent::setUp(array('image')); - // Enable user pictures. - variable_set('user_pictures', 1); - - // Configure default user picture settings. - variable_set('user_picture_dimensions', '1024x1024'); - variable_set('user_picture_file_size', '800'); - variable_set('user_picture_style', 'thumbnail'); - - $this->user = $this->drupalCreateUser(); - - // Test if directories specified in settings exist in filesystem. - $file_dir = 'public://'; - $file_check = file_prepare_directory($file_dir, FILE_CREATE_DIRECTORY); - // TODO: Test public and private methods? - - $picture_dir = variable_get('user_picture_path', 'pictures'); - $picture_path = $file_dir . $picture_dir; - - $pic_check = file_prepare_directory($picture_path, FILE_CREATE_DIRECTORY); - $this->_directory_test = is_writable($picture_path); - $this->assertTrue($this->_directory_test, "The directory $picture_path doesn't exist or is not writable. Further tests won't be made."); - } - - function testNoPicture() { - $this->drupalLogin($this->user); - - // Try to upload a file that is not an image for the user picture. - $not_an_image = current($this->drupalGetTestFiles('html')); - $this->saveUserPicture($not_an_image); - $this->assertRaw(t('Only JPEG, PNG and GIF images are allowed.'), t('Non-image files are not accepted.')); - } - - /** - * Do the test: - * GD Toolkit is installed - * Picture has invalid dimension - * - * results: The image should be uploaded because ImageGDToolkit resizes the picture - */ - function testWithGDinvalidDimension() { - if ($this->_directory_test && image_get_toolkit()) { - $this->drupalLogin($this->user); - - $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->uri); - - // Set new variables: invalid dimensions, valid filesize (0 = no limit). - $test_dim = ($info['width'] - 10) . 'x' . ($info['height'] - 10); - variable_set('user_picture_dimensions', $test_dim); - variable_set('user_picture_file_size', 0); - - $pic_path = $this->saveUserPicture($image); - // Check that the image was resized and is being displayed on the - // user's profile page. - $text = t('The image was resized to fit within the maximum allowed dimensions of %dimensions pixels.', array('%dimensions' => $test_dim)); - $this->assertRaw($text, t('Image was resized.')); - $alt = t("@user's picture", array('@user' => user_format_name($this->user))); - $style = variable_get('user_picture_style', ''); - $this->assertRaw(image_style_url($style, $pic_path), t("Image is displayed in user's edit page")); - - // Check if file is located in proper directory. - $this->assertTrue(is_file($pic_path), t("File is located in proper directory")); - } - } - - /** - * Do the test: - * GD Toolkit is installed - * Picture has invalid size - * - * results: The image should be uploaded because ImageGDToolkit resizes the picture - */ - function testWithGDinvalidSize() { - if ($this->_directory_test && image_get_toolkit()) { - $this->drupalLogin($this->user); - - // Images are sorted first by size then by name. We need an image - // bigger than 1 KB so we'll grab the last one. - $files = $this->drupalGetTestFiles('image'); - $image = end($files); - $info = image_get_info($image->uri); - - // Set new variables: valid dimensions, invalid filesize. - $test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10); - $test_size = 1; - variable_set('user_picture_dimensions', $test_dim); - variable_set('user_picture_file_size', $test_size); - - $pic_path = $this->saveUserPicture($image); - - // Test that the upload failed and that the correct reason was cited. - $text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename)); - $this->assertRaw($text, t('Upload failed.')); - $text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->uri)), '%maxsize' => format_size($test_size * 1024))); - $this->assertRaw($text, t('File size cited as reason for failure.')); - - // Check if file is not uploaded. - $this->assertFalse(is_file($pic_path), t('File was not uploaded.')); - } - } - - /** - * Do the test: - * GD Toolkit is not installed - * Picture has invalid size - * - * results: The image shouldn't be uploaded - */ - function testWithoutGDinvalidDimension() { - if ($this->_directory_test && !image_get_toolkit()) { - $this->drupalLogin($this->user); - - $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->uri); + parent::setUp(array('image', 'comment')); - // Set new variables: invalid dimensions, valid filesize (0 = no limit). - $test_dim = ($info['width'] - 10) . 'x' . ($info['height'] - 10); - variable_set('user_picture_dimensions', $test_dim); - variable_set('user_picture_file_size', 0); - - $pic_path = $this->saveUserPicture($image); + $this->web_user = $this->drupalCreateUser(array( + 'access content', + 'access comments', + 'post comments', + 'skip comment approval', + )); + $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article')); - // Test that the upload failed and that the correct reason was cited. - $text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename)); - $this->assertRaw($text, t('Upload failed.')); - $text = t('The image is too large; the maximum dimensions are %dimensions pixels.', array('%dimensions' => $test_dim)); - $this->assertRaw($text, t('Checking response on invalid image (dimensions).')); + // @see standard.install + module_load_install('user'); + _user_install_picture_field(); - // Check if file is not uploaded. - $this->assertFalse(is_file($pic_path), t('File was not uploaded.')); - } + // Remove 'summary' pseudo-field from compact view mode on the User entity. + $bundle_settings = field_bundle_settings('user', 'user'); + $bundle_settings['extra_fields']['display']['member_for']['compact'] = array( + 'visible' => FALSE, + 'weight' => 10, + ); + field_bundle_settings('user', 'user', $bundle_settings); } /** - * Do the test: - * GD Toolkit is not installed - * Picture has invalid size - * - * results: The image shouldn't be uploaded + * Tests creation, display, and deletion of user pictures. */ - function testWithoutGDinvalidSize() { - if ($this->_directory_test && !image_get_toolkit()) { - $this->drupalLogin($this->user); - - $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->uri); + function testCreateDeletePicture() { + $this->drupalLogin($this->web_user); - // Set new variables: valid dimensions, invalid filesize. - $test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10); - $test_size = 1; - variable_set('user_picture_dimensions', $test_dim); - variable_set('user_picture_file_size', $test_size); + // Save a new picture. + $image = current($this->drupalGetTestFiles('image')); + $file = $this->saveUserPicture($image); - $pic_path = $this->saveUserPicture($image); + // Verify that the image is displayed on the user account page. + $this->drupalGet('user'); + $this->assertRaw(file_uri_target($file->uri), t('User picture found on user account page.')); - // Test that the upload failed and that the correct reason was cited. - $text = t('The specified file %filename could not be uploaded.', array('%filename' => $image->filename)); - $this->assertRaw($text, t('Upload failed.')); - $text = t('The file is %filesize exceeding the maximum file size of %maxsize.', array('%filesize' => format_size(filesize($image->uri)), '%maxsize' => format_size($test_size * 1024))); - $this->assertRaw($text, t('File size cited as reason for failure.')); + // Delete the picture. + $edit = array(); + $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Remove')); + $this->drupalPost(NULL, array(), t('Save')); - // Check if file is not uploaded. - $this->assertFalse(is_file($pic_path), t('File was not uploaded.')); - } + // Verify that the image has been deleted. + $this->assertFalse(file_load($file->fid), 'File was removed from the database.'); + // Clear out PHP's file stat cache so we see the current value. + clearstatcache(); + $this->assertFalse(is_file($file->uri), 'File was removed from the file system.'); } /** - * Do the test: - * Picture is valid (proper size and dimension) - * - * results: The image should be uploaded + * Tests embedded users on node pages. */ - function testPictureIsValid() { - if ($this->_directory_test) { - $this->drupalLogin($this->user); - - $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->uri); - - // Set new variables: valid dimensions, valid filesize (0 = no limit). - $test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10); - variable_set('user_picture_dimensions', $test_dim); - variable_set('user_picture_file_size', 0); + function testPictureOnNodeComment() { + $this->drupalLogin($this->web_user); - $pic_path = $this->saveUserPicture($image); + // Save a new picture. + $image = current($this->drupalGetTestFiles('image')); + $file = $this->saveUserPicture($image); - // Check if image is displayed in user's profile page. - $this->drupalGet('user'); - $this->assertRaw(file_uri_target($pic_path), t("Image is displayed in user's profile page")); + $node = $this->drupalCreateNode(array('type' => 'article')); - // Check if file is located in proper directory. - $this->assertTrue(is_file($pic_path), t('File is located in proper directory')); + // Enable user pictures on nodes. + variable_set('theme_settings', array('toggle_node_user_picture' => TRUE)); - // Set new picture dimensions. - $test_dim = ($info['width'] + 5) . 'x' . ($info['height'] + 5); - variable_set('user_picture_dimensions', $test_dim); + // Verify that the image is displayed on the user account page. + $this->drupalGet('node/' . $node->nid); + $this->assertRaw(file_uri_target($file->uri), 'User picture found on node page.'); - $pic_path2 = $this->saveUserPicture($image); - $this->assertNotEqual($pic_path, $pic_path2, t('Filename of second picture is different.')); - } - } + // Enable user pictures on comments, instead of nodes. + variable_set('theme_settings', array('toggle_comment_user_picture' => TRUE)); - /** - * Test HTTP schema working with user pictures. - */ - function testExternalPicture() { - $this->drupalLogin($this->user); - // Set the default picture to an URI with a HTTP schema. - $images = $this->drupalGetTestFiles('image'); - $image = $images[0]; - $pic_path = file_create_url($image->uri); - variable_set('user_picture_default', $pic_path); - - // Check if image is displayed in user's profile page. - $this->drupalGet('user'); - - // Get the user picture image via xpath. - $elements = $this->xpath('//div[@class="user-picture"]/img'); - $this->assertEqual(count($elements), 1, t("There is exactly one user picture on the user's profile page")); - $this->assertEqual($pic_path, (string) $elements[0]['src'], t("User picture source is correct: " . $pic_path . " " . print_r($elements, TRUE))); + $edit = array( + 'comment_body[' . LANGUAGE_NOT_SPECIFIED . '][0][value]' => $this->randomString(), + ); + $this->drupalPost('comment/reply/' . $node->nid, $edit, t('Save')); + $this->assertRaw(file_uri_target($file->uri), 'User picture found on comment.'); } /** - * Tests deletion of user pictures. + * Edits the user picture for the test user. */ - function testDeletePicture() { - $this->drupalLogin($this->user); - - $image = current($this->drupalGetTestFiles('image')); - $info = image_get_info($image->uri); - - // Set new variables: valid dimensions, valid filesize (0 = no limit). - $test_dim = ($info['width'] + 10) . 'x' . ($info['height'] + 10); - variable_set('user_picture_dimensions', $test_dim); - variable_set('user_picture_file_size', 0); - - // Save a new picture. - $edit = array('files[picture_upload]' => drupal_realpath($image->uri)); - $this->drupalPost('user/' . $this->user->uid . '/edit', $edit, t('Save')); - - // Load actual user data from database. - $account = user_load($this->user->uid, TRUE); - $pic_path = !empty($account->picture) ? $account->picture->uri : NULL; - - // Check if image is displayed in user's profile page. - $this->drupalGet('user'); - $this->assertRaw(file_uri_target($pic_path), "Image is displayed in user's profile page"); - - // Check if file is located in proper directory. - $this->assertTrue(is_file($pic_path), 'File is located in proper directory'); - - $edit = array('picture_delete' => 1); - $this->drupalPost('user/' . $this->user->uid . '/edit', $edit, t('Save')); - - // Load actual user data from database. - $account1 = user_load($this->user->uid, TRUE); - $this->assertFalse($account1->picture, 'User object has no picture'); - - $file = file_load($account->picture->fid); - $this->assertFalse($file, 'File is removed from database'); - - // Clear out PHP's file stat cache so we see the current value. - clearstatcache(); - $this->assertFalse(is_file($pic_path), 'File is removed from file system'); - } - function saveUserPicture($image) { - $edit = array('files[picture_upload]' => drupal_realpath($image->uri)); - $this->drupalPost('user/' . $this->user->uid . '/edit', $edit, t('Save')); + $edit = array('files[field_user_picture_und_0]' => drupal_realpath($image->uri)); + $this->drupalPost('user/' . $this->web_user->uid . '/edit', $edit, t('Save')); // Load actual user data from database. - $account = user_load($this->user->uid, TRUE); - return !empty($account->picture) ? $account->picture->uri : NULL; - } - - /** - * Tests the admin form validates user picture settings. - */ - function testUserPictureAdminFormValidation() { - $this->drupalLogin($this->drupalCreateUser(array('administer users'))); - - // The default values are valid. - $this->drupalPost('admin/config/people/accounts', array(), t('Save configuration')); - $this->assertText(t('The configuration options have been saved.'), 'The default values are valid.'); - - // The form does not save with an invalid file size. - $edit = array( - 'user_picture_file_size' => $this->randomName(), - ); - $this->drupalPost('admin/config/people/accounts', $edit, t('Save configuration')); - $this->assertNoText(t('The configuration options have been saved.'), 'The form does not save with an invalid file size.'); + $account = user_load($this->web_user->uid, TRUE); + return file_load($account->field_user_picture[LANGUAGE_NOT_SPECIFIED][0]['fid']); } } - class UserPermissionsTestCase extends DrupalWebTestCase { protected $admin_user; protected $rid; diff --git a/core/themes/bartik/css/style-rtl.css b/core/themes/bartik/css/style-rtl.css index 90638eb..19ed3f6 100644 --- a/core/themes/bartik/css/style-rtl.css +++ b/core/themes/bartik/css/style-rtl.css @@ -84,9 +84,9 @@ ul.tips { /* ----------------- Content ------------------ */ -.submitted .user-picture img { +.submitted .field-name-field-user-picture img { float: right; - margin-left: 5px; + margin-left: 20px; margin-right: 0; } .field-type-taxonomy-term-reference .field-label { @@ -105,7 +105,7 @@ ul.tips { /* ----------------- Comments ----------------- */ -.comment .user-picture img { +.comment .field-name-field-user-picture img { margin-right: 0; } .comment .attribution { diff --git a/core/themes/bartik/css/style.css b/core/themes/bartik/css/style.css index 7ab3d4e..651cfc3 100644 --- a/core/themes/bartik/css/style.css +++ b/core/themes/bartik/css/style.css @@ -595,10 +595,9 @@ h1#page-title { color: #68696b; margin-bottom: -5px; } -.submitted .user-picture img { +.submitted .field-name-field-user-picture img { float: left; /* LTR */ - height: 20px; - margin: 1px 5px 0 0; /* LTR */ + margin: 1px 20px 0 0; /* LTR */ } .field-type-taxonomy-term-reference { margin: 0 0 1.2em; @@ -630,7 +629,7 @@ h1#page-title { text-align: right; } .field-type-image img, -.user-picture img { +.field-name-field-user-picture img { margin: 0 0 1em; } ul.links { @@ -651,7 +650,7 @@ ul.links { .comment h2.title { margin-bottom: 1em; } -.comment div.user-picture img { +.comment .field-name-field-user-picture img { margin-left: 0; /* LTR */ } .comment { @@ -1029,7 +1028,7 @@ div.messages { /* -------------- User Profile -------------- */ -.profile .user-picture { +.profile .field-name-field-user-picture { float: none; } diff --git a/core/themes/bartik/templates/comment.tpl.php b/core/themes/bartik/templates/comment.tpl.php index 0b70594..8361a3e 100644 --- a/core/themes/bartik/templates/comment.tpl.php +++ b/core/themes/bartik/templates/comment.tpl.php @@ -20,7 +20,6 @@ * - $permalink: Comment permalink. * - $submitted: Submission information created from $author and $created * during template_preprocess_comment(). - * - $picture: Authors picture. * - $signature: Authors signature. * - $status: Comment status. Possible values are: * unpublished, published, or preview. @@ -64,7 +63,7 @@
- +

diff --git a/core/themes/bartik/templates/node.tpl.php b/core/themes/bartik/templates/node.tpl.php index 318197c..ef869e6 100644 --- a/core/themes/bartik/templates/node.tpl.php +++ b/core/themes/bartik/templates/node.tpl.php @@ -10,7 +10,7 @@ * or print a subset such as render($content['field_example']). Use * hide($content['field_example']) to temporarily suppress the printing of a * given element. - * - $user_picture: The node author's picture from user-picture.tpl.php. + * - $user_picture: The node author's picture. Use render() when printing. * - $date: Formatted creation date. Preprocess functions can reformat it by * calling format_date() with the desired parameters on the $created * variable. @@ -93,7 +93,7 @@

diff --git a/core/update.php b/core/update.php index 9797833..c426a47 100644 --- a/core/update.php +++ b/core/update.php @@ -184,7 +184,8 @@ function update_results_page() { $output = '

Updates were attempted. If you see no failures below, you may proceed happily back to your site. Otherwise, you may need to update your database manually.' . $log_message . '

'; } else { - list($module, $version) = array_pop(reset($_SESSION['updates_remaining'])); + $last = reset($_SESSION['updates_remaining']); + list($module, $version) = array_pop($last); $output = '

The update process was aborted prematurely while running update #' . $version . ' in ' . $module . '.module.' . $log_message; if (module_exists('dblog')) { $output .= ' You may need to check the watchdog database table manually.'; diff --git a/profiles/standard/standard.install b/profiles/standard/standard.install index 30a943b..fe008b7 100644 --- a/profiles/standard/standard.install +++ b/profiles/standard/standard.install @@ -273,12 +273,6 @@ function standard_install() { // Don't display date and author information for "Basic page" nodes by default. variable_set('node_submitted_page', FALSE); - // Enable user picture support and set the default to a square thumbnail option. - variable_set('user_pictures', '1'); - variable_set('user_picture_dimensions', '1024x1024'); - variable_set('user_picture_file_size', '800'); - variable_set('user_picture_style', 'thumbnail'); - // Allow visitor account creation with administrative approval. variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL); @@ -402,6 +396,17 @@ function standard_install() { ); field_create_instance($instance); + // Create user picture field. + module_load_install('user'); + _user_install_picture_field(); + // Remove 'summary' pseudo-field from compact view mode on the User entity. + $bundle_settings = field_bundle_settings('user', 'user'); + $bundle_settings['extra_fields']['display']['member_for']['compact'] = array( + 'visible' => FALSE, + 'weight' => 10, + ); + field_bundle_settings('user', 'user', $bundle_settings); + // Enable default permissions for system roles. $filtered_html_permission = filter_permission_name($filtered_html_format); user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content', 'access comments', $filtered_html_permission));