Fix code style after PR merge

pull/266/merge
Aleksander Machniak 8 years ago
parent 6dbbf0e14e
commit 18842dd14e

@ -1,6 +1,7 @@
CHANGELOG Roundcube Webmail CHANGELOG Roundcube Webmail
=========================== ===========================
- Squirrelmail_usercopy: Add option to define character set of data files
- Removed useless 'created' column from 'session' table (#5389) - Removed useless 'created' column from 'session' table (#5389)
- Require PHP >= 5.4 - Require PHP >= 5.4
- Add possibility to preview and download attachments in mail compose (#5053) - Add possibility to preview and download attachments in mail compose (#5053)

@ -3,7 +3,7 @@
"type": "roundcube-plugin", "type": "roundcube-plugin",
"description": "Copy a new users identity and settings from a nearby Squirrelmail installation", "description": "Copy a new users identity and settings from a nearby Squirrelmail installation",
"license": "GPLv3+", "license": "GPLv3+",
"version": "1.4", "version": "1.6",
"authors": [ "authors": [
{ {
"name": "Thomas Bruederli", "name": "Thomas Bruederli",

@ -3,7 +3,7 @@
/** /**
* Copy a new users identities and contacts from a nearby Squirrelmail installation * Copy a new users identities and contacts from a nearby Squirrelmail installation
* *
* @version 1.5 * @version 1.6
* @author Thomas Bruederli, Johannes Hessellund, pommi, Thomas Lueder * @author Thomas Bruederli, Johannes Hessellund, pommi, Thomas Lueder
*/ */
class squirrelmail_usercopy extends rcube_plugin class squirrelmail_usercopy extends rcube_plugin
@ -162,7 +162,7 @@ class squirrelmail_usercopy extends rcube_plugin
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, '/'); $srcdir = slashify($srcdir).chunk_split(substr(base_convert(crc32($uname), 10, 16), 0, $hash_level), 1, '/');
} }
$file_charset = $rcmail->config->get('squirrelmail_file_charset'); $file_charset = $rcmail->config->get('squirrelmail_file_charset');
$prefsfile = slashify($srcdir) . $uname . '.pref'; $prefsfile = slashify($srcdir) . $uname . '.pref';
$abookfile = slashify($srcdir) . $uname . '.abook'; $abookfile = slashify($srcdir) . $uname . '.abook';
@ -173,31 +173,21 @@ class squirrelmail_usercopy extends rcube_plugin
$this->prefs = array(); $this->prefs = array();
foreach (file($prefsfile) as $line) { foreach (file($prefsfile) as $line) {
list($key, $value) = explode('=', $line); list($key, $value) = explode('=', $line);
if (empty($file_charset)) { $this->prefs[$key] = $this->convert_charset(rtrim($value), $file_charset);
$this->prefs[$key] = utf8_encode(rtrim($value));
} else {
$this->prefs[$key] = rcube_charset::convert(rtrim($value), $file_charset, "UTF-8");
}
} }
// also read signature file if exists // also read signature file if exists
if (is_readable($sigfile)) { if (is_readable($sigfile)) {
if (empty($file_charset)) { $sig = file_get_contents($sigfile);
$this->prefs['___signature___'] = utf8_encode(file_get_contents($sigfile)); $this->prefs['___signature___'] = $this->convert_charset($sig, $file_charset);
} else {
$this->prefs['___signature___'] = rcube_charset::convert(file_get_contents($sigfile), $file_charset, "UTF-8");
}
} }
if (isset($this->prefs['identities']) && $this->prefs['identities'] > 1) { if (isset($this->prefs['identities']) && $this->prefs['identities'] > 1) {
for ($i=1; $i < $this->prefs['identities']; $i++) { for ($i=1; $i < $this->prefs['identities']; $i++) {
// read signature file if exists // read signature file if exists
if (is_readable($sigbase.$i)) { if (is_readable($sigbase.$i)) {
if (empty($file_charset)) { $sig = file_get_contents($sigbase.$i);
$this->prefs['___sig'.$i.'___'] = utf8_encode(file_get_contents($sigbase.$i)); $this->prefs['___sig'.$i.'___'] = $this->convert_charset($sig, $file_charset);
} else {
$this->prefs['___sig'.$i.'___'] = rcube_charset::convert(file_get_contents($sigbase.$i), $file_charset, "UTF-8");
}
} }
} }
} }
@ -205,11 +195,8 @@ class squirrelmail_usercopy extends rcube_plugin
// parse addres book file // parse addres book file
if (filesize($abookfile)) { if (filesize($abookfile)) {
foreach(file($abookfile) as $line) { foreach(file($abookfile) as $line) {
if (empty($file_charset)) { $line = $this->convert_charset(rtrim($line), $file_charset);
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', utf8_encode(rtrim($line))); list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', $line);
} else {
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', rcube_charset::convert(rtrim($line), $file_charset, "UTF-8"));
}
if ($rec['name'] && $rec['email']) { if ($rec['name'] && $rec['email']) {
$this->abook[] = $rec; $this->abook[] = $rec;
} }
@ -261,4 +248,13 @@ class squirrelmail_usercopy extends rcube_plugin
} }
} // end if 'sql'-driver } // end if 'sql'-driver
} }
private function convert_charset($str, $charset = null)
{
if (!$charset) {
return utf8_encode($sig);
}
return rcube_charset::convert($str, $charset, RCMAIL_CHARSET);
}
} }

Loading…
Cancel
Save