If module me is installed, the argument validation makes error in user.module, because there are'nt numeric argument, and the user can't be loaded.
This patch check if module me is installed, and then makes global $user if the 'me' alias is using.

Comments

szantog’s picture

StatusFileSize
new1.45 KB

Sorry, wrong patch was uploaded.

szantog’s picture

StatusFileSize
new2.3 KB

Another patch, because the disable edit tab settings doesn't work with module me too.

szantog’s picture

Assigned: Unassigned » szantog
Status: Needs review » Needs work

Hmm.. I get some error, and the patch was made about wrong version, so i need more test..

berliner’s picture

Status: Needs work » Needs review
StatusFileSize
new1.02 KB

I propose the attached path. It doesn't specifically test for the me module, but rather checks whether the user id is already set in the $form array. Very simple patch, but it solves the problem for me.

berliner’s picture

StatusFileSize
new2.27 KB

Revised the above patch because it erroneously put admin information into the account form when an admin edits the profile of a user account.

kenorb’s picture

Title: Conflict with module me » Conflict with modules me, etc.
kenorb’s picture

Title: Conflict with modules me, etc. » Account Profile conflict with modules me, etc.
szantog’s picture

StatusFileSize
new8.26 KB
new4.23 KB

Ok, I figured it out.
The problem was two thing:
1. The module content profile set/unset the cp edit form's path in menu_router depends on it's settings. If the "profile edit tabs" settings is 'Show a tab at the user's page' the profile settings is under path user/'%/edit/%profile_name doesn't exists! This would caused this: #981914: Missing argument 2 for user_category_load()

In menu_alter is set: $items['user/%user_category/edit/' . $profile]['type'] = MENU_CALLBACK; but $items['user/%user_category/edit/' . $profile]['type'] doesn't defined previous, so we have an 'empty' menu_item without access_arguments and page_arguments, then get drupal_access_denied.

2. The module me.
This unset the 'user/%user_category/edit' menu item, this uses ['user/%me_category/edit'] instead.

Because of 1 i changed the redirect method. I think, this solves this too: #1000822: redirect loop

  $content_profile_settings = content_profile_get_settings($profile);
  switch ($form_id) {
    case 'user_profile_form':
        // need two type of redirect depends on content_profile_settings
        if (variable_get('account_profile_redirect', TRUE)) {
          if ($content_profile_settings['edit_tab'] == 'top')  {
            $target_url = ('user/' . arg(1) . "/profile/$profile");
          }
          elseif ($content_profile_settings['edit_tab'] == 'sub') {
            $target_url = ('user/' . arg(1) . "/edit/$profile");
          }
          if ($target_url) {
            if (isset($_REQUEST['destination'])) {
              $destination = $_REQUEST['destination'];
              unset($_REQUEST['destination']);
              drupal_goto($target_url, array('destination' => $destination));
              exit;
            }
            else {
               drupal_goto($target_url);
               exit;
            }
          }
          // header("Location: " . base_path() . $_GET['q'] . "/$profile");
        }

and the _menu_alter

    if (isset($items['user/%user_category/edit/' . $profile]['type'])) {
      $items['user/%user_category/edit/' . $profile]['type'] = MENU_CALLBACK; // remove content profile tab
    }

Because of 2. i changed the activate method

      if (module_exists('me') && !is_numeric(arg(1))) {
        global $user;
        $account = $user;
      }
      else {
        $account = user_load(arg(1));
      }
      if ($account) { // activate only on edit page (not on registration page)

and the menu_alter

      if (module_exists('me')) {
        $items['user/%me_category/edit']['type'] = MENU_CALLBACK;
        $items['user/%me_category/edit/account']['type'] = MENU_CALLBACK;
      }
      else {
        $items['user/%user_category/edit']['type'] = MENU_CALLBACK;
      }

I attach a zipped version, please review it, if you can't use diff. And again: sorry for my english. :)

martynpanes’s picture

Hi There,
Just To say thanks for finding a fix to this problem - I am desperate to get a new site released for a customer using the content and account profile modules.

kenorb’s picture

@martynpanes: Have you tested the patch?

light9’s picture

#9 works for me!
szantog thank you so much!

frosty29’s picture

I was getting the Missing argument 2 for user_category_load()
which went away if I turned off "Redirect on User Edit page"

The patch worked for me - but I don't have either me or tab tamer modules .

Drupal 6.22 with latest of:
account_profile
admin_menu
advanced_help
auto_nodetitle
breadcrumbs_disabler
captcha
cck
computed_field
content_access
content_profile
date
libraries
logintoboggan
print
remember_me
rules
sharedemail
token
views
views_attach
views_customfield
views_dynamic_fields
views_export_xls
wysiwyg with tinymce

Would it make sense to release the patch anyway?

Thanks!

kenorb’s picture

Status: Needs review » Needs work

#9 patch looks fine. I don't know how me module works, but:

-      if (is_numeric(arg(1)) && $user = user_load(arg(1))) { // activate only on edit page (not on registration page) 
+      if (module_exists('me') && !is_numeric(arg(1))) {
+        global $user;
+        $account = $user;
+      }
+      else {
+        $account = user_load(arg(1));
+      }

you loading user from global variable, when 'me' is installed. But what if you open someone's else account from admin account? Probably it will load admin account instead of user? I'm right?

kenorb’s picture

Title: Account Profile conflict with modules me, etc. » Integration with 'me' module
Category: bug » feature

Marked as duplicate: #1152488: Support "me" module
Based that this issue is 'me' specified, and 'me' is doing lots of changes to user behaviour, changing as a feature.

Copied patch from: #1152488: Support "me" module
done by emerya

Here is the quick fix (around line 64) :

 if (is_numeric(arg(1)) && $user = user_load(arg(1))) { 

turns into

      $uid = arg(1);
      if (module_exists('me') && arg(1) == 'me') {
        global $user;
        $uid = $user->uid;
      }
      if (is_numeric($uid) && $user = user_load($uid)) {
kenorb’s picture

szantog:
Have you done some progress or do you have some recent patches available for testing? Thanks.

szantog’s picture

Status: Needs work » Needs review

"But what if you open someone's else account from admin account? Probably it will load admin account instead of user? I'm right?"

The module me only changes the logged in users menu items from user/[uid] to user/me. In this way if a user is in user/me or user/me/* always get own user page. It's impossible (or module me bug..)

If an admin open something else user page, they would go to original user/[uid]/* path, and there are a numeric arg(1).

"Have you done some progress or do you have some recent patches available for testing? Thanks."

No, just these. It works some my sites without any issue. :)

arski’s picture

sub

technikh’s picture

kenorb’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)

Closing as per Drupal 6 end-of-life. Unless somebody can provide a clean, tested patch.