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

Diff of /contributions/modules/webserver_auth/webserver_auth.module

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

revision 1.22, Thu Jul 17 20:37:37 2008 UTC revision 1.22.2.1, Thu Aug 7 16:38:49 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: webserver_auth.module,v 1.21 2008/07/17 20:28:39 weitzman Exp $  // $Id$
3    
4    /**
5     * Implementation of hook_menu().
6     */
7  function webserver_auth_menu() {  function webserver_auth_menu() {
8    $items = array();    $items = array();
9    $items['admin/settings/webserver_auth'] = array(    $items['admin/settings/webserver_auth'] = array(
# Line 13  function webserver_auth_menu() { Line 16  function webserver_auth_menu() {
16    return $items;    return $items;
17  }  }
18    
19    /**
20     * Implementation of hook_init().
21     */
22  function webserver_auth_init() {  function webserver_auth_init() {
23    global $user;    global $user;
24    
# Line 57  function webserver_auth_init() { Line 63  function webserver_auth_init() {
63   * Implementation of hook_user().   * Implementation of hook_user().
64   */   */
65  function webserver_auth_user($op, &$edit, &$account, $category = NULL) {  function webserver_auth_user($op, &$edit, &$account, $category = NULL) {
66    if ($op == 'submit' && $category = 'account') {    if ($op == 'insert' && $category = 'account') {
67      // Only fiddle with new accounts.      $account->name = trim($account->name);
68      if (empty($account->uid)) {      // Pretty up the username for NTLM authentication (i.e. Windows)
69        $account->name = trim($account->name);      if (variable_get('webserver_auth_strip_prefix', TRUE)) {
70        // Pretty up the username for NTLM authentication (i.e. Windows)        // Get 'bar' from 'foo1\foo2\bar'
71        if (variable_get('webserver_auth_strip_prefix', TRUE)) {        $account->name = array_pop(explode("\\", $account->name));
72          // Get 'bar' from 'foo1\foo2\bar'      }
73          $account->name = array_pop(explode("\\", $account->name));      if (variable_get('webserver_auth_strip_domain', TRUE)) {
74        }        // Get 'foo' from 'foo@bar'
75        if (variable_get('webserver_auth_strip_domain', TRUE)) {        $account->name = array_shift(explode('@', $account->name));
76          // Get 'foo' from 'foo@bar'      }
77          $account->name = array_shift(explode('@', $account->name));      db_query("UPDATE {users} SET name = '%s' WHERE uid = %d", $account->name, $account->uid);
78        }      // Generate an e-mail address automagically
79        if ($domain = variable_get('webserver_auth_email_domain', '')) {
80        // Generate an e-mail address automagically        if ($account->name) {
81        if ($domain = variable_get('webserver_auth_email_domain', '')) {          db_query("UPDATE {users} SET mail = '%s@%s' WHERE uid = %d", $account->name, $domain, $account->uid);
         if ($account->name) {  
           $account->mail = $account->name. '@'. $domain;  
         }  
       }  
       // run some custom code to modify the user object at creation time  
       if ($code = variable_get('webserver_auth_insert', '')) {  
         eval('?>'. $code);  
82        }        }
83      }      }
84        // run some custom code to modify the user object at creation time
85        if ($code = variable_get('webserver_auth_insert', '')) {
86          eval('?>'. $code);
87        }
88    }    }
89    elseif ($op == 'logout') {    elseif ($op == 'logout') {
90      global $base_url;      global $base_url;
# Line 90  function webserver_auth_user($op, &$edit Line 93  function webserver_auth_user($op, &$edit
93    }    }
94  }  }
95    
96    /**
97     * Implementation of hook_settings().
98     */
99  function webserver_auth_settings() {  function webserver_auth_settings() {
100    $form['webserver_auth_email_domain'] = array(    $form['webserver_auth_email_domain'] = array(
101      '#type' => 'textfield',      '#type' => 'textfield',
# Line 120  function webserver_auth_settings() { Line 126  function webserver_auth_settings() {
126        '#type' => 'textarea',        '#type' => 'textarea',
127        '#title' => 'User account modification',        '#title' => 'User account modification',
128        '#default_value' => variable_get('webserver_auth_insert', ''),        '#default_value' => variable_get('webserver_auth_insert', ''),
129        '#description' => t("Modify user accounts at the time of creation. Use PHP code (enclosed in <code>&lt;?php</code> and <code>?&gt;</code>). The variable <code>\$account</code> is available as in <a href=\"http://api.drupal.org/api/function/hook_user/6\">hook_user('submit',...)</a>. Changes to the \$account object will be automatically saved."),        '#description' => t("Modify user accounts at the time of creation. Use PHP code (enclosed in <code>&lt;?php</code> and <code>?&gt;</code>). The variable <code>\$account</code> is available as in <a href=\"http://api.drupal.org/api/function/hook_user/6\">hook_user('insert',...)</a>. Changes to the user object must be explicitly saved to the database to be made permanent."),
130      ),      ),
131    );    );
132    return system_settings_form($form);    return system_settings_form($form);

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.22.2.1

  ViewVC Help
Powered by ViewVC 1.1.2