From fd8cb9974be30aaca0d65d1807d6a4f784da5f0b Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Wed, 6 Feb 2013 23:36:38 +0100 Subject: initial version of a local storage implementation which will use unique slugified filename on the local filesystem. This implementation will only be enabled on windows based system to solve the issues around UTF-8 file names with php on windows. --- lib/files/storage/local.php | 5 + lib/files/storage/mappedlocal.php | 335 ++++++++++++++++++++++++++++++++++++++ lib/files/storage/temporary.php | 1 + 3 files changed, 341 insertions(+) create mode 100644 lib/files/storage/mappedlocal.php (limited to 'lib/files/storage') diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index a5db4ba9194..d387a898320 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -8,6 +8,10 @@ namespace OC\Files\Storage; +if (\OC_Util::runningOnWindows()) { + require_once 'mappedlocal.php'; +} else { + /** * for local filestore, we only have to map the paths */ @@ -245,3 +249,4 @@ class Local extends \OC\Files\Storage\Common{ return $this->filemtime($path)>$time; } } +} diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php new file mode 100644 index 00000000000..80dd79bc41f --- /dev/null +++ b/lib/files/storage/mappedlocal.php @@ -0,0 +1,335 @@ + + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +namespace OC\Files\Storage; + +/** + * for local filestore, we only have to map the paths + */ +class Local extends \OC\Files\Storage\Common{ + protected $datadir; + private $mapper; + + public function __construct($arguments) { + $this->datadir=$arguments['datadir']; + if(substr($this->datadir, -1)!=='/') { + $this->datadir.='/'; + } + + $this->mapper= new \OC\Files\Mapper(); + } + public function __destruct() { + if (defined('PHPUNIT_RUN')) { + $this->mapper->removePath($this->datadir, true, true); + } + } + public function getId(){ + return 'local::'.$this->datadir; + } + public function mkdir($path) { + return @mkdir($this->buildPath($path)); + } + public function rmdir($path) { + if ($result = @rmdir($this->buildPath($path))) { + $this->cleanMapper($path); + } + return $result; + } + public function opendir($path) { + $files = array('.', '..'); + $physicalPath= $this->buildPath($path); + + $logicalPath = $this->mapper->physicalToLogic($physicalPath); + $dh = opendir($physicalPath); + while ($file = readdir($dh)) { + if ($file === '.' or $file === '..') { + continue; + } + + $logicalFilePath = $this->mapper->physicalToLogic($physicalPath.DIRECTORY_SEPARATOR.$file); + + $file= $this->mapper->stripRootFolder($logicalFilePath, $logicalPath); + $file = $this->stripLeading($file); + $files[]= $file; + } + + \OC\Files\Stream\Dir::register('local-win32'.$path, $files); + return opendir('fakedir://local-win32'.$path); + } + public function is_dir($path) { + if(substr($path,-1)=='/') { + $path=substr($path, 0, -1); + } + return is_dir($this->buildPath($path)); + } + public function is_file($path) { + return is_file($this->buildPath($path)); + } + public function stat($path) { + $fullPath = $this->buildPath($path); + $statResult = stat($fullPath); + + if ($statResult['size'] < 0) { + $size = self::getFileSizeFromOS($fullPath); + $statResult['size'] = $size; + $statResult[7] = $size; + } + return $statResult; + } + public function filetype($path) { + $filetype=filetype($this->buildPath($path)); + if($filetype=='link') { + $filetype=filetype(realpath($this->buildPath($path))); + } + return $filetype; + } + public function filesize($path) { + if($this->is_dir($path)) { + return 0; + }else{ + $fullPath = $this->buildPath($path); + $fileSize = filesize($fullPath); + if ($fileSize < 0) { + return self::getFileSizeFromOS($fullPath); + } + + return $fileSize; + } + } + public function isReadable($path) { + return is_readable($this->buildPath($path)); + } + public function isUpdatable($path) { + return is_writable($this->buildPath($path)); + } + public function file_exists($path) { + return file_exists($this->buildPath($path)); + } + public function filemtime($path) { + return filemtime($this->buildPath($path)); + } + public function touch($path, $mtime=null) { + // sets the modification time of the file to the given value. + // If mtime is nil the current time is set. + // note that the access time of the file always changes to the current time. + if(!is_null($mtime)) { + $result=touch( $this->buildPath($path), $mtime ); + }else{ + $result=touch( $this->buildPath($path)); + } + if( $result ) { + clearstatcache( true, $this->buildPath($path) ); + } + + return $result; + } + public function file_get_contents($path) { + return file_get_contents($this->buildPath($path)); + } + public function file_put_contents($path, $data) {//trigger_error("$path = ".var_export($path, 1)); + return file_put_contents($this->buildPath($path), $data); + } + public function unlink($path) { + return $this->delTree($path); + } + public function rename($path1, $path2) { + if (!$this->isUpdatable($path1)) { + \OC_Log::write('core','unable to rename, file is not writable : '.$path1,\OC_Log::ERROR); + return false; + } + if(! $this->file_exists($path1)) { + \OC_Log::write('core','unable to rename, file does not exists : '.$path1,\OC_Log::ERROR); + return false; + } + + $physicPath1 = $this->buildPath($path1); + $physicPath2 = $this->buildPath($path2); + if($return=rename($physicPath1, $physicPath2)) { + // mapper needs to create copies or all children + $this->copyMapping($path1, $path2); + $this->cleanMapper($physicPath1, false, true); + } + return $return; + } + public function copy($path1, $path2) { + if($this->is_dir($path2)) { + if(!$this->file_exists($path2)) { + $this->mkdir($path2); + } + $source=substr($path1, strrpos($path1, '/')+1); + $path2.=$source; + } + if($return=copy($this->buildPath($path1), $this->buildPath($path2))) { + // mapper needs to create copies or all children + $this->copyMapping($path1, $path2); + } + return $return; + } + public function fopen($path, $mode) { + if($return=fopen($this->buildPath($path), $mode)) { + switch($mode) { + case 'r': + break; + case 'r+': + case 'w+': + case 'x+': + case 'a+': + break; + case 'w': + case 'x': + case 'a': + break; + } + } + return $return; + } + + public function getMimeType($path) { + if($this->isReadable($path)) { + return \OC_Helper::getMimeType($this->buildPath($path)); + }else{ + return false; + } + } + + private function delTree($dir, $isLogicPath=true) { + $dirRelative=$dir; + if ($isLogicPath) { + $dir=$this->buildPath($dir); + } + if (!file_exists($dir)) { + return true; + } + if (!is_dir($dir) || is_link($dir)) { + if($return=unlink($dir)) { + $this->cleanMapper($dir, false); + return $return; + } + } + foreach (scandir($dir) as $item) { + if ($item == '.' || $item == '..') { + continue; + } + if(is_file($dir.'/'.$item)) { + if(unlink($dir.'/'.$item)) { + $this->cleanMapper($dir.'/'.$item, false); + } + }elseif(is_dir($dir.'/'.$item)) { + if (!$this->delTree($dir. "/" . $item, false)) { + return false; + }; + } + } + if($return=rmdir($dir)) { + $this->cleanMapper($dir, false); + } + return $return; + } + + private static function getFileSizeFromOS($fullPath) { + $name = strtolower(php_uname('s')); + // Windows OS: we use COM to access the filesystem + if (strpos($name, 'win') !== false) { + if (class_exists('COM')) { + $fsobj = new \COM("Scripting.FileSystemObject"); + $f = $fsobj->GetFile($fullPath); + return $f->Size; + } + } else if (strpos($name, 'bsd') !== false) { + if (\OC_Helper::is_function_enabled('exec')) { + return (float)exec('stat -f %z ' . escapeshellarg($fullPath)); + } + } else if (strpos($name, 'linux') !== false) { + if (\OC_Helper::is_function_enabled('exec')) { + return (float)exec('stat -c %s ' . escapeshellarg($fullPath)); + } + } else { + \OC_Log::write('core', 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, \OC_Log::ERROR); + } + + return 0; + } + + public function hash($path, $type, $raw=false) { + return hash_file($type, $this->buildPath($path), $raw); + } + + public function free_space($path) { + return @disk_free_space($this->buildPath($path)); + } + + public function search($query) { + return $this->searchInDir($query); + } + public function getLocalFile($path) { + return $this->buildPath($path); + } + public function getLocalFolder($path) { + return $this->buildPath($path); + } + + protected function searchInDir($query, $dir='', $isLogicPath=true) { + $files=array(); + $physicalDir = $this->buildPath($dir); + foreach (scandir($physicalDir) as $item) { + if ($item == '.' || $item == '..') + continue; + $physicalItem = $this->mapper->physicalToLogic($physicalDir.DIRECTORY_SEPARATOR.$item); + $item = substr($physicalItem, strlen($physicalDir)+1); + + if(strstr(strtolower($item), strtolower($query)) !== false) { + $files[]=$dir.'/'.$item; + } + if(is_dir($physicalItem)) { + $files=array_merge($files, $this->searchInDir($query, $physicalItem, false)); + } + } + return $files; + } + + /** + * check if a file or folder has been updated since $time + * @param string $path + * @param int $time + * @return bool + */ + public function hasUpdated($path, $time) { + return $this->filemtime($path)>$time; + } + + private function buildPath($path, $create=true) { + $path = $this->stripLeading($path); + $fullPath = $this->datadir.$path; + return $this->mapper->logicToPhysical($fullPath, $create); + } + + private function cleanMapper($path, $isLogicPath=true, $recursive=true) { + $fullPath = $path; + if ($isLogicPath) { + $fullPath = $this->datadir.$path; + } + $this->mapper->removePath($fullPath, $isLogicPath, $recursive); + } + + private function copyMapping($path1, $path2) { + $path1 = $this->stripLeading($path1); + $path2 = $this->stripLeading($path2); + + $fullPath1 = $this->datadir.$path1; + $fullPath2 = $this->datadir.$path2; + + $this->mapper->copy($fullPath1, $fullPath2); + } + + private function stripLeading($path) { + if(strpos($path, '/') === 0) { + $path = substr($path, 1); + } + + return $path; + } +} diff --git a/lib/files/storage/temporary.php b/lib/files/storage/temporary.php index 542d2cd9f48..d84dbda2e39 100644 --- a/lib/files/storage/temporary.php +++ b/lib/files/storage/temporary.php @@ -21,6 +21,7 @@ class Temporary extends Local{ } public function __destruct() { + parent::__destruct(); $this->cleanUp(); } } -- cgit v1.2.3 From 60411f7d3d676e4ed83262b1066e7ce4a7dc904f Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sat, 9 Feb 2013 16:18:30 +0100 Subject: Remove unneeded __destruct call in OC\Files\Storage\Temporary --- lib/files/storage/temporary.php | 1 - 1 file changed, 1 deletion(-) (limited to 'lib/files/storage') diff --git a/lib/files/storage/temporary.php b/lib/files/storage/temporary.php index d84dbda2e39..542d2cd9f48 100644 --- a/lib/files/storage/temporary.php +++ b/lib/files/storage/temporary.php @@ -21,7 +21,6 @@ class Temporary extends Local{ } public function __destruct() { - parent::__destruct(); $this->cleanUp(); } } -- cgit v1.2.3 From 8174e5faf18fcd762efce5ffdfabfa1102580dd5 Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Sat, 9 Feb 2013 19:03:03 +0100 Subject: 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 (limited to 'lib/files/storage') 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); + } +} + -- cgit v1.2.3 From 92e6409f4008d21c8507310d7b6ce0f64fc29b71 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Mon, 11 Feb 2013 13:53:10 +0100 Subject: 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(-) (limited to 'lib/files/storage') 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; } -- cgit v1.2.3 From e0da721a7dd51cf939f0aed533d5d0fa0fa8f74e Mon Sep 17 00:00:00 2001 From: Thomas Müller Date: Sat, 9 Feb 2013 17:16:13 +0100 Subject: adding ctor to Local and revert call to it within Temporary --- lib/files/storage/local.php | 2 ++ lib/files/storage/temporary.php | 1 + 2 files changed, 3 insertions(+) (limited to 'lib/files/storage') diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index d387a898320..9fe01135866 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -23,6 +23,8 @@ class Local extends \OC\Files\Storage\Common{ $this->datadir.='/'; } } + public function __destruct() { + } public function getId(){ return 'local::'.$this->datadir; } diff --git a/lib/files/storage/temporary.php b/lib/files/storage/temporary.php index 542d2cd9f48..d84dbda2e39 100644 --- a/lib/files/storage/temporary.php +++ b/lib/files/storage/temporary.php @@ -21,6 +21,7 @@ class Temporary extends Local{ } public function __destruct() { + parent::__destruct(); $this->cleanUp(); } } -- cgit v1.2.3 From 5c4a804ddb4942687d5b8495d1ede51873cd412b Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sat, 9 Feb 2013 16:46:55 +0100 Subject: Fix SpaceBeforeOpenBrace errors --- apps/files_external/ajax/addRootCertificate.php | 2 +- apps/files_external/lib/streamwrapper.php | 2 +- apps/files_external/lib/swift.php | 2 +- apps/files_external/lib/webdav.php | 2 +- apps/files_versions/lib/versions.php | 2 +- apps/user_ldap/ajax/deleteConfiguration.php | 4 ++-- apps/user_ldap/lib/connection.php | 4 ++-- lib/api.php | 2 +- lib/app.php | 6 +++--- lib/base.php | 2 +- lib/connector/sabre/request.php | 2 +- lib/fileproxy/fileoperations.php | 2 +- lib/fileproxy/quota.php | 2 +- lib/files/cache/permissions.php | 2 +- lib/files/storage/common.php | 10 +++++----- lib/installer.php | 12 ++++++------ lib/ocs/privatedata.php | 2 +- lib/util.php | 4 ++-- settings/oauth.php | 8 ++++---- 19 files changed, 36 insertions(+), 36 deletions(-) (limited to 'lib/files/storage') diff --git a/apps/files_external/ajax/addRootCertificate.php b/apps/files_external/ajax/addRootCertificate.php index ba8a14d2ea1..7794238ab36 100644 --- a/apps/files_external/ajax/addRootCertificate.php +++ b/apps/files_external/ajax/addRootCertificate.php @@ -14,7 +14,7 @@ fclose($fh); $filename = $_FILES['rootcert_import']['name']; $view = new \OC\Files\View('/'.\OCP\User::getUser().'/files_external/uploads'); -if (!$view->file_exists('')){ +if (!$view->file_exists('')) { $view->mkdir(''); } diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index 7c3ddcf8a2c..ff7e2238bd1 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -12,7 +12,7 @@ abstract class StreamWrapper extends \OC\Files\Storage\Common{ private $ready = false; protected function init(){ - if($this->ready){ + if($this->ready) { return; } $this->ready = true; diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index cbf2007052b..8ffa9d8552d 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -290,7 +290,7 @@ class SWIFT extends \OC\Files\Storage\Common{ } private function init(){ - if($this->ready){ + if($this->ready) { return; } $this->ready = true; diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 2a953ac63f4..f54cdc06228 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -49,7 +49,7 @@ class DAV extends \OC\Files\Storage\Common{ } private function init(){ - if($this->ready){ + if($this->ready) { return; } $this->ready = true; diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index b54bc4a4422..b4ef88a6e87 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -94,7 +94,7 @@ class Storage { // expire old revisions if necessary $newSize = self::expire($filename, $versionsSize); - if ( $newSize != $versionsSize ) { + if ( $newSize != $versionsSize ) { \OCP\Config::setAppValue('files_versions', 'size', $versionsSize); } } diff --git a/apps/user_ldap/ajax/deleteConfiguration.php b/apps/user_ldap/ajax/deleteConfiguration.php index b7d633a049d..ade57110d34 100644 --- a/apps/user_ldap/ajax/deleteConfiguration.php +++ b/apps/user_ldap/ajax/deleteConfiguration.php @@ -27,9 +27,9 @@ OCP\JSON::checkAppEnabled('user_ldap'); OCP\JSON::callCheck(); $prefix = $_POST['ldap_serverconfig_chooser']; -if(\OCA\user_ldap\lib\Helper::deleteServerConfiguration($prefix)){ +if(\OCA\user_ldap\lib\Helper::deleteServerConfiguration($prefix)) { OCP\JSON::success(); } else { $l=OC_L10N::get('user_ldap'); OCP\JSON::error(array('message' => $l->t('Failed to delete the server configuration'))); -} \ No newline at end of file +} diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 933f2f42074..9a37920e35d 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -192,7 +192,7 @@ class Connection { private function getValue($varname) { static $defaults; - if(is_null($defaults)){ + if(is_null($defaults)) { $defaults = $this->getDefaults(); } return \OCP\Config::getAppValue($this->configID, @@ -336,7 +336,7 @@ class Connection { case 'ldapBaseGroups': case 'ldapAttributesForUserSearch': case 'ldapAttributesForGroupSearch': - if(is_array($value)){ + if(is_array($value)) { $value = implode("\n", $value); } break; diff --git a/lib/api.php b/lib/api.php index abf1c3b0036..70e3028b68a 100644 --- a/lib/api.php +++ b/lib/api.php @@ -82,7 +82,7 @@ class OC_API { // Prepare the request variables if($_SERVER['REQUEST_METHOD'] == 'PUT') { parse_str(file_get_contents("php://input"), $parameters['_put']); - } else if($_SERVER['REQUEST_METHOD'] == 'DELETE'){ + } else if($_SERVER['REQUEST_METHOD'] == 'DELETE') { parse_str(file_get_contents("php://input"), $parameters['_delete']); } $name = $parameters['_route']; diff --git a/lib/app.php b/lib/app.php index bf7eeef0181..7eab1405781 100644 --- a/lib/app.php +++ b/lib/app.php @@ -157,7 +157,7 @@ class OC_App{ */ public static function isShipped($appid){ $info = self::getAppInfo($appid); - if(isset($info['shipped']) && $info['shipped']=='true'){ + if(isset($info['shipped']) && $info['shipped']=='true') { return true; } else { return false; @@ -247,7 +247,7 @@ class OC_App{ OC_Appconfig::setValue( $app, 'enabled', 'no' ); // check if app is a shipped app or not. if not delete - if(!OC_App::isShipped( $app )){ + if(!OC_App::isShipped( $app )) { OC_Installer::removeApp( $app ); } } @@ -726,7 +726,7 @@ class OC_App{ $app1[$i]['ocs_id'] = $app['id']; $app1[$i]['internal'] = $app1[$i]['active'] = 0; $app1[$i]['update'] = false; - if($app['label']=='recommended'){ + if($app['label']=='recommended') { $app1[$i]['internallabel'] = 'Recommended'; $app1[$i]['internalclass'] = 'recommendedapp'; }else{ diff --git a/lib/base.php b/lib/base.php index c60a97100f4..fea9e3ca3a6 100644 --- a/lib/base.php +++ b/lib/base.php @@ -550,7 +550,7 @@ class OC { } $request = OC_Request::getPathInfo(); - if(substr($request, -3) !== '.js'){// we need these files during the upgrade + if(substr($request, -3) !== '.js') {// we need these files during the upgrade self::checkMaintenanceMode(); self::checkUpgrade(); } diff --git a/lib/connector/sabre/request.php b/lib/connector/sabre/request.php index 97a27996bf3..d70c25c4e70 100644 --- a/lib/connector/sabre/request.php +++ b/lib/connector/sabre/request.php @@ -40,7 +40,7 @@ class OC_Connector_Sabre_Request extends Sabre_HTTP_Request { * @return string */ public function getRawServerValue($field) { - if($field == 'REQUEST_URI'){ + if($field == 'REQUEST_URI') { return $this->getUri(); } else{ diff --git a/lib/fileproxy/fileoperations.php b/lib/fileproxy/fileoperations.php index 47ccd8f8c26..b2ff2e7e5e9 100644 --- a/lib/fileproxy/fileoperations.php +++ b/lib/fileproxy/fileoperations.php @@ -28,7 +28,7 @@ class OC_FileProxy_FileOperations extends OC_FileProxy{ static $rootView; public function premkdir($path) { - if(!self::$rootView){ + if(!self::$rootView) { self::$rootView = new \OC\Files\View(''); } return !self::$rootView->file_exists($path); diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php index 7e0f631c8fb..07d1d250e4d 100644 --- a/lib/fileproxy/quota.php +++ b/lib/fileproxy/quota.php @@ -95,7 +95,7 @@ class OC_FileProxy_Quota extends OC_FileProxy{ } public function preCopy($path1, $path2) { - if(!self::$rootView){ + if(!self::$rootView) { self::$rootView = new \OC\Files\View(''); } return (self::$rootView->filesize($path1)<$this->getFreeSpace($path2) or $this->getFreeSpace($path2)==-1); diff --git a/lib/files/cache/permissions.php b/lib/files/cache/permissions.php index d0968337f02..e24c05b10a3 100644 --- a/lib/files/cache/permissions.php +++ b/lib/files/cache/permissions.php @@ -18,7 +18,7 @@ class Permissions { * @param \OC\Files\Storage\Storage|string $storage */ public function __construct($storage){ - if($storage instanceof \OC\Files\Storage\Storage){ + if($storage instanceof \OC\Files\Storage\Storage) { $this->storageId = $storage->getId(); }else{ $this->storageId = $storage; diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index ce9e7ead6d1..6935ba00953 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -51,19 +51,19 @@ abstract class Common implements \OC\Files\Storage\Storage { } public function getPermissions($path){ $permissions = 0; - if($this->isCreatable($path)){ + if($this->isCreatable($path)) { $permissions |= \OCP\PERMISSION_CREATE; } - if($this->isReadable($path)){ + if($this->isReadable($path)) { $permissions |= \OCP\PERMISSION_READ; } - if($this->isUpdatable($path)){ + if($this->isUpdatable($path)) { $permissions |= \OCP\PERMISSION_UPDATE; } - if($this->isDeletable($path)){ + if($this->isDeletable($path)) { $permissions |= \OCP\PERMISSION_DELETE; } - if($this->isSharable($path)){ + if($this->isSharable($path)) { $permissions |= \OCP\PERMISSION_SHARE; } return $permissions; diff --git a/lib/installer.php b/lib/installer.php index c86f801b5fc..aa192880af0 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -270,12 +270,12 @@ class OC_Installer{ public static function isUpdateAvailable( $app ) { $ocsid=OC_Appconfig::getValue( $app, 'ocsid', ''); - if($ocsid<>''){ + if($ocsid<>'') { $ocsdata=OC_OCSClient::getApplication($ocsid); $ocsversion= (string) $ocsdata['version']; $currentversion=OC_App::getAppVersion($app); - if($ocsversion<>$currentversion){ + if($ocsversion<>$currentversion) { return($ocsversion); }else{ @@ -326,22 +326,22 @@ class OC_Installer{ */ public static function removeApp( $name, $options = array()) { - if(isset($options['keeppreferences']) and $options['keeppreferences']==false ){ + if(isset($options['keeppreferences']) and $options['keeppreferences']==false ) { // todo // remove preferences } - if(isset($options['keepappconfig']) and $options['keepappconfig']==false ){ + if(isset($options['keepappconfig']) and $options['keepappconfig']==false ) { // todo // remove app config } - if(isset($options['keeptables']) and $options['keeptables']==false ){ + if(isset($options['keeptables']) and $options['keeptables']==false ) { // todo // remove app database tables } - if(isset($options['keepfiles']) and $options['keepfiles']==false ){ + if(isset($options['keepfiles']) and $options['keepfiles']==false ) { // todo // remove user files } diff --git a/lib/ocs/privatedata.php b/lib/ocs/privatedata.php index 311b24269dd..971a5c2ad31 100644 --- a/lib/ocs/privatedata.php +++ b/lib/ocs/privatedata.php @@ -46,7 +46,7 @@ class OC_OCS_Privatedata { $app = addslashes(strip_tags($parameters['app'])); $key = addslashes(strip_tags($parameters['key'])); $value = OC_OCS::readData('post', 'value', 'text'); - if(OC_Preferences::setValue($user, $app, $key, $value)){ + if(OC_Preferences::setValue($user, $app, $key, $value)) { return new OC_OCS_Result(null, 100); } } diff --git a/lib/util.php b/lib/util.php index a4e7271adcd..59e67f2a5f1 100755 --- a/lib/util.php +++ b/lib/util.php @@ -246,8 +246,8 @@ class OC_Util { $handler = ini_get("session.save_handler"); if($handler == "files") { $tmpDir = session_save_path(); - if($tmpDir != ""){ - if(!@is_writable($tmpDir)){ + if($tmpDir != "") { + if(!@is_writable($tmpDir)) { $errors[]=array('error' => 'The temporary folder used by PHP to save the session data is either incorrect or not writable! Please check : '.session_save_path().'
', 'hint'=>'Please ask your server administrator to grant write access or define another temporary folder.'); } diff --git a/settings/oauth.php b/settings/oauth.php index 8dba9b33a53..07b7ae5c31d 100644 --- a/settings/oauth.php +++ b/settings/oauth.php @@ -15,7 +15,7 @@ switch($operation){ case 'register': // Here external apps can register with an ownCloud - if(empty($_GET['name']) || empty($_GET['url'])){ + if(empty($_GET['name']) || empty($_GET['url'])) { // Invalid request echo 401; } else { @@ -54,13 +54,13 @@ switch($operation){ foreach($consumer['scopes'] as $requiredapp){ // App scopes are in this format: app_$appname $requiredapp = end(explode('_', $requiredapp)); - if(!in_array($requiredapp, $apps)){ + if(!in_array($requiredapp, $apps)) { $notfound[] = $requiredapp; } } - if(!empty($notfound)){ + if(!empty($notfound)) { // We need more apps :( Show error - if(count($notfound)==1){ + if(count($notfound)==1) { $message = 'requires that you have an extra app installed on your ownCloud. Please contact your ownCloud administrator and ask them to install the app below.'; } else { $message = 'requires that you have some extra apps installed on your ownCloud. Please contract your ownCloud administrator and ask them to install the apps below.'; -- cgit v1.2.3 From d3ef967993d1e685e3311b073a8312c9dafdf214 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sat, 9 Feb 2013 17:27:57 +0100 Subject: Fix indentation style --- apps/files_trashbin/lib/trash.php | 2 +- core/templates/exception.php | 4 ++-- lib/app.php | 38 +++++++++++++++++++------------------- lib/files/storage/common.php | 2 +- lib/migrate.php | 2 +- lib/ocs.php | 2 +- lib/public/iaddressbook.php | 20 ++++++++++---------- 7 files changed, 35 insertions(+), 35 deletions(-) (limited to 'lib/files/storage') diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index d88dc1ac252..8016040f1e9 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -349,7 +349,7 @@ class Trashbin { $versionsName = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath($filename); $versions = array(); if ($timestamp ) { - // fetch for old versions + // fetch for old versions $matches = glob( $versionsName.'.v*.d'.$timestamp ); $offset = -strlen($timestamp)-2; } else { diff --git a/core/templates/exception.php b/core/templates/exception.php index 47792225557..62d6cf2ade5 100644 --- a/core/templates/exception.php +++ b/core/templates/exception.php @@ -20,11 +20,11 @@ echo 'Request Method: ' . $_['sysinfo']['requestmethod'] . "\n"; echo 'Database: ' . $_['sysinfo']['database'] . "\n"; echo ''; - }else{ + } else { echo 'Your administrator has disabled systeminformations.'; } ?>

- \ No newline at end of file + diff --git a/lib/app.php b/lib/app.php index 7eab1405781..fe381a57077 100644 --- a/lib/app.php +++ b/lib/app.php @@ -76,14 +76,14 @@ class OC_App{ && empty(OC_Util::$core_scripts) && empty(OC_Util::$core_styles)) { OC_Util::$core_scripts = OC_Util::$scripts; - OC_Util::$scripts = array(); - OC_Util::$core_styles = OC_Util::$styles; - OC_Util::$styles = array(); + OC_Util::$scripts = array(); + OC_Util::$core_styles = OC_Util::$styles; + OC_Util::$styles = array(); + } } - } // return - return true; -} + return true; + } /** * load a single app @@ -557,16 +557,16 @@ class OC_App{ $forms=array(); switch($type) { case 'settings': - $source=self::$settingsForms; - break; + $source=self::$settingsForms; + break; case 'admin': - $source=self::$adminForms; - break; + $source=self::$adminForms; + break; case 'personal': - $source=self::$personalForms; - break; + $source=self::$personalForms; + break; default: - return array(); + return array(); } foreach($source as $form) { $forms[]=include $form; @@ -694,15 +694,15 @@ class OC_App{ // OR $app['ocs_id'] == $remote['ocs_id'] ) { unset( $remoteApps[$key]); + } } } + $combinedApps = array_merge( $appList, $remoteApps ); + } else { + $combinedApps = $appList; } - $combinedApps = array_merge( $appList, $remoteApps ); - } else { - $combinedApps = $appList; - } - return $combinedApps; -} + return $combinedApps; + } /** * @brief: get a list of all apps on apps.owncloud.com diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index 6935ba00953..bff5c5d57d9 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -132,7 +132,7 @@ abstract class Common implements \OC\Files\Storage\Storage { //$this->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV if ( $empty == false ) { if ( !$this->rmdir( $directory ) ) { - return false; + return false; } } return true; diff --git a/lib/migrate.php b/lib/migrate.php index 87bdd016fe4..45130be3a1f 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -181,7 +181,7 @@ class OC_Migrate{ return json_encode( array( 'success' => false ) ); } return json_encode( array( 'success' => true, 'data' => self::$zippath ) ); - } + } /** * @brief imports a user, or owncloud instance diff --git a/lib/ocs.php b/lib/ocs.php index 879aaa76687..1657f1f9d7b 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -173,7 +173,7 @@ class OC_OCS { } } xmlwriter_end_element($writer); - } + } xmlwriter_end_element($writer); }elseif($dimension=='3') { diff --git a/lib/public/iaddressbook.php b/lib/public/iaddressbook.php index 14943747f48..77e8750d9da 100644 --- a/lib/public/iaddressbook.php +++ b/lib/public/iaddressbook.php @@ -43,22 +43,22 @@ namespace OCP { * @return array of contacts which are arrays of key-value-pairs */ public function search($pattern, $searchProperties, $options); -// // dummy results -// return array( -// array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), -// array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), -// ); + // // dummy results + // return array( + // array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', 'GEO' => '37.386013;-122.082932'), + // array('id' => 5, 'FN' => 'Thomas Tanghus', 'EMAIL' => array('d@e.f', 'g@h.i')), + // ); /** * @param array $properties this array if key-value-pairs defines a contact * @return array representing the contact just created or updated */ public function createOrUpdate($properties); -// // dummy -// return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', -// 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', -// 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' -// ); + // // dummy + // return array('id' => 0, 'FN' => 'Thomas Müller', 'EMAIL' => 'a@b.c', + // 'PHOTO' => 'VALUE=uri:http://www.abc.com/pub/photos/jqpublic.gif', + // 'ADR' => ';;123 Main Street;Any Town;CA;91921-1234' + // ); /** * @return mixed -- cgit v1.2.3 From cd35d257bb3bef2e02ccf0cd99e59a74f1a753b9 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Sat, 9 Feb 2013 17:35:47 +0100 Subject: Fix NoSpaceAfterComma and SpaceBeforeComma --- apps/files/templates/part.breadcrumb.php | 2 +- apps/files_encryption/appinfo/app.php | 2 +- apps/files_encryption/lib/crypt.php | 2 +- apps/files_external/lib/config.php | 4 +-- apps/files_external/lib/ftp.php | 4 +-- apps/files_external/lib/smb.php | 2 +- apps/files_external/lib/streamwrapper.php | 22 ++++++------- apps/files_external/lib/swift.php | 2 +- apps/files_external/lib/webdav.php | 18 +++++------ apps/files_trashbin/ajax/undelete.php | 2 +- apps/files_trashbin/index.php | 2 +- apps/files_trashbin/lib/trash.php | 4 +-- apps/user_ldap/lib/connection.php | 2 +- lib/connector/sabre/file.php | 2 +- lib/connector/sabre/node.php | 4 +-- lib/files/mapper.php | 2 +- lib/files/storage/common.php | 54 +++++++++++++++---------------- lib/files/storage/local.php | 6 ++-- lib/files/storage/mappedlocal.php | 6 ++-- lib/ocs.php | 2 +- lib/ocs/cloud.php | 2 +- lib/ocs/privatedata.php | 2 +- lib/public/share.php | 2 +- lib/user.php | 2 +- lib/util.php | 6 ++-- 25 files changed, 79 insertions(+), 79 deletions(-) (limited to 'lib/files/storage') diff --git a/apps/files/templates/part.breadcrumb.php b/apps/files/templates/part.breadcrumb.php index 4cc2c4dce9e..f01cb8d212a 100644 --- a/apps/files/templates/part.breadcrumb.php +++ b/apps/files/templates/part.breadcrumb.php @@ -1,7 +1,7 @@ diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index 08728622525..c7cd8ca32de 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -12,7 +12,7 @@ OC_FileProxy::register( new OCA\Encryption\Proxy() ); // User-related hooks OCP\Util::connectHook( 'OC_User', 'post_login', 'OCA\Encryption\Hooks', 'login' ); -OCP\Util::connectHook( 'OC_User', 'pre_setPassword','OCA\Encryption\Hooks', 'setPassphrase' ); +OCP\Util::connectHook( 'OC_User', 'pre_setPassword', 'OCA\Encryption\Hooks', 'setPassphrase' ); // Sharing-related hooks OCP\Util::connectHook( 'OCP\Share', 'post_shared', 'OCA\Encryption\Hooks', 'postShared' ); diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index c7a414c5080..437a18669e5 100755 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -692,4 +692,4 @@ class Crypt { } -} \ No newline at end of file +} diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index d78c69e83db..44e668a09c0 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -310,7 +310,7 @@ class OC_Mount_Config { foreach ($data[self::MOUNT_TYPE_GROUP] as $group => $mounts) { $content .= "\t\t'".$group."' => array (\n"; foreach ($mounts as $mountPoint => $mount) { - $content .= "\t\t\t'".addcslashes($mountPoint,"'")."' => ".str_replace("\n", '', var_export($mount, true)).", \n"; + $content .= "\t\t\t'".addcslashes($mountPoint, "'")."' => ".str_replace("\n", '', var_export($mount, true)).", \n"; } $content .= "\t\t),\n"; @@ -322,7 +322,7 @@ class OC_Mount_Config { foreach ($data[self::MOUNT_TYPE_USER] as $user => $mounts) { $content .= "\t\t'".$user."' => array (\n"; foreach ($mounts as $mountPoint => $mount) { - $content .= "\t\t\t'".addcslashes($mountPoint,"'")."' => ".str_replace("\n", '', var_export($mount, true)).",\n"; + $content .= "\t\t\t'".addcslashes($mountPoint, "'")."' => ".str_replace("\n", '', var_export($mount, true)).",\n"; } $content .= "\t\t),\n"; } diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php index 9a27b63323a..9b6c037bb57 100644 --- a/apps/files_external/lib/ftp.php +++ b/apps/files_external/lib/ftp.php @@ -68,7 +68,7 @@ class FTP extends \OC\Files\Storage\StreamWrapper{ case 'ab': //these are supported by the wrapper $context = stream_context_create(array('ftp' => array('overwrite' => true))); - return fopen($this->constructUrl($path),$mode, false,$context); + return fopen($this->constructUrl($path), $mode, false, $context); case 'r+': case 'w+': case 'wb+': @@ -89,7 +89,7 @@ class FTP extends \OC\Files\Storage\StreamWrapper{ $this->getFile($path, $tmpFile); } self::$tempFiles[$tmpFile]=$path; - return fopen('close://'.$tmpFile,$mode); + return fopen('close://'.$tmpFile, $mode); } return false; } diff --git a/apps/files_external/lib/smb.php b/apps/files_external/lib/smb.php index ffba0d000ca..62f6591d25a 100644 --- a/apps/files_external/lib/smb.php +++ b/apps/files_external/lib/smb.php @@ -33,7 +33,7 @@ class SMB extends \OC\Files\Storage\StreamWrapper{ $this->share='/'.$this->share; } if(substr($this->share, -1, 1)=='/') { - $this->share = substr($this->share,0,-1); + $this->share = substr($this->share, 0, -1); } } diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index ff7e2238bd1..a631e7ce06a 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -71,39 +71,39 @@ abstract class StreamWrapper extends \OC\Files\Storage\Common{ return $succes; } - public function fopen($path,$mode) { + public function fopen($path, $mode) { $this->init(); - return fopen($this->constructUrl($path),$mode); + return fopen($this->constructUrl($path), $mode); } public function free_space($path) { return 0; } - public function touch($path,$mtime=null) { + public function touch($path, $mtime=null) { $this->init(); if(is_null($mtime)) { - $fh = $this->fopen($path,'a'); - fwrite($fh,''); + $fh = $this->fopen($path, 'a'); + fwrite($fh, ''); fclose($fh); } else { return false;//not supported } } - public function getFile($path,$target) { + public function getFile($path, $target) { $this->init(); - return copy($this->constructUrl($path),$target); + return copy($this->constructUrl($path), $target); } - public function uploadFile($path,$target) { + public function uploadFile($path, $target) { $this->init(); - return copy($path,$this->constructUrl($target)); + return copy($path, $this->constructUrl($target)); } - public function rename($path1,$path2) { + public function rename($path1, $path2) { $this->init(); - return rename($this->constructUrl($path1),$this->constructUrl($path2)); + return rename($this->constructUrl($path1), $this->constructUrl($path2)); } public function stat($path) { diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index 8ffa9d8552d..0fd6fa143b8 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -210,7 +210,7 @@ class SWIFT extends \OC\Files\Storage\Common{ return false; } else { $fh=fopen($tmpFile, 'a'); - fwrite($fh,$name . "\n"); + fwrite($fh, $name . "\n"); } } catch(\Exception $e) { file_put_contents($tmpFile, $name . "\n"); diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index f54cdc06228..039a07b1ef2 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -153,10 +153,10 @@ class DAV extends \OC\Files\Storage\Common{ public function unlink($path) { $this->init(); - return $this->simpleResponse('DELETE', $path, null ,204); + return $this->simpleResponse('DELETE', $path, null, 204); } - public function fopen($path,$mode) { + public function fopen($path, $mode) { $this->init(); $path=$this->cleanPath($path); switch($mode) { @@ -235,13 +235,13 @@ class DAV extends \OC\Files\Storage\Common{ $this->client->proppatch($path, array('{DAV:}lastmodified' => $mtime)); } - public function getFile($path,$target) { + public function getFile($path, $target) { $this->init(); - $source=$this->fopen($path,'r'); - file_put_contents($target,$source); + $source=$this->fopen($path, 'r'); + file_put_contents($target, $source); } - public function uploadFile($path,$target) { + public function uploadFile($path, $target) { $this->init(); $source=fopen($path, 'r'); @@ -256,7 +256,7 @@ class DAV extends \OC\Files\Storage\Common{ curl_close ($curl); } - public function rename($path1,$path2) { + public function rename($path1, $path2) { $this->init(); $path1=$this->cleanPath($path1); $path2=$this->root.$this->cleanPath($path2); @@ -268,7 +268,7 @@ class DAV extends \OC\Files\Storage\Common{ } } - public function copy($path1,$path2) { + public function copy($path1, $path2) { $this->init(); $path1=$this->cleanPath($path1); $path2=$this->root.$this->cleanPath($path2); @@ -321,7 +321,7 @@ class DAV extends \OC\Files\Storage\Common{ } } - private function simpleResponse($method,$path,$body,$expected) { + private function simpleResponse($method, $path, $body, $expected) { $path=$this->cleanPath($path); try { $response=$this->client->request($method, $path, $body); diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index cc010979c51..6320c1d0827 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -38,7 +38,7 @@ if ( $error ) { $filelist .= $e.', '; } $l = OC_L10N::get('files_trashbin'); - $message = $l->t("Couldn't restore %s", array(rtrim($filelist,', '))); + $message = $l->t("Couldn't restore %s", array(rtrim($filelist, ', '))); OCP\JSON::error(array("data" => array("message" => $message, "success" => $success, "error" => $error))); } else { diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php index 1aceb8ffefd..a2d4cc0a44d 100644 --- a/apps/files_trashbin/index.php +++ b/apps/files_trashbin/index.php @@ -27,7 +27,7 @@ if ($dir) { $pos = strpos($dir.'/', '/', 1); $tmp = substr($dir, 0, $pos); $pos = strrpos($tmp, '.d'); - $timestamp = substr($tmp,$pos+2); + $timestamp = substr($tmp, $pos+2); $result[] = array( 'id' => $entryName, 'timestamp' => $timestamp, diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 8016040f1e9..76844ca92e9 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -80,7 +80,7 @@ class Trashbin { } } } else { - \OC_Log::write('files_trashbin', 'Couldn\'t move '.$file_path.' to the trash bin' , \OC_log::ERROR); + \OC_Log::write('files_trashbin', 'Couldn\'t move '.$file_path.' to the trash bin', \OC_log::ERROR); } // get available disk space for user @@ -188,7 +188,7 @@ class Trashbin { \OCP\Config::setAppValue('files_trashbin', 'size', $trashbinSize); return true; } else { - \OC_Log::write('files_trashbin', 'Couldn\'t restore file from trash bin, '.$filename , \OC_log::ERROR); + \OC_Log::write('files_trashbin', 'Couldn\'t restore file from trash bin, '.$filename, \OC_log::ERROR); } return false; diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 9a37920e35d..0bf2efe35af 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -235,7 +235,7 @@ class Connection { $this->config['turnOffCertCheck'] = $this->$v('ldap_turn_off_cert_check'); $this->config['ldapUserDisplayName'] - = mb_strtolower($this->$v('ldap_display_name'),'UTF-8'); + = mb_strtolower($this->$v('ldap_display_name'), 'UTF-8'); $this->config['ldapUserFilter'] = $this->$v('ldap_userlist_filter'); $this->config['ldapGroupFilter'] = $this->$v('ldap_group_filter'); diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index 61165d9956d..c7375541e86 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -84,7 +84,7 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D */ public function get() { - return \OC\Files\Filesystem::fopen($this->path,'rb'); + return \OC\Files\Filesystem::fopen($this->path, 'rb'); } diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index 52995630211..57ce3710db8 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -84,12 +84,12 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $newPath = $parentPath . '/' . $newName; $oldPath = $this->path; - \OC\Files\Filesystem::rename($this->path,$newPath); + \OC\Files\Filesystem::rename($this->path, $newPath); $this->path = $newPath; $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertypath` = ? WHERE `userid` = ? AND `propertypath` = ?' ); - $query->execute( array( $newPath,OC_User::getUser(), $oldPath )); + $query->execute( array( $newPath, OC_User::getUser(), $oldPath )); } diff --git a/lib/files/mapper.php b/lib/files/mapper.php index 2d29a8532b6..cd163dcbfcd 100644 --- a/lib/files/mapper.php +++ b/lib/files/mapper.php @@ -107,7 +107,7 @@ class Mapper private function stripLast($path) { if (substr($path, -1) == '/') { - $path = substr_replace($path ,'',-1); + $path = substr_replace($path, '', -1); } return $path; } diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index bff5c5d57d9..b4c33c69f6b 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -83,21 +83,21 @@ abstract class Common implements \OC\Files\Storage\Storage { } return fread($handle, $size); } - public function file_put_contents($path,$data) { + public function file_put_contents($path, $data) { $handle = $this->fopen($path, "w"); return fwrite($handle, $data); } - public function rename($path1,$path2) { - if($this->copy($path1,$path2)) { + public function rename($path1, $path2) { + if($this->copy($path1, $path2)) { return $this->unlink($path1); }else{ return false; } } - public function copy($path1,$path2) { - $source=$this->fopen($path1,'r'); - $target=$this->fopen($path2,'w'); - $count=\OC_Helper::streamCopy($source,$target); + public function copy($path1, $path2) { + $source=$this->fopen($path1, 'r'); + $target=$this->fopen($path2, 'w'); + $count=\OC_Helper::streamCopy($source, $target); return $count>0; } @@ -111,7 +111,7 @@ abstract class Common implements \OC\Files\Storage\Storage { * deleted together with its contents. To avoid this set $empty to true */ public function deleteAll( $directory, $empty = false ) { - $directory = trim($directory,'/'); + $directory = trim($directory, '/'); if ( !$this->file_exists( \OCP\USER::getUser() . '/' . $directory ) || !$this->is_dir( \OCP\USER::getUser() . '/' . $directory ) ) { return false; @@ -146,25 +146,25 @@ abstract class Common implements \OC\Files\Storage\Storage { if($this->is_dir($path)) { return 'httpd/unix-directory'; } - $source=$this->fopen($path,'r'); + $source=$this->fopen($path, 'r'); if(!$source) { return false; } - $head=fread($source,8192);//8kb should suffice to determine a mimetype - if($pos=strrpos($path,'.')) { - $extension=substr($path,$pos); + $head=fread($source, 8192);//8kb should suffice to determine a mimetype + if($pos=strrpos($path, '.')) { + $extension=substr($path, $pos); }else{ $extension=''; } $tmpFile=\OC_Helper::tmpFile($extension); - file_put_contents($tmpFile,$head); + file_put_contents($tmpFile, $head); $mime=\OC_Helper::getMimeType($tmpFile); unlink($tmpFile); return $mime; } - public function hash($type,$path,$raw = false) { + public function hash($type, $path, $raw = false) { $tmpFile=$this->getLocalFile($path); - $hash=hash($type,$tmpFile,$raw); + $hash=hash($type, $tmpFile, $raw); unlink($tmpFile); return $hash; } @@ -175,42 +175,42 @@ abstract class Common implements \OC\Files\Storage\Storage { return $this->toTmpFile($path); } private function toTmpFile($path) {//no longer in the storage api, still useful here - $source=$this->fopen($path,'r'); + $source=$this->fopen($path, 'r'); if(!$source) { return false; } - if($pos=strrpos($path,'.')) { - $extension=substr($path,$pos); + if($pos=strrpos($path, '.')) { + $extension=substr($path, $pos); }else{ $extension=''; } $tmpFile=\OC_Helper::tmpFile($extension); - $target=fopen($tmpFile,'w'); - \OC_Helper::streamCopy($source,$target); + $target=fopen($tmpFile, 'w'); + \OC_Helper::streamCopy($source, $target); return $tmpFile; } public function getLocalFolder($path) { $baseDir=\OC_Helper::tmpFolder(); - $this->addLocalFolder($path,$baseDir); + $this->addLocalFolder($path, $baseDir); return $baseDir; } - private function addLocalFolder($path,$target) { + private function addLocalFolder($path, $target) { if($dh=$this->opendir($path)) { while($file=readdir($dh)) { if($file!=='.' and $file!=='..') { if($this->is_dir($path.'/'.$file)) { mkdir($target.'/'.$file); - $this->addLocalFolder($path.'/'.$file,$target.'/'.$file); + $this->addLocalFolder($path.'/'.$file, $target.'/'.$file); }else{ $tmp=$this->toTmpFile($path.'/'.$file); - rename($tmp,$target.'/'.$file); + rename($tmp, $target.'/'.$file); } } } } } - protected function searchInDir($query,$dir='') { + protected function searchInDir($query, $dir='') { $files=array(); $dh=$this->opendir($dir); if($dh) { @@ -220,7 +220,7 @@ abstract class Common implements \OC\Files\Storage\Storage { $files[]=$dir.'/'.$item; } if($this->is_dir($dir.'/'.$item)) { - $files=array_merge($files,$this->searchInDir($query,$dir.'/'.$item)); + $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); } } } @@ -233,7 +233,7 @@ abstract class Common implements \OC\Files\Storage\Storage { * @param int $time * @return bool */ - public function hasUpdated($path,$time) { + public function hasUpdated($path, $time) { return $this->filemtime($path)>$time; } diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index aaa3c0fab49..4099f860d7b 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -40,7 +40,7 @@ class Local extends \OC\Files\Storage\Common{ return opendir($this->datadir.$path); } public function is_dir($path) { - if(substr($path,-1)=='/') { + if(substr($path, -1)=='/') { $path=substr($path, 0, -1); } return is_dir($this->datadir.$path); @@ -117,11 +117,11 @@ class Local extends \OC\Files\Storage\Common{ } public function rename($path1, $path2) { if (!$this->isUpdatable($path1)) { - \OC_Log::write('core','unable to rename, file is not writable : '.$path1,\OC_Log::ERROR); + \OC_Log::write('core', 'unable to rename, file is not writable : '.$path1, \OC_Log::ERROR); return false; } if(! $this->file_exists($path1)) { - \OC_Log::write('core','unable to rename, file does not exists : '.$path1,\OC_Log::ERROR); + \OC_Log::write('core', 'unable to rename, file does not exists : '.$path1, \OC_Log::ERROR); return false; } diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index 218465d8eef..f2af5bfe357 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -61,7 +61,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ return opendir('fakedir://local-win32'.$path); } public function is_dir($path) { - if(substr($path,-1)=='/') { + if(substr($path, -1)=='/') { $path=substr($path, 0, -1); } return is_dir($this->buildPath($path)); @@ -138,11 +138,11 @@ class MappedLocal extends \OC\Files\Storage\Common{ } public function rename($path1, $path2) { if (!$this->isUpdatable($path1)) { - \OC_Log::write('core','unable to rename, file is not writable : '.$path1,\OC_Log::ERROR); + \OC_Log::write('core', 'unable to rename, file is not writable : '.$path1, \OC_Log::ERROR); return false; } if(! $this->file_exists($path1)) { - \OC_Log::write('core','unable to rename, file does not exists : '.$path1,\OC_Log::ERROR); + \OC_Log::write('core', 'unable to rename, file does not exists : '.$path1, \OC_Log::ERROR); return false; } diff --git a/lib/ocs.php b/lib/ocs.php index 1657f1f9d7b..e08f0846f81 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -89,7 +89,7 @@ class OC_OCS { $format = self::readData($method, 'format', 'text', ''); $txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n"; $txt.=OC_OCS::getDebugOutput(); - echo(OC_OCS::generateXml($format,'failed',999,$txt)); + echo(OC_OCS::generateXml($format, 'failed', 999, $txt)); } diff --git a/lib/ocs/cloud.php b/lib/ocs/cloud.php index 820d24a8e0c..5553ae38215 100644 --- a/lib/ocs/cloud.php +++ b/lib/ocs/cloud.php @@ -31,7 +31,7 @@ class OC_OCS_Cloud { foreach($apps as $app) { $info = OC_App::getAppInfo($app); if(isset($info['standalone'])) { - $newValue = array('name'=>$info['name'],'url'=>OC_Helper::linkToAbsolute($app,''),'icon'=>''); + $newValue = array('name'=>$info['name'], 'url'=>OC_Helper::linkToAbsolute($app, ''), 'icon'=>''); $values[] = $newValue; } } diff --git a/lib/ocs/privatedata.php b/lib/ocs/privatedata.php index 971a5c2ad31..4dfd0a6e66e 100644 --- a/lib/ocs/privatedata.php +++ b/lib/ocs/privatedata.php @@ -29,7 +29,7 @@ class OC_OCS_Privatedata { $user = OC_User::getUser(); $app = addslashes(strip_tags($parameters['app'])); $key = addslashes(strip_tags($parameters['key'])); - $result = OC_OCS::getData($user,$app,$key); + $result = OC_OCS::getData($user, $app, $key); $xml = array(); foreach($result as $i=>$log) { $xml[$i]['key']=$log['key']; diff --git a/lib/public/share.php b/lib/public/share.php index af2a538e252..6dc30f6ae42 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -142,7 +142,7 @@ class Share { * @return Item */ public static function getShareByToken($token) { - $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?',1); + $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `token` = ?', 1); $result = $query->execute(array($token)); if (\OC_DB::isError($result)) { \OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result) . ', token=' . $token, \OC_Log::ERROR); diff --git a/lib/user.php b/lib/user.php index 16680be4aa0..48f4e5c7006 100644 --- a/lib/user.php +++ b/lib/user.php @@ -541,7 +541,7 @@ class OC_User { */ public static function userExists($uid, $excludingBackend=null) { foreach(self::$_usedBackends as $backend) { - if (!is_null($excludingBackend) && !strcmp(get_class($backend),$excludingBackend)) { + if (!is_null($excludingBackend) && !strcmp(get_class($backend), $excludingBackend)) { OC_Log::write('OC_User', $excludingBackend . 'excluded from user existance check.', OC_Log::DEBUG); continue; } diff --git a/lib/util.php b/lib/util.php index 59e67f2a5f1..b9ac8ed75d8 100755 --- a/lib/util.php +++ b/lib/util.php @@ -691,10 +691,10 @@ class OC_Util { curl_setopt($curl, CURLOPT_MAXREDIRS, 10); curl_setopt($curl, CURLOPT_USERAGENT, "ownCloud Server Crawler"); - if(OC_Config::getValue('proxy','')<>'') { + if(OC_Config::getValue('proxy', '')<>'') { curl_setopt($curl, CURLOPT_PROXY, OC_Config::getValue('proxy')); } - if(OC_Config::getValue('proxyuserpwd','')<>'') { + if(OC_Config::getValue('proxyuserpwd', '')<>'') { curl_setopt($curl, CURLOPT_PROXYUSERPWD, OC_Config::getValue('proxyuserpwd')); } $data = curl_exec($curl); @@ -703,7 +703,7 @@ class OC_Util { } else { $contextArray = null; - if(OC_Config::getValue('proxy','')<>'') { + if(OC_Config::getValue('proxy', '')<>'') { $contextArray = array( 'http' => array( 'timeout' => 10, -- cgit v1.2.3 From ffae6f4b847e96d691053300c355ab81edc6c1c8 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 11 Feb 2013 17:44:02 +0100 Subject: Style-fix: Breakup long lines --- lib/app.php | 79 ++++++++-- lib/appconfig.php | 9 +- lib/backgroundjob/queuedtask.php | 3 +- lib/base.php | 39 +++-- lib/config.php | 3 +- lib/connector/sabre/directory.php | 3 +- lib/connector/sabre/file.php | 5 +- lib/connector/sabre/locks.php | 33 ++++- lib/connector/sabre/node.php | 12 +- lib/db.php | 12 +- lib/eventsource.php | 3 +- lib/filechunking.php | 3 +- lib/files.php | 11 +- lib/files/cache/cache.php | 12 +- lib/files/cache/permissions.php | 9 +- lib/files/cache/upgrade.php | 3 +- lib/files/filesystem.php | 7 +- lib/files/storage/common.php | 3 +- lib/files/storage/local.php | 4 +- lib/files/storage/mappedlocal.php | 4 +- lib/files/view.php | 16 +- lib/filesystem.php | 7 +- lib/group.php | 7 +- lib/group/database.php | 11 +- lib/helper.php | 12 +- lib/hook.php | 4 +- lib/image.php | 32 +++- lib/installer.php | 25 +++- lib/log.php | 4 +- lib/log/owncloud.php | 3 +- lib/mail.php | 7 +- lib/migrate.php | 30 +++- lib/migration/content.php | 4 +- lib/ocs.php | 6 +- lib/ocsclient.php | 9 +- lib/preferences.php | 15 +- lib/public/api.php | 3 +- lib/public/config.php | 3 +- lib/public/files.php | 3 +- lib/public/share.php | 304 +++++++++++++++++++++++++++----------- lib/public/template.php | 3 +- lib/public/user.php | 3 +- lib/public/util.php | 9 +- lib/setup.php | 21 ++- lib/template.php | 17 ++- lib/templatelayout.php | 6 +- lib/updater.php | 8 +- lib/user.php | 13 +- lib/user/database.php | 6 +- lib/util.php | 90 +++++++---- lib/vcategories.php | 4 +- 51 files changed, 682 insertions(+), 260 deletions(-) (limited to 'lib/files/storage') diff --git a/lib/app.php b/lib/app.php index 159ada958d3..e653c30b2d9 100644 --- a/lib/app.php +++ b/lib/app.php @@ -172,7 +172,8 @@ class OC_App{ return array(); } $apps=array('files'); - $query = OC_DB::prepare( 'SELECT `appid` FROM `*PREFIX*appconfig` WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'' ); + $query = OC_DB::prepare( 'SELECT `appid` FROM `*PREFIX*appconfig`' + .' WHERE `configkey` = \'enabled\' AND `configvalue`=\'yes\'' ); $result=$query->execute(); while($row=$result->fetchRow()) { if(array_search($row['appid'], $apps)===false) { @@ -213,7 +214,8 @@ class OC_App{ $appdata=OC_OCSClient::getApplication($app); $download=OC_OCSClient::getApplicationDownload($app, 1); if(isset($download['downloadlink']) and $download['downloadlink']!='') { - $app=OC_Installer::installApp(array('source'=>'http', 'href'=>$download['downloadlink'],'appdata'=>$appdata)); + $info = array('source'=>'http', 'href'=>$download['downloadlink'], 'appdata'=>$appdata); + $app=OC_Installer::installApp($info); } } } @@ -222,7 +224,10 @@ class OC_App{ $info=OC_App::getAppInfo($app); $version=OC_Util::getVersion(); if(!isset($info['require']) or ($version[0]>$info['require'])) { - OC_Log::write('core', 'App "'.$info['name'].'" can\'t be installed because it is not compatible with this version of ownCloud', OC_Log::ERROR); + OC_Log::write('core', + 'App "'.$info['name'].'" can\'t be installed because it is' + .' not compatible with this version of ownCloud', + OC_Log::ERROR); return false; }else{ OC_Appconfig::setValue( $app, 'enabled', 'yes' ); @@ -337,34 +342,70 @@ class OC_App{ // by default, settings only contain the help menu if(OC_Config::getValue('knowledgebaseenabled', true)==true) { $settings = array( - array( "id" => "help", "order" => 1000, "href" => OC_Helper::linkToRoute( "settings_help" ), "name" => $l->t("Help"), "icon" => OC_Helper::imagePath( "settings", "help.svg" )) - ); + array( + "id" => "help", + "order" => 1000, + "href" => OC_Helper::linkToRoute( "settings_help" ), + "name" => $l->t("Help"), + "icon" => OC_Helper::imagePath( "settings", "help.svg" ) + ) + ); } // if the user is logged-in if (OC_User::isLoggedIn()) { // personal menu - $settings[] = array( "id" => "personal", "order" => 1, "href" => OC_Helper::linkToRoute( "settings_personal" ), "name" => $l->t("Personal"), "icon" => OC_Helper::imagePath( "settings", "personal.svg" )); + $settings[] = array( + "id" => "personal", + "order" => 1, + "href" => OC_Helper::linkToRoute( "settings_personal" ), + "name" => $l->t("Personal"), + "icon" => OC_Helper::imagePath( "settings", "personal.svg" ) + ); // if there are some settings forms if(!empty(self::$settingsForms)) { // settings menu - $settings[]=array( "id" => "settings", "order" => 1000, "href" => OC_Helper::linkToRoute( "settings_settings" ), "name" => $l->t("Settings"), "icon" => OC_Helper::imagePath( "settings", "settings.svg" )); + $settings[]=array( + "id" => "settings", + "order" => 1000, + "href" => OC_Helper::linkToRoute( "settings_settings" ), + "name" => $l->t("Settings"), + "icon" => OC_Helper::imagePath( "settings", "settings.svg" ) + ); } //SubAdmins are also allowed to access user management if(OC_SubAdmin::isSubAdmin(OC_User::getUser())) { // admin users menu - $settings[] = array( "id" => "core_users", "order" => 2, "href" => OC_Helper::linkToRoute( "settings_users" ), "name" => $l->t("Users"), "icon" => OC_Helper::imagePath( "settings", "users.svg" )); + $settings[] = array( + "id" => "core_users", + "order" => 2, + "href" => OC_Helper::linkToRoute( "settings_users" ), + "name" => $l->t("Users"), + "icon" => OC_Helper::imagePath( "settings", "users.svg" ) + ); } // if the user is an admin if(OC_User::isAdminUser(OC_User::getUser())) { // admin apps menu - $settings[] = array( "id" => "core_apps", "order" => 3, "href" => OC_Helper::linkToRoute( "settings_apps" ).'?installed', "name" => $l->t("Apps"), "icon" => OC_Helper::imagePath( "settings", "apps.svg" )); + $settings[] = array( + "id" => "core_apps", + "order" => 3, + "href" => OC_Helper::linkToRoute( "settings_apps" ).'?installed', + "name" => $l->t("Apps"), + "icon" => OC_Helper::imagePath( "settings", "apps.svg" ) + ); - $settings[]=array( "id" => "admin", "order" => 1000, "href" => OC_Helper::linkToRoute( "settings_admin" ), "name" => $l->t("Admin"), "icon" => OC_Helper::imagePath( "settings", "admin.svg" )); + $settings[]=array( + "id" => "admin", + "order" => 1000, + "href" => OC_Helper::linkToRoute( "settings_admin" ), + "name" => $l->t("Admin"), + "icon" => OC_Helper::imagePath( "settings", "admin.svg" ) + ); } } @@ -644,7 +685,8 @@ class OC_App{ public static function listAllApps() { $installedApps = OC_App::getAllApps(); - //TODO which apps do we want to blacklist and how do we integrate blacklisting with the multi apps folder feature? + //TODO which apps do we want to blacklist and how do we integrate + // blacklisting with the multi apps folder feature? $blacklist = array('files');//we dont want to show configuration for these $appList = array(); @@ -709,7 +751,8 @@ class OC_App{ /** * @brief: get a list of all apps on apps.owncloud.com - * @return array, multi-dimensional array of apps. Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description + * @return array, multi-dimensional array of apps. + * Keys: id, name, type, typename, personid, license, detailpage, preview, changed, description */ public static function getAppstoreApps( $filter = 'approved' ) { $categoryNames = OC_OCSClient::getCategories(); @@ -777,7 +820,9 @@ class OC_App{ $installedVersion = $versions[$app]; if (version_compare($currentVersion, $installedVersion, '>')) { $info = self::getAppInfo($app); - OC_Log::write($app, 'starting app upgrade from '.$installedVersion.' to '.$currentVersion, OC_Log::DEBUG); + OC_Log::write($app, + 'starting app upgrade from '.$installedVersion.' to '.$currentVersion, + OC_Log::DEBUG); try { OC_App::updateApp($app); OC_Hook::emit('update', 'success', 'Updated '.$info['name'].' app'); @@ -807,7 +852,10 @@ class OC_App{ // check if the app is compatible with this version of ownCloud $info = OC_App::getAppInfo($app); if(!isset($info['require']) or (($version[0].'.'.$version[1])>$info['require'])) { - OC_Log::write('core', 'App "'.$info['name'].'" ('.$app.') can\'t be used because it is not compatible with this version of ownCloud', OC_Log::ERROR); + OC_Log::write('core', + 'App "'.$info['name'].'" ('.$app.') can\'t be used because it is' + .' not compatible with this version of ownCloud', + OC_Log::ERROR); OC_App::disable( $app ); OC_Hook::emit('update', 'success', 'Disabled '.$info['name'].' app because it is not compatible'); } @@ -823,7 +871,8 @@ class OC_App{ return $versions; // when function is used besides in checkUpgrade } $versions=array(); - $query = OC_DB::prepare( 'SELECT `appid`, `configvalue` FROM `*PREFIX*appconfig` WHERE `configkey` = \'installed_version\'' ); + $query = OC_DB::prepare( 'SELECT `appid`, `configvalue` FROM `*PREFIX*appconfig`' + .' WHERE `configkey` = \'installed_version\'' ); $result = $query->execute(); while($row = $result->fetchRow()) { $versions[$row['appid']]=$row['configvalue']; diff --git a/lib/appconfig.php b/lib/appconfig.php index 1f2d576af87..e615d838173 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -91,7 +91,8 @@ class OC_Appconfig{ */ public static function getValue( $app, $key, $default = null ) { // At least some magic in here :-) - $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?' ); + $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*appconfig`' + .' WHERE `appid` = ? AND `configkey` = ?' ); $result = $query->execute( array( $app, $key )); $row = $result->fetchRow(); if($row) { @@ -124,11 +125,13 @@ class OC_Appconfig{ public static function setValue( $app, $key, $value ) { // Does the key exist? yes: update. No: insert if(! self::hasKey($app, $key)) { - $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*appconfig` ( `appid`, `configkey`, `configvalue` ) VALUES( ?, ?, ? )' ); + $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*appconfig` ( `appid`, `configkey`, `configvalue` )' + .' VALUES( ?, ?, ? )' ); $query->execute( array( $app, $key, $value )); } else{ - $query = OC_DB::prepare( 'UPDATE `*PREFIX*appconfig` SET `configvalue` = ? WHERE `appid` = ? AND `configkey` = ?' ); + $query = OC_DB::prepare( 'UPDATE `*PREFIX*appconfig` SET `configvalue` = ?' + .' WHERE `appid` = ? AND `configkey` = ?' ); $query->execute( array( $value, $app, $key )); } } diff --git a/lib/backgroundjob/queuedtask.php b/lib/backgroundjob/queuedtask.php index 8264e1a0ae6..b2ce6f39ed8 100644 --- a/lib/backgroundjob/queuedtask.php +++ b/lib/backgroundjob/queuedtask.php @@ -82,7 +82,8 @@ class OC_BackgroundJob_QueuedTask{ * @return id of task */ public static function add( $app, $klass, $method, $parameters ) { - $stmt = OC_DB::prepare( 'INSERT INTO `*PREFIX*queuedtasks` (`app`, `klass`, `method`, `parameters`) VALUES(?,?,?,?)' ); + $stmt = OC_DB::prepare( 'INSERT INTO `*PREFIX*queuedtasks` (`app`, `klass`, `method`, `parameters`)' + .' VALUES(?,?,?,?)' ); $result = $stmt->execute(array($app, $klass, $method, $parameters )); return OC_DB::insertid(); diff --git a/lib/base.php b/lib/base.php index fea9e3ca3a6..a40c2b7dfba 100644 --- a/lib/base.php +++ b/lib/base.php @@ -162,7 +162,9 @@ class OC { OC::$THIRDPARTYWEBROOT = rtrim(dirname(OC::$WEBROOT), '/'); OC::$THIRDPARTYROOT = rtrim(dirname(OC::$SERVERROOT), '/'); } else { - echo("3rdparty directory not found! Please put the ownCloud 3rdparty folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file."); + echo("3rdparty directory not found! Please put the ownCloud 3rdparty' + .' folder in the ownCloud folder or the folder above.' + .' You can also configure the location in the config.php file."); exit; } // search the apps folder @@ -178,11 +180,16 @@ class OC { } elseif (file_exists(OC::$SERVERROOT . '/apps')) { OC::$APPSROOTS[] = array('path' => OC::$SERVERROOT . '/apps', 'url' => '/apps', 'writable' => true); } elseif (file_exists(OC::$SERVERROOT . '/../apps')) { - OC::$APPSROOTS[] = array('path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', 'url' => '/apps', 'writable' => true); + OC::$APPSROOTS[] = array( + 'path' => rtrim(dirname(OC::$SERVERROOT), '/') . '/apps', + 'url' => '/apps', + 'writable' => true + ); } if (empty(OC::$APPSROOTS)) { - echo("apps directory not found! Please put the ownCloud apps folder in the ownCloud folder or the folder above. You can also configure the location in the config.php file."); + echo("apps directory not found! Please put the ownCloud apps folder in the ownCloud folder' + .' or the folder above. You can also configure the location in the config.php file."); exit; } $paths = array(); @@ -202,9 +209,14 @@ class OC { } public static function checkConfig() { - if (file_exists(OC::$SERVERROOT . "/config/config.php") and !is_writable(OC::$SERVERROOT . "/config/config.php")) { + if (file_exists(OC::$SERVERROOT . "/config/config.php") + and !is_writable(OC::$SERVERROOT . "/config/config.php")) { $tmpl = new OC_Template('', 'error', 'guest'); - $tmpl->assign('errors', array(1 => array('error' => "Can't write into config directory 'config'", 'hint' => "You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); + $tmpl->assign('errors', array(1 => array( + 'error' => "Can't write into config directory 'config'", + 'hint' => "You can usually fix this by giving the webserver user write access' + .' to the config directory in owncloud" + ))); $tmpl->printPage(); exit(); } @@ -257,7 +269,9 @@ class OC { if (version_compare($currentVersion, $installedVersion, '>')) { if ($showTemplate && !OC_Config::getValue('maintenance', false)) { OC_Config::setValue('maintenance', true); - OC_Log::write('core', 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, OC_Log::DEBUG); + OC_Log::write('core', + 'starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, + OC_Log::DEBUG); OC_Util::addscript('update'); $tmpl = new OC_Template('', 'update', 'guest'); $tmpl->assign('version', OC_Util::getVersionString()); @@ -387,14 +401,16 @@ class OC { } //set http auth headers for apache+php-cgi work around - if (isset($_SERVER['HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) { + if (isset($_SERVER['HTTP_AUTHORIZATION']) + && preg_match('/Basic\s+(.*)$/i', $_SERVER['HTTP_AUTHORIZATION'], $matches)) { list($name, $password) = explode(':', base64_decode($matches[1]), 2); $_SERVER['PHP_AUTH_USER'] = strip_tags($name); $_SERVER['PHP_AUTH_PW'] = strip_tags($password); } //set http auth headers for apache+php-cgi work around if variable gets renamed by apache - if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) { + if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION']) + && preg_match('/Basic\s+(.*)$/i', $_SERVER['REDIRECT_HTTP_AUTHORIZATION'], $matches)) { list($name, $password) = explode(':', base64_decode($matches[1]), 2); $_SERVER['PHP_AUTH_USER'] = strip_tags($name); $_SERVER['PHP_AUTH_PW'] = strip_tags($password); @@ -441,7 +457,8 @@ class OC { OC_User::useBackend(new OC_User_Database()); OC_Group::useBackend(new OC_Group_Database()); - if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SESSION['user_id']) && $_SERVER['PHP_AUTH_USER'] != $_SESSION['user_id']) { + if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SESSION['user_id']) + && $_SERVER['PHP_AUTH_USER'] != $_SESSION['user_id']) { OC_User::logout(); } @@ -498,7 +515,9 @@ class OC { // write error into log if locale can't be set if (OC_Util::issetlocaleworking() == false) { - OC_Log::write('core', 'setting locale to en_US.UTF-8/en_US.UTF8 failed. Support is probably not installed on your system', OC_Log::ERROR); + OC_Log::write('core', + 'setting locale to en_US.UTF-8/en_US.UTF8 failed. Support is probably not installed on your system', + OC_Log::ERROR); } if (OC_Config::getValue('installed', false)) { if (OC_Appconfig::getValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { diff --git a/lib/config.php b/lib/config.php index cbea9199320..a5c11b466f7 100644 --- a/lib/config.php +++ b/lib/config.php @@ -166,7 +166,8 @@ class OC_Config{ $tmpl = new OC_Template( '', 'error', 'guest' ); $tmpl->assign('errors', array(1=>array( 'error'=>"Can't write into config directory 'config'", - 'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud"))); + 'hint'=>"You can usually fix this by giving the webserver user write access' + .' to the config directory in owncloud"))); $tmpl->printPage(); exit; } diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index e29059d0395..a9aa891d409 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -160,7 +160,8 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa $chunks = array_chunk($paths, 200, false); foreach ($chunks as $pack) { $placeholders = join(',', array_fill(0, count($pack), '?')); - $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties` WHERE `userid` = ?' . ' AND `propertypath` IN ('.$placeholders.')' ); + $query = OC_DB::prepare( 'SELECT * FROM `*PREFIX*properties`' + .' WHERE `userid` = ?' . ' AND `propertypath` IN ('.$placeholders.')' ); array_unshift($pack, OC_User::getUser()); // prepend userid $result = $query->execute( $pack ); while($row = $result->fetchRow()) { diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index c7375541e86..c4c27e92251 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -113,8 +113,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D /** * Returns the ETag for a file * - * An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change. - * The ETag is an arbritrary string, but MUST be surrounded by double-quotes. + * An ETag is a unique identifier representing the current version of the + * file. If the file changes, the ETag MUST change. The ETag is an + * arbritrary string, but MUST be surrounded by double-quotes. * * Return null if the ETag can not effectively be determined * diff --git a/lib/connector/sabre/locks.php b/lib/connector/sabre/locks.php index a72d003bc72..e58e584fb41 100644 --- a/lib/connector/sabre/locks.php +++ b/lib/connector/sabre/locks.php @@ -44,7 +44,8 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { // NOTE: SQLite requires time() to be inserted directly. That's ugly // but otherwise reading locks from SQLite Databases will return // nothing - $query = 'SELECT * FROM `*PREFIX*locks` WHERE `userid` = ? AND (`created` + `timeout`) > '.time().' AND (( `uri` = ?)'; + $query = 'SELECT * FROM `*PREFIX*locks`' + .' WHERE `userid` = ? AND (`created` + `timeout`) > '.time().' AND (( `uri` = ?)'; $params = array(OC_User::getUser(), $uri); // We need to check locks for every part in the uri. @@ -116,11 +117,33 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract { } if ($exists) { - $query = OC_DB::prepare( 'UPDATE `*PREFIX*locks` SET `owner` = ?, `timeout` = ?, `scope` = ?, `depth` = ?, `uri` = ?, `created` = ? WHERE `userid` = ? AND `token` = ?' ); - $result = $query->execute( array($lockInfo->owner,$lockInfo->timeout,$lockInfo->scope,$lockInfo->depth,$uri,$lockInfo->created,OC_User::getUser(),$lockInfo->token)); + $query = OC_DB::prepare( 'UPDATE `*PREFIX*locks`' + .' SET `owner` = ?, `timeout` = ?, `scope` = ?, `depth` = ?, `uri` = ?, `created` = ?' + .' WHERE `userid` = ? AND `token` = ?' ); + $result = $query->execute( array( + $lockInfo->owner, + $lockInfo->timeout, + $lockInfo->scope, + $lockInfo->depth, + $uri, + $lockInfo->created, + OC_User::getUser(), + $lockInfo->token) + ); } else { - $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*locks` (`userid`,`owner`,`timeout`,`scope`,`depth`,`uri`,`created`,`token`) VALUES (?,?,?,?,?,?,?,?)' ); - $result = $query->execute( array(OC_User::getUser(),$lockInfo->owner,$lockInfo->timeout,$lockInfo->scope,$lockInfo->depth,$uri,$lockInfo->created,$lockInfo->token)); + $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*locks`' + .' (`userid`,`owner`,`timeout`,`scope`,`depth`,`uri`,`created`,`token`)' + .' VALUES (?,?,?,?,?,?,?,?)' ); + $result = $query->execute( array( + OC_User::getUser(), + $lockInfo->owner, + $lockInfo->timeout, + $lockInfo->scope, + $lockInfo->depth, + $uri, + $lockInfo->created, + $lockInfo->token) + ); } return true; diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php index 57ce3710db8..360c3066d05 100644 --- a/lib/connector/sabre/node.php +++ b/lib/connector/sabre/node.php @@ -88,7 +88,8 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $this->path = $newPath; - $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertypath` = ? WHERE `userid` = ? AND `propertypath` = ?' ); + $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertypath` = ?' + .' WHERE `userid` = ? AND `propertypath` = ?' ); $query->execute( array( $newPath, OC_User::getUser(), $oldPath )); } @@ -149,7 +150,8 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr // If it was null, we need to delete the property if (is_null($propertyValue)) { if(array_key_exists( $propertyName, $existing )) { - $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*properties` WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); + $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*properties`' + .' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); $query->execute( array( OC_User::getUser(), $this->path, $propertyName )); } } @@ -160,10 +162,12 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr $this->touch($propertyValue); } else { if(!array_key_exists( $propertyName, $existing )) { - $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*properties` (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)' ); + $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*properties`' + .' (`userid`,`propertypath`,`propertyname`,`propertyvalue`) VALUES(?,?,?,?)' ); $query->execute( array( OC_User::getUser(), $this->path, $propertyName,$propertyValue )); } else { - $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ? WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); + $query = OC_DB::prepare( 'UPDATE `*PREFIX*properties` SET `propertyvalue` = ?' + .' WHERE `userid` = ? AND `propertypath` = ? AND `propertyname` = ?' ); $query->execute( array( $propertyValue,OC_User::getUser(), $this->path, $propertyName )); } } diff --git a/lib/db.php b/lib/db.php index 8bb2930e03b..28923e48f0c 100644 --- a/lib/db.php +++ b/lib/db.php @@ -475,7 +475,8 @@ class OC_DB { * http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm */ if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't - $content = str_replace( '0000-00-00 00:00:00', 'CURRENT_TIMESTAMP', $content ); + $content = str_replace( '0000-00-00 00:00:00', + 'CURRENT_TIMESTAMP', $content ); } file_put_contents( $file2, $content ); @@ -500,7 +501,8 @@ class OC_DB { // Die in case something went wrong if( $ret instanceof MDB2_Error ) { - OC_Template::printErrorPage( self::$MDB2->getDebugOutput().' '.$ret->getMessage() . ': ' . $ret->getUserInfo() ); + OC_Template::printErrorPage( self::$MDB2->getDebugOutput().' '.$ret->getMessage() . ': ' + . $ret->getUserInfo() ); } return true; @@ -542,7 +544,8 @@ class OC_DB { * http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions037.htm */ if( $CONFIG_DBTYPE == 'pgsql' ) { //mysql support it too but sqlite doesn't - $content = str_replace( '0000-00-00 00:00:00', 'CURRENT_TIMESTAMP', $content ); + $content = str_replace( '0000-00-00 00:00:00', + 'CURRENT_TIMESTAMP', $content ); } file_put_contents( $file2, $content ); $op = self::$schema->updateDatabase($file2, $previousSchema, array(), false); @@ -680,7 +683,8 @@ class OC_DB { $query = str_ireplace( 'UNIX_TIMESTAMP()', 'strftime(\'%s\',\'now\')', $query ); }elseif( $type == 'pgsql' ) { $query = str_replace( '`', '"', $query ); - $query = str_ireplace( 'UNIX_TIMESTAMP()', 'cast(extract(epoch from current_timestamp) as integer)', $query ); + $query = str_ireplace( 'UNIX_TIMESTAMP()', 'cast(extract(epoch from current_timestamp) as integer)', + $query ); }elseif( $type == 'oci' ) { $query = str_replace( '`', '"', $query ); $query = str_ireplace( 'NOW()', 'CURRENT_TIMESTAMP', $query ); diff --git a/lib/eventsource.php b/lib/eventsource.php index 1b8033943a1..63f19792529 100644 --- a/lib/eventsource.php +++ b/lib/eventsource.php @@ -62,7 +62,8 @@ class OC_EventSource{ $type=null; } if($this->fallback) { - $response=''.PHP_EOL; + $response=''.PHP_EOL; echo $response; }else{ if($type) { diff --git a/lib/filechunking.php b/lib/filechunking.php index d63a0d72c83..e6d69273a44 100644 --- a/lib/filechunking.php +++ b/lib/filechunking.php @@ -97,7 +97,8 @@ class OC_FileChunking { $absolutePath = \OC\Files\Filesystem::normalizePath(\OC\Files\Filesystem::getView()->getAbsolutePath($path)); $data = ''; // use file_put_contents as method because that best matches what this function does - if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) && \OC\Files\Filesystem::isValidPath($path)) { + if (OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) + && \OC\Files\Filesystem::isValidPath($path)) { $path = \OC\Files\Filesystem::getView()->getRelativePath($absolutePath); $exists = \OC\Files\Filesystem::file_exists($path); $run = true; diff --git a/lib/files.php b/lib/files.php index e3245653f99..b594b78c4b7 100644 --- a/lib/files.php +++ b/lib/files.php @@ -200,7 +200,8 @@ class OC_Files { $errors = array( array( 'error' => $l->t('ZIP download is turned off.'), - 'hint' => $l->t('Files need to be downloaded one by one.') . '
' . $l->t('Back to Files') . '', + 'hint' => $l->t('Files need to be downloaded one by one.') + . '
' . $l->t('Back to Files') . '', ) ); $tmpl->assign('errors', $errors); @@ -225,7 +226,9 @@ class OC_Files { $errors = array( array( 'error' => $l->t('Selected files too large to generate zip file.'), - 'hint' => 'Download the files in smaller chunks, seperately or kindly ask your administrator.
' . $l->t('Back to Files') . '', + 'hint' => 'Download the files in smaller chunks, seperately' + .' or kindly ask your administrator.
' + . $l->t('Back to Files') . '', ) ); $tmpl->assign('errors', $errors); @@ -287,7 +290,9 @@ class OC_Files { file_put_contents(OC::$SERVERROOT . '/.htaccess', $htaccess); return OC_Helper::computerFileSize($size); } else { - OC_Log::write('files', 'Can\'t write upload limit to ' . OC::$SERVERROOT . '/.htaccess. Please check the file permissions', OC_Log::WARN); + OC_Log::write('files', + 'Can\'t write upload limit to ' . OC::$SERVERROOT . '/.htaccess. Please check the file permissions', + OC_Log::WARN); } return false; } diff --git a/lib/files/cache/cache.php b/lib/files/cache/cache.php index 38b35c69def..5feed37ae48 100644 --- a/lib/files/cache/cache.php +++ b/lib/files/cache/cache.php @@ -198,7 +198,8 @@ class Cache { $params[] = $this->numericId; $valuesPlaceholder = array_fill(0, count($queryParts), '?'); - $query = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`(' . implode(', ', $queryParts) . ') VALUES(' . implode(', ', $valuesPlaceholder) . ')'); + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*filecache`(' . implode(', ', $queryParts) . ')' + .' VALUES(' . implode(', ', $valuesPlaceholder) . ')'); $query->execute($params); return (int)\OC_DB::insertid('*PREFIX*filecache'); @@ -215,7 +216,8 @@ class Cache { list($queryParts, $params) = $this->buildParts($data); $params[] = $id; - $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=? WHERE fileid = ?'); + $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET ' . implode(' = ?, ', $queryParts) . '=?' + .' WHERE fileid = ?'); $query->execute($params); } @@ -332,7 +334,8 @@ class Cache { $query->execute(array($targetPath, md5($targetPath), $child['fileid'])); } - $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `parent` =? WHERE `fileid` = ?'); + $query = \OC_DB::prepare('UPDATE `*PREFIX*filecache` SET `path` = ?, `path_hash` = ?, `parent` =?' + .' WHERE `fileid` = ?'); $query->execute(array($target, md5($target), $newParentId, $sourceId)); } @@ -492,7 +495,8 @@ class Cache { * @return string|bool the path of the folder or false when no folder matched */ public function getIncomplete() { - $query = \OC_DB::prepare('SELECT `path` FROM `*PREFIX*filecache` WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1'); + $query = \OC_DB::prepare('SELECT `path` FROM `*PREFIX*filecache`' + .' WHERE `storage` = ? AND `size` = -1 ORDER BY `fileid` DESC LIMIT 1'); $query->execute(array($this->numericId)); if ($row = $query->fetchRow()) { return $row['path']; diff --git a/lib/files/cache/permissions.php b/lib/files/cache/permissions.php index e24c05b10a3..e1735831b94 100644 --- a/lib/files/cache/permissions.php +++ b/lib/files/cache/permissions.php @@ -51,9 +51,11 @@ class Permissions { */ public function set($fileId, $user, $permissions) { if (self::get($fileId, $user) !== -1) { - $query = \OC_DB::prepare('UPDATE `*PREFIX*permissions` SET `permissions` = ? WHERE `user` = ? AND `fileid` = ?'); + $query = \OC_DB::prepare('UPDATE `*PREFIX*permissions` SET `permissions` = ?' + .' WHERE `user` = ? AND `fileid` = ?'); } else { - $query = \OC_DB::prepare('INSERT INTO `*PREFIX*permissions`(`permissions`, `user`, `fileid`) VALUES(?, ?,? )'); + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*permissions`(`permissions`, `user`, `fileid`)' + .' VALUES(?, ?,? )'); } $query->execute(array($permissions, $user, $fileId)); } @@ -73,7 +75,8 @@ class Permissions { $params[] = $user; $inPart = implode(', ', array_fill(0, count($fileIds), '?')); - $query = \OC_DB::prepare('SELECT `fileid`, `permissions` FROM `*PREFIX*permissions` WHERE `fileid` IN (' . $inPart . ') AND `user` = ?'); + $query = \OC_DB::prepare('SELECT `fileid`, `permissions` FROM `*PREFIX*permissions`' + .' WHERE `fileid` IN (' . $inPart . ') AND `user` = ?'); $result = $query->execute($params); $filePermissions = array(); while ($row = $result->fetchRow()) { diff --git a/lib/files/cache/upgrade.php b/lib/files/cache/upgrade.php index eb8c7297c3e..1fe4c584686 100644 --- a/lib/files/cache/upgrade.php +++ b/lib/files/cache/upgrade.php @@ -69,7 +69,8 @@ class Upgrade { ( `fileid`, `storage`, `path`, `path_hash`, `parent`, `name`, `mimetype`, `mimepart`, `size`, `mtime`, `encrypted` ) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'); - $insertQuery->execute(array($data['id'], $data['storage'], $data['path'], $data['path_hash'], $data['parent'], $data['name'], + $insertQuery->execute(array($data['id'], $data['storage'], + $data['path'], $data['path_hash'], $data['parent'], $data['name'], $data['mimetype'], $data['mimepart'], $data['size'], $data['mtime'], $data['encrypted'])); } } diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index a0c3c4b9b75..f4530868077 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -135,7 +135,9 @@ class Filesystem { /** * get the mountpoint of the storage object for a path - ( note: because a storage is not always mounted inside the fakeroot, the returned mountpoint is relative to the absolute root of the filesystem and doesn't take the chroot into account + * ( note: because a storage is not always mounted inside the fakeroot, the + * returned mountpoint is relative to the absolute root of the filesystem + * and doesn't take the chroot into account ) * * @param string $path * @return string @@ -318,7 +320,8 @@ class Filesystem { /** * return the path to a local version of the file - * we need this because we can't know if a file is stored local or not from outside the filestorage and for some purposes a local file is needed + * we need this because we can't know if a file is stored local or not from + * outside the filestorage and for some purposes a local file is needed * * @param string $path * @return string diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index b4c33c69f6b..4cdabf1c8a6 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -113,7 +113,8 @@ abstract class Common implements \OC\Files\Storage\Storage { public function deleteAll( $directory, $empty = false ) { $directory = trim($directory, '/'); - if ( !$this->file_exists( \OCP\USER::getUser() . '/' . $directory ) || !$this->is_dir( \OCP\USER::getUser() . '/' . $directory ) ) { + if ( !$this->file_exists( \OCP\USER::getUser() . '/' . $directory ) + || !$this->is_dir( \OCP\USER::getUser() . '/' . $directory ) ) { return false; } elseif( !$this->isReadable( \OCP\USER::getUser() . '/' . $directory ) ) { return false; diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php index 4099f860d7b..da6597c8057 100644 --- a/lib/files/storage/local.php +++ b/lib/files/storage/local.php @@ -205,7 +205,9 @@ class Local extends \OC\Files\Storage\Common{ return (float)exec('stat -c %s ' . escapeshellarg($fullPath)); } } else { - \OC_Log::write('core', 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, \OC_Log::ERROR); + \OC_Log::write('core', + 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, + \OC_Log::ERROR); } return 0; diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index f2af5bfe357..e707f71d71c 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -248,7 +248,9 @@ class MappedLocal extends \OC\Files\Storage\Common{ return (float)exec('stat -c %s ' . escapeshellarg($fullPath)); } } else { - \OC_Log::write('core', 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, \OC_Log::ERROR); + \OC_Log::write('core', + 'Unable to determine file size of "'.$fullPath.'". Unknown OS: '.$name, + \OC_Log::ERROR); } return 0; diff --git a/lib/files/view.php b/lib/files/view.php index 1a234228eab..9ac08c98082 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -92,7 +92,9 @@ class View { /** * get the mountpoint of the storage object for a path - ( note: because a storage is not always mounted inside the fakeroot, the returned mountpoint is relative to the absolute root of the filesystem and doesn't take the chroot into account + * ( note: because a storage is not always mounted inside the fakeroot, the + * returned mountpoint is relative to the absolute root of the filesystem + * and doesn't take the chroot into account ) * * @param string $path * @return string @@ -113,7 +115,8 @@ class View { /** * return the path to a local version of the file - * we need this because we can't know if a file is stored local or not from outside the filestorage and for some purposes a local file is needed + * we need this because we can't know if a file is stored local or not from + * outside the filestorage and for some purposes a local file is needed * * @param string $path * @return string @@ -252,7 +255,8 @@ class View { public function file_put_contents($path, $data) { if (is_resource($data)) { //not having to deal with streams in file_put_contents makes life easier $absolutePath = Filesystem::normalizePath($this->getAbsolutePath($path)); - if (\OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) && Filesystem::isValidPath($path)) { + if (\OC_FileProxy::runPreProxies('file_put_contents', $absolutePath, $data) + && Filesystem::isValidPath($path)) { $path = $this->getRelativePath($absolutePath); $exists = $this->file_exists($path); $run = true; @@ -324,7 +328,8 @@ class View { $postFix2 = (substr($path2, -1, 1) === '/') ? '/' : ''; $absolutePath1 = Filesystem::normalizePath($this->getAbsolutePath($path1)); $absolutePath2 = Filesystem::normalizePath($this->getAbsolutePath($path2)); - if (\OC_FileProxy::runPreProxies('rename', $absolutePath1, $absolutePath2) and Filesystem::isValidPath($path2)) { + if (\OC_FileProxy::runPreProxies('rename', $absolutePath1, $absolutePath2) + and Filesystem::isValidPath($path2)) { $path1 = $this->getRelativePath($absolutePath1); $path2 = $this->getRelativePath($absolutePath2); @@ -776,7 +781,8 @@ class View { $rootEntry = $subCache->get(''); if ($rootEntry) { $relativePath = trim(substr($mountPoint, $dirLength), '/'); - if ($pos = strpos($relativePath, '/')) { //mountpoint inside subfolder add size to the correct folder + if ($pos = strpos($relativePath, '/')) { + //mountpoint inside subfolder add size to the correct folder $entryName = substr($relativePath, 0, $pos); foreach ($files as &$entry) { if ($entry['name'] === $entryName) { diff --git a/lib/filesystem.php b/lib/filesystem.php index e86bea6bff9..34f92b357ca 100644 --- a/lib/filesystem.php +++ b/lib/filesystem.php @@ -34,7 +34,9 @@ class OC_Filesystem { /** * get the mountpoint of the storage object for a path - ( note: because a storage is not always mounted inside the fakeroot, the returned mountpoint is relative to the absolute root of the filesystem and doesn't take the chroot into account + * ( note: because a storage is not always mounted inside the fakeroot, the + * returned mountpoint is relative to the absolute root of the filesystem + * and doesn't take the chroot into account ) * * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem * @param string $path @@ -115,7 +117,8 @@ class OC_Filesystem { /** * return the path to a local version of the file - * we need this because we can't know if a file is stored local or not from outside the filestorage and for some purposes a local file is needed + * we need this because we can't know if a file is stored local or not from + * outside the filestorage and for some purposes a local file is needed * * @deprecated OC_Filesystem is replaced by \OC\Files\Filesystem * @param string $path diff --git a/lib/group.php b/lib/group.php index 5afef769361..6afe1440030 100644 --- a/lib/group.php +++ b/lib/group.php @@ -311,7 +311,12 @@ class OC_Group { $displayNames = array(); foreach ($gids as $gid) { // TODO Need to apply limits to groups as total - $displayNames = array_merge(array_diff(self::displayNamesInGroup($gid, $search, $limit, $offset), $displayNames), $displayNames); + $displayNames = array_merge( + array_diff( + self::displayNamesInGroup($gid, $search, $limit, $offset), + $displayNames + ), + $displayNames); } return $displayNames; } diff --git a/lib/group/database.php b/lib/group/database.php index 1e2328f4c08..8816dd8169c 100644 --- a/lib/group/database.php +++ b/lib/group/database.php @@ -200,7 +200,9 @@ class OC_Group_Database extends OC_Group_Backend { * @return array with user ids */ public function usersInGroup($gid, $search = '', $limit = null, $offset = null) { - $stmt = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*group_user` WHERE `gid` = ? AND `uid` LIKE ?', $limit, $offset); + $stmt = OC_DB::prepare('SELECT `uid` FROM `*PREFIX*group_user` WHERE `gid` = ? AND `uid` LIKE ?', + $limit, + $offset); $result = $stmt->execute(array($gid, $search.'%')); $users = array(); while ($row = $result->fetchRow()) { @@ -220,7 +222,12 @@ class OC_Group_Database extends OC_Group_Backend { public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { $displayNames = ''; - $stmt = OC_DB::prepare('SELECT `*PREFIX*users`.`uid`, `*PREFIX*users`.`displayname` FROM `*PREFIX*users` INNER JOIN `*PREFIX*group_user` ON `*PREFIX*group_user`.`uid` = `*PREFIX*users`.`uid` WHERE `gid` = ? AND `*PREFIX*group_user.uid` LIKE ?', $limit, $offset); + $stmt = OC_DB::prepare('SELECT `*PREFIX*users`.`uid`, `*PREFIX*users`.`displayname`' + .' FROM `*PREFIX*users`' + .' INNER JOIN `*PREFIX*group_user` ON `*PREFIX*group_user`.`uid` = `*PREFIX*users`.`uid`' + .' WHERE `gid` = ? AND `*PREFIX*group_user.uid` LIKE ?', + $limit, + $offset); $result = $stmt->execute(array($gid, $search.'%')); $users = array(); while ($row = $result->fetchRow()) { diff --git a/lib/helper.php b/lib/helper.php index 2713ffed451..0f810ffc0c2 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -132,7 +132,8 @@ class OC_Helper { * Returns a absolute url to the given service. */ public static function linkToRemote( $service, $add_slash = true ) { - return self::makeURLAbsolute(self::linkToRemoteBase($service)) . (($add_slash && $service[strlen($service)-1]!='/')?'/':''); + return self::makeURLAbsolute(self::linkToRemoteBase($service)) + . (($add_slash && $service[strlen($service)-1]!='/')?'/':''); } /** @@ -144,7 +145,8 @@ class OC_Helper { * Returns a absolute url to the given service. */ public static function linkToPublic($service, $add_slash = false) { - return self::linkToAbsolute( '', 'public.php') . '?service=' . $service . (($add_slash && $service[strlen($service)-1]!='/')?'/':''); + return self::linkToAbsolute( '', 'public.php') . '?service=' . $service + . (($add_slash && $service[strlen($service)-1]!='/')?'/':''); } /** @@ -379,7 +381,8 @@ class OC_Helper { $mimeType='application/octet-stream'; } - if($mimeType=='application/octet-stream' and function_exists('finfo_open') and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)) { + if($mimeType=='application/octet-stream' and function_exists('finfo_open') + and function_exists('finfo_file') and $finfo=finfo_open(FILEINFO_MIME)) { $info = @strtolower(finfo_file($finfo, $path)); if($info) { $mimeType=substr($info, 0, strpos($info, ';')); @@ -444,7 +447,8 @@ class OC_Helper { } /** - * returns "checked"-attribute if request contains selected radio element OR if radio element is the default one -- maybe? + * returns "checked"-attribute if request contains selected radio element + * OR if radio element is the default one -- maybe? * @param string $s Name of radio-button element name * @param string $v Value of current radio-button element * @param string $d Value of default radio-button element diff --git a/lib/hook.php b/lib/hook.php index 1f450e7dcac..554381251d6 100644 --- a/lib/hook.php +++ b/lib/hook.php @@ -71,7 +71,9 @@ class OC_Hook{ try { call_user_func( array( $i["class"], $i["name"] ), $params ); } catch (Exception $e){ - OC_Log::write('hook', 'error while running hook (' . $i["class"] . '::' . $i["name"] . '): '.$e->getMessage(), OC_Log::ERROR); + OC_Log::write('hook', + 'error while running hook (' . $i["class"] . '::' . $i["name"] . '): '.$e->getMessage(), + OC_Log::ERROR); } } diff --git a/lib/image.php b/lib/image.php index eaa35350bcb..7b0cbefd657 100644 --- a/lib/image.php +++ b/lib/image.php @@ -169,7 +169,9 @@ class OC_Image { if (!file_exists(dirname($filepath))) mkdir(dirname($filepath), 0777, true); if(!is_writable(dirname($filepath))) { - OC_Log::write('core', __METHOD__.'(): Directory \''.dirname($filepath).'\' is not writable.', OC_Log::ERROR); + OC_Log::write('core', + __METHOD__.'(): Directory \''.dirname($filepath).'\' is not writable.', + OC_Log::ERROR); return false; } elseif(is_writable(dirname($filepath)) && file_exists($filepath) && !is_writable($filepath)) { OC_Log::write('core', __METHOD__.'(): File \''.$filepath.'\' is not writable.', OC_Log::ERROR); @@ -394,35 +396,45 @@ class OC_Image { if (imagetypes() & IMG_GIF) { $this->resource = imagecreatefromgif($imagepath); } else { - OC_Log::write('core', 'OC_Image->loadFromFile, GIF images not supported: '.$imagepath, OC_Log::DEBUG); + OC_Log::write('core', + 'OC_Image->loadFromFile, GIF images not supported: '.$imagepath, + OC_Log::DEBUG); } break; case IMAGETYPE_JPEG: if (imagetypes() & IMG_JPG) { $this->resource = imagecreatefromjpeg($imagepath); } else { - OC_Log::write('core', 'OC_Image->loadFromFile, JPG images not supported: '.$imagepath, OC_Log::DEBUG); + OC_Log::write('core', + 'OC_Image->loadFromFile, JPG images not supported: '.$imagepath, + OC_Log::DEBUG); } break; case IMAGETYPE_PNG: if (imagetypes() & IMG_PNG) { $this->resource = imagecreatefrompng($imagepath); } else { - OC_Log::write('core', 'OC_Image->loadFromFile, PNG images not supported: '.$imagepath, OC_Log::DEBUG); + OC_Log::write('core', + 'OC_Image->loadFromFile, PNG images not supported: '.$imagepath, + OC_Log::DEBUG); } break; case IMAGETYPE_XBM: if (imagetypes() & IMG_XPM) { $this->resource = imagecreatefromxbm($imagepath); } else { - OC_Log::write('core', 'OC_Image->loadFromFile, XBM/XPM images not supported: '.$imagepath, OC_Log::DEBUG); + OC_Log::write('core', + 'OC_Image->loadFromFile, XBM/XPM images not supported: '.$imagepath, + OC_Log::DEBUG); } break; case IMAGETYPE_WBMP: if (imagetypes() & IMG_WBMP) { $this->resource = imagecreatefromwbmp($imagepath); } else { - OC_Log::write('core', 'OC_Image->loadFromFile, WBMP images not supported: '.$imagepath, OC_Log::DEBUG); + OC_Log::write('core', + 'OC_Image->loadFromFile, WBMP images not supported: '.$imagepath, + OC_Log::DEBUG); } break; case IMAGETYPE_BMP: @@ -633,7 +645,9 @@ class OC_Image { $color[1] = $palette[ $color[1] + 1 ]; break; default: - trigger_error('imagecreatefrombmp: ' . $filename . ' has ' . $meta['bits'] . ' bits and this is not supported!', E_USER_WARNING); + trigger_error('imagecreatefrombmp: ' + . $filename . ' has ' . $meta['bits'] . ' bits and this is not supported!', + E_USER_WARNING); return false; } imagesetpixel($im, $x, $y, $color[1]); @@ -739,7 +753,9 @@ class OC_Image { } imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height); if ($process == false) { - OC_Log::write('core', 'OC_Image->centerCrop. Error resampling process image '.$width.'x'.$height, OC_Log::ERROR); + OC_Log::write('core', + 'OC_Image->centerCrop. Error resampling process image '.$width.'x'.$height, + OC_Log::ERROR); imagedestroy($process); return false; } diff --git a/lib/installer.php b/lib/installer.php index aa192880af0..251d115b76c 100644 --- a/lib/installer.php +++ b/lib/installer.php @@ -136,21 +136,29 @@ class OC_Installer{ // check if the app is compatible with this version of ownCloud $version=OC_Util::getVersion(); if(!isset($info['require']) or ($version[0]>$info['require'])) { - OC_Log::write('core', 'App can\'t be installed because it is not compatible with this version of ownCloud', OC_Log::ERROR); + OC_Log::write('core', + 'App can\'t be installed because it is not compatible with this version of ownCloud', + OC_Log::ERROR); OC_Helper::rmdirr($extractDir); return false; } // check if shipped tag is set which is only allowed for apps that are shipped with ownCloud if(isset($info['shipped']) and ($info['shipped']=='true')) { - OC_Log::write('core', 'App can\'t be installed because it contains the true tag which is not allowed for non shipped apps', OC_Log::ERROR); + OC_Log::write('core', + 'App can\'t be installed because it contains the true' + .' tag which is not allowed for non shipped apps', + OC_Log::ERROR); OC_Helper::rmdirr($extractDir); return false; } // check if the ocs version is the same as the version in info.xml/version if(!isset($info['version']) or ($info['version']<>$data['appdata']['version'])) { - OC_Log::write('core', 'App can\'t be installed because the version in info.xml/version is not the same as the version reported from the app store', OC_Log::ERROR); + OC_Log::write('core', + 'App can\'t be installed because the version in info.xml/version is not the same' + .' as the version reported from the app store', + OC_Log::ERROR); OC_Helper::rmdirr($extractDir); return false; } @@ -251,7 +259,8 @@ class OC_Installer{ * -# including appinfo/upgrade.php * -# setting the installed version * - * upgrade.php can determine the current installed version of the app using "OC_Appconfig::getValue($appid, 'installed_version')" + * upgrade.php can determine the current installed version of the app using + * "OC_Appconfig::getValue($appid, 'installed_version')" */ public static function updateApp( $app ) { $ocsid=OC_Appconfig::getValue( $app, 'ocsid'); @@ -437,7 +446,9 @@ class OC_Installer{ // check if grep is installed $grep = exec('which grep'); if($grep=='') { - OC_Log::write('core', 'grep not installed. So checking the code of the app "'.$appname.'" was not possible', OC_Log::ERROR); + OC_Log::write('core', + 'grep not installed. So checking the code of the app "'.$appname.'" was not possible', + OC_Log::ERROR); return true; } @@ -447,7 +458,9 @@ class OC_Installer{ $result = exec($cmd); // bad pattern found if($result<>'') { - OC_Log::write('core', 'App "'.$appname.'" is using a not allowed call "'.$bl.'". Installation refused.', OC_Log::ERROR); + OC_Log::write('core', + 'App "'.$appname.'" is using a not allowed call "'.$bl.'". Installation refused.', + OC_Log::ERROR); return false; } } diff --git a/lib/log.php b/lib/log.php index e869282e88c..3f3334801e5 100644 --- a/lib/log.php +++ b/lib/log.php @@ -53,7 +53,9 @@ class OC_Log { // Uncaught exception handler public static function onException($exception) { - self::write('PHP', $exception->getMessage() . ' at ' . $exception->getFile() . '#' . $exception->getLine(), self::FATAL); + self::write('PHP', + $exception->getMessage() . ' at ' . $exception->getFile() . '#' . $exception->getLine(), + self::FATAL); } //Recoverable errors handler diff --git a/lib/log/owncloud.php b/lib/log/owncloud.php index e53dd5fefcd..20df52c27bb 100644 --- a/lib/log/owncloud.php +++ b/lib/log/owncloud.php @@ -81,7 +81,8 @@ class OC_Log_Owncloud { $ch = fgetc($handle); if ($ch == "\n" || $pos == 0) { if ($line != '') { - // Add the first character if at the start of the file, because it doesn't hit the else in the loop + // Add the first character if at the start of the file, + // because it doesn't hit the else in the loop if ($pos == 0) { $line = $ch.$line; } diff --git a/lib/mail.php b/lib/mail.php index 1bb202ac977..22194045a76 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -32,7 +32,8 @@ class OC_Mail { * @param string $bcc * @throws Exception */ - public static function send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='', $bcc='') { + public static function send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, + $html=0, $altbody='', $ccaddress='', $ccname='', $bcc='') { $SMTPMODE = OC_Config::getValue( 'mail_smtpmode', 'sendmail' ); $SMTPHOST = OC_Config::getValue( 'mail_smtphost', '127.0.0.1' ); @@ -97,7 +98,9 @@ class OC_Mail { $mailo->Send(); unset($mailo); - OC_Log::write('mail', 'Mail from '.$fromname.' ('.$fromaddress.')'.' to: '.$toname.'('.$toaddress.')'.' subject: '.$subject, OC_Log::DEBUG); + OC_Log::write('mail', + 'Mail from '.$fromname.' ('.$fromaddress.')'.' to: '.$toname.'('.$toaddress.')'.' subject: '.$subject, + OC_Log::DEBUG); } catch (Exception $exception) { OC_Log::write('mail', $exception->getMessage(), OC_Log::ERROR); throw($exception); diff --git a/lib/migrate.php b/lib/migrate.php index 45130be3a1f..a0a329705a3 100644 --- a/lib/migrate.php +++ b/lib/migrate.php @@ -167,7 +167,19 @@ class OC_Migrate{ self::$content = new OC_Migration_Content( self::$zip ); // Creates a zip with the owncloud system files self::$content->addDir( OC::$SERVERROOT . '/', false, '/'); - foreach (array(".git", "3rdparty", "apps", "core", "files", "l10n", "lib", "ocs", "search", "settings", "tests") as $dir) { + foreach (array( + ".git", + "3rdparty", + "apps", + "core", + "files", + "l10n", + "lib", + "ocs", + "search", + "settings", + "tests" + ) as $dir) { self::$content->addDir( OC::$SERVERROOT . '/' . $dir, true, "/"); } break; @@ -245,7 +257,9 @@ class OC_Migrate{ } // Import user app data if(file_exists($extractpath . $json->exporteduser . '/migration.db')) { - if( !$appsimported = self::importAppData( $extractpath . $json->exporteduser . '/migration.db', $json, self::$uid ) ) { + if( !$appsimported = self::importAppData( $extractpath . $json->exporteduser . '/migration.db', + $json, + self::$uid ) ) { return json_encode( array( 'success' => false ) ); } } @@ -553,7 +567,9 @@ class OC_Migrate{ return false; } if ( self::$zip->open( self::$zippath, ZIPARCHIVE::CREATE | ZIPARCHIVE::OVERWRITE ) !== true ) { - OC_Log::write('migration', 'Failed to create the zip with error: '.self::$zip->getStatusString(), OC_Log::ERROR); + OC_Log::write('migration', + 'Failed to create the zip with error: '.self::$zip->getStatusString(), + OC_Log::ERROR); return false; } else { return true; @@ -610,7 +626,9 @@ class OC_Migrate{ if( isset( $info->apps->$id ) ) { // Is the app installed if( !OC_App::isEnabled( $id ) ) { - OC_Log::write( 'migration', 'App: ' . $id . ' is not installed, can\'t import data.', OC_Log::INFO ); + OC_Log::write( 'migration', + 'App: ' . $id . ' is not installed, can\'t import data.', + OC_Log::INFO ); $appsstatus[$id] = 'notsupported'; } else { // Did it succeed on export? @@ -624,7 +642,9 @@ class OC_Migrate{ // Then do the import if( !$appsstatus[$id] = $provider->import( $info->apps->$id, $importinfo ) ) { // Failed to import app - OC_Log::write( 'migration', 'Failed to import app data for user: ' . self::$uid . ' for app: ' . $id, OC_Log::ERROR ); + OC_Log::write( 'migration', + 'Failed to import app data for user: ' . self::$uid . ' for app: ' . $id, + OC_Log::ERROR ); } } else { // Add to failed list diff --git a/lib/migration/content.php b/lib/migration/content.php index d640bea4b9f..400a46a4340 100644 --- a/lib/migration/content.php +++ b/lib/migration/content.php @@ -236,7 +236,9 @@ class OC_Migration_Content{ */ public function finish() { if( !$this->zip->close() ) { - OC_Log::write( 'migration', 'Failed to write the zip file with error: '.$this->zip->getStatusString(), OC_Log::ERROR ); + OC_Log::write( 'migration', + 'Failed to write the zip file with error: '.$this->zip->getStatusString(), + OC_Log::ERROR ); return false; } $this->cleanup(); diff --git a/lib/ocs.php b/lib/ocs.php index e08f0846f81..93e8931ce2e 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -87,7 +87,8 @@ class OC_OCS { } $format = self::readData($method, 'format', 'text', ''); - $txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n"; + $txt='Invalid query, please check the syntax. API specifications are here:' + .' http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n"; $txt.=OC_OCS::getDebugOutput(); echo(OC_OCS::generateXml($format, 'failed', 999, $txt)); @@ -122,7 +123,8 @@ class OC_OCS { * @param int $itemsperpage * @return string xml/json */ - private static function generateXml($format, $status, $statuscode, $message, $data=array(), $tag='', $tagattribute='', $dimension=-1, $itemscount='', $itemsperpage='') { + private static function generateXml($format, $status, $statuscode, + $message, $data=array(), $tag='', $tagattribute='', $dimension=-1, $itemscount='', $itemsperpage='') { if($format=='json') { $json=array(); $json['status']=$status; diff --git a/lib/ocsclient.php b/lib/ocsclient.php index 30163c1e403..bd0302a2a81 100644 --- a/lib/ocsclient.php +++ b/lib/ocsclient.php @@ -32,7 +32,8 @@ class OC_OCSClient{ * @brief Get the url of the OCS AppStore server. * @returns string of the AppStore server * - * This function returns the url of the OCS AppStore server. It´s possible to set it in the config file or it will fallback to the default + * This function returns the url of the OCS AppStore server. It´s possible + * to set it in the config file or it will fallback to the default */ private static function getAppStoreURL() { $url = OC_Config::getValue('appstoreurl', 'http://api.apps.owncloud.com/v1'); @@ -42,7 +43,8 @@ class OC_OCSClient{ /** * @brief Get the url of the OCS KB server. * @returns string of the KB server - * This function returns the url of the OCS knowledge base server. It´s possible to set it in the config file or it will fallback to the default + * This function returns the url of the OCS knowledge base server. It´s + * possible to set it in the config file or it will fallback to the default */ private static function getKBURL() { $url = OC_Config::getValue('knowledgebaseurl', 'http://api.apps.owncloud.com/v1'); @@ -109,7 +111,8 @@ class OC_OCSClient{ $version='&version='.implode('x', \OC_Util::getVersion()); $filterurl='&filter='.urlencode($filter); - $url=OC_OCSClient::getAppStoreURL().'/content/data?categories='.urlencode($categoriesstring).'&sortmode=new&page='.urlencode($page).'&pagesize=100'.$filterurl.$version; + $url=OC_OCSClient::getAppStoreURL().'/content/data?categories='.urlencode($categoriesstring) + .'&sortmode=new&page='.urlencode($page).'&pagesize=100'.$filterurl.$version; $apps=array(); $xml=OC_OCSClient::getOCSresponse($url); diff --git a/lib/preferences.php b/lib/preferences.php index 6270457834d..5f6434bcf9c 100644 --- a/lib/preferences.php +++ b/lib/preferences.php @@ -114,7 +114,8 @@ class OC_Preferences{ */ public static function getValue( $user, $app, $key, $default = null ) { // Try to fetch the value, return default if not exists. - $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); + $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*preferences`' + .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); $result = $query->execute( array( $user, $app, $key )); $row = $result->fetchRow(); @@ -138,16 +139,19 @@ class OC_Preferences{ */ public static function setValue( $user, $app, $key, $value ) { // Check if the key does exist - $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); + $query = OC_DB::prepare( 'SELECT `configvalue` FROM `*PREFIX*preferences`' + .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); $values=$query->execute(array($user, $app, $key))->fetchAll(); $exists=(count($values)>0); if( !$exists ) { - $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*preferences` ( `userid`, `appid`, `configkey`, `configvalue` ) VALUES( ?, ?, ?, ? )' ); + $query = OC_DB::prepare( 'INSERT INTO `*PREFIX*preferences`' + .' ( `userid`, `appid`, `configkey`, `configvalue` ) VALUES( ?, ?, ?, ? )' ); $query->execute( array( $user, $app, $key, $value )); } else{ - $query = OC_DB::prepare( 'UPDATE `*PREFIX*preferences` SET `configvalue` = ? WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); + $query = OC_DB::prepare( 'UPDATE `*PREFIX*preferences` SET `configvalue` = ?' + .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); $query->execute( array( $value, $user, $app, $key )); } return true; @@ -164,7 +168,8 @@ class OC_Preferences{ */ public static function deleteKey( $user, $app, $key ) { // No need for more comments - $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); + $query = OC_DB::prepare( 'DELETE FROM `*PREFIX*preferences`' + .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?' ); $query->execute( array( $user, $app, $key )); return true; diff --git a/lib/public/api.php b/lib/public/api.php index 95d333f2165..d94b68e908a 100644 --- a/lib/public/api.php +++ b/lib/public/api.php @@ -37,7 +37,8 @@ class API { * @param array $defaults * @param array $requirements */ - public static function register($method, $url, $action, $app, $authLevel = OC_API::USER_AUTH, $defaults = array(), $requirements = array()){ + public static function register($method, $url, $action, $app, $authLevel = OC_API::USER_AUTH, + $defaults = array(), $requirements = array()){ \OC_API::register($method, $url, $action, $app, $authLevel, $defaults, $requirements); } diff --git a/lib/public/config.php b/lib/public/config.php index 1f163d52617..8076d640b49 100644 --- a/lib/public/config.php +++ b/lib/public/config.php @@ -35,7 +35,8 @@ namespace OCP; /** - * This class provides functions to read and write configuration data. configuration can be on a system, application or user level + * This class provides functions to read and write configuration data. + * configuration can be on a system, application or user level */ class Config { /** diff --git a/lib/public/files.php b/lib/public/files.php index f6b3e0ee38a..c2945b200e8 100644 --- a/lib/public/files.php +++ b/lib/public/files.php @@ -31,7 +31,8 @@ namespace OCP; /** - * This class provides access to the internal filesystem abstraction layer. Use this class exlusively if you want to access files + * This class provides access to the internal filesystem abstraction layer. Use + * this class exlusively if you want to access files */ class Files { /** diff --git a/lib/public/share.php b/lib/public/share.php index cc2c45e3f31..c0f35333e83 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -37,10 +37,17 @@ class Share { const SHARE_TYPE_REMOTE = 6; /** CRUDS permissions (Create, Read, Update, Delete, Share) using a bitmask - * Construct permissions for share() and setPermissions with Or (|) e.g. Give user read and update permissions: PERMISSION_READ | PERMISSION_UPDATE - * Check if permission is granted with And (&) e.g. Check if delete is granted: if ($permissions & PERMISSION_DELETE) - * Remove permissions with And (&) and Not (~) e.g. Remove the update permission: $permissions &= ~PERMISSION_UPDATE - * Apps are required to handle permissions on their own, this class only stores and manages the permissions of shares + * Construct permissions for share() and setPermissions with Or (|) e.g. + * Give user read and update permissions: PERMISSION_READ | PERMISSION_UPDATE + * + * Check if permission is granted with And (&) e.g. Check if delete is + * granted: if ($permissions & PERMISSION_DELETE) + * + * Remove permissions with And (&) and Not (~) e.g. Remove the update + * permission: $permissions &= ~PERMISSION_UPDATE + * + * Apps are required to handle permissions on their own, this class only + * stores and manages the permissions of shares * @see lib/public/constants.php */ @@ -66,14 +73,21 @@ class Share { public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) { if (self::isEnabled()) { if (!isset(self::$backendTypes[$itemType])) { - self::$backendTypes[$itemType] = array('class' => $class, 'collectionOf' => $collectionOf, 'supportedFileExtensions' => $supportedFileExtensions); + self::$backendTypes[$itemType] = array( + 'class' => $class, + 'collectionOf' => $collectionOf, + 'supportedFileExtensions' => $supportedFileExtensions + ); if(count(self::$backendTypes) === 1) { \OC_Util::addScript('core', 'share'); \OC_Util::addStyle('core', 'share'); } return true; } - \OC_Log::write('OCP\Share', 'Sharing backend '.$class.' not registered, '.self::$backendTypes[$itemType]['class'].' is already registered for '.$itemType, \OC_Log::WARN); + \OC_Log::write('OCP\Share', + 'Sharing backend '.$class.' not registered, '.self::$backendTypes[$itemType]['class'] + .' is already registered for '.$itemType, + \OC_Log::WARN); } return false; } @@ -99,8 +113,10 @@ class Share { * @param int Number of items to return (optional) Returns all by default * @return Return depends on format */ - public static function getItemsSharedWith($itemType, $format = self::FORMAT_NONE, $parameters = null, $limit = -1, $includeCollections = false) { - return self::getItems($itemType, null, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, $parameters, $limit, $includeCollections); + public static function getItemsSharedWith($itemType, $format = self::FORMAT_NONE, + $parameters = null, $limit = -1, $includeCollections = false) { + return self::getItems($itemType, null, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, + $parameters, $limit, $includeCollections); } /** @@ -110,8 +126,10 @@ class Share { * @param int Format (optional) Format type must be defined by the backend * @return Return depends on format */ - public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE, $parameters = null, $includeCollections = false) { - return self::getItems($itemType, $itemTarget, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, $parameters, 1, $includeCollections); + public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE, + $parameters = null, $includeCollections = false) { + return self::getItems($itemType, $itemTarget, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, + $parameters, 1, $includeCollections); } /** @@ -121,8 +139,10 @@ class Share { * @param int Format (optional) Format type must be defined by the backend * @return Return depends on format */ - public static function getItemSharedWithBySource($itemType, $itemSource, $format = self::FORMAT_NONE, $parameters = null, $includeCollections = false) { - return self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, $parameters, 1, $includeCollections, true); + public static function getItemSharedWithBySource($itemType, $itemSource, $format = self::FORMAT_NONE, + $parameters = null, $includeCollections = false) { + return self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups, \OC_User::getUser(), null, $format, + $parameters, 1, $includeCollections, true); } /** @@ -133,7 +153,8 @@ class Share { * @return Item */ public static function getItemSharedWithByLink($itemType, $itemSource, $uidOwner) { - return self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null, $uidOwner, self::FORMAT_NONE, null, 1); + return self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null, $uidOwner, self::FORMAT_NONE, + null, 1); } /** @@ -157,8 +178,10 @@ class Share { * @param int Number of items to return (optional) Returns all by default * @return Return depends on format */ - public static function getItemsShared($itemType, $format = self::FORMAT_NONE, $parameters = null, $limit = -1, $includeCollections = false) { - return self::getItems($itemType, null, null, null, \OC_User::getUser(), $format, $parameters, $limit, $includeCollections); + public static function getItemsShared($itemType, $format = self::FORMAT_NONE, $parameters = null, + $limit = -1, $includeCollections = false) { + return self::getItems($itemType, null, null, null, \OC_User::getUser(), $format, + $parameters, $limit, $includeCollections); } /** @@ -168,8 +191,10 @@ class Share { * @param int Format (optional) Format type must be defined by the backend * @return Return depends on format */ - public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE, $parameters = null, $includeCollections = false) { - return self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), $format, $parameters, -1, $includeCollections); + public static function getItemShared($itemType, $itemSource, $format = self::FORMAT_NONE, + $parameters = null, $includeCollections = false) { + return self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), $format, + $parameters, -1, $includeCollections); } /** @@ -199,14 +224,18 @@ class Share { if ($sharingPolicy == 'groups_only') { $inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith)); if (empty($inGroup)) { - $message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of'; + $message = 'Sharing '.$itemSource.' failed, because the user ' + .$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } } // Check if the item source is already shared with the user, either from the same owner or a different user - if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups, $shareWith, null, self::FORMAT_NONE, null, 1, true, true)) { - // Only allow the same share to occur again if it is the same owner and is not a user share, this use case is for increasing permissions for a specific user + if ($checkExists = self::getItems($itemType, $itemSource, self::$shareTypeUserAndGroups, + $shareWith, null, self::FORMAT_NONE, null, 1, true, true)) { + // Only allow the same share to occur again if it is the same + // owner and is not a user share, this use case is for increasing + // permissions for a specific user if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) { $message = 'Sharing '.$itemSource.' failed, because this item is already shared with '.$shareWith; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); @@ -220,14 +249,18 @@ class Share { throw new \Exception($message); } if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) { - $message = 'Sharing '.$itemSource.' failed, because '.$uidOwner.' is not a member of the group '.$shareWith; + $message = 'Sharing '.$itemSource.' failed, because ' + .$uidOwner.' is not a member of the group '.$shareWith; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } // Check if the item source is already shared with the group, either from the same owner or a different user // The check for each user in the group is done inside the put() function - if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_GROUP, $shareWith, null, self::FORMAT_NONE, null, 1, true, true)) { - // Only allow the same share to occur again if it is the same owner and is not a group share, this use case is for increasing permissions for a specific user + if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_GROUP, $shareWith, + null, self::FORMAT_NONE, null, 1, true, true)) { + // Only allow the same share to occur again if it is the same + // owner and is not a group share, this use case is for increasing + // permissions for a specific user if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) { $message = 'Sharing '.$itemSource.' failed, because this item is already shared with '.$shareWith; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); @@ -242,7 +275,8 @@ class Share { } else if ($shareType === self::SHARE_TYPE_LINK) { if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') == 'yes') { // when updating a link share - if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null, $uidOwner, self::FORMAT_NONE, null, 1)) { + if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_LINK, null, + $uidOwner, self::FORMAT_NONE, null, 1)) { // remember old token $oldToken = $checkExists['token']; //delete the old share @@ -262,7 +296,8 @@ class Share { } else { $token = \OC_Util::generate_random_bytes(self::TOKEN_LENGTH); } - $result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, $token); + $result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, + null, $token); if ($result) { return $token; } else { @@ -341,7 +376,8 @@ class Share { * @return Returns true on success or false on failure */ public static function unshare($itemType, $itemSource, $shareType, $shareWith) { - if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, null, 1)) { + if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), + self::FORMAT_NONE, null, 1)) { // Pass all the vars we have for now, they may be useful \OC_Hook::emit('OCP\Share', 'pre_unshare', array( 'itemType' => $itemType, @@ -389,9 +425,16 @@ class Share { public static function unshareFromSelf($itemType, $itemTarget) { if ($item = self::getItemSharedWith($itemType, $itemTarget)) { if ((int)$item['share_type'] === self::SHARE_TYPE_GROUP) { - // Insert an extra row for the group share and set permission to 0 to prevent it from showing up for the user - $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)'); - $query->execute(array($item['item_type'], $item['item_source'], $item['item_target'], $item['id'], self::$shareTypeGroupUserUnique, \OC_User::getUser(), $item['uid_owner'], 0, $item['stime'], $item['file_source'], $item['file_target'])); + // Insert an extra row for the group share and set permission + // to 0 to prevent it from showing up for the user + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share`' + .' (`item_type`, `item_source`, `item_target`, `parent`, `share_type`,' + .' `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`)' + .' VALUES (?,?,?,?,?,?,?,?,?,?,?)'); + $query->execute(array($item['item_type'], $item['item_source'], $item['item_target'], + $item['id'], self::$shareTypeGroupUserUnique, + \OC_User::getUser(), $item['uid_owner'], 0, $item['stime'], $item['file_source'], + $item['file_target'])); \OC_DB::insertid('*PREFIX*share'); // Delete all reshares by this user of the group share self::delete($item['id'], true, \OC_User::getUser()); @@ -418,13 +461,16 @@ class Share { * @return Returns true on success or false on failure */ public static function setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions) { - if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) { - // Check if this item is a reshare and verify that the permissions granted don't exceed the parent shared item + if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, + \OC_User::getUser(), self::FORMAT_NONE, null, 1, false)) { + // Check if this item is a reshare and verify that the permissions + // granted don't exceed the parent shared item if (isset($item['parent'])) { $query = \OC_DB::prepare('SELECT `permissions` FROM `*PREFIX*share` WHERE `id` = ?', 1); $result = $query->execute(array($item['parent']))->fetchRow(); if (~(int)$result['permissions'] & $permissions) { - $message = 'Setting permissions for '.$itemSource.' failed, because the permissions exceed permissions granted to '.\OC_User::getUser(); + $message = 'Setting permissions for '.$itemSource.' failed,' + .' because the permissions exceed permissions granted to '.\OC_User::getUser(); \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } @@ -441,9 +487,11 @@ class Share { $parents = array($item['id']); while (!empty($parents)) { $parents = "'".implode("','", $parents)."'"; - $query = \OC_DB::prepare('SELECT `id`, `permissions` FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.')'); + $query = \OC_DB::prepare('SELECT `id`, `permissions` FROM `*PREFIX*share`' + .' WHERE `parent` IN ('.$parents.')'); $result = $query->execute(); - // Reset parents array, only go through loop again if items are found that need permissions removed + // Reset parents array, only go through loop again if + // items are found that need permissions removed $parents = array(); while ($item = $result->fetchRow()) { // Check if permissions need to be removed @@ -457,7 +505,8 @@ class Share { // Remove the permissions for all reshares of this item if (!empty($ids)) { $ids = "'".implode("','", $ids)."'"; - $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = `permissions` & ? WHERE `id` IN ('.$ids.')'); + $query = \OC_DB::prepare('UPDATE `*PREFIX*share` SET `permissions` = `permissions` & ?' + .' WHERE `id` IN ('.$ids.')'); $query->execute(array($permissions)); } } @@ -470,7 +519,8 @@ class Share { } public static function setExpirationDate($itemType, $itemSource, $date) { - if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), self::FORMAT_NONE, null, -1, false)) { + if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), + self::FORMAT_NONE, null, -1, false)) { if (!empty($items)) { if ($date == '') { $date = null; @@ -533,7 +583,8 @@ class Share { if (!self::getBackend($itemType) instanceof Share_Backend_Collection || $itemType != 'folder') { unset($collectionTypes[0]); } - // Return array if collections were found or the item type is a collection itself - collections can be inside collections + // Return array if collections were found or the item type is a + // collection itself - collections can be inside collections if (count($collectionTypes) > 0) { return $collectionTypes; } @@ -556,7 +607,9 @@ class Share { * See public functions getItem(s)... for parameter usage * */ - private static function getItems($itemType, $item = null, $shareType = null, $shareWith = null, $uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1, $includeCollections = false, $itemShareWithBySource = false) { + private static function getItems($itemType, $item = null, $shareType = null, $shareWith = null, + $uidOwner = null, $format = self::FORMAT_NONE, $parameters = null, $limit = -1, + $includeCollections = false, $itemShareWithBySource = false) { if (!self::isEnabled()) { if ($limit == 1 || (isset($uidOwner) && isset($item))) { return false; @@ -565,7 +618,8 @@ class Share { } } $backend = self::getBackend($itemType); - // Get filesystem root to add it to the file target and remove from the file source, match file_source with the file cache + // Get filesystem root to add it to the file target and remove from the + // file source, match file_source with the file cache if ($itemType == 'file' || $itemType == 'folder') { $root = \OC\Files\Filesystem::getRoot(); $where = 'INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid`'; @@ -668,7 +722,8 @@ class Share { } if ($limit != -1 && !$includeCollections) { if ($shareType == self::$shareTypeUserAndGroups) { - // Make sure the unique user target is returned if it exists, unique targets should follow the group share in the database + // Make sure the unique user target is returned if it exists, + // unique targets should follow the group share in the database // If the limit is not 1, the filtering can be done later $where .= ' ORDER BY `*PREFIX*share`.`id` DESC'; } @@ -684,16 +739,20 @@ class Share { // TODO Optimize selects if ($format == self::FORMAT_STATUSES) { if ($itemType == 'file' || $itemType == 'folder') { - $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `file_source`, `path`, `expiration`'; + $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' + .' `share_type`, `file_source`, `path`, `expiration`'; } else { $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `expiration`'; } } else { if (isset($uidOwner)) { if ($itemType == 'file' || $itemType == 'folder') { - $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`, `expiration`, `token`'; + $select = '`*PREFIX*share`.`id`, `item_type`, `*PREFIX*share`.`parent`,' + .' `share_type`, `share_with`, `file_source`, `path`, `permissions`, `stime`,' + .' `expiration`, `token`'; } else { - $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`, `stime`, `file_source`, `expiration`, `token`'; + $select = '`id`, `item_type`, `item_source`, `parent`, `share_type`, `share_with`, `permissions`,' + .' `stime`, `file_source`, `expiration`, `token`'; } } else { if ($fileDependent) { @@ -706,7 +765,9 @@ class Share { .'`permissions`, `expiration`, `storage`, `*PREFIX*filecache`.`parent` as `file_parent`, ' .'`name`, `mtime`, `mimetype`, `mimepart`, `size`, `encrypted`, `etag`'; } else { - $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`'; + $select = '`*PREFIX*share`.`id`, `item_type`, `item_source`, `item_target`, + `*PREFIX*share`.`parent`, `share_type`, `share_with`, `uid_owner`, + `file_source`, `path`, `file_target`, `permissions`, `stime`, `expiration`, `token`'; } } else { $select = '*'; @@ -717,7 +778,9 @@ class Share { $query = \OC_DB::prepare('SELECT '.$select.' FROM `*PREFIX*share` '.$where, $queryLimit); $result = $query->execute($queryArgs); if (\OC_DB::isError($result)) { - \OC_Log::write('OCP\Share', \OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=' . $where, \OC_Log::ERROR); + \OC_Log::write('OCP\Share', + \OC_DB::getErrorMessage($result) . ', select=' . $select . ' where=' . $where, + \OC_Log::ERROR); } $items = array(); $targets = array(); @@ -735,7 +798,8 @@ class Share { } else if (!isset($uidOwner)) { // Check if the same target already exists if (isset($targets[$row[$column]])) { - // Check if the same owner shared with the user twice through a group and user share - this is allowed + // Check if the same owner shared with the user twice + // through a group and user share - this is allowed $id = $targets[$row[$column]]; if ($items[$id]['uid_owner'] == $row['uid_owner']) { // Switch to group share type to ensure resharing conditions aren't bypassed @@ -743,8 +807,10 @@ class Share { $items[$id]['share_type'] = self::SHARE_TYPE_GROUP; $items[$id]['share_with'] = $row['share_with']; } - // Switch ids if sharing permission is granted on only one share to ensure correct parent is used if resharing - if (~(int)$items[$id]['permissions'] & PERMISSION_SHARE && (int)$row['permissions'] & PERMISSION_SHARE) { + // Switch ids if sharing permission is granted on only + // one share to ensure correct parent is used if resharing + if (~(int)$items[$id]['permissions'] & PERMISSION_SHARE + && (int)$row['permissions'] & PERMISSION_SHARE) { $items[$row['id']] = $items[$id]; $switchedItems[$id] = $row['id']; unset($items[$id]); @@ -798,7 +864,8 @@ class Share { } // Check if this is a collection of the requested item type if ($includeCollections && $collectionTypes && in_array($row['item_type'], $collectionTypes)) { - if (($collectionBackend = self::getBackend($row['item_type'])) && $collectionBackend instanceof Share_Backend_Collection) { + if (($collectionBackend = self::getBackend($row['item_type'])) + && $collectionBackend instanceof Share_Backend_Collection) { // Collections can be inside collections, check if the item is a collection if (isset($item) && $row['item_type'] == $itemType && $row[$column] == $item) { $collectionItems[] = $row; @@ -825,7 +892,8 @@ class Share { $meta = \OC\Files\Filesystem::getFileInfo($child['file_path']); $childItem['file_source'] = $meta['fileid']; } - $childItem['file_target'] = \OC\Files\Filesystem::normalizePath($child['file_path']); + $childItem['file_target'] = + \OC\Files\Filesystem::normalizePath($child['file_path']); } if (isset($item)) { if ($childItem[$column] == $item) { @@ -898,7 +966,8 @@ class Share { * @param bool|array Parent folder target (optional) * @return bool Returns true on success or false on failure */ - private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, $parentFolder = null, $token = null) { + private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, + $permissions, $parentFolder = null, $token = null) { $backend = self::getBackend($itemType); // Check if this is a reshare if ($checkReshare = self::getItemSharedWithBySource($itemType, $itemSource, self::FORMAT_NONE, null, true)) { @@ -911,7 +980,8 @@ class Share { // Check if share permissions is granted if ((int)$checkReshare['permissions'] & PERMISSION_SHARE) { if (~(int)$checkReshare['permissions'] & $permissions) { - $message = 'Sharing '.$itemSource.' failed, because the permissions exceed permissions granted to '.$uidOwner; + $message = 'Sharing '.$itemSource + .' failed, because the permissions exceed permissions granted to '.$uidOwner; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } else { @@ -933,7 +1003,8 @@ class Share { $suggestedItemTarget = null; $suggestedFileTarget = null; if (!$backend->isValidSource($itemSource, $uidOwner)) { - $message = 'Sharing '.$itemSource.' failed, because the sharing backend for '.$itemType.' could not find its source'; + $message = 'Sharing '.$itemSource.' failed, because the sharing backend for ' + .$itemType.' could not find its source'; \OC_Log::write('OCP\Share', $message, \OC_Log::ERROR); throw new \Exception($message); } @@ -956,14 +1027,18 @@ class Share { $fileSource = null; } } - $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`, `token`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)'); + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`,' + .' `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`,' + .' `file_target`, `token`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)'); // Share with a group if ($shareType == self::SHARE_TYPE_GROUP) { - $groupItemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith['group'], $uidOwner, $suggestedItemTarget); + $groupItemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith['group'], + $uidOwner, $suggestedItemTarget); if (isset($fileSource)) { if ($parentFolder) { if ($parentFolder === true) { - $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner, $suggestedFileTarget); + $groupFileTarget = self::generateTarget('file', $filePath, $shareType, + $shareWith['group'], $uidOwner, $suggestedFileTarget); // Set group default file target for future use $parentFolders[0]['folder'] = $groupFileTarget; } else { @@ -972,21 +1047,25 @@ class Share { $parent = $parentFolder[0]['id']; } } else { - $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], $uidOwner, $suggestedFileTarget); + $groupFileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith['group'], + $uidOwner, $suggestedFileTarget); } } else { $groupFileTarget = null; } - $query->execute(array($itemType, $itemSource, $groupItemTarget, $parent, $shareType, $shareWith['group'], $uidOwner, $permissions, time(), $fileSource, $groupFileTarget, $token)); + $query->execute(array($itemType, $itemSource, $groupItemTarget, $parent, $shareType, + $shareWith['group'], $uidOwner, $permissions, time(), $fileSource, $groupFileTarget, $token)); // Save this id, any extra rows for this group share will need to reference it $parent = \OC_DB::insertid('*PREFIX*share'); // Loop through all users of this group in case we need to add an extra row foreach ($shareWith['users'] as $uid) { - $itemTarget = self::generateTarget($itemType, $itemSource, self::SHARE_TYPE_USER, $uid, $uidOwner, $suggestedItemTarget, $parent); + $itemTarget = self::generateTarget($itemType, $itemSource, self::SHARE_TYPE_USER, $uid, + $uidOwner, $suggestedItemTarget, $parent); if (isset($fileSource)) { if ($parentFolder) { if ($parentFolder === true) { - $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner, $suggestedFileTarget, $parent); + $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, + $uidOwner, $suggestedFileTarget, $parent); if ($fileTarget != $groupFileTarget) { $parentFolders[$uid]['folder'] = $fileTarget; } @@ -995,7 +1074,8 @@ class Share { $parent = $parentFolder[$uid]['id']; } } else { - $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, $uid, $uidOwner, $suggestedFileTarget, $parent); + $fileTarget = self::generateTarget('file', $filePath, self::SHARE_TYPE_USER, + $uid, $uidOwner, $suggestedFileTarget, $parent); } } else { $fileTarget = null; @@ -1016,7 +1096,9 @@ class Share { )); // Insert an extra row for the group share if the item or file target is unique for this user if ($itemTarget != $groupItemTarget || (isset($fileSource) && $fileTarget != $groupFileTarget)) { - $query->execute(array($itemType, $itemSource, $itemTarget, $parent, self::$shareTypeGroupUserUnique, $uid, $uidOwner, $permissions, time(), $fileSource, $fileTarget, $token)); + $query->execute(array($itemType, $itemSource, $itemTarget, $parent, + self::$shareTypeGroupUserUnique, $uid, $uidOwner, $permissions, time(), + $fileSource, $fileTarget, $token)); $id = \OC_DB::insertid('*PREFIX*share'); } } @@ -1025,23 +1107,27 @@ class Share { return $parentFolders; } } else { - $itemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedItemTarget); + $itemTarget = self::generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, + $suggestedItemTarget); if (isset($fileSource)) { if ($parentFolder) { if ($parentFolder === true) { - $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner, $suggestedFileTarget); + $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, + $uidOwner, $suggestedFileTarget); $parentFolders['folder'] = $fileTarget; } else { $fileTarget = $parentFolder['folder'].$itemSource; $parent = $parentFolder['id']; } } else { - $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner, $suggestedFileTarget); + $fileTarget = self::generateTarget('file', $filePath, $shareType, $shareWith, $uidOwner, + $suggestedFileTarget); } } else { $fileTarget = null; } - $query->execute(array($itemType, $itemSource, $itemTarget, $parent, $shareType, $shareWith, $uidOwner, $permissions, time(), $fileSource, $fileTarget, $token)); + $query->execute(array($itemType, $itemSource, $itemTarget, $parent, $shareType, $shareWith, $uidOwner, + $permissions, time(), $fileSource, $fileTarget, $token)); $id = \OC_DB::insertid('*PREFIX*share'); \OC_Hook::emit('OCP\Share', 'post_shared', array( 'itemType' => $itemType, @@ -1076,7 +1162,8 @@ class Share { * @param int The id of the parent group share (optional) * @return string Item target */ - private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedTarget = null, $groupParent = null) { + private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, + $suggestedTarget = null, $groupParent = null) { $backend = self::getBackend($itemType); if ($shareType == self::SHARE_TYPE_LINK) { if (isset($suggestedTarget)) { @@ -1143,18 +1230,28 @@ class Share { // Find similar targets to improve backend's chances to generate a unqiue target if ($userAndGroups) { if ($column == 'file_target') { - $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` IN (\'file\', \'folder\') AND `share_type` IN (?,?,?) AND `share_with` IN (\''.implode('\',\'', $userAndGroups).'\')'); - $result = $checkTargets->execute(array(self::SHARE_TYPE_USER, self::SHARE_TYPE_GROUP, self::$shareTypeGroupUserUnique)); + $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share`' + .' WHERE `item_type` IN (\'file\', \'folder\')' + .' AND `share_type` IN (?,?,?)' + .' AND `share_with` IN (\''.implode('\',\'', $userAndGroups).'\')'); + $result = $checkTargets->execute(array(self::SHARE_TYPE_USER, self::SHARE_TYPE_GROUP, + self::$shareTypeGroupUserUnique)); } else { - $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` = ? AND `share_type` IN (?,?,?) AND `share_with` IN (\''.implode('\',\'', $userAndGroups).'\')'); - $result = $checkTargets->execute(array($itemType, self::SHARE_TYPE_USER, self::SHARE_TYPE_GROUP, self::$shareTypeGroupUserUnique)); + $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share`' + .' WHERE `item_type` = ? AND `share_type` IN (?,?,?)' + .' AND `share_with` IN (\''.implode('\',\'', $userAndGroups).'\')'); + $result = $checkTargets->execute(array($itemType, self::SHARE_TYPE_USER, + self::SHARE_TYPE_GROUP, self::$shareTypeGroupUserUnique)); } } else { if ($column == 'file_target') { - $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` IN (\'file\', \'folder\') AND `share_type` = ? AND `share_with` = ?'); + $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share`' + .' WHERE `item_type` IN (\'file\', \'folder\')' + .' AND `share_type` = ? AND `share_with` = ?'); $result = $checkTargets->execute(array(self::SHARE_TYPE_GROUP, $shareWith)); } else { - $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share` WHERE `item_type` = ? AND `share_type` = ? AND `share_with` = ?'); + $checkTargets = \OC_DB::prepare('SELECT `'.$column.'` FROM `*PREFIX*share`' + .' WHERE `item_type` = ? AND `share_type` = ? AND `share_with` = ?'); $result = $checkTargets->execute(array($itemType, self::SHARE_TYPE_GROUP, $shareWith)); } } @@ -1182,21 +1279,33 @@ class Share { $parents = array($parent); while (!empty($parents)) { $parents = "'".implode("','", $parents)."'"; - // Check the owner on the first search of reshares, useful for finding and deleting the reshares by a single user of a group share + // Check the owner on the first search of reshares, useful for + // finding and deleting the reshares by a single user of a group share if (count($ids) == 1 && isset($uidOwner)) { - $query = \OC_DB::prepare('SELECT `id`, `uid_owner`, `item_type`, `item_target`, `parent` FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') AND `uid_owner` = ?'); + $query = \OC_DB::prepare('SELECT `id`, `uid_owner`, `item_type`, `item_target`, `parent`' + .' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.') AND `uid_owner` = ?'); $result = $query->execute(array($uidOwner)); } else { - $query = \OC_DB::prepare('SELECT `id`, `item_type`, `item_target`, `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.')'); + $query = \OC_DB::prepare('SELECT `id`, `item_type`, `item_target`, `parent`, `uid_owner`' + .' FROM `*PREFIX*share` WHERE `parent` IN ('.$parents.')'); $result = $query->execute(); } // Reset parents array, only go through loop again if items are found $parents = array(); while ($item = $result->fetchRow()) { - // Search for a duplicate parent share, this occurs when an item is shared to the same user through a group and user or the same item is shared by different users + // Search for a duplicate parent share, this occurs when an + // item is shared to the same user through a group and user or the + // same item is shared by different users $userAndGroups = array_merge(array($item['uid_owner']), \OC_Group::getUserGroups($item['uid_owner'])); - $query = \OC_DB::prepare('SELECT `id`, `permissions` FROM `*PREFIX*share` WHERE `item_type` = ? AND `item_target` = ? AND `share_type` IN (?,?,?) AND `share_with` IN (\''.implode('\',\'', $userAndGroups).'\') AND `uid_owner` != ? AND `id` != ?'); - $duplicateParent = $query->execute(array($item['item_type'], $item['item_target'], self::SHARE_TYPE_USER, self::SHARE_TYPE_GROUP, self::$shareTypeGroupUserUnique, $item['uid_owner'], $item['parent']))->fetchRow(); + $query = \OC_DB::prepare('SELECT `id`, `permissions` FROM `*PREFIX*share`' + .' WHERE `item_type` = ?' + .' AND `item_target` = ?' + .' AND `share_type` IN (?,?,?)' + .' AND `share_with` IN (\''.implode('\',\'', $userAndGroups).'\')' + .' AND `uid_owner` != ? AND `id` != ?'); + $duplicateParent = $query->execute(array($item['item_type'], $item['item_target'], + self::SHARE_TYPE_USER, self::SHARE_TYPE_GROUP, self::$shareTypeGroupUserUnique, + $item['uid_owner'], $item['parent']))->fetchRow(); if ($duplicateParent) { // Change the parent to the other item id if share permission is granted if ($duplicateParent['permissions'] & PERMISSION_SHARE) { @@ -1225,7 +1334,8 @@ class Share { public static function post_deleteUser($arguments) { // Delete any items shared with the deleted user - $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share` WHERE `share_with` = ? AND `share_type` = ? OR `share_type` = ?'); + $query = \OC_DB::prepare('DELETE FROM `*PREFIX*share`' + .' WHERE `share_with` = ? AND `share_type` = ? OR `share_type` = ?'); $result = $query->execute(array($arguments['uid'], self::SHARE_TYPE_USER, self::$shareTypeGroupUserUnique)); // Delete any items the deleted user shared $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*share` WHERE `uid_owner` = ?'); @@ -1239,21 +1349,27 @@ class Share { // Find the group shares and check if the user needs a unique target $query = \OC_DB::prepare('SELECT * FROM `*PREFIX*share` WHERE `share_type` = ? AND `share_with` = ?'); $result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid'])); - $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`, `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`, `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)'); + $query = \OC_DB::prepare('INSERT INTO `*PREFIX*share` (`item_type`, `item_source`,' + .' `item_target`, `parent`, `share_type`, `share_with`, `uid_owner`, `permissions`,' + .' `stime`, `file_source`, `file_target`) VALUES (?,?,?,?,?,?,?,?,?,?,?)'); while ($item = $result->fetchRow()) { if ($item['item_type'] == 'file' || $item['item_type'] == 'file') { $itemTarget = null; } else { - $itemTarget = self::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, $arguments['uid'], $item['uid_owner'], $item['item_target'], $item['id']); + $itemTarget = self::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, + $arguments['uid'], $item['uid_owner'], $item['item_target'], $item['id']); } if (isset($item['file_source'])) { - $fileTarget = self::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, $arguments['uid'], $item['uid_owner'], $item['file_target'], $item['id']); + $fileTarget = self::generateTarget($item['item_type'], $item['item_source'], self::SHARE_TYPE_USER, + $arguments['uid'], $item['uid_owner'], $item['file_target'], $item['id']); } else { $fileTarget = null; } // Insert an extra row for the group share if the item or file target is unique for this user if ($itemTarget != $item['item_target'] || $fileTarget != $item['file_target']) { - $query->execute(array($item['item_type'], $item['item_source'], $itemTarget, $item['id'], self::$shareTypeGroupUserUnique, $arguments['uid'], $item['uid_owner'], $item['permissions'], $item['stime'], $item['file_source'], $fileTarget)); + $query->execute(array($item['item_type'], $item['item_source'], $itemTarget, $item['id'], + self::$shareTypeGroupUserUnique, $arguments['uid'], $item['uid_owner'], $item['permissions'], + $item['stime'], $item['file_source'], $fileTarget)); \OC_DB::insertid('*PREFIX*share'); } } @@ -1261,8 +1377,10 @@ class Share { public static function post_removeFromGroup($arguments) { // TODO Don't call if user deleted? - $query = \OC_DB::prepare('SELECT `id`, `share_type` FROM `*PREFIX*share` WHERE (`share_type` = ? AND `share_with` = ?) OR (`share_type` = ? AND `share_with` = ?)'); - $result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid'], self::$shareTypeGroupUserUnique, $arguments['uid'])); + $query = \OC_DB::prepare('SELECT `id`, `share_type` FROM `*PREFIX*share`' + .' WHERE (`share_type` = ? AND `share_with` = ?) OR (`share_type` = ? AND `share_with` = ?)'); + $result = $query->execute(array(self::SHARE_TYPE_GROUP, $arguments['gid'], self::$shareTypeGroupUserUnique, + $arguments['uid'])); while ($item = $result->fetchRow()) { if ($item['share_type'] == self::SHARE_TYPE_GROUP) { // Delete all reshares by this user of the group share @@ -1319,10 +1437,18 @@ interface Share_Backend { * @param int Format * @return ? * - * The items array is a 3-dimensional array with the item_source as the first key and the share id as the second key to an array with the share info. + * The items array is a 3-dimensional array with the item_source as the + * first key and the share id as the second key to an array with the share + * info. + * * The key/value pairs included in the share info depend on the function originally called: - * If called by getItem(s)Shared: id, item_type, item, item_source, share_type, share_with, permissions, stime, file_source - * If called by getItem(s)SharedWith: id, item_type, item, item_source, item_target, share_type, share_with, permissions, stime, file_source, file_target + * If called by getItem(s)Shared: id, item_type, item, item_source, + * share_type, share_with, permissions, stime, file_source + * + * If called by getItem(s)SharedWith: id, item_type, item, item_source, + * item_target, share_type, share_with, permissions, stime, file_source, + * file_target + * * This function allows the backend to control the output of shared items with custom formats. * It is only called through calls to the public getItem(s)Shared(With) functions. */ diff --git a/lib/public/template.php b/lib/public/template.php index 4cda3650866..ccf19cf052c 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -99,7 +99,8 @@ function html_select_options($options, $selected, $params=array()) { /** - * This class provides the template system for owncloud. You can use it to load specific templates, add data and generate the html code + * This class provides the template system for owncloud. You can use it to load + * specific templates, add data and generate the html code */ class Template extends \OC_Template { diff --git a/lib/public/user.php b/lib/public/user.php index de52055a4c5..86d1d0ccde8 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -31,7 +31,8 @@ namespace OCP; /** - * This class provides access to the user management. You can get information about the currently logged in user and the permissions for example + * This class provides access to the user management. You can get information + * about the currently logged in user and the permissions for example */ class User { /** diff --git a/lib/public/util.php b/lib/public/util.php index 5f6ede4460e..13498b260ef 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -59,9 +59,11 @@ class Util { * @param string $fromname * @param bool $html */ - public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '') { + public static function sendMail( $toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, + $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '') { // call the internal mail class - \OC_MAIL::send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html, $altbody, $ccaddress, $ccname, $bcc); + \OC_MAIL::send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, + $html, $altbody, $ccaddress, $ccname, $bcc); } /** @@ -340,7 +342,8 @@ class Util { /** * @brief Used to sanitize HTML * - * This function is used to sanitize HTML and should be applied on any string or array of strings before displaying it on a web page. + * This function is used to sanitize HTML and should be applied on any + * string or array of strings before displaying it on a web page. * * @param string|array of strings * @return array with sanitized strings or a single sinitized string, depends on the input parameter. diff --git a/lib/setup.php b/lib/setup.php index cfaf7288663..0c049841b2a 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -205,7 +205,8 @@ class OC_Setup { } $oldUser=OC_Config::getValue('dbuser', false); - $query="SELECT user FROM mysql.user WHERE user='$dbuser'"; //this should be enough to check for admin rights in mysql + //this should be enough to check for admin rights in mysql + $query="SELECT user FROM mysql.user WHERE user='$dbuser'"; if(mysql_query($query, $connection)) { //use the admin login data for the new database user @@ -235,7 +236,8 @@ class OC_Setup { } //fill the database if needed - $query="select count(*) from information_schema.tables where table_schema='$dbname' AND table_name = '{$dbtableprefix}users';"; + $query="select count(*) from information_schema.tables' + .' where table_schema='$dbname' AND table_name = '{$dbtableprefix}users';"; $result = mysql_query($query, $connection); if($result) { $row=mysql_fetch_row($result); @@ -257,7 +259,8 @@ class OC_Setup { echo($entry); } $query="GRANT ALL PRIVILEGES ON `$name` . * TO '$user'"; - $result = mysql_query($query, $connection); //this query will fail if there aren't the right permissons, ignore the error + //this query will fail if there aren't the right permissons, ignore the error + $result = mysql_query($query, $connection); } private static function createDBUser($name, $password, $connection) { @@ -407,7 +410,8 @@ class OC_Setup { } } - private static function setupOCIDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $dbtablespace, $username) { + private static function setupOCIDatabase($dbhost, $dbuser, $dbpass, $dbname, $dbtableprefix, $dbtablespace, + $username) { $l = self::getTrans(); $e_host = addslashes($dbhost); $e_dbname = addslashes($dbname); @@ -424,7 +428,8 @@ class OC_Setup { } //check for roles creation rights in oracle - $query="SELECT count(*) FROM user_role_privs, role_sys_privs WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'"; + $query="SELECT count(*) FROM user_role_privs, role_sys_privs' + .' WHERE user_role_privs.granted_role = role_sys_privs.role AND privilege = 'CREATE ROLE'"; $stmt = oci_parse($connection, $query); if (!$stmt) { $entry = $l->t('DB Error: "%s"', array(oci_last_error($connection))) . '
'; @@ -641,8 +646,10 @@ class OC_Setup { header("Location: ".OC::$WEBROOT.'/'); } else { - $error = $l->t('Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken.'); - $hint = $l->t('Please double check the installation guides.', 'http://doc.owncloud.org/server/5.0/admin_manual/installation.html'); + $error = $l->t('Your web server is not yet properly setup to allow files' + .' synchronization because the WebDAV interface seems to be broken.'); + $hint = $l->t('Please double check the installation guides.', + 'http://doc.owncloud.org/server/5.0/admin_manual/installation.html'); $tmpl = new OC_Template('', 'error', 'guest'); $tmpl->assign('errors', array(1 => array('error' => $error, 'hint' => $hint)), false); diff --git a/lib/template.php b/lib/template.php index fb9f7ad62d9..0230d2f9343 100644 --- a/lib/template.php +++ b/lib/template.php @@ -192,7 +192,13 @@ class OC_Template{ // Content Security Policy // If you change the standard policy, please also change it in config.sample.php - $policy = OC_Config::getValue('custom_csp_policy', 'default-src \'self\'; script-src \'self\' \'unsafe-eval\'; style-src \'self\' \'unsafe-inline\'; frame-src *; img-src *; font-src \'self\' data:'); + $policy = OC_Config::getValue('custom_csp_policy', + 'default-src \'self\'; ' + .'script-src \'self\' \'unsafe-eval\'; ' + .'style-src \'self\' \'unsafe-inline\'; ' + .'frame-src *; ' + .'img-src *; ' + .'font-src \'self\' data:'); header('Content-Security-Policy:'.$policy); // Standard header('X-WebKit-CSP:'.$policy); // Older webkit browsers @@ -215,7 +221,8 @@ class OC_Template{ $mode='tablet'; }elseif(stripos($_SERVER['HTTP_USER_AGENT'], 'iphone')>0) { $mode='mobile'; - }elseif((stripos($_SERVER['HTTP_USER_AGENT'], 'N9')>0) and (stripos($_SERVER['HTTP_USER_AGENT'], 'nokia')>0)) { + }elseif((stripos($_SERVER['HTTP_USER_AGENT'], 'N9')>0) + and (stripos($_SERVER['HTTP_USER_AGENT'], 'nokia')>0)) { $mode='mobile'; }else{ $mode='default'; @@ -285,7 +292,8 @@ class OC_Template{ if ($this->checkPathForTemplate(OC::$SERVERROOT."/themes/$theme/$app/templates/", $name, $fext)) { }elseif ($this->checkPathForTemplate(OC::$SERVERROOT."/$app/templates/", $name, $fext)) { }else{ - echo('template not found: template:'.$name.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + echo('template not found: template:'.$name.' formfactor:'.$fext + .' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); die(); } @@ -295,7 +303,8 @@ class OC_Template{ if ($this->checkPathForTemplate(OC::$SERVERROOT."/themes/$theme/core/templates/", $name, $fext)) { } elseif ($this->checkPathForTemplate(OC::$SERVERROOT."/core/templates/", $name, $fext)) { }else{ - echo('template not found: template:'.$name.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + echo('template not found: template:'.$name.' formfactor:'.$fext + .' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); die(); } } diff --git a/lib/templatelayout.php b/lib/templatelayout.php index 345f540af04..25d4033d9ee 100644 --- a/lib/templatelayout.php +++ b/lib/templatelayout.php @@ -134,7 +134,8 @@ class OC_TemplateLayout extends OC_Template { } } if(! $append) { - echo('css file not found: style:'.$style.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + echo('css file not found: style:'.$style.' formfactor:'.$fext + .' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); die(); } } @@ -202,7 +203,8 @@ class OC_TemplateLayout extends OC_Template { } } if(! $append) { - echo('js file not found: script:'.$script.' formfactor:'.$fext.' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); + echo('js file not found: script:'.$script.' formfactor:'.$fext + .' webroot:'.OC::$WEBROOT.' serverroot:'.OC::$SERVERROOT); die(); } } diff --git a/lib/updater.php b/lib/updater.php index d44ac108380..e7d33ac2bb9 100644 --- a/lib/updater.php +++ b/lib/updater.php @@ -30,7 +30,9 @@ class OC_Updater{ */ public static function check() { OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true)); - if(OC_Appconfig::getValue('core', 'installedat', '')=='') OC_Appconfig::setValue('core', 'installedat', microtime(true)); + if(OC_Appconfig::getValue('core', 'installedat', '')=='') { + OC_Appconfig::setValue('core', 'installedat', microtime(true)); + } $updaterurl='http://apps.owncloud.com/updater.php'; $version=OC_Util::getVersion(); @@ -72,7 +74,9 @@ class OC_Updater{ if(OC_Config::getValue('updatechecker', true)==true) { $data=OC_Updater::check(); if(isset($data['version']) and $data['version']<>'') { - $txt=''.$l->t('%s is available. Get more information', array($data['versionstring'], $data['web'])).''; + $txt='' + .$l->t('%s is available. Get more information', + array($data['versionstring'], $data['web'])).''; }else{ $txt=$l->t('up to date'); } diff --git a/lib/user.php b/lib/user.php index 6c74bb73c8c..35b259550f8 100644 --- a/lib/user.php +++ b/lib/user.php @@ -160,7 +160,8 @@ class OC_User { // Check the name for bad characters // Allowed are: "a-z", "A-Z", "0-9" and "_.@-" if( preg_match( '/[^a-zA-Z0-9 _\.@\-]/', $uid )) { - throw new Exception('Only the following characters are allowed in a username: "a-z", "A-Z", "0-9", and "_.@-"'); + throw new Exception('Only the following characters are allowed in a username:' + .' "a-z", "A-Z", "0-9", and "_.@-"'); } // No empty username if(trim($uid) == '') { @@ -588,7 +589,8 @@ class OC_User { * @param string $userid */ public static function enableUser($userid) { - $sql = "DELETE FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; + $sql = "DELETE FROM `*PREFIX*preferences`' + .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; $stmt = OC_DB::prepare($sql); if ( ! OC_DB::isError($stmt) ) { $result = $stmt->execute(array($userid, 'core', 'enabled', 'false')); @@ -606,14 +608,17 @@ class OC_User { * @return bool */ public static function isEnabled($userid) { - $sql = "SELECT `userid` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; + $sql = "SELECT `userid` FROM `*PREFIX*preferences`' + .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ? AND `configvalue` = ?"; $stmt = OC_DB::prepare($sql); if ( ! OC_DB::isError($stmt) ) { $result = $stmt->execute(array($userid, 'core', 'enabled', 'false')); if ( ! OC_DB::isError($result) ) { return $result->numRows() ? false : true; } else { - OC_Log::write('OC_User', 'could not check if enabled: '. OC_DB::getErrorMessage($result), OC_Log::ERROR); + OC_Log::write('OC_User', + 'could not check if enabled: '. OC_DB::getErrorMessage($result), + OC_Log::ERROR); } } else { OC_Log::write('OC_User', 'could not check if enabled: '. OC_DB::getErrorMessage($stmt), OC_Log::ERROR); diff --git a/lib/user/database.php b/lib/user/database.php index 1a6a22d7a16..a0ad03fe0a0 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -155,7 +155,8 @@ class OC_User_Database extends OC_User_Backend { */ public function getDisplayNames($search = '', $limit = null, $offset = null) { $displayNames = array(); - $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`displayname`) LIKE LOWER(?)', $limit, $offset); + $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`' + .' WHERE LOWER(`displayname`) LIKE LOWER(?)', $limit, $offset); $result = $query->execute(array($search.'%')); $users = array(); while ($row = $result->fetchRow()) { @@ -163,7 +164,8 @@ class OC_User_Database extends OC_User_Backend { } // let's see if we can also find some users who don't have a display name yet - $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users` WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset); + $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`' + .' WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset); $result = $query->execute(array($search.'%')); while ($row = $result->fetchRow()) { $displayName = trim($row['displayname'], ' '); diff --git a/lib/util.php b/lib/util.php index 5c12e0b90f7..b2a4fce65a2 100755 --- a/lib/util.php +++ b/lib/util.php @@ -73,7 +73,8 @@ class OC_Util { * @return array */ 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 + // 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, 92, 10); } @@ -86,7 +87,9 @@ class OC_Util { } /** - * get the current installed edition of ownCloud. There is the community edition that just returns an empty string and the enterprise edition that returns "Enterprise". + * get the current installed edition of ownCloud. There is the community + * edition that just returns an empty string and the enterprise edition + * that returns "Enterprise". * @return string */ public static function getEditionString() { @@ -166,24 +169,33 @@ class OC_Util { $web_server_restart= false; //check for database drivers - if(!(is_callable('sqlite_open') or class_exists('SQLite3')) and !is_callable('mysql_connect') and !is_callable('pg_connect')) { - $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.
', 'hint'=>'');//TODO: sane hint + if(!(is_callable('sqlite_open') or class_exists('SQLite3')) + and !is_callable('mysql_connect') + and !is_callable('pg_connect')) { + $errors[]=array('error'=>'No database drivers (sqlite, mysql, or postgresql) installed.
', + 'hint'=>'');//TODO: sane hint $web_server_restart= true; } //common hint for all file permissons error messages - $permissionsHint="Permissions can usually be fixed by giving the webserver write access to the ownCloud directory"; + $permissionsHint="Permissions can usually be fixed by giving the webserver write access' + .' to the ownCloud directory"; // Check if config folder is writable. if(!is_writable(OC::$SERVERROOT."/config/") or !is_readable(OC::$SERVERROOT."/config/")) { - $errors[]=array('error'=>"Can't write into config directory 'config'", 'hint'=>"You can usually fix this by giving the webserver user write access to the config directory in owncloud"); + $errors[]=array('error'=>"Can't write into config directory 'config'", + 'hint'=>"You can usually fix this by giving the webserver user write access' + .' to the config directory in owncloud"); } // Check if there is a writable install folder. if(OC_Config::getValue('appstoreenabled', true)) { - if( OC_App::getInstallPath() === null || !is_writable(OC_App::getInstallPath()) || !is_readable(OC_App::getInstallPath()) ) { - $errors[]=array('error'=>"Can't write into apps directory", 'hint'=>"You can usually fix this by giving the webserver user write access to the apps directory - in owncloud or disabling the appstore in the config file."); + if( OC_App::getInstallPath() === null + || !is_writable(OC_App::getInstallPath()) + || !is_readable(OC_App::getInstallPath()) ) { + $errors[]=array('error'=>"Can't write into apps directory", + 'hint'=>"You can usually fix this by giving the webserver user write access' + .' to the apps directory in owncloud or disabling the appstore in the config file."); } } $CONFIG_DATADIRECTORY = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ); @@ -193,53 +205,68 @@ class OC_Util { if ($success) { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } else { - $errors[]=array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY.")", 'hint'=>"You can usually fix this by giving the webserver write access to the ownCloud directory '".OC::$SERVERROOT."' (in a terminal, use the command 'chown -R www-data:www-data /path/to/your/owncloud/install/data' "); + $errors[]=array('error'=>"Can't create data directory (".$CONFIG_DATADIRECTORY.")", + 'hint'=>"You can usually fix this by giving the webserver write access to the ownCloud directory '" + .OC::$SERVERROOT."' (in a terminal, use the command " + ."'chown -R www-data:www-data /path/to/your/owncloud/install/data' "); } } else if(!is_writable($CONFIG_DATADIRECTORY) or !is_readable($CONFIG_DATADIRECTORY)) { - $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud
', 'hint'=>$permissionsHint); + $errors[]=array('error'=>'Data directory ('.$CONFIG_DATADIRECTORY.') not writable by ownCloud
', + 'hint'=>$permissionsHint); } else { $errors = array_merge($errors, self::checkDataDirectoryPermissions($CONFIG_DATADIRECTORY)); } // check if all required php modules are present if(!class_exists('ZipArchive')) { - $errors[]=array('error'=>'PHP module zip not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module zip not installed.
', + 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('mb_detect_encoding')) { - $errors[]=array('error'=>'PHP module mb multibyte not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module mb multibyte not installed.
', + 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('ctype_digit')) { - $errors[]=array('error'=>'PHP module ctype is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module ctype is not installed.
', + 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('json_encode')) { - $errors[]=array('error'=>'PHP module JSON is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module JSON is not installed.
', + 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('imagepng')) { - $errors[]=array('error'=>'PHP module GD is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module GD is not installed.
', + 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('gzencode')) { - $errors[]=array('error'=>'PHP module zlib is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module zlib is not installed.
', + 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('iconv')) { - $errors[]=array('error'=>'PHP module iconv is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module iconv is not installed.
', + 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(!function_exists('simplexml_load_string')) { - $errors[]=array('error'=>'PHP module SimpleXML is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP module SimpleXML is not installed.
', + 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } if(floatval(phpversion())<5.3) { - $errors[]=array('error'=>'PHP 5.3 is required.
', 'hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher. PHP 5.2 is no longer supported by ownCloud and the PHP community.'); + $errors[]=array('error'=>'PHP 5.3 is required.
', + 'hint'=>'Please ask your server administrator to update PHP to version 5.3 or higher.' + .' PHP 5.2 is no longer supported by ownCloud and the PHP community.'); $web_server_restart= false; } if(!defined('PDO::ATTR_DRIVER_NAME')) { - $errors[]=array('error'=>'PHP PDO module is not installed.
', 'hint'=>'Please ask your server administrator to install the module.'); + $errors[]=array('error'=>'PHP PDO module is not installed.
', + 'hint'=>'Please ask your server administrator to install the module.'); $web_server_restart= false; } @@ -248,14 +275,17 @@ class OC_Util { $tmpDir = session_save_path(); if($tmpDir != "") { if(!@is_writable($tmpDir)) { - $errors[]=array('error' => 'The temporary folder used by PHP to save the session data is either incorrect or not writable! Please check : '.session_save_path().'
', - 'hint'=>'Please ask your server administrator to grant write access or define another temporary folder.'); + $errors[]=array('error' => 'The temporary folder used by PHP to save the session data' + .' is either incorrect or not writable! Please check : '.session_save_path().'
', + 'hint'=>'Please ask your server administrator to grant write access' + .' or define another temporary folder.'); } } } if($web_server_restart) { - $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?
', 'hint'=>'Please ask your server administrator to restart the web server.'); + $errors[]=array('error'=>'PHP modules have been installed, but they are still listed as missing?
', + 'hint'=>'Please ask your server administrator to restart the web server.'); } return $errors; @@ -270,14 +300,16 @@ class OC_Util { if (stristr(PHP_OS, 'WIN')) { //TODO: permissions checks for windows hosts } else { - $permissionsModHint = 'Please change the permissions to 0770 so that the directory cannot be listed by other users.'; + $permissionsModHint = 'Please change the permissions to 0770 so that the directory' + .' cannot be listed by other users.'; $prems = substr(decoct(@fileperms($dataDirectory)), -3); if (substr($prems, -1) != '0') { OC_Helper::chmodr($dataDirectory, 0770); clearstatcache(); $prems = substr(decoct(@fileperms($dataDirectory)), -3); if (substr($prems, 2, 1) != '0') { - $errors[] = array('error' => 'Data directory ('.$dataDirectory.') is readable for other users
', 'hint' => $permissionsModHint); + $errors[] = array('error' => 'Data directory ('.$dataDirectory.') is readable for other users
', + 'hint' => $permissionsModHint); } } } @@ -323,7 +355,8 @@ class OC_Util { public static function checkLoggedIn() { // Check if we are a user if( !OC_User::isLoggedIn()) { - header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php', array('redirect_url' => OC_Request::requestUri()))); + header( 'Location: '.OC_Helper::linkToAbsolute( '', 'index.php', + array('redirect_url' => OC_Request::requestUri()))); exit(); } } @@ -552,7 +585,8 @@ class OC_Util { } /** - * Check if the setlocal call doesn't work. This can happen if the right local packages are not available on the server. + * Check if the setlocal call doesn't work. This can happen if the right + * local packages are not available on the server. */ public static function issetlocaleworking() { // setlocale test is pointless on Windows diff --git a/lib/vcategories.php b/lib/vcategories.php index 1700870f91f..8de497a6191 100644 --- a/lib/vcategories.php +++ b/lib/vcategories.php @@ -689,7 +689,9 @@ class OC_VCategories { $stmt = OCP\DB::prepare($sql); $result = $stmt->execute(array($id)); if (OC_DB::isError($result)) { - OC_Log::write('core', __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), OC_Log::ERROR); + OC_Log::write('core', + __METHOD__. 'DB error: ' . OC_DB::getErrorMessage($result), + OC_Log::ERROR); } } catch(Exception $e) { OCP\Util::writeLog('core', __METHOD__.', exception: '.$e->getMessage(), -- cgit v1.2.3 From b488800bd5665eaa11b54002509e9e8b85c0780e Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Fri, 15 Feb 2013 17:41:22 +0100 Subject: fix error in recursive search --- lib/files/storage/mappedlocal.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/files/storage') diff --git a/lib/files/storage/mappedlocal.php b/lib/files/storage/mappedlocal.php index e707f71d71c..434c10bcbf7 100644 --- a/lib/files/storage/mappedlocal.php +++ b/lib/files/storage/mappedlocal.php @@ -20,7 +20,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ $this->datadir.='/'; } - $this->mapper= new \OC\Files\Mapper(); + $this->mapper= new \OC\Files\Mapper($this->datadir); } public function __destruct() { if (defined('PHPUNIT_RUN')) { @@ -274,7 +274,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ return $this->buildPath($path); } - protected function searchInDir($query, $dir='', $isLogicPath=true) { + protected function searchInDir($query, $dir='') { $files=array(); $physicalDir = $this->buildPath($dir); foreach (scandir($physicalDir) as $item) { @@ -287,7 +287,7 @@ class MappedLocal extends \OC\Files\Storage\Common{ $files[]=$dir.'/'.$item; } if(is_dir($physicalItem)) { - $files=array_merge($files, $this->searchInDir($query, $physicalItem, false)); + $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); } } return $files; -- cgit v1.2.3 From d96146a017bd8f7e4573e4555cea2c198fa9fbad Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Sat, 16 Feb 2013 03:27:50 +0100 Subject: Give storage backends the option to define having no known free space When this is the case only the configured max upload size is taking into account for uploading --- apps/files/ajax/upload.php | 2 +- apps/files_external/lib/amazons3.php | 5 ----- apps/files_external/lib/sftp.php | 4 ---- apps/files_external/lib/streamwrapper.php | 4 ---- apps/files_external/lib/swift.php | 4 ---- apps/files_external/lib/webdav.php | 2 +- lib/files/filesystem.php | 2 ++ lib/files/storage/common.php | 9 +++++++++ lib/helper.php | 8 ++++++-- 9 files changed, 19 insertions(+), 21 deletions(-) (limited to 'lib/files/storage') diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 07977f5ddf1..9031c729eff 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -48,7 +48,7 @@ $totalSize = 0; foreach ($files['size'] as $size) { $totalSize += $size; } -if ($totalSize > \OC\Files\Filesystem::free_space($dir)) { +if ($totalSize > $maxUploadFilesize) { OCP\JSON::error(array('data' => array('message' => $l->t('Not enough storage available'), 'uploadMaxFilesize' => $maxUploadFilesize, 'maxHumanFilesize' => $maxHumanFilesize))); diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 494885a1dd3..37e53a3a670 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -229,11 +229,6 @@ class AmazonS3 extends \OC\Files\Storage\Common { return false; } - public function free_space($path) { - // Infinite? - return false; - } - public function touch($path, $mtime = null) { if (is_null($mtime)) { $mtime = time(); diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index 551a5a64ef2..77c08d3b733 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -241,10 +241,6 @@ class SFTP extends \OC\Files\Storage\Common { } } - public function free_space($path) { - return -1; - } - public function touch($path, $mtime=null) { try { if (!is_null($mtime)) return false; diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index a631e7ce06a..4685877f26b 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -76,10 +76,6 @@ abstract class StreamWrapper extends \OC\Files\Storage\Common{ return fopen($this->constructUrl($path), $mode); } - public function free_space($path) { - return 0; - } - public function touch($path, $mtime=null) { $this->init(); if(is_null($mtime)) { diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index 0fd6fa143b8..a00316c1f84 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -478,10 +478,6 @@ class SWIFT extends \OC\Files\Storage\Common{ } } - public function free_space($path) { - return 1024*1024*1024*8; - } - public function touch($path, $mtime=null) { $this->init(); $obj=$this->getObject($path); diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index 039a07b1ef2..91cc22779e6 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -222,7 +222,7 @@ class DAV extends \OC\Files\Storage\Common{ return 0; } } catch(\Exception $e) { - return 0; + return \OC\Files\FREE_SPACE_UNKNOWN; } } diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index f4530868077..0dafef836bd 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -29,6 +29,8 @@ namespace OC\Files; +const FREE_SPACE_UNKNOWN = -2; + class Filesystem { public static $loaded = false; /** diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index 4cdabf1c8a6..4e7a73e5d4a 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -301,4 +301,13 @@ abstract class Common implements \OC\Files\Storage\Storage { } return implode('/', $output); } + + /** + * get the free space in the storage + * @param $path + * return int + */ + public function free_space($path){ + return \OC\Files\FREE_SPACE_UNKNOWN; + } } diff --git a/lib/helper.php b/lib/helper.php index 0f810ffc0c2..add5c66e7be 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -762,9 +762,13 @@ class OC_Helper { $maxUploadFilesize = min($upload_max_filesize, $post_max_size); $freeSpace = \OC\Files\Filesystem::free_space($dir); - $freeSpace = max($freeSpace, 0); + if($freeSpace !== \OC\Files\FREE_SPACE_UNKNOWN){ + $freeSpace = max($freeSpace, 0); - return min($maxUploadFilesize, $freeSpace); + return min($maxUploadFilesize, $freeSpace); + } else { + return $maxUploadFilesize; + } } /** -- cgit v1.2.3 From d8137fdf66a513d0de4bb234d0427ff27ca40106 Mon Sep 17 00:00:00 2001 From: Björn Schießle Date: Fri, 22 Feb 2013 16:43:11 +0100 Subject: return both, count and result if the operation succeeded or failed. Maybe in some cases it is useful to know how much bytes where copied --- apps/files_sharing/lib/sharedstorage.php | 3 ++- lib/files/storage/common.php | 4 ++-- lib/files/view.php | 8 ++++---- lib/helper.php | 9 ++++++--- lib/public/files.php | 3 ++- 5 files changed, 16 insertions(+), 11 deletions(-) (limited to 'lib/files/storage') diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index 65812b7e2fd..e920329ae49 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -314,7 +314,8 @@ class Shared extends \OC\Files\Storage\Common { if ($this->isCreatable(dirname($path2))) { $source = $this->fopen($path1, 'r'); $target = $this->fopen($path2, 'w'); - return \OC_Helper::streamCopy($source, $target); + list ($count, $result) = \OC_Helper::streamCopy($source, $target); + return $result; } return false; } diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index 4e7a73e5d4a..fd9ae844a8e 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -97,8 +97,8 @@ abstract class Common implements \OC\Files\Storage\Storage { public function copy($path1, $path2) { $source=$this->fopen($path1, 'r'); $target=$this->fopen($path2, 'w'); - $count=\OC_Helper::streamCopy($source, $target); - return $count>0; + list($count, $result) = \OC_Helper::streamCopy($source, $target); + return $result; } /** diff --git a/lib/files/view.php b/lib/files/view.php index 11edbadab9b..f48d0c8b225 100644 --- a/lib/files/view.php +++ b/lib/files/view.php @@ -285,7 +285,7 @@ class View { } $target = $this->fopen($path, 'w'); if ($target) { - $count = \OC_Helper::streamCopy($data, $target); + list ($count, $result) = \OC_Helper::streamCopy($data, $target); fclose($target); fclose($data); if ($this->fakeRoot == Filesystem::getRoot()) { @@ -303,7 +303,7 @@ class View { ); } \OC_FileProxy::runPostProxies('file_put_contents', $absolutePath, $count); - return $count > 0; + return $result; } else { return false; } @@ -361,7 +361,7 @@ class View { } else { $source = $this->fopen($path1 . $postFix1, 'r'); $target = $this->fopen($path2 . $postFix2, 'w'); - $result = \OC_Helper::streamCopy($source, $target); + list($count, $result) = \OC_Helper::streamCopy($source, $target); list($storage1, $internalPath1) = Filesystem::resolvePath($absolutePath1 . $postFix1); $storage1->unlink($internalPath1); } @@ -443,7 +443,7 @@ class View { } else { $source = $this->fopen($path1 . $postFix1, 'r'); $target = $this->fopen($path2 . $postFix2, 'w'); - $result = \OC_Helper::streamCopy($source, $target); + list($count, $result) = \OC_Helper::streamCopy($source, $target); } if ($this->fakeRoot == Filesystem::getRoot()) { \OC_Hook::emit( diff --git a/lib/helper.php b/lib/helper.php index 2c9cd36b199..7420a79eb2d 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -513,13 +513,16 @@ class OC_Helper { if(!$source or !$target) { return false; } - $result=true; + $result = true; + $count = 0; while(!feof($source)) { - if (fwrite($target, fread($source, 8192)) === false) { + if ($c = fwrite($target, fread($source, 8192)) === false) { $result = false; + } else { + $count += $c; } } - return $result; + return array($count, $result); } /** diff --git a/lib/public/files.php b/lib/public/files.php index c2945b200e8..700bf574537 100644 --- a/lib/public/files.php +++ b/lib/public/files.php @@ -62,7 +62,8 @@ class Files { * @return int the number of bytes copied */ public static function streamCopy( $source, $target ) { - return(\OC_Helper::streamCopy( $source, $target )); + list($count, $result) = \OC_Helper::streamCopy( $source, $target ); + return $count; } /** -- cgit v1.2.3 From bb75dfc021a68bcd9526ef40f78bca4910798345 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Fri, 22 Feb 2013 17:21:57 +0100 Subject: Whitespace fixes --- apps/files/js/filelist.js | 14 +- apps/files/js/files.js | 20 +- apps/files_external/lib/config.php | 16 +- apps/files_external/lib/sftp.php | 14 +- apps/files_sharing/public.php | 3 +- apps/files_trashbin/ajax/delete.php | 2 +- apps/files_trashbin/ajax/undelete.php | 4 +- apps/files_trashbin/appinfo/app.php | 6 +- apps/files_trashbin/index.php | 28 +-- apps/files_trashbin/js/disableDefaultActions.js | 6 +- apps/files_trashbin/js/trash.js | 24 +- apps/files_trashbin/lib/hooks.php | 40 +-- apps/files_trashbin/lib/trash.php | 322 ++++++++++++------------ apps/files_trashbin/templates/part.list.php | 1 - apps/files_versions/ajax/rollbackVersion.php | 1 - apps/files_versions/js/versions.js | 4 +- apps/files_versions/lib/hooks.php | 6 +- apps/files_versions/lib/versions.php | 84 +++---- apps/user_ldap/lib/helper.php | 1 - apps/user_webdavauth/settings.php | 2 +- lib/connector/sabre/directory.php | 12 +- lib/connector/sabre/file.php | 8 +- lib/files/cache/legacy.php | 6 +- lib/files/filesystem.php | 2 +- lib/files/storage/common.php | 4 +- lib/group.php | 50 ++-- lib/group/backend.php | 34 +-- lib/group/database.php | 32 +-- lib/hook.php | 16 +- lib/image.php | 2 +- lib/public/share.php | 6 +- lib/public/user.php | 34 +-- lib/request.php | 2 +- lib/search.php | 4 +- lib/setup.php | 10 +- lib/user.php | 2 +- lib/user/backend.php | 4 +- lib/user/database.php | 12 +- settings/ajax/changedisplayname.php | 62 ++--- settings/routes.php | 2 +- 40 files changed, 449 insertions(+), 453 deletions(-) (limited to 'lib/files/storage') diff --git a/apps/files/js/filelist.js b/apps/files/js/filelist.js index 0bf1f79ab77..ea721059c3f 100644 --- a/apps/files/js/filelist.js +++ b/apps/files/js/filelist.js @@ -35,7 +35,7 @@ var FileList={ if(extension){ name_span.append($('').addClass('extension').text(extension)); } - //dirs can show the number of uploaded files + //dirs can show the number of uploaded files if (type == 'dir') { link_elem.append($('').attr({ 'class': 'uploadtext', @@ -44,7 +44,7 @@ var FileList={ } td.append(link_elem); tr.append(td); - + //size column if(size!=t('files', 'Pending')){ simpleSize=simpleFileSize(size); @@ -59,7 +59,7 @@ var FileList={ "style": 'color:rgb('+sizeColor+','+sizeColor+','+sizeColor+')' }).text(simpleSize); tr.append(td); - + // date column var modifiedColor = Math.round((Math.round((new Date()).getTime() / 1000)-lastModifiedTime)/60/60/24*5); td = $('').attr({ "class": "date" }); @@ -87,7 +87,7 @@ var FileList={ lastModified, $('#permissions').val() ); - + FileList.insertElement(name, 'file', tr.attr('data-file',name)); var row = $('tr').filterAttr('data-file',name); if(loading){ @@ -101,7 +101,7 @@ var FileList={ FileActions.display(row.find('td.filename')); }, addDir:function(name,size,lastModified,hidden){ - + var tr = this.createRow( 'dir', name, @@ -111,7 +111,7 @@ var FileList={ lastModified, $('#permissions').val() ); - + FileList.insertElement(name,'dir',tr); var row = $('tr').filterAttr('data-file',name); row.find('td.filename').draggable(dragOptions); @@ -344,7 +344,7 @@ var FileList={ var deleteAction = $('tr').filterAttr('data-file',file).children("td.date").children(".move2trash"); deleteAction[0].outerHTML = oldHTML; }); - } + } }); } }; diff --git a/apps/files/js/files.js b/apps/files/js/files.js index 8327460cca6..6801fb59910 100644 --- a/apps/files/js/files.js +++ b/apps/files/js/files.js @@ -114,7 +114,7 @@ $(document).ready(function() { $(this).parent().children('#file_upload_start').trigger('click'); return false; }); - + // Show trash bin $('#trash a').live('click', function() { window.location=OC.filePath('files_trashbin', '', 'index.php'); @@ -817,26 +817,26 @@ var createDragShadow = function(event){ //select dragged file $(event.target).parents('tr').find('td input:first').prop('checked',true); } - + var selectedFiles = getSelectedFiles(); - + if (!isDragSelected && selectedFiles.length == 1) { //revert the selection $(event.target).parents('tr').find('td input:first').prop('checked',false); } - + //also update class when we dragged more than one file if (selectedFiles.length > 1) { $(event.target).parents('tr').addClass('selected'); } - + // build dragshadow var dragshadow = $('
'); var tbody = $(''); dragshadow.append(tbody); - + var dir=$('#dir').val(); - + $(selectedFiles).each(function(i,elem){ var newtr = $('' +''+elem.name+''+humanFileSize(elem.size)+'' @@ -850,7 +850,7 @@ var createDragShadow = function(event){ }); } }); - + return dragshadow; } @@ -870,9 +870,9 @@ var folderDropOptions={ if ($(event.target).parents('tr').find('td input:first').prop('checked') === true) { return false; } - + var target=$.trim($(this).find('.nametext').text()); - + var files = ui.helper.find('tr'); $(files).each(function(i,row){ var dir = $(row).data('dir'); diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index d31c2f35a68..905c5d50cde 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -38,7 +38,7 @@ class OC_Mount_Config { * @return array */ public static function getBackends() { - + $backends['\OC\Files\Storage\Local']=array( 'backend' => 'Local', 'configuration' => array( @@ -77,7 +77,7 @@ class OC_Mount_Config { 'token' => '#token', 'token_secret' => '#token secret'), 'custom' => 'google'); - + $backends['\OC\Files\Storage\SWIFT']=array( 'backend' => 'OpenStack Swift', 'configuration' => array( @@ -86,7 +86,7 @@ class OC_Mount_Config { 'token' => '*Token', 'root' => '&Root', 'secure' => '!Secure ftps://')); - + if(OC_Mount_Config::checksmbclient()) $backends['\OC\Files\Storage\SMB']=array( 'backend' => 'SMB / CIFS', 'configuration' => array( @@ -95,7 +95,7 @@ class OC_Mount_Config { 'password' => '*Password', 'share' => 'Share', 'root' => '&Root')); - + $backends['\OC\Files\Storage\DAV']=array( 'backend' => 'ownCloud / WebDAV', 'configuration' => array( @@ -104,13 +104,13 @@ class OC_Mount_Config { 'password' => '*Password', 'root' => '&Root', 'secure' => '!Secure https://')); - + $backends['\OC\Files\Storage\SFTP']=array( 'backend' => 'SFTP', 'configuration' => array( 'host' => 'URL', - 'user' => 'Username', - 'password' => '*Password', + 'user' => 'Username', + 'password' => '*Password', 'root' => '&Root')); return($backends); @@ -378,7 +378,7 @@ class OC_Mount_Config { } /** - * check if php-ftp is installed + * check if php-ftp is installed */ public static function checkphpftp() { if(function_exists('ftp_login')) { diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index 785eb7dfc42..ede6c251fd9 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -32,7 +32,7 @@ class SFTP extends \OC\Files\Storage\Common { $this->root = isset($params['root']) ? $this->cleanPath($params['root']) : '/'; if ($this->root[0] != '/') $this->root = '/' . $this->root; if (substr($this->root, -1, 1) != '/') $this->root .= '/'; - + $host_keys = $this->read_host_keys(); $this->client = new \Net_SFTP($this->host); @@ -50,18 +50,18 @@ class SFTP extends \OC\Files\Storage\Common { $host_keys[$this->host] = $current_host_key; $this->write_host_keys($host_keys); } - + if(!$this->file_exists('')){ $this->mkdir(''); } } - + public function test() { if (!isset($params['host']) || !isset($params['user']) || !isset($params['password'])) { throw new \Exception("Required parameters not set"); - } + } } - + public function getId(){ return 'sftp::' . $this->user . '@' . $this->host . '/' . $this->root; } @@ -109,7 +109,7 @@ class SFTP extends \OC\Files\Storage\Common { $host_key_arr = explode("::", $line, 2); if (count($host_key_arr) == 2) { $hosts[] = $host_key_arr[0]; - $keys[] = $host_key_arr[1]; + $keys[] = $host_key_arr[1]; } } return array_combine($hosts, $keys); @@ -203,7 +203,7 @@ class SFTP extends \OC\Files\Storage\Common { $tmp = \OC_Helper::tmpFile($ext); $this->getFile($abs_path, $tmp); return fopen($tmp, $mode); - + case 'w': case 'wb': case 'a': diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index f265a7dd014..243ee668f1f 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -43,7 +43,7 @@ if (isset($_GET['t'])) { $path = \OC\Files\Filesystem::getPath($linkItem['file_source']); } } -} +} if (isset($path)) { if (!isset($linkItem['item_type'])) { OCP\Util::writeLog('share', 'No item type set for share id: ' . $linkItem['id'], \OCP\Util::ERROR); @@ -212,4 +212,3 @@ if (isset($path)) { header('HTTP/1.0 404 Not Found'); $tmpl = new OCP\Template('', '404', 'guest'); $tmpl->printPage(); - diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index 34f35c39ccb..1834fb54003 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -20,7 +20,7 @@ foreach ($list as $file) { $filename = $file; $timestamp = null; } - + OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp); if (!OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) { $success[$i]['filename'] = $file; diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index 93f2aaf1fa2..80de3c31f91 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -1,4 +1,4 @@ -getAbsolutePath($dir); $dirContent = opendir($fullpath); $i = 0; @@ -36,10 +36,10 @@ if ($dir) { 'type' => $view->is_dir($dir.'/'.$entryName) ? 'dir' : 'file', 'location' => $dir, ); - } + } } closedir($dirContent); - + } else { $dirlisting = false; $query = \OC_DB::prepare('SELECT id,location,timestamp,type,mime FROM *PREFIX*files_trash WHERE user=?'); @@ -67,28 +67,28 @@ foreach ($result as $r) { $files[] = $i; } -// Make breadcrumb +// Make breadcrumb $pathtohere = ''; -$breadcrumb = array(); -foreach (explode('/', $dir) as $i) { +$breadcrumb = array(); +foreach (explode('/', $dir) as $i) { if ($i != '') { if ( preg_match('/^(.+)\.d[0-9]+$/', $i, $match) ) { $name = $match[1]; } else { $name = $i; - } - $pathtohere .= '/' . $i; - $breadcrumb[] = array('dir' => $pathtohere, 'name' => $name); - } + } + $pathtohere .= '/' . $i; + $breadcrumb[] = array('dir' => $pathtohere, 'name' => $name); + } } -$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); -$breadcrumbNav->assign('breadcrumb', $breadcrumb, false); +$breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); +$breadcrumbNav->assign('breadcrumb', $breadcrumb, false); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php') . '?dir=', false); $list = new OCP\Template('files_trashbin', 'part.list', ''); $list->assign('files', $files, false); -$list->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php'). '?dir='.$dir, false); +$list->assign('baseURL', OCP\Util::linkTo('files_trashbin', 'index.php'). '?dir='.$dir, false); $list->assign('downloadURL', OCP\Util::linkTo('files_trashbin', 'download.php') . '?file='.$dir, false); $list->assign('disableSharing', true); $list->assign('dirlisting', $dirlisting); diff --git a/apps/files_trashbin/js/disableDefaultActions.js b/apps/files_trashbin/js/disableDefaultActions.js index 27c3e13db4d..df08bfb1a50 100644 --- a/apps/files_trashbin/js/disableDefaultActions.js +++ b/apps/files_trashbin/js/disableDefaultActions.js @@ -1,4 +1,4 @@ -/* disable download and sharing actions */ -var disableDownloadActions = true; -var disableSharing = true; +/* disable download and sharing actions */ +var disableDownloadActions = true; +var disableSharing = true; var trashBinApp = true; \ No newline at end of file diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js index 208cc88f0fd..7769def535e 100644 --- a/apps/files_trashbin/js/trash.js +++ b/apps/files_trashbin/js/trash.js @@ -19,22 +19,22 @@ $(document).ready(function() { OC.dialogs.alert(result.data.message, 'Error'); } }); - + }); }; - + FileActions.register('all', 'Delete', OC.PERMISSION_READ, function () { return OC.imagePath('core', 'actions/delete'); }, function (filename) { $('.tipsy').remove(); - + var tr=$('tr').filterAttr('data-file', filename); var deleteAction = $('tr').filterAttr('data-file',filename).children("td.date").children(".action.delete"); var oldHTML = deleteAction[0].outerHTML; var newHTML = ''; var files = tr.attr('data-file'); deleteAction[0].outerHTML = newHTML; - + $.post(OC.filePath('files_trashbin','ajax','delete.php'), {files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') }, function(result){ @@ -46,9 +46,9 @@ $(document).ready(function() { OC.dialogs.alert(result.data.message, 'Error'); } }); - + }); - + // Sets the select_all checkbox behaviour : $('#select_all').click(function() { if($(this).attr('checked')){ @@ -91,18 +91,18 @@ $(document).ready(function() { } processSelection(); }); - + $('.undelete').click('click',function(event) { var spinner = ''; var files=getSelectedFiles('file'); var fileslist = JSON.stringify(files); var dirlisting=getSelectedFiles('dirlisting')[0]; - + for (var i=0; i'; var files=getSelectedFiles('file'); var fileslist = JSON.stringify(files); var dirlisting=getSelectedFiles('dirlisting')[0]; - + for (var i=0; i. - * +/** + * ownCloud - trash bin + * + * @author Bjoern Schiessle + * @copyright 2013 Bjoern Schiessle schiessle@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 + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see . + * */ /** @@ -36,7 +36,7 @@ class Hooks { * to copy the file to the trash bin */ public static function remove_hook($params) { - + if ( \OCP\App::isEnabled('files_trashbin') ) { $path = $params['path']; Trashbin::move2trash($path); diff --git a/apps/files_trashbin/lib/trash.php b/apps/files_trashbin/lib/trash.php index 2b8b32c3a16..8355c7252b0 100644 --- a/apps/files_trashbin/lib/trash.php +++ b/apps/files_trashbin/lib/trash.php @@ -1,67 +1,67 @@ . - * - */ - -namespace OCA\Files_Trashbin; - +/** + * ownCloud - trash bin + * + * @author Bjoern Schiessle + * @copyright 2013 Bjoern Schiessle schiessle@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 + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see . + * + */ + +namespace OCA\Files_Trashbin; + class Trashbin { // how long do we keep files in the trash bin if no other value is defined in the config file (unit: days) const DEFAULT_RETENTION_OBLIGATION=180; // unit: percentage; 50% of available disk space/quota const DEFAULTMAXSIZE=50; - + /** * move file to the trash bin - * + * * @param $file_path path to the deleted file/directory relative to the files root directory */ public static function move2trash($file_path) { $user = \OCP\User::getUser(); - $view = new \OC_FilesystemView('/'. $user); - if (!$view->is_dir('files_trashbin')) { - $view->mkdir('files_trashbin'); - $view->mkdir("versions_trashbin"); - } - - $path_parts = pathinfo($file_path); - - $deleted = $path_parts['basename']; - $location = $path_parts['dirname']; - $timestamp = time(); - $mime = $view->getMimeType('files'.$file_path); - - if ( $view->is_dir('files'.$file_path) ) { - $type = 'dir'; - } else { - $type = 'file'; + $view = new \OC_FilesystemView('/'. $user); + if (!$view->is_dir('files_trashbin')) { + $view->mkdir('files_trashbin'); + $view->mkdir("versions_trashbin"); } - - if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { + + $path_parts = pathinfo($file_path); + + $deleted = $path_parts['basename']; + $location = $path_parts['dirname']; + $timestamp = time(); + $mime = $view->getMimeType('files'.$file_path); + + if ( $view->is_dir('files'.$file_path) ) { + $type = 'dir'; + } else { + $type = 'file'; + } + + if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); - $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin')); + $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin')); } $trashbinSize += self::copy_recursive($file_path, 'files_trashbin/'.$deleted.'.d'.$timestamp, $view); - if ( $view->file_exists('files_trashbin/'.$deleted.'.d'.$timestamp) ) { + if ( $view->file_exists('files_trashbin/'.$deleted.'.d'.$timestamp) ) { $query = \OC_DB::prepare("INSERT INTO *PREFIX*files_trash (id,timestamp,location,type,mime,user)" ." VALUES (?,?,?,?,?,?)"); $result = $query->execute(array($deleted, $timestamp, $location, $type, $mime, $user)); @@ -69,49 +69,49 @@ class Trashbin { $view->deleteAll('files_trashbin/'.$deleted.'.d'.$timestamp); \OC_Log::write('files_trashbin', 'trash bin database couldn\'t be updated', \OC_log::ERROR); return; - } - - if ( \OCP\App::isEnabled('files_versions') ) { + } + + if ( \OCP\App::isEnabled('files_versions') ) { if ( $view->is_dir('files_versions'.$file_path) ) { $trashbinSize += self::calculateSize( new \OC_FilesystemView('/'. $user.'/files_versions/'.$file_path) ); - $view->rename('files_versions'.$file_path, 'versions_trashbin/'. $deleted.'.d'.$timestamp); - } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($file_path) ) { + $view->rename('files_versions'.$file_path, 'versions_trashbin/'. $deleted.'.d'.$timestamp); + } else if ( $versions = \OCA\Files_Versions\Storage::getVersions($file_path) ) { foreach ($versions as $v) { - $trashbinSize += $view->filesize('files_versions'.$v['path'].'.v'.$v['version']); + $trashbinSize += $view->filesize('files_versions'.$v['path'].'.v'.$v['version']); $view->rename('files_versions'.$v['path'].'.v'.$v['version'], 'versions_trashbin/'. $deleted.'.v'.$v['version'].'.d'.$timestamp); - } - } + } + } } } else { \OC_Log::write('files_trashbin', 'Couldn\'t move '.$file_path.' to the trash bin', \OC_log::ERROR); } - - // get available disk space for user - $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($user, 'files', 'quota')); - if ( $quota == null ) { - $quota = \OCP\Util::computerFileSize(\OC_Appconfig::getValue('files', 'default_quota')); - } - if ( $quota == null ) { - $quota = \OC\Files\Filesystem::free_space('/'); + + // get available disk space for user + $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($user, 'files', 'quota')); + if ( $quota == null ) { + $quota = \OCP\Util::computerFileSize(\OC_Appconfig::getValue('files', 'default_quota')); + } + if ( $quota == null ) { + $quota = \OC\Files\Filesystem::free_space('/'); } - - // calculate available space for trash bin - $rootInfo = $view->getFileInfo('/files'); - $free = $quota-$rootInfo['size']; // remaining free space for user - if ( $free > 0 ) { - $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions - } else { - $availableSpace = $free-$trashbinSize; + + // calculate available space for trash bin + $rootInfo = $view->getFileInfo('/files'); + $free = $quota-$rootInfo['size']; // remaining free space for user + if ( $free > 0 ) { + $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $trashbinSize; // how much space can be used for versions + } else { + $availableSpace = $free-$trashbinSize; } - + $trashbinSize -= self::expire($availableSpace); - \OCP\Config::setAppValue('files_trashbin', 'size', $trashbinSize); + \OCP\Config::setAppValue('files_trashbin', 'size', $trashbinSize); } - - + + /** * restore files from trash bin * @param $file path to the deleted file @@ -121,10 +121,10 @@ class Trashbin { public static function restore($file, $filename, $timestamp) { $user = \OCP\User::getUser(); $view = new \OC_FilesystemView('/'.$user); - - if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { - $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); - $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin')); + + if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { + $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); + $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin')); } if ( $timestamp ) { $query = \OC_DB::prepare('SELECT location,type FROM *PREFIX*files_trash' @@ -134,13 +134,13 @@ class Trashbin { \OC_Log::write('files_trashbin', 'trash bin database inconsistent!', \OC_Log::ERROR); return false; } - - // if location no longer exists, restore file in the root directory - $location = $result[0]['location']; - if ( $result[0]['location'] != '/' && + + // if location no longer exists, restore file in the root directory + $location = $result[0]['location']; + if ( $result[0]['location'] != '/' && (!$view->is_dir('files'.$result[0]['location']) || - !$view->isUpdatable('files'.$result[0]['location'])) ) { - $location = ''; + !$view->isUpdatable('files'.$result[0]['location'])) ) { + $location = ''; } } else { $path_parts = pathinfo($filename); @@ -150,10 +150,10 @@ class Trashbin { ); $location = ''; } - + $source = \OC_Filesystem::normalizePath('files_trashbin/'.$file); $target = \OC_Filesystem::normalizePath('files/'.$location.'/'.$filename); - + // we need a extension in case a file/dir with the same name already exists $ext = self::getUniqueExtension($location, $filename, $view); $mtime = $view->filemtime($source); @@ -170,14 +170,14 @@ class Trashbin { $versionedFile = $filename; } else { $versionedFile = $file; - } + } if ( $result[0]['type'] == 'dir' ) { $trashbinSize -= self::calculateSize( new \OC_FilesystemView('/'.$user.'/'.'versions_trashbin/'. $file) ); $view->rename(\OC_Filesystem::normalizePath('versions_trashbin/'. $file), \OC_Filesystem::normalizePath('files_versions/'.$location.'/'.$filename.$ext)); - } else if ( $versions = self::getVersionsFromTrash($versionedFile, $timestamp) ) { + } else if ( $versions = self::getVersionsFromTrash($versionedFile, $timestamp) ) { foreach ($versions as $v) { if ($timestamp ) { $trashbinSize -= $view->filesize('versions_trashbin/'.$versionedFile.'.v'.$v.'.d'.$timestamp); @@ -187,13 +187,13 @@ class Trashbin { $trashbinSize -= $view->filesize('versions_trashbin/'.$versionedFile.'.v'.$v); $view->rename('versions_trashbin/'.$versionedFile.'.v'.$v, 'files_versions/'.$location.'/'.$filename.$ext.'.v'.$v); - } - } - } + } + } + } } if ( $timestamp ) { - $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?'); + $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?'); $query->execute(array($user,$filename,$timestamp)); } @@ -205,31 +205,31 @@ class Trashbin { return false; } - - /** - * delete file from trash bin permanently + + /** + * delete file from trash bin permanently * @param $filename path to the file - * @param $timestamp of deletion time - * @return size of deleted files - */ - public static function delete($filename, $timestamp=null) { - $user = \OCP\User::getUser(); + * @param $timestamp of deletion time + * @return size of deleted files + */ + public static function delete($filename, $timestamp=null) { + $user = \OCP\User::getUser(); $view = new \OC_FilesystemView('/'.$user); - $size = 0; - - if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { - $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); - $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin')); + $size = 0; + + if ( ($trashbinSize = \OCP\Config::getAppValue('files_trashbin', 'size')) === null ) { + $trashbinSize = self::calculateSize(new \OC_FilesystemView('/'. $user.'/files_trashbin')); + $trashbinSize += self::calculateSize(new \OC_FilesystemView('/'. $user.'/versions_trashbin')); } - - if ( $timestamp ) { - $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?'); - $query->execute(array($user,$filename,$timestamp)); + + if ( $timestamp ) { + $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND id=? AND timestamp=?'); + $query->execute(array($user,$filename,$timestamp)); $file = $filename.'.d'.$timestamp; } else { $file = $filename; } - + if ( \OCP\App::isEnabled('files_versions') ) { if ($view->is_dir('versions_trashbin/'.$file)) { $size += self::calculateSize(new \OC_Filesystemview('/'.$user.'/versions_trashbin/'.$file)); @@ -245,8 +245,8 @@ class Trashbin { } } } - } - + } + if ($view->is_dir('/files_trashbin/'.$file)) { $size += self::calculateSize(new \OC_Filesystemview('/'.$user.'/files_trashbin/'.$file)); } else { @@ -255,8 +255,8 @@ class Trashbin { $view->unlink('/files_trashbin/'.$file); $trashbinSize -= $size; \OCP\Config::setAppValue('files_trashbin', 'size', $trashbinSize); - - return $size; + + return $size; } /** @@ -279,22 +279,22 @@ class Trashbin { return $view->file_exists($target); } - /** + /** * clean up the trash bin - * @param max. available disk space for trashbin - */ + * @param max. available disk space for trashbin + */ private static function expire($availableSpace) { - + $user = \OCP\User::getUser(); $view = new \OC_FilesystemView('/'.$user); $size = 0; - - $query = \OC_DB::prepare('SELECT location,type,id,timestamp FROM *PREFIX*files_trash WHERE user=?'); + + $query = \OC_DB::prepare('SELECT location,type,id,timestamp FROM *PREFIX*files_trash WHERE user=?'); $result = $query->execute(array($user))->fetchAll(); - + $retention_obligation = \OC_Config::getValue('trashbin_retention_obligation', self::DEFAULT_RETENTION_OBLIGATION); - + $limit = time() - ($retention_obligation * 86400); foreach ( $result as $r ) { @@ -318,14 +318,14 @@ class Trashbin { foreach ($versions as $v) { $size += $view->filesize('versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp); $view->unlink('versions_trashbin/'.$filename.'.v'.$v.'.d'.$timestamp); - } + } } } } - - $query = \OC_DB::prepare('DELETE FROM *PREFIX*files_trash WHERE user=? AND timestampexecute(array($user,$limit)); - + $availableSpace = $availableSpace + $size; // if size limit for trash bin reached, delete oldest files in trash bin if ($availableSpace < 0) { @@ -340,15 +340,15 @@ class Trashbin { $size += $tmp; $i++; } - + } - - return $size; + + return $size; } - + /** * recursive copy to copy a whole directory - * + * * @param $source source path, relative to the users files directory * @param $destination destination path relative to the users root directoy * @param $view file view for the users root directory @@ -375,7 +375,7 @@ class Trashbin { } return $size; } - + /** * find all versions which belong to the file we want to restore * @param $filename name of the file which should be restored @@ -383,7 +383,7 @@ class Trashbin { */ private static function getVersionsFromTrash($filename, $timestamp) { $view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/versions_trashbin'); - $versionsName = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath($filename); + $versionsName = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath($filename); $versions = array(); if ($timestamp ) { // fetch for old versions @@ -391,20 +391,20 @@ class Trashbin { $offset = -strlen($timestamp)-2; } else { $matches = glob( $versionsName.'.v*' ); - } - + } + foreach( $matches as $ma ) { if ( $timestamp ) { - $parts = explode( '.v', substr($ma, 0, $offset) ); + $parts = explode( '.v', substr($ma, 0, $offset) ); $versions[] = ( end( $parts ) ); } else { - $parts = explode( '.v', $ma ); + $parts = explode( '.v', $ma ); $versions[] = ( end( $parts ) ); } } return $versions; } - + /** * find unique extension for restored file if a file with the same name already exists * @param $location where the file should be restored @@ -413,40 +413,40 @@ class Trashbin { * @return string with unique extension */ private static function getUniqueExtension($location, $filename, $view) { - $ext = ''; - if ( $view->file_exists('files'.$location.'/'.$filename) ) { - $tmpext = '.restored'; - $ext = $tmpext; - $i = 1; - while ( $view->file_exists('files'.$location.'/'.$filename.$ext) ) { - $ext = $tmpext.$i; - $i++; - } + $ext = ''; + if ( $view->file_exists('files'.$location.'/'.$filename) ) { + $tmpext = '.restored'; + $ext = $tmpext; + $i = 1; + while ( $view->file_exists('files'.$location.'/'.$filename.$ext) ) { + $ext = $tmpext.$i; + $i++; + } } return $ext; } - /** + /** * @brief get the size from a given root folder - * @param $view file view on the root folder - * @return size of the folder - */ - private static function calculateSize($view) { - $root = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath(''); + * @param $view file view on the root folder + * @return size of the folder + */ + private static function calculateSize($view) { + $root = \OCP\Config::getSystemValue('datadirectory').$view->getAbsolutePath(''); if (!file_exists($root)) { return 0; } $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($root), - \RecursiveIteratorIterator::CHILD_FIRST); - $size = 0; - + \RecursiveIteratorIterator::CHILD_FIRST); + $size = 0; + foreach ($iterator as $path) { $relpath = substr($path, strlen($root)-1); if ( !$view->is_dir($relpath) ) { $size += $view->filesize($relpath); - } - } - return $size; + } + } + return $size; } - -} + +} diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php index 2de0d7ee91a..dea0a43cd4c 100644 --- a/apps/files_trashbin/templates/part.list.php +++ b/apps/files_trashbin/templates/part.list.php @@ -69,4 +69,3 @@ array( "message" => $l->t("Could not revert: %s", array($file) )))); } - diff --git a/apps/files_versions/js/versions.js b/apps/files_versions/js/versions.js index dec222eefce..109829fa03f 100644 --- a/apps/files_versions/js/versions.js +++ b/apps/files_versions/js/versions.js @@ -64,9 +64,9 @@ function createVersionsDropdown(filename, files) { } else { $(html).appendTo($('thead .share')); } - + $("#makelink").click(function() { - goToVersionPage(historyUrl); + goToVersionPage(historyUrl); }); $.ajax({ diff --git a/apps/files_versions/lib/hooks.php b/apps/files_versions/lib/hooks.php index 6c87eba423d..7891b20e92f 100644 --- a/apps/files_versions/lib/hooks.php +++ b/apps/files_versions/lib/hooks.php @@ -41,7 +41,7 @@ class Hooks { if($path<>'') { Storage::delete($path); } - + } } @@ -59,8 +59,8 @@ class Hooks { if($oldpath<>'' && $newpath<>'') { Storage::rename( $oldpath, $newpath ); } - + } } - + } diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 8a67de04d83..adbf2c1df7e 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -19,7 +19,7 @@ class Storage { const DEFAULTENABLED=true; const DEFAULTMAXSIZE=50; // unit: percentage; 50% of available disk space/quota - + private static $max_versions_per_interval = array( //first 10sec, one version every 2sec 1 => array('intervalEndsAfter' => 10, 'step' => 2), @@ -45,14 +45,14 @@ class Storage { } return array($uid, $filename); } - + /** * store a new version of a file. */ public static function store($filename) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { list($uid, $filename) = self::getUidAndFilename($filename); - + $files_view = new \OC\Files\View('/'.$uid .'/files'); $users_view = new \OC\Files\View('/'.$uid); @@ -79,10 +79,10 @@ class Storage { $versionsSize = self::calculateSize($uid); } $versionsSize += $users_view->filesize('files'.$filename); - + // expire old revisions if necessary $newSize = self::expire($filename, $versionsSize); - + if ( $newSize != $versionsSize ) { \OCP\Config::setAppValue('files_versions', 'size', $versionsSize); } @@ -96,7 +96,7 @@ class Storage { public static function delete($filename) { list($uid, $filename) = self::getUidAndFilename($filename); $versions_fileview = new \OC\Files\View('/'.$uid .'/files_versions'); - + $abs_path = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath('').$filename.'.v'; if( ($versions = self::getVersions($uid, $filename)) ) { if ( ($versionsSize = \OCP\Config::getAppValue('files_versions', 'size')) === null ) { @@ -109,7 +109,7 @@ class Storage { \OCP\Config::setAppValue('files_versions', 'size', $versionsSize); } } - + /** * rename versions of a file */ @@ -119,7 +119,7 @@ class Storage { $versions_view = new \OC\Files\View('/'.$uid .'/files_versions'); $files_view = new \OC\Files\View('/'.$uid .'/files'); $abs_newpath = \OCP\Config::getSystemValue('datadirectory').$versions_view->getAbsolutePath('').$newpath; - + if ( $files_view->is_dir($oldpath) && $versions_view->is_dir($oldpath) ) { $versions_view->rename($oldpath, $newpath); } else if ( ($versions = Storage::getVersions($uid, $oldpath)) ) { @@ -130,7 +130,7 @@ class Storage { } } } - + /** * rollback to an old version of a file. */ @@ -140,14 +140,14 @@ class Storage { list($uid, $filename) = self::getUidAndFilename($filename); $users_view = new \OC\Files\View('/'.$uid); $versionCreated = false; - + //first create a new version $version = 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename); if ( !$users_view->file_exists($version)) { $users_view->copy('files'.$filename, 'files_versions'.$filename.'.v'.$users_view->filemtime('files'.$filename)); $versionCreated = true; } - + // rollback if( @$users_view->copy('files_versions'.$filename.'.v'.$revision, 'files'.$filename) ) { $users_view->touch('files'.$filename, $revision); @@ -178,7 +178,7 @@ class Storage { $versions = array(); // fetch for old versions $matches = glob( $versionsName.'.v*' ); - + if ( !$matches ) { return $versions; } @@ -238,25 +238,25 @@ class Storage { if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions'); $versionsRoot = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath(''); - + $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($versionsRoot), \RecursiveIteratorIterator::CHILD_FIRST ); - + $size = 0; - + foreach ($iterator as $path) { if ( preg_match('/^.+\.v(\d+)$/', $path, $match) ) { $relpath = substr($path, strlen($versionsRoot)-1); $size += $versions_fileview->filesize($relpath); } } - + return $size; } } - + /** * @brief returns all stored file versions from a given user * @param $uid id to the user @@ -266,27 +266,27 @@ class Storage { if( \OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true' ) { $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions'); $versionsRoot = \OCP\Config::getSystemValue('datadirectory').$versions_fileview->getAbsolutePath(''); - + $iterator = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator($versionsRoot), \RecursiveIteratorIterator::CHILD_FIRST ); - + $versions = array(); - + foreach ($iterator as $path) { if ( preg_match('/^.+\.v(\d+)$/', $path, $match) ) { $relpath = substr($path, strlen($versionsRoot)-1); $versions[$match[1].'#'.$relpath] = array('path' => $relpath, 'timestamp' => $match[1]); } } - + ksort($versions); - + $i = 0; - + $result = array(); - + foreach( $versions as $key => $value ) { $i++; $size = $versions_fileview->filesize($value['path']); @@ -295,14 +295,14 @@ class Storage { $result['all'][$key]['version'] = $value['timestamp']; $result['all'][$key]['path'] = $filename; $result['all'][$key]['size'] = $size; - + $filename = substr($value['path'], 0, -strlen($value['timestamp'])-2); $result['by_file'][$filename][$key]['version'] = $value['timestamp']; $result['by_file'][$filename][$key]['path'] = $filename; $result['by_file'][$filename][$key]['size'] = $size; - + } - + return $result; } } @@ -312,9 +312,9 @@ class Storage { */ private static function expire($filename, $versionsSize = null) { if(\OCP\Config::getSystemValue('files_versions', Storage::DEFAULTENABLED)=='true') { - list($uid, $filename) = self::getUidAndFilename($filename); + list($uid, $filename) = self::getUidAndFilename($filename); $versions_fileview = new \OC\Files\View('/'.$uid.'/files_versions'); - + // get available disk space for user $quota = \OCP\Util::computerFileSize(\OC_Preferences::getValue($uid, 'files', 'quota')); if ( $quota == null ) { @@ -323,7 +323,7 @@ class Storage { if ( $quota == null ) { $quota = \OC\Files\Filesystem::free_space('/'); } - + // make sure that we have the current size of the version history if ( $versionsSize === null ) { if ( ($versionsSize = \OCP\Config::getAppValue('files_versions', 'size')) === null ) { @@ -339,9 +339,9 @@ class Storage { $availableSpace = ($free * self::DEFAULTMAXSIZE / 100) - $versionsSize; // how much space can be used for versions } else { $availableSpace = $free-$versionsSize; - } + } - // after every 1000s run reduce the number of all versions not only for the current file + // after every 1000s run reduce the number of all versions not only for the current file $random = rand(0, 1000); if ($random == 0) { $result = Storage::getAllVersions($uid); @@ -351,29 +351,29 @@ class Storage { $all_versions = Storage::getVersions($uid, $filename); $versions_by_file[$filename] = $all_versions; } - + $time = time(); - + // it is possible to expire versions from more than one file // iterate through all given files foreach ($versions_by_file as $filename => $versions) { $versions = array_reverse($versions); // newest version first - + $interval = 1; - $step = Storage::$max_versions_per_interval[$interval]['step']; + $step = Storage::$max_versions_per_interval[$interval]['step']; if (Storage::$max_versions_per_interval[$interval]['intervalEndsAfter'] == -1) { $nextInterval = -1; } else { $nextInterval = $time - Storage::$max_versions_per_interval[$interval]['intervalEndsAfter']; } - + $firstVersion = reset($versions); $firstKey = key($versions); $prevTimestamp = $firstVersion['version']; $nextVersion = $firstVersion['version'] - $step; $remaining_versions[$firstKey] = $firstVersion; unset($versions[$firstKey]); - + foreach ($versions as $key => $version) { $newInterval = true; while ( $newInterval ) { @@ -403,11 +403,11 @@ class Storage { $prevTimestamp = $version['version']; } } - + // check if enough space is available after versions are rearranged. // if not we delete the oldest versions until we meet the size limit for versions $numOfVersions = count($all_versions); - $i = 0; + $i = 0; while ($availableSpace < 0) { if ($i = $numOfVersions-2) break; // keep at least the last version $versions_fileview->unlink($all_versions[$i]['path'].'.v'.$all_versions[$i]['version']); @@ -415,10 +415,10 @@ class Storage { $availableSpace += $all_versions[$i]['size']; $i++; } - + return $versionsSize; // finally return the new size of the version history } - + return false; } } diff --git a/apps/user_ldap/lib/helper.php b/apps/user_ldap/lib/helper.php index 29ce998dae7..45c379445af 100644 --- a/apps/user_ldap/lib/helper.php +++ b/apps/user_ldap/lib/helper.php @@ -102,4 +102,3 @@ class Helper { return true; } } - diff --git a/apps/user_webdavauth/settings.php b/apps/user_webdavauth/settings.php index 7eabb0d48cc..ae9cb7e4c92 100755 --- a/apps/user_webdavauth/settings.php +++ b/apps/user_webdavauth/settings.php @@ -26,7 +26,7 @@ OC_Util::checkAdminUser(); if($_POST) { // CSRF check OCP\JSON::callCheck(); - + if(isset($_POST['webdav_url'])) { OC_CONFIG::setValue('user_webdavauth_url', strip_tags($_POST['webdav_url'])); } diff --git a/lib/connector/sabre/directory.php b/lib/connector/sabre/directory.php index a9aa891d409..953692f80a9 100644 --- a/lib/connector/sabre/directory.php +++ b/lib/connector/sabre/directory.php @@ -62,12 +62,12 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa } } else { $newPath = $this->path . '/' . $name; - + // mark file as partial while uploading (ignored by the scanner) $partpath = $newPath . '.part'; - + \OC\Files\Filesystem::file_put_contents($partpath, $data); - + //detect aborted upload if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) { if (isset($_SERVER['CONTENT_LENGTH'])) { @@ -80,10 +80,10 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa } } } - + // rename to correct path \OC\Files\Filesystem::rename($partpath, $newPath); - + // allow sync clients to send the mtime along in a header $mtime = OC_Request::hasModificationTime(); if ($mtime !== false) { @@ -91,7 +91,7 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa header('X-OC-MTime: accepted'); } } - + return OC_Connector_Sabre_Node::getETagPropertyForPath($newPath); } diff --git a/lib/connector/sabre/file.php b/lib/connector/sabre/file.php index c4c27e92251..91646312e90 100644 --- a/lib/connector/sabre/file.php +++ b/lib/connector/sabre/file.php @@ -47,9 +47,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D // mark file as partial while uploading (ignored by the scanner) $partpath = $this->path . '.part'; - + \OC\Files\Filesystem::file_put_contents($partpath, $data); - + //detect aborted upload if (isset ($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] === 'PUT' ) { if (isset($_SERVER['CONTENT_LENGTH'])) { @@ -62,10 +62,10 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D } } } - + // rename to correct path \OC\Files\Filesystem::rename($partpath, $this->path); - + //allow sync clients to send the mtime along in a header $mtime = OC_Request::hasModificationTime(); if ($mtime !== false) { diff --git a/lib/files/cache/legacy.php b/lib/files/cache/legacy.php index 6d1ffa7b40b..2b8689fcbda 100644 --- a/lib/files/cache/legacy.php +++ b/lib/files/cache/legacy.php @@ -51,12 +51,12 @@ class Legacy { $this->cacheHasItems = false; return false; } - + if ($result === false || property_exists($result, 'error_message_prefix')) { $this->cacheHasItems = false; return false; - } - + } + $this->cacheHasItems = (bool)$result->fetchRow(); return $this->cacheHasItems; } diff --git a/lib/files/filesystem.php b/lib/files/filesystem.php index 401ee8417e5..0bbd7550d74 100644 --- a/lib/files/filesystem.php +++ b/lib/files/filesystem.php @@ -221,7 +221,7 @@ class Filesystem { $root = \OC_User::getHome($user); self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user); - + // Load system mount points if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file(\OC::$SERVERROOT . '/config/mount.json')) { if (is_file(\OC::$SERVERROOT . '/config/mount.json')) { diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index 4e7a73e5d4a..8faacdf01d8 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -278,7 +278,7 @@ abstract class Common implements \OC\Files\Storage\Storage { return uniqid(); } } - + /** * clean a path, i.e. remove all redundant '.' and '..' * making sure that it can't point to higher than '/' @@ -289,7 +289,7 @@ abstract class Common implements \OC\Files\Storage\Storage { if (strlen($path) == 0 or $path[0] != '/') { $path = '/' . $path; } - + $output = array(); foreach (explode('/', $path) as $chunk) { if ($chunk == '..') { diff --git a/lib/group.php b/lib/group.php index 8c06ddc0fd0..88f0a2a032c 100644 --- a/lib/group.php +++ b/lib/group.php @@ -286,31 +286,31 @@ class OC_Group { } return $users; } - - /** - * @brief get a list of all display names in a group - * @returns array with display names (value) and user ids(key) - */ - public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { - $displayNames=array(); - foreach(self::$_usedBackends as $backend) { - $displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames); - } - return $displayNames; + + /** + * @brief get a list of all display names in a group + * @returns array with display names (value) and user ids(key) + */ + public static function displayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { + $displayNames=array(); + foreach(self::$_usedBackends as $backend) { + $displayNames = array_merge($backend->displayNamesInGroup($gid, $search, $limit, $offset), $displayNames); + } + return $displayNames; } - - /** - * @brief get a list of all display names in several groups - * @param array $gids - * @param string $search - * @param int $limit - * @param int $offset - * @return array with display names (Key) user ids (value) - */ - public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) { + + /** + * @brief get a list of all display names in several groups + * @param array $gids + * @param string $search + * @param int $limit + * @param int $offset + * @return array with display names (Key) user ids (value) + */ + public static function displayNamesInGroups($gids, $search = '', $limit = -1, $offset = 0) { $displayNames = array(); - foreach ($gids as $gid) { - // TODO Need to apply limits to groups as total + foreach ($gids as $gid) { + // TODO Need to apply limits to groups as total $diff = array_diff( self::displayNamesInGroup($gid, $search, $limit, $offset), $displayNames @@ -318,7 +318,7 @@ class OC_Group { if ($diff) { $displayNames = array_merge($diff, $displayNames); } - } - return $displayNames; + } + return $displayNames; } } diff --git a/lib/group/backend.php b/lib/group/backend.php index 4f6570c3be3..e7b7b21d957 100644 --- a/lib/group/backend.php +++ b/lib/group/backend.php @@ -133,23 +133,23 @@ abstract class OC_Group_Backend implements OC_Group_Interface { public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { return array(); } - - /** - * @brief get a list of all display names in a group - * @param string $gid - * @param string $search - * @param int $limit - * @param int $offset - * @return array with display names (value) and user ids (key) - */ - public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { - $displayNames = ''; - $users = $this->usersInGroup($gid, $search, $limit, $offset); - foreach ( $users as $user ) { - $DisplayNames[$user] = $user; - } - - return $DisplayNames; + + /** + * @brief get a list of all display names in a group + * @param string $gid + * @param string $search + * @param int $limit + * @param int $offset + * @return array with display names (value) and user ids (key) + */ + public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { + $displayNames = ''; + $users = $this->usersInGroup($gid, $search, $limit, $offset); + foreach ( $users as $user ) { + $DisplayNames[$user] = $user; + } + + return $DisplayNames; } } diff --git a/lib/group/database.php b/lib/group/database.php index 93dc05c53a1..40e9b0d4147 100644 --- a/lib/group/database.php +++ b/lib/group/database.php @@ -210,16 +210,16 @@ class OC_Group_Database extends OC_Group_Backend { } return $users; } - - /** - * @brief get a list of all display names in a group - * @param string $gid - * @param string $search - * @param int $limit - * @param int $offset - * @return array with display names (value) and user ids (key) - */ - public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { + + /** + * @brief get a list of all display names in a group + * @param string $gid + * @param string $search + * @param int $limit + * @param int $offset + * @return array with display names (value) and user ids (key) + */ + public function DisplayNamesInGroup($gid, $search = '', $limit = -1, $offset = 0) { $displayNames = ''; $stmt = OC_DB::prepare('SELECT `*PREFIX*users`.`uid`, `*PREFIX*users`.`displayname`' @@ -228,12 +228,12 @@ class OC_Group_Database extends OC_Group_Backend { .' WHERE `gid` = ? AND `*PREFIX*group_user`.`uid` LIKE ?', $limit, $offset); - $result = $stmt->execute(array($gid, $search.'%')); - $users = array(); + $result = $stmt->execute(array($gid, $search.'%')); + $users = array(); while ($row = $result->fetchRow()) { - $displayName = trim($row['displayname'], ' '); - $displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName; - } - return $displayNames; + $displayName = trim($row['displayname'], ' '); + $displayNames[$row['uid']] = empty($displayName) ? $row['uid'] : $displayName; + } + return $displayNames; } } diff --git a/lib/hook.php b/lib/hook.php index 554381251d6..8516cf0dcff 100644 --- a/lib/hook.php +++ b/lib/hook.php @@ -20,23 +20,23 @@ class OC_Hook{ * TODO: write example */ static public function connect( $signalclass, $signalname, $slotclass, $slotname ) { - // If we're trying to connect to an emitting class that isn't + // If we're trying to connect to an emitting class that isn't // yet registered, register it if( !array_key_exists( $signalclass, self::$registered )) { self::$registered[$signalclass] = array(); } - // If we're trying to connect to an emitting method that isn't + // If we're trying to connect to an emitting method that isn't // yet registered, register it with the emitting class - if( !array_key_exists( $signalname, self::$registered[$signalclass] )) { + if( !array_key_exists( $signalname, self::$registered[$signalclass] )) { self::$registered[$signalclass][$signalname] = array(); } - + // Connect the hook handler to the requested emitter self::$registered[$signalclass][$signalname][] = array( "class" => $slotclass, "name" => $slotname ); - + // No chance for failure ;-) return true; } @@ -53,19 +53,19 @@ class OC_Hook{ * TODO: write example */ static public function emit( $signalclass, $signalname, $params = array()) { - + // Return false if no hook handlers are listening to this // emitting class if( !array_key_exists( $signalclass, self::$registered )) { return false; } - + // Return false if no hook handlers are listening to this // emitting method if( !array_key_exists( $signalname, self::$registered[$signalclass] )) { return false; } - + // Call all slots foreach( self::$registered[$signalclass][$signalname] as $i ) { try { diff --git a/lib/image.php b/lib/image.php index dc1c6df85ae..97b0231047b 100644 --- a/lib/image.php +++ b/lib/image.php @@ -765,7 +765,7 @@ class OC_Image { imagealphablending($process, false); imagesavealpha($process, true); } - + imagecopyresampled($process, $this->resource, 0, 0, $x, $y, $targetWidth, $targetHeight, $width, $height); if ($process == false) { OC_Log::write('core', diff --git a/lib/public/share.php b/lib/public/share.php index c0f35333e83..37cf0838ed1 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -384,7 +384,7 @@ class Share { 'itemSource' => $itemSource, 'shareType' => $shareType, 'shareWith' => $shareWith, - )); + )); self::delete($item['id']); return true; } @@ -404,7 +404,7 @@ class Share { 'itemType' => $itemType, 'itemSource' => $itemSource, 'shares' => $shares - )); + )); foreach ($shares as $share) { self::delete($share['id']); } @@ -848,7 +848,7 @@ class Share { if ( isset($row['uid_owner']) && $row['uid_owner'] != '') { $row['displayname_owner'] = \OCP\User::getDisplayName($row['uid_owner']); } - + $items[$row['id']] = $row; } if (!empty($items)) { diff --git a/lib/public/user.php b/lib/public/user.php index 86d1d0ccde8..9edebe0e7cf 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -52,25 +52,25 @@ class User { public static function getUsers($search = '', $limit = null, $offset = null) { return \OC_USER::getUsers(); } - - /** - * @brief get the user display name of the user currently logged in. - * @return string display name - */ - public static function getDisplayName($user=null) { - return \OC_USER::getDisplayName($user); + + /** + * @brief get the user display name of the user currently logged in. + * @return string display name + */ + public static function getDisplayName($user=null) { + return \OC_USER::getDisplayName($user); } - - /** - * @brief Get a list of all display names - * @returns array with all display names (value) and the correspondig uids (key) - * - * Get a list of all display names and user ids. - */ - public static function getDisplayNames($search = '', $limit = null, $offset = null) { - return \OC_USER::getDisplayNames($search, $limit, $offset); + + /** + * @brief Get a list of all display names + * @returns array with all display names (value) and the correspondig uids (key) + * + * Get a list of all display names and user ids. + */ + public static function getDisplayNames($search = '', $limit = null, $offset = null) { + return \OC_USER::getDisplayNames($search, $limit, $offset); } - + /** * @brief Check if the user is logged in * @returns true/false diff --git a/lib/request.php b/lib/request.php index 3af93289670..30a25df23ab 100755 --- a/lib/request.php +++ b/lib/request.php @@ -149,7 +149,7 @@ class OC_Request { return 'gzip'; return false; } - + /** * @brief Check if the requester sent along an mtime * @returns false or an mtime diff --git a/lib/search.php b/lib/search.php index e5a65f7157d..b9c75dfc333 100644 --- a/lib/search.php +++ b/lib/search.php @@ -57,14 +57,14 @@ class OC_Search{ } return $results; } - + /** * remove an existing search provider * @param string $provider class name of a OC_Search_Provider */ public static function removeProvider($provider) { self::$registeredProviders = array_filter( - self::$registeredProviders, + self::$registeredProviders, function ($element) use ($provider) { return ($element['class'] != $provider); } diff --git a/lib/setup.php b/lib/setup.php index faf011fccb1..19e4a82b51f 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -98,7 +98,7 @@ class OC_Setup { $error[] = array( 'error' => $e->getMessage(), 'hint' => $e->getHint() - ); + ); return($error); } catch (Exception $e) { $error[] = array( @@ -174,7 +174,7 @@ class OC_Setup { OC_Appconfig::setValue('core', 'lastupdatedat', microtime(true)); OC_AppConfig::setValue('core', 'remote_core.css', '/core/minimizer.php'); OC_AppConfig::setValue('core', 'remote_core.js', '/core/minimizer.php'); - + OC_Group::createGroup('admin'); OC_Group::addToGroup($username, 'admin'); OC_User::login($username, $password); @@ -276,7 +276,7 @@ class OC_Setup { $query = "CREATE USER '$name'@'%' IDENTIFIED BY '$password'"; $result = mysql_query($query, $connection); if (!$result) { - throw new DatabaseSetupException($l->t("MySQL user '%s'@'%%' already exists", array($name)), + throw new DatabaseSetupException($l->t("MySQL user '%s'@'%%' already exists", array($name)), $l->t("Drop this user from MySQL.")); } } @@ -550,7 +550,7 @@ class OC_Setup { $result = oci_execute($stmt); if(!$result) { $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '
'; - $entry .= $l->t('Offending command was: "%s", name: %s, password: %s', + $entry .= $l->t('Offending command was: "%s", name: %s, password: %s', array($query, $name, $password)) . '
'; echo($entry); } @@ -582,7 +582,7 @@ class OC_Setup { $result = oci_execute($stmt); if(!$result) { $entry = $l->t('DB Error: "%s"', array(oci_error($connection))) . '
'; - $entry .= $l->t('Offending command was: "%s", name: %s, password: %s', + $entry .= $l->t('Offending command was: "%s", name: %s, password: %s', array($query, $name, $password)) . '
'; echo($entry); } diff --git a/lib/user.php b/lib/user.php index e69fef95a13..16f6d2787cb 100644 --- a/lib/user.php +++ b/lib/user.php @@ -437,7 +437,7 @@ class OC_User { } return false; } - + /** * @brief Check whether user can change his display name * @param $uid The username diff --git a/lib/user/backend.php b/lib/user/backend.php index 60b3cc6c5e4..93e8f17ca98 100644 --- a/lib/user/backend.php +++ b/lib/user/backend.php @@ -124,7 +124,7 @@ abstract class OC_User_Backend implements OC_User_Interface { public function getHome($uid) { return false; } - + /** * @brief get display name of the user * @param $uid user ID of the user @@ -133,7 +133,7 @@ abstract class OC_User_Backend implements OC_User_Interface { public function getDisplayName($uid) { return $uid; } - + /** * @brief Get a list of all display names * @returns array with all displayNames (value) and the corresponding uids (key) diff --git a/lib/user/database.php b/lib/user/database.php index a0ad03fe0a0..210c7f3e1eb 100644 --- a/lib/user/database.php +++ b/lib/user/database.php @@ -110,7 +110,7 @@ class OC_User_Database extends OC_User_Backend { return false; } } - + /** * @brief Set display name * @param $uid The username @@ -146,7 +146,7 @@ class OC_User_Database extends OC_User_Backend { } } } - + /** * @brief Get a list of all display names * @returns array with all displayNames (value) and the correspondig uids (key) @@ -162,7 +162,7 @@ class OC_User_Database extends OC_User_Backend { while ($row = $result->fetchRow()) { $displayNames[$row['uid']] = $row['displayname']; } - + // let's see if we can also find some users who don't have a display name yet $query = OC_DB::prepare('SELECT `uid`, `displayname` FROM `*PREFIX*users`' .' WHERE LOWER(`uid`) LIKE LOWER(?)', $limit, $offset); @@ -173,11 +173,11 @@ class OC_User_Database extends OC_User_Backend { $displayNames[$row['uid']] = $row['uid']; } } - - + + return $displayNames; } - + /** * @brief Check if the password is correct * @param $uid The username diff --git a/settings/ajax/changedisplayname.php b/settings/ajax/changedisplayname.php index 08c1b1455cd..dff4d733cd2 100644 --- a/settings/ajax/changedisplayname.php +++ b/settings/ajax/changedisplayname.php @@ -1,33 +1,33 @@ - array( "message" => $l->t("Authentication error") ))); - exit(); -} - -// Return Success story -if( OC_User::setDisplayName( $username, $displayName )) { - OC_JSON::success(array("data" => array( "username" => $username, 'displayName' => $displayName ))); -} -else{ + array( "message" => $l->t("Authentication error") ))); + exit(); +} + +// Return Success story +if( OC_User::setDisplayName( $username, $displayName )) { + OC_JSON::success(array("data" => array( "username" => $username, 'displayName' => $displayName ))); +} +else{ OC_JSON::error(array("data" => array( "message" => $l->t("Unable to change display name"), 'displayName' => OC_User::getDisplayName($username) ))); } diff --git a/settings/routes.php b/settings/routes.php index 26d933dba45..b20119b5803 100644 --- a/settings/routes.php +++ b/settings/routes.php @@ -39,7 +39,7 @@ $this->create('settings_ajax_removegroup', '/settings/ajax/removegroup.php') ->actionInclude('settings/ajax/removegroup.php'); $this->create('settings_ajax_changepassword', '/settings/ajax/changepassword.php') ->actionInclude('settings/ajax/changepassword.php'); -$this->create('settings_ajax_changedisplayname', '/settings/ajax/changedisplayname.php') +$this->create('settings_ajax_changedisplayname', '/settings/ajax/changedisplayname.php') ->actionInclude('settings/ajax/changedisplayname.php'); // personel $this->create('settings_ajax_lostpassword', '/settings/ajax/lostpassword.php') -- cgit v1.2.3 From 6b33a23a513b612416d8219a516331ffa695efe2 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 26 Feb 2013 02:51:57 +0100 Subject: Code style --- lib/files/storage/common.php | 187 ++++++++++++++++++++++++------------------- 1 file changed, 106 insertions(+), 81 deletions(-) (limited to 'lib/files/storage') diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index f9c6bdfce0c..0e596561920 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -22,81 +22,94 @@ namespace OC\Files\Storage; abstract class Common implements \OC\Files\Storage\Storage { - public function __construct($parameters) {} + public function __construct($parameters) { + } + public function is_dir($path) { - return $this->filetype($path)=='dir'; + return $this->filetype($path) == 'dir'; } + public function is_file($path) { - return $this->filetype($path)=='file'; + return $this->filetype($path) == 'file'; } + public function filesize($path) { - if($this->is_dir($path)) { - return 0;//by definition - }else{ + if ($this->is_dir($path)) { + return 0; //by definition + } else { $stat = $this->stat($path); return $stat['size']; } } + public function isCreatable($path) { if ($this->is_dir($path) && $this->isUpdatable($path)) { return true; } return false; } + public function isDeletable($path) { return $this->isUpdatable($path); } + public function isSharable($path) { return $this->isReadable($path); } - public function getPermissions($path){ + + public function getPermissions($path) { $permissions = 0; - if($this->isCreatable($path)) { + if ($this->isCreatable($path)) { $permissions |= \OCP\PERMISSION_CREATE; } - if($this->isReadable($path)) { + if ($this->isReadable($path)) { $permissions |= \OCP\PERMISSION_READ; } - if($this->isUpdatable($path)) { + if ($this->isUpdatable($path)) { $permissions |= \OCP\PERMISSION_UPDATE; } - if($this->isDeletable($path)) { + if ($this->isDeletable($path)) { $permissions |= \OCP\PERMISSION_DELETE; } - if($this->isSharable($path)) { + if ($this->isSharable($path)) { $permissions |= \OCP\PERMISSION_SHARE; } return $permissions; } + public function filemtime($path) { $stat = $this->stat($path); return $stat['mtime']; } + public function file_get_contents($path) { $handle = $this->fopen($path, "r"); - if(!$handle) { + if (!$handle) { return false; } - $size=$this->filesize($path); - if($size==0) { + $size = $this->filesize($path); + if ($size == 0) { return ''; } return fread($handle, $size); } + public function file_put_contents($path, $data) { $handle = $this->fopen($path, "w"); return fwrite($handle, $data); } + public function rename($path1, $path2) { - if($this->copy($path1, $path2)) { + if ($this->copy($path1, $path2)) { return $this->unlink($path1); - }else{ + } else { return false; } } + public function copy($path1, $path2) { - $source=$this->fopen($path1, 'r'); - $target=$this->fopen($path2, 'w'); + $source = $this->fopen($path1, 'r'); + $target = $this->fopen($path2, 'w'); list($count, $result) = \OC_Helper::streamCopy($source, $target); return $result; } @@ -110,29 +123,30 @@ abstract class Common implements \OC\Files\Storage\Storage { * @note By default the directory specified by $directory will be * deleted together with its contents. To avoid this set $empty to true */ - public function deleteAll( $directory, $empty = false ) { + public function deleteAll($directory, $empty = false) { $directory = trim($directory, '/'); - if ( !$this->file_exists( \OCP\USER::getUser() . '/' . $directory ) - || !$this->is_dir( \OCP\USER::getUser() . '/' . $directory ) ) { + if (!$this->file_exists(\OCP\USER::getUser() . '/' . $directory) + || !$this->is_dir(\OCP\USER::getUser() . '/' . $directory) + ) { return false; - } elseif( !$this->isReadable( \OCP\USER::getUser() . '/' . $directory ) ) { + } elseif (!$this->isReadable(\OCP\USER::getUser() . '/' . $directory)) { return false; } else { - $directoryHandle = $this->opendir( \OCP\USER::getUser() . '/' . $directory ); - while ( $contents = readdir( $directoryHandle ) ) { - if ( $contents != '.' && $contents != '..') { + $directoryHandle = $this->opendir(\OCP\USER::getUser() . '/' . $directory); + while ($contents = readdir($directoryHandle)) { + if ($contents != '.' && $contents != '..') { $path = $directory . "/" . $contents; - if ( $this->is_dir( $path ) ) { - $this->deleteAll( $path ); + if ($this->is_dir($path)) { + $this->deleteAll($path); } else { - $this->unlink( \OCP\USER::getUser() .'/' . $path ); // TODO: make unlink use same system path as is_dir + $this->unlink(\OCP\USER::getUser() . '/' . $path); // TODO: make unlink use same system path as is_dir } } } //$this->closedir( $directoryHandle ); // TODO: implement closedir in OC_FSV - if ( $empty == false ) { - if ( !$this->rmdir( $directory ) ) { + if ($empty == false) { + if (!$this->rmdir($directory)) { return false; } } @@ -140,88 +154,95 @@ abstract class Common implements \OC\Files\Storage\Storage { } } + public function getMimeType($path) { - if(!$this->file_exists($path)) { + if (!$this->file_exists($path)) { return false; } - if($this->is_dir($path)) { + if ($this->is_dir($path)) { return 'httpd/unix-directory'; } - $source=$this->fopen($path, 'r'); - if(!$source) { + $source = $this->fopen($path, 'r'); + if (!$source) { return false; } - $head=fread($source, 8192);//8kb should suffice to determine a mimetype - if($pos=strrpos($path, '.')) { - $extension=substr($path, $pos); - }else{ - $extension=''; + $head = fread($source, 8192); //8kb should suffice to determine a mimetype + if ($pos = strrpos($path, '.')) { + $extension = substr($path, $pos); + } else { + $extension = ''; } - $tmpFile=\OC_Helper::tmpFile($extension); + $tmpFile = \OC_Helper::tmpFile($extension); file_put_contents($tmpFile, $head); - $mime=\OC_Helper::getMimeType($tmpFile); + $mime = \OC_Helper::getMimeType($tmpFile); unlink($tmpFile); return $mime; } + public function hash($type, $path, $raw = false) { - $tmpFile=$this->getLocalFile($path); - $hash=hash($type, $tmpFile, $raw); + $tmpFile = $this->getLocalFile($path); + $hash = hash($type, $tmpFile, $raw); unlink($tmpFile); return $hash; } + public function search($query) { return $this->searchInDir($query); } + public function getLocalFile($path) { return $this->toTmpFile($path); } - private function toTmpFile($path) {//no longer in the storage api, still useful here - $source=$this->fopen($path, 'r'); - if(!$source) { + + private function toTmpFile($path) { //no longer in the storage api, still useful here + $source = $this->fopen($path, 'r'); + if (!$source) { return false; } - if($pos=strrpos($path, '.')) { - $extension=substr($path, $pos); - }else{ - $extension=''; + if ($pos = strrpos($path, '.')) { + $extension = substr($path, $pos); + } else { + $extension = ''; } - $tmpFile=\OC_Helper::tmpFile($extension); - $target=fopen($tmpFile, 'w'); + $tmpFile = \OC_Helper::tmpFile($extension); + $target = fopen($tmpFile, 'w'); \OC_Helper::streamCopy($source, $target); return $tmpFile; } + public function getLocalFolder($path) { - $baseDir=\OC_Helper::tmpFolder(); + $baseDir = \OC_Helper::tmpFolder(); $this->addLocalFolder($path, $baseDir); return $baseDir; } + private function addLocalFolder($path, $target) { - if($dh=$this->opendir($path)) { - while($file=readdir($dh)) { - if($file!=='.' and $file!=='..') { - if($this->is_dir($path.'/'.$file)) { - mkdir($target.'/'.$file); - $this->addLocalFolder($path.'/'.$file, $target.'/'.$file); - }else{ - $tmp=$this->toTmpFile($path.'/'.$file); - rename($tmp, $target.'/'.$file); + if ($dh = $this->opendir($path)) { + while ($file = readdir($dh)) { + if ($file !== '.' and $file !== '..') { + if ($this->is_dir($path . '/' . $file)) { + mkdir($target . '/' . $file); + $this->addLocalFolder($path . '/' . $file, $target . '/' . $file); + } else { + $tmp = $this->toTmpFile($path . '/' . $file); + rename($tmp, $target . '/' . $file); } } } } } - protected function searchInDir($query, $dir='') { - $files=array(); - $dh=$this->opendir($dir); - if($dh) { - while($item=readdir($dh)) { + protected function searchInDir($query, $dir = '') { + $files = array(); + $dh = $this->opendir($dir); + if ($dh) { + while ($item = readdir($dh)) { if ($item == '.' || $item == '..') continue; - if(strstr(strtolower($item), strtolower($query))!==false) { - $files[]=$dir.'/'.$item; + if (strstr(strtolower($item), strtolower($query)) !== false) { + $files[] = $dir . '/' . $item; } - if($this->is_dir($dir.'/'.$item)) { - $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item)); + if ($this->is_dir($dir . '/' . $item)) { + $files = array_merge($files, $this->searchInDir($query, $dir . '/' . $item)); } } } @@ -230,32 +251,34 @@ abstract class Common implements \OC\Files\Storage\Storage { /** * check if a file or folder has been updated since $time + * * @param string $path * @param int $time * @return bool */ public function hasUpdated($path, $time) { - return $this->filemtime($path)>$time; + return $this->filemtime($path) > $time; } - public function getCache($path=''){ + public function getCache($path = '') { return new \OC\Files\Cache\Cache($this); } - public function getScanner($path=''){ + public function getScanner($path = '') { return new \OC\Files\Cache\Scanner($this); } - public function getPermissionsCache($path=''){ + public function getPermissionsCache($path = '') { return new \OC\Files\Cache\Permissions($this); } - public function getWatcher($path=''){ + public function getWatcher($path = '') { return new \OC\Files\Cache\Watcher($this); } /** * get the owner of a path + * * @param string $path The path to get the owner * @return string uid or false */ @@ -269,12 +292,12 @@ abstract class Common implements \OC\Files\Storage\Storage { * @param string $path * @return string */ - public function getETag($path){ + public function getETag($path) { $ETagFunction = \OC_Connector_Sabre_Node::$ETagFunction; - if($ETagFunction) { + if ($ETagFunction) { $hash = call_user_func($ETagFunction, $path); return $hash; - }else{ + } else { return uniqid(); } } @@ -282,6 +305,7 @@ abstract class Common implements \OC\Files\Storage\Storage { /** * clean a path, i.e. remove all redundant '.' and '..' * making sure that it can't point to higher than '/' + * * @param $path The path to clean * @return string cleaned path */ @@ -304,10 +328,11 @@ abstract class Common implements \OC\Files\Storage\Storage { /** * get the free space in the storage + * * @param $path * return int */ - public function free_space($path){ + public function free_space($path) { return \OC\Files\FREE_SPACE_UNKNOWN; } } -- cgit v1.2.3 From 52dccd4aa14612ed93f50967e85ed6a0c6e22295 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Tue, 26 Feb 2013 02:53:02 +0100 Subject: Storage: don't throw warnings when a stat fails --- lib/files/storage/common.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/files/storage') diff --git a/lib/files/storage/common.php b/lib/files/storage/common.php index 0e596561920..cb41d17e446 100644 --- a/lib/files/storage/common.php +++ b/lib/files/storage/common.php @@ -38,7 +38,11 @@ abstract class Common implements \OC\Files\Storage\Storage { return 0; //by definition } else { $stat = $this->stat($path); - return $stat['size']; + if (isset($stat['size'])) { + return $stat['size']; + } else { + return 0; + } } } @@ -79,7 +83,11 @@ abstract class Common implements \OC\Files\Storage\Storage { public function filemtime($path) { $stat = $this->stat($path); - return $stat['mtime']; + if (isset($stat['mtime'])) { + return $stat['mtime']; + } else { + return 0; + } } public function file_get_contents($path) { -- cgit v1.2.3