diff --git a/content_profile.module b/content_profile.module index 48bc9d2..4a91ed8 100644 --- a/content_profile.module +++ b/content_profile.module @@ -172,6 +172,28 @@ function content_profile_admin_settings(&$form_state, $type) { 'sub' => t("Show a secondary tab below the user's edit tab"), ), ); + $form['display']['page_redirect'] = array( + '#type' => 'radios', + '#title' => t('Redirecting content profile node to the user page'), + '#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'), + 1 => t('Redirect content profile node to user profile'), + 2 => t('Redirect user profile to content profile node'), + ), + ); + $form['display']['edit_page_redirect'] = array( + '#type' => 'radios', + '#title' => t('Redirecting content profile edit node to the content profile user edit'), + '#default_value' => content_profile_get_settings($type, 'edit_page_redirect'), + '#description' => t('Optionally redirect all conent profile user edit forms or content profile edit forms'), + '#options' => array( + 0 => t('Do not redirect'), + 1 => t('Redirect content profile node edit to content profile user edit'), + 2 => t('Redirect content profile user edit to content profile node edit'), + ), + ); $form['submit'] = array( '#type' => 'submit', '#value' => t('Submit'), @@ -304,6 +326,13 @@ function content_profile_user($op, &$edit, &$account, $category = NULL) { return $data; case 'view': + foreach (content_profile_get_types('names') as $type => $type_name) { + if (content_profile_get_settings($type, 'page_redirect') == 2) { + if ($node = content_profile_load($type, arg(1))) { + drupal_goto("node/". $node->nid); + } + } + } $account->content['content_profile'] = content_profile_show_profiles($account->uid); break; @@ -383,6 +412,14 @@ function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { drupal_goto('node/'. $nid .'/edit', 'destination=user/'. $node->uid); } } + elseif ($op == 'prepare' && is_content_profile($node) && arg(0) == 'node' && content_profile_get_settings($node->type, 'edit_page_redirect') == 1) { + drupal_goto('user/' . $node->uid . '/profile/' . $node->type); + } + elseif ($op == 'prepare' && is_content_profile($node) && arg(0) == 'user' && (arg(2) == 'edit' || arg(2) == 'profile') && arg(3) == $node->type) { + if (content_profile_get_settings($node->type, 'edit_page_redirect') == 2) { + drupal_goto('node/' . $node->nid . '/edit'); + } + } elseif ($op == 'validate' && is_content_profile($node) && user_access('administer nodes')) { $form = $a3; // Only validate if the user-name changed or we add a new node @@ -400,6 +437,9 @@ function content_profile_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { $node->uid = $node->translation_source->uid; $node->name = $node->translation_source->name; } + elseif ($op == 'view' && is_content_profile($node) && arg(0) == 'node' && content_profile_get_settings($node->type, 'page_redirect') == 1) { + drupal_goto('user/' . $node->uid); + } } /** @@ -463,6 +503,8 @@ function content_profile_content_profile_settings() { 'edit_link' => 0, 'edit_tab' => 'sub', 'add_link' => 1, + 'page_redirect' => 0, + 'edit_page_redirect' => 0, ); }