Commit b715220a authored by Dries's avatar Dries

- Patch #301071 by fago, andypost, joachim, Damien Tournoud: remove profile...

- Patch #301071 by fago, andypost, joachim, Damien Tournoud: remove profile module from core. Die profile module, die! RIP.
parent 05219169
<?php
/**
* @file
* Default theme implementation for displaying a users profile within a
* block. It only shows in relation to a node displayed as a full page.
*
* Available variables:
* - $user_picture: Image configured for the account linking to the users page.
* - $profile: Keyed array of all profile fields that have a value.
*
* Each $field in $profile contains:
* - $field->title: Title of the profile field.
* - $field->value: Value of the profile field.
* - $field->type: Type of the profile field, i.e., checkbox, textfield,
* textarea, selection, list, url or date.
*
* Since $profile is keyed, a direct print of the field is possible. Not
* all accounts may have a value for a profile so do a check first. If a field
* of "last_name" was set for the site, the following can be used.
*
* <?php if (isset($profile['last_name'])): ?>
* <div class="field last-name">
* <?php print $profile['last_name']->title; ?>:<br />
* <?php print $profile['last_name']->value; ?>
* </div>
* <?php endif; ?>
*
* @see template_preprocess_profile_block()
*/
?>
<?php print $user_picture; ?>
<?php foreach ($profile as $field) : ?>
<p>
<?php if ($field->type != 'checkbox') : ?>
<strong><?php print $field->title; ?></strong><br />
<?php endif; ?>
<?php print $field->value; ?>
</p>
<?php endforeach; ?>
<?php
/**
* @file
* Default theme implementation for displaying a user and their profile data
* for member listing pages.
*
* @see profile-wrapper.tpl.php
* where all the data is collected and printed out.
*
* Available variables:
* - $account: User's account object.
* - $user_picture: Image configured for the account linking to the users page.
* - $name: User's account name linking to the users page.
* - $profile: Keyed array of all profile fields that are set as visible
* in member list pages (configured by site administrators). It also needs
* to have a value in order to be present.
*
* Each $field in $profile contains:
* - $field->title: Title of the profile field.
* - $field->value: Value of the profile field.
* - $field->type: Type of the profile field, i.e., checkbox, textfield,
* textarea, selection, list, url or date.
*
* Since $profile is keyed, a direct print of the field is possible. Not
* all accounts may have a value for a profile so do a check first. If a field
* of "last_name" was set for the site, the following can be used.
*
* <?php if (isset($profile['last_name'])): ?>
* <div class="field last-name">
* <?php print $profile['last_name']->title; ?>:<br />
* <?php print $profile['last_name']->value; ?>
* </div>
* <?php endif; ?>
*
* @see template_preprocess_profile_listing()
*/
?>
<div class="profile clearfix">
<?php print $user_picture; ?>
<div class="name">
<?php print $name; ?>
</div>
<?php foreach ($profile as $field) : ?>
<div class="field">
<?php print $field->value; ?>
</div>
<?php endforeach; ?>
</div>
<?php
/**
* @file
* Default theme implementation for wrapping member listings and their
* profiles.
*
* This template is used when viewing a list of users. It can be a general
* list for viewing all users with the url of "example.com/profile" or when
* viewing a set of users who share a specific value for a profile such
* as "example.com/profile/country/belgium".
*
* Available variables:
* - $content: User account profiles iterated through profile-listing.tpl.php.
* - $current_field: The named field being browsed. Provided here for context.
* The above example would result in "last_name". An alternate template name
* is also based on this, e.g., "profile-wrapper-last_name.tpl.php".
*
* @see template_preprocess_profile_wrapper()
*/
?>
<div id="profile">
<?php print $content; ?>
</div>
This diff is collapsed.
#profile-fields td.category {
font-weight: bold;
}
#profile-fields tr.category-message {
color: #999;
}
#profile-fields tr.category-populated {
display: none;
}
name = Profile
description = Supports configurable user profiles.
package = Core
version = VERSION
core = 8.x
files[] = profile.test
configure = admin/config/people/profile
; The Profile module is deprecated, and included in Drupal 7 for legacy
; purposes only. By default, the module will be hidden from the UI unless you
; are upgrading a site that uses the Profile module to extend user profiles.
; See user_system_info_alter().
hidden = TRUE
<?php
/**
* @file
* Install, update and uninstall functions for the profile module.
*/
/**
* Implements hook_uninstall().
*/
function profile_uninstall() {
variable_del('profile_block_author_fields');
}
/**
* Implements hook_schema().
*/
function profile_schema() {
$schema['profile_field'] = array(
'description' => 'Stores profile field information.',
'fields' => array(
'fid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique profile field ID.',
),
'title' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'Title of the field shown to the end user.',
),
'name' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Internal name of the field used in the form HTML and URLs.',
),
'explanation' => array(
'type' => 'text',
'not null' => FALSE,
'description' => 'Explanation of the field to end users.',
),
'category' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => 'Profile category that the field will be grouped under.',
),
'page' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
'description' => "Title of page used for browsing by the field's value",
),
'type' => array(
'type' => 'varchar',
'length' => 128,
'not null' => FALSE,
'description' => 'Type of form field.',
),
'weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Weight of field in relation to other profile fields.',
),
'required' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Whether the user is required to enter a value. (0 = no, 1 = yes)',
),
'register' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Whether the field is visible in the user registration form. (1 = yes, 0 = no)',
),
'visibility' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The level of visibility for the field. (0 = hidden, 1 = private, 2 = public on profile but not member list pages, 3 = public on profile and list pages)',
),
'autocomplete' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'Whether form auto-completion is enabled. (0 = disabled, 1 = enabled)',
),
'options' => array(
'type' => 'text',
'not null' => FALSE,
'description' => 'List of options to be used in a list selection field.',
),
),
'indexes' => array(
'category' => array('category'),
),
'unique keys' => array(
'name' => array('name'),
),
'primary key' => array('fid'),
);
$schema['profile_value'] = array(
'description' => 'Stores values for profile fields.',
'fields' => array(
'fid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {profile_field}.fid of the field.',
),
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'description' => 'The {users}.uid of the profile user.',
),
'value' => array(
'type' => 'text',
'not null' => FALSE,
'description' => 'The value for the field.',
),
),
'primary key' => array('uid', 'fid'),
'indexes' => array(
'fid' => array('fid'),
),
'foreign keys' => array(
'profile_field' => array(
'table' => 'profile_field',
'columns' => array('fid' => 'fid'),
),
'profile_user' => array(
'table' => 'users',
'columns' => array('uid' => 'uid'),
),
),
);
return $schema;
}
(function ($) {
/**
* Add functionality to the profile drag and drop table.
*
* This behavior is dependent on the tableDrag behavior, since it uses the
* objects initialized in that behavior to update the row. It shows and hides
* a warning message when removing the last field from a profile category.
*/
Drupal.behaviors.profileDrag = {
attach: function (context, settings) {
var table = $('#profile-fields');
var tableDrag = Drupal.tableDrag['profile-fields']; // Get the profile tableDrag object.
// Add a handler for when a row is swapped, update empty categories.
tableDrag.row.prototype.onSwap = function (swappedRow) {
var rowObject = this;
$('tr.category-message', table).each(function () {
// If the dragged row is in this category, but above the message row, swap it down one space.
if ($(this).prev('tr').get(0) == rowObject.element) {
// Prevent a recursion problem when using the keyboard to move rows up.
if ((rowObject.method != 'keyboard' || rowObject.direction == 'down')) {
rowObject.swap('after', this);
}
}
// This category has become empty
if ($(this).next('tr').is(':not(.draggable)') || $(this).next('tr').size() == 0) {
$(this).removeClass('category-populated').addClass('category-empty');
}
// This category has become populated.
else if ($(this).is('.category-empty')) {
$(this).removeClass('category-empty').addClass('category-populated');
}
});
};
// Add a handler so when a row is dropped, update fields dropped into new categories.
tableDrag.onDrop = function () {
dragObject = this;
if ($(dragObject.rowObject.element).prev('tr').is('.category-message')) {
var categoryRow = $(dragObject.rowObject.element).prev('tr').get(0);
var categoryNum = categoryRow.className.replace(/([^ ]+[ ]+)*category-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
var categoryField = $('select.profile-category', dragObject.rowObject.element);
var weightField = $('select.profile-weight', dragObject.rowObject.element);
var oldcategoryNum = weightField[0].className.replace(/([^ ]+[ ]+)*profile-weight-([^ ]+)([ ]+[^ ]+)*/, '$2');
if (!categoryField.is('.profile-category-' + categoryNum)) {
categoryField.removeClass('profile-category-' + oldcategoryNum).addClass('profile-category-' + categoryNum);
weightField.removeClass('profile-weight-' + oldcategoryNum).addClass('profile-weight-' + categoryNum);
categoryField.val(categoryField[0].options[categoryNum].value);
}
}
};
}
};
})(jQuery);
This diff is collapsed.
<?php
/**
* @file
* User page callbacks for the profile module.
*/
/**
* Menu callback; display a list of user information.
*/
function profile_browse() {
// Ensure that the path is converted to 3 levels always.
list(, $name, $value) = array_pad(explode('/', $_GET['q'], 3), 3, '');
$field = db_query("SELECT DISTINCT(fid), type, title, page, visibility FROM {profile_field} WHERE name = :name", array(':name' => $name))->fetchObject();
if ($name && $field->fid) {
// Only allow browsing of fields that have a page title set.
if (empty($field->page)) {
drupal_not_found();
return;
}
// Do not allow browsing of private and hidden fields by non-admins.
if (!user_access('administer users') && ($field->visibility == PROFILE_PRIVATE || $field->visibility == PROFILE_HIDDEN)) {
drupal_access_denied();
return;
}
// Compile a list of fields to show.
$fields = db_query('SELECT name, title, type, weight, page FROM {profile_field} WHERE fid <> :fid AND visibility = :visibility ORDER BY weight', array(
':fid' => $field->fid,
':visibility' => PROFILE_PUBLIC_LISTINGS,
))->fetchAll();
$query = db_select('users', 'u')->extend('PagerDefault');
$query->join('profile_value', 'v', 'u.uid = v.uid');
$query
->fields('u', array('uid', 'access'))
->condition('v.fid', $field->fid)
->condition('u.status', 0, '<>')
->orderBy('u.access', 'DESC');
// Determine what query to use:
$arguments = array($field->fid);
switch ($field->type) {
case 'checkbox':
$query->condition('v.value', 1);
break;
case 'textfield':
case 'selection':
$query->condition('v.value', $value);
break;
case 'list':
$query->condition('v.value', '%' . db_like($value) . '%', 'LIKE');
break;
default:
drupal_not_found();
return;
}
$uids = $query
->limit(20)
->execute()
->fetchCol();
// Load the users.
$users = user_load_multiple($uids);
$content = '';
foreach ($users as $account) {
$profile = _profile_update_user_fields($fields, $account);
$content .= theme('profile_listing', array('account' => $account, 'fields' => $profile));
}
$output = theme('profile_wrapper', array('content' => $content));
$output .= theme('pager');
if ($field->type == 'selection' || $field->type == 'list' || $field->type == 'textfield') {
$title = strtr(check_plain($field->page), array('%value' => drupal_placeholder($value)));
}
else {
$title = check_plain($field->page);
}
drupal_set_title($title, PASS_THROUGH);
return $output;
}
elseif ($name && !$field->fid) {
drupal_not_found();
}
else {
// Compile a list of fields to show.
$fields = db_query('SELECT name, title, type, weight, page, visibility FROM {profile_field} WHERE visibility = :visibility ORDER BY category, weight', array(':visibility' => PROFILE_PUBLIC_LISTINGS))->fetchAll();
// Extract the affected users:
$query = db_select('users', 'u')->extend('PagerDefault');
$uids = $query
->fields('u', array('uid', 'access'))
->condition('u.uid', 0, '>')
->condition('u.status', 0, '>')
->orderBy('u.access', 'DESC')
->limit(20)
->execute()
->fetchCol();
$users = user_load_multiple($uids);
$content = '';
foreach ($users as $account) {
$profile = _profile_update_user_fields($fields, $account);
$content .= theme('profile_listing', array('account' => $account, 'fields' => $profile));
}
$output = theme('profile_wrapper', array('content' => $content));
$output .= theme('pager');
drupal_set_title(t('User list'));
return $output;
}
}
/**
* Callback to allow autocomplete of profile text fields.
*/
function profile_autocomplete($field, $string) {
$matches = array();
$autocomplete_field = (bool) db_query_range("SELECT 1 FROM {profile_field} WHERE fid = :fid AND autocomplete = 1", 0, 1, array(':fid' => $field))->fetchField();
if ($autocomplete_field) {
$values = db_select('profile_value')
->fields('profile_value', array('value'))
->condition('fid', $field)
->condition('value', db_like($string) . '%', 'LIKE')
->groupBy('value')
->orderBy('value')
->range(0, 10)
->execute()->fetchCol();
foreach ($values as $value) {
$matches[$value] = check_plain($value);
}
}
drupal_json_output($matches);
}
This diff is collapsed.
......@@ -3907,27 +3907,3 @@ function user_file_download_access($field, $entity_type, $entity) {
return user_view_access($entity);
}
}
/**
* Implements hook_system_info_alter().
*
* Drupal 7 ships with two methods to add additional fields to users: Profile
* module, a legacy module dating back from 2002, and Field API integration
* with users. While Field API support for users currently provides less end
* user features, the inefficient data storage mechanism of Profile module, as
* well as its lack of consistency with the rest of the entity / field based
* systems in Drupal 7, make this a sub-optimal solution to those who were not
* using it in previous releases of Drupal.
*
* To prevent new Drupal 7 sites from installing Profile module, and
* unwittingly ending up with two completely different and incompatible methods
* of extending users, only make the Profile module available if the profile_*
* tables are present.
*
* @todo: Remove in D8, pending upgrade path.
*/
function user_system_info_alter(&$info, $file, $type) {
if ($type == 'module' && $file->name == 'profile' && db_table_exists('profile_field')) {
$info['hidden'] = FALSE;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment