Commit 5c66f8f0 authored by Wolfgang Ziegler's avatar Wolfgang Ziegler
Browse files

#1399618 improved menu rebuilding logic once again.

parent 3b948e77
Loading
Loading
Loading
Loading
+33 −0
Changes for contrib/profile2_page.module: 33 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -210,3 +210,36 @@ function profile2_page_form_profile2_type_form_alter(&$form, &$form_state) {
  );
  $form['data']['#tree'] = TRUE;
}

/**
 * Implements hook_profile2_type_insert().
 */
function profile2_page_profile2_type_insert(ProfileType $type) {
  // Do not directly issue menu rebuilds here to avoid potentially multiple
  // rebuilds. Instead, let menu_get_item() issue the rebuild on the next page.
  if (!empty($type->data['use_page'])) {
    variable_set('menu_rebuild_needed', TRUE);
  }
}

/**
 * Implements hook_profile2_type_update().
 */
function profile2_page_profile2_type_update(ProfileType $type) {
  // Rebuild the menu if use_page or the type name has been changed.
  // @see profile2_page_profile2_type_insert()
  if (empty($type->data['use_page']) != empty($type->original->data['use_page']) || ($type->data['use_page'] &&  $type->type != $type->original->type)) {
    variable_set('menu_rebuild_needed', TRUE);
  }
}

/**
 * Implements hook_profile2_type_delete()
 */
function profile2_page_profile2_type_delete($type) {
  // Do not directly issue menu rebuilds here to avoid potentially multiple
  // rebuilds. Instead, let menu_get_item() issue the rebuild on the next page.
  if (!empty($type->data['use_page'])) {
    variable_set('menu_rebuild_needed', TRUE);
  }
}
+0 −22
Changes for profile2.module: 0 added lines, 22 removed lines.
Original line number Diff line number Diff line
@@ -306,25 +306,6 @@ function profile2_type_delete(ProfileType $type) {
  $type->delete();
}

/**
 * Implements hook_profile2_type_insert().
 */
function profile2_profile2_type_insert(ProfileType $type) {
  // Always rebuild the menu in case a profile type is inserted or changed, as
  // also extension modules like profile2 page might need menu rebuilds. In
  // order to avoid possible multiple rebuilds of modules we just do it always
  // but once here.
  menu_rebuild();
}

/**
 * Implements hook_profile2_type_update().
 */
function profile2_profile2_type_update(ProfileType $type) {
  // @see profile2_profile2_type_insert()
  menu_rebuild();
}

/**
* Implements hook_profile2_type_delete()
*/
@@ -333,11 +314,8 @@ function profile2_profile2_type_delete($type) {
  if ($pids = array_keys(profile2_load_multiple(FALSE, array('type' => $type->type)))) {
    profile2_delete_multiple($pids);
  }
  // @see profile2_profile2_type_insert()
  menu_rebuild();
}


/**
 * Implements hook_user_view().
 */