/[drupal]/contributions/modules/bio/bio.module
ViewVC logotype

Diff of /contributions/modules/bio/bio.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2.2.27, Wed Mar 19 18:46:38 2008 UTC revision 1.2.2.28, Mon Mar 24 19:16:34 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: bio.module,v 1.2.2.26 2008/03/19 00:55:55 dww Exp $  // $Id: bio.module,v 1.2.2.27 2008/03/19 18:46:38 dww Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 100  function bio_form_alter($form_id, &$form Line 100  function bio_form_alter($form_id, &$form
100        $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']['#description'] = t('This field is disabled. You cannot alter the author of this entry from within the user area.');
101      }      }
102    }    }
103    }
104    
105    // Display CCK fields on the user registration form, if they've been  /**
106    // marked as such.   * Returns a FAPI form array for use on the user registration form.
107    if ($form_id == 'user_register' && variable_get('bio_regstration_form', 0) && module_exists('content')) {   *
108     * @see bio_user().
109     */
110    function bio_user_register_form() {
111      $form = array();
112      if (variable_get('bio_regstration_form', 0) && module_exists('content')) {
113      $widget_types = _content_widget_types();      $widget_types = _content_widget_types();
114      $fields = _bio_get_fields();      $fields = _bio_get_fields();
115      $default_values = variable_get('bio_regstration_form_fields', array());      $default_values = variable_get('bio_regstration_form_fields', array());
# Line 112  function bio_form_alter($form_id, &$form Line 118  function bio_form_alter($form_id, &$form
118      $node = new stdClass();      $node = new stdClass();
119      $node->type = bio_get_type();      $node->type = bio_get_type();
120    
121        $bio_type_name = node_get_types('name', bio_get_type());
122        $form['bio_info'] = array(
123          '#type' => 'fieldset',
124          '#title' => t('@bio_type_name information', array('@bio_type_name' => $bio_type_name)),
125        );
126    
127      foreach ($fields as $field_name => $field) {      foreach ($fields as $field_name => $field) {
128        if ($field['required'] || !empty($default_values[$field_name])) {        if ($field['required'] || !empty($default_values[$field_name])) {
129          $node_field = content_default_value($node, $field, array());          $node_field = content_default_value($node, $field, array());
# Line 123  function bio_form_alter($form_id, &$form Line 135  function bio_form_alter($form_id, &$form
135          // Get the form field and add it to the form.          // Get the form field and add it to the form.
136          $cck_field = $function('prepare form values', $node, $field, $node_field);          $cck_field = $function('prepare form values', $node, $field, $node_field);
137          $cck_field = $function('form', $node, $field, $node_field);          $cck_field = $function('form', $node, $field, $node_field);
138          $form = array_merge($form, $cck_field);          $form['bio_info'][] = $cck_field;
   
139        }        }
140      }      }
141    
142      // Add custom validate/submit handlers.      // Add custom validate handler.
     $form['#submit']['bio_user_register_submit'] = array();  
143      $form['#validate']['bio_user_register_validate'] = array();      $form['#validate']['bio_user_register_validate'] = array();
144    }    }
145      return $form;
146  }  }
147    
148  /**  /**
# Line 155  function bio_user_register_validate($for Line 166  function bio_user_register_validate($for
166   * Submit handler for user registration form. Automatically creates a bio node   * Submit handler for user registration form. Automatically creates a bio node
167   * on registration if any bio fields are set to show on the registration form.   * on registration if any bio fields are set to show on the registration form.
168   */   */
169  function bio_user_register_submit($form_id, $form_values) {  function bio_user_register_submit($form_values) {
170    // Create bio node for this user.    // Create bio node for this user.
171    $node = new StdClass;    $node = new StdClass;
172    $node->type = bio_get_type();    $node->type = bio_get_type();
# Line 255  function bio_nodeapi(&$node, $op, $a3 = Line 266  function bio_nodeapi(&$node, $op, $a3 =
266   */   */
267  function bio_user($op, &$edit, &$account, $category = NULL) {  function bio_user($op, &$edit, &$account, $category = NULL) {
268    // If there's no bio for this user, nothing to do here.    // If there's no bio for this user, nothing to do here.
269    if (!$nid = bio_for_user($account->uid)) {    if ($op != 'register' &&  $op != 'insert' && !$nid = bio_for_user($account->uid)) {
270      return;      return;
271    }    }
272    
# Line 283  function bio_user($op, &$edit, &$account Line 294  function bio_user($op, &$edit, &$account
294        }        }
295        break;        break;
296    
297        case 'register':
298          // Display CCK fields on the user registration form, if they've been
299          // marked as such.
300          return bio_user_register_form();
301          break;
302    
303        case 'insert':
304          return bio_user_register_submit($edit);
305          break;
306    }    }
307  }  }
308    

Legend:
Removed from v.1.2.2.27  
changed lines
  Added in v.1.2.2.28

  ViewVC Help
Powered by ViewVC 1.1.2