summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2012-11-07 17:18:56 +0100
committerRobin Appelman <icewind@owncloud.com>2012-11-07 17:18:56 +0100
commit961ff01a93dd69cb12196a1b8507cce925e74fbc (patch)
tree4956c9a42d6286b0851ca73641439e5c002f6a9a /lib
parent4b940955ddb3266f625eae83da412a655efef319 (diff)
parent5cad2d7ccc3d2b4ccd9e1b090e28787f1c28b6ca (diff)
downloadnextcloud-server-961ff01a93dd69cb12196a1b8507cce925e74fbc.tar.gz
nextcloud-server-961ff01a93dd69cb12196a1b8507cce925e74fbc.zip
merge master into filesystem
Diffstat (limited to 'lib')
-rw-r--r--lib/MDB2/Driver/Reverse/sqlite3.php2
-rw-r--r--lib/MDB2/Driver/sqlite3.php3
-rw-r--r--lib/archive/tar.php3
-rw-r--r--lib/backgroundjob.php2
-rw-r--r--lib/base.php10
-rw-r--r--lib/connector/sabre/node.php16
-rw-r--r--lib/connector/sabre/quotaplugin.php16
-rw-r--r--lib/fileproxy/quota.php16
-rw-r--r--lib/files/storage/local.php34
-rw-r--r--lib/files/view.php2
-rw-r--r--lib/installer.php8
-rw-r--r--lib/log.php2
-rw-r--r--lib/migrate.php2
-rw-r--r--lib/migration/content.php2
-rw-r--r--lib/ocsclient.php6
-rw-r--r--lib/public/backgroundjob.php2
-rw-r--r--lib/public/share.php2
-rw-r--r--lib/public/util.php2
-rw-r--r--lib/template.php2
-rw-r--r--lib/user.php2
-rwxr-xr-xlib/util.php2
21 files changed, 73 insertions, 63 deletions
diff --git a/lib/MDB2/Driver/Reverse/sqlite3.php b/lib/MDB2/Driver/Reverse/sqlite3.php
index 36626478ce8..97037809549 100644
--- a/lib/MDB2/Driver/Reverse/sqlite3.php
+++ b/lib/MDB2/Driver/Reverse/sqlite3.php
@@ -476,7 +476,7 @@ class MDB2_Driver_Reverse_sqlite3 extends MDB2_Driver_Reverse_Common
$definition['unique'] = true;
$count = count($column_names);
for ($i=0; $i<$count; ++$i) {
- $column_name = strtok($column_names[$i]," ");
+ $column_name = strtok($column_names[$i], " ");
$collation = strtok(" ");
$definition['fields'][$column_name] = array(
'position' => $i+1
diff --git a/lib/MDB2/Driver/sqlite3.php b/lib/MDB2/Driver/sqlite3.php
index bccb8cbbf01..fa4c91c1269 100644
--- a/lib/MDB2/Driver/sqlite3.php
+++ b/lib/MDB2/Driver/sqlite3.php
@@ -397,8 +397,7 @@ class MDB2_Driver_sqlite3 extends MDB2_Driver_Common
}
if ($this->fix_assoc_fields_names ||
- $this->options['portability'] & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES)
- {
+ $this->options['portability'] & MDB2_PORTABILITY_FIX_ASSOC_FIELD_NAMES) {
$this->connection->exec("PRAGMA short_column_names = 1");
$this->fix_assoc_fields_names = true;
}
diff --git a/lib/archive/tar.php b/lib/archive/tar.php
index 6c264686991..0fa633c6038 100644
--- a/lib/archive/tar.php
+++ b/lib/archive/tar.php
@@ -130,8 +130,7 @@ class OC_Archive_TAR extends OC_Archive{
if( $file == $header['filename']
or $file.'/' == $header['filename']
or '/'.$file.'/' == $header['filename']
- or '/'.$file == $header['filename'])
- {
+ or '/'.$file == $header['filename']) {
return $header;
}
}
diff --git a/lib/backgroundjob.php b/lib/backgroundjob.php
index f486519bf09..28b5ce3af20 100644
--- a/lib/backgroundjob.php
+++ b/lib/backgroundjob.php
@@ -40,7 +40,7 @@ class OC_BackgroundJob{
* @param $type execution type
* @return boolean
*
- * This method sets the execution type of the background jobs. Possible types
+ * This method sets the execution type of the background jobs. Possible types
* are "none", "ajax", "webcron", "cron"
*/
public static function setExecutionType( $type ) {
diff --git a/lib/base.php b/lib/base.php
index 1403e5a2bef..2d6601f306a 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -530,8 +530,7 @@ class OC{
}
$file_ext = substr($param['file'], -3);
if ($file_ext != 'php'
- || !self::loadAppScriptFile($param))
- {
+ || !self::loadAppScriptFile($param)) {
header('HTTP/1.0 404 Not Found');
}
}
@@ -601,8 +600,7 @@ class OC{
if(!isset($_COOKIE["oc_remember_login"])
|| !isset($_COOKIE["oc_token"])
|| !isset($_COOKIE["oc_username"])
- || !$_COOKIE["oc_remember_login"])
- {
+ || !$_COOKIE["oc_remember_login"]) {
return false;
}
OC_App::loadApps(array('authentication'));
@@ -627,9 +625,9 @@ class OC{
OC_Util::redirectToDefaultPage();
// doesn't return
}
- // if you reach this point you have changed your password
+ // if you reach this point you have changed your password
// or you are an attacker
- // we can not delete tokens here because users may reach
+ // we can not delete tokens here because users may reach
// this point multiple times after a password change
OC_Log::write('core', 'Authentication cookie rejected for user '.$_COOKIE['oc_username'], OC_Log::WARN);
}
diff --git a/lib/connector/sabre/node.php b/lib/connector/sabre/node.php
index 2095c956e5f..ebc9e539625 100644
--- a/lib/connector/sabre/node.php
+++ b/lib/connector/sabre/node.php
@@ -26,6 +26,13 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
const LASTMODIFIED_PROPERTYNAME = '{DAV:}lastmodified';
/**
+ * Allow configuring the method used to generate Etags
+ *
+ * @var array(class_name, function_name)
+ */
+ public static $ETagFunction = null;
+
+ /**
* The path to the current node
*
* @var string
@@ -178,7 +185,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* If the array is empty, all properties should be returned
*
* @param array $properties
- * @return void
+ * @return array
*/
public function getProperties($properties) {
if (is_null($this->property_cache)) {
@@ -209,7 +216,12 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @return string|null Returns null if the ETag can not effectively be determined
*/
static protected function createETag($path) {
- return uniqid('', true);
+ if(self::$ETagFunction) {
+ $hash = call_user_func(self::$ETagFunction, $path);
+ return $hash;
+ }else{
+ return uniqid('', true);
+ }
}
/**
diff --git a/lib/connector/sabre/quotaplugin.php b/lib/connector/sabre/quotaplugin.php
index 5b8ef941710..a56a65ad863 100644
--- a/lib/connector/sabre/quotaplugin.php
+++ b/lib/connector/sabre/quotaplugin.php
@@ -2,7 +2,7 @@
/**
* This plugin check user quota and deny creating files when they exceeds the quota.
- *
+ *
* @copyright Copyright (C) 2012 entreCables S.L. All rights reserved.
* @author Sergio Cambra
* @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
@@ -10,9 +10,9 @@
class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin {
/**
- * Reference to main server object
- *
- * @var Sabre_DAV_Server
+ * Reference to main server object
+ *
+ * @var Sabre_DAV_Server
*/
private $server;
@@ -23,8 +23,8 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin {
* addPlugin is called.
*
* This method should set up the requires event subscriptions.
- *
- * @param Sabre_DAV_Server $server
+ *
+ * @param Sabre_DAV_Server $server
* @return void
*/
public function initialize(Sabre_DAV_Server $server) {
@@ -37,10 +37,10 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin {
/**
* This method is called before any HTTP method and forces users to be authenticated
- *
+ *
* @param string $method
* @throws Sabre_DAV_Exception
- * @return bool
+ * @return bool
*/
public function checkQuota($uri, $data = null) {
$expected = $this->server->httpRequest->getHeader('X-Expected-Entity-Length');
diff --git a/lib/fileproxy/quota.php b/lib/fileproxy/quota.php
index cd9a2f4a192..b359b9ae023 100644
--- a/lib/fileproxy/quota.php
+++ b/lib/fileproxy/quota.php
@@ -38,8 +38,10 @@ class OC_FileProxy_Quota extends OC_FileProxy{
if(in_array($user, $this->userQuota)) {
return $this->userQuota[$user];
}
+ $userQuota=OC_Preferences::getValue($user, 'files', 'quota', 'default');
$userQuota=OC_Preferences::getValue($user,'files','quota','default');
if($userQuota=='default') {
+ $userQuota=OC_AppConfig::getValue('files', 'default_quota', 'none');
$userQuota=OC_AppConfig::getValue('files','default_quota','none');
}
if($userQuota=='none') {
@@ -57,7 +59,7 @@ class OC_FileProxy_Quota extends OC_FileProxy{
* @return int
*/
private function getFreeSpace($path) {
- list($storage,)=\OC\Files\Filesystem::resolvePath($path);
+ $storage=OC_Filesystem::getStorage($path);
$owner=$storage->getOwner($path);
$totalSpace=$this->getQuota($owner);
@@ -73,33 +75,33 @@ class OC_FileProxy_Quota extends OC_FileProxy{
return $totalSpace-$usedSpace;
}
- public function postFree_space($path,$space) {
+ public function postFree_space($path, $space) {
$free=$this->getFreeSpace($path);
if($free==0) {
return $space;
}
- return min($free,$space);
+ return min($free, $space);
}
- public function preFile_put_contents($path,$data) {
+ public function preFile_put_contents($path, $data) {
if (is_resource($data)) {
$data = '';//TODO: find a way to get the length of the stream without emptying it
}
return (strlen($data)<$this->getFreeSpace($path) or $this->getFreeSpace($path)==0);
}
- public function preCopy($path1,$path2) {
+ public function preCopy($path1, $path2) {
if(!self::$rootView){
self::$rootView = new \OC\Files\View('');
}
return (self::$rootView->filesize($path1)<$this->getFreeSpace($path2) or $this->getFreeSpace($path2)==0);
}
- public function preFromTmpFile($tmpfile,$path) {
+ public function preFromTmpFile($tmpfile, $path) {
return (filesize($tmpfile)<$this->getFreeSpace($path) or $this->getFreeSpace($path)==0);
}
- public function preFromUploadedFile($tmpfile,$path) {
+ public function preFromUploadedFile($tmpfile, $path) {
return (filesize($tmpfile)<$this->getFreeSpace($path) or $this->getFreeSpace($path)==0);
}
}
diff --git a/lib/files/storage/local.php b/lib/files/storage/local.php
index 71f3bedad39..e888094627a 100644
--- a/lib/files/storage/local.php
+++ b/lib/files/storage/local.php
@@ -15,7 +15,7 @@ class Local extends \OC\Files\Storage\Common{
protected $datadir;
public function __construct($arguments) {
$this->datadir=$arguments['datadir'];
- if(substr($this->datadir,-1)!=='/') {
+ if(substr($this->datadir, -1)!=='/') {
$this->datadir.='/';
}
}
@@ -33,7 +33,7 @@ class Local extends \OC\Files\Storage\Common{
}
public function is_dir($path) {
if(substr($path,-1)=='/') {
- $path=substr($path,0,-1);
+ $path=substr($path, 0, -1);
}
return is_dir($this->datadir.$path);
}
@@ -87,13 +87,13 @@ class Local extends \OC\Files\Storage\Common{
public function file_get_contents($path) {
return file_get_contents($this->datadir.$path);
}
- public function file_put_contents($path,$data) {
- return file_put_contents($this->datadir.$path,$data);
+ public function file_put_contents($path, $data) {
+ return file_put_contents($this->datadir.$path, $data);
}
public function unlink($path) {
return $this->delTree($path);
}
- public function rename($path1,$path2) {
+ 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;
@@ -103,22 +103,22 @@ class Local extends \OC\Files\Storage\Common{
return false;
}
- if($return=rename($this->datadir.$path1,$this->datadir.$path2)) {
+ if($return=rename($this->datadir.$path1, $this->datadir.$path2)) {
}
return $return;
}
- public function copy($path1,$path2) {
+ public function copy($path1, $path2) {
if($this->is_dir($path2)) {
if(!$this->file_exists($path2)) {
$this->mkdir($path2);
}
- $source=substr($path1, strrpos($path1,'/')+1);
+ $source=substr($path1, strrpos($path1, '/')+1);
$path2.=$source;
}
- return copy($this->datadir.$path1,$this->datadir.$path2);
+ return copy($this->datadir.$path1, $this->datadir.$path2);
}
- public function fopen($path,$mode) {
- if($return=fopen($this->datadir.$path,$mode)) {
+ public function fopen($path, $mode) {
+ if($return=fopen($this->datadir.$path, $mode)) {
switch($mode) {
case 'r':
break;
@@ -138,7 +138,7 @@ class Local extends \OC\Files\Storage\Common{
public function getMimeType($path) {
if($this->isReadable($path)) {
- return \OC_Helper::getMimeType($this->datadir.$path);
+ return \OC_Helper::getMimeType($this->datadir . $path);
}else{
return false;
}
@@ -165,8 +165,8 @@ class Local extends \OC\Files\Storage\Common{
return $return;
}
- public function hash($path,$type,$raw=false) {
- return hash_file($type,$this->datadir.$path,$raw);
+ public function hash($path, $type, $raw=false) {
+ return hash_file($type, $this->datadir.$path, $raw);
}
public function free_space($path) {
@@ -183,7 +183,7 @@ class Local extends \OC\Files\Storage\Common{
return $this->datadir.$path;
}
- protected function searchInDir($query,$dir='') {
+ protected function searchInDir($query, $dir='') {
$files=array();
foreach (scandir($this->datadir.$dir) as $item) {
if ($item == '.' || $item == '..') continue;
@@ -191,7 +191,7 @@ class Local extends \OC\Files\Storage\Common{
$files[]=$dir.'/'.$item;
}
if(is_dir($this->datadir.$dir.'/'.$item)) {
- $files=array_merge($files,$this->searchInDir($query,$dir.'/'.$item));
+ $files=array_merge($files, $this->searchInDir($query, $dir.'/'.$item));
}
}
return $files;
@@ -202,7 +202,7 @@ class Local extends \OC\Files\Storage\Common{
* @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/view.php b/lib/files/view.php
index c5e470b438e..709e374d863 100644
--- a/lib/files/view.php
+++ b/lib/files/view.php
@@ -34,7 +34,7 @@ class View {
$this->fakeRoot = $root;
}
- public function getAbsolutePath($path) {
+ public function getAbsolutePath($path = '/') {
if (!$path) {
$path = '/';
}
diff --git a/lib/installer.php b/lib/installer.php
index 266c07d5c2b..7dc8b0cef8d 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -57,7 +57,7 @@ class OC_Installer{
*/
public static function installApp( $data = array()) {
if(!isset($data['source'])) {
- OC_Log::write('core','No source specified when installing app', OC_Log::ERROR);
+ OC_Log::write('core', 'No source specified when installing app', OC_Log::ERROR);
return false;
}
@@ -65,13 +65,13 @@ class OC_Installer{
if($data['source']=='http') {
$path=OC_Helper::tmpFile();
if(!isset($data['href'])) {
- OC_Log::write('core','No href specified when installing app from http', OC_Log::ERROR);
+ OC_Log::write('core', 'No href specified when installing app from http', OC_Log::ERROR);
return false;
}
copy($data['href'], $path);
}else{
if(!isset($data['path'])) {
- OC_Log::write('core','No path specified when installing app from local file', OC_Log::ERROR);
+ OC_Log::write('core', 'No path specified when installing app from local file', OC_Log::ERROR);
return false;
}
$path=$data['path'];
@@ -86,7 +86,7 @@ class OC_Installer{
rename($path, $path.'.tgz');
$path.='.tgz';
}else{
- OC_Log::write('core','Archives of type '.$mime.' are not supported', OC_Log::ERROR);
+ OC_Log::write('core', 'Archives of type '.$mime.' are not supported', OC_Log::ERROR);
return false;
}
diff --git a/lib/log.php b/lib/log.php
index b5e8e1b06a1..e9cededa5c0 100644
--- a/lib/log.php
+++ b/lib/log.php
@@ -47,7 +47,7 @@ class OC_Log {
//ob_end_clean();
self::write('PHP', $error['message'] . ' at ' . $error['file'] . '#' . $error['line'], self::FATAL);
} else {
- return true;
+ return true;
}
}
diff --git a/lib/migrate.php b/lib/migrate.php
index 616417a2271..96f5a0001f7 100644
--- a/lib/migrate.php
+++ b/lib/migrate.php
@@ -611,7 +611,7 @@ class OC_Migrate{
if( file_exists( $db ) ) {
// Connect to the db
if(!self::connectDB( $db )) {
- OC_Log::write('migration','Failed to connect to migration.db', OC_Log::ERROR);
+ OC_Log::write('migration', 'Failed to connect to migration.db', OC_Log::ERROR);
return false;
}
} else {
diff --git a/lib/migration/content.php b/lib/migration/content.php
index 54982b3c847..00df62f0c7f 100644
--- a/lib/migration/content.php
+++ b/lib/migration/content.php
@@ -205,7 +205,7 @@ class OC_Migration_Content{
}
closedir($dirhandle);
} else {
- OC_Log::write('admin_export',"Was not able to open directory: " . $dir, OC_Log::ERROR);
+ OC_Log::write('admin_export', "Was not able to open directory: " . $dir, OC_Log::ERROR);
return false;
}
return true;
diff --git a/lib/ocsclient.php b/lib/ocsclient.php
index ceeb78570fd..b6b5ad8f0a9 100644
--- a/lib/ocsclient.php
+++ b/lib/ocsclient.php
@@ -162,7 +162,7 @@ class OC_OCSClient{
$xml=OC_OCSClient::getOCSresponse($url);
if($xml==false) {
- OC_Log::write('core','Unable to parse OCS content', OC_Log::FATAL);
+ OC_Log::write('core', 'Unable to parse OCS content', OC_Log::FATAL);
return null;
}
$data=simplexml_load_string($xml);
@@ -200,7 +200,7 @@ class OC_OCSClient{
$xml=OC_OCSClient::getOCSresponse($url);
if($xml==false) {
- OC_Log::write('core','Unable to parse OCS content', OC_Log::FATAL);
+ OC_Log::write('core', 'Unable to parse OCS content', OC_Log::FATAL);
return null;
}
$data=simplexml_load_string($xml);
@@ -238,7 +238,7 @@ class OC_OCSClient{
$xml=OC_OCSClient::getOCSresponse($url);
if($xml==false) {
- OC_Log::write('core','Unable to parse knowledgebase content', OC_Log::FATAL);
+ OC_Log::write('core', 'Unable to parse knowledgebase content', OC_Log::FATAL);
return null;
}
$data=simplexml_load_string($xml);
diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php
index 24a17836f7f..601046fe691 100644
--- a/lib/public/backgroundjob.php
+++ b/lib/public/backgroundjob.php
@@ -62,7 +62,7 @@ class BackgroundJob {
* @param $type execution type
* @return boolean
*
- * This method sets the execution type of the background jobs. Possible types
+ * This method sets the execution type of the background jobs. Possible types
* are "none", "ajax", "webcron", "cron"
*/
public static function setExecutionType( $type ) {
diff --git a/lib/public/share.php b/lib/public/share.php
index 707d5abe440..dd1aac609a5 100644
--- a/lib/public/share.php
+++ b/lib/public/share.php
@@ -28,7 +28,7 @@ namespace OCP;
/**
* This class provides the ability for apps to share their content between users.
* Apps must create a backend class that implements OCP\Share_Backend and register it with this class.
-*
+*
* It provides the following hooks:
* - post_shared
*/
diff --git a/lib/public/util.php b/lib/public/util.php
index 6ce79715b6f..7b5b1abbded 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -61,7 +61,7 @@ class Util {
*/
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=0, $altbody='', $ccaddress='', $ccname='', $bcc='');
+ \OC_MAIL::send($toaddress, $toname, $subject, $mailtext, $fromaddress, $fromname, $html = 0, $altbody = '', $ccaddress = '', $ccname = '', $bcc = '');
}
/**
diff --git a/lib/template.php b/lib/template.php
index efcc6e82c4c..3d3589abd1e 100644
--- a/lib/template.php
+++ b/lib/template.php
@@ -199,7 +199,7 @@ 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';
diff --git a/lib/user.php b/lib/user.php
index be0e525d868..801ab7f608d 100644
--- a/lib/user.php
+++ b/lib/user.php
@@ -133,7 +133,7 @@ class OC_User {
self::useBackend($backend);
$_setupedBackends[]=$i;
}else{
- OC_Log::write('core','User backend '.$class.' not found.', OC_Log::ERROR);
+ OC_Log::write('core', 'User backend '.$class.' not found.', OC_Log::ERROR);
}
}
}
diff --git a/lib/util.php b/lib/util.php
index 9b8eb13ca2c..8e6eb6ca032 100755
--- a/lib/util.php
+++ b/lib/util.php
@@ -572,7 +572,7 @@ class OC_Util {
// creating a test file
$testfile = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" ).'/'.$filename;
- if(file_exists($testfile)){// already running this test, possible recursive call
+ if(file_exists($testfile)) {// already running this test, possible recursive call
return false;
}