--- menu_position.user_roles.inc.orig 2013-05-23 00:40:55.375447424 +0200 +++ menu_position.user_roles.inc 2013-05-23 00:56:59.402735563 +0200 @@ -14,8 +14,16 @@ * TRUE if condition applies successfully. Otherwise FALSE. */ function menu_position_menu_position_condition_user_role($variables) { + if ($variables['context']['bundle_name'] != 'user') { + return FALSE; + } + if ($variables['user'] == 'viewed') { + $account = $variables['context']['user']; + } else { + $account = $GLOBALS['user']; + } // Check for the roles the currently logged in user has. - foreach (array_keys($GLOBALS['user']->roles) as $role_id) { + foreach (array_keys($account->roles) as $role_id) { if (array_key_exists($role_id, $variables['user_role'])) { return TRUE; } @@ -45,12 +53,22 @@ 'js' => array(drupal_get_path('module', 'menu_position') . '/plugins/menu_position.user_roles.js'), ), ); + $form['conditions']['user_role']['user'] = array( + '#type' => 'select', + '#title' => t('User'), + '#default_value' => !empty($variables['user']) ? $variables['user'] : array(), + '#options' => array( + 'loggedin' => t('Logged in user'), + 'viewed' => t('User being viewed'), + ), + '#weight' => -30, + ); $form['conditions']['user_role']['user_role'] = array( '#type' => 'checkboxes', '#title' => t('User roles'), '#default_value' => !empty($variables['user_role']) ? $variables['user_role'] : array(), '#options' => user_roles(TRUE), - '#description' => t('Apply this rule on pages when the currently logged in user has this role(s).'), + '#description' => t('Apply this rule on pages when the user has this role(s).'), '#weight' => -20, ); @@ -79,6 +97,7 @@ if (!empty($form_state['values']['user_role'])) { // Add this plugin's variables to the rule. $variables = array( + 'user' => $form_state['values']['user'], 'user_role' => $form_state['values']['user_role'], ); $form_state['values']['conditions']['user_role'] = $variables;