Index: bio.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/bio/bio.module,v retrieving revision 1.2.2.29 diff -u -r1.2.2.29 bio.module --- bio.module 11 Apr 2009 04:34:52 -0000 1.2.2.29 +++ bio.module 19 Aug 2010 16:53:53 -0000 @@ -168,34 +168,37 @@ * on registration if any bio fields are set to show on the registration form. */ function bio_user_register_submit($form_values) { - // Create bio node for this user. - $node = new StdClass; - $node->type = bio_get_type(); - $node->uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $form_values['name'])); - $node->title = $form_values['name']; - $node->name = $form_values['name']; - node_object_prepare($node); - - $node_options = variable_get('node_options_'. $node->type, array('status', 'promote')); - foreach (array('status', 'promote', 'sticky') as $key) { - $node->$key = in_array($key, $node_options); - } - // Always use the default revision setting. - $node->revision = in_array('revision', $node_options); + // Only create the node on registration if Bio's form values are on the form. + if (variable_get('bio_regstration_form', 0)) { + // Create bio node for this user. + $node = new StdClass; + $node->type = bio_get_type(); + $node->uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $form_values['name'])); + $node->title = $form_values['name']; + $node->name = $form_values['name']; + node_object_prepare($node); - foreach ($form_values as $field_name => $value) { - if (preg_match('/^field_/', $field_name)) { - $node->$field_name = $form_values[$field_name]; + $node_options = variable_get('node_options_'. $node->type, array('status', 'promote')); + foreach (array('status', 'promote', 'sticky') as $key) { + $node->$key = in_array($key, $node_options); + } + // Always use the default revision setting. + $node->revision = in_array('revision', $node_options); + + foreach ($form_values as $field_name => $value) { + if (preg_match('/^field_/', $field_name)) { + $node->$field_name = $form_values[$field_name]; + } + } + + // Create the node. + $node = node_submit($node); + node_save($node); + + // Give us a nice log message. + if ($node->nid) { + watchdog('content', t('Bio: added %user bio upon registration.', array('%user' => $node->name)), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid")); } - } - - // Create the node. - $node = node_submit($node); - node_save($node); - - // Give us a nice log message. - if ($node->nid) { - watchdog('content', t('Bio: added %user bio upon registration.', array('%user' => $node->name)), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid")); } } @@ -337,13 +340,17 @@ * @return * Node ID of bio, or FALSE if no bio node was found. */ -function bio_for_user($uid = NULL) { +function bio_for_user($uid = NULL, $reset = FALSE) { + // Cache the node IDs of each user statically so it doesn't kill the system. + static $nids = array(); if (is_null($uid)) { global $user; $uid = $user->uid; } - - return db_result(db_query('SELECT nid FROM {bio} WHERE uid = %d', $uid)); + if (!isset($nids[$uid]) || $reset) { + $nids[$uid] = db_result(db_query('SELECT nid FROM {bio} WHERE uid = %d', $uid)); + } + return $nids[$uid]; } /**