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
===========================
- Squirrelmail_usercopy: Add option to define character set of data files
- Removed useless 'created' column from 'session' table (#5389)
- Require PHP >= 5.4
- Add possibility to preview and download attachments in mail compose (#5053)

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

@ -3,7 +3,7 @@
/**
* 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
*/
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) {
$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';
$abookfile = slashify($srcdir) . $uname . '.abook';
@ -173,31 +173,21 @@ class squirrelmail_usercopy extends rcube_plugin
$this->prefs = array();
foreach (file($prefsfile) as $line) {
list($key, $value) = explode('=', $line);
if (empty($file_charset)) {
$this->prefs[$key] = utf8_encode(rtrim($value));
} else {
$this->prefs[$key] = rcube_charset::convert(rtrim($value), $file_charset, "UTF-8");
}
$this->prefs[$key] = $this->convert_charset(rtrim($value), $file_charset);
}
// also read signature file if exists
if (is_readable($sigfile)) {
if (empty($file_charset)) {
$this->prefs['___signature___'] = utf8_encode(file_get_contents($sigfile));
} else {
$this->prefs['___signature___'] = rcube_charset::convert(file_get_contents($sigfile), $file_charset, "UTF-8");
}
$sig = file_get_contents($sigfile);
$this->prefs['___signature___'] = $this->convert_charset($sig, $file_charset);
}
if (isset($this->prefs['identities']) && $this->prefs['identities'] > 1) {
for ($i=1; $i < $this->prefs['identities']; $i++) {
// read signature file if exists
if (is_readable($sigbase.$i)) {
if (empty($file_charset)) {
$this->prefs['___sig'.$i.'___'] = utf8_encode(file_get_contents($sigbase.$i));
} else {
$this->prefs['___sig'.$i.'___'] = rcube_charset::convert(file_get_contents($sigbase.$i), $file_charset, "UTF-8");
}
$sig = file_get_contents($sigbase.$i);
$this->prefs['___sig'.$i.'___'] = $this->convert_charset($sig, $file_charset);
}
}
}
@ -205,11 +195,8 @@ class squirrelmail_usercopy extends rcube_plugin
// parse addres book file
if (filesize($abookfile)) {
foreach(file($abookfile) as $line) {
if (empty($file_charset)) {
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', utf8_encode(rtrim($line)));
} else {
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', rcube_charset::convert(rtrim($line), $file_charset, "UTF-8"));
}
$line = $this->convert_charset(rtrim($line), $file_charset);
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', $line);
if ($rec['name'] && $rec['email']) {
$this->abook[] = $rec;
}
@ -261,4 +248,13 @@ class squirrelmail_usercopy extends rcube_plugin
}
} // 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