From 05b46f78281e5df49a5c6a0513a37eaf03c3c29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Fri, 8 Feb 2013 17:16:18 +0100 Subject: [PATCH 01/58] on creation only test for existing users if the backend supports user creation this solves the issue where no users can be created any more if backends are active which always return true on userExists() like WebDAV Auth --- lib/user.php | 15 ++++++++++++++- settings/ajax/createuser.php | 6 ------ settings/js/users.js | 6 ------ 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/lib/user.php b/lib/user.php index 9dc8cca97a6..76c4c45ee30 100644 --- a/lib/user.php +++ b/lib/user.php @@ -172,7 +172,7 @@ class OC_User { } // Check if user already exists - if( self::userExists($uid) ) { + if( self::userExistsForCreation($uid) ) { throw new Exception('The username is already being used'); } @@ -551,6 +551,19 @@ class OC_User { return false; } + public static function userExistsForCreation($uid) { + foreach(self::$_usedBackends as $backend) { + if(!$backend->implementsActions(OC_USER_BACKEND_CREATE_USER)) + continue; + + $result=$backend->userExists($uid); + if($result===true) { + return true; + } + } + return false; + } + /** * disables a user * @param string $userid the user to disable diff --git a/settings/ajax/createuser.php b/settings/ajax/createuser.php index 09ef25d92fa..56653bed6bd 100644 --- a/settings/ajax/createuser.php +++ b/settings/ajax/createuser.php @@ -26,12 +26,6 @@ if(OC_User::isAdminUser(OC_User::getUser())) { $username = $_POST["username"]; $password = $_POST["password"]; -// Does the group exist? -if(OC_User::userExists($username)) { - OC_JSON::error(array("data" => array( "message" => "User already exists" ))); - exit(); -} - // Return Success story try { if (!OC_User::createUser($username, $password)) { diff --git a/settings/js/users.js b/settings/js/users.js index 094cddda294..3ab48675f29 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -400,12 +400,6 @@ $(document).ready(function () { event.preventDefault(); var username = $('#newusername').val(); var password = $('#newuserpassword').val(); - if ($('#content table tbody tr').filterAttr('data-uid', username).length > 0) { - OC.dialogs.alert( - t('settings', 'The username is already being used'), - t('settings', 'Error creating user')); - return; - } if ($.trim(username) == '') { OC.dialogs.alert( t('settings', 'A valid username must be provided'), From 8ff20ac683413af4ea06e9d1b4afa69634d7daff Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Sat, 9 Feb 2013 17:13:02 +0100 Subject: [PATCH 02/58] ellipsize infield labels when too long, specifically fix #871 for database labels on installation --- core/css/styles.css | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/css/styles.css b/core/css/styles.css index 556ca6b82bb..6c9704b16c3 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -177,7 +177,11 @@ input[name="password-clone"] { padding-left:1.8em; width:11.7em !important; } #login .groupmiddle label, #login .groupbottom label { top:.65em; } p.infield { position:relative; } label.infield { cursor:text !important; top:1.05em; left:.85em; } -#login form label.infield { position:absolute; font-size:19px; color:#aaa; white-space:nowrap; padding-left:1.4em; } +#login form label.infield { /* labels are ellipsized when too long, keep them short */ + position:absolute; width:90%; padding-left:1.4em; + font-size:19px; color:#aaa; + white-space:nowrap; overflow:hidden; text-overflow:ellipsis; +} #login #databaseField .infield { padding-left:0; } #login form input[type="checkbox"]+label { position:relative; margin:0; font-size:1em; text-shadow:#fff 0 1px 0; } #login form .errors { background:#fed7d7; border:1px solid #f00; list-style-indent:inside; margin:0 0 2em; padding:1em; } From 8174e5faf18fcd762efce5ffdfabfa1102580dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Sat, 9 Feb 2013 19:03:03 +0100 Subject: [PATCH 03/58] make MappedLocal available and testable within Linux as well --- lib/files/storage/local.php | 4 ++- lib/files/storage/mappedlocal.php | 2 +- tests/lib/files/storage/mappedlocal.php | 40 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 tests/lib/files/storage/mappedlocal.php diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index d387a898320..038d68bf46b 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -9,7 +9,9 @@ namespace OC\Files\Storage; if (\OC_Util::runningOnWindows()) { - require_once 'mappedlocal.php'; + class Local extends MappedLocal { + + } } else { /** diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index 80dd79bc41f..411b053737a 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -10,7 +10,7 @@ namespace OC\Files\Storage; /** * for local filestore, we only have to map the paths */ -class Local extends \OC\Files\Storage\Common{ +class MappedLocal extends \OC\Files\Storage\Common{ protected $datadir; private $mapper; diff --git a/tests/lib/files/storage/mappedlocal.php b/tests/lib/files/storage/mappedlocal.php new file mode 100644 index 00000000000..b483f3a1954 --- /dev/null +++ b/tests/lib/files/storage/mappedlocal.php @@ -0,0 +1,40 @@ +. +* +*/ + +namespace Test\Files\Storage; + +class MappedLocal extends Storage { + /** + * @var string tmpDir + */ + private $tmpDir; + public function setUp() { + $this->tmpDir=\OC_Helper::tmpFolder(); + $this->instance=new \OC\Files\Storage\MappedLocal(array('datadir'=>$this->tmpDir)); + } + + public function tearDown() { + \OC_Helper::rmdirr($this->tmpDir); + unset($this->instance); + } +} + From 92e6409f4008d21c8507310d7b6ce0f64fc29b71 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Mon, 11 Feb 2013 13:53:10 +0100 Subject: [PATCH 04/58] fixing mappedlocal storage to work on non-windows as well this allows us to run unit tests on linux - necessary to enable easy regression testing --- lib/files/mapper.php | 16 +++++++++++++++- lib/files/storage/mappedlocal.php | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/files/mapper.php b/lib/files/mapper.php index 71b665e49bb..2d29a8532b6 100644 --- a/lib/files/mapper.php +++ b/lib/files/mapper.php @@ -117,6 +117,9 @@ class Mapper $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*file_map` WHERE `logic_path_hash` = ?'); $result = $query->execute(array(md5($logicPath))); $result = $result->fetchRow(); + if ($result === false) { + return null; + } return $result['physic_path']; } @@ -160,11 +163,16 @@ class Mapper $sluggedElements = array(); // skip slugging the drive letter on windows - TODO: test if local path - if (strpos(strtolower(php_uname('s')), 'win') !== false) { + if (\OC_Util::runningOnWindows()) { $sluggedElements[]= $pathElements[0]; array_shift($pathElements); } foreach ($pathElements as $pathElement) { + // remove empty elements + if (empty($pathElement)) { + continue; + } + // TODO: remove file ext before slugify on last element $sluggedElements[] = self::slugify($pathElement); } @@ -177,6 +185,12 @@ class Mapper array_pop($sluggedElements); array_push($sluggedElements, $last.'-'.$index); } + + // on non-windows systems add the leading / if necessary + if (!\OC_Util::runningOnWindows() and $path[0] === '/') { + return DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $sluggedElements); + } + return implode(DIRECTORY_SEPARATOR, $sluggedElements); } diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index 411b053737a..218465d8eef 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -329,6 +329,9 @@ class MappedLocal extends \OC\Files\Storage\Common{ if(strpos($path, '/') === 0) { $path = substr($path, 1); } + if ($path === false) { + return ''; + } return $path; } From 5a0a9564ce98938401b276d634caab48f788fff3 Mon Sep 17 00:00:00 2001 From: Frank Karlitschek Date: Sat, 9 Feb 2013 17:13:43 +0100 Subject: [PATCH 05/58] alpha 1 --- lib/util.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/util.php b/lib/util.php index 81ad2df3ac6..a4e7271adcd 100755 --- a/lib/util.php +++ b/lib/util.php @@ -74,7 +74,7 @@ class OC_Util { */ public static function getVersion() { // hint: We only can count up. So the internal version number of ownCloud 4.5 will be 4.90.0. This is not visible to the user - return array(4, 91, 10); + return array(4, 92, 10); } /** @@ -82,7 +82,7 @@ class OC_Util { * @return string */ public static function getVersionString() { - return '5.0 pre alpha'; + return '5.0 alpha 1'; } /** From 79511f6d932d7fc41b104ef68367746bf117b5b5 Mon Sep 17 00:00:00 2001 From: Jan-Christoph Borchardt Date: Sat, 9 Feb 2013 17:14:20 +0100 Subject: [PATCH 06/58] fixed database input group having two slightly thicker dividers --- core/css/styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/css/styles.css b/core/css/styles.css index 6c9704b16c3..072b92ecb0e 100644 --- a/core/css/styles.css +++ b/core/css/styles.css @@ -163,7 +163,7 @@ input[name="password-clone"] { padding-left:1.8em; width:11.7em !important; } } .groupmiddle input { margin-top:0; margin-bottom:0; - border-top:0; border-radius:0; + border-top:0; border-bottom:0; border-radius:0; box-shadow:0 1px 1px #fff,0 1px 0 #ddd inset; } .groupbottom input { From f58ed7a509da54fcd29e21dc6fc75528822157a4 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Sun, 10 Feb 2013 17:31:12 +0100 Subject: [PATCH 07/58] no need to implement createUser in web dav auth --- apps/user_webdavauth/user_webdavauth.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apps/user_webdavauth/user_webdavauth.php b/apps/user_webdavauth/user_webdavauth.php index 1459781a3b4..dd34e0ad2f1 100755 --- a/apps/user_webdavauth/user_webdavauth.php +++ b/apps/user_webdavauth/user_webdavauth.php @@ -28,12 +28,6 @@ class OC_USER_WEBDAVAUTH extends OC_User_Backend { $this->webdavauth_url = OC_Config::getValue( "user_webdavauth_url" ); } - public function createUser() { - // Can't create user - OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to create users from web frontend using WebDAV user backend', 3); - return false; - } - public function deleteUser($uid) { // Can't delete user OC_Log::write('OC_USER_WEBDAVAUTH', 'Not possible to delete users from web frontend using WebDAV user backend', 3); From dbb4be903c52db5a241aa5765412a3bb875097c2 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Sun, 10 Feb 2013 21:52:57 +0100 Subject: [PATCH 08/58] LDAP: change generation of internal names. Use UUID for users. Change to sequential numbers for groups as they are still used as display names --- apps/user_ldap/lib/access.php | 119 ++++++++++++++++++++++++++++------ 1 file changed, 100 insertions(+), 19 deletions(-) diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index 68cbe4a5e75..ab6915d839b 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -293,6 +293,10 @@ abstract class Access { $query->execute(array($dn, $uuid)); return $component; } + } else { + //If the UUID can't be detected something is foul. + \OCP\Util::writeLog('user_ldap', 'Cannot determine UUID for '.$dn.'. Skipping.', \OCP\Util::INFO); + return false; } if(is_null($ldapname)) { @@ -303,21 +307,24 @@ abstract class Access { } $ldapname = $ldapname[0]; } - $ldapname = $this->sanitizeUsername($ldapname); + $intname = $isUser ? $this->sanitizeUsername($uuid) : $this->sanitizeUsername($ldapname); //a new user/group! Add it only if it doesn't conflict with other backend's users or existing groups - if(($isUser && !\OCP\User::userExists($ldapname, 'OCA\\user_ldap\\USER_LDAP')) || (!$isUser && !\OC_Group::groupExists($ldapname))) { - if($this->mapComponent($dn, $ldapname, $isUser)) { - return $ldapname; + //disabling Cache is required to avoid that the new user is cached as not-existing in fooExists check + $originalTTL = $this->connection->ldapCacheTTL; + $this->connection->setConfiguration(array('ldapCacheTTL' => 0)); + if(($isUser && !\OCP\User::userExists($intname)) + || (!$isUser && !\OC_Group::groupExists($intname))) { + if($this->mapComponent($dn, $intname, $isUser)) { + $this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL)); + return $intname; } } + $this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL)); - //doh! There is a conflict. We need to distinguish between users/groups. Adding indexes is an idea, but not much of a help for the user. The DN is ugly, but for now the only reasonable way. But we transform it to a readable format and remove the first part to only give the path where this object is located. - $oc_name = $this->alternateOwnCloudName($ldapname, $dn); - if(($isUser && !\OCP\User::userExists($oc_name)) || (!$isUser && !\OC_Group::groupExists($oc_name))) { - if($this->mapComponent($dn, $oc_name, $isUser)) { - return $oc_name; - } + $altname = $this->createAltInternalOwnCloudName($intname, $isUser); + if($this->mapComponent($dn, $altname, $isUser)) { + return $altname; } //if everything else did not help.. @@ -400,18 +407,92 @@ abstract class Access { } /** - * @brief creates a hopefully unique name for owncloud based on the display name and the dn of the LDAP object + * @brief creates a unique name for internal ownCloud use for users. Don't call it directly. * @param $name the display name of the object - * @param $dn the dn of the object - * @returns string with with the name to use in ownCloud + * @returns string with with the name to use in ownCloud or false if unsuccessful * - * creates a hopefully unique name for owncloud based on the display name and the dn of the LDAP object + * Instead of using this method directly, call + * createAltInternalOwnCloudName($name, true) */ - private function alternateOwnCloudName($name, $dn) { - $ufn = ldap_dn2ufn($dn); - $name = $name . '@' . trim(\OCP\Util::mb_substr_replace($ufn, '', 0, mb_strpos($ufn, ',', 0, 'UTF-8'), 'UTF-8')); - $name = $this->sanitizeUsername($name); - return $name; + private function _createAltInternalOwnCloudNameForUsers($name) { + $attempts = 0; + //while loop is just a precaution. If a name is not generated within + //20 attempts, something else is very wrong. Avoids infinite loop. + while($attempts < 20){ + $altName = $name . '_' . uniqid(); + if(\OCP\User::userExists($altName)) { + return $altName; + } + $attempts++; + } + return false; + } + + /** + * @brief creates a unique name for internal ownCloud use for groups. Don't call it directly. + * @param $name the display name of the object + * @returns string with with the name to use in ownCloud or false if unsuccessful. + * + * Instead of using this method directly, call + * createAltInternalOwnCloudName($name, false) + * + * Group names are also used as display names, so we do a sequential + * numbering, e.g. Developers_42 when there are 41 other groups called + * "Developers" + */ + private function _createAltInternalOwnCloudNameForGroups($name) { + $query = \OCP\DB::prepare(' + SELECT `owncloud_name` + FROM `'.$this->getMapTable(false).'` + WHERE `owncloud_name` LIKE ? + '); + + $usedNames = array(); + $res = $query->execute(array($name.'_%')); + while($row = $res->fetchRow()) { + $usedNames[] = $row['owncloud_name']; + } + if(!($usedNames) || count($usedNames) == 0) { + $lastNo = 1; //will become name_2 + } else { + natsort($usedNames); + $lastname = array_pop($usedNames); + $lastNo = intval(substr($lastname, strrpos($lastname, '_') + 1)); + } + $altName = $name.'_'.strval($lastNo+1); + unset($usedNames); + + $attempts = 1; + while($attempts < 21){ + //Pro forma check to be really sure it is unique + //while loop is just a precaution. If a name is not generated within + //20 attempts, something else is very wrong. Avoids infinite loop. + if(!\OC_Group::groupExists($altName)) { + return $altName; + } + $altName = $name . '_' . $lastNo + $attempts; + $attempts++; + } + return false; + } + + /** + * @brief creates a unique name for internal ownCloud use. + * @param $name the display name of the object + * @param $isUser boolean, whether name should be created for a user (true) or a group (false) + * @returns string with with the name to use in ownCloud or false if unsuccessful + */ + private function createAltInternalOwnCloudName($name, $isUser) { + $originalTTL = $this->connection->ldapCacheTTL; + $this->connection->setConfiguration(array('ldapCacheTTL' => 0)); + if($isUser) { + $altName = $this->_createAltInternalOwnCloudNameForUsers($name); + } else { + $altName = $this->_createAltInternalOwnCloudNameForGroups($name); + } + $this->connection->setConfiguration(array('ldapCacheTTL' => $originalTTL)); + + return $altName; } /** From afc9fe419aee034999fcaa9ace05c0043189154d Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Sun, 10 Feb 2013 21:53:27 +0100 Subject: [PATCH 09/58] adjust copyright --- apps/user_ldap/lib/access.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index ab6915d839b..057ae17c308 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -4,7 +4,7 @@ * ownCloud – LDAP Access * * @author Arthur Schiwon - * @copyright 2012 Arthur Schiwon blizzz@owncloud.com + * @copyright 2012, 2013 Arthur Schiwon blizzz@owncloud.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE From 56d10e9054c5f2699e3e0df00bd71a40f53be738 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 10 Feb 2013 18:15:23 +0100 Subject: [PATCH 10/58] Cache: simplify scanner logic a bit when handeling with unknown folder sizes --- lib/files/cache/scanner.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index 5a9a119458e..ff37c944240 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -101,18 +101,16 @@ class Scanner { $child = ($path) ? $path . '/' . $file : $file; $data = $this->scanFile($child); if ($data) { - if ($data['mimetype'] === 'httpd/unix-directory') { + if ($data['size'] === -1) { if ($recursive === self::SCAN_RECURSIVE) { $childQueue[] = $child; $data['size'] = 0; } else { - $data['size'] = -1; + $size = -1; } - } else { } - if ($data['size'] === -1) { - $size = -1; - } elseif ($size !== -1) { + + if ($size !== -1) { $size += $data['size']; } } @@ -133,7 +131,7 @@ class Scanner { } return $size; } - + /** * @brief check if the file should be ignored when scanning * NOTE: files with a '.part' extension are ignored as well! @@ -143,8 +141,8 @@ class Scanner { */ private function isIgnoredFile($file) { if ($file === '.' || $file === '..' - || pathinfo($file,PATHINFO_EXTENSION) === 'part') - { + || pathinfo($file, PATHINFO_EXTENSION) === 'part' + ) { return true; } return false; From 299649b40e1a87eee7bcead74b269fe8c452e04d Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sun, 10 Feb 2013 18:24:24 +0100 Subject: [PATCH 11/58] Cache: reuse known folder sizes when doing a shallow scan --- lib/files/cache/scanner.php | 10 +++++++--- tests/lib/files/cache/watcher.php | 1 - 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index ff37c944240..b27b3555c91 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -58,9 +58,10 @@ class Scanner { * scan a single file and store it in the cache * * @param string $file + * @param bool $checkExisting check existing folder sizes in the cache instead of always using -1 for folder size * @return array with metadata of the scanned file */ - public function scanFile($file) { + public function scanFile($file, $checkExisting = false) { \OC_Hook::emit('\OC\Files\Cache\Scanner', 'scan_file', array('path' => $file, 'storage' => $this->storageId)); $data = $this->getData($file); if ($data) { @@ -73,7 +74,10 @@ class Scanner { $this->scanFile($parent); } } - $id = $this->cache->put($file, $data); + if ($data['size'] === -1 and $cacheData = $this->cache->get($file)) { + $data['size'] = $cacheData['size']; + } + $this->cache->put($file, $data); } return $data; } @@ -99,7 +103,7 @@ class Scanner { while ($file = readdir($dh)) { if (!$this->isIgnoredFile($file)) { $child = ($path) ? $path . '/' . $file : $file; - $data = $this->scanFile($child); + $data = $this->scanFile($child, $recursive === self::SCAN_SHALLOW); if ($data) { if ($data['size'] === -1) { if ($recursive === self::SCAN_RECURSIVE) { diff --git a/tests/lib/files/cache/watcher.php b/tests/lib/files/cache/watcher.php index e8a1689cab0..8ef6ab44d10 100644 --- a/tests/lib/files/cache/watcher.php +++ b/tests/lib/files/cache/watcher.php @@ -76,7 +76,6 @@ class Watcher extends \PHPUnit_Framework_TestCase { $updater->checkUpdate(''); $entry = $cache->get('foo.txt'); - $this->assertEquals(-1, $entry['size']); $this->assertEquals('httpd/unix-directory', $entry['mimetype']); $this->assertFalse($cache->inCache('folder')); $this->assertFalse($cache->inCache('folder/bar.txt')); From d84c3cd014fd73930cd15aee64d57aad3383b2aa Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 11 Feb 2013 13:24:56 +0100 Subject: [PATCH 12/58] Cache: actually use parameter --- lib/files/cache/scanner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index b27b3555c91..ec216264429 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -74,7 +74,7 @@ class Scanner { $this->scanFile($parent); } } - if ($data['size'] === -1 and $cacheData = $this->cache->get($file)) { + if ($checkExisting and $data['size'] === -1 and $cacheData = $this->cache->get($file)) { $data['size'] = $cacheData['size']; } $this->cache->put($file, $data); From 2921d2fb785f265bb3bf17873ada304145d49aec Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 11 Feb 2013 13:27:34 +0100 Subject: [PATCH 13/58] Cache: don't create a new etag when the mtime hasn't changed --- lib/files/cache/scanner.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/files/cache/scanner.php b/lib/files/cache/scanner.php index ec216264429..7f19261d972 100644 --- a/lib/files/cache/scanner.php +++ b/lib/files/cache/scanner.php @@ -76,6 +76,9 @@ class Scanner { } if ($checkExisting and $data['size'] === -1 and $cacheData = $this->cache->get($file)) { $data['size'] = $cacheData['size']; + if ($data['mtime'] === $cacheData['mtime']) { + $data['etag'] = $cacheData['etag']; + } } $this->cache->put($file, $data); } From e68e5cc849b625dccc38b903fd19e418d62d1c22 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 11 Feb 2013 15:18:14 +0100 Subject: [PATCH 14/58] Split editable select code used for quota selection into a jquery plugin --- core/js/singleselect.js | 76 ++++ settings/css/settings.css | 1 - settings/js/users.js | 792 ++++++++++++++++------------------- settings/templates/users.php | 62 ++- settings/users.php | 1 + 5 files changed, 475 insertions(+), 457 deletions(-) create mode 100644 core/js/singleselect.js diff --git a/core/js/singleselect.js b/core/js/singleselect.js new file mode 100644 index 00000000000..1a018b74148 --- /dev/null +++ b/core/js/singleselect.js @@ -0,0 +1,76 @@ +(function ($) { + $.fn.singleSelect = function () { + return this.each(function (i, select) { + var input = $(''); + select = $(select); + input.css('position', 'absolute'); + input.css(select.offset()); + input.css({ + 'box-sizing': 'border-box', + '-moz-box-sizing': 'border-box', + 'margin': 0, + 'width': (select.width() - 5) + 'px', + 'height': (select.outerHeight() - 2) + 'px', + 'border': 'none', + 'box-shadow': 'none', + 'margin-top': '1px', + 'margin-left': '1px', + 'z-index': 1000 + }); + input.hide(); + $('body').append(input); + + select.on('change', function (event) { + var value = $(this).val(), + newAttr = $('option:selected', $(this)).attr('data-new'); + if (!(typeof newAttr !== 'undefined' && newAttr !== false)) { + input.hide(); + select.data('previous', value); + } else { + event.stopImmediatePropagation(); + input.show(); + select.css('background-color', 'white'); + input.focus(); + } + }); + + $(select).data('previous', $(select).val()); + + input.on('change', function () { + var value = $(this).val(); + if (value) { + select.children().attr('selected', null); + var existingOption = select.children().filter(function (i, option) { + return ($(option).val() == value); + }); + if (existingOption.length) { + existingOption.attr('selected', 'selected'); + } else { + var option = $('