summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2011-08-26 10:41:22 (GMT)
committer Dries Buytaert2011-08-26 10:41:22 (GMT)
commitb715220acb9eb997dbf9a11cb8e5d2dd41d2dd80 (patch)
tree42f0d146893f15b9b1215028bce61ed84081f5e0
parent052191691ab6eaf767a552e6c422f8059169d647 (diff)
- Patch #301071 by fago, andypost, joachim, Damien Tournoud: remove profile module from core. Die profile module, die! RIP.
-rw-r--r--modules/profile/profile-block.tpl.php41
-rw-r--r--modules/profile/profile-listing.tpl.php52
-rw-r--r--modules/profile/profile-wrapper.tpl.php24
-rw-r--r--modules/profile/profile.admin.inc446
-rw-r--r--modules/profile/profile.css10
-rw-r--r--modules/profile/profile.info12
-rw-r--r--modules/profile/profile.install152
-rw-r--r--modules/profile/profile.js58
-rw-r--r--modules/profile/profile.module628
-rw-r--r--modules/profile/profile.pages.inc139
-rw-r--r--modules/profile/profile.test490
-rw-r--r--modules/user/user.module24
12 files changed, 0 insertions, 2076 deletions
diff --git a/modules/profile/profile-block.tpl.php b/modules/profile/profile-block.tpl.php
deleted file mode 100644
index 0bd8331..0000000
--- a/modules/profile/profile-block.tpl.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?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; ?>
diff --git a/modules/profile/profile-listing.tpl.php b/modules/profile/profile-listing.tpl.php
deleted file mode 100644
index d484ed2..0000000
--- a/modules/profile/profile-listing.tpl.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?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>
diff --git a/modules/profile/profile-wrapper.tpl.php b/modules/profile/profile-wrapper.tpl.php
deleted file mode 100644
index 997ab98..0000000
--- a/modules/profile/profile-wrapper.tpl.php
+++ /dev/null
@@ -1,24 +0,0 @@
-<?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>
diff --git a/modules/profile/profile.admin.inc b/modules/profile/profile.admin.inc
deleted file mode 100644
index d6ac3c3..0000000
--- a/modules/profile/profile.admin.inc
+++ /dev/null
@@ -1,446 +0,0 @@
-<?php
-
-/**
- * @file
- * Administrative page callbacks for the profile module.
- */
-
-/**
- * Form builder to display a listing of all editable profile fields.
- *
- * @ingroup forms
- * @see profile_admin_overview_submit()
- */
-function profile_admin_overview($form) {
- $result = db_query('SELECT title, name, type, category, fid, weight FROM {profile_field} ORDER BY category, weight');
-
- $categories = array();
- foreach ($result as $field) {
- // Collect all category information
- $categories[] = $field->category;
-
- // Save all field information
- $form[$field->fid]['name'] = array('#markup' => check_plain($field->name));
- $form[$field->fid]['title'] = array('#markup' => check_plain($field->title));
- $form[$field->fid]['type'] = array('#markup' => $field->type);
- $form[$field->fid]['category'] = array(
- '#type' => 'select',
- '#title' => t('Category for @title', array('@title' => $field->title)),
- '#title_display' => 'invisible',
- '#default_value' => $field->category,
- '#options' => array(),
- );
- $form[$field->fid]['weight'] = array(
- '#type' => 'weight',
- '#title' => t('Weight for @title', array('@title' => $field->title)),
- '#title_display' => 'invisible',
- '#default_value' => $field->weight,
- );
- $form[$field->fid]['edit'] = array('#type' => 'link', '#title' => t('edit'), '#href' => "admin/config/people/profile/edit/$field->fid");
- $form[$field->fid]['delete'] = array('#type' => 'link', '#title' => t('delete'), '#href' => "admin/config/people/profile/delete/$field->fid");
- }
-
- // Add the category combo boxes
- $categories = array_unique($categories);
- foreach ($form as $fid => $field) {
- foreach ($categories as $cat => $category) {
- $form[$fid]['category']['#options'][$category] = $category;
- }
- }
-
- // Display the submit button only when there's more than one field
- if (count($form) > 1) {
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
- }
- else {
- // Disable combo boxes when there isn't a submit button
- foreach ($form as $fid => $field) {
- unset($form[$fid]['weight']);
- $form[$fid]['category']['#type'] = 'value';
- }
- }
- $form['#tree'] = TRUE;
-
- // @todo: Any reason this isn't done using an element with #theme = 'links'?
- $addnewfields = '<h2>' . t('Add new field') . '</h2>';
- $addnewfields .= '<ul>';
- foreach (_profile_field_types() as $key => $value) {
- $addnewfields .= '<li>' . l($value, "admin/config/people/profile/add/$key") . '</li>';
- }
- $addnewfields .= '</ul>';
- $form['addnewfields'] = array('#markup' => $addnewfields);
-
- return $form;
-}
-
-/**
- * Submit handler to update changed profile field weights and categories.
- *
- * @see profile_admin_overview()
- */
-function profile_admin_overview_submit($form, &$form_state) {
- foreach (element_children($form_state['values']) as $fid) {
- if (is_numeric($fid)) {
- $weight = $form_state['values'][$fid]['weight'];
- $category = $form_state['values'][$fid]['category'];
- if ($weight != $form[$fid]['weight']['#default_value'] || $category != $form[$fid]['category']['#default_value']) {
- db_update('profile_field')
- ->fields(array(
- 'weight' => $weight,
- 'category' => $category,
- ))
- ->condition('fid', $fid)
- ->execute();
- }
- }
- }
-
- drupal_set_message(t('Profile fields have been updated.'));
- cache_clear_all();
- menu_rebuild();
-}
-
-/**
- * Returns HTML for the profile field overview form into a drag and drop enabled table.
- *
- * @param $variables
- * An associative array containing:
- * - form: A render element representing the form.
- *
- * @see profile_admin_overview()
- * @ingroup themeable
- */
-function theme_profile_admin_overview($variables) {
- $form = $variables['form'];
-
- drupal_add_css(drupal_get_path('module', 'profile') . '/profile.css');
- // Add javascript if there's more than one field.
- if (isset($form['actions'])) {
- drupal_add_js(drupal_get_path('module', 'profile') . '/profile.js');
- }
-
- $rows = array();
- $categories = array();
- $category_number = 0;
- foreach (element_children($form) as $key) {
- // Don't take form control structures.
- if (isset($form[$key]['category'])) {
- $field = &$form[$key];
- $category = $field['category']['#default_value'];
-
- if (!isset($categories[$category])) {
- // Category classes are given numeric IDs because there's no guarantee
- // class names won't contain invalid characters.
- $categories[$category] = $category_number;
- $category_field['#attributes']['class'] = array('profile-category', 'profile-category-' . $category_number);
- $rows[] = array(array('data' => check_plain($category), 'colspan' => 7, 'class' => array('category')));
- $rows[] = array('data' => array(array('data' => '<em>' . t('No fields in this category. If this category remains empty when saved, it will be removed.') . '</em>', 'colspan' => 7)), 'class' => array('category-' . $category_number . '-message', 'category-message', 'category-populated'));
-
- // Make it draggable only if there is more than one field
- if (isset($form['actions'])) {
- drupal_add_tabledrag('profile-fields', 'order', 'sibling', 'profile-weight', 'profile-weight-' . $category_number);
- drupal_add_tabledrag('profile-fields', 'match', 'sibling', 'profile-category', 'profile-category-' . $category_number);
- }
- $category_number++;
- }
-
- // Add special drag and drop classes that group fields together.
- $field['weight']['#attributes']['class'] = array('profile-weight', 'profile-weight-' . $categories[$category]);
- $field['category']['#attributes']['class'] = array('profile-category', 'profile-category-' . $categories[$category]);
-
- // Add the row
- $row = array();
- $row[] = drupal_render($field['title']);
- $row[] = drupal_render($field['name']);
- $row[] = drupal_render($field['type']);
- if (isset($form['actions'])) {
- $row[] = drupal_render($field['category']);
- $row[] = drupal_render($field['weight']);
- }
- $row[] = drupal_render($field['edit']);
- $row[] = drupal_render($field['delete']);
- $rows[] = array('data' => $row, 'class' => array('draggable'));
- }
- }
-
- $header = array(t('Title'), t('Name'), t('Type'));
- if (isset($form['actions'])) {
- $header[] = t('Category');
- $header[] = t('Weight');
- }
- $header[] = array('data' => t('Operations'), 'colspan' => 2);
-
- $output = theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No fields available.'), 'attributes' => array('id' => 'profile-fields')));
- $output .= drupal_render_children($form);
-
- return $output;
-}
-
-/**
- * Menu callback: Generate a form to add/edit a user profile field.
- *
- * @ingroup forms
- * @see profile_field_form_validate()
- * @see profile_field_form_submit()
- */
-function profile_field_form($form, &$form_state, $arg = NULL) {
- if (arg(4) == 'edit') {
- if (is_numeric($arg)) {
- $fid = $arg;
-
- $edit = db_query('SELECT * FROM {profile_field} WHERE fid = :fid', array('fid' => $fid))->fetchAssoc();
-
- if (!$edit) {
- drupal_not_found();
- return;
- }
- drupal_set_title(t('Edit %title', array('%title' => $edit['title'])), PASS_THROUGH);
- $form['fid'] = array('#type' => 'value',
- '#value' => $fid,
- );
- $type = $edit['type'];
- }
- else {
- drupal_not_found();
- return;
- }
- }
- else {
- $types = _profile_field_types();
- if (!isset($types[$arg])) {
- drupal_not_found();
- return;
- }
- $type = $arg;
- drupal_set_title(t('Add new %type', array('%type' => $types[$type])), PASS_THROUGH);
- $edit = array('name' => 'profile_');
- $form['type'] = array('#type' => 'value', '#value' => $type);
- }
- $edit += array(
- 'category' => '',
- 'title' => '',
- 'explanation' => '',
- 'weight' => 0,
- 'page' => '',
- 'autocomplete' => '',
- 'required' => '',
- 'register' => '',
- );
- $form['category'] = array('#type' => 'textfield',
- '#title' => t('Category'),
- '#default_value' => $edit['category'],
- '#autocomplete_path' => 'admin/config/people/profile/autocomplete',
- '#description' => t('The category the new field should be part of. Categories are used to group fields logically. An example category is "Personal information".'),
- '#required' => TRUE,
- );
- $form['title'] = array('#type' => 'textfield',
- '#title' => t('Title'),
- '#default_value' => $edit['title'],
- '#description' => t('The title of the new field. The title will be shown to the user. An example title is "Favorite color".'),
- '#required' => TRUE,
- );
- $form['name'] = array('#type' => 'textfield',
- '#title' => t('Form name'),
- '#default_value' => $edit['name'],
- '#description' => t('The name of the field. The form name is not shown to the user but used internally in the HTML code and URLs.
-Unless you know what you are doing, it is highly recommended that you prefix the form name with <code>profile_</code> to avoid name clashes with other fields. Spaces or any other special characters except dash (-) and underscore (_) are not allowed. An example name is "profile_favorite_color" or perhaps just "profile_color".'),
- '#required' => TRUE,
- );
- $form['explanation'] = array('#type' => 'textarea',
- '#title' => t('Explanation'),
- '#default_value' => $edit['explanation'],
- '#description' => t('An optional explanation to go with the new field. The explanation will be shown to the user.'),
- );
- if ($type == 'selection') {
- $form['fields']['options'] = array('#type' => 'textarea',
- '#title' => t('Selection options'),
- '#default_value' => isset($edit['options']) ? $edit['options'] : '',
- '#description' => t('A list of all options. Put each option on a separate line. Example options are "red", "blue", "green", etc.'),
- );
- }
- $form['visibility'] = array('#type' => 'radios',
- '#title' => t('Visibility'),
- '#default_value' => isset($edit['visibility']) ? $edit['visibility'] : PROFILE_PUBLIC,
- '#options' => array(PROFILE_HIDDEN => t('Hidden profile field, only accessible by administrators, modules and themes.'), PROFILE_PRIVATE => t('Private field, content only available to privileged users.'), PROFILE_PUBLIC => t('Public field, content shown on profile page but not used on member list pages.'), PROFILE_PUBLIC_LISTINGS => t('Public field, content shown on profile page and on member list pages.')),
- );
- if ($type == 'selection' || $type == 'list' || $type == 'textfield') {
- $form['fields']['page'] = array('#type' => 'textfield',
- '#title' => t('Page title'),
- '#default_value' => $edit['page'],
- '#description' => t('To enable browsing this field by value, enter a title for the resulting page. The word <code>%value</code> will be substituted with the corresponding value. An example page title is "People whose favorite color is %value" . This is only applicable for a public field.'),
- );
- }
- elseif ($type == 'checkbox') {
- $form['fields']['page'] = array('#type' => 'textfield',
- '#title' => t('Page title'),
- '#default_value' => $edit['page'],
- '#description' => t('To enable browsing this field by value, enter a title for the resulting page. An example page title is "People who are employed" . This is only applicable for a public field.'),
- );
- }
- $form['weight'] = array('#type' => 'weight',
- '#title' => t('Weight'),
- '#default_value' => $edit['weight'],
- '#description' => t('The weights define the order in which the form fields are shown. Lighter fields "float up" towards the top of the category.'),
- );
- $form['autocomplete'] = array('#type' => 'checkbox',
- '#title' => t('Form will auto-complete while user is typing.'),
- '#default_value' => $edit['autocomplete'],
- '#description' => t('For security, auto-complete will be disabled if the user does not have access to user profiles.'),
- );
- $form['required'] = array('#type' => 'checkbox',
- '#title' => t('The user must enter a value.'),
- '#default_value' => $edit['required'],
- );
- $form['register'] = array('#type' => 'checkbox',
- '#title' => t('Visible in user registration form.'),
- '#default_value' => $edit['register'],
- );
-
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array('#type' => 'submit',
- '#value' => t('Save field'),
- );
- return $form;
-}
-
-/**
- * Validate profile_field_form submissions.
- */
-function profile_field_form_validate($form, &$form_state) {
- // Validate the 'field name':
- if (preg_match('/[^a-zA-Z0-9_-]/', $form_state['values']['name'])) {
- form_set_error('name', t('The specified form name contains one or more illegal characters. Spaces or any other special characters except dash (-) and underscore (_) are not allowed.'));
- }
-
- $users_table = drupal_get_schema('users');
- if (!empty($users_table['fields'][$form_state['values']['name']])) {
- form_set_error('name', t('The specified form name is reserved for use by Drupal.'));
- }
- // Validate the category:
- if (!$form_state['values']['category']) {
- form_set_error('category', t('You must enter a category.'));
- }
- if (strtolower($form_state['values']['category']) == 'account') {
- form_set_error('category', t('The specified category name is reserved for use by Drupal.'));
- }
- $query = db_select('profile_field');
- $query->fields('profile_field', array('fid'));
-
- if (isset($form_state['values']['fid'])) {
- $query->condition('fid', $form_state['values']['fid'], '<>');
- }
- $query_name = clone $query;
-
- $title = $query
- ->condition('title', $form_state['values']['title'])
- ->condition('category', $form_state['values']['category'])
- ->execute()
- ->fetchField();
- if ($title) {
- form_set_error('title', t('The specified title is already in use.'));
- }
- $name = $query_name
- ->condition('name', $form_state['values']['name'])
- ->execute()
- ->fetchField();
- if ($name) {
- form_set_error('name', t('The specified name is already in use.'));
- }
- if ($form_state['values']['visibility'] == PROFILE_HIDDEN) {
- if ($form_state['values']['required']) {
- form_set_error('required', t('A hidden field cannot be required.'));
- }
- if ($form_state['values']['register']) {
- form_set_error('register', t('A hidden field cannot be set to visible on the user registration form.'));
- }
- }
-}
-
-/**
- * Process profile_field_form submissions.
- */
-function profile_field_form_submit($form, &$form_state) {
- if (!isset($form_state['values']['options'])) {
- $form_state['values']['options'] = '';
- }
- if (!isset($form_state['values']['page'])) {
- $form_state['values']['page'] = '';
- }
- // Remove all elements that are not profile_field columns.
- $values = array_intersect_key($form_state['values'], array_flip(array('type', 'category', 'title', 'name', 'explanation', 'visibility', 'page', 'weight', 'autocomplete', 'required', 'register', 'options')));
- if (!isset($form_state['values']['fid'])) {
- db_insert('profile_field')
- ->fields($values)
- ->execute();
- drupal_set_message(t('The field has been created.'));
- watchdog('profile', 'Profile field %field added under category %category.', array('%field' => $form_state['values']['title'], '%category' => $form_state['values']['category']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/people/profile'));
- }
- else {
- db_update('profile_field')
- ->fields($values)
- ->condition('fid', $form_state['values']['fid'])
- ->execute();
- drupal_set_message(t('The field has been updated.'));
- }
- cache_clear_all();
- menu_rebuild();
-
- $form_state['redirect'] = 'admin/config/people/profile';
- return;
-}
-
-/**
- * Menu callback; deletes a field from all user profiles.
- */
-function profile_field_delete($form, &$form_state, $fid) {
- $field = db_query("SELECT title FROM {profile_field} WHERE fid = :fid", array(':fid' => $fid))->fetchObject();
- if (!$field) {
- drupal_not_found();
- return;
- }
- $form['fid'] = array('#type' => 'value', '#value' => $fid);
- $form['title'] = array('#type' => 'value', '#value' => $field->title);
-
- return confirm_form($form,
- t('Are you sure you want to delete the field %field?', array('%field' => $field->title)), 'admin/config/people/profile',
- t('This action cannot be undone. If users have entered values into this field in their profile, these entries will also be deleted. If you want to keep the user-entered data, instead of deleting the field you may wish to <a href="@edit-field">edit this field</a> and change it to a hidden profile field so that it may only be accessed by administrators.', array('@edit-field' => url('admin/config/people/profile/edit/' . $fid))),
- t('Delete'), t('Cancel'));
-}
-
-/**
- * Process a field delete form submission.
- */
-function profile_field_delete_submit($form, &$form_state) {
- db_delete('profile_field')
- ->condition('fid', $form_state['values']['fid'])
- ->execute();
- db_delete('profile_value')
- ->condition('fid', $form_state['values']['fid'])
- ->execute();
-
- cache_clear_all();
-
- drupal_set_message(t('The field %field has been deleted.', array('%field' => $form_state['values']['title'])));
- watchdog('profile', 'Profile field %field deleted.', array('%field' => $form_state['values']['title']), WATCHDOG_NOTICE, l(t('view'), 'admin/config/people/profile'));
-
- $form_state['redirect'] = 'admin/config/people/profile';
- return;
-}
-
-/**
- * Retrieve a pipe delimited string of autocomplete suggestions for profile categories
- */
-function profile_admin_settings_autocomplete($string) {
- $matches = array();
- $result = db_select('profile_field')
- ->fields('profile_field', array('category'))
- ->condition('category', db_like($string) . '%', 'LIKE')
- ->range(0, 10)
- ->execute();
-
- foreach ($result as $data) {
- $matches[$data->category] = check_plain($data->category);
- }
- drupal_json_output($matches);
-}
diff --git a/modules/profile/profile.css b/modules/profile/profile.css
deleted file mode 100644
index c3132f9..0000000
--- a/modules/profile/profile.css
+++ /dev/null
@@ -1,10 +0,0 @@
-
-#profile-fields td.category {
- font-weight: bold;
-}
-#profile-fields tr.category-message {
- color: #999;
-}
-#profile-fields tr.category-populated {
- display: none;
-}
diff --git a/modules/profile/profile.info b/modules/profile/profile.info
deleted file mode 100644
index f4c8699..0000000
--- a/modules/profile/profile.info
+++ /dev/null
@@ -1,12 +0,0 @@
-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
diff --git a/modules/profile/profile.install b/modules/profile/profile.install
deleted file mode 100644
index c5747cf..0000000
--- a/modules/profile/profile.install
+++ /dev/null
@@ -1,152 +0,0 @@
-<?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;
-}
diff --git a/modules/profile/profile.js b/modules/profile/profile.js
deleted file mode 100644
index f842aa0..0000000
--- a/modules/profile/profile.js
+++ /dev/null
@@ -1,58 +0,0 @@
-(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);
diff --git a/modules/profile/profile.module b/modules/profile/profile.module
deleted file mode 100644
index 8cac6d7..0000000
--- a/modules/profile/profile.module
+++ /dev/null
@@ -1,628 +0,0 @@
-<?php
-
-/**
- * @file
- * Support for configurable user profiles.
- */
-
-/**
- * Private field, content only available to privileged users.
- */
-define('PROFILE_PRIVATE', 1);
-
-/**
- * Public field, content shown on profile page but not used on member list pages.
- */
-define('PROFILE_PUBLIC', 2);
-
-/**
- * Public field, content shown on profile page and on member list pages.
- */
-define('PROFILE_PUBLIC_LISTINGS', 3);
-
-/**
- * Hidden profile field, only accessible by administrators, modules and themes.
- */
-define('PROFILE_HIDDEN', 4);
-
-/**
- * Implements hook_help().
- */
-function profile_help($path, $arg) {
- switch ($path) {
- case 'admin/help#profile':
- $output = '';
- $output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Profile module allows site administrators to define custom fields (such as country, full name, or age) for user profiles, which are then displayed in the <a href="@user">My Account</a> section. This permits users of a site to share more information about themselves, and can help community-based sites organize users around specific information. For more information, see the online handbook entry for <a href="@profile">Profile module</a>.', array('@user' => url('user'), '@profile' => 'http://drupal.org/handbook/modules/profile/')) . '</p>';
- $output .= '<h3>' . t('Uses') . '</h3>';
- $output .= '<dl>';
- $output .= '<dt>' . t('Adding fields to the default profile') . '</dt>';
- $output .= '<dd>' . t('To provide the ability for users to enter more information about themselves, the Profile module allows additional fields to be added to the default user profile. Examples of common additions would be <em>Location</em>, <em>Company</em>, <em>Age</em>, or <em>About me</em>.') . '</dd>';
- $output .= '<dt>' . t('User information pages') . '</dt>';
- $output .= '<dd>' . t('The Profile module enables links to see further information about site users. You can view both a main <a href="@profile">User list page</a>, and more specified pages by clicking on linked fields in any profile. For example, the <a href="@profile-country">People who live in Canada</a> listing on Drupal.org displays all users who have entered <em>Canada</em> in the <em>Country</em> field on their user profile.', array('@profile' => url('profile'), '@profile-country' => 'http://drupal.org/profile/country/Canada')) . '</dd>';
- $output .= '<dt>' . t('Author information block') . '</dt>';
- $output .= '<dd>' . t('The <em>Author information block</em> is a default block created by the Profile module that can be enabled on the <a href="@blocks">Blocks administration page</a>. It shows visitors of your website information about the author of the page they are reading.', array('@blocks' => url('admin/structure/block'))) . '</dd>';
- $output .= '</dl>';
- return $output;
- case 'admin/config/people/profile':
- return '<p>' . t("This page displays a list of the existing custom profile fields to be displayed on a user's <em>My account</em> page. To provide structure, similar or related fields may be placed inside a category. To add a new category (or edit an existing one), edit a profile field and provide a new category name.") . '</p>';
- }
-}
-
-/**
- * Implements hook_theme().
- */
-function profile_theme() {
- return array(
- 'profile_block' => array(
- 'variables' => array('account' => NULL, 'fields' => array()),
- 'template' => 'profile-block',
- ),
- 'profile_listing' => array(
- 'variables' => array('account' => NULL, 'fields' => array()),
- 'template' => 'profile-listing',
- ),
- 'profile_wrapper' => array(
- 'variables' => array('content' => NULL),
- 'template' => 'profile-wrapper',
- ),
- 'profile_admin_overview' => array(
- 'render element' => 'form',
- 'file' => 'profile.admin.inc',
- )
- );
-}
-
-/**
- * Implements hook_menu().
- */
-function profile_menu() {
- $items['profile'] = array(
- 'title' => 'User list',
- 'page callback' => 'profile_browse',
- 'access arguments' => array('access user profiles'),
- 'file' => 'profile.pages.inc',
- 'type' => MENU_SUGGESTED_ITEM,
- );
- $items['admin/config/people/profile'] = array(
- 'title' => 'Profiles',
- 'description' => 'Create customizable fields for your users.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('profile_admin_overview'),
- 'access arguments' => array('administer users'),
- 'file' => 'profile.admin.inc',
- );
- $items['admin/config/people/profile/add'] = array(
- 'title' => 'Add field',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('profile_field_form'),
- 'access arguments' => array('administer users'),
- 'type' => MENU_VISIBLE_IN_BREADCRUMB,
- 'file' => 'profile.admin.inc',
- );
- $items['admin/config/people/profile/autocomplete'] = array(
- 'title' => 'Profile category autocomplete',
- 'page callback' => 'profile_admin_settings_autocomplete',
- 'access arguments' => array('administer users'),
- 'file' => 'profile.admin.inc',
- 'type' => MENU_CALLBACK,
- );
- $items['admin/config/people/profile/edit'] = array(
- 'title' => 'Edit field',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('profile_field_form'),
- 'access arguments' => array('administer users'),
- 'type' => MENU_VISIBLE_IN_BREADCRUMB,
- 'file' => 'profile.admin.inc',
- );
- $items['admin/config/people/profile/delete'] = array(
- 'title' => 'Delete field',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('profile_field_delete'),
- 'access arguments' => array('administer users'),
- 'type' => MENU_VISIBLE_IN_BREADCRUMB,
- 'file' => 'profile.admin.inc',
- );
- $items['profile/autocomplete'] = array(
- 'title' => 'Profile autocomplete',
- 'page callback' => 'profile_autocomplete',
- 'access arguments' => array('access user profiles'),
- 'file' => 'profile.pages.inc',
- 'type' => MENU_CALLBACK,
- );
- return $items;
-}
-
-/**
- * Implements hook_block_info().
- */
- function profile_block_info() {
- $blocks['author-information']['info'] = t('Author information');
- $blocks['author-information']['cache'] = DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE;
- return $blocks;
-}
-
-/**
- * Implements hook_block_configure().
- */
-function profile_block_configure($delta = '') {
- // Compile a list of fields to show
- $fields = array();
- $result = db_query('SELECT name, title, weight, visibility FROM {profile_field} WHERE visibility IN (:visibility) ORDER BY weight', array(':visibility' => array(PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS)));
- foreach ($result as $record) {
- $fields[$record->name] = check_plain($record->title);
- }
- $fields['user_profile'] = t('Link to full user profile');
- $form['profile_block_author_fields'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Profile fields to display'),
- '#default_value' => variable_get('profile_block_author_fields', array()),
- '#options' => $fields,
- '#description' => t('Select which profile fields you wish to display in the block. Only fields designated as public in the <a href="@profile-admin">profile field configuration</a> are available.', array('@profile-admin' => url('admin/config/people/profile'))),
- );
- return $form;
-}
-
-/**
- * Implements hook_block_save().
- */
-function profile_block_save($delta = '', $edit = array()) {
- variable_set('profile_block_author_fields', $edit['profile_block_author_fields']);
-}
-
-/**
- * Implements hook_block_view().
- */
-function profile_block_view($delta = '') {
- if (user_access('access user profiles')) {
- $output = '';
- if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == NULL) {
- $node = node_load(arg(1));
- $account = user_load($node->uid);
-
- if ($use_fields = variable_get('profile_block_author_fields', array())) {
- // Compile a list of fields to show.
- $fields = array();
- $result = db_query('SELECT * FROM {profile_field} WHERE visibility IN (:visibility) ORDER BY weight', array(':visibility' => array(PROFILE_PUBLIC, PROFILE_PUBLIC_LISTINGS)));
- foreach ($result as $record) {
- // Ensure that field is displayed only if it is among the defined block fields and, if it is private, the user has appropriate permissions.
- if (isset($use_fields[$record->name]) && $use_fields[$record->name]) {
- $fields[] = $record;
- }
- }
- }
-
- if (!empty($fields)) {
- $profile = _profile_update_user_fields($fields, $account);
- $output .= theme('profile_block', array('account' => $account, 'fields' => $profile));
- }
-
- if (isset($use_fields['user_profile']) && $use_fields['user_profile']) {
- $output .= '<div>' . l(t('View full user profile'), 'user/' . $account->uid) . '</div>';
- }
- }
-
- if ($output) {
- $block['subject'] = t('About %name', array('%name' => format_username($account)));
- $block['content'] = $output;
- return $block;
- }
- }
-}
-
-/**
- * Implements hook_user_presave().
- */
-function profile_user_presave(&$edit, $account, $category) {
- if ($account->uid) {
- profile_save_profile($edit, $account, $category);
- }
-}
-
-/**
- * Implements hook_user_insert().
- */
-function profile_user_insert(&$edit, $account, $category) {
- profile_save_profile($edit, $account, $category, TRUE);
-}
-
-/**
- * Implements hook_user_cancel().
- */
-function profile_user_cancel(&$edit, $account, $method) {
- switch ($method) {
- case 'user_cancel_reassign':
- db_delete('profile_value')
- ->condition('uid', $account->uid)
- ->execute();
- }
-}
-
-/**
- * Implements hook_user_delete().
- */
-function profile_user_delete($account) {
- db_delete('profile_value')
- ->condition('uid', $account->uid)
- ->execute();
-}
-
-/**
- * Implements hook_user_load().
- */
-function profile_user_load($users) {
- $result = db_query('SELECT f.name, f.type, v.uid, v.value FROM {profile_field} f INNER JOIN {profile_value} v ON f.fid = v.fid WHERE uid IN (:uids)', array(':uids' => array_keys($users)));
- foreach ($result as $record) {
- if (empty($users[$record->uid]->{$record->name})) {
- $users[$record->uid]->{$record->name} = _profile_field_serialize($record->type) ? unserialize($record->value) : $record->value;
- }
- }
-}
-
-function profile_save_profile(&$edit, $account, $category, $register = FALSE) {
- $result = _profile_get_fields($category, $register);
- foreach ($result as $field) {
- if (_profile_field_serialize($field->type)) {
- $edit[$field->name] = serialize($edit[$field->name]);
- }
- db_merge('profile_value')
- ->key(array(
- 'fid' => $field->fid,
- 'uid' => $account->uid,
- ))
- ->fields(array('value' => $edit[$field->name]))
- ->execute();
- }
-}
-
-function profile_view_field($account, $field) {
- // Only allow browsing of private fields for admins, if browsing is enabled,
- // and if a user has permission to view profiles. Note that this check is
- // necessary because a user may always see their own profile.
- $browse = user_access('access user profiles')
- && (user_access('administer users') || $field->visibility != PROFILE_PRIVATE)
- && !empty($field->page);
-
- if (isset($account->{$field->name}) && $value = $account->{$field->name}) {
- switch ($field->type) {
- case 'textarea':
- return check_markup($value, filter_default_format($account), '', TRUE);
- case 'textfield':
- case 'selection':
- return $browse ? l($value, 'profile/' . $field->name . '/' . $value) : check_plain($value);
- case 'checkbox':
- return $browse ? l($field->title, 'profile/' . $field->name) : check_plain($field->title);
- case 'url':
- return '<a href="' . check_url($value) . '">' . check_plain($value) . '</a>';
- case 'date':
- $format = substr(variable_get('date_format_short', 'm/d/Y - H:i'), 0, 5);
- // Note: Avoid PHP's date() because it does not handle dates before
- // 1970 on Windows. This would make the date field useless for e.g.
- // birthdays.
- $replace = array(
- 'd' => sprintf('%02d', $value['day']),
- 'j' => $value['day'],
- 'm' => sprintf('%02d', $value['month']),
- 'M' => map_month($value['month']),
- 'Y' => $value['year'],
- 'H:i' => NULL,
- 'g:ia' => NULL,
- );
- return strtr($format, $replace);
- case 'list':
- $values = preg_split("/[,\n\r]/", $value);
- $fields = array();
- foreach ($values as $value) {
- if ($value = trim($value)) {
- $fields[] = $browse ? l($value, 'profile/' . $field->name . '/' . $value) : check_plain($value);
- }
- }
- return implode(', ', $fields);
- }
- }
-}
-
-/**
- * Implements hook_user_view().
- */
-function profile_user_view($account) {
- // Show private fields to administrators and people viewing their own account.
- if (user_access('administer users') || $GLOBALS['user']->uid == $account->uid) {
- $result = db_query('SELECT * FROM {profile_field} WHERE visibility <> :hidden ORDER BY category, weight', array(':hidden' => PROFILE_HIDDEN));
- }
- else {
- $result = db_query('SELECT * FROM {profile_field} WHERE visibility <> :private AND visibility <> :hidden ORDER BY category, weight', array(':private' => PROFILE_PRIVATE, ':hidden' => PROFILE_HIDDEN));
- }
-
- $fields = array();
- foreach ($result as $field) {
- if ($value = profile_view_field($account, $field)) {
- $title = ($field->type != 'checkbox') ? check_plain($field->title) : NULL;
-
- // Create a single fieldset for each category.
- if (!isset($account->content[$field->category])) {
- $account->content[$field->category] = array(
- '#type' => 'user_profile_category',
- '#title' => $field->category,
- );
- }
-
- $account->content[$field->category][$field->name] = array(
- '#type' => 'user_profile_item',
- '#title' => $title,
- '#markup' => $value,
- '#weight' => $field->weight,
- '#attributes' => array('class' => array('profile-' . $field->name)),
- );
- }
- }
-}
-
-function _profile_form_explanation($field) {
- $output = filter_xss_admin($field->explanation);
-
- if ($field->type == 'list') {
- $output .= ' ' . t('Put each item on a separate line or separate them by commas. No HTML allowed.');
- }
-
- if ($field->visibility == PROFILE_PRIVATE) {
- $output .= ' ' . t('The content of this field is kept private and will not be shown publicly.');
- }
-
- return $output;
-}
-
-/**
- * Implements hook_form_alter().
- */
-function profile_form_alter(&$form, &$form_state, $form_id) {
- if (!($form_id == 'user_register_form' || $form_id == 'user_profile_form')) {
- return;
- }
- $form['#validate'][] = 'profile_user_form_validate';
- $account = $form['#user'];
- $result = _profile_get_fields($form['#user_category'], $form['#user_category'] == 'register');
- $weight = 1;
- foreach ($result as $field) {
- $category = $field->category;
- if (!isset($form[$category])) {
- $form[$category] = array('#type' => 'fieldset', '#title' => check_plain($category), '#weight' => $weight++);
- }
- switch ($field->type) {
- case 'textfield':
- case 'url':
- $form[$category][$field->name] = array(
- '#type' => 'textfield',
- '#title' => check_plain($field->title),
- '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
- '#maxlength' => 255,
- '#description' => _profile_form_explanation($field),
- '#required' => $field->required,
- );
- if ($field->autocomplete) {
- $form[$category][$field->name]['#autocomplete_path'] = "profile/autocomplete/" . $field->fid;
- }
- break;
-
- case 'textarea':
- $form[$category][$field->name] = array(
- '#type' => 'textarea',
- '#title' => check_plain($field->title),
- '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
- '#description' => _profile_form_explanation($field),
- '#required' => $field->required,
- );
- break;
-
- case 'list':
- $form[$category][$field->name] = array(
- '#type' => 'textarea',
- '#title' => check_plain($field->title),
- '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
- '#description' => _profile_form_explanation($field),
- '#required' => $field->required,
- );
- break;
-
- case 'checkbox':
- $form[$category][$field->name] = array(
- '#type' => 'checkbox',
- '#title' => check_plain($field->title),
- '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
- '#description' => _profile_form_explanation($field),
- '#required' => $field->required,
- );
- break;
-
- case 'selection':
- $options = $field->required ? array() : array('--');
- $lines = preg_split("/[\n\r]/", $field->options);
- foreach ($lines as $line) {
- if ($line = trim($line)) {
- $options[$line] = $line;
- }
- }
- $form[$category][$field->name] = array(
- '#type' => 'select',
- '#title' => check_plain($field->title),
- '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
- '#options' => $options,
- '#description' => _profile_form_explanation($field),
- '#required' => $field->required,
- );
- break;
-
- case 'date':
- $form[$category][$field->name] = array(
- '#type' => 'date',
- '#title' => check_plain($field->title),
- '#default_value' => isset($account->{$field->name}) ? $account->{$field->name} : '',
- '#description' => _profile_form_explanation($field),
- '#required' => $field->required,
- );
- break;
- }
- }
-}
-
-/**
- * Helper function: update an array of user fields by calling profile_view_field
- */
-function _profile_update_user_fields($fields, $account) {
- foreach ($fields as $key => $field) {
- $fields[$key]->value = profile_view_field($account, $field);
- }
- return $fields;
-}
-
-/**
- * Form validation handler for the user register/profile form.
- *
- * @see profile_form_alter()
- */
-function profile_user_form_validate($form, &$form_state) {
- $result = _profile_get_fields($form['#user_category'], $form['#user_category'] == 'register');
- foreach ($result as $field) {
- if (!empty($form_state['values'][$field->name])) {
- if ($field->type == 'url' && !valid_url($form_state['values'][$field->name], TRUE)) {
- form_set_error($field->name, t('The value provided for %field is not a valid URL.', array('%field' => $field->title)));
- }
- }
- elseif ($field->required && !user_access('administer users')) {
- form_set_error($field->name, t('The field %field is required.', array('%field' => $field->title)));
- }
- }
-}
-
-/**
- * Implements hook_user_categories().
- */
-function profile_user_categories() {
- $result = db_query("SELECT DISTINCT(category) FROM {profile_field}");
- $data = array();
- foreach ($result as $category) {
- $data[] = array(
- 'name' => $category->category,
- 'title' => $category->category,
- 'weight' => 3,
- 'access callback' => 'profile_category_access',
- 'access arguments' => array(1, $category->category)
- );
- }
- return $data;
-}
-
-/**
- * Menu item access callback - check if a user has access to a profile category.
- */
-function profile_category_access($account, $category) {
- if (user_access('administer users') && $account->uid > 0) {
- return TRUE;
- }
- else {
- $category_visible = (bool) db_query_range('SELECT 1 FROM {profile_field} WHERE category = :category AND visibility <> :visibility', 0, 1, array(
- ':category' => $category,
- ':visibility' => PROFILE_HIDDEN
- ))->fetchField();
- return user_edit_access($account) && $category_visible;
- }
-}
-
-/**
- * Process variables for profile-block.tpl.php.
- *
- * The $variables array contains the following arguments:
- * - $account
- * - $fields
- *
- * @see profile-block.tpl.php
- */
-function template_preprocess_profile_block(&$variables) {
-
- $variables['user_picture'] = theme('user_picture', array('account' => $variables['account']));
- $variables['profile'] = array();
- // Supply filtered version of $fields that have values.
- foreach ($variables['fields'] as $field) {
- if ($field->value) {
- $variables['profile'][$field->name] = new stdClass();
- $variables['profile'][$field->name]->title = check_plain($field->title);
- $variables['profile'][$field->name]->value = $field->value;
- $variables['profile'][$field->name]->type = $field->type;
- }
- }
-
-}
-
-/**
- * Process variables for profile-listing.tpl.php.
- *
- * The $variables array contains the following arguments:
- * - $account
- * - $fields
- *
- * @see profile-listing.tpl.php
- */
-function template_preprocess_profile_listing(&$variables) {
-
- $variables['user_picture'] = theme('user_picture', array('account' => $variables['account']));
- $variables['name'] = theme('username', array('account' => $variables['account']));
- $variables['profile'] = array();
- // Supply filtered version of $fields that have values.
- foreach ($variables['fields'] as $field) {
- if ($field->value) {
- $variables['profile'][$field->name]->title = $field->title;
- $variables['profile'][$field->name]->value = $field->value;
- $variables['profile'][$field->name]->type = $field->type;
- }
- }
-
-}
-
-/**
- * Process variables for profile-wrapper.tpl.php.
- *
- * The $variables array contains the following arguments:
- * - $content
- *
- * @see profile-wrapper.tpl.php
- */
-function template_preprocess_profile_wrapper(&$variables) {
- $variables['current_field'] = '';
- if ($field = arg(1)) {
- $variables['current_field'] = $field;
- $variables['theme_hook_suggestions'][] = 'profile_wrapper__' . $field;
- }
-}
-
-function _profile_field_types($type = NULL) {
- $types = array('textfield' => t('single-line textfield'),
- 'textarea' => t('multi-line textfield'),
- 'checkbox' => t('checkbox'),
- 'selection' => t('list selection'),
- 'list' => t('freeform list'),
- 'url' => t('URL'),
- 'date' => t('date'));
- return isset($type) ? $types[$type] : $types;
-}
-
-function _profile_field_serialize($type = NULL) {
- return $type == 'date';
-}
-
-function _profile_get_fields($category, $register = FALSE) {
- $query = db_select('profile_field');
- if ($register) {
- $query->condition('register', 1);
- }
- else {
- $query->condition('category', db_like($category), 'LIKE');
- }
- if (!user_access('administer users')) {
- $query->condition('visibility', PROFILE_HIDDEN, '<>');
- }
- return $query
- ->fields('profile_field')
- ->orderBy('category', 'ASC')
- ->orderBy('weight', 'ASC')
- ->execute();
-}
diff --git a/modules/profile/profile.pages.inc b/modules/profile/profile.pages.inc
deleted file mode 100644
index 06f9632..0000000
--- a/modules/profile/profile.pages.inc
+++ /dev/null
@@ -1,139 +0,0 @@
-<?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);
-}
diff --git a/modules/profile/profile.test b/modules/profile/profile.test
deleted file mode 100644
index 83bed25..0000000
--- a/modules/profile/profile.test
+++ /dev/null
@@ -1,490 +0,0 @@
-<?php
-
-/**
- * @file
- * Tests for profile.module.
- */
-
-/**
- * A class for common methods for testing profile fields.
- */
-class ProfileTestCase extends DrupalWebTestCase {
- protected $admin_user;
- protected $normal_user;
-
- function setUp() {
- parent::setUp('profile');
- variable_set('user_register', USER_REGISTER_VISITORS);
-
- $this->admin_user = $this->drupalCreateUser(array('administer users', 'access user profiles', 'administer blocks'));
-
- // This is the user whose profile will be edited.
- $this->normal_user = $this->drupalCreateUser();
- }
-
- /**
- * Create a profile field.
- *
- * @param $type
- * The field type to be created.
- * @param $category
- * The category in which the field should be created.
- * @param $edit
- * Additional parameters to be submitted.
- * @return
- * The fid of the field that was just created.
- */
- function createProfileField($type = 'textfield', $category = 'simpletest', $edit = array()) {
- $edit['title'] = $title = $this->randomName(8);
- $edit['name'] = $form_name = 'profile_' . $title;
- $edit['category'] = $category;
- $edit['explanation'] = $this->randomName(50);
-
- $this->drupalPost('admin/config/people/profile/add/' . $type, $edit, t('Save field'));
- $fid = db_query("SELECT fid FROM {profile_field} WHERE title = :title", array(':title' => $title))->fetchField();
- $this->assertTrue($fid, t('New Profile field has been entered in the database'));
-
- // Check that the new field is appearing on the user edit form.
- $this->drupalGet('user/' . $this->admin_user->uid . '/edit/' . $category);
-
- // Checking field.
- if ($type == 'date') {
- $this->assertField($form_name . '[month]', t('Found month selection field'));
- $this->assertField($form_name . '[day]', t('Found day selection field'));
- $this->assertField($form_name . '[year]', t('Found day selection field'));
- }
- else {
- $this->assertField($form_name , t('Found form named @name', array('@name' => $form_name)));
- }
-
- // Checking name.
- $this->assertText($title, t('Checking title for field %title', array('%title' => $title)));
- // Checking explanation.
- $this->assertText($edit['explanation'], t('Checking explanation for field %title', array('%title' => $title)));
-
- return array(
- 'fid' => $fid,
- 'type' => $type,
- 'form_name' => $form_name,
- 'title' => $title,
- 'category' => $category,
- );
- }
-
- /**
- * Update a profile field.
- *
- * @param $fid
- * The fid of the field to be updated.
- * @param $type
- * The type of field to be updated.
- * @param $edit
- * Field parameters to be submitted.
- * @return
- * Array representation of the updated field.
- */
- function updateProfileField($fid, $type = 'textfield', $edit = array()) {
-
- $form_name = $edit['name'];
- $title = $edit['title'];
- $category = $edit['category'];
-
- $this->drupalPost('admin/config/people/profile/edit/' . $fid, $edit, t('Save field'));
-
- // Check that the updated field is appearing on the user edit form.
- $this->drupalGet('user/' . $this->admin_user->uid . '/edit/' . $category);
-
- // Checking field.
- if ($type == 'date') {
- $this->assertField($form_name . '[month]', t('Found month selection field'));
- $this->assertField($form_name . '[day]', t('Found day selection field'));
- $this->assertField($form_name . '[year]', t('Found day selection field'));
- }
- else {
- $this->assertField($form_name , t('Found form named @name', array('@name' => $form_name)));
- }
-
- // Checking name.
- $this->assertText($title, t('Checking title for field %title', array('%title' => $title)));
- // Checking explanation.
- $this->assertText($edit['explanation'], t('Checking explanation for field %title', array('%title' => $title)));
-
- return array(
- 'fid' => $fid,
- 'type' => $type,
- 'form_name' => $form_name,
- 'title' => $title,
- 'category' => $category,
- );
- }
-
- /**
- * Set the profile field to a random value
- *
- * @param $field
- * The field that should be set.
- * @param $value
- * The value for the field, defaults to a random string.
- * @return
- * The value that has been assigned to
- */
- function setProfileField($field, $value = NULL) {
-
- if (!isset($value)) {
- $value = $this->randomName();
- }
-
- $edit = array(
- $field['form_name'] => $value,
- );
- $this->drupalPost('user/' . $this->normal_user->uid . '/edit/' . $field['category'], $edit, t('Save'));
-
- // Check profile page.
- $content = $this->drupalGet('user/' . $this->normal_user->uid);
- $this->assertText($field['title'], t('Found profile field with title %title', array('%title' => $field['title'])));
-
- if ($field['type'] != 'checkbox') {
- // $value must be cast to a string in order to be found by assertText.
- $this->assertText("$value", t('Found profile field with value %value', array('%value' => $value)));
- }
-
- return $value;
- }
-
- /**
- * Delete a profile field.
- *
- * @param $field
- * The field to be deleted.
- */
- function deleteProfileField($field) {
- $this->drupalPost('admin/config/people/profile/delete/' . $field['fid'], array(), t('Delete'));
- $this->drupalGet('admin/config/people/profile');
- $this->assertNoText($field['title'], t('Checking deleted field %title', array('%title' => $field['title'])));
- }
-}
-
-class ProfileTestFields extends ProfileTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'Test single fields',
- 'description' => 'Testing profile module with add/edit/delete textfield, textarea, list, checkbox, and url fields into profile page',
- 'group' => 'Profile'
- );
- }
-
- /**
- * Test each of the field types. List selection and date fields are tested
- * separately because they need some special handling.
- */
- function testProfileFields() {
- $this->drupalLogin($this->admin_user);
-
- // Set test values for every field type.
- $field_types = array(
- 'textfield' => $this->randomName(),
- 'textarea' => $this->randomName(),
- 'list' => $this->randomName(),
- 'checkbox' => 1,
- // An underscore is an invalid character in a domain name. The method randomName can
- // return an underscore.
- 'url' => 'http://www.' . str_replace('_', '', $this->randomName(10)) . '.org',
- );
-
- // For each field type, create a field, give it a value, update the field,
- // and delete the field.
- foreach ($field_types as $type => $value) {
- $field = $this->createProfileField($type);
- $this->setProfileField($field, $value);
- $edit = array(
- 'name' => $field['form_name'],
- 'title' => $this->randomName(),
- 'category' => $field['category'],
- 'explanation' => $this->randomName(),
- );
- $field = $this->updateProfileField($field['fid'], $field['type'], $edit);
- $this->deleteProfileField($field);
- }
- }
-}
-
-class ProfileTestSelect extends ProfileTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'Test select field',
- 'description' => 'Testing profile module with add/edit/delete a select field',
- 'group' => 'Profile'
- );
- }
-
- /**
- * Create a list selection field, give it a value, update and delete the field.
- */
- function testProfileSelectionField() {
- $this->drupalLogin($this->admin_user);
-
- $edit = array(
- 'options' => implode("\n", range(1, 10)),
- );
- $field = $this->createProfileField('selection', 'simpletest', $edit);
-
- $this->setProfileField($field, rand(1, 10));
-
- $edit = array(
- 'name' => $field['form_name'],
- 'title' => $this->randomName(),
- 'category' => $field['category'],
- 'explanation' => $this->randomName(),
- );
- $field = $this->updateProfileField($field['fid'], $field['type'], $edit);
- $this->deleteProfileField($field);
- }
-}
-
-class ProfileTestDate extends ProfileTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'Test date field',
- 'description' => 'Testing profile module with add/edit/delete a date field',
- 'group' => 'Profile'
- );
- }
-
- /**
- * Create a date field, give it a value, update and delete the field.
- */
- function testProfileDateField() {
- $this->drupalLogin($this->admin_user);
-
- variable_set('date_format_short', 'm/d/Y - H:i');
- $field = $this->createProfileField('date');
-
- // Set date to January 09, 1983
- $edit = array(
- $field['form_name'] . '[month]' => 1,
- $field['form_name'] . '[day]' => 9,
- $field['form_name'] . '[year]' => 1983,
- );
-
- $this->drupalPost('user/' . $this->normal_user->uid . '/edit/' . $field['category'], $edit, t('Save'));
-
- // Check profile page.
- $this->drupalGet('user/' . $this->normal_user->uid);
- $this->assertText($field['title'], t('Found profile field with title %title', array('%title' => $field['title'])));
-
- $this->assertText('01/09/1983', t('Found date profile field.'));
-
- $edit = array(
- 'name' => $field['form_name'],
- 'title' => $this->randomName(),
- 'category' => $field['category'],
- 'explanation' => $this->randomName(),
- );
- $field = $this->updateProfileField($field['fid'], $field['type'], $edit);
- $this->deleteProfileField($field);
- }
-}
-
-class ProfileTestWeights extends ProfileTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'Test field weights',
- 'description' => 'Testing profile modules weigting of fields',
- 'group' => 'Profile'
- );
- }
-
- function testProfileFieldWeights() {
- $this->drupalLogin($this->admin_user);
-
- $category = $this->randomName();
- $field1 = $this->createProfileField('textfield', $category, array('weight' => 1));
- $field2 = $this->createProfileField('textfield', $category, array('weight' => -1));
-
- $this->setProfileField($field1, $this->randomName(8));
- $this->setProfileField($field2, $this->randomName(8));
-
- $profile_edit = $this->drupalGet('user/' . $this->normal_user->uid . '/edit/' . $category);
- $this->assertTrue(strpos($profile_edit, $field1['title']) > strpos($profile_edit, $field2['title']), t('Profile field weights are respected on the user edit form.'));
-
- $profile_page = $this->drupalGet('user/' . $this->normal_user->uid);
- $this->assertTrue(strpos($profile_page, $field1['title']) > strpos($profile_page, $field2['title']), t('Profile field weights are respected on the user profile page.'));
- }
-}
-
-/**
- * Test profile field autocompletion and access.
- */
-class ProfileTestAutocomplete extends ProfileTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'Autocompletion',
- 'description' => 'Test profile fields with autocompletion.',
- 'group' => 'Profile'
- );
- }
-
- /**
- * Tests profile field autocompletion and access.
- */
- function testAutocomplete() {
- $this->drupalLogin($this->admin_user);
-
- // Create a new profile field with autocompletion enabled.
- $category = $this->randomName();
- $field = $this->createProfileField('textfield', $category, array('weight' => 1, 'autocomplete' => 1));
-
- // Enter profile field value.
- $field['value'] = $this->randomName();
- $this->setProfileField($field, $field['value']);
-
- // Set some html for what we want to see in the page output later.
- $autocomplete_html = '<input type="hidden" id="' . drupal_html_id('edit-' . $field['form_name'] . '-autocomplete') . '" value="' . url('profile/autocomplete/' . $field['fid'], array('absolute' => TRUE)) . '" disabled="disabled" class="autocomplete" />';
- $field_html = '<input type="text" maxlength="255" name="' . $field['form_name'] . '" id="' . drupal_html_id('edit-' . $field['form_name']) . '" size="60" value="' . $field['value'] . '" class="form-text form-autocomplete required" />';
-
- // Check that autocompletion html is found on the user's profile edit page.
- $this->drupalGet('user/' . $this->admin_user->uid . '/edit/' . $category);
- $this->assertRaw($autocomplete_html, t('Autocomplete found.'));
- $this->assertRaw('misc/autocomplete.js', t('Autocomplete JavaScript found.'));
- $this->assertRaw('class="form-text form-autocomplete"', t('Autocomplete form element class found.'));
-
- // Check the autocompletion path using the first letter of our user's profile
- // field value to make sure access is allowed and a valid result if found.
- $this->drupalGet('profile/autocomplete/' . $field['fid'] . '/' . $field['value'][0]);
- $this->assertResponse(200, t('Autocomplete path allowed to user with permission.'));
- $this->assertRaw($field['value'], t('Autocomplete value found.'));
-
- // Logout and login with a user without the 'access user profiles' permission.
- $this->drupalLogout();
- $this->drupalLogin($this->normal_user);
-
- // Check that autocompletion html is not found on the user's profile edit page.
- $this->drupalGet('user/' . $this->normal_user->uid . '/edit/' . $category);
- $this->assertNoRaw($autocomplete_html, t('Autocomplete not found.'));
-
- // User should be denied access to the profile autocomplete path.
- $this->drupalGet('profile/autocomplete/' . $field['fid'] . '/' . $field['value'][0]);
- $this->assertResponse(403, t('Autocomplete path denied to user without permission.'));
- }
-}
-
-class ProfileBlockTestCase extends ProfileTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'Block availability',
- 'description' => 'Check if the Author Information block is available.',
- 'group' => 'Profile',
- );
- }
-
- function setUp() {
- parent::setUp();
-
- // Login the admin user.
- $this->drupalLogin($this->admin_user);
-
- // Create two fields.
- $category = $this->randomName();
- $this->field1 = $this->createProfileField('textfield', $category, array('weight' => 0));
- $this->field2 = $this->createProfileField('textfield', $category, array('weight' => 1));
-
- // Assign values to those fields.
- $this->value1 = $this->setProfileField($this->field1);
- $this->value2 = $this->setProfileField($this->field2);
-
- // Create a node authored by the normal user.
- $this->node = $this->drupalCreateNode(array(
- 'uid' => $this->normal_user->uid,
- ));
- }
-
- function testAuthorInformationBlock() {
- // Set the block to a region to confirm the block is availble.
- $edit = array();
- $edit['blocks[profile_author-information][region]'] = 'footer';
- $this->drupalPost('admin/structure/block', $edit, t('Save blocks'));
- $this->assertText(t('The block settings have been updated.'), t('Block successfully move to footer region.'));
-
- // Enable field 1.
- $this->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
- 'profile_block_author_fields[' . $this->field1['form_name'] . ']' => TRUE,
- ), t('Save block'));
- $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
-
- // Visit the node and confirm that the field is displayed.
- $this->drupalGet('node/' . $this->node->nid);
- $this->assertRaw($this->value1, t('Field 1 is displayed'));
- $this->assertNoRaw($this->value2, t('Field 2 is not displayed'));
-
- // Enable only field 2.
- $this->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
- 'profile_block_author_fields[' . $this->field1['form_name'] . ']' => FALSE,
- 'profile_block_author_fields[' . $this->field2['form_name'] . ']' => TRUE,
- ), t('Save block'));
- $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
-
- // Visit the node and confirm that the field is displayed.
- $this->drupalGet('node/' . $this->node->nid);
- $this->assertNoRaw($this->value1, t('Field 1 is not displayed'));
- $this->assertRaw($this->value2, t('Field 2 is displayed'));
-
- // Enable both fields.
- $this->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
- 'profile_block_author_fields[' . $this->field1['form_name'] . ']' => TRUE,
- 'profile_block_author_fields[' . $this->field2['form_name'] . ']' => TRUE,
- ), t('Save block'));
- $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
-
- // Visit the node and confirm that the field is displayed.
- $this->drupalGet('node/' . $this->node->nid);
- $this->assertRaw($this->value1, t('Field 1 is displayed'));
- $this->assertRaw($this->value2, t('Field 2 is displayed'));
-
- // Enable the link to the user profile.
- $this->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
- 'profile_block_author_fields[user_profile]' => TRUE,
- ), t('Save block'));
- $this->assertText(t('The block configuration has been saved.'), t('Block configuration set.'));
-
- // Visit the node and confirm that the user profile link is displayed.
- $this->drupalGet('node/' . $this->node->nid);
- $this->clickLink(t('View full user profile'));
- $this->assertEqual($this->getUrl(), url('user/' . $this->normal_user->uid, array('absolute' => TRUE)));
- }
-}
-
-/**
- * Test profile browsing.
- */
-class ProfileTestBrowsing extends ProfileTestCase {
- public static function getInfo() {
- return array(
- 'name' => 'Profile browsing',
- 'description' => 'Test profile browsing.',
- 'group' => 'Profile',
- );
- }
-
- /**
- * Test profile browsing.
- */
- function testProfileBrowsing() {
- $this->drupalLogin($this->admin_user);
- $field = $this->createProfileField('list', 'simpletest', array('page' => '%value'));
-
- // Set a random value for the profile field.
- $value = $this->setProfileField($field);
-
- // Check that user is found on the profile browse page.
- $this->drupalGet("profile/{$field['form_name']}/$value");
- $this->assertText($this->normal_user->name);
- }
-}
-
- /**
- * TODO:
- * - Test field visibility
- * - Test required fields
- * - Test fields on registration form
- * - Test updating fields
- */
diff --git a/modules/user/user.module b/modules/user/user.module
index 044ad46..db0591f 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -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;
- }
-}