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

Diff of /contributions/modules/inline_registration/inline_registration.module

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

revision 1.1.4.1, Fri Mar 20 16:55:40 2009 UTC revision 1.1.4.2, Fri Mar 20 18:30:37 2009 UTC
# Line 7  Line 7 
7   */   */
8    
9  /**  /**
10     * Implementation of hook_menu().
11     */
12    function inline_registration_menu() {
13      $items['admin/settings/inline_registration'] = array(
14        'title' => t('Inline registration'),
15        'description' => t('Select the content types which should have an inline registration form.'),
16        'page callback' => 'drupal_get_form',
17        'page arguments' => array('inline_registration_admin_settings'),
18        'access arguments' => array('access administration pages'),
19        'file' => 'inline_registration.pages.inc',
20      );
21    
22      return $items;
23    }
24    
25    
26    /**
27   * Implementation of hook_form_alter().   * Implementation of hook_form_alter().
28   */   */
29  function inline_registration_form_alter(&$form, $form_state, $form_id) {  function inline_registration_form_alter(&$form, $form_state, $form_id) {
30    global $user;    global $user;
31      $types = variable_get('inline_registration_content_types', array());
32    
33    if ($user->uid == 0) { // User is not logged in    if ($user->uid == 0 && in_array($form['type']['#value'], $types)) {
34      if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id && arg(1) == 'add') {  
35        // Add the user registration form to the node/add/page      $form['register'] = array(
36        $form['register'] = array(        '#type' => 'fieldset',
37          '#type' => 'fieldset',        '#title' => t('Login or Register as a New User'),
38          '#title' => t('Login or Register as a New User'),        '#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'])))),
39          '#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'])))),        '#weight' => -99,
40          '#weight' => -99,      );
41        );  
42        $form['register']['form'] = user_register();      $form['register']['form'] = drupal_retrieve_form('user_register', $form_state);
   
       // Remove the user_register submit button in favor of the node submit button  
       $form['register']['form']['submit'] = NULL;  
   
       // Rename the user field to remind the user that this is the registration form and not a login field  
       $form['register']['form']['name']['#title'] = t('Choose a Username');  
   
       // Add our own validation and submit function to the node_form  
       $form['#validate'][] = 'inline_registration_validate';  
       $form['#submit'][] = 'inline_registration_submit';  
43    
44        // And ensure our submit function is called first (so the node is authored by the newly created user)      // Remove the user_register submit button in favor of the node submit button
45        $form['#submit'] = array_reverse($form['#submit']);      unset($form['register']['form']['submit']);
46      }  
47        // Rename the user field to remind the user that this is the registration form and not a login field
48        $form['register']['form']['name']['#title'] = t('Choose a Username');
49    
50        // Add our own validation and submit function to the node_form
51        $form['#validate'][] = 'inline_registration_validate';
52        $form['#submit'][] = 'inline_registration_submit';
53    
54        // And ensure our submit function is called first (so the node is authored by the newly created user)
55        $form['#submit'] = array_reverse($form['#submit']);
56    
57    }    }
58  }  }
59    

Legend:
Removed from v.1.1.4.1  
changed lines
  Added in v.1.1.4.2

  ViewVC Help
Powered by ViewVC 1.1.2