| 1 |
<?php |
<?php |
| 2 |
// $Id$ |
// $Id: inline_registration.module,v 1.1.4.2 2009/03/20 18:30:37 livido Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 6 |
* |
* |
| 7 |
*/ |
*/ |
| 8 |
|
|
|
/** |
|
|
* Implementation of hook_menu(). |
|
|
*/ |
|
|
function inline_registration_menu() { |
|
|
$items['admin/settings/inline_registration'] = array( |
|
|
'title' => t('Inline registration'), |
|
|
'description' => t('Select the content types which should have an inline registration form.'), |
|
|
'page callback' => 'drupal_get_form', |
|
|
'page arguments' => array('inline_registration_admin_settings'), |
|
|
'access arguments' => array('access administration pages'), |
|
|
'file' => 'inline_registration.pages.inc', |
|
|
); |
|
|
|
|
|
return $items; |
|
|
} |
|
|
|
|
| 9 |
|
|
| 10 |
/** |
/** |
| 11 |
* Implementation of hook_form_alter(). |
* Implementation of hook_form_alter(). |
| 12 |
*/ |
*/ |
| 13 |
function inline_registration_form_alter(&$form, $form_state, $form_id) { |
function inline_registration_form_alter(&$form, $form_state, $form_id) { |
| 14 |
global $user; |
global $user; |
| 15 |
$types = variable_get('inline_registration_content_types', array()); |
if ($user->uid == 0 && variable_get('inline_registration_'. $form['#node']->type, 0)) { |
|
|
|
|
if ($user->uid == 0 && in_array($form['type']['#value'], $types)) { |
|
| 16 |
|
|
| 17 |
$form['register'] = array( |
$form['register'] = array( |
| 18 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 19 |
'#title' => t('Login or Register as a New User'), |
'#title' => t('Login or Register as a New User'), |
| 20 |
'#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', array('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', array('destination='. $_GET['q'])))), |
| 21 |
'#weight' => -99, |
'#weight' => variable_get('inline_registration_weight_'. $form['#node']->type, 0), |
| 22 |
); |
); |
| 23 |
|
|
| 24 |
$form['register']['form'] = drupal_retrieve_form('user_register', $form_state); |
$form['register']['form'] = drupal_retrieve_form('user_register', $form_state); |
| 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 |
|
|
| 66 |
/** |
/** |