Changeset 4018 in subversion
- Timestamp:
- Sep 30, 2010 2:50:48 AM (3 years ago)
- File:
-
- 1 edited
-
trunk/plugins/virtuser_query/virtuser_query.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/virtuser_query/virtuser_query.php
r4010 r4018 5 5 * 6 6 * Add it to the plugins list in config/main.inc.php and set 7 * SQL quer y to resolve user names and e-mail addresses from the database7 * SQL queries to resolve usernames, e-mail addresses and hostnames from the database 8 8 * %u will be replaced with the current username for login. 9 * The query should select the user's e-mail address as first column 10 * and optional identity data columns in specified order: 9 * %m will be replaced with the current e-mail address for login. 10 * 11 * Queries should select the user's e-mail address, username or the imap hostname as first column 12 * The email query could optionally select identity data columns in specified order: 11 13 * name, organization, reply-to, bcc, signature, html_signature 12 14 * 13 * $rcmail_config['virtuser_query'] = '';15 * $rcmail_config['virtuser_query'] = array('email' => '', 'user' => '', 'host' => ''); 14 16 * 15 * @version 1. 017 * @version 1.1 16 18 * @author Aleksander Machniak 19 * @author Steffen Vogel 17 20 */ 18 21 class virtuser_query extends rcube_plugin 19 22 { 20 private $ query;23 private $config; 21 24 private $app; 22 25 … … 24 27 { 25 28 $this->app = rcmail::get_instance(); 26 $this-> query= $this->app->config->get('virtuser_query');29 $this->config = $this->app->config->get('virtuser_query'); 27 30 28 if ($this->query) { 29 $this->add_hook('user2email', array($this, 'user2email')); 30 // $this->add_hook('email2user', array($this, 'email2user')); 31 } 31 if (!empty($this->config)) { 32 if (is_string($this->config)) { 33 $this->config = array('email' => $this->config); 34 } 35 36 if ($this->config['email']) { 37 $this->add_hook('user2email', array($this, 'user2email')); 38 } 39 if ($this->config['user']) { 40 $this->add_hook('email2user', array($this, 'email2user')); 41 } 42 if ($this->config['host']) { 43 $this->add_hook('authenticate', array($this, 'user2host')); 44 } 45 } 32 46 } 33 47 … … 39 53 $dbh = $this->app->get_dbh(); 40 54 41 $sql_result = $dbh->query(preg_replace('/%u/', $dbh->escapeSimple($p['user']), $this-> query));55 $sql_result = $dbh->query(preg_replace('/%u/', $dbh->escapeSimple($p['user']), $this->config['email'])); 42 56 43 57 while ($sql_arr = $dbh->fetch_array($sql_result)) { … … 62 76 } 63 77 } 64 78 65 79 $p['email'] = $result; 66 80 … … 68 82 } 69 83 84 /** 85 * EMail > User 86 */ 87 function email2user($p) 88 { 89 $dbh = $this->app->get_dbh(); 90 91 $sql_result = $dbh->query(preg_replace('/%m/', $dbh->escapeSimple($p['email']), $this->config['user'])); 92 93 if ($sql_arr = $dbh->fetch_array($sql_result)) { 94 $p['user'] = $sql_arr[0]; 95 } 96 97 return $p; 98 } 99 100 /** 101 * User > Host 102 */ 103 function user2host($p) 104 { 105 $dbh = $this->app->get_dbh(); 106 107 $sql_result = $dbh->query(preg_replace('/%u/', $dbh->escapeSimple($p['user']), $this->config['host'])); 108 109 if ($sql_arr = $dbh->fetch_array($sql_result)) { 110 $p['host'] = $sql_arr[0]; 111 } 112 113 return $p; 114 } 115 70 116 } 117
Note: See TracChangeset
for help on using the changeset viewer.
