Index: bio.module
===================================================================
RCS file: /var/lib/cvs_web_solutions/w2/sites/all/modules/bio/bio.module,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- bio.module	25 Jul 2007 21:33:43 -0000	1.1
+++ bio.module	25 Jul 2007 21:43:03 -0000	1.2
@@ -1,15 +1,37 @@
 <?php
-// $Id: bio.module,v 1.1 2007-07-25 21:33:43 jscheel Exp $
+// $Id: bio.module,v 1.2 2007-07-25 21:43:03 jscheel Exp $
 
 /** 
  * Implementation of hook_init()
  */
 function bio_init() {
-  if ($_GET['q'] == 'node/add/'.variable_get('bio_nodetype', 'bio')) {
+  $nodetype = variable_get('bio_nodetype', 'bio');
+  if ($_GET['q'] == 'node/add/'.$nodetype) {
     if (($nid = bio_for_user()) && !user_access('administer nodes')) {
       drupal_goto('node/'.$nid.'/edit');
     }
   }
+  if (!$may_cache && $_GET['q'] !== 'node/add/'.$nodetype && arg(0) !== 'logout') {
+    if (variable_get('bio_enforce', 0)) {
+      if ( !isset($user) ) {
+        global $user;
+      }
+      if ($user->uid > 1) {
+        $type = variable_get('bio_nodetype', 'bio');
+        $sql = "SELECT COUNT(n.nid)
+                FROM node n
+                WHERE n.status = 1 AND n.uid = $user->uid AND n.type = '"; 
+        $sql .= $type;
+        $sql .= "'";
+    
+        $result = db_result(db_query($sql));
+        if (!$result) {
+          drupal_set_message('Please create a bio before continuing.', 'error');
+          drupal_goto('node/add/' . $nodetype, NULL, NULL, 303);
+        }
+      }
+    }
+  }
 }
 
 /** 
@@ -188,6 +210,7 @@ function bio_for_user($uid = NULL){
  * - bio node type
  * - node types on which to display links
  * - use bio for profile
+ * - enforce bio creation 
  */
 function bio_settings() {
   $types = array();
@@ -221,5 +244,11 @@ function bio_settings() {
     '#description' => t('Display nothing but the bio node on the user profile page.'),
     '#default_value' => variable_get('bio_profile_takeover', 0),
   );
+  $form['bio_enforce'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Enforce bio.'),
+    '#description' => t('Require every user to create a bio. If they have not, redirect them.'),
+    '#default_value' => variable_get('bio_enforce', 0),
+  );
   return system_settings_form($form);
 }
