| 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 |
| 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()); |
| 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()); |
| 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 |
/** |
/** |
| 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(); |
| 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 |
|
|
| 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 |
|
|