diff -u b/lib/Drupal/profile2/ProfileFormController.php b/lib/Drupal/profile2/ProfileFormController.php --- b/lib/Drupal/profile2/ProfileFormController.php +++ b/lib/Drupal/profile2/ProfileFormController.php @@ -33,11 +33,15 @@ */ public function save(array $form, array &$form_state) { + global $user; + $profile = $this->getEntity($form_state); $profile->save(); - drupal_set_message(t('Your profile has been saved.')); - - // Rebuild the menu tree. - menu_router_rebuild(); + if ($user->uid == $profile->uid) { + drupal_set_message(t('Your profile has been saved.')); + } + else { + drupal_set_message(t("@name's profile has been saved.", array('@name' => user_format_name(user_load($profile->uid))))); + } } } diff -u b/lib/Drupal/profile2/ProfileTypeFormController.php b/lib/Drupal/profile2/ProfileTypeFormController.php --- b/lib/Drupal/profile2/ProfileTypeFormController.php +++ b/lib/Drupal/profile2/ProfileTypeFormController.php @@ -34,7 +34,6 @@ '#maxlength' => 32, '#machine_name' => array( 'exists' => 'profile2_type_load', - 'source' => array('label'), ), ); @@ -52,13 +51,18 @@ */ public function save(array $form, array &$form_state) { $profile_type = $this->getEntity($form_state); - $profile_type->save(); + $status = $profile_type->save(); - drupal_set_message(t('%label configuration has been saved.', array('%label' => $profile_type->label()))); + if ($status == SAVED_UPDATED) { + drupal_set_message(t('%label configuration has been updated.', array('%label' => $profile_type->label()))); + } else { + drupal_set_message(t('%label configuration has been inserted.', array('%label' => $profile_type->label()))); + } $form_state['redirect'] = 'admin/structure/profiles'; // Rebuild the menu tree. + // @todo Make a router rebuild unnecessary. menu_router_rebuild(); } diff -u b/lib/Drupal/profile2/Tests/Profile2CRUDTestCase.php b/lib/Drupal/profile2/Tests/Profile2CRUDTestCase.php --- b/lib/Drupal/profile2/Tests/Profile2CRUDTestCase.php +++ b/lib/Drupal/profile2/Tests/Profile2CRUDTestCase.php @@ -121,7 +121,7 @@ $this->drupalLogin($user1); // Make sure access is denied to the profile. - $this->drupalGet('user/' . $user1->uid . '/edit/profile/main'); + $this->drupalGet('user/' . $user1->uid . '/edit/main'); $this->assertText(t('Access denied'), 'Access has been denied.'); // Test creating a profile manually (e.g. by an admin) and ensure the user @@ -135,7 +135,7 @@ // Create profiles for the user2. $edit['profile_fullname[und][0][value]'] = $this->randomName(); - $this->drupalPost('user/' . $user2->uid . '/edit/profile/main', $edit, t('Save')); + $this->drupalPost('user/' . $user2->uid . '/edit/main', $edit, t('Save')); $this->assertText(t('Your profile has been saved.'), 'Profile saved.'); $this->assertEqual(profile2_load_by_user($user2, 'main')->profile_fullname[LANGUAGE_NOT_SPECIFIED][0]['value'], $edit['profile_fullname[und][0][value]'], 'Profile edited.'); diff -u b/profile2.admin.inc b/profile2.admin.inc --- b/profile2.admin.inc +++ b/profile2.admin.inc @@ -18,0 +19,8 @@ + * Page callback: Renders the form for editing profile types. + */ +function profile2_type_edit(ProfileType $profile_type) { + drupal_set_title(t('Edit @name', array('@name' => $profile_type->label))); + return entity_get_form($profile_type); +} + +/** diff -u b/profile2.module b/profile2.module --- b/profile2.module +++ b/profile2.module @@ -119,9 +119,10 @@ ); $items['admin/structure/profiles/manage/%profile2_type'] = array( 'title' => 'Edit profile type', - 'page callback' => 'entity_get_form', + 'page callback' => 'profile2_type_edit', 'page arguments' => array(4), 'access arguments' => array('administer profile types'), + 'file' => 'profile2.admin.inc', ); $items['admin/structure/profiles/manage/%profile2_type/edit'] = array( 'title' => 'Edit', @@ -146,7 +147,7 @@ foreach (profile2_get_types() as $id => $profile_type) { $label = $profile_type->label(); - $items["user/%user/edit/profile/$id"] = array( + $items["user/%user/edit/$id"] = array( 'title' => $label, 'page callback' => 'profile2_profile_edit', 'page arguments' => array(1, $id), @@ -455,8 +456,6 @@ /** * Implements hook_form_FORM_ID_alter() for the registration form. - * - * @todo Let's try to find a better solution for this and everything related. */ function profile2_form_user_register_form_alter(&$form, &$form_state) { foreach (profile2_get_types() as $type_name => $profile_type) {