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 17:05:00 -0000 @@ -16,22 +16,6 @@ include_once drupal_get_path('module', 'bio') .'/bio_panels.inc'; } -/** - * Implementation of hook_init(). - */ -function bio_init() { - // TODO: This interferes with aggressive caching. Can we do this in - // hook_menu() instead? Looks like we'd need to make bio follow after node. - // Could cause problems w/ registration and/or CRUD functions. - - // Don't allow non-admin users to create more than one bio. - if ($_GET['q'] == 'node/add/'. bio_get_type()) { - if (($nid = bio_for_user()) && !user_access('administer nodes')) { - drupal_goto('node/'. $nid .'/edit'); - } - } -} - /** * Implementation of hook_menu(). */ @@ -87,18 +71,26 @@ * Implementation of hook_form_alter(). */ function bio_form_alter($form_id, &$form) { - if ($form_id == bio_get_type() .'_node_form' && arg(0) == 'user') { + if ($form_id == bio_get_type() .'_node_form') { // We're editing the bio in the user area... be sure we end up here when we // finish submission, and disallow changing the author. - $account = user_load(array('uid' => arg(1))); - $form['#redirect'] = "user/$account->uid"; - if (isset($form['author']['name'])) { - $form['author']['name']['#default_value'] = $account->name; - $form['author']['name']['#value'] = $account->name; - $form['author']['name']['#disabled'] = TRUE; - $form['uid']['#value'] = $account->uid; - 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.'); + if (arg(0) == 'user') { + $account = user_load(array('uid' => arg(1))); + $form['#redirect'] = "user/$account->uid"; + if (isset($form['author']['name'])) { + $form['author']['name']['#default_value'] = $account->name; + $form['author']['name']['#value'] = $account->name; + $form['author']['name']['#disabled'] = TRUE; + $form['uid']['#value'] = $account->uid; + 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.'); + } + } + else if (arg(0) == 'node' && arg(1) == 'add' && arg(2) == bio_get_type()) { + // Make sure the user doesn't add two Bio nodes. + if (($nid = bio_for_user()) && !user_access('administer nodes')) { + drupal_goto('node/'. $nid .'/edit'); + } } } }