--- content_profile.module 2010-03-15 16:28:14.000000000 -0400 +++ content_profile-NEW.module 2010-03-15 16:14:41.000000000 -0400 @@ -170,6 +170,17 @@ function content_profile_admin_settings( 'sub' => t("Show a secondary tab below the user's edit tab"), ), ); + $form['display']['page_redirect'] = array( + '#type' => 'radios', + '#title' => t("Prevent duplicate pages by adding a redirect."), + '#default_value' => content_profile_get_settings($type, 'page_redirect'), + '#description' => t("Optionally redirect all full page node views or default user profile views"), + '#options' => array( + 0 => t("Do not add a redirect"), + 1 => t('Redirect content profile node to user profile'), + 2 => t('Redirect user profile to content profile node'), + ), + ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), @@ -398,6 +409,29 @@ function content_profile_nodeapi(&$node, $node->uid = $node->translation_source->uid; $node->name = $node->translation_source->name; } + elseif ($op == 'view' && is_content_profile($node)) { + // Check that we are on node/N where N is the NID of a profile + if (arg(0) == 'node' && arg(1) == $node->nid && arg(2) == "") { + // Check if the redirect settings for this node type are set to redirect content profile to user page + if (content_profile_get_settings($node->type, 'page_redirect') == 1) { + // redirect to the user profile page + drupal_goto("user/". $node->uid); + } + } + // Or check that we are on user/U where U is the UID of a user + elseif (arg(0) == 'user' && arg(1) != "" && arg(2) == "") { + foreach (content_profile_get_types('names') as $type => $type_name) { + // Check if the redirect settings for this node type are set to redirect content profile to user page + if (content_profile_get_settings($type, 'page_redirect') == 2) { + // redirect to the user profile page + if ($node = content_profile_load($type, check_plain(arg(1)))) { + drupal_goto("node/". $node->nid); + } + } + } + } + } + } /** @@ -461,6 +495,7 @@ function content_profile_content_profile 'edit_link' => 0, 'edit_tab' => 'sub', 'add_link' => 1, + 'page_redirect' => 0, ); }