diff options
author | Aleksander Machniak <alec@alec.pl> | 2017-06-02 21:06:47 +0300 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2017-06-02 21:07:41 +0300 |
commit | fe4c6260620af16c9d1edc00aa40ebbaf5426778 (patch) | |
tree | 3a1cb307fba85353204fded23d20d24f0e110269 /plugins | |
parent | fa566b6b1e1377f408ca956594d4dfbb9f085c20 (diff) |
Code optimization, update changelog
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/zipdownload/composer.json | 2 | ||||
-rw-r--r-- | plugins/zipdownload/zipdownload.php | 21 |
2 files changed, 10 insertions, 13 deletions
diff --git a/plugins/zipdownload/composer.json b/plugins/zipdownload/composer.json index 3d86619a5..9c936ec40 100644 --- a/plugins/zipdownload/composer.json +++ b/plugins/zipdownload/composer.json @@ -3,7 +3,7 @@ "type": "roundcube-plugin", "description": "Adds an option to download all attachments to a message in one zip file, when a message has multiple attachments. Also allows the download of a selection of messages in one zip file. Supports mbox and maildir format.", "license": "GPLv3+", - "version": "3.2", + "version": "3.3", "authors": [ { "name": "Thomas Bruederli", diff --git a/plugins/zipdownload/zipdownload.php b/plugins/zipdownload/zipdownload.php index 157b53a8f..383d40063 100644 --- a/plugins/zipdownload/zipdownload.php +++ b/plugins/zipdownload/zipdownload.php @@ -182,8 +182,7 @@ class zipdownload extends rcube_plugin } } } - - + /** * Create and get display name of attachment part to add on zip file * @@ -205,22 +204,20 @@ class zipdownload extends rcube_plugin } } - $displayname = $this->_convert_filename($filename); + $displayname = $this->_convert_filename($filename); + /** * Adding a number before dot of extension on a name of file with same name on zip * Ext: attach(1).txt on attach filename that has a attach.txt filename on same zip */ - if (in_array($displayname, $this->names)) { - $attachNumber = 1; + if (isset($this->name[$displayname])) { list($filename, $ext) = preg_split("/\.(?=[^\.]*$)/", $displayname); - foreach ($this->names as $name) { - if (preg_match("/{$filename}\((\d+)\)\.{$ext}/", $name, $match)) { - $attachNumber = ((int) $match[1]) + 1; - } - } - $displayname = $filename . '(' .$attachNumber . ').' . $ext; + $displayname = $filename . '(' . ($this->names[$displayname]++) . ').' . $ext; + $this->names[$displayname] = 1; + } + else { + $this->names[$displayname] = 1; } - $this->names[] = $displayname; return $displayname; } |