Skip to content

Commit

Permalink
Merge pull request #7 from bugfolder/1.x-1.x
Browse files Browse the repository at this point in the history
Cleanup from D7 Profile
  • Loading branch information
bugfolder authored Jan 14, 2021
2 parents 4c944bc + 08827e2 commit 1628013
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 18 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,20 @@ Upgrading from Drupal 7
-----------------------

This module is the successor to the [Drupal 7 Profile2
module](https://drupal.org/project/profile2) and will automatically import and
module](https://drupal.org/project/profile2) and can automatically import and
convert any Profile2 profiles when upgrading from a Drupal 7 installation.

Note that this module does NOT import from the [deprecated Profile
Note that this module does _not_ import from the [deprecated Profile
module](https://www.drupal.org/node/874026) that was provided in Drupal 7 core
as an upgrade path from Drupal 6 sites that used Profiles. If you have profiles
from the Drupal 7 Profile module, you should either convert them to Profile2
profiles in Drupal 7 prior to upgrading to Backdrop, or recreate them in
Backdrop after you upgrade.

If you are migrating Drupal 7 Profile2 profiles to Backdrop Profile, you should,
however, _enable_ the Drupal 7 Profile module before preparing the db for
migration.

Documentation
-------------

Expand Down Expand Up @@ -65,3 +69,4 @@ Credits:
* [Wolfgang Ziegler (fago)](https://www.drupal.org/u/fago), [email protected]
* [Joachim Noreiko (joachim)](https://www.drupal.org/u/joachim), [email protected]

``
4 changes: 2 additions & 2 deletions profile.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function profile_display_settings_form($form, &$form_state) {
'#value' => t('Save configuration'),
'#weight' => 40,
);

return $form;
}

Expand Down Expand Up @@ -119,7 +119,7 @@ function profile_type_form($form, &$form_state, $profile_type, $op = 'edit') {
'#submit' => array('profile_type_form_submit_delete')
);
}

return $form;
}

Expand Down
8 changes: 8 additions & 0 deletions profile.install
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,11 @@ function profile_update_1001() {
WHERE name = 'profile2'
AND type = 'module'");
}

/**
* Drop any leftover D7 Profile module tables.
*/
function profile_update_1002() {
db_drop_table('profile_field');
db_drop_table('profile_value');
}
31 changes: 17 additions & 14 deletions profile.module
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ function profile_menu() {
);

$items['admin/config/people/profiles'] = array(
'title' => 'Profile display settings',
'title' => 'Profile display',
'page callback' => 'backdrop_get_form',
'page arguments' => array('profile_display_settings_form'),
'description' => 'Profile display settings form.',
'description' => 'Configure how profile edit forms are displayed when editing accounts.',
'access arguments' => array('administer profile'),
'file' => 'profile.admin.inc',
);
Expand Down Expand Up @@ -235,7 +235,7 @@ function profile_user_edit_access($account, $type_name) {
$profile = profile_load_by_user($account, $type_name);
if (empty($profile)) {
$profile = profile_create(array('type' => $type_name, 'uid' => $account->uid));
}
}
if (profile_access('edit', $profile, $account)) {
return TRUE;
}
Expand Down Expand Up @@ -464,12 +464,12 @@ function profile_type_save($type) {

$data = (array) $type;
$data += array(
'userview' => true,
'userview' => TRUE,
'registration' => 0,
'roles' => array(
'authenticated' => 'authenticated',
),
'module' => null,
'module' => NULL,
'weight' => '0',
'storage' => 1,
'status' => 1,
Expand Down Expand Up @@ -499,7 +499,7 @@ function profile_type_delete($type) {
}

/**
* Implements hook_profile_type_delete()
* Implements hook_profile_type_delete().
*/
function profile_profile_type_delete($type) {
$pids = array_keys(profile_load_multiple(FALSE, array('type' => $type->type)));
Expand Down Expand Up @@ -530,8 +530,8 @@ function profile_user_view($account, $view_mode, $langcode) {
/**
* Implements hook_form_FORM_ID_alter() for the user edit form.
*
* @see profile_form_validate_handler
* @see profile_form_submit_handler
* @see profile_form_validate_handler()
* @see profile_form_submit_handler()
*/
function profile_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
$profile_display = config_get('profile.settings', 'profile_display');
Expand Down Expand Up @@ -562,18 +562,18 @@ function profile_form_user_profile_form_alter(&$form, &$form_state, $form_id) {
$profile = profile_create(array('type' => $type_name, 'uid' => $form_state['user']->uid));
}
$form_state['profiles'][$profile->type] = $profile;
profile_attach_form($form, $form_state);
profile_attach_form($form, $form_state);
}
}
else {
foreach (profile_get_types() as $type_name => $profile_type) {
$profile = profile_load_by_user($form_state['user'], $type_name);
if (empty($profile)) {
$profile = profile_create(array('type' => $type_name, 'uid' => $form_state['user']->uid));
}
}
if (profile_access('edit', $profile)) {
$form_state['profiles'][$profile->type] = $profile;
profile_attach_form($form, $form_state);
profile_attach_form($form, $form_state);
// Wrap each profile form in a fieldset.
$form['profile_' . $type_name] += array(
'#type' => 'fieldset',
Expand Down Expand Up @@ -659,7 +659,7 @@ function profile_attach_form(&$form, &$form_state) {

// Provide a central place for modules to alter the profile forms, but
// skip that in case the caller cares about invoking the hooks.
// @see profile_form().
// @see profile_form()
if (!isset($form_state['profile_skip_hook'])) {
$hooks[] = 'form_profile_edit_' . $type . '_form';
$hooks[] = 'form_profile_form';
Expand Down Expand Up @@ -1038,6 +1038,9 @@ function profile_user_get_properties($account, array $options, $name) {
}


/**
* Return class autoload information.
*/
function profile_autoload_info() {
return array(
'Profile' => 'profile.entity.inc',
Expand Down Expand Up @@ -1136,12 +1139,12 @@ function profile_config_info() {
*/
function profile_type_set_defaults() {
$new_type = array(
'userview' => true,
'userview' => TRUE,
'type' => '',
'label' => '',
'registration' => 1,
'roles' => array(),
'module' => null,
'module' => NULL,
'weight' => 0,
'storage' => PROFILE_STORAGE_NORMAL,
'status' => PROFILE_STATUS_ENABLED,
Expand Down

0 comments on commit 1628013

Please sign in to comment.