| 1 |
<?php |
<?php |
| 2 |
|
// $Id$ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
|
* @file |
| 6 |
|
* |
| 7 |
|
*/ |
| 8 |
|
|
| 9 |
|
/** |
| 10 |
* Implementation of hook_form_alter(). |
* Implementation of hook_form_alter(). |
| 11 |
*/ |
*/ |
| 12 |
function inline_registration_form_alter($form_id, &$form) { |
function inline_registration_form_alter($form_id, &$form) { |
| 13 |
if ($form['type']['#value'] . '_node_form' == $form_id && arg(1) == 'add') { // This is a node/add form |
if ($form['type']['#value'] .'_node_form' == $form_id && variable_get('inline_registration_'. $form['#node']->type, 0) && arg(1) == 'add') { // This is a node/add form |
| 14 |
global $user; |
global $user; |
| 15 |
if ($user->uid == 0) { // User is not logged in |
if ($user->uid == 0) { // User is not logged in |
| 16 |
|
|
| 19 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 20 |
'#title' => t('Login or Register as a New User'), |
'#title' => t('Login or Register as a New User'), |
| 21 |
'#description' => t('You are not currently logged in. In order to post this item please !login or provide the following details to register.', array('!login' => l(t('login now'), 'user/login', NULL, 'destination='. $_GET['q']))), |
'#description' => t('You are not currently logged in. In order to post this item please !login or provide the following details to register.', array('!login' => l(t('login now'), 'user/login', NULL, 'destination='. $_GET['q']))), |
| 22 |
'#weight' => -99, |
'#weight' => variable_get('inline_registration_weight_'. $form['#node']->type, 0), |
| 23 |
); |
); |
| 24 |
$form['register']['form'] = user_register(); |
$form['register']['form'] = user_register(); |
| 25 |
|
|
| 37 |
$form['#submit'] = array_reverse($form['#submit']); |
$form['#submit'] = array_reverse($form['#submit']); |
| 38 |
} |
} |
| 39 |
} |
} |
| 40 |
|
|
| 41 |
|
if ($form_id == 'node_type_form' && isset($form['identity']['type'])) { |
| 42 |
|
$form['inline_registration'] = array( |
| 43 |
|
'#type' => 'fieldset', |
| 44 |
|
'#title' => t('Registration inline'), |
| 45 |
|
'#description' => t('Setting for publishing this content from anonymous user, and automatically create account for this.'), |
| 46 |
|
'#weight' => 20, |
| 47 |
|
'#collapsible' => TRUE, |
| 48 |
|
'#collapsed' => variable_get('inline_registration_'. $form['#node_type']->type, 0) ? FALSE : TRUE, |
| 49 |
|
); |
| 50 |
|
$form['inline_registration']['inline_registration'] = array( |
| 51 |
|
'#type' => 'checkbox', |
| 52 |
|
'#title' => t('Registration inline'), |
| 53 |
|
'#default_value' => variable_get('inline_registration_'. $form['#node_type']->type, 0), |
| 54 |
|
'#description' => t('Enable user creation from this content.'), |
| 55 |
|
); |
| 56 |
|
$form['inline_registration']['inline_registration_weight'] = array( |
| 57 |
|
'#type' => 'weight', |
| 58 |
|
'#title' => t('Weight of field'), |
| 59 |
|
'#default_value' => variable_get('inline_registration_weight_'. $form['#node_type']->type, -10), |
| 60 |
|
'#description' => t("Select weight for this field into content creation form."), |
| 61 |
|
); |
| 62 |
|
} |
| 63 |
} |
} |
| 64 |
|
|
| 65 |
/** |
/** |