Index: bio/bio.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bio/bio.info,v
retrieving revision 1.1
diff -u -p -r1.1 bio.info
--- bio/bio.info	30 Jan 2007 06:25:59 -0000	1.1
+++ bio/bio.info	27 Dec 2007 05:24:13 -0000
@@ -1,3 +1,4 @@
 ; $Id: bio.info,v 1.1 2007/01/30 06:25:59 vauxia Exp $
+core = 6.x
 name = Bio
 description = Use a custom node type for user bios
Index: bio/bio.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bio/bio.module,v
retrieving revision 1.2.2.14
diff -u -p -r1.2.2.14 bio.module
--- bio/bio.module	2 Dec 2007 21:51:26 -0000	1.2.2.14
+++ bio/bio.module	27 Dec 2007 05:24:17 -0000
@@ -4,7 +4,7 @@
 /** 
  * Implementation of hook_init()
  */
-function bio_init() {
+function bio_boot() {
   if ($_GET['q'] == 'node/add/'.variable_get('bio_nodetype', 'bio')) {
     if (($nid = bio_for_user()) && !user_access('administer nodes')) {
       drupal_goto('node/'.$nid.'/edit');
@@ -12,53 +12,48 @@ function bio_init() {
   }
 }
 
-/** 
- * Implementation of hook_menu() 
+/* hook_menu() 
  */
-function bio_menu($may_cache) {
-  global $user;
-  $items = array();
-  if ($may_cache) {
-    $items[] = array(
-      'path'  => 'admin/user/bio',
-      'title' => t('User biographies'),
-      'description' => t('User biographies'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('bio_settings'),
+function bio_menu() {
+  $items['admin/user/bio'] = array(
+	  'title' => 'User biographies',
+	  'description' => 'User biographies',
+	  'page callback' => 'drupal_get_form',
+	  'page arguments' => array('bio_settings'),
     );
-  }
-  else {
-    if (variable_get('bio_profile', 0) && (arg(0) == 'user') && (is_numeric(arg(1)))) {
-      $type = variable_get('bio_nodetype','bio');
-      $nid  = bio_for_user(arg(1));
-      // user has a bio
-      if ($nid) {
-        $node = node_load($nid);
-        $access = node_access('update', $node);
-      }
-      else {
-        $node = (object) array('type' => $type, 'uid' => arg(1));
-        $access = (($user->uid == arg(1)) && node_access('create', $type)) || user_access('administer nodes');
-      }
-      $items[] = array(
-        'path'  => 'user/'.arg(1).'/bio',
-        'title' => node_get_types('name', $type),
-        'callback' => 'node_page_edit',
-        'callback arguments' => array($node),
-        'type' => MENU_LOCAL_TASK,
-        'access' => $access,
-      );
-    }
-    elseif (variable_get('bio_profile', 0) && (arg(0) == 'node') && is_numeric(arg(1)) && !arg(2)) {
-      // if we're about to visit a bio node page, but we've got "use bios for profiles" selected,
-      // redirect to the user page
-      $node = node_load(arg(1));
-      if (user_access('access user profiles') && $node->type == variable_get('bio_nodetype','bio')) {
-        drupal_goto('user/'. $node->uid);
-      }
-    }
-  }
-  return $items;
+
+  $type = variable_get('bio_nodetype','bio');
+  $items['user/%user/bio'] = array(
+    'title' => node_get_types('name', $type),
+    'page callback' => 'bio_menu_page',
+    'page arguments' => array(1),
+    'type' => MENU_LOCAL_TASK,
+    'access callback' => 'bio_menu_access_callback',
+		'access arguments' => array(1),
+    );
+	return $items;
+}
+
+function bio_menu_access_callback($arg) {
+	$nid = bio_for_user($arg->uid);
+	if($nid) {
+		$node = node_load($nid);
+		return node_access('update',$node);
+	}
+	else {
+		global $user;
+		$type = variable_get('bio_nodetype','bio');
+		$access = (($user->uid == $arg->uid) && node_access('create', $type)) || user_access('administer nodes');
+		return $access;
+	}
+}
+
+function bio_menu_page($arg) {
+	module_load_include('inc','node','node.pages');
+	$type = variable_get('bio_nodetype','bio');
+	$nid = bio_for_user($arg->uid);
+	$node = $nid ? node_load($nid) : (object) array('type' => $type, 'uid' => $arg->uid, 'name' => $arg->name);
+	return drupal_get_form($type.'_node_form',$node);
 }
 
 /**
@@ -66,23 +61,23 @@ function bio_menu($may_cache) {
  * 
  * Handle the 
  */
-function bio_form_alter($form_id, &$form) {
-  if ($form_id == variable_get('bio_nodetype', 'bio') ."_node_form" && arg(0) == 'user') {
+function bio_form_alter(&$form, $form_state, $form_id) {	
+	
+  if ($form_id == variable_get('bio_nodetype','bio')."_node_form" && arg(0) == 'user') {
     // we're editing the bio in the user area... be sure we end up here when we finish submission
     $account = user_load(array('uid' => arg(1)));
     $form['#redirect'] = 'user/'. $account->uid;
     if (user_access('administer nodes')) {
-      $form['author']['name']['#default_value'] = $account->name;
-      $form['author']['name']['#value'] = $account->name;
-      $form['author']['name']['#disabled'] = 'disabled';
-      unset($form['author']['name']['#autocomplete_path']);
-      $form['author']['name']['#description'] = t(' This field is disabled. You cannot alter the author of this entry from within the user area.');
+			$form['author']['name']['#disabled'] = TRUE;
+			$form['author']['name']['#default_value'] = $account->name;
+			$form['author']['name']['#description'] = t(' This field is disabled. You cannot alter the author of this entry from within the user area.');
+			unset($form['author']['name']['#autocomplete_path']);
     }
-  }
+	}
 
   // Display CCK fields on the user registration form, if they've been
   // marked as such.
-  if ($form_id == 'user_register' && variable_get('bio_regstration_form', 0)) {
+  if ($form_id == 'user_register' && variable_get('bio_regstration_form', 0) && module_exists('content')) {
     $widget_types = _content_widget_types();
     $fields = _bio_get_fields();
     $default_values = variable_get('bio_regstration_form_fields', array());
@@ -157,15 +152,15 @@ function bio_user_reg_submit($form_id, $
   }
 }
 
-function bio_profile_alter(&$account, &$fields) {
+function bio_profile_alter(&$account) {
   if (variable_get('bio_profile_takeover', 0) && $bio = bio_for_user($account->uid)) {
     $bio = node_load($bio);
     $typename = node_get_types('name', variable_get('bio_nodetype', 'bio'));
-    foreach($fields as $key => $val) {
-      if ($key != $typename) {
-        unset($fields[$key]);
-      }
-    }
+		foreach($account->content as $key => $content) {
+			if($key != node_get_types('name', variable_get('bio_nodetype', 'bio'))) {
+				unset($account->content[$key]);
+			}
+		}
     $account->name = $bio->title;
   }
 }
@@ -181,6 +176,7 @@ function bio_node_info() {
     return array('bio' => array(
       'name' => t('Biography'),
       'module' => 'node',
+			'description' => t('A <em>Biography</em> is a simple node type that will replace the typical user profile view with the content of the Biography node.'),
       'has_title' => TRUE,
       'has_body' => TRUE,
       'custom' => TRUE,
@@ -202,6 +198,7 @@ function bio_nodeapi(&$node, $op, $a3 = 
   switch ($op) {
     case 'validate':
       // This user already has a bio node and this isn't it
+//			print_r($node);
       $account = user_load(array('name' => $node->name));
       $nid = bio_for_user($account->uid);
       if ($nid && ($nid != $node->nid)) {
@@ -216,14 +213,18 @@ function bio_nodeapi(&$node, $op, $a3 = 
  * 
  * - add bio to main user profile page
  */
-function bio_user($op, &$edit, &$user, $category = NULL) {
+function bio_user($op, &$edit, &$account, $category = NULL) {
   if (!variable_get('bio_profile', 0)) return;
 
   switch ($op) {
     case 'view':
-      if (!$nid = bio_for_user($user->uid)) return;
+      if (!$nid = bio_for_user($account->uid)) return;
       if (!node_access('view', $node = node_load($nid))) return;
-      return array(node_get_types('name', variable_get('bio_nodetype', 'bio')) => array('bio' => array('value' => node_view($node, FALSE, TRUE, FALSE))));
+			$account->content[node_get_types('name', variable_get('bio_nodetype', 'bio'))] = array(
+				'#value' => node_view($node, FALSE, TRUE, FALSE),
+			);
+//			print_r(array(node_get_types('name', variable_get('bio_nodetype', 'bio'))));
+//      print_r (array(node_get_types('name', variable_get('bio_nodetype', 'bio')) => array('bio' => array('value' => node_view($node, FALSE, TRUE, FALSE)))));
   }
 }
 
@@ -300,39 +301,41 @@ function bio_settings() {
   );
 
   // Add option to show fields on the registration form.
-  $form['bio_regstration_form'] = array(
-    '#type' => 'radios',
-    '#title' => t('Show fields on registration form'),
-    '#options' => array(t('Disabled'), t('Enabled')),
-    '#default_value' => variable_get('bio_regstration_form', 0),
-    '#description' => t('Enable this option to display bio fields on the user registration form. This will automatically create a bio record for a user when they register.'),
-  );
+  if (module_exists('content')) {
+    $form['bio_regstration_form'] = array(
+      '#type' => 'radios',
+      '#title' => t('Show fields on registration form'),
+      '#options' => array(t('Disabled'), t('Enabled')),
+      '#default_value' => variable_get('bio_regstration_form', 0),
+      '#description' => t('Enable this option to display bio fields on the user registration form. This will automatically create a bio record for a user when they register.'),
+    );
 
-  // Determine the options and default values.
-  $fields = _bio_get_fields();
-  $default_values = variable_get('bio_regstration_form_fields', array());
-  foreach ($fields as $field_name => $properties) {
-    $options[$field_name] = check_plain($properties['widget']['label']);
-    // Required fields are always shown on registration form.
-    if ($properties['required'] || !empty($default_values[$field_name])) {
-      $default_values[$field_name] = $field_name;
-    }
-    else {
-      $default_vales[$field_name] = 0;
+    // Determine the options and default values.
+    $fields = _bio_get_fields();
+    $default_values = variable_get('bio_regstration_form_fields', array());
+    foreach ($fields as $field_name => $properties) {
+      $options[$field_name] = check_plain($properties['widget']['label']);
+      // Required fields are always shown on registration form.
+      if ($properties['required'] || !empty($default_values[$field_name])) {
+        $default_values[$field_name] = $field_name;
+      }
+      else {
+        $default_vales[$field_name] = 0;
+      }
     }
+    // Display list of fields.
+    $form['bio_regstration_form_fields'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('Registration form fields'),
+      '#options' => $options,
+      '#default_value' => $default_values,
+      '#description' => t('Fields checked here will be displayed on the user registration form. Required fields are always shown.'),
+      '#theme' => 'bio_registration_fields',
+    );
   }
-  // Display list of fields.
-  $form['bio_regstration_form_fields'] = array(
-    '#type' => 'checkboxes',
-    '#title' => t('Registration form fields'),
-    '#options' => $options,
-    '#default_value' => $default_values,
-    '#description' => t('Fields checked here will be displayed on the user registration form. Required fields are always shown.'),
-    '#theme' => 'bio_registration_fields',
-  );
 
   $add_a_submit = system_settings_form($form);
-  $add_a_submit['#validate']['bio_settings_validate_xxx'] = array();
+  $add_a_submit['#validate'][] = 'bio_settings_validate_xxx';
   return $add_a_submit;
 }
 
@@ -344,7 +347,7 @@ function bio_settings() {
  */
 function theme_bio_registration_fields($form) {
   $fields = _bio_get_fields();
-  foreach (element_children($form) as $field_name) {
+	foreach (element_children($form) as $field_name) {
     // Disable required fields; they always show up.
     if ($fields[$field_name]['required']) {
       $form[$field_name]['#attributes'] = array('disabled' => 'disabled');
