/[drupal]/contributions/modules/autoassignrole/autoassignrole-admin.inc
ViewVC logotype

Diff of /contributions/modules/autoassignrole/autoassignrole-admin.inc

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

revision 1.1.2.1 by cyberswat, Wed Sep 3 23:12:30 2008 UTC revision 1.1.2.2 by cyberswat, Mon Sep 29 16:24:13 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: autoassignrole-admin.inc,v 1.2 2008/09/03 21:29:02 cyberswat Exp $  // $Id: autoassignrole-admin.inc,v 1.1.2.1 2008/09/03 23:12:30 cyberswat Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 18  function autoassignrole_admin_form() { Line 18  function autoassignrole_admin_form() {
18        accounts created through the administrative interface as well as normal        accounts created through the administrative interface as well as normal
19        new user registration.'),        new user registration.'),
20      '#collapsible' => TRUE,      '#collapsible' => TRUE,
21      '#collapsed' => FALSE,      '#collapsed' => TRUE,
22    );    );
23    $form['autoassignrole_settings_auto']['auto_active'] = array(    $form['autoassignrole_settings_auto']['auto_active'] = array(
24      '#type' => 'radios',      '#type' => 'radios',
# Line 55  function autoassignrole_admin_form() { Line 55  function autoassignrole_admin_form() {
55        DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,        DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
56      );      );
57    }    }
58    
59      $form['autoassignrole_settings_page'] = array(
60        '#type' => 'fieldset',
61        '#title' => t('Assign from URL'),
62        '#description' => t('Assign user roles based on the URL of the role the user
63          is creating the account from.'),
64        '#collapsible' => TRUE,
65        '#collapsed' => TRUE,
66      );
67      $form['autoassignrole_settings_page']['page_active'] = array(
68        '#type' => 'radios',
69        '#title' => t('URL Role Assignment'),
70        '#default_value' => _autoassignrole_settings('page_active'),
71        '#description' => t('The end user will be allowed to select the following
72          roles when they log in.'),
73        '#options' => array(1 => t('Enabled'), 0 => t('Disabled')),
74      );
75    
76      foreach($roles as $k => $v) {
77        $form['autoassignrole_settings_page'][$k] = array(
78          '#type' => 'fieldset',
79          '#title' => $v,
80          '#description' => t('Assign user roles based on the path of the role the
81            user is creating the account from.'),
82          '#collapsible' => TRUE,
83          '#collapsed' => TRUE,
84        );
85      $form['autoassignrole_settings_page'][$k]['display'] = array(
86        '#type' => 'radios',
87        '#title' => t('Display As'),
88        '#default_value' => _autoassignrole_settings('page_active'),
89        '#description' => t('The end user will be allowed to select the following
90          roles when they log in.'),
91        '#options' => array(0 => t('Menu Items'), 1 => t('Links from registration page'), 2 => 'Pages with no navigation'),
92      );
93        $form['autoassignrole_settings_page'][$k]['path'] = array(
94          '#type' => 'textfield',
95          '#title' => t('Path'),
96          '#description' => t('The title of the field that contains the role options
97            the end user sees during registration.'),
98          '#default_value' => _autoassignrole_path($k, 'path'),
99          '#size' => 60,
100          '#maxlength' => 128,
101          '#required' => FALSE,
102        );
103        $form['autoassignrole_settings_page'][$k]['title'] = array(
104          '#type' => 'textfield',
105          '#title' => t('Title'),
106          '#description' => t('The title of the field that contains the role options
107            the end user sees during registration.'),
108          '#default_value' => _autoassignrole_path($k, 'title'),
109          '#size' => 60,
110          '#maxlength' => 128,
111          '#required' => FALSE,
112        );
113        $form['autoassignrole_settings_page'][$k]['description'] = array(
114          '#type' => 'textarea',
115          '#title' => t('Description'),
116          '#description' => t('The description displayed to the end user when they are
117            selecting thier role during registration.'),
118          '#default_value' => _autoassignrole_path($k, 'description'),
119          '#required' => FALSE,
120        );
121      }
122    
123    
124    
125    
126    
127    $form['autoassignrole_settings_user'] = array(    $form['autoassignrole_settings_user'] = array(
128      '#type' => 'fieldset',      '#type' => 'fieldset',
129      '#title' => t('User Role Assignment'),      '#title' => t('Allow User to Choose'),
130      '#collapsible' => TRUE,      '#collapsible' => TRUE,
131      '#collapsed' => FALSE,      '#collapsed' => TRUE,
132    );    );
133    $form['autoassignrole_settings_user']['user_active'] = array(    $form['autoassignrole_settings_user']['user_active'] = array(
134      '#type' => 'radios',      '#type' => 'radios',
# Line 69  function autoassignrole_admin_form() { Line 138  function autoassignrole_admin_form() {
138        roles when they log in.'),        roles when they log in.'),
139      '#options' => array(1 => t('Enabled'), 0 => t('Disabled')),      '#options' => array(1 => t('Enabled'), 0 => t('Disabled')),
140    );    );
   $roles = user_roles(TRUE);  
   // The disabled checkbox subelement for the 'authenticated user' role  
   // must be generated separately and added to the checkboxes element,  
   // because of a limitation in D6 FormAPI not supporting a single disabled  
   // checkbox within a set of checkboxes.  
   // TODO: This should be solved more elegantly. See issue #119038.  
   $checkbox_authenticated = array(  
     '#type' => 'checkbox',  
     '#title' => $roles[DRUPAL_AUTHENTICATED_RID],  
     '#default_value' => TRUE,  
     '#disabled' => TRUE,  
   );  
   unset($roles[DRUPAL_AUTHENTICATED_RID]);  
141    if ($roles) {    if ($roles) {
142      $form['autoassignrole_settings_user']['user_roles'] = array(      $form['autoassignrole_settings_user']['user_roles'] = array(
143        '#type' => 'checkboxes',        '#type' => 'checkboxes',
# Line 91  function autoassignrole_admin_form() { Line 147  function autoassignrole_admin_form() {
147        DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,        DRUPAL_AUTHENTICATED_RID => $checkbox_authenticated,
148      );      );
149    }    }
150    $form['autoassignrole_settings_user']['user_multiple'] = array(  
151      $form['autoassignrole_settings_user']['selection']['user_multiple'] = array(
152      '#type' => 'radios',      '#type' => 'radios',
153      '#title' => t('User Role Selection'),      '#title' => t('User Role Selection'),
154      '#default_value' => _autoassignrole_settings('user_multiple'),      '#default_value' => _autoassignrole_settings('user_multiple'),
# Line 154  function autoassignrole_admin_form() { Line 211  function autoassignrole_admin_form() {
211    return $form;    return $form;
212  }  }
213  function autoassignrole_admin_form_validate($form_id, $form_values) {  function autoassignrole_admin_form_validate($form_id, $form_values) {
214    if($form_values['values']['user_multiple'] == 0 &&    dpm($form_values);
215        $form_values['values']['user_selection'] == 2) {    if($form_values['values']['user_active'] == 1) {
216      form_set_error('user_selection', t('If a user can only select a single role you need to set the selection method as Radio Buttons or Selection Box.'));      if($form_values['values']['user_multiple'] == 0 &&
217    }          $form_values['values']['user_selection'] == 2) {
218    if($form_values['values']['user_multiple'] == 1 &&        form_set_error('user_selection', t('If a user can only select a single role you need to set the selection method as Radio Buttons or Selection Box.'));
219        $form_values['values']['user_selection'] == 0) {      }
220      form_set_error('user_selection', t('If a user can select multiple roles they can not use Radio Buttons as the selection method.'));      if($form_values['values']['user_multiple'] == 1 &&
221            $form_values['values']['user_selection'] == 0) {
222          form_set_error('user_selection', t('If a user can select multiple roles they can not use Radio Buttons as the selection method.'));
223        }
224    }    }
225  }  }
226  function autoassignrole_admin_form_submit($form_id, $form_values) {  function autoassignrole_admin_form_submit($form_id, $form_values) {
# Line 186  function autoassignrole_admin_form_submi Line 246  function autoassignrole_admin_form_submi
246      $form_values['values']['user_description'], 'user_description');      $form_values['values']['user_description'], 'user_description');
247    db_query("UPDATE {autoassignrole} set value = '%s' where arid = '%s'",    db_query("UPDATE {autoassignrole} set value = '%s' where arid = '%s'",
248      $form_values['values']['user_selection'], 'user_selection');      $form_values['values']['user_selection'], 'user_selection');
249      db_query("UPDATE {autoassignrole} set value = '%s' where arid = '%s'",
250        $form_values['values']['page_active'], 'page_active');
251  }  }

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.3