diff --git a/api/js/etemplate/et2_widget_vfs.js b/api/js/etemplate/et2_widget_vfs.js index 8e34a8562b..7b656b677f 100644 --- a/api/js/etemplate/et2_widget_vfs.js +++ b/api/js/etemplate/et2_widget_vfs.js @@ -1172,6 +1172,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend( name: this.options.name, method: this.options.method }; + attrs.recentPaths = this._getRecentPaths(); var callback = _callback || this._buildDialog; egw(window).json( 'EGroupware\\Api\\Etemplate\\Widget\\Vfs::ajax_vfsSelect_content', @@ -1248,6 +1249,7 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend( files = _value.path+'/'+_value.name; break; } + self._setRecentPaths(_value.path); self.value = files; if (self.options.method && self.options.method !== 'download') { @@ -1306,6 +1308,28 @@ var et2_vfsSelect = (function(){ "use strict"; return et2_inputWidget.extend( }); }, + /** + * Set recent path into sessionStorage + * @param {string} _path + */ + _setRecentPaths: function (_path) + { + var recentPaths = egw.getSessionItem('api', 'vfsRecentPaths') ? + egw.getSessionItem('api', 'vfsRecentPaths').split(',') : []; + if (recentPaths.indexOf(_path) == -1) recentPaths.push(_path); + egw.setSessionItem('api', 'vfsRecentPaths', recentPaths); + }, + + /** + * Get recent paths from sessionStorage + * @returns {Array} returns an array of recent paths + */ + _getRecentPaths: function () + { + return egw.getSessionItem('api', 'vfsRecentPaths') ? + egw.getSessionItem('api', 'vfsRecentPaths').split(',') : []; + }, + /** * click handler * @param {event object} e diff --git a/api/src/Etemplate/Widget/Vfs.php b/api/src/Etemplate/Widget/Vfs.php index 4d270a9129..44dacfcb99 100644 --- a/api/src/Etemplate/Widget/Vfs.php +++ b/api/src/Etemplate/Widget/Vfs.php @@ -470,6 +470,22 @@ class Vfs extends File $favorites = \EGroupware\Api\Framework\Favorites::get_favorites('filemanager'); $n = 0; $content['dir'] = array(); + //check for recent paths and add them to the top of favorites list + if (is_array($params['recentPaths'])) + { + foreach($params['recentPaths'] as $p) + { + $mime = \EGroupware\Api\Vfs::mime_content_type($p); + $content['dir'][$n] = array( + 'name' => $p, + 'path' => $p, + 'mime' => $mime, + 'is_dir' => true + ); + ++$n; + } + } + foreach($favorites as $favorite) { $path = $favorite['state']['path'];