| | |
| | | |
| | | // read prefs and add email address |
| | | $this->read_squirrel_prefs($p['user']); |
| | | if (($this->identities_level == 0 || $this->identities_level == 2) && $rcmail->config->get('squirrelmail_set_alias') && $this->prefs['email_address']) |
| | | if (($this->identities_level == 0 || $this->identities_level == 2) |
| | | && $rcmail->config->get('squirrelmail_set_alias') |
| | | && $this->prefs['email_address'] |
| | | ) { |
| | | $p['user_email'] = $this->prefs['email_address']; |
| | | } |
| | | |
| | | return $p; |
| | | } |
| | | |
| | |
| | | |
| | | // prefs are set in create_user() |
| | | if ($this->prefs) { |
| | | if ($this->prefs['full_name']) |
| | | if ($this->prefs['full_name']) { |
| | | $p['record']['name'] = $this->prefs['full_name']; |
| | | if (($this->identities_level == 0 || $this->identities_level == 2) && $this->prefs['email_address']) |
| | | } |
| | | |
| | | if (($this->identities_level == 0 || $this->identities_level == 2) && $this->prefs['email_address']) { |
| | | $p['record']['email'] = $this->prefs['email_address']; |
| | | if ($this->prefs['___signature___']) |
| | | } |
| | | |
| | | if ($this->prefs['___signature___']) { |
| | | $p['record']['signature'] = $this->prefs['___signature___']; |
| | | if ($this->prefs['reply_to']) |
| | | } |
| | | |
| | | if ($this->prefs['reply_to']) { |
| | | $p['record']['reply-to'] = $this->prefs['reply_to']; |
| | | if (($this->identities_level == 0 || $this->identities_level == 1) && isset($this->prefs['identities']) && $this->prefs['identities'] > 1) { |
| | | } |
| | | |
| | | if (($this->identities_level == 0 || $this->identities_level == 1) |
| | | && isset($this->prefs['identities']) && $this->prefs['identities'] > 1 |
| | | ) { |
| | | for ($i=1; $i < $this->prefs['identities']; $i++) { |
| | | unset($ident_data); |
| | | $ident_data = array('name' => '', 'email' => ''); // required data |
| | | if ($this->prefs['full_name'.$i]) |
| | | |
| | | if ($this->prefs['full_name'.$i]) { |
| | | $ident_data['name'] = $this->prefs['full_name'.$i]; |
| | | if ($this->identities_level == 0 && $this->prefs['email_address'.$i]) |
| | | } |
| | | |
| | | if ($this->identities_level == 0 && $this->prefs['email_address'.$i]) { |
| | | $ident_data['email'] = $this->prefs['email_address'.$i]; |
| | | else |
| | | } |
| | | else { |
| | | $ident_data['email'] = $p['record']['email']; |
| | | if ($this->prefs['reply_to'.$i]) |
| | | } |
| | | |
| | | if ($this->prefs['reply_to'.$i]) { |
| | | $ident_data['reply-to'] = $this->prefs['reply_to'.$i]; |
| | | if ($this->prefs['___sig'.$i.'___']) |
| | | } |
| | | |
| | | if ($this->prefs['___sig'.$i.'___']) { |
| | | $ident_data['signature'] = $this->prefs['___sig'.$i.'___']; |
| | | } |
| | | |
| | | // insert identity |
| | | $rcmail->user->insert_identity($ident_data); |
| | | } |
| | |
| | | |
| | | // Set identities_level for operations of this plugin |
| | | $ilevel = $rcmail->config->get('squirrelmail_identities_level'); |
| | | if ($ilevel === null) |
| | | if ($ilevel === null) { |
| | | $ilevel = $rcmail->config->get('identities_level', 0); |
| | | } |
| | | |
| | | $this->identities_level = intval($ilevel); |
| | | } |
| | |
| | | |
| | | /**** File based backend ****/ |
| | | if ($rcmail->config->get('squirrelmail_driver') == 'file' && ($srcdir = $rcmail->config->get('squirrelmail_data_dir'))) { |
| | | if (($hash_level = $rcmail->config->get('squirrelmail_data_dir_hash_level')) > 0) |
| | | if (($hash_level = $rcmail->config->get('squirrelmail_data_dir_hash_level')) > 0) { |
| | | $srcdir = slashify($srcdir).chunk_split(substr(base_convert(crc32($uname), 10, 16), 0, $hash_level), 1, '/'); |
| | | } |
| | | |
| | | $prefsfile = slashify($srcdir) . $uname . '.pref'; |
| | | $abookfile = slashify($srcdir) . $uname . '.abook'; |
| | | $sigfile = slashify($srcdir) . $uname . '.sig'; |
| | |
| | | if (filesize($abookfile)) { |
| | | foreach(file($abookfile) as $line) { |
| | | list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', utf8_encode(rtrim($line))); |
| | | if ($rec['name'] && $rec['email']) |
| | | if ($rec['name'] && $rec['email']) { |
| | | $this->abook[] = $rec; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | /**** Database backend ****/ |
| | | } |
| | | // Database backend |
| | | else if ($rcmail->config->get('squirrelmail_driver') == 'sql') { |
| | | $this->prefs = array(); |
| | | |
| | | /* connect to squirrelmail database */ |
| | | // connect to squirrelmail database |
| | | $db = rcube_db::factory($rcmail->config->get('squirrelmail_dsn')); |
| | | |
| | | $db->set_debug($rcmail->config->get('sql_debug')); |
| | | $db->db_connect('r'); // connect in read mode |
| | | |
| | | /* retrieve prefs */ |
| | | // retrieve prefs |
| | | $userprefs_table = $rcmail->config->get('squirrelmail_userprefs_table'); |
| | | $address_table = $rcmail->config->get('squirrelmail_address_table'); |
| | | $db_charset = $rcmail->config->get('squirrelmail_db_charset'); |
| | | |
| | | if ($db_charset) |
| | | if ($db_charset) { |
| | | $db->query('SET NAMES '.$db_charset); |
| | | } |
| | | |
| | | $sql_result = $db->query('SELECT * FROM ' . $db->quote_identifier($userprefs_table) |
| | | .' WHERE `user` = ?', $uname); // ? is replaced with emailaddress |
| | |
| | | $this->prefs[$sql_array['prefkey']] = rcube_charset::convert(rtrim($sql_array['prefval']), $db_charset); |
| | | } |
| | | |
| | | /* retrieve address table data */ |
| | | // retrieve address table data |
| | | $sql_result = $db->query('SELECT * FROM ' . $db->quote_identifier($address_table) |
| | | .' WHERE `owner` = ?', $uname); // ? is replaced with emailaddress |
| | | |
| | |
| | | $rec['email'] = rcube_charset::convert(rtrim($sql_array['email']), $db_charset); |
| | | $rec['notes'] = rcube_charset::convert(rtrim($sql_array['label']), $db_charset); |
| | | |
| | | if ($rec['name'] && $rec['email']) |
| | | if ($rec['name'] && $rec['email']) { |
| | | $this->abook[] = $rec; |
| | | } |
| | | } |
| | | } // end if 'sql'-driver |
| | | } |
| | | } |