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

Diff of /contributions/modules/sql_auth/sql_auth.module

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

revision 1.3 by anarcat, Thu Feb 23 21:07:06 2006 UTC revision 1.4 by ber, Fri Sep 15 13:17:50 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: sql_auth.module,v 1.2 2006/02/23 20:33:33 anarcat Exp $  // $Id: sql_auth.module,v 1.3 2006/02/23 21:07:06 anarcat Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 31  function _sql_auth_help() { Line 31  function _sql_auth_help() {
31   * Implementation of hook_settings().   * Implementation of hook_settings().
32   */   */
33  function sql_auth_settings() {  function sql_auth_settings() {
34    $group = form_textfield(t('Affiliate name'), 'sql_auth_aff_name', variable_get('sql_auth_aff_name', 'Another database'), 55, 128, t('The name of the affiliate, listed on the login page'));    $form = array();
35    $group .= form_textarea(t('Affiliate explanation'), 'sql_auth_aff_desc', variable_get('sql_auth_aff_desc', _sql_auth_help()), 55, 15, t('The name of the affiliate, listed on the login page'));    $form['sql_auth_aff_settings'] = array(
36    $group .= form_textfield(t('Affiliate extension'), 'sql_auth_aff_server', variable_get('sql_auth_aff_server', 'database_name'), 55, 128, t('The part after the @. So a user \'foo\' users logs in with foo@database_name'));          '#type' => 'fieldset',
37    $group .= form_checkbox(t('Use full username string'), 'sql_auth_aff_server_include', 1, variable_get('sql_auth_aff_server_include', 0), t('Wether to send the full login string (including the @database_name) as a username to the database server when authenticating.'));          '#title' => t('Affiliate Settings'),
38    $output = form_group(t('User help'), $group);          '#collapsible' => TRUE,
39            '#collapsed' => TRUE);
40    $group = NULL;    $form['sql_auth_aff_settings']['sql_auth_aff_name'] = array(
41    $group = form_textfield(t('Database string'), 'sql_auth_string', variable_get('sql_auth_string', 'mysql://username:password@localhost/database'), 55, 128, t('The database string, in the form of mysql://username:password@localhost/database. <strong>Note:!</strong> storing your information, with unecrypted passwords like this is unsafe. In that case, please add a few lines to settings.php:          '#type' => 'textfield',
42            '#title' => t('Affiliate name'),
43            '#default_value' => variable_get('sql_auth_aff_name', 'Another database'),
44            '#size' => 55,
45            '#maxlength' => 128,
46            '#description' => t('The name of the affiliate, listed on the login page'));
47      $form['sql_auth_aff_settings']['sql_auth_aff_desc'] = array(
48            '#type' => 'textarea',
49            '#title' => t('Affiliate explanation'),
50            '#default_value' => variable_get('sql_auth_aff_desc', _sql_auth_help()),
51            '#cols' => 55,
52            '#rows' => 15,
53            '#description' => t('Description of the affiliate, listed on the login page'));
54      $form['sql_auth_aff_settings']['sql_auth_aff_server'] = array(
55            '#type' => 'textfield',
56            '#title' => t('Affiliate extension'),
57            '#default_value' => variable_get('sql_auth_aff_server', 'database_name'),
58            '#size' => 55,
59            '#maxlength' => 128,
60            '#description' => t('The part after the @. So a user \'foo\' users logs in with foo@database_name'));
61      $form['sql_auth_aff_settings']['sql_auth_aff_server_include'] = array(
62            '#type' => 'checkbox',
63            '#title' => t('Use full username string'),
64            '#return_value' => 1,
65            '#default_value' => variable_get('sql_auth_aff_server_include', 0),
66            '#description' => t('Wether to send the full login string (including the @database_name) as a username to the database server when authenticating.'));
67    
68      $form['sql_auth_auth_settings'] = array(
69            '#type' => 'fieldset',
70            '#title' => t('Authentcation Settings'),
71            '#collapsible' => TRUE,
72            '#collapsed' => TRUE);
73      $form['sql_auth_auth_settings']['sql_auth_string'] = array(
74            '#type' => 'textfield',
75            '#title' => t('Database string'),
76            '#default_value' => variable_get('sql_auth_string', 'mysql://username:password@localhost/database'),
77            '#size' => 55,
78            '#maxlength' => 128,
79            '#description' => t('The database string, in the form of mysql://username:password@localhost/database. <strong>Note:!</strong> storing your information, with unecrypted passwords like this is unsafe. In that case, please add a few lines to settings.php:
80    <pre>    <pre>
81      $db_url[\'default\'] = \'mysql://drupal:drupal@localhost/drupal\';      $db_url[\'default\'] = \'mysql://drupal:drupal@localhost/drupal\';
82      $db_url[\'mydb\'] = \'mysql://user:pwd@localhost/anotherdb\';      $db_url[\'mydb\'] = \'mysql://user:pwd@localhost/anotherdb\';
83    </pre>    </pre>
84    and remove your default $db_url = \'mysql://drupal:drupal@localhost/drupal\';<br/>    and remove your default $db_url = \'mysql://drupal:drupal@localhost/drupal\';<br/>
85    You can then give \'mydb\' in this textfield.<br/>    You can then give \'mydb\' in this textfield.<br/>
86    <a href="http://drupal.org/node/18429">more info here</a>    <a href="http://drupal.org/node/18429">more info here</a>'));
87    '));    $form['sql_auth_auth_settings']['sql_auth_table'] = array(
88    $group .= form_textfield(t('Database table'), 'sql_auth_table', variable_get('sql_auth_table', 'users'),  55, 128, t('The table where the users are stored.'));          '#type' => 'textfield',
89    $group .= form_textfield(t('User column'), 'sql_auth_user_col', variable_get('sql_auth_user_col', 'name'), 55, 128, t('The table column where the username is stored'));          '#title' => t('Database table'),
90    $group .= form_textfield(t('Password column'), 'sql_auth_pass_col', variable_get('sql_auth_pass_col', 'pass'), 55, 128, t('The table column where the password is stored'));          '#default_value' => variable_get('sql_auth_table', 'users'),
91    $group .= form_select(t('Password scheme'), 'sql_auth_pass_scheme', variable_get('sql_auth_pass_scheme', 'MD5'), _sql_auth_supported_schemes(), t('The password algorithm that is used to store (and check) the password. Drupal uses MD5 authentication by default, but some other systems might use other encryption algorithm. Those are passed to the database backend verbatim, as a function call so support might vary from a database engine to another. See %url for details.', array('url' => 'http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html')));          '#size' => 55,
92    $group .= form_checkbox(t('Encrypt with salt'), 'sql_auth_pass_salt', 1, variable_get('sql_auth_pass_salt', 0), t('Wether to encrypt the password with a salt when checking. Usually only relevant with the ENCRYPT() function.'));          '#maxlength' => 128,
93    $output .= form_group(t('Database settings'), $group);          '#description' => t('The table where the users are stored.'));
94    return $output;    $form['sql_auth_auth_settings']['sql_auth_user_col'] = array(
95            '#type' => 'textfield',
96            '#title' => t('User column'),
97            '#default_value' => variable_get('sql_auth_user_col', 'name'),
98            '#size' => 55,
99            '#maxlength' => 128,
100            '#description' => t('The table column where the username is stored'));
101      $form['sql_auth_auth_settings']['sql_auth_pass_col'] = array(
102            '#type' => 'textfield',
103            '#title' => t('Password column'),
104            '#default_value' => variable_get('sql_auth_pass_col', 'pass'),
105            '#size' => 55,
106            '#maxlength' => 128,
107            '#description' => t('The table column where the password is stored'));
108      $form['sql_auth_auth_settings']['sql_auth_pass_scheme'] = array(
109            '#type' => 'select',
110            '#title' => t('Password scheme'),
111            '#default_value' => variable_get('sql_auth_pass_scheme', 'MD5'),
112            '#options' => _sql_auth_supported_schemes(),
113            '#description' => t('The password algorithm that is used to store (and check) the password. Drupal uses MD5 authentication by default, but some other systems might use other encryption algorithm. Those are passed to the database backend verbatim, as a function call so support might vary from a database engine to another. See %url for details.', array('url' => 'http://dev.mysql.com/doc/refman/5.0/en/encryption-functions.html')));
114      $form['sql_auth_auth_settings']['sql_auth_pass_salt'] = array(
115            '#type' => 'checkbox',
116            '#title' => t('Encrypt with salt'),
117            '#return_value' => 1,
118            '#default_value' => variable_get('sql_auth_pass_salt', 0),
119            '#description' => t('Wether to encrypt the password with a salt when checking. Usually only relevant with the ENCRYPT() function.'));
120      return $form;
121  }  }
122    
123    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.3