diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-10-27 14:28:24 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-10-27 14:28:24 +0200 |
commit | 38371d12756a3d64b8381cf034ae0774b5934df1 (patch) | |
tree | 913bdd5346a76af3c06604a7a3c6fa16cd5f97fa /apps | |
parent | 0fb707d2c90846c1231cdefac79e9b58c8351c81 (diff) | |
parent | 0c40a061e4925181101196d379137fb020924980 (diff) | |
download | nextcloud-server-38371d12756a3d64b8381cf034ae0774b5934df1.tar.gz nextcloud-server-38371d12756a3d64b8381cf034ae0774b5934df1.zip |
Merge branch 'master' into filesystem
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/appinfo/routes.php | 12 | ||||
-rw-r--r-- | apps/files/index.php | 4 | ||||
-rw-r--r-- | apps/files/js/fileactions.js | 2 | ||||
-rw-r--r-- | apps/files/js/filelist.js | 2 | ||||
-rw-r--r-- | apps/user_ldap/lib/access.php | 85 | ||||
-rw-r--r-- | apps/user_ldap/user_ldap.php | 13 |
6 files changed, 73 insertions, 45 deletions
diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php new file mode 100644 index 00000000000..e1ab560803d --- /dev/null +++ b/apps/files/appinfo/routes.php @@ -0,0 +1,12 @@ +<?php +/** + * Copyright (c) 2012 Bart Visscher <bartv@thisnet.nl> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +$this->create('download', 'download{file}') + ->requirements(array('file' => '.*')) + ->actionInclude('files/download.php'); + diff --git a/apps/files/index.php b/apps/files/index.php index a2cf87d027e..43a559d034e 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -87,11 +87,11 @@ foreach( explode( '/', $dir ) as $i ) { // make breadcrumb und filelist markup $list = new OCP\Template( 'files', 'part.list', '' ); $list->assign( 'files', $files, false ); -$list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir=', false); +$list->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir=', false); $list->assign( 'downloadURL', OCP\Util::linkTo('files', 'download.php').'?file=', false); $breadcrumbNav = new OCP\Template( 'files', 'part.breadcrumb', '' ); $breadcrumbNav->assign( 'breadcrumb', $breadcrumb, false ); -$breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'&dir=', false); +$breadcrumbNav->assign( 'baseURL', OCP\Util::linkTo('files', 'index.php').'?dir=', false); $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize')); $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size')); diff --git a/apps/files/js/fileactions.js b/apps/files/js/fileactions.js index e184cbfa915..0cf4a052225 100644 --- a/apps/files/js/fileactions.js +++ b/apps/files/js/fileactions.js @@ -185,7 +185,7 @@ FileActions.register('all','Rename', OC.PERMISSION_UPDATE, function(){return OC. }); FileActions.register('dir','Open', OC.PERMISSION_READ, '', function(filename){ - window.location=OC.linkTo('files', 'index.php') + '&dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); + window.location=OC.linkTo('files', 'index.php') + '?dir='+encodeURIComponent($('#dir').val()).replace(/%2F/g, '/')+'/'+encodeURIComponent(filename); }); FileActions.setDefault('dir','Open'); diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 6b49f622668..f08e412921e 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -46,7 +46,7 @@ var FileList={ html = $('<tr></tr>').attr({ "data-type": "dir", "data-size": size, "data-file": name, "data-permissions": $('#permissions').val()}); td = $('<td></td>').attr({"class": "filename", "style": 'background-image:url('+OC.imagePath('core', 'filetypes/folder.png')+')' }); td.append('<input type="checkbox" />'); - link_elem = $('<a></a>').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"&dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); + link_elem = $('<a></a>').attr({ "class": "name", "href": OC.linkTo('files', 'index.php')+"?dir="+ encodeURIComponent($('#dir').val()+'/'+name).replace(/%2F/g, '/') }); link_elem.append($('<span></span>').addClass('nametext').text(name)); link_elem.append($('<span></span>').attr({'class': 'uploadtext', 'currentUploads': 0})); td.append(link_elem); diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index aa108f9840e..d3439451499 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -25,7 +25,6 @@ namespace OCA\user_ldap\lib; abstract class Access { protected $connection; - //never ever check this var directly, always use getPagedSearchResultState protected $pagedSearchedSuccessful; @@ -512,32 +511,8 @@ abstract class Access { return array(); } - //TODO: lines 516:540 into a function of its own. $pagedSearchOK as return - //check wether paged query should be attempted - $pagedSearchOK = false; - if($this->connection->hasPagedResultSupport && !is_null($limit)) { - $offset = intval($offset); //can be null - //get the cookie from the search for the previous search, required by LDAP - $cookie = $this->getPagedResultCookie($filter, $limit, $offset); - if(empty($cookie) && ($offset > 0)) { - //no cookie known, although the offset is not 0. Maybe cache run out. We need to start all over *sigh* (btw, Dear Reader, did you need LDAP paged searching was designed by MSFT?) - $reOffset = ($offset - $limit) < 0 ? 0 : $offset - $limit; - //a bit recursive, $offset of 0 is the exit - $this->search($filter, $base, $attr, $limit, $reOffset, true); - $cookie = $this->getPagedResultCookie($filter, $limit, $offset); - //still no cookie? obviously, the server does not like us. Let's skip paging efforts. - //TODO: remember this, probably does not change in the next request... - if(empty($cookie)) { - $cookie = null; - } - } - if(!is_null($cookie)) { - $pagedSearchOK = ldap_control_paged_result($link_resource, $limit, false, $cookie); - \OCP\Util::writeLog('user_ldap', 'Ready for a paged search', \OCP\Util::DEBUG); - } else { - \OCP\Util::writeLog('user_ldap', 'No paged search for us, Cpt., Limit '.$limit.' Offset '.$offset, \OCP\Util::DEBUG); - } - } + //check wether paged search should be attempted + $pagedSearchOK = $this->initPagedSearch($filter, $base, $attr, $limit, $offset); $sr = ldap_search($link_resource, $base, $filter, $attr); $findings = ldap_get_entries($link_resource, $sr ); @@ -551,7 +526,7 @@ abstract class Access { return; } //if count is bigger, then the server does not support paged search. Instead, he did a normal search. We set a flag here, so the callee knows how to deal with it. - //TODO: Not used, just make a count on the returned values in the callee + //TODO: Instead, slice findings or selection later if($findings['count'] <= $limit) { $this->pagedSearchedSuccessful = true; } @@ -604,8 +579,15 @@ abstract class Access { } } } -// die(var_dump($selection)); - return $selection; + $findings = $selection; + } + if(!$this->pagedSearchedSuccessful + || ( + !is_null($limit) + || !is_null($offset) + ) + ) { + $findings = array_slice($findings, intval($offset), $limit); } return $findings; } @@ -775,4 +757,47 @@ abstract class Access { return $result; } + + /** + * @brief prepares a paged search, if possible + * @param $filter the LDAP filter for the search + * @param $base the LDAP subtree that shall be searched + * @param $attr optional, when a certain attribute shall be filtered outside + * @param $limit + * @param $offset + * + */ + private function initPagedSearch($filter, $base, $attr, $limit, $offset) { + $pagedSearchOK = false; + if($this->connection->hasPagedResultSupport && !is_null($limit)) { + $offset = intval($offset); //can be null + //get the cookie from the search for the previous search, required by LDAP + $cookie = $this->getPagedResultCookie($filter, $limit, $offset); + if(empty($cookie) && ($offset > 0)) { + //no cookie known, although the offset is not 0. Maybe cache run out. We need to start all over *sigh* (btw, Dear Reader, did you need LDAP paged searching was designed by MSFT?) + $reOffset = ($offset - $limit) < 0 ? 0 : $offset - $limit; + //a bit recursive, $offset of 0 is the exit + \OCP\Util::writeLog('user_ldap', 'Looking for cookie L/O '.$limit.'/'.$reOffset, \OCP\Util::INFO); + $this->search($filter, $base, $attr, $limit, $reOffset, true); + $cookie = $this->getPagedResultCookie($filter, $limit, $offset); + //still no cookie? obviously, the server does not like us. Let's skip paging efforts. + //TODO: remember this, probably does not change in the next request... + if(empty($cookie)) { + $cookie = null; + } + } + if(!is_null($cookie)) { + if($offset > 0) { + \OCP\Util::writeLog('user_ldap', 'Cookie '.$cookie, \OCP\Util::INFO); + } + $pagedSearchOK = ldap_control_paged_result($this->connection->getConnectionResource(), $limit, false, $cookie); + \OCP\Util::writeLog('user_ldap', 'Ready for a paged search', \OCP\Util::INFO); + } else { + \OCP\Util::writeLog('user_ldap', 'No paged search for us, Cpt., Limit '.$limit.' Offset '.$offset, \OCP\Util::INFO); + } + } + + return $pagedSearchOK; + } + }
\ No newline at end of file diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index e95bd24fbdd..916d3f1d46a 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -119,20 +119,11 @@ class USER_LDAP extends lib\Access implements \OCP\UserInterface { $this->connection->ldapGroupDisplayName.'='.$search )); - \OCP\Util::writeLog('user_ldap', 'getUsers: Get users filter '.$filter, \OCP\Util::DEBUG); + \OCP\Util::writeLog('user_ldap', 'getUsers: Options: search '.$search.' limit '.$limit.' offset '.$offset.' Filter: '.$filter, \OCP\Util::DEBUG); //do the search and translate results to owncloud names $ldap_users = $this->fetchListOfUsers($filter, array($this->connection->ldapUserDisplayName, 'dn'), $limit, $offset); $ldap_users = $this->ownCloudUserNames($ldap_users); - - if(!$this->getPagedSearchResultState()) { - \OCP\Util::writeLog('user_ldap', 'getUsers: We got old-style results', \OCP\Util::DEBUG); - //if not supported, a 'normal' search has run automatically, we just need to get our slice of the cake. And we cache the general search, too - $this->connection->writeToCache('getUsers-'.$search, $ldap_users); - $ldap_users = array_slice($ldap_users, $offset, $limit); - } else { - //debug message only - \OCP\Util::writeLog('user_ldap', 'getUsers: We got paged results', \OCP\Util::DEBUG); - } + \OCP\Util::writeLog('user_ldap', 'getUsers: '.count($ldap_users). ' Users found', \OCP\Util::DEBUG); $this->connection->writeToCache($cachekey, $ldap_users); return $ldap_users; |