summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private')
-rwxr-xr-xlib/private/activitymanager.php1
-rw-r--r--lib/private/allconfig.php4
-rw-r--r--lib/private/api.php3
-rw-r--r--lib/private/app.php13
-rw-r--r--lib/private/appconfig.php204
-rw-r--r--lib/private/appframework/app.php1
-rw-r--r--lib/private/appframework/dependencyinjection/dicontainer.php3
-rw-r--r--lib/private/appframework/http.php2
-rw-r--r--lib/private/appframework/http/redirectresponse.php4
-rw-r--r--lib/private/appframework/http/request.php2
-rw-r--r--lib/private/appframework/middleware/middlewaredispatcher.php2
-rw-r--r--lib/private/appframework/middleware/security/securityexception.php1
-rw-r--r--lib/private/appframework/middleware/security/securitymiddleware.php2
-rw-r--r--lib/private/appframework/routing/routeactionhandler.php4
-rw-r--r--lib/private/appframework/routing/routeconfig.php1
-rw-r--r--lib/private/appframework/utility/simplecontainer.php2
-rw-r--r--lib/private/archive.php37
-rw-r--r--lib/private/archive/tar.php41
-rw-r--r--lib/private/archive/zip.php44
-rw-r--r--lib/private/arrayparser.php27
-rw-r--r--lib/private/backgroundjob.php4
-rw-r--r--lib/private/backgroundjob/job.php4
-rw-r--r--lib/private/backgroundjob/joblist.php80
-rw-r--r--lib/private/cache/file.php9
-rw-r--r--lib/private/cache/fileglobal.php12
-rw-r--r--lib/private/cache/usercache.php2
-rw-r--r--lib/private/config.php2
-rw-r--r--lib/private/connector/sabre/aborteduploaddetectionplugin.php2
-rw-r--r--lib/private/connector/sabre/file.php13
-rw-r--r--lib/private/connector/sabre/node.php14
-rw-r--r--lib/private/connector/sabre/objecttree.php5
-rw-r--r--lib/private/connector/sabre/principal.php2
-rw-r--r--lib/private/connector/sabre/quotaplugin.php2
-rw-r--r--lib/private/connector/sabre/server.php1
-rw-r--r--lib/private/davclient.php2
-rw-r--r--lib/private/db.php15
-rw-r--r--lib/private/db/connection.php2
-rw-r--r--lib/private/db/connectionwrapper.php4
-rw-r--r--lib/private/db/mdb2schemamanager.php2
-rw-r--r--lib/private/db/mdb2schemareader.php3
-rw-r--r--lib/private/db/mdb2schemawriter.php11
-rw-r--r--lib/private/db/statementwrapper.php20
-rw-r--r--lib/private/defaults.php3
-rw-r--r--lib/private/filechunking.php12
-rw-r--r--lib/private/fileproxy.php13
-rw-r--r--lib/private/files.php25
-rw-r--r--lib/private/files/cache/backgroundwatcher.php3
-rw-r--r--lib/private/files/cache/cache.php2
-rw-r--r--lib/private/files/cache/homecache.php3
-rw-r--r--lib/private/files/cache/legacy.php5
-rw-r--r--lib/private/files/cache/storage.php25
-rw-r--r--lib/private/files/cache/updater.php4
-rw-r--r--lib/private/files/cache/watcher.php46
-rw-r--r--lib/private/files/fileinfo.php189
-rw-r--r--lib/private/files/filesystem.php28
-rw-r--r--lib/private/files/mapper.php18
-rw-r--r--lib/private/files/mount/manager.php2
-rw-r--r--lib/private/files/node/folder.php1
-rw-r--r--lib/private/files/node/node.php4
-rw-r--r--lib/private/files/node/root.php5
-rw-r--r--lib/private/files/storage/common.php19
-rw-r--r--lib/private/files/storage/loader.php7
-rw-r--r--lib/private/files/storage/local.php16
-rw-r--r--lib/private/files/storage/mappedlocal.php19
-rw-r--r--lib/private/files/storage/wrapper/quota.php3
-rw-r--r--lib/private/files/storage/wrapper/wrapper.php8
-rw-r--r--lib/private/files/stream/close.php3
-rw-r--r--lib/private/files/stream/dir.php3
-rw-r--r--lib/private/files/utils/scanner.php6
-rw-r--r--lib/private/files/view.php50
-rw-r--r--lib/private/geo.php4
-rw-r--r--lib/private/group.php2
-rw-r--r--lib/private/group/dummy.php2
-rw-r--r--lib/private/group/manager.php14
-rw-r--r--lib/private/helper.php48
-rw-r--r--lib/private/hooks/emitter.php2
-rw-r--r--lib/private/image.php18
-rw-r--r--lib/private/installer.php29
-rw-r--r--lib/private/json.php1
-rw-r--r--lib/private/l10n.php10
-rw-r--r--lib/private/l10n/string.php3
-rw-r--r--lib/private/legacy/appconfig.php128
-rw-r--r--lib/private/legacy/preferences.php2
-rw-r--r--lib/private/mail.php2
-rw-r--r--lib/private/memcache/factory.php2
-rw-r--r--lib/private/migrate.php118
-rw-r--r--lib/private/migration/content.php54
-rw-r--r--lib/private/migration/provider.php2
-rw-r--r--lib/private/mimetypes.list.php147
-rw-r--r--lib/private/ocs.php18
-rw-r--r--lib/private/ocs/result.php18
-rw-r--r--lib/private/ocsclient.php4
-rw-r--r--lib/private/preferences.php125
-rwxr-xr-xlib/private/preview.php10
-rw-r--r--lib/private/preview/office.php2
-rw-r--r--lib/private/preview/pdf.php2
-rw-r--r--lib/private/preview/provider.php2
-rw-r--r--lib/private/preview/svg.php2
-rw-r--r--lib/private/preview/unknown.php2
-rwxr-xr-xlib/private/request.php13
-rw-r--r--lib/private/response.php6
-rw-r--r--lib/private/search.php1
-rw-r--r--lib/private/search/result.php1
-rw-r--r--lib/private/server.php28
-rw-r--r--lib/private/session/memory.php2
-rw-r--r--lib/private/setup.php9
-rw-r--r--lib/private/share/mailnotifications.php160
-rw-r--r--lib/private/share/searchresultsorter.php59
-rw-r--r--lib/private/tags.php11
-rw-r--r--lib/private/template.php7
-rw-r--r--lib/private/template/base.php20
-rw-r--r--lib/private/template/functions.php5
-rw-r--r--lib/private/template/resourcelocator.php8
-rw-r--r--lib/private/template/templatefilelocator.php7
-rw-r--r--lib/private/templatelayout.php4
-rw-r--r--lib/private/urlgenerator.php3
-rw-r--r--lib/private/user.php13
-rw-r--r--lib/private/user/database.php4
-rw-r--r--lib/private/user/dummy.php2
-rw-r--r--lib/private/user/http.php2
-rw-r--r--lib/private/user/interface.php2
-rw-r--r--lib/private/user/manager.php4
-rw-r--r--lib/private/user/session.php3
-rwxr-xr-xlib/private/util.php41
124 files changed, 1672 insertions, 647 deletions
diff --git a/lib/private/activitymanager.php b/lib/private/activitymanager.php
index 7e7e2257874..685809581ac 100755
--- a/lib/private/activitymanager.php
+++ b/lib/private/activitymanager.php
@@ -59,7 +59,6 @@ class ActivityManager implements IManager {
*
* $callable has to return an instance of OCA\Activity\IConsumer
*
- * @param string $key
* @param \Closure $callable
*/
function registerConsumer(\Closure $callable) {
diff --git a/lib/private/allconfig.php b/lib/private/allconfig.php
index a4aa69d43fb..de3ac973637 100644
--- a/lib/private/allconfig.php
+++ b/lib/private/allconfig.php
@@ -17,7 +17,7 @@ class AllConfig implements \OCP\IConfig {
* Sets a new system wide value
*
* @param string $key the key of the value, under which will be saved
- * @param string $value the value that should be stored
+ * @param mixed $value the value that should be stored
* @todo need a use case for this
*/
// public function setSystemValue($key, $value) {
@@ -28,7 +28,7 @@ class AllConfig implements \OCP\IConfig {
* Looks up a system wide defined value
*
* @param string $key the key of the value, under which it was saved
- * @param string $default the default value to be returned if the value isn't set
+ * @param mixed $default the default value to be returned if the value isn't set
* @return string the saved value
*/
public function getSystemValue($key, $default = '') {
diff --git a/lib/private/api.php b/lib/private/api.php
index c713368125c..3f96196e6df 100644
--- a/lib/private/api.php
+++ b/lib/private/api.php
@@ -328,6 +328,9 @@ class OC_API {
}
}
+ /**
+ * @param XMLWriter $writer
+ */
private static function toXML($array, $writer) {
foreach($array as $k => $v) {
if ($k[0] === '@') {
diff --git a/lib/private/app.php b/lib/private/app.php
index da09021cf3f..47f983cce35 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -38,7 +38,7 @@ class OC_App{
/**
* @brief clean the appid
- * @param $app Appid that needs to be cleaned
+ * @param string|boolean $app Appid that needs to be cleaned
* @return string
*/
public static function cleanAppId($app) {
@@ -261,7 +261,7 @@ class OC_App{
/**
* @brief disables an app
* @param string $app app
- * @return bool
+ * @return boolean|null
*
* This function set an app as disabled in appconfig.
*/
@@ -342,7 +342,7 @@ class OC_App{
/**
* @brief Returns the Settings Navigation
- * @return array
+ * @return string
*
* This function returns an array containing all settings pages added. The
* entries are sorted by the key 'order' ascending.
@@ -437,6 +437,7 @@ class OC_App{
/**
* Get the path where to install apps
+ * @return string
*/
public static function getInstallPath() {
if(OC_Config::getValue('appstoreenabled', true)==false) {
@@ -490,6 +491,7 @@ class OC_App{
/**
* get the last version of the app, either from appinfo/version or from appinfo/info.xml
+ * @return string
*/
public static function getAppVersion($appid) {
$file= self::getAppPath($appid).'/appinfo/version';
@@ -570,7 +572,7 @@ class OC_App{
/**
* @brief Returns the navigation
- * @return array
+ * @return string
*
* This function returns an array containing all entries added. The
* entries are sorted by the key 'order' ascending. Additional to the keys
@@ -638,6 +640,8 @@ class OC_App{
/**
* register an admin form to be shown
+ * @param string $app
+ * @param string $page
*/
public static function registerAdmin($app, $page) {
self::$adminForms[]= $app.'/'.$page.'.php';
@@ -854,6 +858,7 @@ class OC_App{
/**
* check if the app needs updating and update when needed
+ * @param string $app
*/
public static function checkUpgrade($app) {
if (in_array($app, self::$checkedApps)) {
diff --git a/lib/private/appconfig.php b/lib/private/appconfig.php
index da0b2ff8604..cdaaebb87e5 100644
--- a/lib/private/appconfig.php
+++ b/lib/private/appconfig.php
@@ -33,15 +33,59 @@
*
*/
+namespace OC;
+
+use \OC\DB\Connection;
+
/**
* This class provides an easy way for apps to store config values in the
* database.
*/
-class OC_Appconfig {
+class AppConfig implements \OCP\IAppConfig {
+ /**
+ * @var \OC\DB\Connection $conn
+ */
+ protected $conn;
+
+ private $cache = array();
- private static $cache = array();
+ private $appsLoaded = array();
- private static $appsLoaded = array();
+ /**
+ * @param \OC\DB\Connection $conn
+ */
+ public function __construct(Connection $conn) {
+ $this->conn = $conn;
+ }
+
+ /**
+ * @param string $app
+ * @return string[]
+ */
+ private function getAppCache($app) {
+ if (!isset($this->cache[$app])) {
+ $this->cache[$app] = array();
+ }
+ return $this->cache[$app];
+ }
+
+ /**
+ * @param string $app
+ */
+ private function getAppValues($app) {
+ $appCache = $this->getAppCache($app);
+ if (array_search($app, $this->appsLoaded) === false) {
+ $query = 'SELECT `configvalue`, `configkey` FROM `*PREFIX*appconfig`'
+ . ' WHERE `appid` = ?';
+ $result = $this->conn->executeQuery($query, array($app));
+ while ($row = $result->fetch()) {
+ $appCache[$row['configkey']] = $row['configvalue'];
+ }
+ $this->appsLoaded[] = $app;
+ }
+ $this->cache[$app] = $appCache;
+ return $appCache;
+ }
/**
* @brief Get all apps using the config
@@ -50,16 +94,14 @@ class OC_Appconfig {
* This function returns a list of all apps that have at least one
* entry in the appconfig table.
*/
- public static function getApps() {
- // No magic in here!
- $query = OC_DB::prepare('SELECT DISTINCT `appid` FROM `*PREFIX*appconfig` ORDER BY `appid`');
- $result = $query->execute();
+ public function getApps() {
+ $query = 'SELECT DISTINCT `appid` FROM `*PREFIX*appconfig` ORDER BY `appid`';
+ $result = $this->conn->executeQuery($query);
$apps = array();
- while ($row = $result->fetchRow()) {
- $apps[] = $row["appid"];
+ while ($appid = $result->fetchColumn()) {
+ $apps[] = $appid;
}
-
return $apps;
}
@@ -71,35 +113,13 @@ class OC_Appconfig {
* This function gets all keys of an app. Please note that the values are
* not returned.
*/
- public static function getKeys($app) {
- // No magic in here as well
- $query = OC_DB::prepare('SELECT `configkey` FROM `*PREFIX*appconfig` WHERE `appid` = ?');
- $result = $query->execute(array($app));
-
- $keys = array();
- while ($row = $result->fetchRow()) {
- $keys[] = $row["configkey"];
- }
-
+ public function getKeys($app) {
+ $values = $this->getAppValues($app);
+ $keys = array_keys($values);
+ sort($keys);
return $keys;
}
- private static function getAppValues($app) {
- if (!isset(self::$cache[$app])) {
- self::$cache[$app] = array();
- }
- if (array_search($app, self::$appsLoaded) === false) {
- $query = OC_DB::prepare('SELECT `configvalue`, `configkey` FROM `*PREFIX*appconfig`'
- . ' WHERE `appid` = ?');
- $result = $query->execute(array($app));
- while ($row = $result->fetchRow()) {
- self::$cache[$app][$row['configkey']] = $row['configvalue'];
- }
- self::$appsLoaded[] = $app;
- }
- return self::$cache[$app];
- }
-
/**
* @brief Gets the config value
* @param string $app app
@@ -110,18 +130,11 @@ class OC_Appconfig {
* This function gets a value from the appconfig table. If the key does
* not exist the default value will be returned
*/
- public static function getValue($app, $key, $default = null) {
- if (!isset(self::$cache[$app])) {
- self::$cache[$app] = array();
- }
- if (isset(self::$cache[$app][$key])) {
- return self::$cache[$app][$key];
- }
- $values = self::getAppValues($app);
+ public function getValue($app, $key, $default = null) {
+ $values = $this->getAppValues($app);
if (isset($values[$key])) {
return $values[$key];
} else {
- self::$cache[$app][$key] = $default;
return $default;
}
}
@@ -132,12 +145,9 @@ class OC_Appconfig {
* @param string $key
* @return bool
*/
- public static function hasKey($app, $key) {
- if (isset(self::$cache[$app]) and isset(self::$cache[$app][$key])) {
- return true;
- }
- $exists = self::getKeys($app);
- return in_array($key, $exists);
+ public function hasKey($app, $key) {
+ $values = $this->getAppValues($app);
+ return isset($values[$key]);
}
/**
@@ -145,79 +155,78 @@ class OC_Appconfig {
* @param string $app app
* @param string $key key
* @param string $value value
- * @return bool
*
* Sets a value. If the key did not exist before it will be created.
*/
- 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->execute(array($app, $key, $value));
+ public function setValue($app, $key, $value) {
+ // Does the key exist? no: insert, yes: update.
+ if (!$this->hasKey($app, $key)) {
+ $data = array(
+ 'appid' => $app,
+ 'configkey' => $key,
+ 'configvalue' => $value,
+ );
+ $this->conn->insert('*PREFIX*appconfig', $data);
} else {
- $query = OC_DB::prepare('UPDATE `*PREFIX*appconfig` SET `configvalue` = ?'
- . ' WHERE `appid` = ? AND `configkey` = ?');
- $query->execute(array($value, $app, $key));
+ $data = array(
+ 'configvalue' => $value,
+ );
+ $where = array(
+ 'appid' => $app,
+ 'configkey' => $key,
+ );
+ $this->conn->update('*PREFIX*appconfig', $data, $where);
}
- // TODO where should this be documented?
- \OC_Hook::emit('OC_Appconfig', 'post_set_value', array(
- 'app' => $app,
- 'key' => $key,
- 'value' => $value
- ));
- if (!isset(self::$cache[$app])) {
- self::$cache[$app] = array();
+ if (!isset($this->cache[$app])) {
+ $this->cache[$app] = array();
}
- self::$cache[$app][$key] = $value;
+ $this->cache[$app][$key] = $value;
}
/**
* @brief Deletes a key
* @param string $app app
* @param string $key key
- * @return bool
- *
- * Deletes a key.
+ * @return boolean|null
*/
- public static function deleteKey($app, $key) {
- // Boring!
- $query = OC_DB::prepare('DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ? AND `configkey` = ?');
- $query->execute(array($app, $key));
- if (isset(self::$cache[$app]) and isset(self::$cache[$app][$key])) {
- unset(self::$cache[$app][$key]);
+ public function deleteKey($app, $key) {
+ $where = array(
+ 'appid' => $app,
+ 'configkey' => $key,
+ );
+ $this->conn->delete('*PREFIX*appconfig', $where);
+ if (isset($this->cache[$app]) and isset($this->cache[$app][$key])) {
+ unset($this->cache[$app][$key]);
}
-
- return true;
}
/**
* @brief Remove app from appconfig
* @param string $app app
- * @return bool
+ * @return boolean|null
*
* Removes all keys in appconfig belonging to the app.
*/
- public static function deleteApp($app) {
- // Nothing special
- $query = OC_DB::prepare('DELETE FROM `*PREFIX*appconfig` WHERE `appid` = ?');
- $query->execute(array($app));
- self::$cache[$app] = array();
-
- return true;
+ public function deleteApp($app) {
+ $where = array(
+ 'appid' => $app,
+ );
+ $this->conn->delete('*PREFIX*appconfig', $where);
+ unset($this->cache[$app]);
}
/**
* get multiply values, either the app or key can be used as wildcard by setting it to false
*
- * @param app
- * @param key
+ * @param boolean $app
+ * @param string $key
* @return array
*/
- public static function getValues($app, $key) {
- if ($app !== false and $key !== false) {
+ public function getValues($app, $key) {
+ if (($app !== false) == ($key !== false)) {
return false;
}
+
$fields = '`configvalue`';
$where = 'WHERE';
$params = array();
@@ -232,13 +241,14 @@ class OC_Appconfig {
$params[] = $key;
$key = 'appid';
}
- $queryString = 'SELECT ' . $fields . ' FROM `*PREFIX*appconfig` ' . $where;
- $query = OC_DB::prepare($queryString);
- $result = $query->execute($params);
+ $query = 'SELECT ' . $fields . ' FROM `*PREFIX*appconfig` ' . $where;
+ $result = $this->conn->executeQuery($query, $params);
+
$values = array();
- while ($row = $result->fetchRow()) {
+ while ($row = $result->fetch((\PDO::FETCH_ASSOC))) {
$values[$row[$key]] = $row['configvalue'];
}
+
return $values;
}
}
diff --git a/lib/private/appframework/app.php b/lib/private/appframework/app.php
index b835188661a..3b13194862d 100644
--- a/lib/private/appframework/app.php
+++ b/lib/private/appframework/app.php
@@ -25,7 +25,6 @@
namespace OC\AppFramework;
use OC\AppFramework\DependencyInjection\DIContainer;
-use OCP\AppFramework\IAppContainer;
/**
diff --git a/lib/private/appframework/dependencyinjection/dicontainer.php b/lib/private/appframework/dependencyinjection/dicontainer.php
index e2ea974e104..4821ecaf67b 100644
--- a/lib/private/appframework/dependencyinjection/dicontainer.php
+++ b/lib/private/appframework/dependencyinjection/dicontainer.php
@@ -34,7 +34,6 @@ use OC\AppFramework\Utility\SimpleContainer;
use OC\AppFramework\Utility\TimeFactory;
use OCP\AppFramework\IApi;
use OCP\AppFramework\IAppContainer;
-use OCP\AppFramework\IMiddleWare;
use OCP\AppFramework\Middleware;
use OCP\IServerContainer;
@@ -135,7 +134,7 @@ class DIContainer extends SimpleContainer implements IAppContainer{
/**
* @param Middleware $middleWare
- * @return boolean
+ * @return boolean|null
*/
function registerMiddleWare(Middleware $middleWare) {
array_push($this->middleWares, $middleWare);
diff --git a/lib/private/appframework/http.php b/lib/private/appframework/http.php
index 41fc0db6b38..65d926105f1 100644
--- a/lib/private/appframework/http.php
+++ b/lib/private/appframework/http.php
@@ -108,7 +108,7 @@ class Http extends BaseHttp {
* Gets the correct header
* @param Http::CONSTANT $status the constant from the Http class
* @param \DateTime $lastModified formatted last modified date
- * @param string $Etag the etag
+ * @param string $ETag the etag
*/
public function getStatusHeader($status, \DateTime $lastModified=null,
$ETag=null) {
diff --git a/lib/private/appframework/http/redirectresponse.php b/lib/private/appframework/http/redirectresponse.php
index c4e21059480..05353349065 100644
--- a/lib/private/appframework/http/redirectresponse.php
+++ b/lib/private/appframework/http/redirectresponse.php
@@ -24,8 +24,8 @@
namespace OC\AppFramework\Http;
-use OCP\AppFramework\Http\Response,
- OCP\AppFramework\Http;
+use OCP\AppFramework\Http\Response;
+use OCP\AppFramework\Http;
/**
diff --git a/lib/private/appframework/http/request.php b/lib/private/appframework/http/request.php
index 3e1f4ff87ed..40f47a7bd2f 100644
--- a/lib/private/appframework/http/request.php
+++ b/lib/private/appframework/http/request.php
@@ -114,7 +114,7 @@ class Request implements \ArrayAccess, \Countable, IRequest {
* $request['myvar'] = 'something'; // This throws an exception.
*
* @param string $offset The key to lookup
- * @return string|null
+ * @return boolean
*/
public function offsetExists($offset) {
return isset($this->items['parameters'][$offset]);
diff --git a/lib/private/appframework/middleware/middlewaredispatcher.php b/lib/private/appframework/middleware/middlewaredispatcher.php
index 681140c2242..598743e523f 100644
--- a/lib/private/appframework/middleware/middlewaredispatcher.php
+++ b/lib/private/appframework/middleware/middlewaredispatcher.php
@@ -56,7 +56,7 @@ class MiddlewareDispatcher {
/**
* Adds a new middleware
- * @param Middleware $middleware the middleware which will be added
+ * @param Middleware $middleWare the middleware which will be added
*/
public function registerMiddleware(Middleware $middleWare){
array_push($this->middlewares, $middleWare);
diff --git a/lib/private/appframework/middleware/security/securityexception.php b/lib/private/appframework/middleware/security/securityexception.php
index b32a2769ff5..e551675acdf 100644
--- a/lib/private/appframework/middleware/security/securityexception.php
+++ b/lib/private/appframework/middleware/security/securityexception.php
@@ -32,7 +32,6 @@ class SecurityException extends \Exception {
/**
* @param string $msg the security error message
- * @param bool $ajax true if it resulted because of an ajax request
*/
public function __construct($msg, $code = 0) {
parent::__construct($msg, $code);
diff --git a/lib/private/appframework/middleware/security/securitymiddleware.php b/lib/private/appframework/middleware/security/securitymiddleware.php
index c3143754823..bb02d565fa4 100644
--- a/lib/private/appframework/middleware/security/securitymiddleware.php
+++ b/lib/private/appframework/middleware/security/securitymiddleware.php
@@ -66,7 +66,7 @@ class SecurityMiddleware extends Middleware {
* This runs all the security checks before a method call. The
* security checks are determined by inspecting the controller method
* annotations
- * @param string/Controller $controller the controllername or string
+ * @param string $controller the controllername or string
* @param string $methodName the name of the method
* @throws SecurityException when a security check fails
*/
diff --git a/lib/private/appframework/routing/routeactionhandler.php b/lib/private/appframework/routing/routeactionhandler.php
index 2b9dc38dc43..6a5c64745ae 100644
--- a/lib/private/appframework/routing/routeactionhandler.php
+++ b/lib/private/appframework/routing/routeactionhandler.php
@@ -30,6 +30,10 @@ class RouteActionHandler {
private $actionName;
private $container;
+ /**
+ * @param string $controllerName
+ * @param string $actionName
+ */
public function __construct(DIContainer $container, $controllerName, $actionName) {
$this->controllerName = $controllerName;
$this->actionName = $actionName;
diff --git a/lib/private/appframework/routing/routeconfig.php b/lib/private/appframework/routing/routeconfig.php
index 53ab11bf2f5..716358444a2 100644
--- a/lib/private/appframework/routing/routeconfig.php
+++ b/lib/private/appframework/routing/routeconfig.php
@@ -37,7 +37,6 @@ class RouteConfig {
/**
* @param \OC\AppFramework\DependencyInjection\DIContainer $container
* @param \OC_Router $router
- * @param string $pathToYml
* @internal param $appName
*/
public function __construct(DIContainer $container, \OC_Router $router, $routes) {
diff --git a/lib/private/appframework/utility/simplecontainer.php b/lib/private/appframework/utility/simplecontainer.php
index e631e657756..d08a4879e34 100644
--- a/lib/private/appframework/utility/simplecontainer.php
+++ b/lib/private/appframework/utility/simplecontainer.php
@@ -31,7 +31,7 @@ class SimpleContainer extends \Pimple implements \OCP\IContainer {
* Created instance will be cached in case $shared is true.
*
* @param string $name name of the service to register another backend for
- * @param callable $closure the closure to be called on service creation
+ * @param \Closure $closure the closure to be called on service creation
*/
function registerService($name, \Closure $closure, $shared = true)
{
diff --git a/lib/private/archive.php b/lib/private/archive.php
index 85bfae57295..6f51066ddf8 100644
--- a/lib/private/archive.php
+++ b/lib/private/archive.php
@@ -9,7 +9,7 @@
abstract class OC_Archive{
/**
* open any of the supported archive types
- * @param string path
+ * @param string $path
* @return OC_Archive
*/
public static function open($path) {
@@ -32,39 +32,39 @@ abstract class OC_Archive{
abstract function __construct($source);
/**
* add an empty folder to the archive
- * @param string path
+ * @param string $path
* @return bool
*/
abstract function addFolder($path);
/**
* add a file to the archive
- * @param string path
+ * @param string $path
* @param string source either a local file or string data
* @return bool
*/
abstract function addFile($path, $source='');
/**
* rename a file or folder in the archive
- * @param string source
- * @param string dest
+ * @param string $source
+ * @param string $dest
* @return bool
*/
abstract function rename($source, $dest);
/**
* get the uncompressed size of a file in the archive
- * @param string path
+ * @param string $path
* @return int
*/
abstract function filesize($path);
/**
* get the last modified time of a file in the archive
- * @param string path
+ * @param string $path
* @return int
*/
abstract function mtime($path);
/**
* get the files in a folder
- * @param path
+ * @param string $path
* @return array
*/
abstract function getFolder($path);
@@ -75,48 +75,47 @@ abstract class OC_Archive{
abstract function getFiles();
/**
* get the content of a file
- * @param string path
+ * @param string $path
* @return string
*/
abstract function getFile($path);
/**
* extract a single file from the archive
- * @param string path
- * @param string dest
+ * @param string $path
+ * @param string $dest
* @return bool
*/
abstract function extractFile($path, $dest);
/**
* extract the archive
- * @param string path
- * @param string dest
+ * @param string $dest
* @return bool
*/
abstract function extract($dest);
/**
* check if a file or folder exists in the archive
- * @param string path
+ * @param string $path
* @return bool
*/
abstract function fileExists($path);
/**
* remove a file or folder from the archive
- * @param string path
+ * @param string $path
* @return bool
*/
abstract function remove($path);
/**
* get a file handler
- * @param string path
- * @param string mode
+ * @param string $path
+ * @param string $mode
* @return resource
*/
abstract function getStream($path, $mode);
/**
* add a folder and all its content
* @param string $path
- * @param string source
- * @return bool
+ * @param string $source
+ * @return boolean|null
*/
function addRecursive($path, $source) {
$dh = opendir($source);
diff --git a/lib/private/archive/tar.php b/lib/private/archive/tar.php
index a1c0535b1c3..cbdb565ba35 100644
--- a/lib/private/archive/tar.php
+++ b/lib/private/archive/tar.php
@@ -22,6 +22,9 @@ class OC_Archive_TAR extends OC_Archive{
private $tar=null;
private $path;
+ /**
+ * @param string $source
+ */
function __construct($source) {
$types=array(null, 'gz', 'bz');
$this->path=$source;
@@ -30,8 +33,8 @@ class OC_Archive_TAR extends OC_Archive{
/**
* try to detect the type of tar compression
- * @param string file
- * @return str
+ * @param string $file
+ * @return integer
*/
static public function getTarType($file) {
if(strpos($file, '.')) {
@@ -53,7 +56,7 @@ class OC_Archive_TAR extends OC_Archive{
/**
* add an empty folder to the archive
- * @param string path
+ * @param string $path
* @return bool
*/
function addFolder($path) {
@@ -80,8 +83,8 @@ class OC_Archive_TAR extends OC_Archive{
}
/**
* add a file to the archive
- * @param string path
- * @param string source either a local file or string data
+ * @param string $path
+ * @param string $source either a local file or string data
* @return bool
*/
function addFile($path, $source='') {
@@ -103,8 +106,8 @@ class OC_Archive_TAR extends OC_Archive{
/**
* rename a file or folder in the archive
- * @param string source
- * @param string dest
+ * @param string $source
+ * @param string $dest
* @return bool
*/
function rename($source, $dest) {
@@ -122,6 +125,9 @@ class OC_Archive_TAR extends OC_Archive{
return true;
}
+ /**
+ * @param string $file
+ */
private function getHeader($file) {
if ( ! $this->cachedHeaders ) {
$this->cachedHeaders = $this->tar->listContent();
@@ -139,7 +145,7 @@ class OC_Archive_TAR extends OC_Archive{
/**
* get the uncompressed size of a file in the archive
- * @param string path
+ * @param string $path
* @return int
*/
function filesize($path) {
@@ -158,7 +164,7 @@ class OC_Archive_TAR extends OC_Archive{
/**
* get the files in a folder
- * @param path
+ * @param string $path
* @return array
*/
function getFolder($path) {
@@ -201,7 +207,7 @@ class OC_Archive_TAR extends OC_Archive{
}
/**
* get the content of a file
- * @param string path
+ * @param string $path
* @return string
*/
function getFile($path) {
@@ -209,8 +215,8 @@ class OC_Archive_TAR extends OC_Archive{
}
/**
* extract a single file from the archive
- * @param string path
- * @param string dest
+ * @param string $path
+ * @param string $dest
* @return bool
*/
function extractFile($path, $dest) {
@@ -231,8 +237,7 @@ class OC_Archive_TAR extends OC_Archive{
}
/**
* extract the archive
- * @param string path
- * @param string dest
+ * @param string $dest
* @return bool
*/
function extract($dest) {
@@ -240,7 +245,7 @@ class OC_Archive_TAR extends OC_Archive{
}
/**
* check if a file or folder exists in the archive
- * @param string path
+ * @param string $path
* @return bool
*/
function fileExists($path) {
@@ -268,7 +273,7 @@ class OC_Archive_TAR extends OC_Archive{
/**
* remove a file or folder from the archive
- * @param string path
+ * @param string $path
* @return bool
*/
function remove($path) {
@@ -289,8 +294,8 @@ class OC_Archive_TAR extends OC_Archive{
}
/**
* get a file handler
- * @param string path
- * @param string mode
+ * @param string $path
+ * @param string $mode
* @return resource
*/
function getStream($path, $mode) {
diff --git a/lib/private/archive/zip.php b/lib/private/archive/zip.php
index 8a866716a79..fa5630d7665 100644
--- a/lib/private/archive/zip.php
+++ b/lib/private/archive/zip.php
@@ -13,6 +13,9 @@ class OC_Archive_ZIP extends OC_Archive{
private $zip=null;
private $path;
+ /**
+ * @param string $source
+ */
function __construct($source) {
$this->path=$source;
$this->zip=new ZipArchive();
@@ -23,7 +26,7 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* add an empty folder to the archive
- * @param string path
+ * @param string $path
* @return bool
*/
function addFolder($path) {
@@ -31,8 +34,8 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* add a file to the archive
- * @param string path
- * @param string source either a local file or string data
+ * @param string $path
+ * @param string $source either a local file or string data
* @return bool
*/
function addFile($path, $source='') {
@@ -49,9 +52,9 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* rename a file or folder in the archive
- * @param string source
- * @param string dest
- * @return bool
+ * @param string $source
+ * @param string $dest
+ * @return boolean|null
*/
function rename($source, $dest) {
$source=$this->stripPath($source);
@@ -60,7 +63,7 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* get the uncompressed size of a file in the archive
- * @param string path
+ * @param string $path
* @return int
*/
function filesize($path) {
@@ -69,7 +72,7 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* get the last modified time of a file in the archive
- * @param string path
+ * @param string $path
* @return int
*/
function mtime($path) {
@@ -77,7 +80,7 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* get the files in a folder
- * @param path
+ * @param string $path
* @return array
*/
function getFolder($path) {
@@ -107,7 +110,7 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* get the content of a file
- * @param string path
+ * @param string $path
* @return string
*/
function getFile($path) {
@@ -115,9 +118,9 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* extract a single file from the archive
- * @param string path
- * @param string dest
- * @return bool
+ * @param string $path
+ * @param string $dest
+ * @return boolean|null
*/
function extractFile($path, $dest) {
$fp = $this->zip->getStream($path);
@@ -125,8 +128,7 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* extract the archive
- * @param string path
- * @param string dest
+ * @param string $dest
* @return bool
*/
function extract($dest) {
@@ -134,7 +136,7 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* check if a file or folder exists in the archive
- * @param string path
+ * @param string $path
* @return bool
*/
function fileExists($path) {
@@ -142,7 +144,7 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* remove a file or folder from the archive
- * @param string path
+ * @param string $path
* @return bool
*/
function remove($path) {
@@ -154,8 +156,8 @@ class OC_Archive_ZIP extends OC_Archive{
}
/**
* get a file handler
- * @param string path
- * @param string mode
+ * @param string $path
+ * @param string $mode
* @return resource
*/
function getStream($path, $mode) {
@@ -191,6 +193,10 @@ class OC_Archive_ZIP extends OC_Archive{
}
}
+ /**
+ * @param string $path
+ * @return string
+ */
private function stripPath($path) {
if(!$path || $path[0]=='/') {
return substr($path, 1);
diff --git a/lib/private/arrayparser.php b/lib/private/arrayparser.php
index 3bb394a5163..d353e486577 100644
--- a/lib/private/arrayparser.php
+++ b/lib/private/arrayparser.php
@@ -30,12 +30,18 @@ class ArrayParser {
const TYPE_STRING = 3;
const TYPE_ARRAY = 4;
+ /**
+ * @param string $string
+ */
function parsePHP($string) {
$string = $this->stripPHPTags($string);
$string = $this->stripAssignAndReturn($string);
return $this->parse($string);
}
+ /**
+ * @param string $string
+ */
function stripPHPTags($string) {
$string = trim($string);
if (substr($string, 0, 5) === '<?php') {
@@ -47,6 +53,9 @@ class ArrayParser {
return $string;
}
+ /**
+ * @param string $string
+ */
function stripAssignAndReturn($string) {
$string = trim($string);
if (substr($string, 0, 6) === 'return') {
@@ -74,6 +83,9 @@ class ArrayParser {
return null;
}
+ /**
+ * @param string $string
+ */
function getType($string) {
$string = strtolower($string);
$first = substr($string, 0, 1);
@@ -90,19 +102,31 @@ class ArrayParser {
}
}
+ /**
+ * @param string $string
+ */
function parseString($string) {
return substr($string, 1, -1);
}
+ /**
+ * @param string $string
+ */
function parseNum($string) {
return intval($string);
}
+ /**
+ * @param string $string
+ */
function parseBool($string) {
$string = strtolower($string);
return $string === 'true';
}
+ /**
+ * @param string $string
+ */
function parseArray($string) {
$body = substr($string, 5);
$body = trim($body);
@@ -131,6 +155,9 @@ class ArrayParser {
return $result;
}
+ /**
+ * @param string $body
+ */
function splitArray($body) {
$inSingleQuote = false;//keep track if we are inside quotes
$inDoubleQuote = false;
diff --git a/lib/private/backgroundjob.php b/lib/private/backgroundjob.php
index 9619dcb732c..afc3c270405 100644
--- a/lib/private/backgroundjob.php
+++ b/lib/private/backgroundjob.php
@@ -37,8 +37,8 @@ class OC_BackgroundJob{
/**
* @brief sets the background jobs execution type
- * @param $type execution type
- * @return boolean
+ * @param string $type execution type
+ * @return false|null
*
* This method sets the execution type of the background jobs. Possible types
* are "none", "ajax", "webcron", "cron"
diff --git a/lib/private/backgroundjob/job.php b/lib/private/backgroundjob/job.php
index 92bd0f8fdbd..0cef401bc24 100644
--- a/lib/private/backgroundjob/job.php
+++ b/lib/private/backgroundjob/job.php
@@ -8,7 +8,9 @@
namespace OC\BackgroundJob;
-abstract class Job {
+use OCP\BackgroundJob\IJob;
+
+abstract class Job implements IJob {
/**
* @var int $id
*/
diff --git a/lib/private/backgroundjob/joblist.php b/lib/private/backgroundjob/joblist.php
index 99743a70c77..26c90269349 100644
--- a/lib/private/backgroundjob/joblist.php
+++ b/lib/private/backgroundjob/joblist.php
@@ -1,6 +1,6 @@
<?php
/**
- * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
@@ -8,16 +8,30 @@
namespace OC\BackgroundJob;
-/**
- * Class QueuedJob
- *
- * create a background job that is to be executed once
- *
- * @package OC\BackgroundJob
- */
-class JobList {
+use OCP\BackgroundJob\IJobList;
+
+class JobList implements IJobList {
+ /**
+ * @var \OCP\IDBConnection
+ */
+ private $conn;
+
+ /**
+ * @var \OCP\IConfig $config
+ */
+ private $config;
+
/**
- * @param Job|string $job
+ * @param \OCP\IDBConnection $conn
+ * @param \OCP\IConfig $config
+ */
+ public function __construct($conn, $config) {
+ $this->conn = $conn;
+ $this->config = $config;
+ }
+
+ /**
+ * @param \Test\BackgroundJob\TestJob $job
* @param mixed $argument
*/
public function add($job, $argument = null) {
@@ -28,13 +42,13 @@ class JobList {
$class = $job;
}
$argument = json_encode($argument);
- $query = \OC_DB::prepare('INSERT INTO `*PREFIX*jobs`(`class`, `argument`, `last_run`) VALUES(?, ?, 0)');
+ $query = $this->conn->prepare('INSERT INTO `*PREFIX*jobs`(`class`, `argument`, `last_run`) VALUES(?, ?, 0)');
$query->execute(array($class, $argument));
}
}
/**
- * @param Job|string $job
+ * @param Job $job
* @param mixed $argument
*/
public function remove($job, $argument = null) {
@@ -45,10 +59,10 @@ class JobList {
}
if (!is_null($argument)) {
$argument = json_encode($argument);
- $query = \OC_DB::prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?');
+ $query = $this->conn->prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?');
$query->execute(array($class, $argument));
} else {
- $query = \OC_DB::prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ?');
+ $query = $this->conn->prepare('DELETE FROM `*PREFIX*jobs` WHERE `class` = ?');
$query->execute(array($class));
}
}
@@ -67,9 +81,9 @@ class JobList {
$class = $job;
}
$argument = json_encode($argument);
- $query = \OC_DB::prepare('SELECT `id` FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?');
- $result = $query->execute(array($class, $argument));
- return (bool)$result->fetchRow();
+ $query = $this->conn->prepare('SELECT `id` FROM `*PREFIX*jobs` WHERE `class` = ? AND `argument` = ?');
+ $query->execute(array($class, $argument));
+ return (bool)$query->fetch();
}
/**
@@ -78,10 +92,10 @@ class JobList {
* @return Job[]
*/
public function getAll() {
- $query = \OC_DB::prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs`');
- $result = $query->execute();
+ $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs`');
+ $query->execute();
$jobs = array();
- while ($row = $result->fetchRow()) {
+ while ($row = $query->fetch()) {
$jobs[] = $this->buildJob($row);
}
return $jobs;
@@ -94,15 +108,15 @@ class JobList {
*/
public function getNext() {
$lastId = $this->getLastJob();
- $query = \OC_DB::prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` > ? ORDER BY `id` ASC', 1);
- $result = $query->execute(array($lastId));
- if ($row = $result->fetchRow()) {
+ $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` > ? ORDER BY `id` ASC', 1);
+ $query->execute(array($lastId));
+ if ($row = $query->fetch()) {
return $this->buildJob($row);
} else {
//begin at the start of the queue
- $query = \OC_DB::prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` ORDER BY `id` ASC', 1);
- $result = $query->execute();
- if ($row = $result->fetchRow()) {
+ $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` ORDER BY `id` ASC', 1);
+ $query->execute();
+ if ($row = $query->fetch()) {
return $this->buildJob($row);
} else {
return null; //empty job list
@@ -115,9 +129,9 @@ class JobList {
* @return Job
*/
public function getById($id) {
- $query = \OC_DB::prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` = ?');
- $result = $query->execute(array($id));
- if ($row = $result->fetchRow()) {
+ $query = $this->conn->prepare('SELECT `id`, `class`, `last_run`, `argument` FROM `*PREFIX*jobs` WHERE `id` = ?');
+ $query->execute(array($id));
+ if ($row = $query->fetch()) {
return $this->buildJob($row);
} else {
return null;
@@ -148,16 +162,16 @@ class JobList {
* @param Job $job
*/
public function setLastJob($job) {
- \OC_Appconfig::setValue('backgroundjob', 'lastjob', $job->getId());
+ $this->config->setAppValue('backgroundjob', 'lastjob', $job->getId());
}
/**
* get the id of the last ran job
*
- * @return int
+ * @return string
*/
public function getLastJob() {
- return \OC_Appconfig::getValue('backgroundjob', 'lastjob', 0);
+ return $this->config->getAppValue('backgroundjob', 'lastjob', 0);
}
/**
@@ -166,7 +180,7 @@ class JobList {
* @param Job $job
*/
public function setLastRun($job) {
- $query = \OC_DB::prepare('UPDATE `*PREFIX*jobs` SET `last_run` = ? WHERE `id` = ?');
+ $query = $this->conn->prepare('UPDATE `*PREFIX*jobs` SET `last_run` = ? WHERE `id` = ?');
$query->execute(array(time(), $job->getId()));
}
}
diff --git a/lib/private/cache/file.php b/lib/private/cache/file.php
index b0738d2a92b..8a6ef39f61b 100644
--- a/lib/private/cache/file.php
+++ b/lib/private/cache/file.php
@@ -29,6 +29,9 @@ class File {
}
}
+ /**
+ * @param string $key
+ */
public function get($key) {
$result = null;
$proxyStatus = \OC_FileProxy::$enabled;
@@ -59,6 +62,9 @@ class File {
return $result;
}
+ /**
+ * @param string $key
+ */
public function set($key, $value, $ttl=0) {
$storage = $this->getStorage();
$result = false;
@@ -87,6 +93,9 @@ class File {
return false;
}
+ /**
+ * @param string $key
+ */
public function remove($key) {
$storage = $this->getStorage();
if(!$storage) {
diff --git a/lib/private/cache/fileglobal.php b/lib/private/cache/fileglobal.php
index bd049bba4d0..d9e0fd46d37 100644
--- a/lib/private/cache/fileglobal.php
+++ b/lib/private/cache/fileglobal.php
@@ -21,6 +21,9 @@ class FileGlobal {
return str_replace('/', '_', $key);
}
+ /**
+ * @param string $key
+ */
public function get($key) {
$key = $this->fixKey($key);
if ($this->hasKey($key)) {
@@ -30,6 +33,10 @@ class FileGlobal {
return null;
}
+ /**
+ * @param string $key
+ * @param string $value
+ */
public function set($key, $value, $ttl=0) {
$key = $this->fixKey($key);
$cache_dir = self::getCacheDir();
@@ -81,13 +88,14 @@ class FileGlobal {
}
static public function gc() {
- $last_run = \OC_AppConfig::getValue('core', 'global_cache_gc_lastrun', 0);
+ $appConfig = \OC::$server->getAppConfig();
+ $last_run = $appConfig->getValue('core', 'global_cache_gc_lastrun', 0);
$now = time();
if (($now - $last_run) < 300) {
// only do cleanup every 5 minutes
return;
}
- \OC_AppConfig::setValue('core', 'global_cache_gc_lastrun', $now);
+ $appConfig->setValue('core', 'global_cache_gc_lastrun', $now);
$cache_dir = self::getCacheDir();
if($cache_dir and is_dir($cache_dir)) {
$dh=opendir($cache_dir);
diff --git a/lib/private/cache/usercache.php b/lib/private/cache/usercache.php
index baa8820700b..486e08218a2 100644
--- a/lib/private/cache/usercache.php
+++ b/lib/private/cache/usercache.php
@@ -35,7 +35,7 @@ class UserCache implements \OCP\ICache {
* Set a value in the user cache
*
* @param string $key
- * @param mixed $value
+ * @param string $value
* @param int $ttl Time To Live in seconds. Defaults to 60*60*24
* @return bool
*/
diff --git a/lib/private/config.php b/lib/private/config.php
index 8a9d5ca6158..3649da84973 100644
--- a/lib/private/config.php
+++ b/lib/private/config.php
@@ -77,7 +77,7 @@ class Config {
/**
* @brief Gets a value from config.php
* @param string $key key
- * @param string $default = null default value
+ * @param string|null $default = null default value
* @return string the value or $default
*
* This function gets the value from config.php. If it does not exist,
diff --git a/lib/private/connector/sabre/aborteduploaddetectionplugin.php b/lib/private/connector/sabre/aborteduploaddetectionplugin.php
index 10cca647e8d..ad759d1d84a 100644
--- a/lib/private/connector/sabre/aborteduploaddetectionplugin.php
+++ b/lib/private/connector/sabre/aborteduploaddetectionplugin.php
@@ -47,7 +47,7 @@ class OC_Connector_Sabre_AbortedUploadDetectionPlugin extends Sabre_DAV_ServerPl
}
/**
- * @param $filePath
+ * @param string $filePath
* @param Sabre_DAV_INode $node
* @throws Sabre_DAV_Exception_BadRequest
*/
diff --git a/lib/private/connector/sabre/file.php b/lib/private/connector/sabre/file.php
index ed27cef440d..ef6caaf22a7 100644
--- a/lib/private/connector/sabre/file.php
+++ b/lib/private/connector/sabre/file.php
@@ -58,6 +58,11 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
throw new \Sabre_DAV_Exception_ServiceUnavailable();
}
+ $fileName = basename($this->path);
+ if (!\OCP\Util::isValidFileName($fileName)) {
+ throw new \Sabre_DAV_Exception_BadRequest();
+ }
+
// chunked handling
if (isset($_SERVER['HTTP_OC_CHUNKED'])) {
return $this->createFileChunked($data);
@@ -142,15 +147,16 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
* @throws Sabre_DAV_Exception_Forbidden
*/
public function delete() {
+ $fs = $this->getFS();
if ($this->path === 'Shared') {
throw new \Sabre_DAV_Exception_Forbidden();
}
- if (!\OC\Files\Filesystem::isDeletable($this->path)) {
+ if (!$fs->isDeletable($this->path)) {
throw new \Sabre_DAV_Exception_Forbidden();
}
- \OC\Files\Filesystem::unlink($this->path);
+ $fs->unlink($this->path);
// remove properties
$this->removeProperties();
@@ -206,6 +212,9 @@ class OC_Connector_Sabre_File extends OC_Connector_Sabre_Node implements Sabre_D
}
+ /**
+ * @param resource $data
+ */
private function createFileChunked($data)
{
list($path, $name) = \Sabre_DAV_URLUtil::splitPath($this->path);
diff --git a/lib/private/connector/sabre/node.php b/lib/private/connector/sabre/node.php
index 993aa73faeb..5807c5c7f71 100644
--- a/lib/private/connector/sabre/node.php
+++ b/lib/private/connector/sabre/node.php
@@ -85,19 +85,24 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
* @return void
*/
public function setName($name) {
+ $fs = $this->getFS();
// rename is only allowed if the update privilege is granted
- if (!\OC\Files\Filesystem::isUpdatable($this->path)) {
+ if (!$fs->isUpdatable($this->path)) {
throw new \Sabre_DAV_Exception_Forbidden();
}
list($parentPath, ) = Sabre_DAV_URLUtil::splitPath($this->path);
list(, $newName) = Sabre_DAV_URLUtil::splitPath($name);
+ if (!\OCP\Util::isValidFileName($newName)) {
+ throw new \Sabre_DAV_Exception_BadRequest();
+ }
+
$newPath = $parentPath . '/' . $newName;
$oldPath = $this->path;
- \OC\Files\Filesystem::rename($this->path, $newPath);
+ $fs->rename($this->path, $newPath);
$this->path = $newPath;
@@ -153,9 +158,8 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
/**
* @brief Updates properties on this node,
- * @param array $mutations
* @see Sabre_DAV_IProperties::updateProperties
- * @return bool|array
+ * @return boolean
*/
public function updateProperties($properties) {
$existing = $this->getProperties(array());
@@ -267,7 +271,7 @@ abstract class OC_Connector_Sabre_Node implements Sabre_DAV_INode, Sabre_DAV_IPr
}
/**
- * @return mixed
+ * @return string|null
*/
public function getFileId()
{
diff --git a/lib/private/connector/sabre/objecttree.php b/lib/private/connector/sabre/objecttree.php
index d1e179af2ec..d2fa425b22c 100644
--- a/lib/private/connector/sabre/objecttree.php
+++ b/lib/private/connector/sabre/objecttree.php
@@ -105,6 +105,11 @@ class ObjectTree extends \Sabre_DAV_ObjectTree {
}
}
+ $fileName = basename($destinationPath);
+ if (!\OCP\Util::isValidFileName($fileName)) {
+ throw new \Sabre_DAV_Exception_BadRequest();
+ }
+
$renameOkay = $fs->rename($sourcePath, $destinationPath);
if (!$renameOkay) {
throw new \Sabre_DAV_Exception_Forbidden('');
diff --git a/lib/private/connector/sabre/principal.php b/lib/private/connector/sabre/principal.php
index 59a96797c16..2075aa55c86 100644
--- a/lib/private/connector/sabre/principal.php
+++ b/lib/private/connector/sabre/principal.php
@@ -62,7 +62,7 @@ class OC_Connector_Sabre_Principal implements Sabre_DAVACL_IPrincipalBackend {
* Returns the list of members for a group-principal
*
* @param string $principal
- * @return array
+ * @return string[]
*/
public function getGroupMemberSet($principal) {
// TODO: for now the group principal has only one member, the user itself
diff --git a/lib/private/connector/sabre/quotaplugin.php b/lib/private/connector/sabre/quotaplugin.php
index ea2cb81d1f7..8099794f670 100644
--- a/lib/private/connector/sabre/quotaplugin.php
+++ b/lib/private/connector/sabre/quotaplugin.php
@@ -45,8 +45,8 @@ class OC_Connector_Sabre_QuotaPlugin extends Sabre_DAV_ServerPlugin {
/**
* This method is called before any HTTP method and validates there is enough free space to store the file
*
- * @param string $method
* @throws Sabre_DAV_Exception
+ * @param string $uri
* @return bool
*/
public function checkQuota($uri, $data = null) {
diff --git a/lib/private/connector/sabre/server.php b/lib/private/connector/sabre/server.php
index 41e8885917a..2660b043f46 100644
--- a/lib/private/connector/sabre/server.php
+++ b/lib/private/connector/sabre/server.php
@@ -67,6 +67,7 @@ class OC_Connector_Sabre_Server extends Sabre_DAV_Server {
/**
* Small helper to support PROPFIND with DEPTH_INFINITY.
+ * @param string $path
*/
private function addPathNodesRecursively(&$nodes, $path) {
foreach($this->tree->getChildren($path) as $childNode) {
diff --git a/lib/private/davclient.php b/lib/private/davclient.php
index 28f48f3b921..afa4e1103b4 100644
--- a/lib/private/davclient.php
+++ b/lib/private/davclient.php
@@ -31,7 +31,7 @@ class OC_DAVClient extends \Sabre_DAV_Client {
/**
* @brief Sets the request timeout or 0 to disable timeout.
- * @param int timeout in seconds or 0 to disable
+ * @param integer $timeout in seconds or 0 to disable
*/
public function setRequestTimeout($timeout) {
$this->requestTimeout = (int)$timeout;
diff --git a/lib/private/db.php b/lib/private/db.php
index 562065259fa..cfdac766bff 100644
--- a/lib/private/db.php
+++ b/lib/private/db.php
@@ -44,14 +44,14 @@ class OC_DB {
/**
* @var \OC\DB\Connection $connection
*/
- static private $connection; //the prefered connection to use, only Doctrine
+ static private $connection; //the preferred connection to use, only Doctrine
static private $prefix=null;
static private $type=null;
/**
* @brief connects to the database
- * @return bool true if connection can be established or false on error
+ * @return boolean|null true if connection can be established or false on error
*
* Connects to the database as specified in config.php
*/
@@ -196,7 +196,7 @@ class OC_DB {
* @param int $offset
* @param bool $isManipulation
* @throws DatabaseException
- * @return \Doctrine\DBAL\Statement prepared SQL query
+ * @return OC_DB_StatementWrapper prepared SQL query
*
* SQL query via Doctrine prepare(), needs to be execute()'d!
*/
@@ -252,7 +252,7 @@ class OC_DB {
* an array with 'sql' and optionally 'limit' and 'offset' keys
* .. or a simple sql query string
* @param array $parameters
- * @return result
+ * @return OC_DB_StatementWrapper
* @throws DatabaseException
*/
static public function executeAudited( $stmt, array $parameters = null) {
@@ -298,7 +298,7 @@ class OC_DB {
/**
* @brief gets last value of autoincrement
* @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix
- * @return int id
+ * @return string id
* @throws DatabaseException
*
* \Doctrine\DBAL\Connection lastInsertId
@@ -315,7 +315,8 @@ class OC_DB {
* @brief Insert a row if a matching row doesn't exists.
* @param string $table. The table to insert into in the form '*PREFIX*tableName'
* @param array $input. An array of fieldname/value pairs
- * @return int number of updated rows
+ * @param string $table
+ * @return boolean number of updated rows
*/
public static function insertIfNotExist($table, $input) {
self::connect();
@@ -368,7 +369,7 @@ class OC_DB {
* @brief update the database schema
* @param string $file file to read structure from
* @throws Exception
- * @return bool
+ * @return string|boolean
*/
public static function updateDbFromStructure($file) {
$schemaManager = self::getMDB2SchemaManager();
diff --git a/lib/private/db/connection.php b/lib/private/db/connection.php
index 2581969dbd0..2bd7b093020 100644
--- a/lib/private/db/connection.php
+++ b/lib/private/db/connection.php
@@ -94,7 +94,7 @@ class Connection extends \Doctrine\DBAL\Connection {
* If an SQLLogger is configured, the execution is logged.
*
* @param string $query The SQL query to execute.
- * @param array $params The parameters to bind to the query, if any.
+ * @param string[] $params The parameters to bind to the query, if any.
* @param array $types The types the previous parameters are in.
* @param QueryCacheProfile $qcp
* @return \Doctrine\DBAL\Driver\Statement The executed statement.
diff --git a/lib/private/db/connectionwrapper.php b/lib/private/db/connectionwrapper.php
index 93d4fb57f74..c2cfc21d204 100644
--- a/lib/private/db/connectionwrapper.php
+++ b/lib/private/db/connectionwrapper.php
@@ -31,8 +31,8 @@ class ConnectionWrapper implements \OCP\IDBConnection {
/**
* Used to get the id of the just inserted element
- * @param string $tableName the name of the table where we inserted the item
- * @return int the id of the inserted element
+ * @param string $table the name of the table where we inserted the item
+ * @return string the id of the inserted element
*/
public function lastInsertId($table = null)
{
diff --git a/lib/private/db/mdb2schemamanager.php b/lib/private/db/mdb2schemamanager.php
index 6378c769055..c050d47b499 100644
--- a/lib/private/db/mdb2schemamanager.php
+++ b/lib/private/db/mdb2schemamanager.php
@@ -53,7 +53,7 @@ class MDB2SchemaManager {
/**
* @brief update the database scheme
* @param string $file file to read structure from
- * @return bool
+ * @return string|boolean
*/
public function updateDbFromStructure($file, $generateSql = false) {
$sm = $this->conn->getSchemaManager();
diff --git a/lib/private/db/mdb2schemareader.php b/lib/private/db/mdb2schemareader.php
index b1fd2454cb0..f9a76786c3e 100644
--- a/lib/private/db/mdb2schemareader.php
+++ b/lib/private/db/mdb2schemareader.php
@@ -288,12 +288,13 @@ class MDB2SchemaReader {
if (!empty($fields)) {
if (isset($primary) && $primary) {
$table->setPrimaryKey($fields, $name);
- } else
+ } else {
if (isset($unique) && $unique) {
$table->addUniqueIndex($fields, $name);
} else {
$table->addIndex($fields, $name);
}
+ }
} else {
throw new \DomainException('Empty index definition: ' . $name . ' options:' . print_r($fields, true));
}
diff --git a/lib/private/db/mdb2schemawriter.php b/lib/private/db/mdb2schemawriter.php
index 21b43cbfe80..a2a62a81475 100644
--- a/lib/private/db/mdb2schemawriter.php
+++ b/lib/private/db/mdb2schemawriter.php
@@ -9,7 +9,7 @@
class OC_DB_MDB2SchemaWriter {
/**
- * @param $file
+ * @param string $file
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $sm
* @return bool
*/
@@ -26,6 +26,9 @@ class OC_DB_MDB2SchemaWriter {
return true;
}
+ /**
+ * @param SimpleXMLElement $xml
+ */
private static function saveTable($table, $xml) {
$xml->addChild('name', $table->getName());
$declaration = $xml->addChild('declaration');
@@ -48,6 +51,9 @@ class OC_DB_MDB2SchemaWriter {
}
}
+ /**
+ * @param SimpleXMLElement $xml
+ */
private static function saveColumn($column, $xml) {
$xml->addChild('name', $column->getName());
switch($column->getType()) {
@@ -111,6 +117,9 @@ class OC_DB_MDB2SchemaWriter {
}
}
+ /**
+ * @param SimpleXMLElement $xml
+ */
private static function saveIndex($index, $xml) {
$xml->addChild('name', $index->getName());
if ($index->isPrimary()) {
diff --git a/lib/private/db/statementwrapper.php b/lib/private/db/statementwrapper.php
index 5e89261d936..eaf215c7231 100644
--- a/lib/private/db/statementwrapper.php
+++ b/lib/private/db/statementwrapper.php
@@ -17,6 +17,9 @@ class OC_DB_StatementWrapper {
private $isManipulation = false;
private $lastArguments = array();
+ /**
+ * @param boolean $isManipulation
+ */
public function __construct($statement, $isManipulation) {
$this->statement = $statement;
$this->isManipulation = $isManipulation;
@@ -31,6 +34,9 @@ class OC_DB_StatementWrapper {
/**
* make execute return the result instead of a bool
+ *
+ * @param array $input
+ * @return \OC_DB_StatementWrapper | int
*/
public function execute($input=array()) {
if(OC_Config::getValue( "log_query", false)) {
@@ -169,4 +175,18 @@ class OC_DB_StatementWrapper {
public function fetchOne($colnum = 0) {
return $this->statement->fetchColumn($colnum);
}
+
+ /**
+ * Binds a PHP variable to a corresponding named or question mark placeholder in the
+ * SQL statement that was use to prepare the statement.
+ *
+ * @param mixed $column Either the placeholder name or the 1-indexed placeholder index
+ * @param mixed $variable The variable to bind
+ * @param integer|null $type one of the PDO::PARAM_* constants
+ * @param integer|null $length max length when using an OUT bind
+ * @return boolean
+ */
+ public function bindParam($column, &$variable, $type = null, $length = null){
+ return $this->statement->bindParam($column, $variable, $type, $length);
+ }
}
diff --git a/lib/private/defaults.php b/lib/private/defaults.php
index cec9a65c7f3..0b97497baa1 100644
--- a/lib/private/defaults.php
+++ b/lib/private/defaults.php
@@ -39,6 +39,9 @@ class OC_Defaults {
}
}
+ /**
+ * @param string $method
+ */
private function themeExist($method) {
if (OC_Util::getTheme() !== '' && method_exists('OC_Theme', $method)) {
return true;
diff --git a/lib/private/filechunking.php b/lib/private/filechunking.php
index aa4f73c7c05..be7f4e14a11 100644
--- a/lib/private/filechunking.php
+++ b/lib/private/filechunking.php
@@ -16,6 +16,9 @@ class OC_FileChunking {
return $matches;
}
+ /**
+ * @param string[] $info
+ */
public function __construct($info) {
$this->info = $info;
}
@@ -37,8 +40,8 @@ class OC_FileChunking {
/**
* Stores the given $data under the given $key - the number of stored bytes is returned
*
- * @param $index
- * @param $data
+ * @param string $index
+ * @param resource $data
* @return int
*/
public function store($index, $data) {
@@ -87,7 +90,7 @@ class OC_FileChunking {
/**
* Removes one specific chunk
- * @param $index
+ * @param string $index
*/
public function remove($index) {
$cache = $this->getCache();
@@ -124,6 +127,9 @@ class OC_FileChunking {
);
}
+ /**
+ * @param string $path
+ */
public function file_assemble($path) {
$absolutePath = \OC\Files\Filesystem::normalizePath(\OC\Files\Filesystem::getView()->getAbsolutePath($path));
$data = '';
diff --git a/lib/private/fileproxy.php b/lib/private/fileproxy.php
index 2997aaf81b6..88976c1b8e5 100644
--- a/lib/private/fileproxy.php
+++ b/lib/private/fileproxy.php
@@ -67,6 +67,9 @@ class OC_FileProxy{
self::$proxies[]=$proxy;
}
+ /**
+ * @param string $operation
+ */
public static function getProxies($operation = null) {
if ($operation === null) {
// return all
@@ -81,6 +84,10 @@ class OC_FileProxy{
return $proxies;
}
+ /**
+ * @param string $operation
+ * @param string|boolean $filepath
+ */
public static function runPreProxies($operation,&$filepath,&$filepath2=null) {
if(!self::$enabled) {
return true;
@@ -101,6 +108,12 @@ class OC_FileProxy{
return true;
}
+ /**
+ * @param string $operation
+ * @param string|boolean $path
+ *
+ * @return string
+ */
public static function runPostProxies($operation, $path, $result) {
if(!self::$enabled) {
return $result;
diff --git a/lib/private/files.php b/lib/private/files.php
index 8ce632013cf..656d6f044ca 100644
--- a/lib/private/files.php
+++ b/lib/private/files.php
@@ -32,6 +32,9 @@ class OC_Files {
return \OC\Files\Filesystem::getFileInfo($path, $includeMountPoints);
}
+ /**
+ * @param string $path
+ */
static public function getDirectoryContent($path){
return \OC\Files\Filesystem::getDirectoryContent($path);
}
@@ -40,7 +43,7 @@ class OC_Files {
* return the content of a file or return a zip file containing multiple files
*
* @param string $dir
- * @param string $file ; separated list of files to download
+ * @param string $files ; separated list of files to download
* @param boolean $only_header ; boolean to only send header of the request
*/
public static function get($dir, $files, $only_header = false) {
@@ -103,7 +106,12 @@ class OC_Files {
if ($xsendfile) {
$filename = OC_Helper::moveToNoClean($filename);
}
- $name = $files . '.zip';
+ // downloading root ?
+ if ($files === '') {
+ $name = 'download.zip';
+ } else {
+ $name = $files . '.zip';
+ }
set_time_limit($executionTime);
} else {
$zip = false;
@@ -131,7 +139,7 @@ class OC_Files {
}
if ($xsendfile) {
list($storage) = \OC\Files\Filesystem::resolvePath(\OC\Files\Filesystem::getView()->getAbsolutePath($filename));
- if ($storage instanceof \OC\Files\Storage\Local) {
+ if ($storage->isLocal()) {
self::addSendfileHeader(\OC\Files\Filesystem::getLocalFile($filename));
}
}
@@ -170,6 +178,9 @@ class OC_Files {
}
}
+ /**
+ * @param false|string $filename
+ */
private static function addSendfileHeader($filename) {
if (isset($_SERVER['MOD_X_SENDFILE_ENABLED'])) {
header("X-Sendfile: " . $filename);
@@ -194,10 +205,16 @@ class OC_Files {
}
}
+ /**
+ * @param string $dir
+ * @param ZipArchive $zip
+ */
public static function zipAddDir($dir, $zip, $internalDir='') {
$dirname=basename($dir);
$zip->addEmptyDir($internalDir.$dirname);
$internalDir.=$dirname.='/';
+ // prevent absolute dirs
+ $internalDir = ltrim($internalDir, '/');
$files=OC_Files::getDirectoryContent($dir);
foreach($files as $file) {
$filename=$file['name'];
@@ -215,7 +232,7 @@ class OC_Files {
/**
* checks if the selected files are within the size constraint. If not, outputs an error page.
*
- * @param dir $dir
+ * @param string $dir
* @param files $files
*/
static function validateZipDownload($dir, $files) {
diff --git a/lib/private/files/cache/backgroundwatcher.php b/lib/private/files/cache/backgroundwatcher.php
index 923804f48d0..2194651233d 100644
--- a/lib/private/files/cache/backgroundwatcher.php
+++ b/lib/private/files/cache/backgroundwatcher.php
@@ -24,6 +24,9 @@ class BackgroundWatcher {
return $row['id'];
}
+ /**
+ * @param integer $id
+ */
static private function checkUpdate($id) {
$cacheItem = Cache::getById($id);
if (is_null($cacheItem)) {
diff --git a/lib/private/files/cache/cache.php b/lib/private/files/cache/cache.php
index 1e7936ca26d..4cab4619149 100644
--- a/lib/private/files/cache/cache.php
+++ b/lib/private/files/cache/cache.php
@@ -487,7 +487,7 @@ class Cache {
/**
* update the folder size and the size of all parent folders
*
- * @param $path
+ * @param string|boolean $path
*/
public function correctFolderSize($path) {
$this->calculateFolderSize($path);
diff --git a/lib/private/files/cache/homecache.php b/lib/private/files/cache/homecache.php
index 71bb944da71..a7c310a3782 100644
--- a/lib/private/files/cache/homecache.php
+++ b/lib/private/files/cache/homecache.php
@@ -38,6 +38,9 @@ class HomeCache extends Cache {
return $totalSize;
}
+ /**
+ * @param string $path
+ */
public function get($path) {
$data = parent::get($path);
if ($path === '' or $path === '/') {
diff --git a/lib/private/files/cache/legacy.php b/lib/private/files/cache/legacy.php
index 8eed1f67a5d..4d5f58741e9 100644
--- a/lib/private/files/cache/legacy.php
+++ b/lib/private/files/cache/legacy.php
@@ -16,6 +16,9 @@ class Legacy {
private $cacheHasItems = null;
+ /**
+ * @param string $user
+ */
public function __construct($user) {
$this->user = $user;
}
@@ -69,7 +72,7 @@ class Legacy {
/**
* get an item from the legacy cache
*
- * @param string|int $path
+ * @param string $path
* @return array
*/
function get($path) {
diff --git a/lib/private/files/cache/storage.php b/lib/private/files/cache/storage.php
index 5657cf06e12..6b6b0bce9d7 100644
--- a/lib/private/files/cache/storage.php
+++ b/lib/private/files/cache/storage.php
@@ -47,6 +47,9 @@ class Storage {
return $this->numericId;
}
+ /**
+ * @return string
+ */
public static function getStorageId($numericId) {
$sql = 'SELECT `id` FROM `*PREFIX*storages` WHERE `numeric_id` = ?';
@@ -58,6 +61,9 @@ class Storage {
}
}
+ /**
+ * @param string $storageId
+ */
public static function exists($storageId) {
if (strlen($storageId) > 64) {
$storageId = md5($storageId);
@@ -70,4 +76,23 @@ class Storage {
return false;
}
}
+
+ /**
+ * remove the entry for the storage
+ *
+ * @param string $storageId
+ */
+ public static function remove($storageId) {
+ $storageCache = new Storage($storageId);
+ $numericId = $storageCache->getNumericId();
+
+ if (strlen($storageId) > 64) {
+ $storageId = md5($storageId);
+ }
+ $sql = 'DELETE FROM `*PREFIX*storages` WHERE `id` = ?';
+ \OC_DB::executeAudited($sql, array($storageId));
+
+ $sql = 'DELETE FROM `*PREFIX*filecache` WHERE `storage` = ?';
+ \OC_DB::executeAudited($sql, array($numericId));
+ }
}
diff --git a/lib/private/files/cache/updater.php b/lib/private/files/cache/updater.php
index 73bc30e538f..7a45b9e9e96 100644
--- a/lib/private/files/cache/updater.php
+++ b/lib/private/files/cache/updater.php
@@ -8,8 +8,6 @@
namespace OC\Files\Cache;
-use OCP\Util;
-
/**
* listen to filesystem hooks and change the cache accordingly
*/
@@ -112,7 +110,7 @@ class Updater {
/**
* @brief get file owner and path
* @param string $filename
- * @return array with the oweners uid and the owners path
+ * @return string[] with the oweners uid and the owners path
*/
private static function getUidAndFilename($filename) {
diff --git a/lib/private/files/cache/watcher.php b/lib/private/files/cache/watcher.php
index 251ecbe7071..48aa6f853ce 100644
--- a/lib/private/files/cache/watcher.php
+++ b/lib/private/files/cache/watcher.php
@@ -12,6 +12,14 @@ namespace OC\Files\Cache;
* check the storage backends for updates and change the cache accordingly
*/
class Watcher {
+ const CHECK_NEVER = 0; // never check the underlying filesystem for updates
+ const CHECK_ONCE = 1; // check the underlying filesystem for updates once every request for each file
+ const CHECK_ALWAYS = 2; // always check the underlying filesystem for updates
+
+ protected $watchPolicy = self::CHECK_ONCE;
+
+ protected $checkedPaths = array();
+
/**
* @var \OC\Files\Storage\Storage $storage
*/
@@ -23,7 +31,7 @@ class Watcher {
protected $cache;
/**
- * @var Scanner $scanner;
+ * @var Scanner $scanner ;
*/
protected $scanner;
@@ -37,26 +45,38 @@ class Watcher {
}
/**
+ * @param int $policy either \OC\Files\Cache\Watcher::UPDATE_NEVER, \OC\Files\Cache\Watcher::UPDATE_ONCE, \OC\Files\Cache\Watcher::UPDATE_ALWAYS
+ */
+ public function setPolicy($policy) {
+ $this->watchPolicy = $policy;
+ }
+
+ /**
* check $path for updates
*
* @param string $path
* @return boolean | array true if path was updated, otherwise the cached data is returned
*/
public function checkUpdate($path) {
- $cachedEntry = $this->cache->get($path);
- if ($this->storage->hasUpdated($path, $cachedEntry['storage_mtime'])) {
- if ($this->storage->is_dir($path)) {
- $this->scanner->scan($path, Scanner::SCAN_SHALLOW);
- } else {
- $this->scanner->scanFile($path);
- }
- if ($cachedEntry['mimetype'] === 'httpd/unix-directory') {
- $this->cleanFolder($path);
+ if ($this->watchPolicy === self::CHECK_ALWAYS or ($this->watchPolicy === self::CHECK_ONCE and array_search($path, $this->checkedPaths) === false)) {
+ $cachedEntry = $this->cache->get($path);
+ $this->checkedPaths[] = $path;
+ if ($this->storage->hasUpdated($path, $cachedEntry['storage_mtime'])) {
+ if ($this->storage->is_dir($path)) {
+ $this->scanner->scan($path, Scanner::SCAN_SHALLOW);
+ } else {
+ $this->scanner->scanFile($path);
+ }
+ if ($cachedEntry['mimetype'] === 'httpd/unix-directory') {
+ $this->cleanFolder($path);
+ }
+ $this->cache->correctFolderSize($path);
+ return true;
}
- $this->cache->correctFolderSize($path);
- return true;
+ return $cachedEntry;
+ } else {
+ return false;
}
- return $cachedEntry;
}
/**
diff --git a/lib/private/files/fileinfo.php b/lib/private/files/fileinfo.php
new file mode 100644
index 00000000000..2dbdd80a26b
--- /dev/null
+++ b/lib/private/files/fileinfo.php
@@ -0,0 +1,189 @@
+<?php
+/**
+ * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ */
+
+namespace OC\Files;
+
+class FileInfo implements \OCP\Files\FileInfo, \ArrayAccess {
+ /**
+ * @var array $data
+ */
+ private $data;
+
+ /**
+ * @var string $path
+ */
+ private $path;
+
+ /**
+ * @var \OC\Files\Storage\Storage $storage
+ */
+ private $storage;
+
+ /**
+ * @var string $internalPath
+ */
+ private $internalPath;
+
+ /**
+ * @param string|boolean $path
+ * @param Storage\Storage $storage
+ */
+ public function __construct($path, $storage, $internalPath, $data) {
+ $this->path = $path;
+ $this->storage = $storage;
+ $this->internalPath = $internalPath;
+ $this->data = $data;
+ }
+
+ public function offsetSet($offset, $value) {
+ $this->data[$offset] = $value;
+ }
+
+ public function offsetExists($offset) {
+ return isset($this->data[$offset]);
+ }
+
+ public function offsetUnset($offset) {
+ unset($this->data[$offset]);
+ }
+
+ public function offsetGet($offset) {
+ return $this->data[$offset];
+ }
+
+ /**
+ * @return string
+ */
+ public function getPath() {
+ return $this->path;
+ }
+
+ /**
+ * @return \OCP\Files\Storage
+ */
+ public function getStorage() {
+ return $this->storage;
+ }
+
+ /**
+ * @return string
+ */
+ public function getInternalPath() {
+ return $this->internalPath;
+ }
+
+ /**
+ * @return int
+ */
+ public function getId() {
+ return $this->data['fileid'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getMimetype() {
+ return $this->data['mimetype'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getMimePart() {
+ return $this->data['mimepart'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getName() {
+ return $this->data['name'];
+ }
+
+ /**
+ * @return string
+ */
+ public function getEtag() {
+ return $this->data['etag'];
+ }
+
+ /**
+ * @return int
+ */
+ public function getSize() {
+ return $this->data['size'];
+ }
+
+ /**
+ * @return int
+ */
+ public function getMTime() {
+ return $this->data['mtime'];
+ }
+
+ /**
+ * @return bool
+ */
+ public function isEncrypted() {
+ return $this->data['encrypted'];
+ }
+
+ /**
+ * @return int
+ */
+ public function getPermissions() {
+ return $this->data['permissions'];
+ }
+
+ /**
+ * @return \OCP\Files\FileInfo::TYPE_FILE | \OCP\Files\FileInfo::TYPE_FOLDER
+ */
+ public function getType() {
+ return $this->data['type'];
+ }
+
+ public function getData(){
+ return $this->data;
+ }
+
+ /**
+ * @param int $permissions
+ * @return bool
+ */
+ protected function checkPermissions($permissions) {
+ return ($this->getPermissions() & $permissions) === $permissions;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isReadable() {
+ return $this->checkPermissions(\OCP\PERMISSION_READ);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isUpdateable() {
+ return $this->checkPermissions(\OCP\PERMISSION_UPDATE);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isDeletable() {
+ return $this->checkPermissions(\OCP\PERMISSION_DELETE);
+ }
+
+ /**
+ * @return bool
+ */
+ public function isShareable() {
+ return $this->checkPermissions(\OCP\PERMISSION_SHARE);
+ }
+}
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index a83e9aa86d2..952f9f9febf 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -320,16 +320,16 @@ class Filesystem {
else {
self::mount('\OC\Files\Storage\Local', array('datadir' => $root), $user);
}
- $datadir = \OC_Config::getValue("datadirectory", \OC::$SERVERROOT . "/data");
+ $mount_file = \OC_Config::getValue("mount_file", \OC::$SERVERROOT . "/data/mount.json");
//move config file to it's new position
if (is_file(\OC::$SERVERROOT . '/config/mount.json')) {
- rename(\OC::$SERVERROOT . '/config/mount.json', $datadir . '/mount.json');
+ rename(\OC::$SERVERROOT . '/config/mount.json', $mount_file);
}
// Load system mount points
- if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file($datadir . '/mount.json')) {
- if (is_file($datadir . '/mount.json')) {
- $mountConfig = json_decode(file_get_contents($datadir . '/mount.json'), true);
+ if (is_file(\OC::$SERVERROOT . '/config/mount.php') or is_file($mount_file)) {
+ if (is_file($mount_file)) {
+ $mountConfig = json_decode(file_get_contents($mount_file), true);
} elseif (is_file(\OC::$SERVERROOT . '/config/mount.php')) {
$mountConfig = $parser->parsePHP(file_get_contents(\OC::$SERVERROOT . '/config/mount.php'));
}
@@ -614,6 +614,9 @@ class Filesystem {
return self::$defaultInstance->touch($path, $mtime);
}
+ /**
+ * @return string
+ */
static public function file_get_contents($path) {
return self::$defaultInstance->file_get_contents($path);
}
@@ -638,6 +641,9 @@ class Filesystem {
return self::$defaultInstance->fopen($path, $mode);
}
+ /**
+ * @return string
+ */
static public function toTmpFile($path) {
return self::$defaultInstance->toTmpFile($path);
}
@@ -662,6 +668,9 @@ class Filesystem {
return self::$defaultInstance->search($query);
}
+ /**
+ * @param string $query
+ */
static public function searchByMime($query) {
return self::$defaultInstance->searchByMime($query);
}
@@ -727,14 +736,7 @@ class Filesystem {
* @param string $path
* @param boolean $includeMountPoints whether to add mountpoint sizes,
* defaults to true
- * @return array
- *
- * returns an associative array with the following keys:
- * - size
- * - mtime
- * - mimetype
- * - encrypted
- * - versioned
+ * @return \OC\Files\FileInfo
*/
public static function getFileInfo($path, $includeMountPoints = true) {
return self::$defaultInstance->getFileInfo($path, $includeMountPoints);
diff --git a/lib/private/files/mapper.php b/lib/private/files/mapper.php
index 47abd4e52fe..833d4bd8d1c 100644
--- a/lib/private/files/mapper.php
+++ b/lib/private/files/mapper.php
@@ -44,7 +44,7 @@ class Mapper
/**
* @param string $path
* @param bool $isLogicPath indicates if $path is logical or physical
- * @param $recursive
+ * @param boolean $recursive
* @return void
*/
public function removePath($path, $isLogicPath, $recursive) {
@@ -60,8 +60,8 @@ class Mapper
}
/**
- * @param $path1
- * @param $path2
+ * @param string $path1
+ * @param string $path2
* @throws \Exception
*/
public function copy($path1, $path2)
@@ -99,7 +99,7 @@ class Mapper
/**
* @param $path
* @param $root
- * @return bool|string
+ * @return false|string
*/
public function stripRootFolder($path, $root) {
if (strpos($path, $root) !== 0) {
@@ -120,6 +120,9 @@ class Mapper
return $path;
}
+ /**
+ * @param string $logicPath
+ */
private function resolveLogicPath($logicPath) {
$logicPath = $this->stripLast($logicPath);
$sql = 'SELECT * FROM `*PREFIX*file_map` WHERE `logic_path_hash` = ?';
@@ -141,6 +144,10 @@ class Mapper
return $result['logic_path'];
}
+ /**
+ * @param string $logicPath
+ * @param boolean $store
+ */
private function create($logicPath, $store) {
$logicPath = $this->stripLast($logicPath);
$index = 0;
@@ -167,6 +174,9 @@ class Mapper
\OC_DB::executeAudited($sql, array($logicPath, $physicalPath, md5($logicPath), md5($physicalPath)));
}
+ /**
+ * @param integer $index
+ */
public function slugifyPath($path, $index=null) {
$path = $this->stripRootFolder($path, $this->unchangedPhysicalRoot);
diff --git a/lib/private/files/mount/manager.php b/lib/private/files/mount/manager.php
index 4c432dcf724..ff4a336f347 100644
--- a/lib/private/files/mount/manager.php
+++ b/lib/private/files/mount/manager.php
@@ -106,7 +106,7 @@ class Manager {
* Find mounts by numeric storage id
*
* @param string $id
- * @return Mount
+ * @return Mount[]
*/
public function findByNumericId($id) {
$storageId = \OC\Files\Cache\Storage::getStorageId($id);
diff --git a/lib/private/files/node/folder.php b/lib/private/files/node/folder.php
index 923f53821b2..d9e0ddc2d61 100644
--- a/lib/private/files/node/folder.php
+++ b/lib/private/files/node/folder.php
@@ -9,7 +9,6 @@
namespace OC\Files\Node;
use OC\Files\Cache\Cache;
-use OC\Files\Cache\Scanner;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
diff --git a/lib/private/files/node/node.php b/lib/private/files/node/node.php
index 063e2424a64..bc075911749 100644
--- a/lib/private/files/node/node.php
+++ b/lib/private/files/node/node.php
@@ -8,8 +8,6 @@
namespace OC\Files\Node;
-use OC\Files\Cache\Cache;
-use OC\Files\Cache\Scanner;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
@@ -31,7 +29,7 @@ class Node implements \OCP\Files\Node {
/**
* @param \OC\Files\View $view
- * @param \OC\Files\Node\Root Root $root
+ * @param \OC\Files\Node\Root $root
* @param string $path
*/
public function __construct($root, $view, $path) {
diff --git a/lib/private/files/node/root.php b/lib/private/files/node/root.php
index e3d58476e9c..70135285b0d 100644
--- a/lib/private/files/node/root.php
+++ b/lib/private/files/node/root.php
@@ -9,7 +9,6 @@
namespace OC\Files\Node;
use OC\Files\Cache\Cache;
-use OC\Files\Cache\Scanner;
use OC\Files\Mount\Manager;
use OC\Files\Mount\Mount;
use OCP\Files\NotFoundException;
@@ -95,7 +94,7 @@ class Root extends Folder implements Emitter {
/**
* @param string $scope
* @param string $method
- * @param array $arguments
+ * @param Node[] $arguments
*/
public function emit($scope, $method, $arguments = array()) {
$this->emitter->emit($scope, $method, $arguments);
@@ -154,7 +153,7 @@ class Root extends Folder implements Emitter {
* @param string $path
* @throws \OCP\Files\NotFoundException
* @throws \OCP\Files\NotPermittedException
- * @return Node
+ * @return string
*/
public function get($path) {
$path = $this->normalizePath($path);
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php
index 678bf419023..d4dca780ff3 100644
--- a/lib/private/files/storage/common.php
+++ b/lib/private/files/storage/common.php
@@ -202,6 +202,9 @@ abstract class Common implements \OC\Files\Storage\Storage {
return $this->toTmpFile($path);
}
+ /**
+ * @param string $path
+ */
private function toTmpFile($path) { //no longer in the storage api, still useful here
$source = $this->fopen($path, 'r');
if (!$source) {
@@ -224,6 +227,10 @@ abstract class Common implements \OC\Files\Storage\Storage {
return $baseDir;
}
+ /**
+ * @param string $path
+ * @param string $target
+ */
private function addLocalFolder($path, $target) {
$dh = $this->opendir($path);
if (is_resource($dh)) {
@@ -241,6 +248,9 @@ abstract class Common implements \OC\Files\Storage\Storage {
}
}
+ /**
+ * @param string $query
+ */
protected function searchInDir($query, $dir = '') {
$files = array();
$dh = $this->opendir($dir);
@@ -370,4 +380,13 @@ abstract class Common implements \OC\Files\Storage\Storage {
public function free_space($path) {
return \OC\Files\SPACE_UNKNOWN;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isLocal() {
+ // the common implementation returns a temporary file by
+ // default, which is not local
+ return false;
+ }
}
diff --git a/lib/private/files/storage/loader.php b/lib/private/files/storage/loader.php
index 2572ef443bc..966234cb04d 100644
--- a/lib/private/files/storage/loader.php
+++ b/lib/private/files/storage/loader.php
@@ -25,10 +25,17 @@ class Loader {
$this->storageWrappers[] = $callback;
}
+ /**
+ * @param string|boolean $mountPoint
+ * @param string $class
+ */
public function load($mountPoint, $class, $arguments) {
return $this->wrap($mountPoint, new $class($arguments));
}
+ /**
+ * @param string|boolean $mountPoint
+ */
public function wrap($mountPoint, $storage) {
foreach ($this->storageWrappers as $wrapper) {
$storage = $wrapper($mountPoint, $storage);
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php
index db3c6bfca3a..a62230bdba5 100644
--- a/lib/private/files/storage/local.php
+++ b/lib/private/files/storage/local.php
@@ -203,6 +203,9 @@ if (\OC_Util::runningOnWindows()) {
return $return;
}
+ /**
+ * @param string $dir
+ */
private function delTree($dir) {
$dirRelative = $dir;
$dir = $this->datadir . $dir;
@@ -224,6 +227,9 @@ if (\OC_Util::runningOnWindows()) {
return $return;
}
+ /**
+ * @param string $fullPath
+ */
private static function getFileSizeFromOS($fullPath) {
$name = strtolower(php_uname('s'));
// Windows OS: we use COM to access the filesystem
@@ -274,6 +280,9 @@ if (\OC_Util::runningOnWindows()) {
return $this->datadir . $path;
}
+ /**
+ * @param string $query
+ */
protected function searchInDir($query, $dir = '') {
$files = array();
foreach (scandir($this->datadir . $dir) as $item) {
@@ -298,5 +307,12 @@ if (\OC_Util::runningOnWindows()) {
public function hasUpdated($path, $time) {
return $this->filemtime($path) > $time;
}
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isLocal() {
+ return true;
+ }
}
}
diff --git a/lib/private/files/storage/mappedlocal.php b/lib/private/files/storage/mappedlocal.php
index 6c37d445867..1bab3489a28 100644
--- a/lib/private/files/storage/mappedlocal.php
+++ b/lib/private/files/storage/mappedlocal.php
@@ -210,6 +210,9 @@ class MappedLocal extends \OC\Files\Storage\Common{
return $return;
}
+ /**
+ * @param string $dir
+ */
private function delTree($dir, $isLogicPath=true) {
$dirRelative=$dir;
if ($isLogicPath) {
@@ -244,6 +247,9 @@ class MappedLocal extends \OC\Files\Storage\Common{
return $return;
}
+ /**
+ * @param string $fullPath
+ */
private static function getFileSizeFromOS($fullPath) {
$name = strtolower(php_uname('s'));
// Windows OS: we use COM to access the filesystem
@@ -288,6 +294,9 @@ class MappedLocal extends \OC\Files\Storage\Common{
return $this->buildPath($path);
}
+ /**
+ * @param string $query
+ */
protected function searchInDir($query, $dir='') {
$files=array();
$physicalDir = $this->buildPath($dir);
@@ -317,12 +326,18 @@ class MappedLocal extends \OC\Files\Storage\Common{
return $this->filemtime($path)>$time;
}
+ /**
+ * @param string $path
+ */
private function buildPath($path, $create=true) {
$path = $this->stripLeading($path);
$fullPath = $this->datadir.$path;
return $this->mapper->logicToPhysical($fullPath, $create);
}
+ /**
+ * @param string $path
+ */
private function cleanMapper($path, $isLogicPath=true, $recursive=true) {
$fullPath = $path;
if ($isLogicPath) {
@@ -331,6 +346,10 @@ class MappedLocal extends \OC\Files\Storage\Common{
$this->mapper->removePath($fullPath, $isLogicPath, $recursive);
}
+ /**
+ * @param string $path1
+ * @param string $path2
+ */
private function copyMapping($path1, $path2) {
$path1 = $this->stripLeading($path1);
$path2 = $this->stripLeading($path2);
diff --git a/lib/private/files/storage/wrapper/quota.php b/lib/private/files/storage/wrapper/quota.php
index 16127403181..26c952e694a 100644
--- a/lib/private/files/storage/wrapper/quota.php
+++ b/lib/private/files/storage/wrapper/quota.php
@@ -29,6 +29,9 @@ class Quota extends Wrapper {
$this->sizeRoot = isset($parameters['root']) ? $parameters['root'] : '';
}
+ /**
+ * @param string $path
+ */
protected function getSize($path) {
$cache = $this->getCache();
$data = $cache->get($path);
diff --git a/lib/private/files/storage/wrapper/wrapper.php b/lib/private/files/storage/wrapper/wrapper.php
index f9adda80314..11ea9f71da7 100644
--- a/lib/private/files/storage/wrapper/wrapper.php
+++ b/lib/private/files/storage/wrapper/wrapper.php
@@ -432,4 +432,12 @@ class Wrapper implements \OC\Files\Storage\Storage {
public function test() {
return $this->storage->test();
}
+
+ /**
+ * Returns the wrapped storage's value for isLocal()
+ * @return bool wrapped storage's isLocal() value
+ */
+ public function isLocal() {
+ return $this->storage->isLocal();
+ }
}
diff --git a/lib/private/files/stream/close.php b/lib/private/files/stream/close.php
index 80de3497c36..0e1f088fcf9 100644
--- a/lib/private/files/stream/close.php
+++ b/lib/private/files/stream/close.php
@@ -94,6 +94,9 @@ class Close {
return unlink($path);
}
+ /**
+ * @param string $path
+ */
public static function registerCallback($path, $callback) {
self::$callBacks[$path] = $callback;
}
diff --git a/lib/private/files/stream/dir.php b/lib/private/files/stream/dir.php
index 6ca884fc994..2483385c1d8 100644
--- a/lib/private/files/stream/dir.php
+++ b/lib/private/files/stream/dir.php
@@ -41,6 +41,9 @@ class Dir {
return true;
}
+ /**
+ * @param string $path
+ */
public static function register($path, $content) {
self::$dirs[$path] = $content;
}
diff --git a/lib/private/files/utils/scanner.php b/lib/private/files/utils/scanner.php
index 2cad7dd77bd..a802a8fcb8b 100644
--- a/lib/private/files/utils/scanner.php
+++ b/lib/private/files/utils/scanner.php
@@ -69,6 +69,9 @@ class Scanner extends PublicEmitter {
});
}
+ /**
+ * @param string $dir
+ */
public function backgroundScan($dir) {
$mounts = $this->getMounts($dir);
foreach ($mounts as $mount) {
@@ -81,6 +84,9 @@ class Scanner extends PublicEmitter {
}
}
+ /**
+ * @param string $dir
+ */
public function scan($dir) {
$mounts = $this->getMounts($dir);
foreach ($mounts as $mount) {
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index d97544b865e..530aa8f7514 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -48,7 +48,7 @@ class View {
* change the root to a fake root
*
* @param string $fakeRoot
- * @return bool
+ * @return boolean|null
*/
public function chroot($fakeRoot) {
if (!$fakeRoot == '') {
@@ -352,6 +352,9 @@ class View {
return $this->basicOperation('unlink', $path, array('delete'));
}
+ /**
+ * @param string $directory
+ */
public function deleteAll($directory, $empty = false) {
return $this->rmdir($directory);
}
@@ -735,6 +738,9 @@ class View {
return (strlen($this->fakeRoot) > strlen($defaultRoot)) && (substr($this->fakeRoot, 0, strlen($defaultRoot) + 1) === $defaultRoot . '/');
}
+ /**
+ * @param string $path
+ */
private function runHooks($hooks, $path, $post = false) {
$path = $this->getHookPath($path);
$prefix = ($post) ? 'post_' : '';
@@ -781,14 +787,7 @@ class View {
* @param string $path
* @param boolean $includeMountPoints whether to add mountpoint sizes,
* defaults to true
- * @return array
- *
- * returns an associative array with the following keys:
- * - size
- * - mtime
- * - mimetype
- * - encrypted
- * - versioned
+ * @return \OC\Files\FileInfo | false
*/
public function getFileInfo($path, $includeMountPoints = true) {
$data = array();
@@ -841,10 +840,13 @@ class View {
$data['permissions'] = $permissions;
}
}
+ if (!$data) {
+ return false;
+ }
$data = \OC_FileProxy::runPostProxies('getFileInfo', $path, $data);
- return $data;
+ return new FileInfo($path, $storage, $internalPath, $data);
}
/**
@@ -852,7 +854,7 @@ class View {
*
* @param string $directory path under datadirectory
* @param string $mimetype_filter limit returned content to this mimetype or mimepart
- * @return array
+ * @return FileInfo[]
*/
public function getDirectoryContent($directory, $mimetype_filter = '') {
$result = array();
@@ -878,7 +880,11 @@ class View {
$watcher->checkUpdate($internalPath);
}
- $files = $cache->getFolderContents($internalPath); //TODO: mimetype_filter
+ $files = array();
+ $contents = $cache->getFolderContents($internalPath); //TODO: mimetype_filter
+ foreach ($contents as $content) {
+ $files[] = new FileInfo($path . '/' . $content['name'], $storage, $content['path'], $content);
+ }
$permissions = $permissionsCache->getDirectoryPermissions($cache->getId($internalPath), $user);
$ids = array();
@@ -936,7 +942,7 @@ class View {
break;
}
}
- $files[] = $rootEntry;
+ $files[] = new FileInfo($path . '/' . $rootEntry['name'], $subStorage, '', $rootEntry);
}
}
}
@@ -958,6 +964,7 @@ class View {
$result = $files;
}
}
+
return $result;
}
@@ -965,12 +972,15 @@ class View {
* change file metadata
*
* @param string $path
- * @param array $data
+ * @param array | \OCP\Files\FileInfo $data
* @return int
*
* returns the fileid of the updated file
*/
public function putFileInfo($path, $data) {
+ if ($data instanceof FileInfo) {
+ $data = $data->getData();
+ }
$path = Filesystem::normalizePath($this->fakeRoot . '/' . $path);
/**
* @var \OC\Files\Storage\Storage $storage
@@ -995,7 +1005,7 @@ class View {
* search for files with the name matching $query
*
* @param string $query
- * @return array
+ * @return FileInfo[]
*/
public function search($query) {
return $this->searchCommon('%' . $query . '%', 'search');
@@ -1005,7 +1015,7 @@ class View {
* search for files by mimetype
*
* @param string $mimetype
- * @return array
+ * @return FileInfo[]
*/
public function searchByMime($mimetype) {
return $this->searchCommon($mimetype, 'searchByMime');
@@ -1014,7 +1024,7 @@ class View {
/**
* @param string $query
* @param string $method
- * @return array
+ * @return FileInfo[]
*/
private function searchCommon($query, $method) {
$files = array();
@@ -1028,8 +1038,9 @@ class View {
$results = $cache->$method($query);
foreach ($results as $result) {
if (substr($mountPoint . $result['path'], 0, $rootLength + 1) === $this->fakeRoot . '/') {
+ $internalPath = $result['path'];
$result['path'] = substr($mountPoint . $result['path'], $rootLength);
- $files[] = $result;
+ $files[] = new FileInfo($mountPoint . $result['path'], $storage, $internalPath, $result);
}
}
@@ -1043,8 +1054,9 @@ class View {
$results = $cache->$method($query);
if ($results) {
foreach ($results as $result) {
+ $internalPath = $result['path'];
$result['path'] = $relativeMountPoint . $result['path'];
- $files[] = $result;
+ $files[] = new FileInfo($mountPoint . $result['path'], $storage, $internalPath, $result);
}
}
}
diff --git a/lib/private/geo.php b/lib/private/geo.php
index ed01ad0b616..7094d885af6 100644
--- a/lib/private/geo.php
+++ b/lib/private/geo.php
@@ -12,6 +12,10 @@ class OC_Geo{
* @param (string) $longitude - Longitude
* @return (string) $timezone - closest timezone
*/
+ /**
+ * @param integer $latitude
+ * @param integer $longitude
+ */
public static function timezone($latitude, $longitude) {
$alltimezones = DateTimeZone::listIdentifiers();
$variances = array();
diff --git a/lib/private/group.php b/lib/private/group.php
index 444788c97f1..4c187b538af 100644
--- a/lib/private/group.php
+++ b/lib/private/group.php
@@ -243,7 +243,7 @@ class OC_Group {
/**
* @brief get a list of all users in several groups
- * @param array $gids
+ * @param string[] $gids
* @param string $search
* @param int $limit
* @param int $offset
diff --git a/lib/private/group/dummy.php b/lib/private/group/dummy.php
index 9516fd52ff8..da26e1b910e 100644
--- a/lib/private/group/dummy.php
+++ b/lib/private/group/dummy.php
@@ -28,7 +28,7 @@ class OC_Group_Dummy extends OC_Group_Backend {
private $groups=array();
/**
* @brief Try to create a new group
- * @param $gid The name of the group to create
+ * @param string $gid The name of the group to create
* @returns true/false
*
* Trys to create a new group. If the group name already exists, false will
diff --git a/lib/private/group/manager.php b/lib/private/group/manager.php
index bf469d51d12..9b433b64fd4 100644
--- a/lib/private/group/manager.php
+++ b/lib/private/group/manager.php
@@ -76,12 +76,7 @@ class Manager extends PublicEmitter {
if (isset($this->cachedGroups[$gid])) {
return $this->cachedGroups[$gid];
}
- foreach ($this->backends as $backend) {
- if ($backend->groupExists($gid)) {
- return $this->getGroupObject($gid);
- }
- }
- return null;
+ return $this->getGroupObject($gid);
}
protected function getGroupObject($gid) {
@@ -91,6 +86,9 @@ class Manager extends PublicEmitter {
$backends[] = $backend;
}
}
+ if (count($backends) === 0) {
+ return null;
+ }
$this->cachedGroups[$gid] = new Group($gid, $backends, $this->userManager, $this);
return $this->cachedGroups[$gid];
}
@@ -110,8 +108,8 @@ class Manager extends PublicEmitter {
public function createGroup($gid) {
if (!$gid) {
return false;
- } else if ($this->groupExists($gid)) {
- return $this->get($gid);
+ } else if ($group = $this->get($gid)) {
+ return $group;
} else {
$this->emit('\OC\Group', 'preCreate', array($gid));
foreach ($this->backends as $backend) {
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 580f81acc62..1aab2f296e1 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -151,7 +151,33 @@ class OC_Helper {
*/
public static function mimetypeIcon($mimetype) {
$alias = array(
- 'application/xml' => 'code/xml',
+ 'application/octet-stream' => 'file', // use file icon as fallback
+
+ 'application/illustrator' => 'image',
+ 'application/coreldraw' => 'image',
+ 'application/x-gimp' => 'image',
+ 'application/x-photoshop' => 'image',
+
+ 'application/x-font-ttf' => 'font',
+ 'application/font-woff' => 'font',
+ 'application/vnd.ms-fontobject' => 'font',
+
+ 'application/json' => 'text/code',
+ 'application/x-perl' => 'text/code',
+ 'application/x-php' => 'text/code',
+ 'text/x-shellscript' => 'text/code',
+ 'application/xml' => 'text/html',
+ 'text/css' => 'text/code',
+ 'application/x-tex' => 'text',
+
+ 'application/x-compressed' => 'package/x-generic',
+ 'application/x-7z-compressed' => 'package/x-generic',
+ 'application/x-deb' => 'package/x-generic',
+ 'application/x-gzip' => 'package/x-generic',
+ 'application/x-rar-compressed' => 'package/x-generic',
+ 'application/x-tar' => 'package/x-generic',
+ 'application/zip' => 'package/x-generic',
+
'application/msword' => 'x-office/document',
'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document',
'application/vnd.openxmlformats-officedocument.wordprocessingml.template' => 'x-office/document',
@@ -161,6 +187,7 @@ class OC_Helper {
'application/vnd.oasis.opendocument.text-template' => 'x-office/document',
'application/vnd.oasis.opendocument.text-web' => 'x-office/document',
'application/vnd.oasis.opendocument.text-master' => 'x-office/document',
+
'application/mspowerpoint' => 'x-office/presentation',
'application/vnd.ms-powerpoint' => 'x-office/presentation',
'application/vnd.openxmlformats-officedocument.presentationml.presentation' => 'x-office/presentation',
@@ -172,6 +199,7 @@ class OC_Helper {
'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' => 'x-office/presentation',
'application/vnd.oasis.opendocument.presentation' => 'x-office/presentation',
'application/vnd.oasis.opendocument.presentation-template' => 'x-office/presentation',
+
'application/msexcel' => 'x-office/spreadsheet',
'application/vnd.ms-excel' => 'x-office/spreadsheet',
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'x-office/spreadsheet',
@@ -182,6 +210,8 @@ class OC_Helper {
'application/vnd.ms-excel.sheet.binary.macroEnabled.12' => 'x-office/spreadsheet',
'application/vnd.oasis.opendocument.spreadsheet' => 'x-office/spreadsheet',
'application/vnd.oasis.opendocument.spreadsheet-template' => 'x-office/spreadsheet',
+ 'text/csv' => 'x-office/spreadsheet',
+
'application/msaccess' => 'database',
);
@@ -804,18 +834,22 @@ class OC_Helper {
/**
* @brief calculates the maximum upload size respecting system settings, free space and user quota
*
- * @param $dir the current folder where the user currently operates
- * @return number of bytes representing
+ * @param string $dir the current folder where the user currently operates
+ * @param int $freeSpace the number of bytes free on the storage holding $dir, if not set this will be received from the storage directly
+ * @return int number of bytes representing
*/
- public static function maxUploadFilesize($dir) {
- return min(self::freeSpace($dir), self::uploadLimit());
+ public static function maxUploadFilesize($dir, $freeSpace = null) {
+ if (is_null($freeSpace)){
+ $freeSpace = self::freeSpace($dir);
+ }
+ return min($freeSpace, self::uploadLimit());
}
/**
* Calculate free space left within user quota
*
- * @param $dir the current folder where the user currently operates
- * @return number of bytes representing
+ * @param string $dir the current folder where the user currently operates
+ * @return int number of bytes representing
*/
public static function freeSpace($dir) {
$freeSpace = \OC\Files\Filesystem::free_space($dir);
diff --git a/lib/private/hooks/emitter.php b/lib/private/hooks/emitter.php
index 8e9074bad67..8d58dd936cc 100644
--- a/lib/private/hooks/emitter.php
+++ b/lib/private/hooks/emitter.php
@@ -20,6 +20,7 @@ interface Emitter {
* @param string $scope
* @param string $method
* @param callable $callback
+ * @return void
*/
public function listen($scope, $method, $callback);
@@ -27,6 +28,7 @@ interface Emitter {
* @param string $scope optional
* @param string $method optional
* @param callable $callback optional
+ * @return void
*/
public function removeListener($scope = null, $method = null, $callback = null);
}
diff --git a/lib/private/image.php b/lib/private/image.php
index 62d2a1f0fff..17caaa012f5 100644
--- a/lib/private/image.php
+++ b/lib/private/image.php
@@ -34,7 +34,7 @@ class OC_Image {
/**
* @brief Get mime type for an image file.
- * @param $filepath The path to a local image file.
+ * @param string|null $filepath The path to a local image file.
* @returns string The mime type if the it could be determined, otherwise an empty string.
*/
static public function getMimeTypeForFile($filePath) {
@@ -163,6 +163,7 @@ class OC_Image {
/**
* @brief Saves the image.
* @returns bool
+ * @param string $filePath
*/
public function save($filePath=null) {
@@ -396,7 +397,7 @@ class OC_Image {
/**
* @brief Loads an image from an open file handle.
* It is the responsibility of the caller to position the pointer at the correct place and to close the handle again.
- * @param $handle
+ * @param resource $handle
* @returns An image resource or false on error
*/
public function loadFromFileHandle($handle) {
@@ -563,7 +564,7 @@ class OC_Image {
* Create a new image from file or URL
* @link http://www.programmierer-forum.de/function-imagecreatefrombmp-laeuft-mit-allen-bitraten-t143137.htm
* @version 1.00
- * @param string $filename <p>
+ * @param string $fileName <p>
* Path to the BMP image.
* </p>
* @return resource an image resource identifier on success, <b>FALSE</b> on errors.
@@ -704,7 +705,7 @@ class OC_Image {
/**
* @brief Resizes the image preserving ratio.
- * @param $maxsize The maximum size of either the width or height.
+ * @param integer $maxSize The maximum size of either the width or height.
* @returns bool
*/
public function resize($maxSize) {
@@ -852,8 +853,8 @@ class OC_Image {
/**
* @brief Resizes the image to fit within a boundry while preserving ratio.
- * @param $maxWidth
- * @param $maxHeight
+ * @param integer $maxWidth
+ * @param integer $maxHeight
* @returns bool
*/
public function fitIn($maxWidth, $maxHeight) {
@@ -891,8 +892,7 @@ if ( ! function_exists( 'imagebmp') ) {
* @link http://www.programmierer-forum.de/imagebmp-gute-funktion-gefunden-t143716.htm
* @author mgutt <marc@gutt.it>
* @version 1.00
- * @param resource $image
- * @param string $filename [optional] <p>The path to save the file to.</p>
+ * @param string $fileName [optional] <p>The path to save the file to.</p>
* @param int $bit [optional] <p>Bit depth, (default is 24).</p>
* @param int $compression [optional]
* @return bool <b>TRUE</b> on success or <b>FALSE</b> on failure.
@@ -1008,7 +1008,7 @@ if ( ! function_exists( 'exif_imagetype' ) ) {
/**
* Workaround if exif_imagetype does not exist
* @link http://www.php.net/manual/en/function.exif-imagetype.php#80383
- * @param string $filename
+ * @param string $fileName
* @return string|boolean
*/
function exif_imagetype ( $fileName ) {
diff --git a/lib/private/installer.php b/lib/private/installer.php
index 835b6b4c01a..11633a4d4a1 100644
--- a/lib/private/installer.php
+++ b/lib/private/installer.php
@@ -25,10 +25,6 @@
*/
class OC_Installer{
/**
- * @brief Installs an app
- * @param $data array with all information
- * @throws \Exception
- * @returns integer
*
* This function installs an app. All information needed are passed in the
* associative array $data.
@@ -55,6 +51,11 @@ class OC_Installer{
*
* It is the task of oc_app_install to create the tables and do whatever is
* needed to get the app working.
+ *
+ * @brief Installs an app
+ * @param array $data with all information
+ * @throws \Exception
+ * @return integer
*/
public static function installApp( $data = array()) {
$l = \OC_L10N::get('lib');
@@ -153,7 +154,7 @@ class OC_Installer{
}else{
$version = trim($info['version']);
}
-
+
if($version<>trim($data['appdata']['version'])) {
OC_Helper::rmdirr($extractDir);
throw new \Exception($l->t("App can't be installed because the version in info.xml/version is not the same as the version reported from the app store"));
@@ -219,7 +220,7 @@ class OC_Installer{
/**
* @brief checks whether or not an app is installed
- * @param $app app
+ * @param string $app app
* @returns true/false
*
* Checks whether or not an app is installed, i.e. registered in apps table.
@@ -235,7 +236,6 @@ class OC_Installer{
/**
* @brief Update an application
- * @param $data array with all information
*
* This function installs an app. All information needed are passed in the
* associative array $data.
@@ -269,8 +269,7 @@ class OC_Installer{
/**
* @brief Check if an update for the app is available
- * @param $name name of the application
- * @return boolean false or the version number of the update
+ * @return string|false false or the version number of the update
*
* The function will check if an update for a version is available
*/
@@ -297,8 +296,8 @@ class OC_Installer{
/**
* @brief Check if app is already downloaded
- * @param $name name of the application to remove
- * @returns true/false
+ * @param string $name name of the application to remove
+ * @return boolean
*
* The function will check if the app is already downloaded in the apps repository
*/
@@ -313,9 +312,9 @@ class OC_Installer{
/**
* @brief Removes an app
- * @param $name name of the application to remove
+ * @param string $name name of the application to remove
* @param $options array with options
- * @returns true/false
+ * @return boolean|null
*
* This function removes an app. $options is an associative array. The
* following keys are optional:ja
@@ -394,7 +393,7 @@ class OC_Installer{
/**
* install an app already placed in the app folder
* @param string $app id of the app to install
- * @returns array see OC_App::getAppInfo
+ * @return integer
*/
public static function installShippedApp($app) {
//install the database
@@ -429,7 +428,7 @@ class OC_Installer{
/**
* check the code of an app with some static code checks
* @param string $folder the folder of the app to check
- * @returns true for app is o.k. and false for app is not o.k.
+ * @return boolean true for app is o.k. and false for app is not o.k.
*/
public static function checkCode($appname, $folder) {
diff --git a/lib/private/json.php b/lib/private/json.php
index 5c5d7e3a3da..4ccdb490a6c 100644
--- a/lib/private/json.php
+++ b/lib/private/json.php
@@ -21,6 +21,7 @@ class OC_JSON{
/**
* Check if the app is enabled, send json error msg if not
+ * @param string $app
*/
public static function checkAppEnabled($app) {
if( !OC_App::isEnabled($app)) {
diff --git a/lib/private/l10n.php b/lib/private/l10n.php
index 1aa1dc5ea28..ad979a92870 100644
--- a/lib/private/l10n.php
+++ b/lib/private/l10n.php
@@ -99,6 +99,9 @@ class OC_L10N implements \OCP\IL10N {
$this->lang = $lang;
}
+ /**
+ * @param string $transFile
+ */
public function load($transFile) {
$this->app = true;
include $transFile;
@@ -115,7 +118,7 @@ class OC_L10N implements \OCP\IL10N {
return;
}
$app = OC_App::cleanAppId($this->app);
- $lang = $this->lang;
+ $lang = str_replace(array('\0', '/', '\\', '..'), '', $this->lang);
$this->app = true;
// Find the right language
if(is_null($lang) || $lang == '') {
@@ -160,7 +163,7 @@ class OC_L10N implements \OCP\IL10N {
}
}
- if(file_exists(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php')) {
+ if(file_exists(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php') && OC_Helper::issubdirectory(OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php', OC::$SERVERROOT.'/core/l10n/')) {
// Include the file, save the data from $CONFIG
include OC::$SERVERROOT.'/core/l10n/l10n-'.$lang.'.php';
if(isset($LOCALIZATIONS) && is_array($LOCALIZATIONS)) {
@@ -529,6 +532,9 @@ class OC_L10N implements \OCP\IL10N {
return $available;
}
+ /**
+ * @param string $lang
+ */
public static function languageExists($app, $lang) {
if ($lang == 'en') {//english is always available
return true;
diff --git a/lib/private/l10n/string.php b/lib/private/l10n/string.php
index 88c85b32e70..04eaacab57b 100644
--- a/lib/private/l10n/string.php
+++ b/lib/private/l10n/string.php
@@ -27,6 +27,9 @@ class OC_L10N_String{
*/
protected $count;
+ /**
+ * @param OC_L10N $l10n
+ */
public function __construct($l10n, $text, $parameters, $count = 1) {
$this->l10n = $l10n;
$this->text = $text;
diff --git a/lib/private/legacy/appconfig.php b/lib/private/legacy/appconfig.php
new file mode 100644
index 00000000000..b6c3542a673
--- /dev/null
+++ b/lib/private/legacy/appconfig.php
@@ -0,0 +1,128 @@
+<?php
+/**
+ * ownCloud
+ *
+ * @author Frank Karlitschek
+ * @author Jakob Sack
+ * @copyright 2012 Frank Karlitschek frank@owncloud.org
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+/**
+ * This class provides an easy way for apps to store config values in the
+ * database.
+ */
+class OC_Appconfig {
+ /**
+ * @return \OCP\IAppConfig
+ */
+ private static function getAppConfig() {
+ return \OC::$server->getAppConfig();
+ }
+
+ /**
+ * @brief Get all apps using the config
+ * @return array with app ids
+ *
+ * This function returns a list of all apps that have at least one
+ * entry in the appconfig table.
+ */
+ public static function getApps() {
+ return self::getAppConfig()->getApps();
+ }
+
+ /**
+ * @brief Get the available keys for an app
+ * @param string $app the app we are looking for
+ * @return array with key names
+ *
+ * This function gets all keys of an app. Please note that the values are
+ * not returned.
+ */
+ public static function getKeys($app) {
+ return self::getAppConfig()->getKeys($app);
+ }
+
+ /**
+ * @brief Gets the config value
+ * @param string $app app
+ * @param string $key key
+ * @param string $default = null, default value if the key does not exist
+ * @return string the value or $default
+ *
+ * This function gets a value from the appconfig table. If the key does
+ * not exist the default value will be returned
+ */
+ public static function getValue($app, $key, $default = null) {
+ return self::getAppConfig()->getValue($app, $key, $default);
+ }
+
+ /**
+ * @brief check if a key is set in the appconfig
+ * @param string $app
+ * @param string $key
+ * @return bool
+ */
+ public static function hasKey($app, $key) {
+ return self::getAppConfig()->hasKey($app, $key);
+ }
+
+ /**
+ * @brief sets a value in the appconfig
+ * @param string $app app
+ * @param string $key key
+ * @param string $value value
+ *
+ * Sets a value. If the key did not exist before it will be created.
+ */
+ public static function setValue($app, $key, $value) {
+ self::getAppConfig()->setValue($app, $key, $value);
+ }
+
+ /**
+ * @brief Deletes a key
+ * @param string $app app
+ * @param string $key key
+ *
+ * Deletes a key.
+ */
+ public static function deleteKey($app, $key) {
+ self::getAppConfig()->deleteKey($app, $key);
+ }
+
+ /**
+ * @brief Remove app from appconfig
+ * @param string $app app
+ *
+ * Removes all keys in appconfig belonging to the app.
+ */
+ public static function deleteApp($app) {
+ self::getAppConfig()->deleteApp($app);
+ }
+
+ /**
+ * get multiply values, either the app or key can be used as wildcard by setting it to false
+ *
+ * @param app
+ * @param key
+ * @param string|false $app
+ * @param string|false $key
+ * @return array
+ */
+ public static function getValues($app, $key) {
+ return self::getAppConfig()->getValues($app, $key);
+ }
+}
diff --git a/lib/private/legacy/preferences.php b/lib/private/legacy/preferences.php
index a663db7598b..fcde12796ca 100644
--- a/lib/private/legacy/preferences.php
+++ b/lib/private/legacy/preferences.php
@@ -41,7 +41,7 @@ class OC_Preferences{
/**
* @brief Get all apps of a user
* @param string $user user
- * @return array with app ids
+ * @return integer[] with app ids
*
* This function returns a list of all apps of the user that have at least
* one entry in the preferences table.
diff --git a/lib/private/mail.php b/lib/private/mail.php
index b339b33e962..90c3e343199 100644
--- a/lib/private/mail.php
+++ b/lib/private/mail.php
@@ -25,7 +25,7 @@ class OC_Mail {
* @param string $mailtext
* @param string $fromaddress
* @param string $fromname
- * @param bool|int $html
+ * @param integer $html
* @param string $altbody
* @param string $ccaddress
* @param string $ccname
diff --git a/lib/private/memcache/factory.php b/lib/private/memcache/factory.php
index 334cf9a1f0e..d60b157efe2 100644
--- a/lib/private/memcache/factory.php
+++ b/lib/private/memcache/factory.php
@@ -57,7 +57,7 @@ class Factory implements ICacheFactory {
* get a in-server cache instance, will return null if no backend is available
*
* @param string $prefix
- * @return \OC\Memcache\Cache
+ * @return null|Cache
*/
public static function createLowLatency($prefix = '') {
if (XCache::isAvailable()) {
diff --git a/lib/private/migrate.php b/lib/private/migrate.php
index 0b319177400..3fb3e334ea2 100644
--- a/lib/private/migrate.php
+++ b/lib/private/migrate.php
@@ -35,12 +35,8 @@ class OC_Migrate{
static private $zip=false;
// Stores the type of export
static private $exporttype=false;
- // Array of temp files to be deleted after zip creation
- static private $tmpfiles=array();
// Holds the db object
- static private $MDB2=false;
- // Schema db object
- static private $schema=false;
+ static private $migration_database=false;
// Path to the sqlite db
static private $dbpath=false;
// Holds the path to the zip file
@@ -50,7 +46,7 @@ class OC_Migrate{
/**
* register a new migration provider
- * @param OC_Migrate_Provider $provider
+ * @param OC_Migration_Provider $provider
*/
public static function registerProvider($provider) {
self::$providers[]=$provider;
@@ -76,7 +72,7 @@ class OC_Migrate{
* @param optional $uid string user id of user to export if export type is user, defaults to current
* @param ootional $type string type of export, defualts to user
* @param otional $path string path to zip output folder
- * @return false on error, path to zip on success
+ * @return string on error, path to zip on success
*/
public static function export( $uid=null, $type='user', $path=null ) {
$datadir = OC_Config::getValue( 'datadirectory' );
@@ -131,7 +127,7 @@ class OC_Migrate{
if( !self::connectDB() ) {
return json_encode( array( 'success' => false ) );
}
- self::$content = new OC_Migration_Content( self::$zip, self::$MDB2 );
+ self::$content = new OC_Migration_Content( self::$zip, self::$migration_database );
// Export the app info
$exportdata = self::exportAppData();
// Add the data dir to the zip
@@ -257,7 +253,7 @@ class OC_Migrate{
$userfolder = $extractpath . $json->exporteduser;
$newuserfolder = $datadir . '/' . self::$uid;
foreach(scandir($userfolder) as $file){
- if($file !== '.' && $file !== '..' && is_dir($file)) {
+ if($file !== '.' && $file !== '..' && is_dir($userfolder.'/'.$file)) {
$file = str_replace(array('/', '\\'), '', $file);
// Then copy the folder over
@@ -311,7 +307,7 @@ class OC_Migrate{
/**
* @brief recursively deletes a directory
- * @param $dir string path of dir to delete
+ * @param string $dir string path of dir to delete
* $param optional $deleteRootToo bool delete the root directory
* @return bool
*/
@@ -359,24 +355,6 @@ class OC_Migrate{
}
/**
- * @brief connects to a MDB2 database scheme
- * @returns bool
- */
- static private function connectScheme() {
- // We need a mdb2 database connection
- self::$MDB2->loadModule( 'Manager' );
- self::$MDB2->loadModule( 'Reverse' );
-
- // Connect if this did not happen before
- if( !self::$schema ) {
- require_once 'MDB2/Schema.php';
- self::$schema=MDB2_Schema::factory( self::$MDB2 );
- }
-
- return true;
- }
-
- /**
* @brief creates a migration.db in the users data dir with their app data in
* @return bool whether operation was successfull
*/
@@ -429,7 +407,7 @@ class OC_Migrate{
/**
* @brief generates json containing export info, and merges any data supplied
* @param optional $array array of data to include in the returned json
- * @return bool
+ * @return string
*/
static private function getExportInfo( $array=array() ) {
$info = array(
@@ -453,6 +431,7 @@ class OC_Migrate{
/**
* @brief connects to migration.db, or creates if not found
* @param $db optional path to migration.db, defaults to user data dir
+ * @param string $path
* @return bool whether the operation was successful
*/
static private function connectDB( $path=null ) {
@@ -463,47 +442,18 @@ class OC_Migrate{
return false;
}
// Already connected
- if(!self::$MDB2) {
- require_once 'MDB2.php';
-
+ if(!self::$migration_database) {
$datadir = OC_Config::getValue( "datadirectory", OC::$SERVERROOT."/data" );
-
- // DB type
- if( class_exists( 'SQLite3' ) ) {
- $dbtype = 'sqlite3';
- } else if( is_callable( 'sqlite_open' ) ) {
- $dbtype = 'sqlite';
- } else {
- OC_Log::write( 'migration', 'SQLite not found', OC_Log::ERROR );
- return false;
- }
-
- // Prepare options array
- $options = array(
- 'portability' => MDB2_PORTABILITY_ALL & (!MDB2_PORTABILITY_FIX_CASE),
- 'log_line_break' => '<br>',
- 'idxname_format' => '%s',
- 'debug' => true,
- 'quote_identifier' => true
- );
- $dsn = array(
- 'phptype' => $dbtype,
- 'database' => self::$dbpath,
- 'mode' => '0644'
+ $connectionParams = array(
+ 'path' => self::$dbpath,
+ 'driver' => 'pdo_sqlite',
);
+ $connectionParams['adapter'] = '\OC\DB\AdapterSqlite';
+ $connectionParams['wrapperClass'] = 'OC\DB\Connection';
+ $connectionParams['tablePrefix'] = '';
// Try to establish connection
- self::$MDB2 = MDB2::factory( $dsn, $options );
- // Die if we could not connect
- if( PEAR::isError( self::$MDB2 ) ) {
- die( self::$MDB2->getMessage() );
- OC_Log::write( 'migration', 'Failed to create/connect to migration.db', OC_Log::FATAL );
- OC_Log::write( 'migration', self::$MDB2->getUserInfo(), OC_Log::FATAL );
- OC_Log::write( 'migration', self::$MDB2->getMessage(), OC_Log::FATAL );
- return false;
- }
- // We always, really always want associative arrays
- self::$MDB2->setFetchMode(MDB2_FETCHMODE_ASSOC);
+ self::$migration_database = \Doctrine\DBAL\DriverManager::getConnection($connectionParams);
}
return true;
@@ -511,14 +461,11 @@ class OC_Migrate{
/**
* @brief creates the tables in migration.db from an apps database.xml
- * @param $appid string id of the app
+ * @param string $appid string id of the app
* @return bool whether the operation was successful
*/
static private function createAppTables( $appid ) {
-
- if( !self::connectScheme() ) {
- return false;
- }
+ $schema_manager = new OC\DB\MDB2SchemaManager(self::$migration_database);
// There is a database.xml file
$content = file_get_contents(OC_App::getAppPath($appid) . '/appinfo/database.xml' );
@@ -538,29 +485,16 @@ class OC_Migrate{
file_put_contents( $file2, $content );
// Try to create tables
- $definition = self::$schema->parseDatabaseDefinitionFile( $file2 );
-
- unlink( $file2 );
-
- // Die in case something went wrong
- if( $definition instanceof MDB2_Schema_Error ) {
- OC_Log::write( 'migration', 'Failed to parse database.xml for: '.$appid, OC_Log::FATAL );
- OC_Log::write( 'migration', $definition->getMessage().': '.$definition->getUserInfo(), OC_Log::FATAL );
- return false;
- }
-
- $definition['overwrite'] = true;
-
- $ret = self::$schema->createDatabase( $definition );
-
- // Die in case something went wrong
- if( $ret instanceof MDB2_Error ) {
+ try {
+ $schema_manager->createDbFromStructure($file2);
+ } catch(Exception $e) {
+ unlink( $file2 );
OC_Log::write( 'migration', 'Failed to create tables for: '.$appid, OC_Log::FATAL );
- OC_Log::write( 'migration', $ret->getMessage().': '.$ret->getUserInfo(), OC_Log::FATAL );
+ OC_Log::write( 'migration', $e->getMessage(), OC_Log::FATAL );
return false;
}
- return $tables;
+ return $tables;
}
/**
@@ -602,7 +536,7 @@ class OC_Migrate{
/**
* @brief imports a new user
- * @param $db string path to migration.db
+ * @param string $db string path to migration.db
* @param $info object of migration info
* @param $uid optional uid to use
* @return array of apps with import statuses, or false on failure.
@@ -646,7 +580,7 @@ class OC_Migrate{
if( !self::connectDB( $db ) ) {
return false;
}
- $content = new OC_Migration_Content( self::$zip, self::$MDB2 );
+ $content = new OC_Migration_Content( self::$zip, self::$migration_database );
$provider->setData( self::$uid, $content, $info );
// Then do the import
if( !$appsstatus[$id] = $provider->import( $info->apps->$id, $importinfo ) ) {
diff --git a/lib/private/migration/content.php b/lib/private/migration/content.php
index 4413d722731..43eba89b8d5 100644
--- a/lib/private/migration/content.php
+++ b/lib/private/migration/content.php
@@ -27,16 +27,16 @@
class OC_Migration_Content{
private $zip=false;
- // Holds the MDB2 object
+ // Holds the database object
private $db=null;
// Holds an array of tmpfiles to delete after zip creation
private $tmpfiles=array();
/**
* @brief sets up the
- * @param $zip ZipArchive object
- * @param optional $db a MDB2 database object (required for exporttype user)
- * @return bool
+ * @param ZipArchive $zip ZipArchive object
+ * @param $db a database object (required for exporttype user)
+ * @return boolean|null
*/
public function __construct( $zip, $db=null ) {
@@ -47,6 +47,10 @@ class OC_Migration_Content{
// @brief prepares the db
// @param $query the sql query to prepare
+
+ /**
+ * @param string $query
+ */
public function prepare( $query ) {
// Only add database to tmpfiles if actually used
@@ -63,22 +67,14 @@ class OC_Migration_Content{
// Optimize the query
$query = $this->db->prepare( $query );
+ $query = new OC_DB_StatementWrapper($query, false);
- // Die if we have an error (error means: bad query, not 0 results!)
- if( PEAR::isError( $query ) ) {
- $entry = 'DB Error: "'.$query->getMessage().'"<br />';
- $entry .= 'Offending command was: '.$query.'<br />';
- OC_Log::write( 'migration', $entry, OC_Log::FATAL );
- return false;
- } else {
- return $query;
- }
-
+ return $query;
}
/**
* @brief processes the db query
- * @param $query the query to process
+ * @param string $query the query to process
* @return string of processed query
*/
private function processQuery( $query ) {
@@ -134,7 +130,7 @@ class OC_Migration_Content{
/**
* @brief saves a sql data set into migration.db
- * @param $data a sql data set returned from self::prepare()->query()
+ * @param OC_DB_StatementWrapper $data a sql data set returned from self::prepare()->query()
* @param $options array of copyRows options
* @return void
*/
@@ -156,20 +152,14 @@ class OC_Migration_Content{
$sql .= $valuessql . " )";
// Make the query
$query = $this->prepare( $sql );
- if( !$query ) {
- OC_Log::write( 'migration', 'Invalid sql produced: '.$sql, OC_Log::FATAL );
- return false;
- exit();
+ $query->execute( $values );
+ // Do we need to return some values?
+ if( array_key_exists( 'idcol', $options ) ) {
+ // Yes we do
+ $return[] = $row[$options['idcol']];
} else {
- $query->execute( $values );
- // Do we need to return some values?
- if( array_key_exists( 'idcol', $options ) ) {
- // Yes we do
- $return[] = $row[$options['idcol']];
- } else {
- // Take a guess and return the first field :)
- $return[] = reset($row);
- }
+ // Take a guess and return the first field :)
+ $return[] = reset($row);
}
$fields = '';
$values = '';
@@ -179,7 +169,7 @@ class OC_Migration_Content{
/**
* @brief adds a directory to the zip object
- * @param $dir string path of the directory to add
+ * @param boolean|string $dir string path of the directory to add
* @param $recursive bool
* @param $internaldir string path of folder to add dir to in zip
* @return bool
@@ -214,8 +204,8 @@ class OC_Migration_Content{
/**
* @brief adds a file to the zip from a given string
- * @param $data string of data to add
- * @param $path the relative path inside of the zip to save the file to
+ * @param string $data string of data to add
+ * @param string $path the relative path inside of the zip to save the file to
* @return bool
*/
public function addFromString( $data, $path ) {
diff --git a/lib/private/migration/provider.php b/lib/private/migration/provider.php
index 234ab3351f3..2829a97a776 100644
--- a/lib/private/migration/provider.php
+++ b/lib/private/migration/provider.php
@@ -30,7 +30,7 @@ abstract class OC_Migration_Provider{
/**
* @brief sets the OC_Migration_Content object to $this->content
- * @param $content a OC_Migration_Content object
+ * @param OC_Migration_Content $content a OC_Migration_Content object
*/
public function setData( $uid, $content, $info=null ) {
$this->content = $content;
diff --git a/lib/private/mimetypes.list.php b/lib/private/mimetypes.list.php
index 40fb1d2d97d..9bd07b89023 100644
--- a/lib/private/mimetypes.list.php
+++ b/lib/private/mimetypes.list.php
@@ -24,88 +24,107 @@
* Array mapping file extensions to mimetypes (in alphabetical order).
*/
return array(
- 'accdb'=>'application/msaccess',
+ '7z' => 'application/x-7z-compressed',
+ 'accdb' => 'application/msaccess',
'ai' => 'application/illustrator',
- 'avi'=>'video/x-msvideo',
+ 'avi' => 'video/x-msvideo',
'bash' => 'text/x-shellscript',
- 'blend'=>'application/x-blender',
+ 'blend' => 'application/x-blender',
+ 'bin' => 'application/x-bin',
+ 'cb7' => 'application/x-cbr',
+ 'cba' => 'application/x-cbr',
+ 'cbr' => 'application/x-cbr',
+ 'cbt' => 'application/x-cbr',
+ 'cbtc' => 'application/x-cbr',
+ 'cbz' => 'application/x-cbr',
'cc' => 'text/x-c',
'cdr' => 'application/coreldraw',
'cpp' => 'text/x-c++src',
- 'css'=>'text/css',
+ 'css' => 'text/css',
+ 'csv' => 'text/csv',
+ 'cvbdl' => 'application/x-cbr',
'c' => 'text/x-c',
'c++' => 'text/x-c++src',
- 'doc'=>'application/msword',
- 'docx'=>'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
- 'dot'=>'application/msword',
- 'dotx'=>'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
- 'dv'=>'video/dv',
+ 'deb' => 'application/x-deb',
+ 'doc' => 'application/msword',
+ 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'dot' => 'application/msword',
+ 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
+ 'dv' => 'video/dv',
+ 'eot' => 'application/vnd.ms-fontobject',
'epub' => 'application/epub+zip',
- 'exe'=>'application/x-ms-dos-executable',
- 'flac'=>'audio/flac',
- 'gif'=>'image/gif',
- 'gz'=>'application/x-gzip',
- 'gzip'=>'application/x-gzip',
- 'html'=>'text/html',
- 'htm'=>'text/html',
- 'ical'=>'text/calendar',
- 'ics'=>'text/calendar',
+ 'exe' => 'application/x-ms-dos-executable',
+ 'flac' => 'audio/flac',
+ 'gif' => 'image/gif',
+ 'gz' => 'application/x-gzip',
+ 'gzip' => 'application/x-gzip',
+ 'html' => 'text/html',
+ 'htm' => 'text/html',
+ 'ical' => 'text/calendar',
+ 'ics' => 'text/calendar',
'impress' => 'text/impress',
- 'jpeg'=>'image/jpeg',
- 'jpg'=>'image/jpeg',
- 'js'=>'application/javascript',
- 'keynote'=>'application/x-iwork-keynote-sffkey',
- 'kra'=>'application/x-krita',
- 'm2t'=>'video/mp2t',
- 'm4v'=>'video/mp4',
+ 'jpeg' => 'image/jpeg',
+ 'jpg' => 'image/jpeg',
+ 'js' => 'application/javascript',
+ 'json' => 'application/json',
+ 'keynote' => 'application/x-iwork-keynote-sffkey',
+ 'kra' => 'application/x-krita',
+ 'm2t' => 'video/mp2t',
+ 'm4v' => 'video/mp4',
'markdown' => 'text/markdown',
'mdown' => 'text/markdown',
'md' => 'text/markdown',
- 'mdb'=>'application/msaccess',
+ 'mdb' => 'application/msaccess',
'mdwn' => 'text/markdown',
'mobi' => 'application/x-mobipocket-ebook',
- 'mov'=>'video/quicktime',
- 'mp3'=>'audio/mpeg',
- 'mp4'=>'video/mp4',
- 'mpeg'=>'video/mpeg',
- 'mpg'=>'video/mpeg',
- 'msi'=>'application/x-msi',
- 'numbers'=>'application/x-iwork-numbers-sffnumbers',
- 'odg'=>'application/vnd.oasis.opendocument.graphics',
- 'odp'=>'application/vnd.oasis.opendocument.presentation',
- 'ods'=>'application/vnd.oasis.opendocument.spreadsheet',
- 'odt'=>'application/vnd.oasis.opendocument.text',
- 'oga'=>'audio/ogg',
- 'ogg'=>'audio/ogg',
- 'ogv'=>'video/ogg',
- 'pages'=>'application/x-iwork-pages-sffpages',
- 'pdf'=>'application/pdf',
- 'php'=>'application/x-php',
- 'pl'=>'application/x-pearl',
- 'png'=>'image/png',
- 'ppt'=>'application/mspowerpoint',
- 'pptx'=>'application/vnd.openxmlformats-officedocument.presentationml.presentation',
- 'psd'=>'application/x-photoshop',
- 'py'=>'text/x-script.python',
+ 'mov' => 'video/quicktime',
+ 'mp3' => 'audio/mpeg',
+ 'mp4' => 'video/mp4',
+ 'mpeg' => 'video/mpeg',
+ 'mpg' => 'video/mpeg',
+ 'msi' => 'application/x-msi',
+ 'numbers' => 'application/x-iwork-numbers-sffnumbers',
+ 'odg' => 'application/vnd.oasis.opendocument.graphics',
+ 'odp' => 'application/vnd.oasis.opendocument.presentation',
+ 'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
+ 'odt' => 'application/vnd.oasis.opendocument.text',
+ 'oga' => 'audio/ogg',
+ 'ogg' => 'audio/ogg',
+ 'ogv' => 'video/ogg',
+ 'otf' => 'font/opentype',
+ 'pages' => 'application/x-iwork-pages-sffpages',
+ 'pdf' => 'application/pdf',
+ 'php' => 'application/x-php',
+ 'pl' => 'application/x-perl',
+ 'png' => 'image/png',
+ 'ppt' => 'application/mspowerpoint',
+ 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ 'psd' => 'application/x-photoshop',
+ 'py' => 'text/x-python',
+ 'rar' => 'application/x-rar-compressed',
'reveal' => 'text/reveal',
'sgf' => 'application/sgf',
'sh-lib' => 'text/x-shellscript',
'sh' => 'text/x-shellscript',
- 'svg'=>'image/svg+xml',
- 'tar'=>'application/x-tar',
- 'tar.gz'=>'application/x-compressed',
- 'tgz'=>'application/x-compressed',
- 'tiff'=>'image/tiff',
- 'tif'=>'image/tiff',
- 'txt'=>'text/plain',
+ 'svg' => 'image/svg+xml',
+ 'swf' => 'application/x-shockwave-flash',
+ 'tar' => 'application/x-tar',
+ 'tar.gz' => 'application/x-compressed',
+ 'tex' => 'application/x-tex',
+ 'tgz' => 'application/x-compressed',
+ 'tiff' => 'image/tiff',
+ 'tif' => 'image/tiff',
+ 'ttf' => 'application/x-font-ttf',
+ 'txt' => 'text/plain',
'vcard' => 'text/vcard',
'vcf' => 'text/vcard',
- 'wav'=>'audio/wav',
- 'webm'=>'video/webm',
- 'wmv'=>'video/x-ms-asf',
- 'xcf'=>'application/x-gimp',
- 'xls'=>'application/msexcel',
- 'xlsx'=>'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
- 'xml'=>'application/xml',
- 'zip'=>'application/zip',
+ 'wav' => 'audio/wav',
+ 'webm' => 'video/webm',
+ 'woff' => 'application/font-woff',
+ 'wmv' => 'video/x-ms-asf',
+ 'xcf' => 'application/x-gimp',
+ 'xls' => 'application/msexcel',
+ 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'xml' => 'application/xml',
+ 'zip' => 'application/zip',
);
diff --git a/lib/private/ocs.php b/lib/private/ocs.php
index e067196cf11..bbe965ce561 100644
--- a/lib/private/ocs.php
+++ b/lib/private/ocs.php
@@ -23,9 +23,6 @@
*
*/
-use Symfony\Component\Routing\Exception\ResourceNotFoundException;
-use Symfony\Component\Routing\Exception\MethodNotAllowedException;
-
/**
* Class to handle open collaboration services API requests
*
@@ -35,11 +32,11 @@ class OC_OCS {
/**
* reads input date from get/post/cookies and converts the date to a special data-type
*
- * @param string HTTP method to read the key from
- * @param string Parameter to read
- * @param string Variable type to format data
- * @param mixed Default value to return if the key is not found
- * @return mixed Data or if the key is not found and no default is set it will exit with a 400 Bad request
+ * @param string $method HTTP method to read the key from
+ * @param string $key Parameter to read
+ * @param string $type Variable type to format data
+ * @param string $default Default value to return if the key is not found
+ * @return string Data or if the key is not found and no default is set it will exit with a 400 Bad request
*/
public static function readData($method, $key, $type = 'raw', $default = null) {
if ($method == 'get') {
@@ -96,7 +93,7 @@ class OC_OCS {
/**
* generated some debug information to make it easier to find faild API calls
- * @return debug data string
+ * @return string data string
*/
private static function getDebugOutput() {
$txt='';
@@ -214,6 +211,9 @@ class OC_OCS {
}
}
+ /**
+ * @param string $node
+ */
public static function toXml($writer, $data, $node) {
foreach($data as $key => $value) {
if (is_numeric($key)) {
diff --git a/lib/private/ocs/result.php b/lib/private/ocs/result.php
index 84f06fa01c7..9f14e8da7e8 100644
--- a/lib/private/ocs/result.php
+++ b/lib/private/ocs/result.php
@@ -29,7 +29,13 @@ class OC_OCS_Result{
* @param $data mixed the data to return
*/
public function __construct($data=null, $code=100, $message=null) {
- $this->data = $data;
+ if ($data === null) {
+ $this->data = array();
+ } elseif (!is_array($data)) {
+ $this->data = array($this->data);
+ } else {
+ $this->data = $data;
+ }
$this->statusCode = $code;
$this->message = $message;
}
@@ -49,7 +55,7 @@ class OC_OCS_Result{
public function setItemsPerPage(int $items) {
$this->perPage = $items;
}
-
+
/**
* get the status code
* @return int
@@ -57,7 +63,7 @@ class OC_OCS_Result{
public function getStatusCode() {
return $this->statusCode;
}
-
+
/**
* get the meta data for the result
* @return array
@@ -76,15 +82,15 @@ class OC_OCS_Result{
return $meta;
}
-
+
/**
* get the result data
- * @return array|string|int
+ * @return array
*/
public function getData() {
return $this->data;
}
-
+
/**
* return bool if the method succedded
* @return bool
diff --git a/lib/private/ocsclient.php b/lib/private/ocsclient.php
index e35556d92b8..fa6e3fac1bb 100644
--- a/lib/private/ocsclient.php
+++ b/lib/private/ocsclient.php
@@ -50,6 +50,7 @@ class OC_OCSClient{
* @brief Get the content of an OCS url call.
* @returns string of the response
* This function calls an OCS server and returns the response. It also sets a sane timeout
+ * @param string $url
*/
private static function getOCSresponse($url) {
$data = \OC_Util::getUrlContent($url);
@@ -92,6 +93,8 @@ class OC_OCSClient{
* @returns array with application data
*
* This function returns a list of all the applications on the OCS server
+ * @param integer $page
+ * @param string $filter
*/
public static function getApplications($categories, $page, $filter) {
if(OC_Config::getValue('appstoreenabled', true)==false) {
@@ -184,6 +187,7 @@ class OC_OCSClient{
* @returns array with application data
*
* This function returns an download url for an applications from the OCS server
+ * @param integer $item
*/
public static function getApplicationDownload($id, $item) {
if(OC_Config::getValue('appstoreenabled', true)==false) {
diff --git a/lib/private/preferences.php b/lib/private/preferences.php
index 359d9a83589..d45e6e77089 100644
--- a/lib/private/preferences.php
+++ b/lib/private/preferences.php
@@ -43,8 +43,26 @@ use \OC\DB\Connection;
* This class provides an easy way for storing user preferences.
*/
class Preferences {
+ /**
+ * @var \OC\DB\Connection
+ */
protected $conn;
+ /**
+ * 3 dimensional array with the following structure:
+ * [ $userId =>
+ * [ $appId =>
+ * [ $key => $value ]
+ * ]
+ * ]
+ *
+ * @var array $cache
+ */
+ protected $cache = array();
+
+ /**
+ * @param \OC\DB\Connection $conn
+ */
public function __construct(Connection $conn) {
$this->conn = $conn;
}
@@ -58,10 +76,10 @@ class Preferences {
*/
public function getUsers() {
$query = 'SELECT DISTINCT `userid` FROM `*PREFIX*preferences`';
- $result = $this->conn->executeQuery( $query );
+ $result = $this->conn->executeQuery($query);
$users = array();
- while( $userid = $result->fetchColumn()) {
+ while ($userid = $result->fetchColumn()) {
$users[] = $userid;
}
@@ -69,23 +87,38 @@ class Preferences {
}
/**
+ * @param string $user
+ * @return array[]
+ */
+ protected function getUserValues($user) {
+ if (isset($this->cache[$user])) {
+ return $this->cache[$user];
+ }
+ $data = array();
+ $query = 'SELECT `appid`, `configkey`, `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ?';
+ $result = $this->conn->executeQuery($query, array($user));
+ while ($row = $result->fetch()) {
+ $app = $row['appid'];
+ if (!isset($data[$app])) {
+ $data[$app] = array();
+ }
+ $data[$app][$row['configkey']] = $row['configvalue'];
+ }
+ $this->cache[$user] = $data;
+ return $data;
+ }
+
+ /**
* @brief Get all apps of an user
* @param string $user user
- * @return array with app ids
+ * @return integer[] with app ids
*
* This function returns a list of all apps of the user that have at least
* one entry in the preferences table.
*/
- public function getApps( $user ) {
- $query = 'SELECT DISTINCT `appid` FROM `*PREFIX*preferences` WHERE `userid` = ?';
- $result = $this->conn->executeQuery( $query, array( $user ) );
-
- $apps = array();
- while( $appid = $result->fetchColumn()) {
- $apps[] = $appid;
- }
-
- return $apps;
+ public function getApps($user) {
+ $data = $this->getUserValues($user);
+ return array_keys($data);
}
/**
@@ -97,16 +130,13 @@ class Preferences {
* This function gets all keys of an app of an user. Please note that the
* values are not returned.
*/
- public function getKeys( $user, $app ) {
- $query = 'SELECT `configkey` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?';
- $result = $this->conn->executeQuery( $query, array( $user, $app ));
-
- $keys = array();
- while( $key = $result->fetchColumn()) {
- $keys[] = $key;
+ public function getKeys($user, $app) {
+ $data = $this->getUserValues($user);
+ if (isset($data[$app])) {
+ return array_keys($data[$app]);
+ } else {
+ return array();
}
-
- return $keys;
}
/**
@@ -120,13 +150,10 @@ class Preferences {
* This function gets a value from the preferences table. If the key does
* not exist the default value will be returned
*/
- public function getValue( $user, $app, $key, $default = null ) {
- // Try to fetch the value, return default if not exists.
- $query = 'SELECT `configvalue` FROM `*PREFIX*preferences`'
- .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?';
- $row = $this->conn->fetchAssoc( $query, array( $user, $app, $key ));
- if($row) {
- return $row["configvalue"];
+ public function getValue($user, $app, $key, $default = null) {
+ $data = $this->getUserValues($user);
+ if (isset($data[$app]) and isset($data[$app][$key])) {
+ return $data[$app][$key];
} else {
return $default;
}
@@ -142,14 +169,14 @@ class Preferences {
* Adds a value to the preferences. If the key did not exist before, it
* will be added automagically.
*/
- public function setValue( $user, $app, $key, $value ) {
+ public function setValue($user, $app, $key, $value) {
// Check if the key does exist
$query = 'SELECT COUNT(*) FROM `*PREFIX*preferences`'
- .' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?';
- $count = $this->conn->fetchColumn( $query, array( $user, $app, $key ));
+ . ' WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?';
+ $count = $this->conn->fetchColumn($query, array($user, $app, $key));
$exists = $count > 0;
- if( !$exists ) {
+ if (!$exists) {
$data = array(
'userid' => $user,
'appid' => $app,
@@ -168,6 +195,14 @@ class Preferences {
);
$this->conn->update('*PREFIX*preferences', $data, $where);
}
+
+ // only add to the cache if we already loaded data for the user
+ if (isset($this->cache[$user])) {
+ if (!isset($this->cache[$user][$app])) {
+ $this->cache[$user][$app] = array();
+ }
+ $this->cache[$user][$app][$key] = $value;
+ }
}
/**
@@ -178,13 +213,17 @@ class Preferences {
*
* Deletes a key.
*/
- public function deleteKey( $user, $app, $key ) {
+ public function deleteKey($user, $app, $key) {
$where = array(
'userid' => $user,
'appid' => $app,
'configkey' => $key,
);
$this->conn->delete('*PREFIX*preferences', $where);
+
+ if (isset($this->cache[$user]) and isset($this->cache[$user][$app])) {
+ unset($this->cache[$user][$app][$key]);
+ }
}
/**
@@ -194,12 +233,16 @@ class Preferences {
*
* Removes all keys in preferences belonging to the app and the user.
*/
- public function deleteApp( $user, $app ) {
+ public function deleteApp($user, $app) {
$where = array(
'userid' => $user,
'appid' => $app,
);
$this->conn->delete('*PREFIX*preferences', $where);
+
+ if (isset($this->cache[$user])) {
+ unset($this->cache[$user][$app]);
+ }
}
/**
@@ -208,11 +251,13 @@ class Preferences {
*
* Removes all keys in preferences belonging to the user.
*/
- public function deleteUser( $user ) {
+ public function deleteUser($user) {
$where = array(
'userid' => $user,
);
$this->conn->delete('*PREFIX*preferences', $where);
+
+ unset($this->cache[$user]);
}
/**
@@ -221,12 +266,16 @@ class Preferences {
*
* Removes all keys in preferences belonging to the app.
*/
- public function deleteAppFromAllUsers( $app ) {
+ public function deleteAppFromAllUsers($app) {
$where = array(
'appid' => $app,
);
$this->conn->delete('*PREFIX*preferences', $where);
+
+ foreach ($this->cache as &$userCache) {
+ unset($userCache[$app]);
+ }
}
}
-require_once __DIR__.'/legacy/'.basename(__FILE__);
+require_once __DIR__ . '/legacy/' . basename(__FILE__);
diff --git a/lib/private/preview.php b/lib/private/preview.php
index ff93f438f73..80fd003ed8d 100755
--- a/lib/private/preview.php
+++ b/lib/private/preview.php
@@ -138,7 +138,7 @@ class Preview {
/**
* @brief returns the max scale factor
- * @return integer
+ * @return string
*/
public function getMaxScaleFactor() {
return $this->maxScaleFactor;
@@ -146,7 +146,7 @@ class Preview {
/**
* @brief returns the max width set in ownCloud's config
- * @return integer
+ * @return string
*/
public function getConfigMaxX() {
return $this->configMaxX;
@@ -154,7 +154,7 @@ class Preview {
/**
* @brief returns the max height set in ownCloud's config
- * @return integer
+ * @return string
*/
public function getConfigMaxY() {
return $this->configMaxY;
@@ -570,7 +570,6 @@ class Preview {
/**
* @brief register a new preview provider to be used
- * @param string $provider class name of a Preview_Provider
* @param array $options
* @return void
*/
@@ -619,6 +618,9 @@ class Preview {
$preview->deleteAllPreviews();
}
+ /**
+ * @param string $mimetype
+ */
public static function isMimeSupported($mimetype) {
if(!\OC_Config::getValue('enable_previews', true)) {
return false;
diff --git a/lib/private/preview/office.php b/lib/private/preview/office.php
index 884b6e7dc9b..02bb22e9b94 100644
--- a/lib/private/preview/office.php
+++ b/lib/private/preview/office.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
//both, libreoffice backend and php fallback, need imagick
-if (extension_loaded('imagick') && count(\Imagick::queryFormats("PDF")) === 1) {
+if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1) {
$isShellExecEnabled = \OC_Helper::is_function_enabled('shell_exec');
// LibreOffice preview is currently not supported on Windows
diff --git a/lib/private/preview/pdf.php b/lib/private/preview/pdf.php
index 572b8788ac9..d390b4fc677 100644
--- a/lib/private/preview/pdf.php
+++ b/lib/private/preview/pdf.php
@@ -7,7 +7,7 @@
*/
namespace OC\Preview;
-if (extension_loaded('imagick') && count(\Imagick::queryFormats("PDF")) === 1) {
+if (extension_loaded('imagick') && count(@\Imagick::queryFormats("PDF")) === 1) {
class PDF extends Provider {
diff --git a/lib/private/preview/provider.php b/lib/private/preview/provider.php
index 65d09705f40..88337d64e4b 100644
--- a/lib/private/preview/provider.php
+++ b/lib/private/preview/provider.php
@@ -15,7 +15,7 @@ abstract class Provider {
* @param string $path Path of file
* @param int $maxX The maximum X size of the thumbnail. It can be smaller depending on the shape of the image
* @param int $maxY The maximum Y size of the thumbnail. It can be smaller depending on the shape of the image
- * @param bool $scalingUp Disable/Enable upscaling of previews
+ * @param bool $scalingup Disable/Enable upscaling of previews
* @param object $fileview fileview object of user folder
* @return mixed
* false if no preview was generated
diff --git a/lib/private/preview/svg.php b/lib/private/preview/svg.php
index 07a37e8f8c1..9a73fff9467 100644
--- a/lib/private/preview/svg.php
+++ b/lib/private/preview/svg.php
@@ -7,7 +7,7 @@
*/
namespace OC\Preview;
-if (extension_loaded('imagick') && count(\Imagick::queryFormats("SVG")) === 1) {
+if (extension_loaded('imagick') && count(@\Imagick::queryFormats("SVG")) === 1) {
class SVG extends Provider {
diff --git a/lib/private/preview/unknown.php b/lib/private/preview/unknown.php
index 8145c826149..2d3b5c5655e 100644
--- a/lib/private/preview/unknown.php
+++ b/lib/private/preview/unknown.php
@@ -22,7 +22,7 @@ class Unknown extends Provider {
$svgPath = substr_replace($path, 'svg', -3);
- if (extension_loaded('imagick') && file_exists($svgPath) && count(\Imagick::queryFormats("SVG")) === 1) {
+ if (extension_loaded('imagick') && file_exists($svgPath) && count(@\Imagick::queryFormats("SVG")) === 1) {
// http://www.php.net/manual/de/imagick.setresolution.php#85284
$svg = new \Imagick();
diff --git a/lib/private/request.php b/lib/private/request.php
index 2c5b907846e..0fd20b3cc1f 100755
--- a/lib/private/request.php
+++ b/lib/private/request.php
@@ -87,6 +87,7 @@ class OC_Request {
*
* Returns the request uri, even if the website uses one or more
* reverse proxies
+ * @return string
*/
public static function requestUri() {
$uri = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '';
@@ -98,7 +99,7 @@ class OC_Request {
/**
* @brief Returns the script name
- * @returns string the script name
+ * @return string the script name
*
* Returns the script name, even if the website uses one or more
* reverse proxies
@@ -115,7 +116,7 @@ class OC_Request {
/**
* @brief get Path info from request
- * @returns string Path info or false when not found
+ * @return string Path info or false when not found
*/
public static function getPathInfo() {
if (array_key_exists('PATH_INFO', $_SERVER)) {
@@ -139,7 +140,7 @@ class OC_Request {
/**
* @brief get Path info from request, not urldecoded
- * @returns string Path info or false when not found
+ * @return string Path info or false when not found
*/
public static function getRawPathInfo() {
$requestUri = $_SERVER['REQUEST_URI'];
@@ -180,7 +181,7 @@ class OC_Request {
/**
* @brief Check if this is a no-cache request
- * @returns boolean true for no-cache
+ * @return boolean true for no-cache
*/
static public function isNoCache() {
if (!isset($_SERVER['HTTP_CACHE_CONTROL'])) {
@@ -191,7 +192,7 @@ class OC_Request {
/**
* @brief Check if the requestor understands gzip
- * @returns boolean true for gzip encoding supported
+ * @return false|string true for gzip encoding supported
*/
static public function acceptGZip() {
if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) {
@@ -207,7 +208,7 @@ class OC_Request {
/**
* @brief Check if the requester sent along an mtime
- * @returns false or an mtime
+ * @return false or an mtime
*/
static public function hasModificationTime () {
if (isset($_SERVER['HTTP_X_OC_MTIME'])) {
diff --git a/lib/private/response.php b/lib/private/response.php
index 52dbb9d90f8..71c538fb311 100644
--- a/lib/private/response.php
+++ b/lib/private/response.php
@@ -15,7 +15,7 @@ class OC_Response {
/**
* @brief Enable response caching by sending correct HTTP headers
- * @param $cache_time time to cache the response
+ * @param integer $cache_time time to cache the response
* >0 cache time in seconds
* 0 and <0 enable default browser caching
* null cache indefinitly
@@ -80,7 +80,7 @@ class OC_Response {
/**
* @brief Send redirect response
- * @param $location to redirect to
+ * @param string $location to redirect to
*/
static public function redirect($location) {
self::setStatus(self::STATUS_TEMPORARY_REDIRECT);
@@ -167,7 +167,7 @@ class OC_Response {
/**
* @brief Send file as response, checking and setting caching headers
- * @param $filepath of file to send
+ * @param string $filepath of file to send
*/
static public function sendFile($filepath) {
$fp = fopen($filepath, 'rb');
diff --git a/lib/private/search.php b/lib/private/search.php
index b9c75dfc333..70d670e048e 100644
--- a/lib/private/search.php
+++ b/lib/private/search.php
@@ -38,7 +38,6 @@ class OC_Search{
/**
* register a new search provider to be used
- * @param string $provider class name of a OC_Search_Provider
*/
public static function registerProvider($class, $options=array()) {
self::$registeredProviders[]=array('class'=>$class, 'options'=>$options);
diff --git a/lib/private/search/result.php b/lib/private/search/result.php
index 42275c2df11..ceefeab2dae 100644
--- a/lib/private/search/result.php
+++ b/lib/private/search/result.php
@@ -15,6 +15,7 @@ class OC_Search_Result{
* @param string $text some more information about the result
* @param string $link link for the result
* @param string $type the type of result as human readable string ('File', 'Music', etc)
+ * @param string $container
*/
public function __construct($name, $text, $link, $type, $container) {
$this->name=$name;
diff --git a/lib/private/server.php b/lib/private/server.php
index c9e593ec2ed..7696fc207fd 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -124,6 +124,9 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('AllConfig', function($c) {
return new \OC\AllConfig();
});
+ $this->registerService('AppConfig', function ($c) {
+ return new \OC\AppConfig(\OC_DB::getConnection());
+ });
$this->registerService('L10NFactory', function($c) {
return new \OC\L10N\Factory();
});
@@ -148,6 +151,13 @@ class Server extends SimpleContainer implements IServerContainer {
$this->registerService('AvatarManager', function($c) {
return new AvatarManager();
});
+ $this->registerService('JobList', function ($c) {
+ /**
+ * @var Server $c
+ */
+ $config = $c->getConfig();
+ return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config);
+ });
}
/**
@@ -270,6 +280,15 @@ class Server extends SimpleContainer implements IServerContainer {
}
/**
+ * Returns the app config manager
+ *
+ * @return \OCP\IAppConfig
+ */
+ function getAppConfig(){
+ return $this->query('AppConfig');
+ }
+
+ /**
* get an L10N instance
* @param $app string appid
* @return \OC_L10N
@@ -336,4 +355,13 @@ class Server extends SimpleContainer implements IServerContainer {
function getActivityManager() {
return $this->query('ActivityManager');
}
+
+ /**
+ * Returns an job list for controlling background jobs
+ *
+ * @return \OCP\BackgroundJob\IJobList
+ */
+ function getJobList(){
+ return $this->query('JobList');
+ }
}
diff --git a/lib/private/session/memory.php b/lib/private/session/memory.php
index 134cee582ed..1b9ac452575 100644
--- a/lib/private/session/memory.php
+++ b/lib/private/session/memory.php
@@ -25,7 +25,7 @@ class Memory extends Session {
/**
* @param string $key
- * @param mixed $value
+ * @param integer $value
*/
public function set($key, $value) {
$this->data[$key] = $value;
diff --git a/lib/private/setup.php b/lib/private/setup.php
index 5232398d1d7..17ef75bc7b5 100644
--- a/lib/private/setup.php
+++ b/lib/private/setup.php
@@ -94,10 +94,11 @@ class OC_Setup {
}
if(count($error) == 0) {
- OC_Appconfig::setValue('core', 'installedat', microtime(true));
- 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');
+ $appConfig = \OC::$server->getAppConfig();
+ $appConfig->setValue('core', 'installedat', microtime(true));
+ $appConfig->setValue('core', 'lastupdatedat', microtime(true));
+ $appConfig->setValue('core', 'remote_core.css', '/core/minimizer.php');
+ $appConfig->setValue('core', 'remote_core.js', '/core/minimizer.php');
OC_Group::createGroup('admin');
OC_Group::addToGroup($username, 'admin');
diff --git a/lib/private/share/mailnotifications.php b/lib/private/share/mailnotifications.php
new file mode 100644
index 00000000000..360376294cc
--- /dev/null
+++ b/lib/private/share/mailnotifications.php
@@ -0,0 +1,160 @@
+<?php
+/**
+* ownCloud
+*
+* @author Bjoern Schiessle
+* @copyright 2014 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 <http://www.gnu.org/licenses/>.
+*/
+
+namespace OC\Share;
+
+class MailNotifications {
+
+ private $senderId; // sender userId
+ private $from; // sender email address
+ private $senderDisplayName;
+ private $l;
+
+ /**
+ *
+ * @param string $recipient user id
+ * @param string $sender user id (if nothing is set we use the currently logged-in user)
+ */
+ public function __construct($sender = null) {
+ $this->l = \OC_L10N::get('core');
+
+ $this->senderId = $sender;
+
+ $this->from = \OCP\Util::getDefaultEmailAddress('sharing-noreply');
+ if ($this->senderId) {
+ $this->from = \OCP\Config::getUserValue($this->senderId, 'settings', 'email', $this->from);
+ $this->senderDisplayName = \OCP\User::getDisplayName($this->senderId);
+ } else {
+ $this->senderDisplayName = \OCP\User::getDisplayName();
+ }
+ }
+
+ /**
+ * @brief inform users if a file was shared with them
+ *
+ * @param array $recipientList list of recipients
+ * @param type $itemSource shared item source
+ * @param type $itemType shared item type
+ * @return array list of user to whom the mail send operation failed
+ */
+ public function sendInternalShareMail($recipientList, $itemSource, $itemType) {
+
+ $noMail = array();
+
+ foreach ($recipientList as $recipient) {
+ $recipientDisplayName = \OCP\User::getDisplayName($recipient);
+ $to = \OC_Preferences::getValue($recipient, 'settings', 'email', '');
+
+ if ($to === '') {
+ $noMail[] = $recipientDisplayName;
+ continue;
+ }
+
+ $items = \OCP\Share::getItemSharedWithUser($itemType, $itemSource, $recipient);
+ $filename = trim($items[0]['file_target'], '/');
+ $subject = (string) $this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename));
+ $expiration = null;
+ if (isset($items[0]['expiration'])) {
+ try {
+ $date = new DateTime($items[0]['expiration']);
+ $expiration = $date->getTimestamp();
+ } catch (\Exception $e) {
+ \OCP\Util::writeLog('sharing', "Couldn't read date: " . $e->getMessage(), \OCP\Util::ERROR);
+ }
+ }
+
+ if ($itemType === 'folder') {
+ $foldername = "/Shared/" . $filename;
+ } else {
+ // if it is a file we can just link to the Shared folder,
+ // that's the place where the user will find the file
+ $foldername = "/Shared";
+ }
+
+ $link = \OCP\Util::linkToAbsolute('files', 'index.php', array("dir" => $foldername));
+
+ list($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration);
+
+ // send it out now
+ try {
+ \OCP\Util::sendMail($to, $recipientDisplayName, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail);
+ } catch (\Exception $e) {
+ \OCP\Util::writeLog('sharing', "Can't send mail to inform the user abaut an internal share: " . $e->getMessage() , \OCP\Util::ERROR);
+ $noMail[] = $recipientDisplayName;
+ }
+ }
+
+ return $noMail;
+
+ }
+
+ /**
+ * @brief inform recipient about public link share
+ *
+ * @param string recipient recipient email address
+ * @param string $filename the shared file
+ * @param string $link the public link
+ * @param int $expiration expiration date (timestamp)
+ * @return mixed $result true or error message
+ */
+ public function sendLinkShareMail($recipient, $filename, $link, $expiration) {
+ $subject = (string)$this->l->t('%s shared »%s« with you', array($this->senderDisplayName, $filename));
+ list($htmlMail, $alttextMail) = $this->createMailBody($filename, $link, $expiration);
+ try {
+ \OCP\Util::sendMail($recipient, $recipient, $subject, $htmlMail, $this->from, $this->senderDisplayName, 1, $alttextMail);
+ } catch (\Exception $e) {
+ \OCP\Util::writeLog('sharing', "Can't send mail with public link: " . $e->getMessage(), \OCP\Util::ERROR);
+ return $e->getMessage();
+ }
+
+ return true;
+ }
+
+ /**
+ * @brief create mail body for plain text and html mail
+ *
+ * @param string $filename the shared file
+ * @param string $link link to the shared file
+ * @param int $expiration expiration date (timestamp)
+ * @return array with the html mail body and the plain text mail body
+ */
+ private function createMailBody($filename, $link, $expiration) {
+
+ $formatedDate = $expiration ? $this->l->l('date', $expiration) : null;
+
+ $html = new \OC_Template("core", "mail", "");
+ $html->assign ('link', $link);
+ $html->assign ('user_displayname', $this->senderDisplayName);
+ $html->assign ('filename', $filename);
+ $html->assign('expiration', $formatedDate);
+ $htmlMail = $html->fetchPage();
+
+ $alttext = new \OC_Template("core", "altmail", "");
+ $alttext->assign ('link', $link);
+ $alttext->assign ('user_displayname', $this->senderDisplayName);
+ $alttext->assign ('filename', $filename);
+ $alttext->assign('expiration', $formatedDate);
+ $alttextMail = $alttext->fetchPage();
+
+ return array($htmlMail, $alttextMail);
+ }
+
+}
diff --git a/lib/private/share/searchresultsorter.php b/lib/private/share/searchresultsorter.php
new file mode 100644
index 00000000000..76abbf30846
--- /dev/null
+++ b/lib/private/share/searchresultsorter.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Copyright (c) 2014 Arthur Schiwon <blizzz@owncloud.com>
+ * This file is licensed under the Affero General Public License version 3 or
+ * later.
+ * See the COPYING-README file.
+ *
+ */
+namespace OC\Share;
+
+class SearchResultSorter {
+ private $search;
+ private $encoding;
+ private $key;
+ private $log;
+
+ /**
+ * @param string $search the search term as was given by the user
+ * @param string $key the array key containing the value that should be compared
+ * against
+ * @param $encoding optional, encoding to use, defaults to UTF-8
+ * @param $log optional, an \OC\Log instance
+ */
+ public function __construct($search, $key, \OC\Log $log = null, $encoding = 'UTF-8') {
+ $this->encoding = $encoding;
+ $this->key = $key;
+ $this->log = $log;
+ $this->search = mb_strtolower($search, $this->encoding);
+ }
+
+ /**
+ * User and Group names matching the search term at the beginning shall appear
+ * on top of the share dialog. Following entries in alphabetical order.
+ * Callback function for usort. http://php.net/usort
+ */
+ public function sort($a, $b) {
+ if(!isset($a[$this->key]) || !isset($b[$this->key])) {
+ if(!is_null($this->log)) {
+ $this->log->error('Sharing dialogue: cannot sort due to ' .
+ 'missing array key', array('app' => 'core'));
+ }
+ return 0;
+ }
+ $nameA = mb_strtolower($a[$this->key], $this->encoding);
+ $nameB = mb_strtolower($b[$this->key], $this->encoding);
+ $i = mb_strpos($nameA, $this->search, 0, $this->encoding);
+ $j = mb_strpos($nameB, $this->search, 0, $this->encoding);
+
+ if($i === $j || $i > 0 && $j > 0) {
+ return strcmp(mb_strtolower($nameA, $this->encoding),
+ mb_strtolower($nameB, $this->encoding));
+ } elseif ($i === 0) {
+ return -1;
+ } else {
+ return 1;
+ }
+ }
+}
+
diff --git a/lib/private/tags.php b/lib/private/tags.php
index fe7de1073a0..06550068f76 100644
--- a/lib/private/tags.php
+++ b/lib/private/tags.php
@@ -73,6 +73,7 @@ class Tags implements \OCP\ITags {
* Constructor.
*
* @param string $user The user whos data the object will operate on.
+ * @param string $type
*/
public function __construct($user, $type, $defaultTags = array()) {
$this->user = $user;
@@ -83,8 +84,6 @@ class Tags implements \OCP\ITags {
/**
* Load tags from db.
*
- * @param string $type The type identifier e.g. 'contact' or 'event'.
- * @param array $defaultTags An array of default tags to be used if none are stored.
*/
protected function loadTags($defaultTags=array()) {
$this->tags = array();
@@ -176,7 +175,7 @@ class Tags implements \OCP\ITags {
*
* Throws an exception if the tag could not be found.
*
- * @param string|integer $tag Tag id or name.
+ * @param string $tag Tag id or name.
* @return array An array of object ids or false on error.
*/
public function getIdsForTag($tag) {
@@ -235,7 +234,7 @@ class Tags implements \OCP\ITags {
* Add a new tag.
*
* @param string $name A string with a name of the tag
- * @return int the id of the added tag or false if it already exists.
+ * @return false|string the id of the added tag or false if it already exists.
*/
public function add($name) {
$name = trim($name);
@@ -512,7 +511,7 @@ class Tags implements \OCP\ITags {
* Creates a tag/object relation.
*
* @param int $objid The id of the object
- * @param int|string $tag The id or name of the tag
+ * @param string $tag The id or name of the tag
* @return boolean Returns false on database error.
*/
public function tagAs($objid, $tag) {
@@ -544,7 +543,7 @@ class Tags implements \OCP\ITags {
* Delete single tag/object relation from the db
*
* @param int $objid The id of the object
- * @param int|string $tag The id or name of the tag
+ * @param string $tag The id or name of the tag
* @return boolean
*/
public function unTag($objid, $tag) {
diff --git a/lib/private/template.php b/lib/private/template.php
index b2c3a20f281..c6851c6cc8d 100644
--- a/lib/private/template.php
+++ b/lib/private/template.php
@@ -156,6 +156,9 @@ class OC_Template extends \OC\Template\Base {
*
* Will select the template file for the selected theme and formfactor.
* Checking all the possible locations.
+ * @param string $theme
+ * @param string $app
+ * @param string $fext
*/
protected function findTemplate($theme, $app, $name, $fext) {
// Check if it is a app template or not.
@@ -182,7 +185,7 @@ class OC_Template extends \OC\Template\Base {
/**
* @brief Process the template
- * @return bool
+ * @return boolean|string
*
* This function process the template. If $this->renderas is set, it
* will produce a full page.
@@ -223,7 +226,7 @@ class OC_Template extends \OC\Template\Base {
* @param string $application The application we render the template for
* @param string $name Name of the template
* @param array $parameters Parameters for the template
- * @return bool
+ * @return boolean|null
*/
public static function printUserPage( $application, $name, $parameters = array() ) {
$content = new OC_Template( $application, $name, "user" );
diff --git a/lib/private/template/base.php b/lib/private/template/base.php
index 88941bc7132..232a29939cc 100644
--- a/lib/private/template/base.php
+++ b/lib/private/template/base.php
@@ -14,6 +14,11 @@ class Base {
private $l10n; // The l10n-Object
private $theme; // theme defaults
+ /**
+ * @param string $template
+ * @param \OC_L10N $l10n
+ * @param \OC_Defaults $theme
+ */
public function __construct( $template, $requesttoken, $l10n, $theme ) {
$this->vars = array();
$this->vars['requesttoken'] = $requesttoken;
@@ -22,6 +27,12 @@ class Base {
$this->theme = $theme;
}
+ /**
+ * @param string $serverroot
+ * @param string|false $app_dir
+ * @param string $theme
+ * @param string $app
+ */
protected function getAppTemplateDirs($theme, $app, $serverroot, $app_dir) {
// Check if the app is in the app folder or in the root
if( file_exists($app_dir.'/templates/' )) {
@@ -36,6 +47,10 @@ class Base {
);
}
+ /**
+ * @param string $serverroot
+ * @param string $theme
+ */
protected function getCoreTemplateDirs($theme, $serverroot) {
return array(
$serverroot.'/themes/'.$theme.'/core/templates/',
@@ -63,7 +78,7 @@ class Base {
* @brief Appends a variable
* @param string $key key
* @param string $value value
- * @return bool
+ * @return boolean|null
*
* This function assigns a variable in an array context. If the key already
* exists, the value will be appended. It can be accessed via
@@ -97,7 +112,7 @@ class Base {
/**
* @brief Process the template
- * @return bool
+ * @return string
*
* This function processes the template.
*/
@@ -107,6 +122,7 @@ class Base {
/**
* @brief doing the actual work
+ * @param string $file
* @return string content
*
* Includes the template file, fetches its output
diff --git a/lib/private/template/functions.php b/lib/private/template/functions.php
index ce42633b364..a72d41f72da 100644
--- a/lib/private/template/functions.php
+++ b/lib/private/template/functions.php
@@ -78,6 +78,9 @@ function preview_icon( $path ) {
return OC_Helper::previewIcon( $path );
}
+/**
+ * @param string $path
+ */
function publicPreview_icon ( $path, $token ) {
return OC_Helper::publicPreviewIcon( $path, $token );
}
@@ -110,7 +113,7 @@ function strip_time($timestamp){
* @param int $timestamp timestamp to format
* @param int $fromTime timestamp to compare from, defaults to current time
* @param bool $dateOnly whether to strip time information
- * @return formatted timestamp
+ * @return OC_L10N_String timestamp
*/
function relative_modified_date($timestamp, $fromTime = null, $dateOnly = false) {
$l=OC_L10N::get('lib');
diff --git a/lib/private/template/resourcelocator.php b/lib/private/template/resourcelocator.php
index 9f83673664d..8a3dd5e7fa9 100644
--- a/lib/private/template/resourcelocator.php
+++ b/lib/private/template/resourcelocator.php
@@ -19,6 +19,10 @@ abstract class ResourceLocator {
protected $resources = array();
+ /**
+ * @param string $theme
+ * @param string $form_factor
+ */
public function __construct( $theme, $form_factor, $core_map, $party_map ) {
$this->theme = $theme;
$this->form_factor = $form_factor;
@@ -53,6 +57,10 @@ abstract class ResourceLocator {
* @param $file the filename
* @param $web base for path, default map $root to $webroot
*/
+ /**
+ * @param string $file
+ * @param string|false $webroot
+ */
protected function appendIfExist($root, $file, $webroot = null) {
if (is_file($root.'/'.$file)) {
if (!$webroot) {
diff --git a/lib/private/template/templatefilelocator.php b/lib/private/template/templatefilelocator.php
index d5a484b1a14..4676fceb37d 100644
--- a/lib/private/template/templatefilelocator.php
+++ b/lib/private/template/templatefilelocator.php
@@ -13,11 +13,18 @@ class TemplateFileLocator {
protected $dirs;
private $path;
+ /**
+ * @param string[] $dirs
+ * @param string $form_factor
+ */
public function __construct( $form_factor, $dirs ) {
$this->form_factor = $form_factor;
$this->dirs = $dirs;
}
+ /**
+ * @param string $template
+ */
public function find( $template ) {
if ($template === '') {
throw new \InvalidArgumentException('Empty template name');
diff --git a/lib/private/templatelayout.php b/lib/private/templatelayout.php
index d5cd5039753..7bca5bc4836 100644
--- a/lib/private/templatelayout.php
+++ b/lib/private/templatelayout.php
@@ -7,6 +7,10 @@
*/
class OC_TemplateLayout extends OC_Template {
+
+ /**
+ * @param string $renderas
+ */
public function __construct( $renderas ) {
// Decide which page we show
diff --git a/lib/private/urlgenerator.php b/lib/private/urlgenerator.php
index 4e3c1109000..60da34f2d6e 100644
--- a/lib/private/urlgenerator.php
+++ b/lib/private/urlgenerator.php
@@ -147,6 +147,7 @@ class URLGenerator implements IURLGenerator {
* @return string the absolute version of the url
*/
public function getAbsoluteURL($url) {
- return \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . $url;
+ $separator = $url[0] === '/' ? '' : '/';
+ return \OC_Request::serverProtocol() . '://' . \OC_Request::serverHost() . $separator . $url;
}
}
diff --git a/lib/private/user.php b/lib/private/user.php
index 98ebebbe5c1..08ead712028 100644
--- a/lib/private/user.php
+++ b/lib/private/user.php
@@ -205,6 +205,9 @@ class OC_User {
// Delete user files in /data/
OC_Helper::rmdirr(\OC_User::getHome($uid));
+ // Delete the users entry in the storage table
+ \OC\Files\Cache\Storage::remove('home::' . $uid);
+
// Remove it from the Cache
self::getManager()->delete($uid);
}
@@ -219,7 +222,7 @@ class OC_User {
* @brief Try to login a user
* @param $uid The username of the user to log in
* @param $password The password of the user
- * @return bool
+ * @return boolean|null
*
* Log in a user and regenerate a new session - if the password is ok
*/
@@ -243,7 +246,6 @@ class OC_User {
OC_Hook::emit( "OC_User", "pre_login", array( "run" => &$run, "uid" => $uid ));
if($uid) {
- session_regenerate_id(true);
self::setUserId($uid);
self::setDisplayName($uid);
self::getUserSession()->setLoginName($uid);
@@ -287,6 +289,7 @@ class OC_User {
/**
* @brief Sets user display name for session
+ * @param string $uid
*/
public static function setDisplayName($uid, $displayName = null) {
if (is_null($displayName)) {
@@ -478,7 +481,7 @@ class OC_User {
* @brief Check if the password is correct
* @param string $uid The username
* @param string $password The password
- * @return mixed user id a string on success, false otherwise
+ * @return string|false user id a string on success, false otherwise
*
* Check if the password is correct without logging in the user
* returns the user id or false
@@ -512,6 +515,8 @@ class OC_User {
* @returns array with all uids
*
* Get a list of all users.
+ * @param integer $limit
+ * @param integer $offset
*/
public static function getUsers($search = '', $limit = null, $offset = null) {
$users = self::getManager()->search($search, $limit, $offset);
@@ -606,7 +611,7 @@ class OC_User {
/**
* @brief Returns the first active backend from self::$_usedBackends.
- * @return null if no backend active, otherwise OCP\Authentication\IApacheBackend
+ * @return OCP\Authentication\IApacheBackend|null if no backend active, otherwise OCP\Authentication\IApacheBackend
*/
private static function findFirstActiveUsedBackend() {
foreach (self::$_usedBackends as $backend) {
diff --git a/lib/private/user/database.php b/lib/private/user/database.php
index 1a63755b980..15e6643dfb3 100644
--- a/lib/private/user/database.php
+++ b/lib/private/user/database.php
@@ -236,7 +236,7 @@ class OC_User_Database extends OC_User_Backend {
/**
* @brief get the user's home directory
* @param string $uid the username
- * @return boolean
+ * @return string|false
*/
public function getHome($uid) {
if ($this->userExists($uid)) {
@@ -256,7 +256,7 @@ class OC_User_Database extends OC_User_Backend {
/**
* counts the users in the database
*
- * @return int | bool
+ * @return false|string | bool
*/
public function countUsers() {
$query = OC_DB::prepare('SELECT COUNT(*) FROM `*PREFIX*users`');
diff --git a/lib/private/user/dummy.php b/lib/private/user/dummy.php
index fc15a630cf3..2fb51d02de3 100644
--- a/lib/private/user/dummy.php
+++ b/lib/private/user/dummy.php
@@ -100,7 +100,7 @@ class OC_User_Dummy extends OC_User_Backend {
* @param string $search
* @param int $limit
* @param int $offset
- * @return array with all uids
+ * @return string[] with all uids
*
* Get a list of all users.
*/
diff --git a/lib/private/user/http.php b/lib/private/user/http.php
index e99afe59ba7..a0394521012 100644
--- a/lib/private/user/http.php
+++ b/lib/private/user/http.php
@@ -98,7 +98,7 @@ class OC_User_HTTP extends OC_User_Backend {
/**
* @brief get the user's home directory
* @param string $uid the username
- * @return boolean
+ * @return string|false
*/
public function getHome($uid) {
if($this->userExists($uid)) {
diff --git a/lib/private/user/interface.php b/lib/private/user/interface.php
index c72bdfaf3fd..cdcab3e5d00 100644
--- a/lib/private/user/interface.php
+++ b/lib/private/user/interface.php
@@ -30,6 +30,7 @@ interface OC_User_Interface {
*
* Returns the supported actions as int to be
* compared with OC_USER_BACKEND_CREATE_USER etc.
+ * @return boolean
*/
public function implementsActions($actions);
@@ -39,6 +40,7 @@ interface OC_User_Interface {
* @returns true/false
*
* Deletes a user
+ * @return boolean
*/
public function deleteUser($uid);
diff --git a/lib/private/user/manager.php b/lib/private/user/manager.php
index 90970ef9963..8583a451f2d 100644
--- a/lib/private/user/manager.php
+++ b/lib/private/user/manager.php
@@ -144,8 +144,8 @@ class Manager extends PublicEmitter {
/**
* Check if the password is valid for the user
*
- * @param $loginname
- * @param $password
+ * @param string $loginname
+ * @param string $password
* @return mixed the User object on success, false otherwise
*/
public function checkPassword($loginname, $password) {
diff --git a/lib/private/user/session.php b/lib/private/user/session.php
index 1e299416fb3..cd03b30205f 100644
--- a/lib/private/user/session.php
+++ b/lib/private/user/session.php
@@ -149,7 +149,7 @@ class Session implements Emitter, \OCP\IUserSession {
*
* @param string $uid
* @param string $password
- * @return bool
+ * @return boolean|null
*/
public function login($uid, $password) {
$this->manager->emit('\OC\User', 'preLogin', array($uid, $password));
@@ -157,6 +157,7 @@ class Session implements Emitter, \OCP\IUserSession {
if($user !== false) {
if (!is_null($user)) {
if ($user->isEnabled()) {
+ session_regenerate_id(true);
$this->setUser($user);
$this->setLoginName($uid);
$this->manager->emit('\OC\User', 'postLogin', array($user, $password));
diff --git a/lib/private/util.php b/lib/private/util.php
index b16c5980d75..d3b682daa5c 100755
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -90,10 +90,14 @@ class OC_Util {
return true;
}
+ /**
+ * @param string $user
+ */
public static function getUserQuota($user){
- $userQuota = OC_Preferences::getValue($user, 'files', 'quota', 'default');
+ $config = \OC::$server->getConfig();
+ $userQuota = $config->getUserValue($user, 'files', 'quota', 'default');
if($userQuota === 'default') {
- $userQuota = OC_AppConfig::getValue('files', 'default_quota', 'none');
+ $userQuota = $config->getAppValue('files', 'default_quota', 'none');
}
if($userQuota === 'none') {
return \OC\Files\SPACE_UNLIMITED;
@@ -214,7 +218,7 @@ class OC_Util {
* @brief add a javascript file
*
* @param string $application
- * @param filename $file
+ * @param string|null $file filename
* @return void
*/
public static function addScript( $application, $file = null ) {
@@ -233,7 +237,7 @@ class OC_Util {
* @brief add a css file
*
* @param string $application
- * @param filename $file
+ * @param string|null $file filename
* @return void
*/
public static function addStyle( $application, $file = null ) {
@@ -512,7 +516,7 @@ class OC_Util {
/**
* @brief Check for correct file permissions of data directory
- * @paran string $dataDirectory
+ * @param string $dataDirectory
* @return array arrays with error messages and hints
*/
public static function checkDataDirectoryPermissions($dataDirectory) {
@@ -566,6 +570,7 @@ class OC_Util {
/**
* @brief Check if the app is enabled, redirects to home if not
+ * @param string $app
* @return void
*/
public static function checkAppEnabled($app) {
@@ -625,7 +630,7 @@ class OC_Util {
/**
* @brief Check if the user is a subadmin, redirects to home if not
- * @return array $groups where the current user is subadmin
+ * @return null|boolean $groups where the current user is subadmin
*/
public static function checkSubAdminUser() {
OC_Util::checkLoggedIn();
@@ -924,7 +929,7 @@ class OC_Util {
/**
* @brief Check if the connection to the internet is disabled on purpose
- * @return bool
+ * @return string
*/
public static function isInternetConnectionEnabled(){
return \OC_Config::getValue("has_internet_connection", true);
@@ -1129,6 +1134,7 @@ class OC_Util {
}
/**
+ * @param boolean|string $file
* @return string
*/
public static function basename($file) {
@@ -1149,4 +1155,25 @@ class OC_Util {
}
return $version;
}
+
+ /**
+ * Returns whether the given file name is valid
+ * @param $file string file name to check
+ * @return bool true if the file name is valid, false otherwise
+ */
+ public static function isValidFileName($file) {
+ $trimmed = trim($file);
+ if ($trimmed === '') {
+ return false;
+ }
+ if ($trimmed === '.' || $trimmed === '..') {
+ return false;
+ }
+ foreach (str_split($trimmed) as $char) {
+ if (strpos(\OCP\FILENAME_INVALID_CHARS, $char) !== false) {
+ return false;
+ }
+ }
+ return true;
+ }
}