Skip to content
Snippets Groups Projects
Commit 52f2e711 authored by Bart Visscher's avatar Bart Visscher
Browse files

Whitespace fixes in lib

parent 76bc4753
No related branches found
No related tags found
No related merge requests found
Showing
with 81 additions and 84 deletions
......@@ -100,7 +100,7 @@ class OC_Appconfig{
return $default;
}
}
/**
* @brief check if a key is set in the appconfig
* @param string $app
......@@ -111,7 +111,7 @@ class OC_Appconfig{
$exists = self::getKeys( $app );
return in_array( $key, $exists );
}
/**
* @brief sets a value in the appconfig
* @param $app app
......@@ -163,7 +163,7 @@ class OC_Appconfig{
return true;
}
/**
* get multiply values, either the app or key can be used as wildcard by setting it to false
* @param app
......
......@@ -28,7 +28,7 @@ abstract class OC_Archive{
return new OC_Archive_TAR($path);
}
}
abstract function __construct($source);
/**
* add an empty folder to the archive
......
......@@ -14,7 +14,7 @@ class OC_Archive_TAR extends OC_Archive{
const BZIP=2;
private $fileList;
/**
* @var Archive_Tar tar
*/
......@@ -127,7 +127,7 @@ class OC_Archive_TAR extends OC_Archive{
}
return null;
}
/**
* get the uncompressed size of a file in the archive
* @param string path
......@@ -254,7 +254,7 @@ class OC_Archive_TAR extends OC_Archive{
return false;
}
}
/**
* remove a file or folder from the archive
* @param string path
......
......@@ -12,7 +12,7 @@ class OC_Archive_ZIP extends OC_Archive{
*/
private $zip=null;
private $path;
function __construct($source){
$this->path=$source;
$this->zip=new ZipArchive();
......
......@@ -22,7 +22,7 @@
/**
* This class does the dirty work.
*
*
* TODO: locking in doAllSteps
*/
class OC_BackgroundJob_Worker{
......@@ -56,7 +56,7 @@ class OC_BackgroundJob_Worker{
OC_BackgroundJob_QueuedTask::delete( $task['id'] );
call_user_func( array( $task['klass'], $task['method'] ), $task['parameters'] );
}
return true;
}
......@@ -70,7 +70,7 @@ class OC_BackgroundJob_Worker{
*/
public static function doNextStep(){
$laststep = OC_Appconfig::getValue( 'core', 'backgroundjobs_step', 'regular_tasks' );
if( $laststep == 'regular_tasks' ){
// get last app
$lasttask = OC_Appconfig::getValue( 'core', 'backgroundjobs_task', '' );
......@@ -79,7 +79,7 @@ class OC_BackgroundJob_Worker{
$regular_tasks = OC_BackgroundJob_RegularTask::all();
ksort( $regular_tasks );
$done = false;
// search for next background job
foreach( $regular_tasks as $key => $value ){
if( strcmp( $key, $lasttask ) > 0 ){
......@@ -112,7 +112,7 @@ class OC_BackgroundJob_Worker{
OC_Appconfig::setValue( 'core', 'backgroundjobs_task', '' );
}
}
return true;
}
}
......@@ -239,7 +239,7 @@ class OC{
OC_Util::addScript( 'backgroundjobs' );
}
}
OC_Util::addStyle( "styles" );
OC_Util::addStyle( "multiselect" );
OC_Util::addStyle( "jquery-ui-1.8.16.custom" );
......@@ -473,7 +473,7 @@ class OC{
// Someone wants to log in :
} elseif (OC::tryFormLogin()) {
$error = true;
// The user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
} elseif (OC::tryBasicAuthLogin()) {
$error = true;
......
......@@ -38,7 +38,7 @@ class OC_Cache {
if (!self::$global_cache_fast && function_exists('apc_store')) {
self::$global_cache_fast = new OC_Cache_APC(true);
}
self::$global_cache = new OC_Cache_FileGlobal();
if (self::$global_cache_fast) {
self::$global_cache = new OC_Cache_Broker(self::$global_cache_fast, self::$global_cache);
......@@ -67,7 +67,7 @@ class OC_Cache {
if (!self::$user_cache_fast && function_exists('apc_store')) {
self::$user_cache_fast = new OC_Cache_APC();
}
self::$user_cache = new OC_Cache_File();
if (self::$user_cache_fast) {
self::$user_cache = new OC_Cache_Broker(self::$user_cache_fast, self::$user_cache);
......
......@@ -45,4 +45,4 @@ class OC_Connector_Sabre_Auth extends Sabre_DAV_Auth_Backend_AbstractBasic {
}
}
}
}
}
......@@ -203,4 +203,3 @@ class OC_Connector_Sabre_Directory extends OC_Connector_Sabre_Node implements Sa
return $props;
}
}
......@@ -126,4 +126,3 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
}
}
......@@ -42,7 +42,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
// pure sql. MySQL's non-standard string concatination prevents us
// from doing this though.
// NOTE: SQLite requires time() to be inserted directly. That's ugly
// but otherwise reading locks from SQLite Databases will return
// but otherwise reading locks from SQLite Databases will return
// nothing
$query = 'SELECT * FROM `*PREFIX*locks` WHERE `userid` = ? AND (`created` + `timeout`) > '.time().' AND (( `uri` = ?)';
$params = array(OC_User::getUser(),$uri);
......@@ -75,7 +75,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
$stmt = OC_DB::prepare( $query );
$result = $stmt->execute( $params );
$lockList = array();
while( $row = $result->fetchRow()){
......@@ -114,7 +114,7 @@ class OC_Connector_Sabre_Locks extends Sabre_DAV_Locks_Backend_Abstract {
foreach($locks as $lock) {
if ($lock->token == $lockInfo->token) $exists = true;
}
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));
......
......@@ -80,9 +80,9 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
$oldPath = $this->path;
OC_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 ));
......@@ -123,8 +123,8 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
}
/**
* sets the last modification time of the file (mtime) to the value given
/**
* sets the last modification time of the file (mtime) to the value given
* in the second parameter or to now if the second param is empty.
* Even if the modification time is set to a custom value the access time is set to now.
*/
......@@ -195,7 +195,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
if(count($properties) == 0){
return $this->property_cache;
}
$props = array();
foreach($properties as $property) {
if (isset($this->property_cache[$property])) $props[$property] = $this->property_cache[$property];
......
......@@ -27,7 +27,7 @@
class OC_DB {
const BACKEND_PDO=0;
const BACKEND_MDB2=1;
static private $connection; //the prefered connection to use, either PDO or MDB2
static private $backend=null;
static private $MDB2=false;
......@@ -55,7 +55,7 @@ class OC_DB {
}
return self::BACKEND_MDB2;
}
/**
* @brief connects to the database
* @returns true if connection can be established or nothing (die())
......@@ -104,7 +104,7 @@ class OC_DB {
}
$opts = array();
$datadir=OC_Config::getValue( "datadirectory", OC::$SERVERROOT.'/data' );
// do nothing if the connection already has been established
if(!self::$PDO){
// Add the dsn according to the database type
......@@ -158,7 +158,7 @@ class OC_DB {
}
return true;
}
/**
* connect to the database using mdb2
*/
......@@ -234,10 +234,10 @@ class OC_DB {
}
break;
}
// Try to establish connection
self::$MDB2 = MDB2::factory( $dsn, $options );
// Die if we could not connect
if( PEAR::isError( self::$MDB2 )){
echo( '<b>can not connect to database, using '.$type.'. ('.self::$MDB2->getUserInfo().')</center>');
......@@ -245,11 +245,11 @@ class OC_DB {
OC_Log::write('core',self::$MDB2->getMessage(),OC_Log::FATAL);
die( $error );
}
// We always, really always want associative arrays
self::$MDB2->setFetchMode(MDB2_FETCHMODE_ASSOC);
}
// we are done. great!
return true;
}
......@@ -262,7 +262,7 @@ class OC_DB {
* SQL query via MDB2 prepare(), needs to be execute()'d!
*/
static public function prepare( $query , $limit=null, $offset=null ){
if (!is_null($limit) && $limit != -1) {
if (self::$backend == self::BACKEND_MDB2) {
//MDB2 uses or emulates limits & offset internally
......@@ -394,7 +394,7 @@ class OC_DB {
// read file
$content = file_get_contents( $file );
// Make changes and save them to an in-memory file
$file2 = 'static://db_scheme';
$content = str_replace( '*dbname*', $CONFIG_DBNAME, $content );
......@@ -414,7 +414,7 @@ class OC_DB {
// Try to create tables
$definition = self::$schema->parseDatabaseDefinitionFile( $file2 );
//clean up memory
unlink( $file2 );
......@@ -427,7 +427,7 @@ class OC_DB {
$oldname = $definition['name'];
$definition['name']=OC_Config::getValue( "dbuser", $oldname );
}
$ret=self::$schema->createDatabase( $definition );
// Die in case something went wrong
......@@ -438,7 +438,7 @@ class OC_DB {
return true;
}
/**
* @brief update the database scheme
* @param $file file to read structure from
......@@ -451,7 +451,7 @@ class OC_DB {
// read file
$content = file_get_contents( $file );
$previousSchema = self::$schema->getDefinitionFromDatabase();
if (PEAR::isError($previousSchema)) {
$error = $previousSchema->getMessage();
......@@ -475,10 +475,10 @@ class OC_DB {
*/
file_put_contents( $file2, $content );
$op = self::$schema->updateDatabase($file2, $previousSchema, array(), false);
//clean up memory
unlink( $file2 );
if (PEAR::isError($op)) {
$error = $op->getMessage();
$detail = $op->getDebugInfo();
......@@ -528,7 +528,7 @@ class OC_DB {
self::$prefix=OC_Config::getValue( "dbtableprefix", "oc_" );
}
$prefix = self::$prefix;
// differences in escaping of table names ('`' for mysql) and getting the current timestamp
if( $type == 'sqlite' || $type == 'sqlite3' ){
$query = str_replace( '`', '"', $query );
......@@ -547,7 +547,7 @@ class OC_DB {
return $query;
}
/**
* @brief drop a table
* @param string $tableNamme the table to drop
......@@ -557,7 +557,7 @@ class OC_DB {
self::$MDB2->loadModule('Manager');
self::$MDB2->dropTable($tableName);
}
/**
* remove all tables defined in a database structure xml file
* @param string $file the xml file describing the tables
......@@ -578,7 +578,7 @@ class OC_DB {
// get the tables
$definition = self::$schema->parseDatabaseDefinitionFile( $file2 );
// Delete our temporary file
unlink( $file2 );
$tables=array_keys($definition['tables']);
......@@ -586,7 +586,7 @@ class OC_DB {
self::dropTable($table);
}
}
/**
* @brief replaces the owncloud tables with a new set
* @param $file string path to the MDB2 xml db export file
......@@ -596,20 +596,20 @@ class OC_DB {
self::beginTransaction();
// Delete the old tables
self::removeDBStructure( OC::$SERVERROOT . '/db_structure.xml' );
foreach($apps as $app){
$path = OC_App::getAppPath($app).'/appinfo/database.xml';
if(file_exists($path)){
self::removeDBStructure( $path );
self::removeDBStructure( $path );
}
}
// Create new tables
self::createDBFromStructure( $file );
self::commit();
}
/**
* Start a transaction
*/
......@@ -660,7 +660,7 @@ class PDOStatementWrapper{
public function __construct($statement){
$this->statement=$statement;
}
/**
* make execute return the result instead of a bool
*/
......@@ -677,7 +677,7 @@ class PDOStatementWrapper{
return false;
}
}
/**
* provide numRows
*/
......@@ -690,21 +690,21 @@ class PDOStatementWrapper{
return $this->statement->rowCount();
}
}
/**
* provide an alias for fetch
*/
public function fetchRow(){
return $this->statement->fetch();
}
/**
* pass all other function directly to the PDOStatement
*/
public function __call($name,$arguments){
return call_user_func_array(array($this->statement,$name),$arguments);
}
/**
* Provide a simple fetchOne.
* fetch single column from the next row
......@@ -714,4 +714,3 @@ class PDOStatementWrapper{
return $this->statement->fetchColumn($colnum);
}
}
......@@ -30,7 +30,7 @@
class OC_EventSource{
private $fallback;
private $fallBackId=0;
public function __construct(){
@ob_end_clean();
header('Cache-Control: no-cache');
......
......@@ -76,14 +76,14 @@ class OC_FileCache{
self::update($id,$data);
return;
}
// add parent directory to the file cache if it does not exist yet.
if ($parent == -1 && $fullpath != $root) {
$parentDir = substr(dirname($path), 0, strrpos(dirname($path), DIRECTORY_SEPARATOR));
self::scanFile($parentDir);
$parent = self::getParentId($fullpath);
}
if(!isset($data['size']) or !isset($data['mtime'])){//save incomplete data for the next time we write it
OC_FileCache_Cached::$savedData[$fullpath]=$data;
return;
......@@ -136,7 +136,7 @@ class OC_FileCache{
$queryParts[]='`mimepart`=?';
}
$arguments[]=$id;
$sql = 'UPDATE `*PREFIX*fscache` SET '.implode(' , ',$queryParts).' WHERE `id`=?';
$query=OC_DB::prepare($sql);
$result=$query->execute($arguments);
......@@ -192,14 +192,14 @@ class OC_FileCache{
}
$query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE `path_hash`=?');
$query->execute(array(md5($root.$path)));
//delete everything inside the folder
$query=OC_DB::prepare('DELETE FROM `*PREFIX*fscache` WHERE `path` LIKE ?');
$query->execute(array($root.$path.'/%'));
OC_Cache::remove('fileid/'.$root.$path);
}
/**
* return array of filenames matching the querty
* @param string $query
......@@ -277,14 +277,14 @@ class OC_FileCache{
if(($cache=OC_Cache::getUserCache(true)) && $cache->hasKey('fileid/'.$fullPath)){
return $cache->get('fileid/'.$fullPath);
}
$query=OC_DB::prepare('SELECT `id` FROM `*PREFIX*fscache` WHERE `path_hash`=?');
$result=$query->execute(array(md5($fullPath)));
if(OC_DB::isError($result)){
OC_Log::write('files','error while getting file id of '.$path,OC_Log::ERROR);
return -1;
}
$result=$result->fetchRow();
if(is_array($result)){
$id=$result['id'];
......@@ -294,10 +294,10 @@ class OC_FileCache{
if($cache=OC_Cache::getUserCache(true)){
$cache->set('fileid/'.$fullPath,$id);
}
return $id;
}
/**
* get the file path from the id, relative to the home folder of the user
* @param int id
......@@ -331,7 +331,7 @@ class OC_FileCache{
return self::getId(dirname($path),'');
}
}
/**
* adjust the size of the parent folders
* @param string $path
......@@ -390,7 +390,7 @@ class OC_FileCache{
}
}
}
OC_FileCache_Update::cleanFolder($path,$root);
self::increaseSize($path,$totalSize,$root);
}
......
......@@ -12,7 +12,7 @@
*/
class OC_FileCache_Cached{
public static $savedData=array();
public static function get($path,$root=false){
if($root===false){
$root=OC_Filesystem::getRoot();
......
......@@ -42,7 +42,7 @@ class OC_FileCache_Update{
return true;
}
}
/**
* delete non existing files from the cache
*/
......@@ -148,7 +148,7 @@ class OC_FileCache_Update{
}
$mimetype=$view->getMimeType($path);
$size=0;
$cached=OC_FileCache_Cached::get($path,$root);
$cachedSize=isset($cached['size'])?$cached['size']:0;
......
......@@ -43,7 +43,7 @@
class OC_FileProxy{
private static $proxies=array();
public static $enabled=true;
/**
* fallback function when a proxy operation is not implemented
* @param string $function the name of the proxy operation
......@@ -58,7 +58,7 @@ class OC_FileProxy{
return $arguments[1];
}
}
/**
* register a proxy to be used
* @param OC_FileProxy $proxy
......@@ -66,7 +66,7 @@ class OC_FileProxy{
public static function register($proxy){
self::$proxies[]=$proxy;
}
public static function getProxies($operation){
$proxies=array();
foreach(self::$proxies as $proxy){
......
......@@ -27,7 +27,7 @@
class OC_FileProxy_Quota extends OC_FileProxy{
private $userQuota=-1;
/**
* get the quota for the current user
* @return int
......@@ -46,9 +46,9 @@ class OC_FileProxy_Quota extends OC_FileProxy{
$this->userQuota=OC_Helper::computerFileSize($userQuota);
}
return $this->userQuota;
}
/**
* get the free space in the users home folder
* @return int
......@@ -69,7 +69,7 @@ class OC_FileProxy_Quota extends OC_FileProxy{
}
return $totalSpace-$usedSpace;
}
public function postFree_space($path,$space){
$free=$this->getFreeSpace();
if($free==0){
......
......@@ -406,9 +406,9 @@ class OC_Files {
//check for write permissions
if(is_writable(OC::$SERVERROOT.'/.htaccess')) {
file_put_contents(OC::$SERVERROOT.'/.htaccess', $htaccess);
return OC_Helper::computerFileSize($size);
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); }
return false;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment