Index: content_profile.module
===================================================================
--- content_profile.module (.../contrib-stable/content_profile/content_profile.module) (revision 494)
+++ content_profile.module (.../contrib-patch/content_profile/content_profile.module) (working copy)
@@ -6,6 +6,8 @@
* Marks content types as profiles.
*/
+define("CONTENT_PROFILE_TO_USER_PROFILE", 1);
+define("USER_PROFILE_TO_CONTENT_PROFILE", 2);
/**
* Implementation of hook_init().
@@ -159,6 +161,27 @@
'sub' => t("Show a secondary tab below the user's edit tab"),
),
);
+ $form['display']['page_redirect'] = array(
+ '#type' => 'radios',
+ '#title' => t('Redirecting profile content'),
+ '#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 redirect'),
+ CONTENT_PROFILE_TO_USER_PROFILE => t('Redirect content profile node to user profile'),
+ USER_PROFILE_TO_CONTENT_PROFILE => t('Redirect user profile to content profile node, except when the user is logged in and looking at their own page.'),
+ ),
+ );
+ $form['display']['edit_page_redirect'] = array(
+ '#type' => 'radios',
+ '#title' => t('Redirecting profile edit'),
+ '#default_value' => content_profile_get_settings($type, 'edit_page_redirect'),
+ '#options' => array(
+ 0 => t('Do not redirect'),
+ CONTENT_PROFILE_TO_USER_PROFILE => t('Redirect content profile node edit to content profile user edit'),
+ USER_PROFILE_TO_CONTENT_PROFILE => t('Redirect content profile user edit to content profile node edit'),
+ ),
+ );
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
@@ -290,6 +313,14 @@
return $data;
case 'view':
+ global $user;
+ foreach (content_profile_get_types('names') as $type => $type_name) {
+ if ((content_profile_get_settings($type, 'page_redirect') == USER_PROFILE_TO_CONTENT_PROFILE) && ($user->uid != $account->uid)) {
+ if ($node = content_profile_load($type, arg(1))) {
+ drupal_goto("node/". $node->nid);
+ }
+ }
+ }
$account->content['content_profile'] = content_profile_show_profiles($account->uid);
break;
@@ -445,6 +476,8 @@
'edit_link' => 0,
'edit_tab' => 'sub',
'add_link' => 1,
+ 'page_redirect' => 0,
+ 'edit_page_redirect' => 0,
);
}