The Problem: If a bio node is created by an administrator or someone who has administer node privileges and then changes the author of the node, the bio node ID reference in the bio table is not updated.

Ramifications: Even if an administrator has assigned a bio node to another user who is only allowed to have 1 bio node, that user is still able to create a bio node.

Reasoning for this fix: The project I am using this module for has biography pages for all of their personnel. A staff worker in Human Resources will be creating user accounts and creating a basic biography for all new personnel. So for this project we needed the ability to have administrators create biographies and then hand over control to the user by changing the node Author. This small patch solves the problem.


jmstacey’s picture

And by "this small patch solves the problem" I mean "Here's the diff because file uploads don't seem to be working at the moment."

--- sites/all/modules/bio/bio.module	2008-01-28 02:30:13.000000000 -0600
+++ sites/all/modules/bio/bioNew.module	2008-06-04 13:54:55.000000000 -0500
@@ -239,6 +239,11 @@ function bio_nodeapi(&$node, $op, $a3 = 
         form_set_error('name', t('This user already has a @bio. Edit it <a href="@link">here</a> or assign this entry to another user.', array('@bio' => node_get_types('name', $node), '@link' => url('node/'. $nid .'/edit'))));
+	case 'update':
+	  // Node updated, write new uid to bio table.
+	  $account = user_load(array('name' => $node->name));
+	  db_query('UPDATE {bio} SET uid = %d WHERE nid = %d LIMIT 1', $account->uid, $node->nid);
+	  break;
     case 'insert':
       // Record user's bio in bio table.
       db_query('INSERT INTO {bio} (nid, uid) VALUES (%d, %d)', $node->nid, $node->uid);
sun’s picture

Status: Needs review » Needs work

Issue attachments should work now.