/[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.21, Thu Jul 17 20:28:39 2008 UTC revision 1.22, Thu Jul 17 20:37:37 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id$  // $Id: webserver_auth.module,v 1.21 2008/07/17 20:28:39 weitzman Exp $
3    
4  function webserver_auth_menu() {  function webserver_auth_menu() {
5    $items = array();    $items = array();
# Line 57  function webserver_auth_init() { Line 57  function webserver_auth_init() {
57   * Implementation of hook_user().   * Implementation of hook_user().
58   */   */
59  function webserver_auth_user($op, &$edit, &$account, $category = NULL) {  function webserver_auth_user($op, &$edit, &$account, $category = NULL) {
60    if ($op == 'insert' && $category = 'account') {    if ($op == 'submit' && $category = 'account') {
61      $account->name = trim($account->name);      // Only fiddle with new accounts.
62      // Pretty up the username for NTLM authentication (i.e. Windows)      if (empty($account->uid)) {
63      if (variable_get('webserver_auth_strip_prefix', TRUE)) {        $account->name = trim($account->name);
64        // Get 'bar' from 'foo1\foo2\bar'        // Pretty up the username for NTLM authentication (i.e. Windows)
65        $account->name = array_pop(explode("\\", $account->name));        if (variable_get('webserver_auth_strip_prefix', TRUE)) {
66      }          // Get 'bar' from 'foo1\foo2\bar'
67      if (variable_get('webserver_auth_strip_domain', TRUE)) {          $account->name = array_pop(explode("\\", $account->name));
68        // Get 'foo' from 'foo@bar'        }
69        $account->name = array_shift(explode('@', $account->name));        if (variable_get('webserver_auth_strip_domain', TRUE)) {
70      }          // Get 'foo' from 'foo@bar'
71            $account->name = array_shift(explode('@', $account->name));
72          }
73    
74      // Generate an e-mail address automagically        // Generate an e-mail address automagically
75      if ($domain = variable_get('webserver_auth_email_domain', '')) {        if ($domain = variable_get('webserver_auth_email_domain', '')) {
76        if ($account->name) {          if ($account->name) {
77          $account->mail = $account->name. '@'. $domain;            $account->mail = $account->name. '@'. $domain;
78            }
79          }
80          // run some custom code to modify the user object at creation time
81          if ($code = variable_get('webserver_auth_insert', '')) {
82            eval('?>'. $code);
83        }        }
     }  
     // run some custom code to modify the user object at creation time  
     if ($code = variable_get('webserver_auth_insert', '')) {  
       eval('?>'. $code);  
84      }      }
85    }    }
86    elseif ($op == 'logout') {    elseif ($op == 'logout') {
# Line 117  function webserver_auth_settings() { Line 120  function webserver_auth_settings() {
120        '#type' => 'textarea',        '#type' => 'textarea',
121        '#title' => 'User account modification',        '#title' => 'User account modification',
122        '#default_value' => variable_get('webserver_auth_insert', ''),        '#default_value' => variable_get('webserver_auth_insert', ''),
123        '#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."),        '#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."),
124      ),      ),
125    );    );
126    return system_settings_form($form);    return system_settings_form($form);

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

  ViewVC Help
Powered by ViewVC 1.1.2