diff options
264 files changed, 3614 insertions, 1037 deletions
diff --git a/3rdparty b/3rdparty -Subproject 7c2c94c904c2721763e97d5bafd115f863080a6 +Subproject c7b4cdbcc1faa56df2489a5753b457627f460c0 diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 0be38c3b96f..c8286bc15ca 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -11,7 +11,8 @@ OCP\JSON::checkLoggedIn(); // Load the files $dir = isset( $_GET['dir'] ) ? $_GET['dir'] : ''; $dir = \OC\Files\Filesystem::normalizePath($dir); -if (!\OC\Files\Filesystem::is_dir($dir . '/')) { +$dirInfo = \OC\Files\Filesystem::getFileInfo($dir); +if (!$dirInfo->getType() === 'dir') { header("HTTP/1.0 404 Not Found"); exit(); } @@ -20,7 +21,7 @@ $doBreadcrumb = isset($_GET['breadcrumb']); $data = array(); $baseUrl = OCP\Util::linkTo('files', 'index.php') . '?dir='; -$permissions = \OCA\Files\Helper::getDirPermissions($dir); +$permissions = $dirInfo->getPermissions(); // Make breadcrumb if($doBreadcrumb) { diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php index 754c34ef088..145f40c50da 100644 --- a/apps/files/ajax/upload.php +++ b/apps/files/ajax/upload.php @@ -22,6 +22,7 @@ if (empty($_POST['dirToken'])) { } else { // return only read permissions for public upload $allowedPermissions = OCP\PERMISSION_READ; + $public_directory = !empty($_POST['subdir']) ? $_POST['subdir'] : '/'; $linkItem = OCP\Share::getShareByToken($_POST['dirToken']); if ($linkItem === false) { @@ -45,7 +46,7 @@ if (empty($_POST['dirToken'])) { $dir = sprintf( "/%s/%s", $path, - isset($_POST['subdir']) ? $_POST['subdir'] : '' + $public_directory ); if (!$dir || empty($dir) || $dir === false) { @@ -112,7 +113,14 @@ if (strpos($dir, '..') === false) { } else { $target = \OC\Files\Filesystem::normalizePath(stripslashes($dir).'/'.$files['name'][$i]); } - + + $directory = \OC\Files\Filesystem::normalizePath(stripslashes($dir)); + if (isset($public_directory)) { + // If we are uploading from the public app, + // we want to send the relative path in the ajax request. + $directory = $public_directory; + } + if ( ! \OC\Files\Filesystem::file_exists($target) || (isset($_POST['resolution']) && $_POST['resolution']==='replace') ) { @@ -140,7 +148,7 @@ if (strpos($dir, '..') === false) { 'uploadMaxFilesize' => $maxUploadFileSize, 'maxHumanFilesize' => $maxHumanFileSize, 'permissions' => $meta['permissions'] & $allowedPermissions, - 'directory' => \OC\Files\Filesystem::normalizePath(stripslashes($dir)), + 'directory' => $directory, ); } @@ -168,7 +176,7 @@ if (strpos($dir, '..') === false) { 'uploadMaxFilesize' => $maxUploadFileSize, 'maxHumanFilesize' => $maxHumanFileSize, 'permissions' => $meta['permissions'] & $allowedPermissions, - 'directory' => \OC\Files\Filesystem::normalizePath(stripslashes($dir)), + 'directory' => $directory, ); } } diff --git a/apps/files/appinfo/update.php b/apps/files/appinfo/update.php index 3503678e7c7..f920f842166 100644 --- a/apps/files/appinfo/update.php +++ b/apps/files/appinfo/update.php @@ -3,17 +3,14 @@ // fix webdav properties,add namespace in front of the property, update for OC4.5 $installedVersion=OCP\Config::getAppValue('files', 'installed_version'); if (version_compare($installedVersion, '1.1.6', '<')) { - $query = OC_DB::prepare( 'SELECT `propertyname`, `propertypath`, `userid` FROM `*PREFIX*properties`' ); - $result = $query->execute(); - $updateQuery = OC_DB::prepare('UPDATE `*PREFIX*properties`' - .' SET `propertyname` = ?' - .' WHERE `userid` = ?' - .' AND `propertypath` = ?'); - while( $row = $result->fetchRow()) { - if ( $row['propertyname'][0] != '{' ) { - $updateQuery->execute(array('{DAV:}' + $row['propertyname'], $row['userid'], $row['propertypath'])); - } - } + $concat = OC_DB::getConnection()->getDatabasePlatform()-> + getConcatExpression( '\'{DAV:}\'', '`propertyname`' ); + $query = OC_DB::prepare(' + UPDATE `*PREFIX*properties` + SET `propertyname` = ' . $concat . ' + WHERE `propertyname` NOT LIKE \'{%\' + '); + $query->execute(); } //update from OC 3 diff --git a/apps/files/css/files.css b/apps/files/css/files.css index 5526abaf6e2..3ad167054c2 100644 --- a/apps/files/css/files.css +++ b/apps/files/css/files.css @@ -84,9 +84,26 @@ background-color: rgb(240,240,240); } tbody a { color:#000; } -span.extension, span.uploading, td.date { color:#999; } -span.extension { text-transform:lowercase; -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; filter:alpha(opacity=70); opacity:.7; -webkit-transition:opacity 300ms; -moz-transition:opacity 300ms; -o-transition:opacity 300ms; transition:opacity 300ms; } -tr:hover span.extension { -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; filter:alpha(opacity=100); opacity:1; color:#777; } + +span.extension, span.uploading, td.date { + color: #999; +} +span.extension { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)"; + filter: alpha(opacity=70); + opacity: .7; + -webkit-transition: opacity 300ms; + -moz-transition: opacity 300ms; + -o-transition: opacity 300ms; + transition: opacity 300ms; +} +tr:hover span.extension { + -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)"; + filter: alpha(opacity=100); + opacity: 1; + color: #777; +} + table tr.mouseOver td { background-color:#eee; } table th { height:24px; padding:0 8px; color:#999; } table th .name { @@ -302,7 +319,7 @@ a.action>img { max-height:16px; max-width:16px; vertical-align:text-bottom; } #fileList a.action { display: inline; margin: -8px 0; - padding: 18px 8px !important; + padding: 18px 8px; -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)"; filter: alpha(opacity=0); opacity: 0; diff --git a/apps/files/index.php b/apps/files/index.php index dd63f29bc28..ad7a2e210ed 100644 --- a/apps/files/index.php +++ b/apps/files/index.php @@ -37,8 +37,9 @@ OCP\App::setActiveNavigationEntry('files_index'); // Load the files $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : ''; $dir = \OC\Files\Filesystem::normalizePath($dir); +$dirInfo = \OC\Files\Filesystem::getFileInfo($dir); // Redirect if directory does not exist -if (!\OC\Files\Filesystem::is_dir($dir . '/')) { +if (!$dirInfo->getType() === 'dir') { header('Location: ' . OCP\Util::getScriptName() . ''); exit(); } @@ -79,6 +80,8 @@ if (\OC\Files\Cache\Upgrade::needUpgrade($user)) { //dont load anything if we ne $needUpgrade = false; } +$config = \OC::$server->getConfig(); + // Make breadcrumb $breadcrumb = \OCA\Files\Helper::makeBreadcrumb($dir); @@ -92,7 +95,7 @@ $breadcrumbNav = new OCP\Template('files', 'part.breadcrumb', ''); $breadcrumbNav->assign('breadcrumb', $breadcrumb); $breadcrumbNav->assign('baseURL', OCP\Util::linkTo('files', 'index.php') . '?dir='); -$permissions = \OCA\Files\Helper::getDirPermissions($dir); +$permissions = $dirInfo->getPermissions(); if ($needUpgrade) { OCP\Util::addscript('files', 'upgrade'); @@ -104,7 +107,7 @@ if ($needUpgrade) { $freeSpace=$storageInfo['free']; $uploadLimit=OCP\Util::uploadLimit(); $maxUploadFilesize=OCP\Util::maxUploadFilesize($dir); - $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); + $publicUploadEnabled = $config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'); // if the encryption app is disabled, than everything is fine (INIT_SUCCESSFUL status code) $encryptionInitStatus = 2; if (OC_App::isEnabled('files_encryption')) { @@ -143,8 +146,8 @@ if ($needUpgrade) { $tmpl->assign('isPublic', false); $tmpl->assign('publicUploadEnabled', $publicUploadEnabled); $tmpl->assign("encryptedFiles", \OCP\Util::encryptedFiles()); - $tmpl->assign("mailNotificationEnabled", \OC_Appconfig::getValue('core', 'shareapi_allow_mail_notification', 'yes')); - $tmpl->assign("allowShareWithLink", \OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes')); + $tmpl->assign("mailNotificationEnabled", $config->getAppValue('core', 'shareapi_allow_mail_notification', 'yes')); + $tmpl->assign("allowShareWithLink", $config->getAppValue('core', 'shareapi_allow_links', 'yes')); $tmpl->assign("encryptionInitStatus", $encryptionInitStatus); $tmpl->assign('disableSharing', false); $tmpl->assign('ajaxLoad', $ajaxLoad); diff --git a/apps/files/lib/helper.php b/apps/files/lib/helper.php index 01fc65d76b7..ac8a2ad3200 100644 --- a/apps/files/lib/helper.php +++ b/apps/files/lib/helper.php @@ -112,26 +112,4 @@ class Helper } return $breadcrumb; } - - /** - * Returns the numeric permissions for the given directory. - * @param string $dir directory without trailing slash - * @return numeric permissions - */ - public static function getDirPermissions($dir){ - $permissions = \OCP\PERMISSION_READ; - if (\OC\Files\Filesystem::isCreatable($dir . '/')) { - $permissions |= \OCP\PERMISSION_CREATE; - } - if (\OC\Files\Filesystem::isUpdatable($dir . '/')) { - $permissions |= \OCP\PERMISSION_UPDATE; - } - if (\OC\Files\Filesystem::isDeletable($dir . '/')) { - $permissions |= \OCP\PERMISSION_DELETE; - } - if (\OC\Files\Filesystem::isSharable($dir . '/')) { - $permissions |= \OCP\PERMISSION_SHARE; - } - return $permissions; - } } diff --git a/apps/files_encryption/ajax/adminrecovery.php b/apps/files_encryption/ajax/adminrecovery.php index 6a0186d5a9b..61e43acc2c3 100644 --- a/apps/files_encryption/ajax/adminrecovery.php +++ b/apps/files_encryption/ajax/adminrecovery.php @@ -18,7 +18,7 @@ $l = OC_L10N::get('files_encryption'); $return = false; // Enable recoveryAdmin -$recoveryKeyId = OC_Appconfig::getValue('files_encryption', 'recoveryKeyId'); +$recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId'); if (isset($_POST['adminEnableRecovery']) && $_POST['adminEnableRecovery'] === '1') { diff --git a/apps/files_encryption/ajax/getMigrationStatus.php b/apps/files_encryption/ajax/getMigrationStatus.php index 17469a1af0c..7c9e0dcc51c 100644 --- a/apps/files_encryption/ajax/getMigrationStatus.php +++ b/apps/files_encryption/ajax/getMigrationStatus.php @@ -13,16 +13,14 @@ use OCA\Encryption\Util; $loginname = isset($_POST['user']) ? $_POST['user'] : ''; $password = isset($_POST['password']) ? $_POST['password'] : ''; -$migrationCompleted = true; +$migrationStatus = Util::MIGRATION_COMPLETED; if ($loginname !== '' && $password !== '') { $username = \OCP\User::checkPassword($loginname, $password); if ($username) { $util = new Util(new \OC_FilesystemView('/'), $username); - if ($util->getMigrationStatus() !== Util::MIGRATION_COMPLETED) { - $migrationCompleted = false; - } + $migrationStatus = $util->getMigrationStatus(); } } -\OCP\JSON::success(array('data' => array('migrationCompleted' => $migrationCompleted))); +\OCP\JSON::success(array('data' => array('migrationStatus' => $migrationStatus))); diff --git a/apps/files_encryption/appinfo/app.php b/apps/files_encryption/appinfo/app.php index fd9aa429b01..21de421c195 100644 --- a/apps/files_encryption/appinfo/app.php +++ b/apps/files_encryption/appinfo/app.php @@ -10,6 +10,7 @@ OC::$CLASSPATH['OCA\Encryption\Session'] = 'files_encryption/lib/session.php'; OC::$CLASSPATH['OCA\Encryption\Capabilities'] = 'files_encryption/lib/capabilities.php'; OC::$CLASSPATH['OCA\Encryption\Helper'] = 'files_encryption/lib/helper.php'; +\OCP\Util::addscript('files_encryption', 'encryption'); \OCP\Util::addscript('files_encryption', 'detect-migration'); if (!OC_Config::getValue('maintenance', false)) { diff --git a/apps/files_encryption/hooks/hooks.php b/apps/files_encryption/hooks/hooks.php index 83abf3ba9de..3af43f10264 100644 --- a/apps/files_encryption/hooks/hooks.php +++ b/apps/files_encryption/hooks/hooks.php @@ -85,10 +85,9 @@ class Hooks { $ready = $util->beginMigration();
} elseif ($migrationStatus === Util::MIGRATION_IN_PROGRESS) {
// refuse login as long as the initial encryption is running
- while ($migrationStatus === Util::MIGRATION_IN_PROGRESS) {
- sleep(60);
- $migrationStatus = $util->getMigrationStatus();
- }
+ sleep(5);
+ \OCP\User::logout();
+ return false;
}
// If migration not yet done
@@ -109,21 +108,27 @@ class Hooks { }
- // Encrypt existing user files:
- if (
- $util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password'])
- ) {
+ // Encrypt existing user files
+ try {
+ $result = $util->encryptAll('/' . $params['uid'] . '/' . 'files', $session->getLegacyKey(), $params['password']);
+ } catch (\Exception $ex) {
+ \OCP\Util::writeLog('Encryption library', 'Initial encryption failed! Error: ' . $ex->getMessage(), \OCP\Util::FATAL);
+ $util->resetMigrationStatus();
+ \OCP\User::logout();
+ $result = false;
+ }
+
+ if ($result) {
\OC_Log::write(
'Encryption library', 'Encryption of existing files belonging to "' . $params['uid'] . '" completed'
, \OC_Log::INFO
);
- }
-
- // Register successful migration in DB
- $util->finishMigration();
+ // Register successful migration in DB
+ $util->finishMigration();
+ }
}
return true;
@@ -642,7 +647,7 @@ class Hooks { /**
* @brief if the file was really deleted we remove the encryption keys
* @param array $params
- * @return boolean
+ * @return boolean|null
*/
public static function postDelete($params) {
@@ -682,7 +687,7 @@ class Hooks { /**
* @brief remember the file which should be deleted and it's owner
* @param array $params
- * @return boolean
+ * @return boolean|null
*/
public static function preDelete($params) {
$path = $params[\OC\Files\Filesystem::signal_param_path];
diff --git a/apps/files_encryption/js/detect-migration.js b/apps/files_encryption/js/detect-migration.js index 301e77f24f7..f5627edf4e4 100644 --- a/apps/files_encryption/js/detect-migration.js +++ b/apps/files_encryption/js/detect-migration.js @@ -17,10 +17,14 @@ $(document).ready(function(){ data: {user: user, password: password}, async: false, success: function(response) { - if (response.data.migrationCompleted === false) { + if (response.data.migrationStatus === OC.Encryption.MIGRATION_OPEN) { var message = t('files_encryption', 'Initial encryption started... This can take some time. Please wait.'); $('#messageText').text(message); $('#message').removeClass('hidden').addClass('update'); + } else if (response.data.migrationStatus === OC.Encryption.MIGRATION_IN_PROGRESS) { + var message = t('files_encryption', 'Initial encryption running... Please try again later.'); + $('#messageText').text(message); + $('#message').removeClass('hidden').addClass('update'); } } }); diff --git a/apps/files_encryption/js/encryption.js b/apps/files_encryption/js/encryption.js new file mode 100644 index 00000000000..65ffabe55e6 --- /dev/null +++ b/apps/files_encryption/js/encryption.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) 2014 + * Bjoern Schiessle <schiessle@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or later. + * See the COPYING-README file. + */ + +OC.Encryption={ + MIGRATION_OPEN:0, + MIGRATION_COMPLETED:1, + MIGRATION_IN_PROGRESS:-1, +}; diff --git a/apps/files_encryption/lib/crypt.php b/apps/files_encryption/lib/crypt.php index 9155d238c77..caca13acece 100755 --- a/apps/files_encryption/lib/crypt.php +++ b/apps/files_encryption/lib/crypt.php @@ -182,6 +182,7 @@ class Crypt { * @param $data
* @param string $relPath The path of the file, relative to user/data;
* e.g. filename or /Docs/filename, NOT admin/files/filename
+ * @param boolean $isCatFileContent
* @return boolean
*/
public static function isLegacyEncryptedContent($isCatFileContent, $relPath) {
@@ -209,8 +210,8 @@ class Crypt { /**
* @brief Symmetrically encrypt a string
- * @param $plainContent
- * @param $iv
+ * @param string $plainContent
+ * @param string $iv
* @param string $passphrase
* @return string encrypted file content
*/
@@ -229,9 +230,9 @@ class Crypt { /**
* @brief Symmetrically decrypt a string
- * @param $encryptedContent
- * @param $iv
- * @param $passphrase
+ * @param string $encryptedContent
+ * @param string $iv
+ * @param string $passphrase
* @throws \Exception
* @return string decrypted file content
*/
@@ -292,8 +293,7 @@ class Crypt { * @brief Symmetrically encrypts a string and returns keyfile content
* @param string $plainContent content to be encrypted in keyfile
* @param string $passphrase
- * @return bool|string
- * @return string encrypted content combined with IV
+ * @return false|string encrypted content combined with IV
* @note IV need not be specified, as it will be stored in the returned keyfile
* and remain accessible therein.
*/
@@ -326,7 +326,7 @@ class Crypt { * @param $keyfileContent
* @param string $passphrase
* @throws \Exception
- * @return bool|string
+ * @return string|false
* @internal param string $source
* @internal param string $target
* @internal param string $key the decryption key
@@ -438,7 +438,7 @@ class Crypt { * @param $encryptedContent
* @param $shareKey
* @param $privateKey
- * @return bool
+ * @return false|string
* @internal param string $plainContent content to be encrypted
* @returns string $plainContent decrypted string
* @note symmetricDecryptFileContent() can be used to decrypt files created using this method
diff --git a/apps/files_encryption/lib/helper.php b/apps/files_encryption/lib/helper.php index bb06a57c714..ef3775875f0 100755 --- a/apps/files_encryption/lib/helper.php +++ b/apps/files_encryption/lib/helper.php @@ -103,7 +103,7 @@ class Helper { * @brief enable recovery * * @param $recoveryKeyId - * @param $recoveryPassword + * @param string $recoveryPassword * @internal param \OCA\Encryption\Util $util * @internal param string $password * @return bool @@ -111,10 +111,11 @@ class Helper { public static function adminEnableRecovery($recoveryKeyId, $recoveryPassword) { $view = new \OC\Files\View('/'); + $appConfig = \OC::$server->getAppConfig(); if ($recoveryKeyId === null) { $recoveryKeyId = 'recovery_' . substr(md5(time()), 0, 8); - \OC_Appconfig::setValue('files_encryption', 'recoveryKeyId', $recoveryKeyId); + $appConfig->setValue('files_encryption', 'recoveryKeyId', $recoveryKeyId); } if (!$view->is_dir('/owncloud_private_key')) { @@ -147,7 +148,7 @@ class Helper { \OC_FileProxy::$enabled = true; // Set recoveryAdmin as enabled - \OC_Appconfig::setValue('files_encryption', 'recoveryAdminEnabled', 1); + $appConfig->setValue('files_encryption', 'recoveryAdminEnabled', 1); $return = true; @@ -155,7 +156,7 @@ class Helper { $util = new \OCA\Encryption\Util(new \OC_FilesystemView('/'), \OCP\User::getUser()); $return = $util->checkRecoveryPassword($recoveryPassword); if ($return) { - \OC_Appconfig::setValue('files_encryption', 'recoveryAdminEnabled', 1); + $appConfig->setValue('files_encryption', 'recoveryAdminEnabled', 1); } } @@ -209,7 +210,7 @@ class Helper { /** * @brief disable recovery * - * @param $recoveryPassword + * @param string $recoveryPassword * @return bool */ public static function adminDisableRecovery($recoveryPassword) { @@ -218,7 +219,7 @@ class Helper { if ($return) { // Set recoveryAdmin as disabled - \OC_Appconfig::setValue('files_encryption', 'recoveryAdminEnabled', 0); + \OC::$server->getAppConfig()->setValue('files_encryption', 'recoveryAdminEnabled', 0); } return $return; @@ -344,6 +345,7 @@ class Helper { /** * @brief redirect to a error page + * @param Session $session */ public static function redirectToErrorPage($session, $errorCode = null) { @@ -422,8 +424,8 @@ class Helper { /** * @brief glob uses different pattern than regular expressions, escape glob pattern only - * @param unescaped path - * @return escaped path + * @param string $path unescaped path + * @return string path */ public static function escapeGlobPattern($path) { return preg_replace('/(\*|\?|\[)/', '[$1]', $path); @@ -441,7 +443,7 @@ class Helper { /** * @brief get the path of the original file * @param string $tmpFile path of the tmp file - * @return mixed path of the original file or false + * @return string|false path of the original file or false */ public static function getPathFromTmpFile($tmpFile) { if (isset(self::$tmpFileMapping[$tmpFile])) { diff --git a/apps/files_encryption/lib/keymanager.php b/apps/files_encryption/lib/keymanager.php index 7abc565f609..cb9f5e64af3 100755 --- a/apps/files_encryption/lib/keymanager.php +++ b/apps/files_encryption/lib/keymanager.php @@ -170,7 +170,7 @@ class Keymanager { * @brief retrieve keyfile for an encrypted file * @param \OC_FilesystemView $view * @param \OCA\Encryption\Util $util - * @param $filePath + * @param string|false $filePath * @internal param \OCA\Encryption\file $string name * @return string file key or false * @note The keyfile returned is asymmetrically encrypted. Decryption @@ -513,6 +513,8 @@ class Keymanager { /** * @brief Make preparations to vars and filesystem for saving a keyfile + * @param string|boolean $path + * @param string $basePath */ public static function keySetPreparation(\OC_FilesystemView $view, $path, $basePath, $userId) { @@ -542,7 +544,7 @@ class Keymanager { /** * @brief extract filename from share key name * @param string $shareKey (filename.userid.sharekey) - * @return mixed filename or false + * @return string|false filename or false */ protected static function getFilenameFromShareKey($shareKey) { $parts = explode('.', $shareKey); diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php index 11048005969..9d456f6c517 100644 --- a/apps/files_encryption/lib/proxy.php +++ b/apps/files_encryption/lib/proxy.php @@ -262,7 +262,7 @@ class Proxy extends \OC_FileProxy { } elseif ( self::shouldEncrypt($path) - and $meta ['mode'] !== 'r' + and $meta['mode'] !== 'r' and $meta['mode'] !== 'rb' ) { $result = fopen('crypt://' . $path, $meta['mode']); @@ -283,7 +283,7 @@ class Proxy extends \OC_FileProxy { public function postGetFileInfo($path, $data) { // if path is a folder do nothing - if (\OCP\App::isEnabled('files_encryption') && is_array($data) && array_key_exists('size', $data)) { + if (\OCP\App::isEnabled('files_encryption') && $data !== false && array_key_exists('size', $data)) { // Disable encryption proxy to prevent recursive calls $proxyStatus = \OC_FileProxy::$enabled; @@ -341,7 +341,7 @@ class Proxy extends \OC_FileProxy { } // if file is encrypted return real file size - if (is_array($fileInfo) && $fileInfo['encrypted'] === true) { + if ($fileInfo && $fileInfo['encrypted'] === true) { // try to fix unencrypted file size if it doesn't look plausible if ((int)$fileInfo['size'] > 0 && (int)$fileInfo['unencrypted_size'] === 0 ) { $fixSize = $util->getFileSize($path); @@ -354,7 +354,7 @@ class Proxy extends \OC_FileProxy { $size = $fileInfo['unencrypted_size']; } else { // self healing if file was removed from file cache - if (!is_array($fileInfo)) { + if (!$fileInfo) { $fileInfo = array(); } diff --git a/apps/files_encryption/lib/session.php b/apps/files_encryption/lib/session.php index 25f2198181f..aa58e33e9d2 100644 --- a/apps/files_encryption/lib/session.php +++ b/apps/files_encryption/lib/session.php @@ -51,11 +51,13 @@ class Session { } - $publicShareKeyId = \OC_Appconfig::getValue('files_encryption', 'publicShareKeyId'); + $appConfig = \OC::$server->getAppConfig(); + + $publicShareKeyId = $appConfig->getValue('files_encryption', 'publicShareKeyId'); if ($publicShareKeyId === null) { $publicShareKeyId = 'pubShare_' . substr(md5(time()), 0, 8); - \OC_Appconfig::setValue('files_encryption', 'publicShareKeyId', $publicShareKeyId); + $appConfig->setValue('files_encryption', 'publicShareKeyId', $publicShareKeyId); } if ( @@ -195,7 +197,7 @@ class Session { /** * @brief Sets user legacy key to session - * @param $legacyKey + * @param string $legacyKey * @return bool */ public function setLegacyKey($legacyKey) { diff --git a/apps/files_encryption/lib/stream.php b/apps/files_encryption/lib/stream.php index b3bf34ddb82..88eacc6f136 100644 --- a/apps/files_encryption/lib/stream.php +++ b/apps/files_encryption/lib/stream.php @@ -567,7 +567,7 @@ class Stream { // get file info $fileInfo = $this->rootView->getFileInfo($path); - if (is_array($fileInfo)) { + if ($fileInfo) { // set encryption data $fileInfo['encrypted'] = true; $fileInfo['size'] = $this->size; diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index ae3e2a2e15a..ec06bd52f5e 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -63,8 +63,10 @@ class Util { $this->client = $client; $this->userId = $userId; - $this->publicShareKeyId = \OC_Appconfig::getValue('files_encryption', 'publicShareKeyId'); - $this->recoveryKeyId = \OC_Appconfig::getValue('files_encryption', 'recoveryKeyId'); + $appConfig = \OC::$server->getAppConfig(); + + $this->publicShareKeyId = $appConfig->getValue('files_encryption', 'publicShareKeyId'); + $this->recoveryKeyId = $appConfig->getValue('files_encryption', 'recoveryKeyId'); $this->userDir = '/' . $this->userId; $this->fileFolderName = 'files'; @@ -316,7 +318,8 @@ class Util { $found = array( 'plain' => array(), 'encrypted' => array(), - 'legacy' => array() + 'legacy' => array(), + 'broken' => array(), ); } @@ -327,10 +330,7 @@ class Util { if(is_resource($handle)) { while (false !== ($file = readdir($handle))) { - if ( - $file !== "." - && $file !== ".." - ) { + if ($file !== "." && $file !== "..") { $filePath = $directory . '/' . $this->view->getRelativePath('/' . $file); $relPath = \OCA\Encryption\Helper::stripUserFilesPath($filePath); @@ -357,15 +357,23 @@ class Util { // NOTE: This is inefficient; // scanning every file like this // will eat server resources :( - if ( - Keymanager::getFileKey($this->view, $this, $relPath) - && $isEncryptedPath - ) { - - $found['encrypted'][] = array( - 'name' => $file, - 'path' => $filePath - ); + if ($isEncryptedPath) { + + $fileKey = Keymanager::getFileKey($this->view, $this, $relPath); + $shareKey = Keymanager::getShareKey($this->view, $this->userId, $this, $relPath); + // if file is encrypted but now file key is available, throw exception + if ($fileKey === false || $shareKey === false) { + \OCP\Util::writeLog('encryption library', 'No keys available to decrypt the file: ' . $filePath, \OCP\Util::ERROR); + $found['broken'][] = array( + 'name' => $file, + 'path' => $filePath, + ); + } else { + $found['encrypted'][] = array( + 'name' => $file, + 'path' => $filePath, + ); + } // If the file uses old // encryption system @@ -563,7 +571,7 @@ class Util { /** - * @param $path + * @param string $path * @return bool */ public function isSharedPath($path) { @@ -771,6 +779,12 @@ class Util { $successful = false; } + // if there are broken encrypted files than the complete decryption + // was not successful + if (!empty($found['broken'])) { + $successful = false; + } + if ($successful) { $this->view->deleteAll($this->keyfilesPath); $this->view->deleteAll($this->shareKeysPath); @@ -1031,7 +1045,7 @@ class Util { * @brief Decrypt a keyfile * @param string $filePath * @param string $privateKey - * @return bool|string + * @return false|string */ private function decryptKeyfile($filePath, $privateKey) { @@ -1110,12 +1124,15 @@ class Util { /** * @brief Find, sanitise and format users sharing a file * @note This wraps other methods into a portable bundle + * @param boolean $sharingEnabled */ public function getSharingUsersArray($sharingEnabled, $filePath, $currentUserId = false) { + $appConfig = \OC::$server->getAppConfig(); + // Check if key recovery is enabled if ( - \OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled') + $appConfig->getValue('files_encryption', 'recoveryAdminEnabled') && $this->recoveryEnabledForUser() ) { $recoveryEnabled = true; @@ -1144,7 +1161,7 @@ class Util { // Admin UID to list of users to share to if ($recoveryEnabled) { // Find recoveryAdmin user ID - $recoveryKeyId = \OC_Appconfig::getValue('files_encryption', 'recoveryKeyId'); + $recoveryKeyId = $appConfig->getValue('files_encryption', 'recoveryKeyId'); // Add recoveryAdmin to list of users sharing $userIds[] = $recoveryKeyId; } @@ -1186,26 +1203,48 @@ class Util { } /** - * @brief start migration mode to initially encrypt users data + * @brief set migration status + * @param int $status * @return boolean */ - public function beginMigration() { - - $return = false; + private function setMigrationStatus($status) { - $sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ? and `migration_status` = ?'; - $args = array(self::MIGRATION_IN_PROGRESS, $this->userId, self::MIGRATION_OPEN); + $sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ?'; + $args = array($status, $this->userId); $query = \OCP\DB::prepare($sql); $manipulatedRows = $query->execute($args); if ($manipulatedRows === 1) { - $return = true; + $result = true; + \OCP\Util::writeLog('Encryption library', "Migration status set to " . self::MIGRATION_OPEN, \OCP\Util::INFO); + } else { + $result = false; + \OCP\Util::writeLog('Encryption library', "Could not set migration status to " . self::MIGRATION_OPEN, \OCP\Util::WARN); + } + + return $result; + } + + /** + * @brief start migration mode to initially encrypt users data + * @return boolean + */ + public function beginMigration() { + + $result = $this->setMigrationStatus(self::MIGRATION_IN_PROGRESS); + + if ($result) { \OCP\Util::writeLog('Encryption library', "Start migration to encryption mode for " . $this->userId, \OCP\Util::INFO); } else { \OCP\Util::writeLog('Encryption library', "Could not activate migration mode for " . $this->userId . ". Probably another process already started the initial encryption", \OCP\Util::WARN); } - return $return; + return $result; + } + + public function resetMigrationStatus() { + return $this->setMigrationStatus(self::MIGRATION_OPEN); + } /** @@ -1213,22 +1252,15 @@ class Util { * @return boolean */ public function finishMigration() { + $result = $this->setMigrationStatus(self::MIGRATION_COMPLETED); - $return = false; - - $sql = 'UPDATE `*PREFIX*encryption` SET `migration_status` = ? WHERE `uid` = ? and `migration_status` = ?'; - $args = array(self::MIGRATION_COMPLETED, $this->userId, self::MIGRATION_IN_PROGRESS); - $query = \OCP\DB::prepare($sql); - $manipulatedRows = $query->execute($args); - - if ($manipulatedRows === 1) { - $return = true; + if ($result) { \OCP\Util::writeLog('Encryption library', "Finish migration successfully for " . $this->userId, \OCP\Util::INFO); } else { \OCP\Util::writeLog('Encryption library', "Could not deactivate migration mode for " . $this->userId, \OCP\Util::WARN); } - return $return; + return $result; } /** diff --git a/apps/files_encryption/settings-admin.php b/apps/files_encryption/settings-admin.php index 9ad9bfb8877..88e06613997 100644 --- a/apps/files_encryption/settings-admin.php +++ b/apps/files_encryption/settings-admin.php @@ -11,7 +11,7 @@ $tmpl = new OCP\Template('files_encryption', 'settings-admin'); // Check if an adminRecovery account is enabled for recovering files after lost pwd -$recoveryAdminEnabled = OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled', '0'); +$recoveryAdminEnabled = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled', '0'); $tmpl->assign('recoveryEnabled', $recoveryAdminEnabled); diff --git a/apps/files_encryption/settings-personal.php b/apps/files_encryption/settings-personal.php index ffcb99602e2..09e9df05352 100644 --- a/apps/files_encryption/settings-personal.php +++ b/apps/files_encryption/settings-personal.php @@ -20,7 +20,7 @@ $privateKeySet = $session->getPrivateKey() !== false; // did we tried to initialize the keys for this session?
$initialized = $session->getInitialized();
-$recoveryAdminEnabled = OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled');
+$recoveryAdminEnabled = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled');
$recoveryEnabledForUser = $util->recoveryEnabledForUser();
$result = false;
diff --git a/apps/files_encryption/tests/crypt.php b/apps/files_encryption/tests/crypt.php index 388980ad4fd..123943ea26a 100755 --- a/apps/files_encryption/tests/crypt.php +++ b/apps/files_encryption/tests/crypt.php @@ -661,7 +661,7 @@ class Test_Encryption_Crypt extends \PHPUnit_Framework_TestCase { /** * @brief encryption using legacy blowfish method - * @param $data string data to encrypt + * @param string $data data to encrypt * @param $passwd string password * @return string */ diff --git a/apps/files_encryption/tests/hooks.php b/apps/files_encryption/tests/hooks.php index 44525791743..7d926caea1b 100644 --- a/apps/files_encryption/tests/hooks.php +++ b/apps/files_encryption/tests/hooks.php @@ -203,7 +203,7 @@ class Test_Encryption_Hooks extends \PHPUnit_Framework_TestCase { $fileInfo = $this->user1View->getFileInfo($this->filename); // check if we have a valid file info - $this->assertTrue(is_array($fileInfo)); + $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // share the file with user2 \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_ENCRYPTION_HOOKS_USER2, OCP\PERMISSION_ALL); diff --git a/apps/files_encryption/tests/keymanager.php b/apps/files_encryption/tests/keymanager.php index 6f32c50743c..0caf12e91a3 100644 --- a/apps/files_encryption/tests/keymanager.php +++ b/apps/files_encryption/tests/keymanager.php @@ -250,6 +250,10 @@ class Test_Encryption_Keymanager extends \PHPUnit_Framework_TestCase { * dummy class to access protected methods of \OCA\Encryption\Keymanager for testing */ class TestProtectedKeymanagerMethods extends \OCA\Encryption\Keymanager { + + /** + * @param string $sharekey + */ public static function testGetFilenameFromShareKey($sharekey) { return self::getFilenameFromShareKey($sharekey); } diff --git a/apps/files_encryption/tests/share.php b/apps/files_encryption/tests/share.php index acf408a07f0..46a21dd55cd 100755 --- a/apps/files_encryption/tests/share.php +++ b/apps/files_encryption/tests/share.php @@ -61,7 +61,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { \OC_User::useBackend('database'); // enable resharing - \OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes'); + \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes'); // clear share hooks \OC_Hook::clear('OCP\\Share'); @@ -150,7 +150,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info - $this->assertTrue(is_array($fileInfo)); + $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // check if the unencrypted file size is stored $this->assertGreaterThan(0, $fileInfo['unencrypted_size']); @@ -310,7 +310,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files' . $this->folder1); // check if we have a valid file info - $this->assertTrue(is_array($fileInfo)); + $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // re-enable the file proxy \OC_FileProxy::$enabled = $proxyStatus; @@ -388,7 +388,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { . $this->subfolder); // check if we have a valid file info - $this->assertTrue(is_array($fileInfoSubFolder)); + $this->assertTrue($fileInfoSubFolder instanceof \OC\Files\FileInfo); // re-enable the file proxy \OC_FileProxy::$enabled = $proxyStatus; @@ -422,7 +422,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { . $this->subsubfolder . '/' . $this->filename); // check if we have fileInfos - $this->assertTrue(is_array($fileInfo)); + $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // share the file with user3 \OCP\Share::shareItem('file', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, OCP\PERMISSION_ALL); @@ -517,7 +517,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info - $this->assertTrue(is_array($fileInfo)); + $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // check if the unencrypted file size is stored $this->assertGreaterThan(0, $fileInfo['unencrypted_size']); @@ -531,7 +531,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { // login as admin \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); - $publicShareKeyId = \OC_Appconfig::getValue('files_encryption', 'publicShareKeyId'); + $publicShareKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'publicShareKeyId'); // check if share key for public exists $this->assertTrue($this->view->file_exists( @@ -595,7 +595,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info - $this->assertTrue(is_array($fileInfo)); + $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // check if the unencrypted file size is stored $this->assertGreaterThan(0, $fileInfo['unencrypted_size']); @@ -662,7 +662,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); \OCA\Encryption\Helper::adminEnableRecovery(null, 'test123'); - $recoveryKeyId = OC_Appconfig::getValue('files_encryption', 'recoveryKeyId'); + $recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId'); // login as admin \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1); @@ -755,7 +755,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { $this->assertTrue(\OCA\Encryption\Helper::adminEnableRecovery(null, 'test123')); $this->assertTrue(\OCA\Encryption\Helper::adminDisableRecovery('test123')); - $this->assertEquals(0, \OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled')); + $this->assertEquals(0, \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled')); } /** @@ -769,7 +769,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { $result = \OCA\Encryption\Helper::adminEnableRecovery(null, 'test123'); $this->assertTrue($result); - $recoveryKeyId = OC_Appconfig::getValue('files_encryption', 'recoveryKeyId'); + $recoveryKeyId = \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryKeyId'); // login as user2 \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2); @@ -863,7 +863,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { $this->assertTrue($util->setRecoveryForUser(0)); \OCA\Encryption\Helper::adminDisableRecovery('test123'); - $this->assertEquals(0, \OC_Appconfig::getValue('files_encryption', 'recoveryAdminEnabled')); + $this->assertEquals(0, \OC::$server->getAppConfig()->getValue('files_encryption', 'recoveryAdminEnabled')); } /** @@ -888,7 +888,7 @@ class Test_Encryption_Share extends \PHPUnit_Framework_TestCase { '/' . \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1 . '/files/' . $this->filename); // check if we have a valid file info - $this->assertTrue(is_array($fileInfo)); + $this->assertTrue($fileInfo instanceof \OC\Files\FileInfo); // check if the unencrypted file size is stored $this->assertGreaterThan(0, $fileInfo['unencrypted_size']); diff --git a/apps/files_encryption/tests/util.php b/apps/files_encryption/tests/util.php index 97e3c518dac..f70e30c4d73 100755 --- a/apps/files_encryption/tests/util.php +++ b/apps/files_encryption/tests/util.php @@ -64,6 +64,8 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { function setUp() { + // login user + \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1); \OC_User::setUserId(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1); $this->userId = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1; $this->pass = \Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1; @@ -328,7 +330,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { $fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); - $this->assertTrue(is_array($fileInfoUnencrypted)); + $this->assertTrue($fileInfoUnencrypted instanceof \OC\Files\FileInfo); // enable file encryption again \OC_App::enable('files_encryption'); @@ -338,7 +340,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { $fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); - $this->assertTrue(is_array($fileInfoEncrypted)); + $this->assertTrue($fileInfoEncrypted instanceof \OC\Files\FileInfo); // check if mtime and etags unchanged $this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']); @@ -357,23 +359,98 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { $fileInfoEncrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); - $this->assertTrue(is_array($fileInfoEncrypted)); + $this->assertTrue($fileInfoEncrypted instanceof \OC\Files\FileInfo); + $this->assertEquals($fileInfoEncrypted['encrypted'], 1); - // encrypt all unencrypted files - $util->decryptAll('/' . $this->userId . '/' . 'files'); + // decrypt all encrypted files + $result = $util->decryptAll('/' . $this->userId . '/' . 'files'); + + $this->assertTrue($result); $fileInfoUnencrypted = $this->view->getFileInfo($this->userId . '/files/' . $filename); - $this->assertTrue(is_array($fileInfoUnencrypted)); + $this->assertTrue($fileInfoUnencrypted instanceof \OC\Files\FileInfo); // check if mtime and etags unchanged $this->assertEquals($fileInfoEncrypted['mtime'], $fileInfoUnencrypted['mtime']); $this->assertEquals($fileInfoEncrypted['etag'], $fileInfoUnencrypted['etag']); + // file should no longer be encrypted + $this->assertEquals(0, $fileInfoUnencrypted['encrypted']); $this->view->unlink($this->userId . '/files/' . $filename); } + function testDescryptAllWithBrokenFiles() { + + $file1 = "/decryptAll1" . uniqid() . ".txt"; + $file2 = "/decryptAll2" . uniqid() . ".txt"; + + $util = new Encryption\Util($this->view, $this->userId); + + $this->view->file_put_contents($this->userId . '/files/' . $file1, $this->dataShort); + $this->view->file_put_contents($this->userId . '/files/' . $file2, $this->dataShort); + + $fileInfoEncrypted1 = $this->view->getFileInfo($this->userId . '/files/' . $file1); + $fileInfoEncrypted2 = $this->view->getFileInfo($this->userId . '/files/' . $file2); + + $this->assertTrue($fileInfoEncrypted1 instanceof \OC\Files\FileInfo); + $this->assertTrue($fileInfoEncrypted2 instanceof \OC\Files\FileInfo); + $this->assertEquals($fileInfoEncrypted1['encrypted'], 1); + $this->assertEquals($fileInfoEncrypted2['encrypted'], 1); + + // rename keyfile for file1 so that the decryption for file1 fails + // Expected behaviour: decryptAll() returns false, file2 gets decrypted anyway + $this->view->rename($this->userId . '/files_encryption/keyfiles/' . $file1 . '.key', + $this->userId . '/files_encryption/keyfiles/' . $file1 . '.key.moved'); + + // decrypt all encrypted files + $result = $util->decryptAll('/' . $this->userId . '/' . 'files'); + + $this->assertFalse($result); + + $fileInfoUnencrypted1 = $this->view->getFileInfo($this->userId . '/files/' . $file1); + $fileInfoUnencrypted2 = $this->view->getFileInfo($this->userId . '/files/' . $file2); + + $this->assertTrue($fileInfoUnencrypted1 instanceof \OC\Files\FileInfo); + $this->assertTrue($fileInfoUnencrypted2 instanceof \OC\Files\FileInfo); + + // file1 should be still encrypted; file2 should be decrypted + $this->assertEquals(1, $fileInfoUnencrypted1['encrypted']); + $this->assertEquals(0, $fileInfoUnencrypted2['encrypted']); + + // keyfiles and share keys should still exist + $this->assertTrue($this->view->is_dir($this->userId . '/files_encryption/keyfiles/')); + $this->assertTrue($this->view->is_dir($this->userId . '/files_encryption/share-keys/')); + + // rename the keyfile for file1 back + $this->view->rename($this->userId . '/files_encryption/keyfiles/' . $file1 . '.key.moved', + $this->userId . '/files_encryption/keyfiles/' . $file1 . '.key'); + + // try again to decrypt all encrypted files + $result = $util->decryptAll('/' . $this->userId . '/' . 'files'); + + $this->assertTrue($result); + + $fileInfoUnencrypted1 = $this->view->getFileInfo($this->userId . '/files/' . $file1); + $fileInfoUnencrypted2 = $this->view->getFileInfo($this->userId . '/files/' . $file2); + + $this->assertTrue($fileInfoUnencrypted1 instanceof \OC\Files\FileInfo); + $this->assertTrue($fileInfoUnencrypted2 instanceof \OC\Files\FileInfo); + + // now both files should be decrypted + $this->assertEquals(0, $fileInfoUnencrypted1['encrypted']); + $this->assertEquals(0, $fileInfoUnencrypted2['encrypted']); + + // keyfiles and share keys should be deleted + $this->assertFalse($this->view->is_dir($this->userId . '/files_encryption/keyfiles/')); + $this->assertFalse($this->view->is_dir($this->userId . '/files_encryption/share-keys/')); + + $this->view->unlink($this->userId . '/files/' . $file1); + $this->view->unlink($this->userId . '/files/' . $file2); + + } + /** * @large */ @@ -461,7 +538,7 @@ class Test_Encryption_Util extends \PHPUnit_Framework_TestCase { * helper function to set migration status to the right value * to be able to test the migration path * - * @param $status needed migration status for test + * @param integer $status needed migration status for test * @param $user for which user the status should be set * @return boolean */ diff --git a/apps/files_external/lib/amazons3.php b/apps/files_external/lib/amazons3.php index 00baacd488c..06ccd5d16fa 100644 --- a/apps/files_external/lib/amazons3.php +++ b/apps/files_external/lib/amazons3.php @@ -54,6 +54,9 @@ class AmazonS3 extends \OC\Files\Storage\Common { */ private $timeout = 15; + /** + * @param string $path + */ private function normalizePath($path) { $path = trim($path, '/'); diff --git a/apps/files_external/lib/config.php b/apps/files_external/lib/config.php index 8c85c5fbde8..94dc5fb7ad8 100755 --- a/apps/files_external/lib/config.php +++ b/apps/files_external/lib/config.php @@ -35,7 +35,7 @@ class OC_Mount_Config { * If the configuration parameter is a boolean, add a '!' to the beginning of the value * If the configuration parameter is optional, add a '&' to the beginning of the value * If the configuration parameter is hidden, add a '#' to the beginning of the value - * @return array + * @return string */ public static function getBackends() { @@ -263,13 +263,13 @@ class OC_Mount_Config { /** * Add a mount point to the filesystem - * @param string Mount point - * @param string Backend class + * @param string $mountPoint Mount point + * @param string $class Backend class * @param array Backend parameters for the class - * @param string MOUNT_TYPE_GROUP | MOUNT_TYPE_USER - * @param string User or group to apply mount to + * @param string $mountType MOUNT_TYPE_GROUP | MOUNT_TYPE_USER + * @param string $applicable User or group to apply mount to * @param bool Personal or system mount point i.e. is this being called from the personal or admin page - * @return bool + * @return boolean */ public static function addMountPoint($mountPoint, $class, @@ -343,7 +343,7 @@ class OC_Mount_Config { /** * Read the mount points in the config file into an array - * @param bool Personal or system config file + * @param boolean $isPersonal Personal or system config file * @return array */ private static function readData($isPersonal) { @@ -374,6 +374,7 @@ class OC_Mount_Config { * Write the mount points to the config file * @param bool Personal or system config file * @param array Mount points + * @param boolean $isPersonal */ private static function writeData($isPersonal, $data) { if ($isPersonal) { diff --git a/apps/files_external/lib/dropbox.php b/apps/files_external/lib/dropbox.php index f7d8d98cf03..0214e18020c 100755 --- a/apps/files_external/lib/dropbox.php +++ b/apps/files_external/lib/dropbox.php @@ -50,6 +50,9 @@ class Dropbox extends \OC\Files\Storage\Common { } } + /** + * @param string $path + */ private function deleteMetaData($path) { $path = $this->root.$path; if (isset($this->metaData[$path])) { @@ -61,7 +64,7 @@ class Dropbox extends \OC\Files\Storage\Common { /** * @brief Returns the path's metadata - * @param $path path for which to return the metadata + * @param string $path path for which to return the metadata * @param $list if true, also return the directory's contents * @return directory contents if $list is true, file metadata if $list is * false, null if the file doesn't exist or "false" if the operation failed diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php index 426caf008ec..35457f68528 100644 --- a/apps/files_external/lib/google.php +++ b/apps/files_external/lib/google.php @@ -67,7 +67,7 @@ class Google extends \OC\Files\Storage\Common { /** * Get the Google_DriveFile object for the specified path * @param string $path - * @return Google_DriveFile + * @return string */ private function getDriveFile($path) { // Remove leading and trailing slashes @@ -524,6 +524,7 @@ class Google extends \OC\Files\Storage\Common { } public function hasUpdated($path, $time) { + $appConfig = \OC::$server->getAppConfig(); if ($this->is_file($path)) { return parent::hasUpdated($path, $time); } else { @@ -533,7 +534,7 @@ class Google extends \OC\Files\Storage\Common { if ($folder) { $result = false; $folderId = $folder->getId(); - $startChangeId = \OC_Appconfig::getValue('files_external', $this->getId().'cId'); + $startChangeId = $appConfig->getValue('files_external', $this->getId().'cId'); $params = array( 'includeDeleted' => true, 'includeSubscribed' => true, @@ -578,7 +579,7 @@ class Google extends \OC\Files\Storage\Common { break; } } - \OC_Appconfig::setValue('files_external', $this->getId().'cId', $largestChangeId); + $appConfig->setValue('files_external', $this->getId().'cId', $largestChangeId); return $result; } } diff --git a/apps/files_external/lib/irods.php b/apps/files_external/lib/irods.php index 6d4f66e856e..7a7e900fbf0 100644 --- a/apps/files_external/lib/irods.php +++ b/apps/files_external/lib/irods.php @@ -134,6 +134,7 @@ class iRODS extends \OC\Files\Storage\StreamWrapper{ /** * get the best guess for the modification time of an iRODS collection + * @param string $path */ private function collectionMTime($path) { $dh = $this->opendir($path); diff --git a/apps/files_external/lib/sftp.php b/apps/files_external/lib/sftp.php index cd8a0e78864..a0816e2870d 100644 --- a/apps/files_external/lib/sftp.php +++ b/apps/files_external/lib/sftp.php @@ -75,6 +75,9 @@ class SFTP extends \OC\Files\Storage\Common { return 'sftp::' . $this->user . '@' . $this->host . '/' . $this->root; } + /** + * @param string $path + */ private function absPath($path) { return $this->root . $this->cleanPath($path); } @@ -277,6 +280,9 @@ class SFTP extends \OC\Files\Storage\Common { } } + /** + * @param string $path + */ public function constructUrl($path) { $url = 'sftp://'.$this->user.':'.$this->password.'@'.$this->host.$this->root.$path; return $url; diff --git a/apps/files_external/lib/streamwrapper.php b/apps/files_external/lib/streamwrapper.php index e484325e2fb..44bd9a0161a 100644 --- a/apps/files_external/lib/streamwrapper.php +++ b/apps/files_external/lib/streamwrapper.php @@ -9,6 +9,11 @@ namespace OC\Files\Storage; abstract class StreamWrapper extends Common { + + /** + * @param string $path + * @return string|null + */ abstract public function constructUrl($path); public function mkdir($path) { @@ -76,10 +81,17 @@ abstract class StreamWrapper extends Common { } } + /** + * @param string $path + * @param string $target + */ public function getFile($path, $target) { return copy($this->constructUrl($path), $target); } + /** + * @param string $target + */ public function uploadFile($path, $target) { return copy($path, $this->constructUrl($target)); } diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php index b615d24ce76..7a56fcfc8b7 100644 --- a/apps/files_external/lib/swift.php +++ b/apps/files_external/lib/swift.php @@ -52,6 +52,9 @@ class Swift extends \OC\Files\Storage\Common { */ private static $tmpFiles = array(); + /** + * @param string $path + */ private function normalizePath($path) { $path = trim($path, '/'); @@ -62,6 +65,9 @@ class Swift extends \OC\Files\Storage\Common { return $path; } + /** + * @param string $path + */ private function doesObjectExist($path) { try { $object = $this->container->DataObject($path); diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php index f6f4cb16e87..7611316a26a 100644 --- a/apps/files_external/lib/webdav.php +++ b/apps/files_external/lib/webdav.php @@ -247,6 +247,10 @@ class DAV extends \OC\Files\Storage\Common{ return true; } + /** + * @param string $path + * @param string $target + */ public function getFile($path, $target) { $this->init(); $source=$this->fopen($path, 'r'); @@ -332,12 +336,20 @@ class DAV extends \OC\Files\Storage\Common{ } } + /** + * @param string $path + */ public function cleanPath($path) { $path = \OC\Files\Filesystem::normalizePath($path); // remove leading slash return substr($path, 1); } + /** + * @param string $method + * @param string $path + * @param integer $expected + */ private function simpleResponse($method, $path, $body, $expected) { $path=$this->cleanPath($path); try { diff --git a/apps/files_sharing/ajax/publicpreview.php b/apps/files_sharing/ajax/publicpreview.php index a52f522afac..d12d212a2e6 100644 --- a/apps/files_sharing/ajax/publicpreview.php +++ b/apps/files_sharing/ajax/publicpreview.php @@ -11,7 +11,7 @@ if(!\OC_App::isEnabled('files_sharing')){ \OC_User::setIncognitoMode(true); -$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; +$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : ''; $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36'; $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36'; $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; diff --git a/apps/files_sharing/css/public.css b/apps/files_sharing/css/public.css index 21f0c82b829..5246a4b2fec 100644 --- a/apps/files_sharing/css/public.css +++ b/apps/files_sharing/css/public.css @@ -66,7 +66,8 @@ p.info a { margin:0 auto; } -#imgframe img { +#imgframe img, +#imgframe video { max-height:100%; max-width:100%; } @@ -76,6 +77,8 @@ p.info a { margin-top: 10%; } + + thead { padding-left: 0 !important; /* fixes multiselect bar offset on shared page */ } diff --git a/apps/files_sharing/lib/api.php b/apps/files_sharing/lib/api.php index 061e60ad8ed..19a2d22b068 100644 --- a/apps/files_sharing/lib/api.php +++ b/apps/files_sharing/lib/api.php @@ -218,7 +218,7 @@ class Api { //allow password protection $shareWith = isset($_POST['password']) ? $_POST['password'] : null; //check public link share - $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); + $publicUploadEnabled = \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_public_upload', 'yes'); if(isset($_POST['publicUpload']) && $publicUploadEnabled !== 'yes') { return new \OC_OCS_Result(null, 403, "public upload disabled by the administrator"); } @@ -317,7 +317,7 @@ class Api { $shareType = $share['share_type']; $permissions = isset($params['_put']['permissions']) ? (int)$params['_put']['permissions'] : null; - $publicUploadStatus = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); + $publicUploadStatus = \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_public_upload', 'yes'); $publicUploadEnabled = ($publicUploadStatus === 'yes') ? true : false; @@ -356,7 +356,7 @@ class Api { */ private static function updatePublicUpload($share, $params) { - $publicUploadEnabled = \OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes'); + $publicUploadEnabled = \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_public_upload', 'yes'); if($publicUploadEnabled !== 'yes') { return new \OC_OCS_Result(null, 403, "public upload disabled by the administrator"); } diff --git a/apps/files_sharing/lib/cache.php b/apps/files_sharing/lib/cache.php index 1b102f9e5f8..aadc54e4a7f 100644 --- a/apps/files_sharing/lib/cache.php +++ b/apps/files_sharing/lib/cache.php @@ -32,6 +32,9 @@ class Shared_Cache extends Cache { private $storage; private $files = array(); + /** + * @param \OC\Files\Storage\Shared $storage + */ public function __construct($storage) { $this->storage = $storage; } @@ -393,7 +396,7 @@ class Shared_Cache extends Cache { * use the one with the highest id gives the best result with the background scanner, since that is most * likely the folder where we stopped scanning previously * - * @return string|bool the path of the folder or false when no folder matched + * @return boolean the path of the folder or false when no folder matched */ public function getIncomplete() { return false; diff --git a/apps/files_sharing/lib/permissions.php b/apps/files_sharing/lib/permissions.php index 1dc53428a7f..31b7ac361ae 100644 --- a/apps/files_sharing/lib/permissions.php +++ b/apps/files_sharing/lib/permissions.php @@ -42,6 +42,10 @@ class Shared_Permissions extends Permissions { } } + /** + * @param integer $fileId + * @param string $user + */ private function getFile($fileId, $user) { if ($fileId == -1) { return \OCP\PERMISSION_READ; diff --git a/apps/files_sharing/lib/sharedstorage.php b/apps/files_sharing/lib/sharedstorage.php index afe5dffdebd..b922654e5ec 100644 --- a/apps/files_sharing/lib/sharedstorage.php +++ b/apps/files_sharing/lib/sharedstorage.php @@ -41,6 +41,7 @@ class Shared extends \OC\Files\Storage\Common { /** * @brief Get the source file path, permissions, and owner for a shared file * @param string Shared target file path + * @param string $target * @return Returns array with the keys path, permissions, and owner or false if not found */ public function getFile($target) { @@ -64,6 +65,7 @@ class Shared extends \OC\Files\Storage\Common { /** * @brief Get the source file path for a shared file * @param string Shared target file path + * @param string $target * @return string source file path or false if not found */ public function getSourcePath($target) { diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index f03ac7205a3..e7a5f5024b8 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -2,7 +2,9 @@ // Load other apps for file previews OC_App::loadApps(); -if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { +$appConfig = \OC::$server->getAppConfig(); + +if ($appConfig->getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') { header('HTTP/1.0 404 Not Found'); $tmpl = new OCP\Template('', '404', 'guest'); $tmpl->printPage(); @@ -151,7 +153,7 @@ if (isset($path)) { $tmpl->assign('dirToken', $linkItem['token']); $tmpl->assign('sharingToken', $token); $allowPublicUploadEnabled = (bool) ($linkItem['permissions'] & OCP\PERMISSION_CREATE); - if (OC_Appconfig::getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') { + if ($appConfig->getValue('core', 'shareapi_allow_public_upload', 'yes') === 'no') { $allowPublicUploadEnabled = false; } if ($linkItem['item_type'] !== 'folder') { diff --git a/apps/files_sharing/templates/public.php b/apps/files_sharing/templates/public.php index 3ddaf4446df..3eb84ce1672 100644 --- a/apps/files_sharing/templates/public.php +++ b/apps/files_sharing/templates/public.php @@ -35,7 +35,7 @@ <?php else: ?> <div id="imgframe"> <?php $size = \OC\Preview::isMimeSupported($_['mimetype']) ? 500 : 128 ?> - <img src="<?php p(OCP\Util::linkToRoute( 'core_ajax_public_preview', array('x' => $size, 'y' => $size, 'file' => urlencode($_['directory_path']), 't' => $_['dirToken']))); ?>" class="publicpreview"/> + <img src="<?php p(OCP\Util::linkToRoute( 'core_ajax_public_preview', array('x' => $size, 'y' => $size, 'file' => $_['directory_path'], 't' => $_['dirToken']))); ?>" class="publicpreview"/> </div> <?php endif; ?> <div class="directDownload"> diff --git a/apps/files_sharing/tests/watcher.php b/apps/files_sharing/tests/watcher.php index 1a9a54cbcf8..5ab716e829f 100644 --- a/apps/files_sharing/tests/watcher.php +++ b/apps/files_sharing/tests/watcher.php @@ -145,6 +145,7 @@ class Test_Files_Sharing_Watcher extends Test_Files_Sharing_Base { /** * Returns the sizes of the path and its parent dirs in a hash * where the key is the path and the value is the size. + * @param string $path */ function getOwnerDirSizes($path) { $result = array(); diff --git a/apps/files_trashbin/ajax/preview.php b/apps/files_trashbin/ajax/preview.php index 44738734b19..ce64d9ecc9f 100644 --- a/apps/files_trashbin/ajax/preview.php +++ b/apps/files_trashbin/ajax/preview.php @@ -11,7 +11,7 @@ if(!\OC_App::isEnabled('files_trashbin')){ exit; } -$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; +$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : ''; $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44'; $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44'; $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; diff --git a/apps/files_trashbin/lib/trashbin.php b/apps/files_trashbin/lib/trashbin.php index 7544980e071..bc77e9c1543 100644 --- a/apps/files_trashbin/lib/trashbin.php +++ b/apps/files_trashbin/lib/trashbin.php @@ -61,6 +61,11 @@ class Trashbin { } + /** + * @param string $owner + * @param integer $timestamp + * @param string $type + */ private static function copyFilesToOwner($sourcePath, $owner, $ownerPath, $timestamp, $type, $mime) { self::setUpTrash($owner); @@ -169,7 +174,7 @@ class Trashbin { * * @param $file_path path to original file * @param $filename of deleted file - * @param $timestamp when the file was deleted + * @param integer $timestamp when the file was deleted * * @return size of stored versions */ @@ -214,7 +219,7 @@ class Trashbin { * * @param $file_path path to original file * @param $filename of deleted file - * @param $timestamp when the file was deleted + * @param integer $timestamp when the file was deleted * * @return size of encryption keys */ @@ -406,7 +411,7 @@ class Trashbin { * @param \OC\Files\View $view file view * @param $file complete path to file * @param $filename name of file once it was deleted - * @param $uniqueFilename new file name to restore the file without overwriting existing files + * @param string $uniqueFilename new file name to restore the file without overwriting existing files * @param $location location if file * @param $timestamp deleteion time * @@ -460,7 +465,7 @@ class Trashbin { * @param \OC\Files\View $view * @param $file complete path to file * @param $filename name of file - * @param $uniqueFilename new file name to restore the file without overwriting existing files + * @param string $uniqueFilename new file name to restore the file without overwriting existing files * @param $location location of file * @param $timestamp deleteion time * @@ -621,6 +626,9 @@ class Trashbin { return $size; } + /** + * @param \OC\Files\View $view + */ private static function deleteVersions($view, $file, $filename, $timestamp) { $size = 0; if (\OCP\App::isEnabled('files_versions')) { @@ -643,6 +651,9 @@ class Trashbin { return $size; } + /** + * @param \OC\Files\View $view + */ private static function deleteEncryptionKeys($view, $file, $filename, $timestamp) { $size = 0; if (\OCP\App::isEnabled('files_encryption')) { @@ -713,7 +724,7 @@ class Trashbin { /** * calculate remaining free space for trash bin * - * @param $trashbinSize current size of the trash bin + * @param integer $trashbinSize current size of the trash bin * @return available free space for trash bin */ private static function calculateFreeSpace($trashbinSize) { @@ -722,7 +733,7 @@ class Trashbin { $quota = \OC_Preferences::getValue($user, 'files', 'quota'); $view = new \OC\Files\View('/' . $user); if ($quota === null || $quota === 'default') { - $quota = \OC_Appconfig::getValue('files', 'default_quota'); + $quota = \OC::$server->getAppConfig()->getValue('files', 'default_quota'); } if ($quota === null || $quota === 'none') { $quota = \OC\Files\Filesystem::free_space('/'); @@ -826,9 +837,9 @@ class Trashbin { /** * recursive copy to copy a whole directory * - * @param $source source path, relative to the users files directory - * @param $destination destination path relative to the users root directoy - * @param $view file view for the users root directory + * @param string $source source path, relative to the users files directory + * @param string $destination destination path relative to the users root directoy + * @param \OC\Files\View $view file view for the users root directory */ private static function copy_recursive($source, $destination, $view) { $size = 0; @@ -887,7 +898,7 @@ class Trashbin { * find unique extension for restored file if a file with the same name already exists * @param $location where the file should be restored * @param $filename name of the file - * @param $view filesystem view relative to users root directory + * @param \OC\Files\View $view filesystem view relative to users root directory * @return string with unique extension */ private static function getUniqueFilename($location, $filename, $view) { @@ -916,8 +927,8 @@ class Trashbin { /** * @brief get the size from a given root folder - * @param $view file view on the root folder - * @return size of the folder + * @param \OC\Files\View $view file view on the root folder + * @return integer size of the folder */ private static function calculateSize($view) { $root = \OCP\Config::getSystemValue('datadirectory') . $view->getAbsolutePath(''); @@ -996,6 +1007,6 @@ class Trashbin { } public static function preview_icon($path) { - return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 36, 'y' => 36, 'file' => urlencode($path) )); + return \OC_Helper::linkToRoute( 'core_ajax_trashbin_preview', array('x' => 36, 'y' => 36, 'file' => $path )); } } diff --git a/apps/files_versions/lib/versions.php b/apps/files_versions/lib/versions.php index 328ed4305f4..2bd9c15bae4 100644 --- a/apps/files_versions/lib/versions.php +++ b/apps/files_versions/lib/versions.php @@ -336,7 +336,7 @@ class Storage { * @brief deletes used space for files versions in db if user was deleted * * @param type $uid id of deleted user - * @return result of db delete operation + * @return \OC_DB_StatementWrapper of db delete operation */ public static function deleteUser($uid) { $query = \OC_DB::prepare('DELETE FROM `*PREFIX*files_versions` WHERE `user`=?'); @@ -372,7 +372,7 @@ class Storage { /** * @brief returns all stored file versions from a given user - * @param $uid id to the user + * @param string $uid id of the user * @return array with contains two arrays 'all' which contains all versions sorted by age and 'by_file' which contains all versions sorted by filename */ private static function getAllVersions($uid) { @@ -420,8 +420,8 @@ class Storage { /** * @brief get list of files we want to expire - * @param int $currentTime timestamp of current time * @param array $versions list of versions + * @param integer $time * @return array containing the list of to deleted versions and the size of them */ protected static function getExpireList($time, $versions) { @@ -487,7 +487,7 @@ class Storage { $softQuota = true; $quota = \OC_Preferences::getValue($uid, 'files', 'quota'); if ( $quota === null || $quota === 'default') { - $quota = \OC_Appconfig::getValue('files', 'default_quota'); + $quota = \OC::$server->getAppConfig()->getValue('files', 'default_quota'); } if ( $quota === null || $quota === 'none' ) { $quota = \OC\Files\Filesystem::free_space('/'); diff --git a/apps/files_versions/tests/versions.php b/apps/files_versions/tests/versions.php index 25490aa1a04..9f15b86d981 100644 --- a/apps/files_versions/tests/versions.php +++ b/apps/files_versions/tests/versions.php @@ -181,6 +181,9 @@ class Test_Files_Versioning extends \PHPUnit_Framework_TestCase { // extend the original class to make it possible to test protected methods class VersionStorageToTest extends \OCA\Files_Versions\Storage { + /** + * @param integer $time + */ public function callProtectedGetExpireList($time, $versions) { return self::getExpireList($time, $versions); diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php index b619f62f296..6795aecafee 100644 --- a/apps/user_ldap/lib/access.php +++ b/apps/user_ldap/lib/access.php @@ -107,8 +107,8 @@ class Access extends LDAPUtility { /** * @brief checks wether the given attribute`s valua is probably a DN - * @param $attr the attribute in question - * @return if so true, otherwise false + * @param string $attr the attribute in question + * @return boolean if so true, otherwise false */ private function resemblesDN($attr) { $resemblingAttributes = array( @@ -164,6 +164,7 @@ class Access extends LDAPUtility { /** * gives back the database table for the query + * @param boolean $isUser */ private function getMapTable($isUser) { if($isUser) { @@ -175,7 +176,7 @@ class Access extends LDAPUtility { /** * @brief returns the LDAP DN for the given internal ownCloud name of the group - * @param $name the ownCloud name in question + * @param string $name the ownCloud name in question * @returns string with the LDAP DN on success, otherwise false * * returns the LDAP DN for the given internal ownCloud name of the group @@ -211,7 +212,7 @@ class Access extends LDAPUtility { /** * @brief returns the LDAP DN for the given internal ownCloud name * @param $name the ownCloud name in question - * @param $isUser is it a user? otherwise group + * @param boolean $isUser is it a user? otherwise group * @returns string with the LDAP DN on success, otherwise false * * returns the LDAP DN for the given internal ownCloud name @@ -417,6 +418,9 @@ class Access extends LDAPUtility { } + /** + * @param boolean $isUsers + */ private function ldap2ownCloudNames($ldapObjects, $isUsers) { if($isUsers) { $nameAttribute = $this->connection->ldapUserDisplayName; @@ -509,7 +513,7 @@ class Access extends LDAPUtility { /** * @brief creates a unique name for internal ownCloud use. * @param $name the display name of the object - * @param $isUser boolean, whether name should be created for a user (true) or a group (false) + * @param boolean $isUser whether name should be created for a user (true) or a group (false) * @returns string with with the name to use in ownCloud or false if unsuccessful */ private function createAltInternalOwnCloudName($name, $isUser) { @@ -545,6 +549,9 @@ class Access extends LDAPUtility { return $this->mappedComponents(true); } + /** + * @param boolean $isUsers + */ private function mappedComponents($isUsers) { $table = $this->getMapTable($isUsers); @@ -601,14 +608,26 @@ class Access extends LDAPUtility { return true; } + /** + * @param integer $limit + * @param integer $offset + */ public function fetchListOfUsers($filter, $attr, $limit = null, $offset = null) { return $this->fetchList($this->searchUsers($filter, $attr, $limit, $offset), (count($attr) > 1)); } + /** + * @param string $filter + * @param integer $limit + * @param integer $offset + */ public function fetchListOfGroups($filter, $attr, $limit = null, $offset = null) { return $this->fetchList($this->searchGroups($filter, $attr, $limit, $offset), (count($attr) > 1)); } + /** + * @param boolean $manyAttributes + */ private function fetchList($list, $manyAttributes) { if(is_array($list)) { if($manyAttributes) { @@ -626,6 +645,8 @@ class Access extends LDAPUtility { * @brief executes an LDAP search, optimized for Users * @param $filter the LDAP filter for the search * @param $attr optional, when a certain attribute shall be filtered out + * @param integer $limit + * @param integer $offset * @returns array with the search result * * Executes an LDAP search @@ -634,14 +655,19 @@ class Access extends LDAPUtility { return $this->search($filter, $this->connection->ldapBaseUsers, $attr, $limit, $offset); } + /** + * @param string $filter + */ public function countUsers($filter, $attr = array('dn'), $limit = null, $offset = null) { return $this->count($filter, $this->connection->ldapBaseGroups, $attr, $limit, $offset); } /** * @brief executes an LDAP search, optimized for Groups - * @param $filter the LDAP filter for the search + * @param string $filter the LDAP filter for the search * @param $attr optional, when a certain attribute shall be filtered out + * @param integer $limit + * @param integer $offset * @returns array with the search result * * Executes an LDAP search @@ -702,7 +728,7 @@ class Access extends LDAPUtility { * @param $limit maximum results to be counted * @param $offset a starting point * @param $pagedSearchOK whether a paged search has been executed - * @param $skipHandling required for paged search when cookies to + * @param boolean $skipHandling required for paged search when cookies to * prior results need to be gained * @returns array with the search result as first value and pagedSearchOK as * second | false if not successful @@ -736,7 +762,7 @@ class Access extends LDAPUtility { /** * @brief executes an LDAP search, but counts the results only - * @param $filter the LDAP filter for the search + * @param string $filter the LDAP filter for the search * @param $base an array containing the LDAP subtree(s) that shall be searched * @param $attr optional, array, one or more attributes that shall be * retrieved. Results will according to the order in the array. @@ -920,7 +946,7 @@ class Access extends LDAPUtility { /** * @brief combines the input filters with given operator * @param $filters array, the filters to connect - * @param $operator either & or | + * @param string $operator either & or | * @returns the combined filter * * Combines Filter arguments with AND @@ -985,6 +1011,9 @@ class Access extends LDAPUtility { return $this->combineFilterWithOr($filter); } + /** + * @param string $password + */ public function areCredentialsValid($name, $password) { $name = $this->DNasBaseParameter($name); $testConnection = clone $this->connection; @@ -1173,7 +1202,7 @@ class Access extends LDAPUtility { /** * @brief check wether the most recent paged search was successful. It flushed the state var. Use it always after a possible paged search. - * @return true on success, null or false otherwise + * @return boolean|null true on success, null or false otherwise */ public function getPagedSearchResultState() { $result = $this->pagedSearchedSuccessful; diff --git a/apps/user_ldap/lib/configuration.php b/apps/user_ldap/lib/configuration.php index 93f044e3152..954d0501fad 100644 --- a/apps/user_ldap/lib/configuration.php +++ b/apps/user_ldap/lib/configuration.php @@ -78,6 +78,9 @@ class Configuration { 'lastJpegPhotoLookup' => null, ); + /** + * @param string $configPrefix + */ public function __construct($configPrefix, $autoread = true) { $this->configPrefix = $configPrefix; if($autoread) { @@ -106,7 +109,7 @@ class Configuration { * @param $config array that holds the config parameters in an associated * array * @param &$applied optional; array where the set fields will be given to - * @return null + * @return false|null */ public function setConfiguration($config, &$applied = null) { if(!is_array($config)) { diff --git a/apps/user_ldap/lib/connection.php b/apps/user_ldap/lib/connection.php index 7fbabda7106..b2075748a3b 100644 --- a/apps/user_ldap/lib/connection.php +++ b/apps/user_ldap/lib/connection.php @@ -140,6 +140,9 @@ class Connection extends LDAPUtility { return $prefix.md5($key); } + /** + * @param string $key + */ public function getFromCache($key) { if(!$this->configured) { $this->readConfiguration(); @@ -156,6 +159,9 @@ class Connection extends LDAPUtility { return unserialize(base64_decode($this->cache->get($key))); } + /** + * @param string $key + */ public function isCached($key) { if(!$this->configured) { $this->readConfiguration(); @@ -167,6 +173,9 @@ class Connection extends LDAPUtility { return $this->cache->hasKey($key); } + /** + * @param string $key + */ public function writeToCache($key, $value) { if(!$this->configured) { $this->readConfiguration(); @@ -201,7 +210,7 @@ class Connection extends LDAPUtility { * @brief set LDAP configuration with values delivered by an array, not read from configuration * @param $config array that holds the config parameters in an associated array * @param &$setParameters optional; array where the set fields will be given to - * @return true if config validates, false otherwise. Check with $setParameters for detailed success on single parameters + * @return boolean true if config validates, false otherwise. Check with $setParameters for detailed success on single parameters */ public function setConfiguration($config, &$setParameters = null) { if(is_null($setParameters)) { diff --git a/apps/user_ldap/lib/ildapwrapper.php b/apps/user_ldap/lib/ildapwrapper.php index e60cf5ec63f..017d5549690 100644 --- a/apps/user_ldap/lib/ildapwrapper.php +++ b/apps/user_ldap/lib/ildapwrapper.php @@ -29,7 +29,7 @@ interface ILDAPWrapper { /** * @brief Bind to LDAP directory - * @param $link LDAP link resource + * @param resource $link LDAP link resource * @param $dn an RDN to log in with * @param $password the password * @return true on success, false otherwise @@ -50,7 +50,7 @@ interface ILDAPWrapper { * @brief Send LDAP pagination control * @param $link LDAP link resource * @param $pagesize number of results per page - * @param $isCritical Indicates whether the pagination is critical of not. + * @param boolean $isCritical Indicates whether the pagination is critical of not. * @param $cookie structure sent by LDAP server * @return true on success, false otherwise */ @@ -61,7 +61,7 @@ interface ILDAPWrapper { * @param $link LDAP link resource * @param $result LDAP result resource * @param $cookie structure sent by LDAP server - * @return true on success, false otherwise + * @return boolean on success, false otherwise * * Corresponds to ldap_control_paged_result_response */ @@ -124,7 +124,7 @@ interface ILDAPWrapper { /** * @brief Return next result id * @param $link LDAP link resource - * @param $result LDAP entry result resource + * @param resource $result LDAP entry result resource * @return an LDAP search result resource * */ public function nextEntry($link, $result); @@ -155,7 +155,7 @@ interface ILDAPWrapper { * @brief Sets the value of the specified option to be $value * @param $link LDAP link resource * @param $option a defined LDAP Server option - * @param $value the new value for the option + * @param integer $value the new value for the option * @return true on success, false otherwise */ public function setOption($link, $option, $value); @@ -177,7 +177,7 @@ interface ILDAPWrapper { /** * @brief Unbind from LDAP directory - * @param $link LDAP link resource + * @param resource $link LDAP link resource * @return true on success, false otherwise */ public function unbind($link); @@ -186,20 +186,20 @@ interface ILDAPWrapper { /** * @brief Checks whether the server supports LDAP - * @return true if it the case, false otherwise + * @return boolean if it the case, false otherwise * */ public function areLDAPFunctionsAvailable(); /** * @brief Checks whether PHP supports LDAP Paged Results - * @return true if it the case, false otherwise + * @return boolean if it the case, false otherwise * */ public function hasPagedResultSupport(); /** * @brief Checks whether the submitted parameter is a resource * @param $resource the resource variable to check - * @return true if it is a resource, false otherwise + * @return boolean if it is a resource, false otherwise */ public function isResource($resource); diff --git a/apps/user_ldap/lib/ldap.php b/apps/user_ldap/lib/ldap.php index a99c6480121..de9b7481c19 100644 --- a/apps/user_ldap/lib/ldap.php +++ b/apps/user_ldap/lib/ldap.php @@ -108,7 +108,7 @@ class LDAP implements ILDAPWrapper { /** * @brief Checks whether the server supports LDAP - * @return true if it the case, false otherwise + * @return boolean if it the case, false otherwise * */ public function areLDAPFunctionsAvailable() { return function_exists('ldap_connect'); @@ -116,7 +116,7 @@ class LDAP implements ILDAPWrapper { /** * @brief Checks whether PHP supports LDAP Paged Results - * @return true if it the case, false otherwise + * @return boolean if it the case, false otherwise * */ public function hasPagedResultSupport() { $hasSupport = function_exists('ldap_control_paged_result') @@ -127,7 +127,7 @@ class LDAP implements ILDAPWrapper { /** * @brief Checks whether the submitted parameter is a resource * @param $resource the resource variable to check - * @return true if it is a resource, false otherwise + * @return boolean if it is a resource, false otherwise */ public function isResource($resource) { return is_resource($resource); @@ -144,6 +144,9 @@ class LDAP implements ILDAPWrapper { } } + /** + * @param string $functionName + */ private function preFunctionCall($functionName, $args) { $this->curFunc = $functionName; $this->curArgs = $args; diff --git a/apps/user_ldap/lib/proxy.php b/apps/user_ldap/lib/proxy.php index 30e1875901c..b27233bcd19 100644 --- a/apps/user_ldap/lib/proxy.php +++ b/apps/user_ldap/lib/proxy.php @@ -54,13 +54,21 @@ abstract class Proxy { return 'group-'.$gid.'-lastSeenOn'; } + /** + * @param boolean $passOnWhen + * @param string $method + */ abstract protected function callOnLastSeenOn($id, $method, $parameters, $passOnWhen); + + /** + * @param string $method + */ abstract protected function walkBackends($id, $method, $parameters); /** * @brief Takes care of the request to the User backend * @param $uid string, the uid connected to the request - * @param $method string, the method of the user backend that shall be called + * @param string $method string, the method of the user backend that shall be called * @param $parameters an array of parameters to be passed * @return mixed, the result of the specified method */ @@ -80,6 +88,9 @@ abstract class Proxy { return $prefix.md5($key); } + /** + * @param string $key + */ public function getFromCache($key) { if(!$this->isCached($key)) { return null; @@ -89,11 +100,17 @@ abstract class Proxy { return unserialize(base64_decode($this->cache->get($key))); } + /** + * @param string $key + */ public function isCached($key) { $key = $this->getCacheKey($key); return $this->cache->hasKey($key); } + /** + * @param string $key + */ public function writeToCache($key, $value) { $key = $this->getCacheKey($key); $value = base64_encode(serialize($value)); diff --git a/apps/user_ldap/lib/wizard.php b/apps/user_ldap/lib/wizard.php index 00623b74fb1..e79090febc1 100644 --- a/apps/user_ldap/lib/wizard.php +++ b/apps/user_ldap/lib/wizard.php @@ -176,7 +176,7 @@ class Wizard extends LDAPUtility { /** * @brief return the state of the mode of the specified filter - * @param $confkey string, contains the access key of the Configuration + * @param string $confkey string, contains the access key of the Configuration */ private function getFilterMode($confkey) { $mode = $this->configuration->$confkey; @@ -240,6 +240,8 @@ class Wizard extends LDAPUtility { /** * @brief detects the available LDAP groups + * @param string $dbkey + * @param string $confkey * @returns the instance's WizardResult instance */ private function determineGroups($dbkey, $confkey, $testMemberOf = true) { @@ -554,7 +556,7 @@ class Wizard extends LDAPUtility { /** * @brief Checks whether for a given BaseDN results will be returned - * @param $base the BaseDN to test + * @param string $base the BaseDN to test * @return bool true on success, false otherwise */ private function testBaseDN($base) { @@ -619,7 +621,7 @@ class Wizard extends LDAPUtility { /** * @brief creates an LDAP Filter from given configuration - * @param $filterType int, for which use case the filter shall be created + * @param integer $filterType int, for which use case the filter shall be created * can be any of self::LFILTER_USER_LIST, self::LFILTER_LOGIN or * self::LFILTER_GROUP_LIST * @return mixed, string with the filter on success, false otherwise @@ -846,6 +848,9 @@ class Wizard extends LDAPUtility { || (empty($agent) && empty($pwd))); } + /** + * @param string[] $reqs + */ private function checkRequirements($reqs) { $this->checkAgentRequirements(); foreach($reqs as $option) { @@ -860,11 +865,11 @@ class Wizard extends LDAPUtility { /** * @brief does a cumulativeSearch on LDAP to get different values of a * specified attribute - * @param $filters array, the filters that shall be used in the search - * @param $attr the attribute of which a list of values shall be returned + * @param string[] $filters array, the filters that shall be used in the search + * @param string $attr the attribute of which a list of values shall be returned * @param $lfw bool, whether the last filter is a wildcard which shall not * be processed if there were already findings, defaults to true - * @param $maxF string. if not null, this variable will have the filter that + * @param string $maxF string. if not null, this variable will have the filter that * yields most result entries * @return mixed, an array with the values on success, false otherwise * @@ -926,10 +931,10 @@ class Wizard extends LDAPUtility { /** * @brief determines if and which $attr are available on the LDAP server - * @param $objectclasses the objectclasses to use as search filter - * @param $attr the attribute to look for - * @param $dbkey the dbkey of the setting the feature is connected to - * @param $confkey the confkey counterpart for the $dbkey as used in the + * @param string[] $objectclasses the objectclasses to use as search filter + * @param string $attr the attribute to look for + * @param string $dbkey the dbkey of the setting the feature is connected to + * @param string $confkey the confkey counterpart for the $dbkey as used in the * Configuration class * @param $po boolean, whether the objectClass with most result entries * shall be pre-selected via the result diff --git a/apps/user_ldap/templates/part.wizard-groupfilter.php b/apps/user_ldap/templates/part.wizard-groupfilter.php index 0cc4dfa572a..e460997b1bf 100644 --- a/apps/user_ldap/templates/part.wizard-groupfilter.php +++ b/apps/user_ldap/templates/part.wizard-groupfilter.php @@ -1,7 +1,7 @@ <fieldset id="ldapWizard4"> <div> <p> - <?php p($l->t('Limit the access to %s to groups meeting this criteria:', $theme->getName()));?> + <?php p($l->t('Groups meeting these criteria are available in %s:', $theme->getName()));?> </p> <p> <label for="ldap_groupfilter_objectclass"> diff --git a/apps/user_ldap/templates/part.wizard-loginfilter.php b/apps/user_ldap/templates/part.wizard-loginfilter.php index dc5d61e9f77..3dde46fa979 100644 --- a/apps/user_ldap/templates/part.wizard-loginfilter.php +++ b/apps/user_ldap/templates/part.wizard-loginfilter.php @@ -1,7 +1,7 @@ <fieldset id="ldapWizard3"> <div> <p> - <?php p($l->t('What attribute shall be used as login name:'));?> + <?php p($l->t('Users login with this attribute:'));?> </p> <p> <label for="ldap_loginfilter_username"> diff --git a/apps/user_ldap/templates/part.wizard-userfilter.php b/apps/user_ldap/templates/part.wizard-userfilter.php index c1d522ce2a6..eff9f89ce2c 100644 --- a/apps/user_ldap/templates/part.wizard-userfilter.php +++ b/apps/user_ldap/templates/part.wizard-userfilter.php @@ -1,7 +1,7 @@ <fieldset id="ldapWizard2"> <div> <p> - <?php p($l->t('Limit the access to %s to users meeting this criteria:', $theme->getName()));?> + <?php p($l->t('Limit %s access to users meeting these criteria:', $theme->getName()));?> </p> <p> <label for="ldap_userfilter_objectclass"> diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php index 619a992bd12..4a147cf9884 100644 --- a/apps/user_ldap/user_ldap.php +++ b/apps/user_ldap/user_ldap.php @@ -25,7 +25,6 @@ namespace OCA\user_ldap; -use OCA\user_ldap\lib\ILDAPWrapper; use OCA\user_ldap\lib\BackendUtility; class USER_LDAP extends BackendUtility implements \OCP\UserInterface { @@ -139,7 +138,7 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface { * @brief reads the image from LDAP that shall be used as Avatar * @param $uid string, the ownCloud user name * @param $dn string, the user DN - * @return image data (provided by LDAP) | false + * @return string data (provided by LDAP) | false */ private function getAvatarImage($uid, $dn) { $attributes = array('jpegPhoto', 'thumbnailPhoto'); @@ -157,9 +156,9 @@ class USER_LDAP extends BackendUtility implements \OCP\UserInterface { /** * @brief Check if the password is correct - * @param $uid The username - * @param $password The password - * @returns true/false + * @param string $uid The username + * @param string $password The password + * @return boolean * * Check if the password is correct without logging in the user */ diff --git a/core/ajax/preview.php b/core/ajax/preview.php index af0f0493f4c..a1267d6f5cf 100644 --- a/core/ajax/preview.php +++ b/core/ajax/preview.php @@ -7,7 +7,7 @@ */ \OC_Util::checkLoggedIn(); -$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : ''; +$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : ''; $maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '36'; $maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '36'; $scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true; diff --git a/core/command/db/generatechangescript.php b/core/command/db/generatechangescript.php index f971124cfdc..a4d710aa974 100644 --- a/core/command/db/generatechangescript.php +++ b/core/command/db/generatechangescript.php @@ -11,7 +11,6 @@ namespace OC\Core\Command\Db; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class GenerateChangeScript extends Command { diff --git a/core/command/status.php b/core/command/status.php index ea9825b0f61..6bc1dba44aa 100644 --- a/core/command/status.php +++ b/core/command/status.php @@ -9,9 +9,7 @@ namespace OC\Core\Command; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Status extends Command { diff --git a/core/command/upgrade.php b/core/command/upgrade.php index 1d105b67a06..128d27aa3db 100644 --- a/core/command/upgrade.php +++ b/core/command/upgrade.php @@ -10,9 +10,7 @@ namespace OC\Core\Command; use OC\Updater; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; class Upgrade extends Command { diff --git a/core/command/user/report.php b/core/command/user/report.php index f95ba251bcc..70c5a8566b7 100644 --- a/core/command/user/report.php +++ b/core/command/user/report.php @@ -9,10 +9,8 @@ namespace OC\Core\Command\User; use Symfony\Component\Console\Command\Command; -use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Console\Helper\TableHelper; class Report extends Command { protected function configure() { diff --git a/core/img/filetypes/application-x-cbr.png b/core/img/filetypes/application-x-cbr.png Binary files differnew file mode 100644 index 00000000000..c61130cda31 --- /dev/null +++ b/core/img/filetypes/application-x-cbr.png diff --git a/core/img/filetypes/application-x-cbr.svg b/core/img/filetypes/application-x-cbr.svg new file mode 100644 index 00000000000..9e3fc11d39d --- /dev/null +++ b/core/img/filetypes/application-x-cbr.svg @@ -0,0 +1,771 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="32px" + height="32px" + id="svg3194" + version="1.1" + inkscape:version="0.48.3.1 r9886" + sodipodi:docname="application-cbr.svg" + inkscape:export-filename="application-cbr.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs3196"> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3195" + id="linearGradient3066" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.502671,0,0,0.64629877,3.711822,0.79617735)" + x1="23.99999" + y1="14.915504" + x2="23.99999" + y2="32.595779" /> + <linearGradient + id="linearGradient3195"> + <stop + id="stop3197" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop3199" + style="stop-color:#ffffff;stop-opacity:0.23529412" + offset="0.12291458" /> + <stop + id="stop3201" + style="stop-color:#ffffff;stop-opacity:0.15686275" + offset="0.93706012" /> + <stop + id="stop3203" + style="stop-color:#ffffff;stop-opacity:0.39215687" + offset="1" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8-7" + id="radialGradient3069" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0,0.96917483,-0.82965977,0,24.014205,-1.7852207)" + cx="10.90426" + cy="8.4497671" + fx="10.90426" + fy="8.4497671" + r="19.99999" /> + <linearGradient + id="linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8-7"> + <stop + id="stop5430-8-6" + style="stop-color:#5f5f5f;stop-opacity:1" + offset="0" /> + <stop + id="stop5432-3-5" + style="stop-color:#4f4f4f;stop-opacity:1" + offset="0.26238" /> + <stop + id="stop5434-1-6" + style="stop-color:#3b3b3b;stop-opacity:1" + offset="0.704952" /> + <stop + id="stop5436-8-9" + style="stop-color:#2b2b2b;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-7" + id="linearGradient3071" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.65627449,0,0,0.6892852,1.2531134,-0.21112011)" + x1="24" + y1="44" + x2="24" + y2="3.8990016" /> + <linearGradient + id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-7"> + <stop + id="stop5440-4-4" + style="stop-color:#272727;stop-opacity:1" + offset="0" /> + <stop + id="stop5442-3-5" + style="stop-color:#454545;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3731" + id="linearGradient3075" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.56756757,0,0,0.67567567,2.3783793,-0.21620881)" + x1="23.99999" + y1="4.999989" + x2="23.99999" + y2="43" /> + <linearGradient + id="linearGradient3731"> + <stop + id="stop3733" + style="stop-color:#ffffff;stop-opacity:1" + offset="0" /> + <stop + id="stop3735" + style="stop-color:#ffffff;stop-opacity:0.23529412" + offset="0.02706478" /> + <stop + id="stop3737" + style="stop-color:#ffffff;stop-opacity:0.15686275" + offset="0.97377032" /> + <stop + id="stop3739" + style="stop-color:#ffffff;stop-opacity:0.39215687" + offset="1" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8" + id="radialGradient3078" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1.165708e-8,1.6179162,-1.483354,-2.9808191e-8,28.734063,-9.2240923)" + cx="7.4956832" + cy="8.4497671" + fx="7.4956832" + fy="8.4497671" + r="19.99999" /> + <linearGradient + id="linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8"> + <stop + id="stop5430-8" + style="stop-color:#5f5f5f;stop-opacity:1" + offset="0" /> + <stop + id="stop5432-3" + style="stop-color:#4f4f4f;stop-opacity:1" + offset="0.26238" /> + <stop + id="stop5434-1" + style="stop-color:#3b3b3b;stop-opacity:1" + offset="0.704952" /> + <stop + id="stop5436-8" + style="stop-color:#2b2b2b;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6" + id="linearGradient3080" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.60000001,0,0,0.69230771,1.8000008,-0.61538474)" + x1="24" + y1="44" + x2="24" + y2="3.8990016" /> + <linearGradient + id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6"> + <stop + id="stop5440-4" + style="stop-color:#272727;stop-opacity:1" + offset="0" /> + <stop + id="stop5442-3" + style="stop-color:#454545;stop-opacity:1" + offset="1" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient8967-1" + id="radialGradient3083" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0,1.8069473,-2.0594306,0,30.190262,-41.983847)" + cx="24.501682" + cy="6.6475959" + fx="24.501682" + fy="6.6475959" + r="17.49832" /> + <linearGradient + id="linearGradient8967"> + <stop + id="stop8969" + style="stop-color:#ddcfbd;stop-opacity:1" + offset="0" /> + <stop + id="stop8971" + style="stop-color:#856f50;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3319-1" + id="linearGradient3085" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.45330736,0,0,0.48530928,1.9941631,0.11705426)" + x1="32.901409" + y1="4.6481781" + x2="32.901409" + y2="61.481758" /> + <linearGradient + id="linearGradient3319"> + <stop + id="stop3321" + style="stop-color:#a79071;stop-opacity:1" + offset="0" /> + <stop + id="stop3323" + style="stop-color:#6f5d45;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient2346" + id="linearGradient3088" + gradientUnits="userSpaceOnUse" + x1="10.654308" + y1="1" + x2="10.654308" + y2="3" + gradientTransform="matrix(0.60000001,0,0,0.75000464,0.6000147,0.12497942)" /> + <linearGradient + id="linearGradient2346"> + <stop + id="stop2348" + style="stop-color:#eeeeee;stop-opacity:1" + offset="0" /> + <stop + id="stop2350" + style="stop-color:#d9d9da;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-2" + id="linearGradient3090" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.60000001,0,0,0.07692307,1.8001714,0.15384638)" + x1="24" + y1="44" + x2="24" + y2="3.8990016" /> + <linearGradient + id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-2"> + <stop + id="stop5440-4-8" + style="stop-color:#272727;stop-opacity:1" + offset="0" /> + <stop + id="stop5442-3-8" + style="stop-color:#454545;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + id="linearGradient3101"> + <stop + offset="0" + style="stop-color:#9b876c;stop-opacity:1" + id="stop3103" /> + <stop + offset="0.95429963" + style="stop-color:#9b876c;stop-opacity:1" + id="stop3105" /> + <stop + offset="0.95717829" + style="stop-color:#c2c2c2;stop-opacity:1" + id="stop3107" /> + <stop + offset="1" + style="stop-color:#c2c2c2;stop-opacity:1" + id="stop3109" /> + </linearGradient> + <linearGradient + y2="4.882647" + x2="24.640038" + y1="3.1234391" + x1="24.62738" + gradientTransform="matrix(0.69041563,0,0,1.0164576,0.2501926,-2.4916513)" + gradientUnits="userSpaceOnUse" + id="linearGradient3190" + xlink:href="#linearGradient2346" + inkscape:collect="always" /> + <linearGradient + y2="0.065301567" + x2="54.887218" + y1="0.065301567" + x1="5.2122574" + gradientTransform="matrix(0.49253714,0,0,0.4937733,0.8902917,0.14413039)" + gradientUnits="userSpaceOnUse" + id="linearGradient3192" + xlink:href="#linearGradient3911" + inkscape:collect="always" /> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3688-166-749" + id="radialGradient2976" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(2.003784,0,0,1.4,27.98813,-17.4)" + cx="4.9929786" + cy="43.5" + fx="4.9929786" + fy="43.5" + r="2.5" /> + <linearGradient + id="linearGradient3688-166-749"> + <stop + id="stop2883" + style="stop-color:#181818;stop-opacity:1" + offset="0" /> + <stop + id="stop2885" + style="stop-color:#181818;stop-opacity:0" + offset="1" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient3688-464-309" + id="radialGradient2978" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(2.003784,0,0,1.4,-20.01187,-104.4)" + cx="4.9929786" + cy="43.5" + fx="4.9929786" + fy="43.5" + r="2.5" /> + <linearGradient + id="linearGradient3688-464-309"> + <stop + id="stop2889" + style="stop-color:#181818;stop-opacity:1" + offset="0" /> + <stop + id="stop2891" + style="stop-color:#181818;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3702-501-757" + id="linearGradient2980" + gradientUnits="userSpaceOnUse" + x1="25.058096" + y1="47.027729" + x2="25.058096" + y2="39.999443" /> + <linearGradient + id="linearGradient3702-501-757"> + <stop + id="stop2895" + style="stop-color:#181818;stop-opacity:0" + offset="0" /> + <stop + id="stop2897" + style="stop-color:#181818;stop-opacity:1" + offset="0.5" /> + <stop + id="stop2899" + style="stop-color:#181818;stop-opacity:0" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3100" + id="linearGradient3072" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.40540539,0,0,0.45945944,-21.967425,1.9253706)" + x1="23.99999" + y1="4.431067" + x2="24.107431" + y2="43.758408" /> + <linearGradient + id="linearGradient3100"> + <stop + offset="0" + style="stop-color:#ffffff;stop-opacity:1" + id="stop3102" /> + <stop + offset="0.06169702" + style="stop-color:#ffffff;stop-opacity:0.23529412" + id="stop3104" /> + <stop + offset="0.93279684" + style="stop-color:#ffffff;stop-opacity:0.15686275" + id="stop3106" /> + <stop + offset="1" + style="stop-color:#ffffff;stop-opacity:0.39215687" + id="stop3108" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8-3" + id="radialGradient3075" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0,1.1385335,-0.98890268,-2.0976135e-8,-4.5816524,-4.7978939)" + cx="7.4956832" + cy="8.4497671" + fx="7.4956832" + fy="8.4497671" + r="19.99999" /> + <linearGradient + id="linearGradient2867-449-88-871-390-598-476-591-434-148-57-177-641-289-620-227-114-444-680-744-8-3"> + <stop + id="stop5430-8-4" + style="stop-color:#5f5f5f;stop-opacity:1" + offset="0" /> + <stop + id="stop5432-3-0" + style="stop-color:#4f4f4f;stop-opacity:1" + offset="0.26238" /> + <stop + id="stop5434-1-7" + style="stop-color:#3b3b3b;stop-opacity:1" + offset="0.704952" /> + <stop + id="stop5436-8-7" + style="stop-color:#2b2b2b;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-77" + id="linearGradient3077" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.40000001,0,0,0.48717951,-22.537695,1.2600855)" + x1="24" + y1="44" + x2="24" + y2="3.8990016" /> + <linearGradient + id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-77"> + <stop + id="stop5440-4-82" + style="stop-color:#272727;stop-opacity:1" + offset="0" /> + <stop + id="stop5442-3-9" + style="stop-color:#454545;stop-opacity:1" + offset="1" /> + </linearGradient> + <radialGradient + inkscape:collect="always" + xlink:href="#linearGradient8967-1" + id="radialGradient3080" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0,1.2711776,-1.4972812,0,-1.7843744,-27.838648)" + cx="24.501682" + cy="6.6475959" + fx="24.501682" + fy="6.6475959" + r="17.49832" /> + <linearGradient + id="linearGradient8967-1"> + <stop + id="stop8969-2" + style="stop-color:#c4ea71;stop-opacity:1;" + offset="0" /> + <stop + id="stop8971-2" + style="stop-color:#7c9d35;stop-opacity:1;" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3319-1" + id="linearGradient3082" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.32957099,0,0,0.34141245,-22.283968,1.7791087)" + x1="32.901409" + y1="4.6481781" + x2="32.901409" + y2="61.481758" /> + <linearGradient + id="linearGradient3319-1"> + <stop + id="stop3321-3" + style="stop-color:#96bf3e;stop-opacity:1;" + offset="0" /> + <stop + id="stop3323-6" + style="stop-color:#4d6b0d;stop-opacity:1;" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient2346-4" + id="linearGradient3085-0" + gradientUnits="userSpaceOnUse" + x1="10.654308" + y1="1" + x2="10.654308" + y2="3" + gradientTransform="matrix(0.39999999,0,0,0.50000335,-23.337674,1.202378)" /> + <linearGradient + id="linearGradient2346-4"> + <stop + id="stop2348-6" + style="stop-color:#eeeeee;stop-opacity:1" + offset="0" /> + <stop + id="stop2350-4" + style="stop-color:#d9d9da;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-2-9" + id="linearGradient3087" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.39999999,0,0,0.05128207,-22.537569,1.2216233)" + x1="24" + y1="44" + x2="24" + y2="3.8990016" /> + <linearGradient + id="linearGradient3707-319-631-407-324-616-674-812-821-107-178-392-400-6-2-9"> + <stop + id="stop5440-4-8-9" + style="stop-color:#272727;stop-opacity:1" + offset="0" /> + <stop + id="stop5442-3-8-1" + style="stop-color:#454545;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient2346-4" + id="linearGradient3090-0" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.52589466,0,0,1.0164584,-24.496147,-1.5392617)" + x1="24.640038" + y1="3.3805361" + x2="24.640038" + y2="4.4969802" /> + <linearGradient + id="linearGradient3159"> + <stop + id="stop3161" + style="stop-color:#eeeeee;stop-opacity:1" + offset="0" /> + <stop + id="stop3163" + style="stop-color:#d9d9da;stop-opacity:1" + offset="1" /> + </linearGradient> + <linearGradient + inkscape:collect="always" + xlink:href="#linearGradient3911" + id="linearGradient3092" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.37516915,0,0,0.49377366,-24.008579,1.096522)" + x1="10.199131" + y1="0.065301567" + x2="54.887218" + y2="0.065301567" /> + <linearGradient + id="linearGradient3911"> + <stop + id="stop3913" + style="stop-color:#96bf3e;stop-opacity:1;" + offset="0" /> + <stop + id="stop3915" + style="stop-color:#4d6b0d;stop-opacity:1;" + offset="1" /> + </linearGradient> + <radialGradient + r="2.5" + fy="43.5" + fx="4.9929786" + cy="43.5" + cx="4.9929786" + gradientTransform="matrix(2.003784,0,0,1.4,27.98813,-17.4)" + gradientUnits="userSpaceOnUse" + id="radialGradient3082-993" + xlink:href="#linearGradient3688-166-749-49" + inkscape:collect="always" /> + <linearGradient + id="linearGradient3688-166-749-49"> + <stop + offset="0" + style="stop-color:#181818;stop-opacity:1" + id="stop3079" /> + <stop + offset="1" + style="stop-color:#181818;stop-opacity:0" + id="stop3081" /> + </linearGradient> + <radialGradient + r="2.5" + fy="43.5" + fx="4.9929786" + cy="43.5" + cx="4.9929786" + gradientTransform="matrix(2.003784,0,0,1.4,-20.01187,-104.4)" + gradientUnits="userSpaceOnUse" + id="radialGradient3084-992" + xlink:href="#linearGradient3688-464-309-276" + inkscape:collect="always" /> + <linearGradient + id="linearGradient3688-464-309-276"> + <stop + offset="0" + style="stop-color:#181818;stop-opacity:1" + id="stop3085" /> + <stop + offset="1" + style="stop-color:#181818;stop-opacity:0" + id="stop3087" /> + </linearGradient> + <linearGradient + y2="39.999443" + x2="25.058096" + y1="47.027729" + x1="25.058096" + gradientUnits="userSpaceOnUse" + id="linearGradient3086-631" + xlink:href="#linearGradient3702-501-757-979" + inkscape:collect="always" /> + <linearGradient + id="linearGradient3702-501-757-979"> + <stop + offset="0" + style="stop-color:#181818;stop-opacity:0" + id="stop3091" /> + <stop + offset="0.5" + style="stop-color:#181818;stop-opacity:1" + id="stop3093" /> + <stop + offset="1" + style="stop-color:#181818;stop-opacity:0" + id="stop3095" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="2.1523438" + inkscape:cx="-47.81249" + inkscape:cy="58.888102" + inkscape:current-layer="layer1" + showgrid="true" + inkscape:grid-bbox="true" + inkscape:document-units="px" + inkscape:window-width="1366" + inkscape:window-height="744" + inkscape:window-x="0" + inkscape:window-y="24" + inkscape:window-maximized="1" /> + <metadata + id="metadata3199"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + id="layer1" + inkscape:label="Layer 1" + inkscape:groupmode="layer"> + <g + style="display:inline" + id="g2036" + transform="matrix(0.64999974,0,0,0.3333336,0.39999974,15.33333)"> + <g + style="opacity:0.4" + id="g3712" + transform="matrix(1.052632,0,0,1.285713,-1.263158,-13.42854)"> + <rect + style="fill:url(#radialGradient2976);fill-opacity:1;stroke:none" + id="rect2801" + y="40" + x="38" + height="7" + width="5" /> + <rect + style="fill:url(#radialGradient2978);fill-opacity:1;stroke:none" + id="rect3696" + transform="scale(-1,-1)" + y="-47" + x="-10" + height="7" + width="5" /> + <rect + style="fill:url(#linearGradient2980);fill-opacity:1;stroke:none" + id="rect3700" + y="40" + x="10" + height="7.0000005" + width="28" /> + </g> + </g> + <path + inkscape:connector-curvature="0" + style="fill:url(#linearGradient3190);fill-opacity:1;stroke:url(#linearGradient3192);stroke-width:1.01739752;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline" + id="path2723" + d="M 27.491301,2.3043778 C 27.288172,1.6493136 27.414776,1.1334476 27.302585,0.5086989 l -20.7938863,0 0.1227276,1.9826025" /> + <path + inkscape:connector-curvature="0" + style="color:#000000;fill:url(#linearGradient3088);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient3090);stroke-width:0.99999994;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="rect5505-21-3-9" + d="m 7.5001709,3.5 -2.4000002,0 C 4.7576618,3.5 4.5001708,3.46825 4.5001708,3.426829 l 0,-2.0973288 c 0,-0.66594375 0.3354193,-0.82950023 0.7745366,-0.82950023 l 2.2254635,0" /> + <rect + ry="0.5" + style="fill:url(#radialGradient3083);fill-opacity:1.0;stroke:url(#linearGradient3085);stroke-width:1.01904130000000004;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:0;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;display:inline" + id="rect2719" + y="2.5095644" + x="5.5095205" + rx="0.5" + height="26.980959" + width="21.980959" /> + <path + inkscape:connector-curvature="0" + style="color:#000000;fill:url(#radialGradient3078);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient3080);stroke-width:1;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" + id="rect5505-21-3" + d="m 7.5,2.5000001 c 0,0 0,18.7742959 0,26.9999999 l -2.4,0 c -0.3425089,0 -0.6,-0.285772 -0.6,-0.658537 l 0,-26.3414629 z" /> + <rect + style="opacity:0.5;fill:none;stroke:url(#linearGradient3075);stroke-width:0.99999988;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect6741-0" + y="3.5000002" + x="5.5" + height="25" + width="21" /> + <g + style="fill:#000000;fill-opacity:1;opacity:0.2" + id="g3230" + transform="matrix(-0.17865757,0,0,0.17865757,25.443696,7.0670321)"> + <path + style="fill:#000000;fill-opacity:1" + id="path3232" + d="m 50.463,22.014 c -19.869,0 -35.984,11.045 -35.984,24.674 0,6.475 3.667,12.342 9.612,16.748 l -4.027,14.551 20.54,-7.582 c 3.132,0.615 6.438,0.967 9.859,0.967 19.873,0 35.98,-11.049 35.98,-24.684 0,-13.629 -16.107,-24.674 -35.98,-24.674 z" + inkscape:connector-curvature="0" /> + </g> + <g + transform="matrix(-0.17865757,0,0,0.17865757,25.443696,6.0670321)" + id="Layer_5" + style="fill:#ffffff"> + <path + inkscape:connector-curvature="0" + d="m 50.463,22.014 c -19.869,0 -35.984,11.045 -35.984,24.674 0,6.475 3.667,12.342 9.612,16.748 l -4.027,14.551 20.54,-7.582 c 3.132,0.615 6.438,0.967 9.859,0.967 19.873,0 35.98,-11.049 35.98,-24.684 0,-13.629 -16.107,-24.674 -35.98,-24.674 z" + id="path3196" + style="fill:#ffffff" /> + </g> + </g> +</svg> diff --git a/core/js/config.php b/core/js/config.php index 517ea1615a8..b6875fb73f9 100644 --- a/core/js/config.php +++ b/core/js/config.php @@ -57,7 +57,7 @@ $array = array( "firstDay" => json_encode($l->l('firstday', 'firstday')) , "oc_config" => json_encode( array( - 'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', 60 * 60 * 24), + 'session_lifetime' => \OCP\Config::getSystemValue('session_lifetime', ini_get('session.gc_maxlifetime')), 'session_keepalive' => \OCP\Config::getSystemValue('session_keepalive', true) ) ) diff --git a/core/js/js.js b/core/js/js.js index cb177712a3a..d4d2583f1e5 100644 --- a/core/js/js.js +++ b/core/js/js.js @@ -884,11 +884,7 @@ function initCore() { $('a.action.delete').tipsy({gravity:'e', fade:true, live:true}); $('a.action').tipsy({gravity:'s', fade:true, live:true}); $('td .modified').tipsy({gravity:'s', fade:true, live:true}); - $('input').tipsy({gravity:'w', fade:true}); - $('input[type=text]').focus(function(){ - this.select(); - }); } $(document).ready(initCore); diff --git a/core/lostpassword/controller.php b/core/lostpassword/controller.php index 3c8099591a1..fd20c6ba249 100644 --- a/core/lostpassword/controller.php +++ b/core/lostpassword/controller.php @@ -8,6 +8,11 @@ namespace OC\Core\LostPassword; class Controller { + + /** + * @param boolean $error + * @param boolean $requested + */ protected static function displayLostPasswordPage($error, $requested) { $isEncrypted = \OC_App::isEnabled('files_encryption'); \OC_Template::printGuestPage('core/lostpassword', 'lostpassword', @@ -16,6 +21,9 @@ class Controller { 'isEncrypted' => $isEncrypted)); } + /** + * @param boolean $success + */ protected static function displayResetPasswordPage($success, $args) { $route_args = array(); $route_args['token'] = $args['token']; diff --git a/core/templates/installation.php b/core/templates/installation.php index 9670a5e9ee5..d3adb34f412 100644 --- a/core/templates/installation.php +++ b/core/templates/installation.php @@ -48,13 +48,15 @@ <legend><?php print_unescaped($l->t( 'Create an <strong>admin account</strong>' )); ?></legend> <p class="infield grouptop"> <input type="text" name="adminlogin" id="adminlogin" placeholder="" - value="<?php p($_['adminlogin']); ?>" autocomplete="off" autofocus required /> + value="<?php p($_['adminlogin']); ?>" + autocomplete="off" autocapitalize="off" autocorrect="off" autofocus required /> <label for="adminlogin" class="infield"><?php p($l->t( 'Username' )); ?></label> <img class="svg" src="<?php p(image_path('', 'actions/user.svg')); ?>" alt="" /> </p> <p class="infield groupbottom"> <input type="password" name="adminpass" data-typetoggle="#show" id="adminpass" placeholder="" - value="<?php p($_['adminpass']); ?>" required /> + value="<?php p($_['adminpass']); ?>" + autocomplete="off" autocapitalize="off" autocorrect="off" required /> <label for="adminpass" class="infield"><?php p($l->t( 'Password' )); ?></label> <img class="svg" id="adminpass-icon" src="<?php print_unescaped(image_path('', 'actions/password.svg')); ?>" alt="" /> <input type="checkbox" id="show" name="show" /> @@ -74,8 +76,9 @@ <div id="datadirContent"> <label for="directory"><?php p($l->t( 'Data folder' )); ?></label> <input type="text" name="directory" id="directory" - placeholder="<?php p(OC::$SERVERROOT."/data"); ?>" - value="<?php p($_['directory']); ?>" /> + placeholder="<?php p(OC::$SERVERROOT.'/data'); ?>" + value="<?php p($_['directory']); ?>" + autocomplete="off" autocapitalize="off" autocorrect="off" /> </div> </fieldset> <?php endif; ?> @@ -103,11 +106,13 @@ <p class="infield grouptop"> <label for="dbuser" class="infield"><?php p($l->t( 'Database user' )); ?></label> <input type="text" name="dbuser" id="dbuser" placeholder="" - value="<?php p($_['dbuser']); ?>" autocomplete="off" /> + value="<?php p($_['dbuser']); ?>" + autocomplete="off" autocapitalize="off" autocorrect="off" /> </p> <p class="infield groupmiddle"> <input type="password" name="dbpass" id="dbpass" placeholder="" data-typetoggle="#dbpassword" - value="<?php p($_['dbpass']); ?>" /> + value="<?php p($_['dbpass']); ?>" + autocomplete="off" autocapitalize="off" autocorrect="off" /> <label for="dbpass" class="infield"><?php p($l->t( 'Database password' )); ?></label> <input type="checkbox" id="dbpassword" name="dbpassword" /> <label for="dbpassword"></label> @@ -116,21 +121,24 @@ <label for="dbname" class="infield"><?php p($l->t( 'Database name' )); ?></label> <input type="text" name="dbname" id="dbname" placeholder="" value="<?php p($_['dbname']); ?>" - autocomplete="off" pattern="[0-9a-zA-Z$_-]+" /> + autocomplete="off" autocapitalize="off" autocorrect="off" + pattern="[0-9a-zA-Z$_-]+" /> </p> <?php if($_['hasOracle']): ?> <div id="use_oracle_db"> <p class="infield groupmiddle"> <label for="dbtablespace" class="infield"><?php p($l->t( 'Database tablespace' )); ?></label> <input type="text" name="dbtablespace" id="dbtablespace" placeholder="" - value="<?php p($_['dbtablespace']); ?>" autocomplete="off" /> + value="<?php p($_['dbtablespace']); ?>" + autocomplete="off" autocapitalize="off" autocorrect="off" /> </p> </div> <?php endif; ?> <p class="infield groupbottom"> <label for="dbhost" class="infield"><?php p($l->t( 'Database host' )); ?></label> <input type="text" name="dbhost" id="dbhost" placeholder="" - value="<?php p($_['dbhost']); ?>" /> + value="<?php p($_['dbhost']); ?>" + autocomplete="off" autocapitalize="off" autocorrect="off" /> </p> </div> <?php endif; ?> diff --git a/core/templates/login.php b/core/templates/login.php index e697ebe5326..b534e1edea5 100644 --- a/core/templates/login.php +++ b/core/templates/login.php @@ -26,15 +26,17 @@ </p> <p class="infield grouptop"> <input type="text" name="user" id="user" placeholder="" - value="<?php p($_['username']); ?>"<?php p($_['user_autofocus'] ? ' autofocus' : ''); ?> - autocomplete="on" required/> + value="<?php p($_['username']); ?>" + <?php p($_['user_autofocus'] ? 'autofocus' : ''); ?> + autocomplete="on" autocapitalize="off" autocorrect="off" required /> <label for="user" class="infield"><?php p($l->t('Username')); ?></label> <img class="svg" src="<?php print_unescaped(image_path('', 'actions/user.svg')); ?>" alt=""/> </p> <p class="infield groupbottom"> <input type="password" name="password" id="password" value="" placeholder="" - required<?php p($_['user_autofocus'] ? '' : ' autofocus'); ?> /> + <?php p($_['user_autofocus'] ? '' : 'autofocus'); ?> + autocomplete="on" autocapitalize="off" autocorrect="off" required /> <label for="password" class="infield"><?php p($l->t('Password')); ?></label> <img class="svg" id="password-icon" src="<?php print_unescaped(image_path('', 'actions/password.svg')); ?>" alt=""/> </p> @@ -97,7 +97,7 @@ try { touch(TemporaryCronClass::$lockfile); // Work - $jobList = new \OC\BackgroundJob\JobList(); + $jobList = \OC::$server->getJobList(); $jobs = $jobList->getAll(); foreach ($jobs as $job) { $job->execute($jobList, $logger); @@ -109,7 +109,7 @@ try { OC_JSON::error(array('data' => array('message' => 'Backgroundjobs are using system cron!'))); } else { // Work and success :-) - $jobList = new \OC\BackgroundJob\JobList(); + $jobList = \OC::$server->getJobList(); $job = $jobList->getNext(); $job->execute($jobList, $logger); $jobList->setLastJob($job); diff --git a/issue_template.md b/issue_template.md index 0ddc7667bf3..ec14a8b3463 100644 --- a/issue_template.md +++ b/issue_template.md @@ -1,37 +1,44 @@ +### Steps to reproduce +1. +2. +3. + ### Expected behaviour Tell us what should happen ### Actual behaviour Tell us what happens instead -### Steps to reproduce -1. -2. -3. - ### Server configuration -Operating system: +**Operating system**: -Web server: +**Web server:** -Database: +**Database:** -PHP version: +**PHP version:** -ownCloud version: (see ownCloud admin page) +**ownCloud version:** (see ownCloud admin page) -Updated from an older ownCloud or fresh install: +**Updated from an older ownCloud or fresh install:** -List of activated app: +**List of activated apps:** + +**The content of config/config.php:** + +``` +Insert your config.php content here +(Without the database password and passwordsalt) +``` -The content of config/config.php: (Without the database password and passwordsalt) +**Are you using external storage, if yes which one:** local/smb/sftp/... -Are you using external storage, if yes which one: +**Are you using encryption:** yes/no ### Client configuration -Browser: +**Browser:** -Operating system: +**Operating system:** ### Logs #### Web server error log diff --git a/lib/base.php b/lib/base.php index f2d9251294d..a5f064bdb4b 100644 --- a/lib/base.php +++ b/lib/base.php @@ -385,7 +385,7 @@ class OC { } /** - * @return int + * @return string */ private static function getSessionLifeTime() { return OC_Config::getValue('session_lifetime', 60 * 60 * 24); 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..2a715598fc4 100644 --- a/lib/private/appframework/middleware/middlewaredispatcher.php +++ b/lib/private/appframework/middleware/middlewaredispatcher.php @@ -26,7 +26,6 @@ namespace OC\AppFramework\Middleware; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\Response; -use OCP\AppFramework\MiddleWare; /** * This class is used to store and run all the middleware in correct order @@ -56,7 +55,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..5ef6365f657 100644 --- a/lib/private/connector/sabre/file.php +++ b/lib/private/connector/sabre/file.php @@ -206,6 +206,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..05d2d2291ec 100644 --- a/lib/private/connector/sabre/node.php +++ b/lib/private/connector/sabre/node.php @@ -153,9 +153,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 +266,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/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 5bbc2e960d7..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) { @@ -175,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); @@ -199,6 +205,10 @@ class OC_Files { } } + /** + * @param string $dir + * @param ZipArchive $zip + */ public static function zipAddDir($dir, $zip, $internalDir='') { $dirname=basename($dir); $zip->addEmptyDir($internalDir.$dirname); @@ -222,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 5b1b30176e8..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); 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..b6102f5c245 100644 --- a/lib/private/files/filesystem.php +++ b/lib/private/files/filesystem.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 55b1471593d..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); 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 fa0788f2377..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) { 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 a430e3e4617..1bcdca7f47a 100644 --- a/lib/private/files/storage/wrapper/quota.php +++ b/lib/private/files/storage/wrapper/quota.php @@ -23,6 +23,9 @@ class Quota extends Wrapper { $this->quota = $parameters['quota']; } + /** + * @param string $path + */ protected function getSize($path) { $cache = $this->getCache(); $data = $cache->get($path); 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 58cb1b88d66..e5d1fa9b513 100644 --- a/lib/private/helper.php +++ b/lib/private/helper.php @@ -151,6 +151,7 @@ class OC_Helper { */ public static function mimetypeIcon($mimetype) { $alias = array( + 'application/octet-stream' => 'file', // use file icon as fallback 'application/xml' => 'code/xml', 'application/msword' => 'x-office/document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'x-office/document', 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 91a9f91e1d6..42685ddab5c 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..1ade18ea427 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; @@ -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..174877d623b 100644 --- a/lib/private/mimetypes.list.php +++ b/lib/private/mimetypes.list.php @@ -29,10 +29,17 @@ return array( 'avi'=>'video/x-msvideo', 'bash' => 'text/x-shellscript', 'blend'=>'application/x-blender', + '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', + 'cvbdl' => 'application/x-cbr', 'c' => 'text/x-c', 'c++' => 'text/x-c++src', 'doc'=>'application/msword', 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/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/searchresultsorter.php b/lib/private/share/searchresultsorter.php index fbf77179097..76abbf30846 100644 --- a/lib/private/share/searchresultsorter.php +++ b/lib/private/share/searchresultsorter.php @@ -15,8 +15,8 @@ class SearchResultSorter { private $log; /** - * @param $search the search term as was given by the user - * @param $key the array key containing the value that should be compared + * @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 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/user.php b/lib/private/user.php index 2519200d0f0..86a01f96258 100644 --- a/lib/private/user.php +++ b/lib/private/user.php @@ -222,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 */ @@ -290,6 +290,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)) { @@ -481,7 +482,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 @@ -515,6 +516,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); @@ -609,7 +612,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..1740bad5abe 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)); diff --git a/lib/private/util.php b/lib/private/util.php index 0585749d615..829eedce044 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) { diff --git a/lib/public/activity/imanager.php b/lib/public/activity/imanager.php index 086e430d677..449fdcc934d 100644 --- a/lib/public/activity/imanager.php +++ b/lib/public/activity/imanager.php @@ -53,6 +53,7 @@ interface IManager { * $callable has to return an instance of OCA\Activity\IConsumer * * @param \Closure $callable + * @return void */ function registerConsumer(\Closure $callable); diff --git a/lib/public/app.php b/lib/public/app.php index e0b5682242b..96162299ec4 100644 --- a/lib/public/app.php +++ b/lib/public/app.php @@ -85,6 +85,7 @@ class App { * Register a Configuration Screen that should appear in the personal settings section. * @param $app string appid * @param $page string page to be included + * @return void */ public static function registerPersonal( $app, $page ) { \OC_App::registerPersonal( $app, $page ); @@ -92,8 +93,9 @@ class App { /** * Register a Configuration Screen that should appear in the Admin section. - * @param $app string appid - * @param $page string page to be included + * @param string $app string appid + * @param string $page string page to be included + * @return void */ public static function registerAdmin( $app, $page ) { \OC_App::registerAdmin( $app, $page ); @@ -111,7 +113,7 @@ class App { /** * checks whether or not an app is enabled - * @param string + * @param string $app * @return boolean * * This function checks whether or not an app is enabled. @@ -122,7 +124,8 @@ class App { /** * Check if the app is enabled, redirects to home if not - * @param string + * @param string $app + * @return void */ public static function checkAppEnabled( $app ) { \OC_Util::checkAppEnabled( $app ); @@ -130,8 +133,8 @@ class App { /** * Get the last version of the app, either from appinfo/version or from appinfo/info.xml - * @param string - * @return boolean + * @param string $app + * @return string */ public static function getAppVersion( $app ) { return \OC_App::getAppVersion( $app ); diff --git a/lib/public/appframework/controller.php b/lib/public/appframework/controller.php index dc8da967871..7c2219bd046 100644 --- a/lib/public/appframework/controller.php +++ b/lib/public/appframework/controller.php @@ -68,7 +68,7 @@ abstract class Controller { * 1. URL parameters * 2. POST parameters * 3. GET parameters - * @param mixed $default If the key is not found, this value will be returned + * @param string $default If the key is not found, this value will be returned * @return mixed the content of the array */ public function params($key, $default=null){ @@ -131,7 +131,7 @@ abstract class Controller { * @param array $params the template parameters in key => value structure * @param string $renderAs user renders a full page, blank only your template * admin an entry in the admin settings - * @param array $headers set additional headers in name/value pairs + * @param string[] $headers set additional headers in name/value pairs * @return \OCP\AppFramework\Http\TemplateResponse containing the page */ public function render($templateName, array $params=array(), diff --git a/lib/public/appframework/http/response.php b/lib/public/appframework/http/response.php index 0f5a18ca4fe..d223621d4fd 100644 --- a/lib/public/appframework/http/response.php +++ b/lib/public/appframework/http/response.php @@ -155,7 +155,7 @@ class Response { /** * Get "last modified" date - * @return string RFC2822 formatted last modified date + * @return \DateTime RFC2822 formatted last modified date */ public function getLastModified() { return $this->lastModified; diff --git a/lib/public/appframework/iapi.php b/lib/public/appframework/iapi.php index 963e870f79b..c4aeea2d4e5 100644 --- a/lib/public/appframework/iapi.php +++ b/lib/public/appframework/iapi.php @@ -45,6 +45,7 @@ interface IApi { * Adds a new javascript file * @param string $scriptName the name of the javascript in js/ without the suffix * @param string $appName the name of the app, defaults to the current one + * @return void */ function addScript($scriptName, $appName = null); @@ -53,6 +54,7 @@ interface IApi { * Adds a new css file * @param string $styleName the name of the css file in css/without the suffix * @param string $appName the name of the app, defaults to the current one + * @return void */ function addStyle($styleName, $appName = null); @@ -60,6 +62,7 @@ interface IApi { /** * shorthand for addScript for files in the 3rdparty directory * @param string $name the name of the file without the suffix + * @return void */ function add3rdPartyScript($name); @@ -67,6 +70,7 @@ interface IApi { /** * shorthand for addStyle for files in the 3rdparty directory * @param string $name the name of the file without the suffix + * @return void */ function add3rdPartyStyle($name); diff --git a/lib/public/appframework/iappcontainer.php b/lib/public/appframework/iappcontainer.php index 7e6ec6016b7..e4f5f37cad2 100644 --- a/lib/public/appframework/iappcontainer.php +++ b/lib/public/appframework/iappcontainer.php @@ -66,8 +66,8 @@ interface IAppContainer extends IContainer{ function isAdminUser(); /** - * @param $message - * @param $level + * @param string $message + * @param string $level * @return mixed */ function log($message, $level); diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php index a7f54491dfa..03b94403b47 100644 --- a/lib/public/backgroundjob.php +++ b/lib/public/backgroundjob.php @@ -33,7 +33,7 @@ use \OC\BackgroundJob\JobList; /** * This class provides functions to register backgroundjobs in ownCloud * - * To create a new backgroundjob create a new class that inharits from either \OC\BackgroundJob\Job, + * To create a new backgroundjob create a new class that inherits from either \OC\BackgroundJob\Job, * \OC\BackgroundJob\QueuedJob or \OC\BackgroundJob\TimedJob and register it using * \OCP\BackgroundJob->registerJob($job, $argument), $argument will be passed to the run() function * of the job when the job is executed. @@ -59,7 +59,7 @@ class BackgroundJob { * sets the background jobs execution type * * @param string $type execution type - * @return boolean + * @return false|null * * This method sets the execution type of the background jobs. Possible types * are "none", "ajax", "webcron", "cron" @@ -69,11 +69,11 @@ class BackgroundJob { } /** - * @param \OC\BackgroundJob\Job|string $job + * @param string $job * @param mixed $argument */ public static function registerJob($job, $argument = null) { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $jobList->add($job, $argument); } @@ -82,7 +82,7 @@ class BackgroundJob { * creates a regular task * @param string $klass class name * @param string $method method name - * @return true + * @return boolean|null */ public static function addRegularTask($klass, $method) { if (!\OC::needUpgrade()) { @@ -99,7 +99,7 @@ class BackgroundJob { * key is string "$klass-$method", value is array( $klass, $method ) */ static public function allRegularTasks() { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $allJobs = $jobList->getAll(); $regularJobs = array(); foreach ($allJobs as $job) { @@ -115,10 +115,10 @@ class BackgroundJob { * @deprecated * Gets one queued task * @param int $id ID of the task - * @return associative array + * @return BackgroundJob\IJob array */ public static function findQueuedTask($id) { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); return $jobList->getById($id); } @@ -128,7 +128,7 @@ class BackgroundJob { * @return array with associative arrays */ public static function allQueuedTasks() { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $allJobs = $jobList->getAll(); $queuedJobs = array(); foreach ($allJobs as $job) { @@ -148,7 +148,7 @@ class BackgroundJob { * @return array with associative arrays */ public static function queuedTaskWhereAppIs($app) { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $allJobs = $jobList->getAll(); $queuedJobs = array(); foreach ($allJobs as $job) { @@ -170,7 +170,7 @@ class BackgroundJob { * @param string $class class name * @param string $method method name * @param string $parameters all useful data as text - * @return int id of task + * @return boolean id of task */ public static function addQueuedTask($app, $class, $method, $parameters) { self::registerJob('OC\BackgroundJob\Legacy\QueuedJob', array('app' => $app, 'klass' => $class, 'method' => $method, 'parameters' => $parameters)); @@ -181,12 +181,12 @@ class BackgroundJob { * @deprecated * deletes a queued task * @param int $id id of task - * @return bool + * @return boolean|null * * Deletes a report */ public static function deleteQueuedTask($id) { - $jobList = new JobList(); + $jobList = \OC::$server->getJobList(); $job = $jobList->getById($id); if ($job) { $jobList->remove($job); diff --git a/lib/public/backgroundjob/ijob.php b/lib/public/backgroundjob/ijob.php new file mode 100644 index 00000000000..eaf11c4f684 --- /dev/null +++ b/lib/public/backgroundjob/ijob.php @@ -0,0 +1,43 @@ +<?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 OCP\BackgroundJob; + +interface IJob { + /** + * Run the background job with the registered argument + * + * @param \OCP\BackgroundJob\IJobList $jobList The job list that manages the state of this job + * @param \OC\Log $logger + * @return void + */ + public function execute($jobList, $logger = null); + + /** + * Get the id of the background job + * This id is determined by the job list when a job is added to the list + * + * @return int + */ + public function getId(); + + /** + * Get the last time this job was run as unix timestamp + * + * @return int + */ + public function getLastRun(); + + /** + * Get the argument associated with the background job + * This is the argument that will be passed to the background job + * + * @return mixed + */ + public function getArgument(); +} diff --git a/lib/public/backgroundjob/ijoblist.php b/lib/public/backgroundjob/ijoblist.php new file mode 100644 index 00000000000..c9b546605b8 --- /dev/null +++ b/lib/public/backgroundjob/ijoblist.php @@ -0,0 +1,82 @@ +<?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 OCP\BackgroundJob; + +interface IJobList { + /** + * Add a job to the list + * + * @param \OCP\BackgroundJob\IJob |string $job + * @param mixed $argument The argument to be passed to $job->run() when the job is exectured + * @param string $job + * @return void + */ + public function add($job, $argument = null); + + /** + * Remove a job from the list + * + * @param IJob $job + * @param mixed $argument + * @return void + */ + public function remove($job, $argument = null); + + /** + * check if a job is in the list + * + * @param $job + * @param mixed $argument + * @return bool + */ + public function has($job, $argument); + + /** + * get all jobs in the list + * + * @return \OCP\BackgroundJob\IJob[] + */ + public function getAll(); + + /** + * get the next job in the list + * + * @return \OCP\BackgroundJob\IJob + */ + public function getNext(); + + /** + * @param int $id + * @return \OCP\BackgroundJob\IJob + */ + public function getById($id); + + /** + * set the job that was last ran to the current time + * + * @param \OCP\BackgroundJob\IJob $job + * @return void + */ + public function setLastJob($job); + + /** + * get the id of the last ran job + * + * @return int + */ + public function getLastJob(); + + /** + * set the lastRun of $job to now + * + * @param \OCP\BackgroundJob\IJob $job + * @return void + */ + public function setLastRun($job); +} diff --git a/lib/public/config.php b/lib/public/config.php index d9355a0605f..bb973939f44 100644 --- a/lib/public/config.php +++ b/lib/public/config.php @@ -42,7 +42,7 @@ class Config { /** * Gets a value from config.php * @param string $key key - * @param string $default = null default value + * @param mixed $default = null default value * @return string the value or $default * * This function gets the value from config.php. If it does not exist, @@ -55,7 +55,7 @@ class Config { /** * Sets a value * @param string $key key - * @param string $value value + * @param mixed $value value * @return bool * * This function sets the value and writes the config.php. If the file can @@ -89,7 +89,7 @@ class Config { * @param string $app app * @param string $key key * @param string $value value - * @return string true/false + * @return boolean true/false * * Sets a value. If the key did not exist before it will be created. */ diff --git a/lib/public/contacts/imanager.php b/lib/public/contacts/imanager.php index 973d48be5ec..5b9d64ecc41 100644 --- a/lib/public/contacts/imanager.php +++ b/lib/public/contacts/imanager.php @@ -96,7 +96,7 @@ namespace OCP\Contacts { * This function can be used to delete the contact identified by the given id * * @param object $id the unique identifier to a contact - * @param $address_book_key + * @param $address_book_key * @return bool successful or not */ function delete($id, $address_book_key); @@ -106,7 +106,7 @@ namespace OCP\Contacts { * Otherwise the contact will be updated by replacing the entire data set. * * @param array $properties this array if key-value-pairs defines a contact - * @param $address_book_key string to identify the address book in which the contact shall be created or updated + * @param $address_book_key string to identify the address book in which the contact shall be created or updated * @return array representing the contact just created or updated */ function createOrUpdate($properties, $address_book_key); @@ -122,6 +122,7 @@ namespace OCP\Contacts { * Registers an address book * * @param \OCP\IAddressBook $address_book + * @return void */ function registerAddressBook(\OCP\IAddressBook $address_book); @@ -129,6 +130,7 @@ namespace OCP\Contacts { * Unregisters an address book * * @param \OCP\IAddressBook $address_book + * @return void */ function unregisterAddressBook(\OCP\IAddressBook $address_book); @@ -138,6 +140,7 @@ namespace OCP\Contacts { * * @param string $key * @param \Closure $callable + * @return void */ function register($key, \Closure $callable); @@ -148,6 +151,7 @@ namespace OCP\Contacts { /** * removes all registered address book instances + * @return void */ function clear(); } diff --git a/lib/public/db.php b/lib/public/db.php index 4a19d78d444..cb876b4d1f9 100644 --- a/lib/public/db.php +++ b/lib/public/db.php @@ -39,7 +39,7 @@ class DB { * @param string $query Query string * @param int $limit Limit of the SQL statement * @param int $offset Offset of the SQL statement - * @return \Doctrine\DBAL\Statement prepared SQL query + * @return \OC_DB_StatementWrapper prepared SQL query * * SQL query via Doctrine prepare(), needs to be execute()'d! */ @@ -49,7 +49,7 @@ class DB { /** * Insert a row if a matching row doesn't exists. - * @param $table string The table name (will replace *PREFIX*) to perform the replace on. + * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix * @param $input array * * The input array if in the form: @@ -70,8 +70,8 @@ class DB { /** * Gets last value of autoincrement - * @param $table string The optional table name (will replace *PREFIX*) and add sequence suffix - * @return int + * @param string $table The optional table name (will replace *PREFIX*) and add sequence suffix + * @return string * * \Doctrine\DBAL\Connection lastInsertID() * diff --git a/lib/public/files.php b/lib/public/files.php index d36d74fdf77..e2d9c81d442 100644 --- a/lib/public/files.php +++ b/lib/public/files.php @@ -37,7 +37,6 @@ namespace OCP; class Files { /** * Recusive deletion of folders - * @param string path to the folder * @return bool */ static function rmdirr( $dir ) { @@ -46,7 +45,7 @@ class Files { /** * Get the mimetype form a local file - * @param string path + * @param string $path * @return string * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead */ @@ -56,7 +55,7 @@ class Files { /** * Search for files by mimetype - * @param string mimetype + * @param string $mimetype * @return array */ static public function searchByMime( $mimetype ) { @@ -65,8 +64,8 @@ class Files { /** * Copy the contents of one stream to another - * @param resource source - * @param resource target + * @param resource $source + * @param resource $target * @return int the number of bytes copied */ public static function streamCopy( $source, $target ) { @@ -76,7 +75,7 @@ class Files { /** * Create a temporary file with an unique filename - * @param string postfix + * @param string $postfix * @return string * * temporary files are automatically cleaned up after the script is finished @@ -97,8 +96,8 @@ class Files { /** * Adds a suffix to the name in case the file exists - * @param string path - * @param string filename + * @param string $path + * @param string $filename * @return string */ public static function buildNotExistingFileName( $path, $filename ) { @@ -108,7 +107,7 @@ class Files { /** * Gets the Storage for an app - creates the needed folder if they are not * existant - * @param string appid + * @param string $app * @return \OC\Files\View */ public static function getStorage( $app ) { diff --git a/lib/public/files/file.php b/lib/public/files/file.php index c6cda59f9b0..6208aeff426 100644 --- a/lib/public/files/file.php +++ b/lib/public/files/file.php @@ -43,6 +43,7 @@ interface File extends Node { * * @param string $data * @throws \OCP\Files\NotPermittedException + * @return void */ public function putContent($data); diff --git a/lib/public/files/fileinfo.php b/lib/public/files/fileinfo.php new file mode 100644 index 00000000000..68ce45d3fa1 --- /dev/null +++ b/lib/public/files/fileinfo.php @@ -0,0 +1,138 @@ +<?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 OCP\Files; + +interface FileInfo { + const TYPE_FILE = 'file'; + const TYPE_FOLDER = 'folder'; + + /** + * Get the Etag of the file or folder + * + * @return string + */ + public function getEtag(); + + /** + * Get the size in bytes for the file or folder + * + * @return int + */ + public function getSize(); + + /** + * Get the last modified date as timestamp for the file or folder + * + * @return int + */ + public function getMtime(); + + /** + * Get the name of the file or folder + * + * @return string + */ + public function getName(); + + /** + * Get the path relative to the storage + * + * @return string + */ + public function getInternalPath(); + + /** + * Get the absolute path + * + * @return string + */ + public function getPath(); + + /** + * Get the full mimetype of the file or folder i.e. 'image/png' + * + * @return string + */ + public function getMimetype(); + + /** + * Get the first part of the mimetype of the file or folder i.e. 'image' + * + * @return string + */ + public function getMimePart(); + + /** + * Get the storage the file or folder is storage on + * + * @return \OCP\Files\Storage + */ + public function getStorage(); + + /** + * Get the file id of the file or folder + * + * @return int + */ + public function getId(); + + /** + * Check whether the file is encrypted + * + * @return bool + */ + public function isEncrypted(); + + /** + * Get the permissions of the file or folder as bitmasked combination of the following constants + * \OCP\PERMISSION_CREATE + * \OCP\PERMISSION_READ + * \OCP\PERMISSION_UPDATE + * \OCP\PERMISSION_DELETE + * \OCP\PERMISSION_SHARE + * \OCP\PERMISSION_ALL + * + * @return int + */ + public function getPermissions(); + + /** + * Check whether this is a file or a folder + * + * @return \OCP\Files\FileInfo::TYPE_FILE | \OCP\Files\FileInfo::TYPE_FOLDER + */ + public function getType(); + + /** + * Check if the file or folder is readable + * + * @return bool + */ + public function isReadable(); + + /** + * Check if a file is writable + * + * @return bool + */ + public function isUpdateable(); + + /** + * Check if a file or folder can be deleted + * + * @return bool + */ + public function isDeletable(); + + /** + * Check if a file or folder can be shared + * + * @return bool + */ + public function isShareable(); +} diff --git a/lib/public/files/node.php b/lib/public/files/node.php index 972b1cfa492..a380394095b 100644 --- a/lib/public/files/node.php +++ b/lib/public/files/node.php @@ -41,6 +41,7 @@ interface Node { /** * Delete the file or folder + * @return void */ public function delete(); @@ -58,6 +59,7 @@ interface Node { * * @param int $mtime (optional) modified date as unix timestamp * @throws \OCP\Files\NotPermittedException + * @return void */ public function touch($mtime = null); diff --git a/lib/public/files/storage.php b/lib/public/files/storage.php index fe30f8f50af..5ec8ac6245c 100644 --- a/lib/public/files/storage.php +++ b/lib/public/files/storage.php @@ -39,6 +39,7 @@ interface Storage { * $parameters is a free form array with the configuration options needed to construct the storage * * @param array $parameters + * @return void */ public function __construct($parameters); diff --git a/lib/public/iappconfig.php b/lib/public/iappconfig.php new file mode 100644 index 00000000000..1f31898bf2c --- /dev/null +++ b/lib/public/iappconfig.php @@ -0,0 +1,93 @@ +<?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 OCP; + +/** + * This class provides an easy way for apps to store config values in the + * database. + */ +interface IAppConfig { + /** + * @brief check if a key is set in the appconfig + * @param string $app + * @param string $key + * @return bool + */ + public function hasKey($app, $key); + + /** + * @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 function getValue($app, $key, $default = null); + + /** + * @brief Deletes a key + * @param string $app app + * @param string $key key + * @return bool + * + * Deletes a key. + */ + public function deleteKey($app, $key); + + /** + * @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 function getKeys($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 $key + * @return array + */ + public function getValues($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. + * @return void + */ + public function setValue($app, $key, $value); + + /** + * @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 function getApps(); + + /** + * @brief Remove app from appconfig + * @param string $app app + * @return bool + * + * Removes all keys in appconfig belonging to the app. + */ + public function deleteApp($app); +} diff --git a/lib/public/iavatar.php b/lib/public/iavatar.php index 2cbec0d45c3..43fa32556de 100644 --- a/lib/public/iavatar.php +++ b/lib/public/iavatar.php @@ -22,7 +22,7 @@ interface IAvatar { /** * @brief sets the users avatar - * @param $data mixed imagedata or path to set a new avatar + * @param Image $data mixed imagedata or path to set a new avatar * @throws Exception if the provided file is not a jpg or png image * @throws Exception if the provided image is not valid * @throws \OCP\NotSquareException if the image is not square diff --git a/lib/public/iconfig.php b/lib/public/iconfig.php index 1d0f8e0015c..0ebbd9f5a71 100644 --- a/lib/public/iconfig.php +++ b/lib/public/iconfig.php @@ -38,7 +38,7 @@ interface 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); @@ -59,6 +59,7 @@ interface IConfig { * @param string $appName the appName that we want to store the value under * @param string $key the key of the value, under which will be saved * @param string $value the value that should be stored + * @return void */ public function setAppValue($appName, $key, $value); @@ -80,6 +81,7 @@ interface IConfig { * @param string $appName the appName that we want to store the value under * @param string $key the key under which the value is being stored * @param string $value the value that you want to store + * @return void */ public function setUserValue($userId, $appName, $key, $value); @@ -90,6 +92,7 @@ interface IConfig { * @param string $appName the appName that we stored the value under * @param string $key the key under which the value is being stored * @param string $default the default value to be returned if the value isn't set + * @return string */ public function getUserValue($userId, $appName, $key, $default = ''); } diff --git a/lib/public/il10n.php b/lib/public/il10n.php index 817b299b0b7..1c025e7824f 100644 --- a/lib/public/il10n.php +++ b/lib/public/il10n.php @@ -25,7 +25,7 @@ interface IL10N { * Translating * @param $text String The text we need a translation for * @param array $parameters default:array() Parameters for sprintf - * @return \OC_L10N_String|string Translation or the same text + * @return \OC_L10N_String Translation or the same text * * Returns the translation. If no translation is found, $text will be * returned. @@ -38,7 +38,7 @@ interface IL10N { * @param $text_plural String the string to translate for n objects * @param $count Integer Number of objects * @param array $parameters default:array() Parameters for sprintf - * @return \OC_L10N_String|string Translation or the same text + * @return \OC_L10N_String Translation or the same text * * Returns the translation. If no translation is found, $text will be * returned. %n will be replaced with the number of objects. diff --git a/lib/public/inavigationmanager.php b/lib/public/inavigationmanager.php index 73e85d03761..9497d3fd08e 100644 --- a/lib/public/inavigationmanager.php +++ b/lib/public/inavigationmanager.php @@ -37,12 +37,14 @@ interface INavigationManager { /** * Creates a new navigation entry * @param array $entry containing: id, name, order, icon and href key + * @return void */ public function add(array $entry); /** * Sets the current navigation entry of the currently running app * @param string $appId id of the app entry to activate (from added $entry) + * @return void */ public function setActiveEntry($appId); } diff --git a/lib/public/irequest.php b/lib/public/irequest.php index ca23e12b7f5..d77a9bc887a 100644 --- a/lib/public/irequest.php +++ b/lib/public/irequest.php @@ -55,6 +55,11 @@ namespace OCP; interface IRequest { + /** + * @param string $name + * + * @return string + */ function getHeader($name); /** diff --git a/lib/public/iservercontainer.php b/lib/public/iservercontainer.php index 5473f3ee334..5fb51f9ecd5 100644 --- a/lib/public/iservercontainer.php +++ b/lib/public/iservercontainer.php @@ -114,6 +114,13 @@ interface IServerContainer { function getConfig(); /** + * Returns the app config manager + * + * @return \OCP\IAppConfig + */ + function getAppConfig(); + + /** * get an L10N instance * @param $app string appid * @return \OCP\IL10N @@ -176,4 +183,11 @@ interface IServerContainer { */ function getAvatarManager(); + /** + * Returns an job list for controlling background jobs + * + * @return \OCP\BackgroundJob\IJobList + */ + function getJobList(); + } diff --git a/lib/public/itags.php b/lib/public/itags.php index ea62fb38ecb..f8ebaa668f1 100644 --- a/lib/public/itags.php +++ b/lib/public/itags.php @@ -49,7 +49,7 @@ interface ITags { /** * Check if any tags are saved for this type and user. * - * @return boolean. + * @return boolean */ public function isEmpty(); @@ -147,7 +147,7 @@ interface 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); @@ -156,7 +156,7 @@ interface 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/public/iusersession.php b/lib/public/iusersession.php index 131b326ab90..adc706cc7c3 100644 --- a/lib/public/iusersession.php +++ b/lib/public/iusersession.php @@ -45,6 +45,7 @@ interface IUserSession { /** * Logs the user out including all the session data * Logout, destroys session + * @return void */ public function logout(); diff --git a/lib/public/json.php b/lib/public/json.php index cd5d233ef90..e7371ad63f3 100644 --- a/lib/public/json.php +++ b/lib/public/json.php @@ -81,7 +81,7 @@ class JSON { * parameter to the ajax call, then assign it to the template and finally * add a hidden input field also named 'requesttoken' containing the value. * - * @return string json formatted error string if not valid. + * @return \json|null json formatted error string if not valid. */ public static function callCheck() { return(\OC_JSON::callCheck()); diff --git a/lib/public/share.php b/lib/public/share.php index ae7d29e8b87..ebc555dba5f 100644 --- a/lib/public/share.php +++ b/lib/public/share.php @@ -78,7 +78,10 @@ class Share { * @param string Backend class * @param string (optional) Depends on item type * @param array (optional) List of supported file extensions if this item type depends on files - * @return Returns true if backend is registered or false if error + * @param string $itemType + * @param string $class + * @param string $collectionOf + * @return boolean true if backend is registered or false if error */ public static function registerBackend($itemType, $class, $collectionOf = null, $supportedFileExtensions = null) { if (self::isEnabled()) { @@ -104,7 +107,7 @@ class Share { /** * Check if the Share API is enabled - * @return Returns true if enabled or false + * @return boolean true if enabled or false * * The Share API is enabled by default if not configured */ @@ -135,7 +138,7 @@ class Share { /** * Find which users can access a shared item - * @param $path to the file + * @param string $path to the file * @param $user owner of the file * @param include owner to the list of users with access to the file * @return array @@ -247,6 +250,7 @@ class Share { * @param mixed Parameters (optional) * @param int Number of items to return (optional) Returns all by default * @param bool include collections (optional) + * @param string $itemType * @return Return depends on format */ public static function getItemsSharedWith($itemType, $format = self::FORMAT_NONE, @@ -262,7 +266,7 @@ class Share { * @param int $format (optional) Format type must be defined by the backend * @param mixed Parameters (optional) * @param bool include collections (optional) - * @return Return depends on format + * @return string depends on format */ public static function getItemSharedWith($itemType, $itemTarget, $format = self::FORMAT_NONE, $parameters = null, $includeCollections = false) { @@ -403,6 +407,7 @@ class Share { * @param mixed Parameters * @param int Number of items to return (optional) Returns all by default * @param bool include collections + * @param string $itemType * @return Return depends on format */ public static function getItemsShared($itemType, $format = self::FORMAT_NONE, $parameters = null, @@ -646,7 +651,7 @@ class Share { * @param string Item source * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK * @param string User or group the item is being shared with - * @return Returns true on success or false on failure + * @return boolean true on success or false on failure */ public static function unshare($itemType, $itemSource, $shareType, $shareWith) { if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, \OC_User::getUser(), @@ -661,7 +666,9 @@ class Share { * Unshare an item from all users, groups, and remove all links * @param string Item type * @param string Item source - * @return Returns true on success or false on failure + * @param string $itemType + * @param string $itemSource + * @return boolean true on success or false on failure */ public static function unshareAll($itemType, $itemSource) { // Get all of the owners of shares of this item. @@ -693,7 +700,9 @@ class Share { * Unshare an item shared with the current user * @param string Item type * @param string Item target - * @return Returns true on success or false on failure + * @param string $itemType + * @param string $itemTarget + * @return boolean true on success or false on failure * * Unsharing from self is not allowed for items inside collections */ @@ -749,12 +758,12 @@ class Share { /** * Set the permissions of an item for a specific user or group - * @param string Item type - * @param string Item source - * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK - * @param string User or group the item is being shared with - * @param int CRUDS permissions - * @return Returns true on success or false on failure + * @param string $itemType Item type + * @param string $itemSource Item source + * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK + * @param string $shareWith User or group the item is being shared with + * @param integer|null $permissions CRUDS + * @return boolean true on success or false on failure */ public static function setPermissions($itemType, $itemSource, $shareType, $shareWith, $permissions) { if ($item = self::getItems($itemType, $itemSource, $shareType, $shareWith, @@ -836,7 +845,7 @@ class Share { * @param string $itemType * @param string $itemSource * @param string $date expiration date - * @return Share_Backend + * @return boolean */ public static function setExpirationDate($itemType, $itemSource, $date) { if ($items = self::getItems($itemType, $itemSource, null, null, \OC_User::getUser(), @@ -930,7 +939,7 @@ class Share { /** * Check if resharing is allowed - * @return Returns true if allowed or false + * @return boolean true if allowed or false * * Resharing is allowed by default if not configured */ @@ -1380,15 +1389,15 @@ class Share { /** * Put shared item into the database - * @param string Item type - * @param string Item source - * @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK - * @param string User or group the item is being shared with - * @param string User that is the owner of shared item - * @param int CRUDS permissions - * @param bool|array Parent folder target (optional) - * @param string token (optional) - * @param string name of the source item (optional) + * @param string $itemType Item type + * @param string $itemSource Item source + * @param integer $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK + * @param string $shareWith User or group the item is being shared with + * @param string $uidOwner User that is the owner of shared item + * @param int $permissions CRUDS permissions + * @param bool|array, $parentFolder Parent folder target (optional) + * @param string $token (optional) + * @param string $itemSourceName name of the source item (optional) * @return bool Returns true on success or false on failure */ private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, @@ -1629,6 +1638,7 @@ class Share { * @param string User that is the owner of shared item * @param string The suggested target originating from a reshare (optional) * @param int The id of the parent group share (optional) + * @param integer $shareType * @return string Item target */ private static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, @@ -1936,7 +1946,9 @@ interface Share_Backend { * Get the source of the item to be stored in the database * @param string Item source * @param string Owner of the item - * @return mixed|array|false Source + * @param string $itemSource + * @param string $uidOwner + * @return boolean Source * * Return an array if the item is file dependent, the array needs two keys: 'item' and 'file' * Return false if the item does not exist for the user @@ -1959,8 +1971,8 @@ interface Share_Backend { /** * Converts the shared item sources back into the item in the specified format - * @param array Shared items - * @param int Format + * @param array $items Shared items + * @param integer $format * @return TODO * * The items array is a 3-dimensional array with the item_source as the @@ -1992,6 +2004,9 @@ interface Share_Backend_File_Dependent extends Share_Backend { * Get the file path of the item * @param string Item source * @param string User that is the owner of shared item + * @param string $itemSource + * @param string $uidOwner + * @return boolean */ public function getFilePath($itemSource, $uidOwner); diff --git a/lib/public/template.php b/lib/public/template.php index 320b7c6393f..9a994c1bea8 100644 --- a/lib/public/template.php +++ b/lib/public/template.php @@ -35,7 +35,7 @@ namespace OCP; * Make OC_Helper::imagePath available as a simple function * @param string app * @param string image - * @return link to the image + * @return string to the image * * @see OC_Helper::imagePath */ @@ -47,7 +47,7 @@ function image_path( $app, $image ) { /** * Make OC_Helper::mimetypeIcon available as a simple function * @param string mimetype - * @return path to the image of this file type. + * @return string to the image of this file type. */ function mimetype_icon( $mimetype ) { return(\mimetype_icon( $mimetype )); @@ -56,7 +56,7 @@ function mimetype_icon( $mimetype ) { /** * Make preview_icon available as a simple function * @param string path of file - * @return path to the preview of the image + * @return string to the preview of the image */ function preview_icon( $path ) { return(\preview_icon( $path )); @@ -65,8 +65,8 @@ function preview_icon( $path ) { /** * Make publicpreview_icon available as a simple function * Returns the path to the preview of the image. - * @param string path of file - * @param string token + * @param string $path of file + * @param string $token * @return link to the preview */ function publicPreview_icon ( $path, $token ) { @@ -77,7 +77,7 @@ function publicPreview_icon ( $path, $token ) { * Make OC_Helper::humanFileSize available as a simple function * Example: 2048 to 2 kB. * @param int size in bytes - * @return size as string + * @return string size as string */ function human_file_size( $bytes ) { return(\human_file_size( $bytes )); @@ -88,7 +88,7 @@ function human_file_size( $bytes ) { * Return the relative date in relation to today. Returns something like "last hour" or "two month ago" * @param int unix timestamp * @param boolean date only - * @return human readable interpretation of the timestamp + * @return OC_L10N_String human readable interpretation of the timestamp */ function relative_modified_date( $timestamp, $dateOnly = false ) { return(\relative_modified_date($timestamp, null, $dateOnly)); @@ -99,7 +99,7 @@ function relative_modified_date( $timestamp, $dateOnly = false ) { * Return a human readable outout for a file size. * @deprecated human_file_size() instead * @param integer size of a file in byte - * @return human readable interpretation of a file size + * @return string human readable interpretation of a file size */ function simple_file_size($bytes) { return(\human_file_size($bytes)); @@ -111,7 +111,7 @@ function simple_file_size($bytes) { * @param $options the options * @param $selected which one is selected? * @param array the parameters - * @return html options + * @return string html options */ function html_select_options($options, $selected, $params=array()) { return(\html_select_options($options, $selected, $params)); diff --git a/lib/public/user.php b/lib/public/user.php index acc0e3b737b..7bac938b838 100644 --- a/lib/public/user.php +++ b/lib/public/user.php @@ -46,8 +46,8 @@ class User { /** * Get a list of all users * @param string search pattern - * @param int limit - * @param int offset + * @param integer $limit + * @param integer $offset * @return array with all uids */ public static function getUsers( $search = '', $limit = null, $offset = null ) { @@ -101,9 +101,9 @@ class User { /** * Check if the password is correct - * @param string The username - * @param string The password - * @return mixed username on success, false otherwise + * @param string $uid The username + * @param string $password The password + * @return string|false username on success, false otherwise * * Check if the password is correct without logging in the user */ diff --git a/lib/public/util.php b/lib/public/util.php index 4611e5e2650..570283e2a8a 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -121,7 +121,7 @@ class Util { /** * get l10n object * @param string $application - * @return OC_L10N + * @return \OC_L10N */ public static function getL10N( $application ) { return \OC_L10N::get( $application ); diff --git a/ocs/providers.php b/ocs/providers.php index bf94b85dcfb..2c62f767ad3 100644 --- a/ocs/providers.php +++ b/ocs/providers.php @@ -23,6 +23,8 @@ require_once '../lib/base.php'; +header('Content-type: application/xml'); + $url=OCP\Util::getServerProtocol().'://'.substr(OCP\Util::getServerHost().OCP\Util::getRequestUri(), 0, -17).'ocs/v1.php/'; echo(' diff --git a/remote.php b/remote.php index 2d0088cd903..7884695b3a5 100644 --- a/remote.php +++ b/remote.php @@ -14,7 +14,7 @@ try { } $service=substr($path_info, 1, $pos-1); - $file = OC_AppConfig::getValue('core', 'remote_' . $service); + $file = \OC::$server->getAppConfig()->getValue('core', 'remote_' . $service); if(is_null($file)) { OC_Response::setStatus(OC_Response::STATUS_NOT_FOUND); diff --git a/settings/ajax/decryptall.php b/settings/ajax/decryptall.php index ebc17aacfaa..d7c104ab151 100644 --- a/settings/ajax/decryptall.php +++ b/settings/ajax/decryptall.php @@ -16,7 +16,14 @@ $util = new \OCA\Encryption\Util($view, \OCP\User::getUser()); $result = $util->initEncryption($params); if ($result !== false) { - $successful = $util->decryptAll(); + + try { + $successful = $util->decryptAll(); + } catch (\Exception $ex) { + \OCP\Util::writeLog('encryption library', "Decryption finished unexpected: " . $ex->getMessage(), \OCP\Util::ERROR); + $successful = false; + } + if ($successful === true) { \OCP\JSON::success(array('data' => array('message' => 'Files decrypted successfully'))); } else { diff --git a/settings/js/personal.js b/settings/js/personal.js index 3b876467756..ef261b50bbc 100644 --- a/settings/js/personal.js +++ b/settings/js/personal.js @@ -163,7 +163,7 @@ $(document).ready(function(){ }); - $('#email').keyup(function(){ + $('#email').keyup(function(event){ if ($('#email').val() !== '' ){ // if this is the enter key changeEmailAddress() is already invoked // so it doesn't need to be triggered again diff --git a/settings/templates/personal.php b/settings/templates/personal.php index 31ae3a991b6..188ff75f96b 100644 --- a/settings/templates/personal.php +++ b/settings/templates/personal.php @@ -40,10 +40,12 @@ if($_['passwordChangeSupported']) { <div id="passwordchanged"><?php echo $l->t('Your password was changed');?></div> <div id="passworderror"><?php echo $l->t('Unable to change your password');?></div> <input type="password" id="pass1" name="oldpassword" - placeholder="<?php echo $l->t('Current password');?>" autocomplete="off" /> + placeholder="<?php echo $l->t('Current password');?>" + autocomplete="off" autocapitalize="off" autocorrect="off" /> <input type="password" id="pass2" name="personal-password" placeholder="<?php echo $l->t('New password');?>" - data-typetoggle="#personal-show" autocomplete="off" /> + data-typetoggle="#personal-show" + autocomplete="off" autocapitalize="off" autocorrect="off" /> <input type="checkbox" id="personal-show" name="show" /><label for="personal-show"></label> <input id="passwordbutton" type="submit" value="<?php echo $l->t('Change password');?>" /> <br/> @@ -60,7 +62,9 @@ if($_['displayNameChangeSupported']) { <form id="displaynameform"> <fieldset class="personalblock"> <h2><?php echo $l->t('Full Name');?></h2> - <input type="text" id="displayName" name="displayName" value="<?php p($_['displayName'])?>" /> + <input type="text" id="displayName" name="displayName" + value="<?php p($_['displayName'])?>" + autocomplete="on" autocapitalize="off" autocorrect="off" /> <span class="msg"></span> <input type="hidden" id="oldDisplayName" name="oldDisplayName" value="<?php p($_['displayName'])?>" /> </fieldset> @@ -76,7 +80,9 @@ if($_['passwordChangeSupported']) { <fieldset class="personalblock"> <h2><?php p($l->t('Email'));?></h2> <input type="text" name="email" id="email" value="<?php p($_['email']); ?>" - placeholder="<?php p($l->t('Your email address'));?>" /><span class="msg"></span><br /> + placeholder="<?php p($l->t('Your email address'));?>" + autocomplete="on" autocapitalize="off" autocorrect="off" /> + <span class="msg"></span><br /> <em><?php p($l->t('Fill in an email address to enable password recovery'));?></em> </fieldset> </form> diff --git a/tests/lib/api.php b/tests/lib/api.php index 9c4324e63e0..233beebd68a 100644 --- a/tests/lib/api.php +++ b/tests/lib/api.php @@ -9,6 +9,10 @@ class Test_API extends PHPUnit_Framework_TestCase { // Helps build a response variable + + /** + * @param string $message + */ function buildResponse($shipped, $data, $code, $message=null) { return array( 'shipped' => $shipped, @@ -18,6 +22,10 @@ class Test_API extends PHPUnit_Framework_TestCase { } // Validate details of the result + + /** + * @param OC_OCS_Result $result + */ function checkResult($result, $success) { // Check response is of correct type $this->assertInstanceOf('OC_OCS_Result', $result); diff --git a/tests/lib/appconfig.php b/tests/lib/appconfig.php index 23dd2549e32..6ae790a9edd 100644 --- a/tests/lib/appconfig.php +++ b/tests/lib/appconfig.php @@ -1,6 +1,7 @@ <?php /** * Copyright (c) 2013 Christopher Schäpers <christopher@schaepers.it> + * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. @@ -41,6 +42,7 @@ class Test_Appconfig extends PHPUnit_Framework_TestCase { while ($row = $result->fetchRow()) { $expected[] = $row['appid']; } + sort($expected); $apps = \OC_Appconfig::getApps(); $this->assertEquals($expected, $apps); } @@ -52,6 +54,7 @@ class Test_Appconfig extends PHPUnit_Framework_TestCase { while($row = $result->fetchRow()) { $expected[] = $row["configkey"]; } + sort($expected); $keys = \OC_Appconfig::getKeys('testapp'); $this->assertEquals($expected, $keys); } diff --git a/tests/lib/appframework/http/DispatcherTest.php b/tests/lib/appframework/http/DispatcherTest.php index 6cf0da879ff..9841dcaa1f7 100644 --- a/tests/lib/appframework/http/DispatcherTest.php +++ b/tests/lib/appframework/http/DispatcherTest.php @@ -24,7 +24,6 @@ namespace OC\AppFramework\Http; -use OC\AppFramework\Core\API; use OC\AppFramework\Middleware\MiddlewareDispatcher; use OCP\AppFramework\Http; //require_once(__DIR__ . "/../classloader.php"); @@ -78,6 +77,10 @@ class DispatcherTest extends \PHPUnit_Framework_TestCase { } + /** + * @param string $out + * @param string $httpHeaders + */ private function setMiddlewareExpections($out=null, $httpHeaders=null, $responseHeaders=array(), $ex=false, $catchEx=true) { diff --git a/tests/lib/appframework/http/ResponseTest.php b/tests/lib/appframework/http/ResponseTest.php index 1a38c38c1e7..4f21d77a170 100644 --- a/tests/lib/appframework/http/ResponseTest.php +++ b/tests/lib/appframework/http/ResponseTest.php @@ -25,8 +25,8 @@ namespace OC\AppFramework\Http; -use OCP\AppFramework\Http\Response, - OCP\AppFramework\Http; +use OCP\AppFramework\Http\Response; +use OCP\AppFramework\Http; class ResponseTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/lib/appframework/middleware/MiddlewareDispatcherTest.php b/tests/lib/appframework/middleware/MiddlewareDispatcherTest.php index 95d42e4eb8e..f16b14150c3 100644 --- a/tests/lib/appframework/middleware/MiddlewareDispatcherTest.php +++ b/tests/lib/appframework/middleware/MiddlewareDispatcherTest.php @@ -50,6 +50,9 @@ class TestMiddleware extends Middleware { private $beforeControllerThrowsEx; + /** + * @param boolean $beforeControllerThrowsEx + */ public function __construct($beforeControllerThrowsEx) { self::$beforeControllerCalled = 0; self::$afterControllerCalled = 0; diff --git a/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php b/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php index dae6135dc54..63c48a62829 100644 --- a/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php +++ b/tests/lib/appframework/middleware/security/SecurityMiddlewareTest.php @@ -58,6 +58,9 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { } + /** + * @param string $method + */ private function checkNavEntry($method){ $api = $this->getAPI(); @@ -79,6 +82,10 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { } + /** + * @param string $method + * @param string $test + */ private function ajaxExceptionStatus($method, $test, $status) { $api = $this->getAPI(); $api->expects($this->any()) @@ -183,6 +190,10 @@ class SecurityMiddlewareTest extends \PHPUnit_Framework_TestCase { } + /** + * @param string $method + * @param string $expects + */ private function securityCheck($method, $expects, $shouldFail=false){ $api = $this->getAPI(); $api->expects($this->once()) diff --git a/tests/lib/appframework/routing/RoutingTest.php b/tests/lib/appframework/routing/RoutingTest.php index a7aa922db12..d0244cf2511 100644 --- a/tests/lib/appframework/routing/RoutingTest.php +++ b/tests/lib/appframework/routing/RoutingTest.php @@ -78,6 +78,13 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase $this->assertResource($routes, 'admin_accounts', '/admin/accounts', 'AdminAccountsController', 'adminAccountId'); } + /** + * @param string $name + * @param string $verb + * @param string $url + * @param string $controllerName + * @param string $actionName + */ private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName) { // route mocks @@ -100,6 +107,12 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase $config->register(); } + /** + * @param string $resourceName + * @param string $url + * @param string $controllerName + * @param string $paramName + */ private function assertResource($yaml, $resourceName, $url, $controllerName, $paramName) { // router mock diff --git a/tests/lib/backgroundjob/dummyjoblist.php b/tests/lib/backgroundjob/dummyjoblist.php index e1579c273bb..7801269b27e 100644 --- a/tests/lib/backgroundjob/dummyjoblist.php +++ b/tests/lib/backgroundjob/dummyjoblist.php @@ -21,6 +21,8 @@ class DummyJobList extends \OC\BackgroundJob\JobList { private $last = 0; + public function __construct(){} + /** * @param \OC\BackgroundJob\Job|string $job * @param mixed $argument diff --git a/tests/lib/backgroundjob/job.php b/tests/lib/backgroundjob/job.php index 7d66fa772d2..10a8f46462e 100644 --- a/tests/lib/backgroundjob/job.php +++ b/tests/lib/backgroundjob/job.php @@ -8,31 +8,6 @@ namespace Test\BackgroundJob; - -class TestJob extends \OC\BackgroundJob\Job { - private $testCase; - - /** - * @var callable $callback - */ - private $callback; - - /** - * @param Job $testCase - * @param callable $callback - */ - public function __construct($testCase, $callback) { - $this->testCase = $testCase; - $this->callback = $callback; - } - - public function run($argument) { - $this->testCase->markRun(); - $callback = $this->callback; - $callback($argument); - } -} - class Job extends \PHPUnit_Framework_TestCase { private $run = false; diff --git a/tests/lib/backgroundjob/joblist.php b/tests/lib/backgroundjob/joblist.php new file mode 100644 index 00000000000..c3318f80cb2 --- /dev/null +++ b/tests/lib/backgroundjob/joblist.php @@ -0,0 +1,203 @@ +<?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 Test\BackgroundJob; + +class JobList extends \PHPUnit_Framework_TestCase { + /** + * @var \OC\BackgroundJob\JobList + */ + protected $instance; + + /** + * @var \OCP\IConfig | \PHPUnit_Framework_MockObject_MockObject $config + */ + protected $config; + + public function setUp() { + $conn = \OC::$server->getDatabaseConnection(); + $this->config = $this->getMock('\OCP\IConfig'); + $this->instance = new \OC\BackgroundJob\JobList($conn, $this->config); + } + + public function argumentProvider() { + return array( + array(null), + array(false), + array('foobar'), + array(12), + array(array( + 'asd' => 5, + 'foo' => 'bar' + )) + ); + } + + /** + * @dataProvider argumentProvider + * @param $argument + */ + public function testAddRemove($argument) { + $existingJobs = $this->instance->getAll(); + $job = new TestJob(); + $this->instance->add($job, $argument); + + $jobs = $this->instance->getAll(); + + $this->assertCount(count($existingJobs) + 1, $jobs); + $addedJob = $jobs[count($jobs) - 1]; + $this->assertInstanceOf('\Test\BackgroundJob\TestJob', $addedJob); + $this->assertEquals($argument, $addedJob->getArgument()); + + $this->instance->remove($job, $argument); + + $jobs = $this->instance->getAll(); + $this->assertEquals($existingJobs, $jobs); + } + + /** + * @dataProvider argumentProvider + * @param $argument + */ + public function testRemoveDifferentArgument($argument) { + $existingJobs = $this->instance->getAll(); + $job = new TestJob(); + $this->instance->add($job, $argument); + + $jobs = $this->instance->getAll(); + $this->instance->remove($job, 10); + $jobs2 = $this->instance->getAll(); + + $this->assertEquals($jobs, $jobs2); + + $this->instance->remove($job, $argument); + + $jobs = $this->instance->getAll(); + $this->assertEquals($existingJobs, $jobs); + } + + /** + * @dataProvider argumentProvider + * @param $argument + */ + public function testHas($argument) { + $job = new TestJob(); + $this->assertFalse($this->instance->has($job, $argument)); + $this->instance->add($job, $argument); + + $this->assertTrue($this->instance->has($job, $argument)); + + $this->instance->remove($job, $argument); + + $this->assertFalse($this->instance->has($job, $argument)); + } + + /** + * @dataProvider argumentProvider + * @param $argument + */ + public function testHasDifferentArgument($argument) { + $job = new TestJob(); + $this->instance->add($job, $argument); + + $this->assertFalse($this->instance->has($job, 10)); + + $this->instance->remove($job, $argument); + } + + public function testGetLastJob() { + $this->config->expects($this->once()) + ->method('getAppValue') + ->with('backgroundjob', 'lastjob', 0) + ->will($this->returnValue(15)); + + $this->assertEquals(15, $this->instance->getLastJob()); + } + + public function testGetNext() { + $job = new TestJob(); + $this->instance->add($job, 1); + $this->instance->add($job, 2); + + $jobs = $this->instance->getAll(); + + $savedJob1 = $jobs[count($jobs) - 2]; + $savedJob2 = $jobs[count($jobs) - 1]; + + $this->config->expects($this->once()) + ->method('getAppValue') + ->with('backgroundjob', 'lastjob', 0) + ->will($this->returnValue($savedJob1->getId())); + + $nextJob = $this->instance->getNext(); + + $this->assertEquals($savedJob2, $nextJob); + + $this->instance->remove($job, 1); + $this->instance->remove($job, 2); + } + + public function testGetNextWrapAround() { + $job = new TestJob(); + $this->instance->add($job, 1); + $this->instance->add($job, 2); + + $jobs = $this->instance->getAll(); + + $savedJob2 = $jobs[count($jobs) - 1]; + + $this->config->expects($this->once()) + ->method('getAppValue') + ->with('backgroundjob', 'lastjob', 0) + ->will($this->returnValue($savedJob2->getId())); + + $nextJob = $this->instance->getNext(); + + $this->assertEquals($jobs[0], $nextJob); + + $this->instance->remove($job, 1); + $this->instance->remove($job, 2); + } + + /** + * @dataProvider argumentProvider + * @param $argument + */ + public function testGetById($argument) { + $job = new TestJob(); + $this->instance->add($job, $argument); + + $jobs = $this->instance->getAll(); + + $addedJob = $jobs[count($jobs) - 1]; + + $this->assertEquals($addedJob, $this->instance->getById($addedJob->getId())); + + $this->instance->remove($job, $argument); + } + + public function testSetLastRun() { + $job = new TestJob(); + $this->instance->add($job); + + $jobs = $this->instance->getAll(); + + $addedJob = $jobs[count($jobs) - 1]; + + $timeStart = time(); + $this->instance->setLastRun($addedJob); + $timeEnd = time(); + + $addedJob = $this->instance->getById($addedJob->getId()); + + $this->assertGreaterThanOrEqual($timeStart, $addedJob->getLastRun()); + $this->assertLessThanOrEqual($timeEnd, $addedJob->getLastRun()); + + $this->instance->remove($job); + } +} diff --git a/tests/lib/backgroundjob/testjob.php b/tests/lib/backgroundjob/testjob.php new file mode 100644 index 00000000000..23fc4268d1a --- /dev/null +++ b/tests/lib/backgroundjob/testjob.php @@ -0,0 +1,34 @@ +<?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 Test\BackgroundJob; + + +class TestJob extends \OC\BackgroundJob\Job { + private $testCase; + + /** + * @var callable $callback + */ + private $callback; + + /** + * @param Job $testCase + * @param callable $callback + */ + public function __construct($testCase = null, $callback = null) { + $this->testCase = $testCase; + $this->callback = $callback; + } + + public function run($argument) { + $this->testCase->markRun(); + $callback = $this->callback; + $callback($argument); + } +} diff --git a/tests/lib/db.php b/tests/lib/db.php index f0b271a36f1..2fca67b5638 100644 --- a/tests/lib/db.php +++ b/tests/lib/db.php @@ -30,7 +30,7 @@ class Test_DB extends PHPUnit_Framework_TestCase { public function setUp() { $dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml'; - $r = '_'.OC_Util::generateRandomBytes('4').'_'; + $r = '_'.OC_Util::generateRandomBytes(4).'_'; $content = file_get_contents( $dbfile ); $content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content ); file_put_contents( self::$schema_file, $content ); diff --git a/tests/lib/dbschema.php b/tests/lib/dbschema.php index 4a7b7f7aac0..11e9fcdf4fa 100644 --- a/tests/lib/dbschema.php +++ b/tests/lib/dbschema.php @@ -16,7 +16,7 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase { $dbfile = OC::$SERVERROOT.'/tests/data/db_structure.xml'; $dbfile2 = OC::$SERVERROOT.'/tests/data/db_structure2.xml'; - $r = '_'.OC_Util::generateRandomBytes('4').'_'; + $r = '_'.OC_Util::generateRandomBytes(4).'_'; $content = file_get_contents( $dbfile ); $content = str_replace( '*dbprefix*', '*dbprefix*'.$r, $content ); file_put_contents( $this->schema_file, $content ); @@ -111,10 +111,16 @@ class Test_DBSchema extends PHPUnit_Framework_TestCase { } } + /** + * @param string $table + */ public function assertTableExist($table) { $this->assertTrue($this->tableExist($table), 'Table ' . $table . ' does not exist'); } + /** + * @param string $table + */ public function assertTableNotExist($table) { $type=OC_Config::getValue( "dbtype", "sqlite" ); if( $type == 'sqlite' || $type == 'sqlite3' ) { diff --git a/tests/lib/errorHandler.php b/tests/lib/errorHandler.php index 68b87deccb6..32396eafbea 100644 --- a/tests/lib/errorHandler.php +++ b/tests/lib/errorHandler.php @@ -56,6 +56,10 @@ class Test_ErrorHandler extends \PHPUnit_Framework_TestCase { * @brief dummy class to access protected methods of \OC\Log\ErrorHandler */ class TestableErrorHandler extends \OC\Log\ErrorHandler { + + /** + * @param string $msg + */ public static function testRemovePassword($msg) { return self::removePassword($msg); } diff --git a/tests/lib/files/cache/homecache.php b/tests/lib/files/cache/homecache.php index 87fd0dba4c6..dbcf6e9caa0 100644 --- a/tests/lib/files/cache/homecache.php +++ b/tests/lib/files/cache/homecache.php @@ -19,6 +19,10 @@ class DummyUser extends \OC\User\User { */ private $uid; + /** + * @param string $uid + * @param string $home + */ public function __construct($uid, $home) { $this->home = $home; $this->uid = $uid; diff --git a/tests/lib/files/cache/watcher.php b/tests/lib/files/cache/watcher.php index 1920c276907..7f4f3c5ee98 100644 --- a/tests/lib/files/cache/watcher.php +++ b/tests/lib/files/cache/watcher.php @@ -11,7 +11,7 @@ namespace Test\Files\Cache; class Watcher extends \PHPUnit_Framework_TestCase { /** - * @var \OC\Files\Storage\Storage[] $storages; + * @var \OC\Files\Storage\Storage[] $storages */ private $storages = array(); @@ -105,6 +105,60 @@ class Watcher extends \PHPUnit_Framework_TestCase { $this->assertTrue($cache->inCache('foo.txt/bar.txt')); } + public function testPolicyNever() { + $storage = $this->getTestStorage(); + $cache = $storage->getCache(); + $updater = $storage->getWatcher(); + + //set the mtime to the past so it can detect an mtime change + $cache->put('foo.txt', array('storage_mtime' => 10)); + + $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_NEVER); + + $storage->file_put_contents('foo.txt', 'q'); + $this->assertFalse($updater->checkUpdate('foo.txt')); + + $cache->put('foo.txt', array('storage_mtime' => 20)); + $storage->file_put_contents('foo.txt', 'w'); + $this->assertFalse($updater->checkUpdate('foo.txt')); + } + + public function testPolicyOnce() { + $storage = $this->getTestStorage(); + $cache = $storage->getCache(); + $updater = $storage->getWatcher(); + + //set the mtime to the past so it can detect an mtime change + $cache->put('foo.txt', array('storage_mtime' => 10)); + + $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ONCE); + + $storage->file_put_contents('foo.txt', 'q'); + $this->assertTrue($updater->checkUpdate('foo.txt')); + + $cache->put('foo.txt', array('storage_mtime' => 20)); + $storage->file_put_contents('foo.txt', 'w'); + $this->assertFalse($updater->checkUpdate('foo.txt')); + } + + public function testPolicyAlways() { + $storage = $this->getTestStorage(); + $cache = $storage->getCache(); + $updater = $storage->getWatcher(); + + //set the mtime to the past so it can detect an mtime change + $cache->put('foo.txt', array('storage_mtime' => 10)); + + $updater->setPolicy(\OC\Files\Cache\Watcher::CHECK_ALWAYS); + + $storage->file_put_contents('foo.txt', 'q'); + $this->assertTrue($updater->checkUpdate('foo.txt')); + + $cache->put('foo.txt', array('storage_mtime' => 20)); + $storage->file_put_contents('foo.txt', 'w'); + $this->assertTrue($updater->checkUpdate('foo.txt')); + } + /** * @param bool $scan * @return \OC\Files\Storage\Storage diff --git a/tests/lib/files/etagtest.php b/tests/lib/files/etagtest.php index 6c41413c4df..ce05adb188a 100644 --- a/tests/lib/files/etagtest.php +++ b/tests/lib/files/etagtest.php @@ -68,6 +68,9 @@ class EtagTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($originalEtags, $this->getEtags($files)); } + /** + * @param string[] $files + */ private function getEtags($files) { $etags = array(); foreach ($files as $file) { diff --git a/tests/lib/files/node/integration.php b/tests/lib/files/node/integration.php index 14e1d05853d..319f2f9f5f7 100644 --- a/tests/lib/files/node/integration.php +++ b/tests/lib/files/node/integration.php @@ -9,10 +9,7 @@ namespace Test\Files\Node; use OC\Files\Cache\Cache; -use OC\Files\Mount\Manager; use OC\Files\Node\Root; -use OCP\Files\NotFoundException; -use OCP\Files\NotPermittedException; use OC\Files\Storage\Temporary; use OC\Files\View; use OC\User\User; diff --git a/tests/lib/files/node/root.php b/tests/lib/files/node/root.php index 97eaf7f7162..27f1a937826 100644 --- a/tests/lib/files/node/root.php +++ b/tests/lib/files/node/root.php @@ -8,7 +8,6 @@ namespace Test\Files\Node; -use OC\Files\Cache\Cache; use OCP\Files\NotPermittedException; use OC\Files\Mount\Manager; diff --git a/tests/lib/files/storage/home.php b/tests/lib/files/storage/home.php index 885291e4404..51315a2a556 100644 --- a/tests/lib/files/storage/home.php +++ b/tests/lib/files/storage/home.php @@ -29,6 +29,10 @@ class DummyUser extends User { private $uid; + /** + * @param string $uid + * @param string $home + */ public function __construct($uid, $home) { $this->uid = $uid; $this->home = $home; diff --git a/tests/lib/files/storage/wrapper/quota.php b/tests/lib/files/storage/wrapper/quota.php index 87bafb64d41..e1b880255fb 100644 --- a/tests/lib/files/storage/wrapper/quota.php +++ b/tests/lib/files/storage/wrapper/quota.php @@ -27,6 +27,9 @@ class Quota extends \Test\Files\Storage\Storage { \OC_Helper::rmdirr($this->tmpDir); } + /** + * @param integer $limit + */ protected function getLimitedStorage($limit) { $storage = new \OC\Files\Storage\Local(array('datadir' => $this->tmpDir)); $storage->getScanner()->scan(''); diff --git a/tests/lib/files/stream/quota.php b/tests/lib/files/stream/quota.php index b11f0ac74c0..d5edace544d 100644 --- a/tests/lib/files/stream/quota.php +++ b/tests/lib/files/stream/quota.php @@ -13,6 +13,10 @@ class Quota extends \PHPUnit_Framework_TestCase { \OC\Files\Stream\Quota::clear(); } + /** + * @param string $mode + * @param integer $limit + */ protected function getStream($mode, $limit) { $source = fopen('php://temp', $mode); return \OC\Files\Stream\Quota::wrap($source, $limit); diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php index 72a2f854cb2..371d1ed1798 100644 --- a/tests/lib/files/view.php +++ b/tests/lib/files/view.php @@ -7,6 +7,8 @@ namespace Test\Files; +use OC\Files\Cache\Watcher; + class TemporaryNoTouch extends \OC\Files\Storage\Temporary { public function touch($path, $mtime = null) { return false; @@ -249,6 +251,7 @@ class View extends \PHPUnit_Framework_TestCase { function testWatcher() { $storage1 = $this->getTestStorage(); \OC\Files\Filesystem::mount($storage1, array(), '/'); + $storage1->getWatcher()->setPolicy(Watcher::CHECK_ALWAYS); $rootView = new \OC\Files\View(''); diff --git a/tests/lib/group/backend.php b/tests/lib/group/backend.php index d308232a78b..2c563ae9ac9 100644 --- a/tests/lib/group/backend.php +++ b/tests/lib/group/backend.php @@ -29,7 +29,7 @@ abstract class Test_Group_Backend extends PHPUnit_Framework_TestCase { /** * get a new unique group name * test cases can override this in order to clean up created groups - * @return array + * @return string */ public function getGroupName() { return uniqid('test_'); @@ -38,7 +38,7 @@ abstract class Test_Group_Backend extends PHPUnit_Framework_TestCase { /** * get a new unique user name * test cases can override this in order to clean up created user - * @return array + * @return string */ public function getUserName() { return uniqid('test_'); diff --git a/tests/lib/group/database.php b/tests/lib/group/database.php index 5278c26f4df..3e05c656061 100644 --- a/tests/lib/group/database.php +++ b/tests/lib/group/database.php @@ -26,7 +26,7 @@ class Test_Group_Database extends Test_Group_Backend { /** * get a new unique group name * test cases can override this in order to clean up created groups - * @return array + * @return string */ public function getGroupName() { $name=uniqid('test_'); @@ -37,7 +37,7 @@ class Test_Group_Database extends Test_Group_Backend { /** * get a new unique user name * test cases can override this in order to clean up created user - * @return array + * @return string */ public function getUserName() { return uniqid('test_'); diff --git a/tests/lib/group/group.php b/tests/lib/group/group.php index f1fda3b9288..3982c00e45f 100644 --- a/tests/lib/group/group.php +++ b/tests/lib/group/group.php @@ -13,7 +13,7 @@ use OC\User\User; class Group extends \PHPUnit_Framework_TestCase { /** - * @return \PHPUnit_Framework_MockObject_MockObject | \OC\User\Manager + * @return \OC\User\Manager | \OC\User\Manager */ protected function getUserManager() { $userManager = $this->getMock('\OC\User\Manager'); diff --git a/tests/lib/group/manager.php b/tests/lib/group/manager.php index 9d3adf51a0c..90f0e1b35e2 100644 --- a/tests/lib/group/manager.php +++ b/tests/lib/group/manager.php @@ -116,16 +116,22 @@ class Manager extends \PHPUnit_Framework_TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend */ + $backendGroupCreated = false; $backend = $this->getMock('\OC_Group_Database'); $backend->expects($this->any()) ->method('groupExists') ->with('group1') - ->will($this->returnValue(false)); + ->will($this->returnCallback(function () use (&$backendGroupCreated) { + return $backendGroupCreated; + })); $backend->expects($this->once()) ->method('implementsActions') ->will($this->returnValue(true)); $backend->expects($this->once()) - ->method('createGroup'); + ->method('createGroup') + ->will($this->returnCallback(function () use (&$backendGroupCreated) { + $backendGroupCreated = true; + }));; /** * @var \OC\User\Manager $userManager @@ -170,6 +176,10 @@ class Manager extends \PHPUnit_Framework_TestCase { ->method('getGroups') ->with('1') ->will($this->returnValue(array('group1'))); + $backend->expects($this->once()) + ->method('groupExists') + ->with('group1') + ->will($this->returnValue(true)); /** * @var \OC\User\Manager $userManager @@ -193,6 +203,9 @@ class Manager extends \PHPUnit_Framework_TestCase { ->method('getGroups') ->with('1') ->will($this->returnValue(array('group1'))); + $backend1->expects($this->any()) + ->method('groupExists') + ->will($this->returnValue(true)); /** * @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend2 @@ -202,6 +215,9 @@ class Manager extends \PHPUnit_Framework_TestCase { ->method('getGroups') ->with('1') ->will($this->returnValue(array('group12', 'group1'))); + $backend2->expects($this->any()) + ->method('groupExists') + ->will($this->returnValue(true)); /** * @var \OC\User\Manager $userManager @@ -228,6 +244,9 @@ class Manager extends \PHPUnit_Framework_TestCase { ->method('getGroups') ->with('1', 2, 1) ->will($this->returnValue(array('group1'))); + $backend1->expects($this->any()) + ->method('groupExists') + ->will($this->returnValue(true)); /** * @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend2 @@ -237,6 +256,9 @@ class Manager extends \PHPUnit_Framework_TestCase { ->method('getGroups') ->with('1', 1, 0) ->will($this->returnValue(array('group12'))); + $backend2->expects($this->any()) + ->method('groupExists') + ->will($this->returnValue(true)); /** * @var \OC\User\Manager $userManager @@ -263,6 +285,10 @@ class Manager extends \PHPUnit_Framework_TestCase { ->method('getUserGroups') ->with('user1') ->will($this->returnValue(array('group1'))); + $backend->expects($this->any()) + ->method('groupExists') + ->with('group1') + ->will($this->returnValue(true)); /** * @var \OC\User\Manager $userManager @@ -286,6 +312,10 @@ class Manager extends \PHPUnit_Framework_TestCase { ->method('getUserGroups') ->with('user1') ->will($this->returnValue(array('group1'))); + $backend1->expects($this->any()) + ->method('groupExists') + ->will($this->returnValue(true)); + /** * @var \PHPUnit_Framework_MockObject_MockObject | \OC_Group_Backend $backend2 */ @@ -294,6 +324,9 @@ class Manager extends \PHPUnit_Framework_TestCase { ->method('getUserGroups') ->with('user1') ->will($this->returnValue(array('group1', 'group2'))); + $backend1->expects($this->any()) + ->method('groupExists') + ->will($this->returnValue(true)); /** * @var \OC\User\Manager $userManager diff --git a/tests/lib/migrate.php b/tests/lib/migrate.php new file mode 100644 index 00000000000..d438a7a692e --- /dev/null +++ b/tests/lib/migrate.php @@ -0,0 +1,90 @@ +<?php +/** + * Copyright (c) 2014 Tom Needham <tom@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +class Test_Migrate extends PHPUnit_Framework_TestCase { + + public $users; + public $tmpfiles = array(); + + /** + * @brief Generates a test user and sets up their file system + * @return string the test users id + */ + public function generateUser() { + $username = uniqid(); + \OC_User::createUser($username, 'password'); + \OC_Util::tearDownFS(); + \OC_User::setUserId(''); + \OC\Files\Filesystem::tearDown(); + \OC_Util::setupFS($username); + $this->users[] = $username; + return $username; + } + + /** + * @brief validates an export for a user + * @brief checks for existence of export_info.json and file folder + * @param string $exportedUser the user that was exported + * @param string $path the path to the .zip export + * @param string $exportedBy + */ + public function validateUserExport($exportedBy, $exportedUser, $path) { + $this->assertTrue(file_exists($path)); + // Extract + $extract = get_temp_dir() . '/oc_import_' . uniqid(); + //mkdir($extract); + $this->tmpfiles[] = $extract; + $zip = new ZipArchive; + $zip->open($path); + $zip->extractTo($extract); + $zip->close(); + $this->assertTrue(file_exists($extract.'/export_info.json')); + $exportInfo = file_get_contents($extract.'/export_info.json'); + $exportInfo = json_decode($exportInfo); + $this->assertNotNull($exportInfo); + $this->assertEquals($exportedUser, $exportInfo->exporteduser); + $this->assertEquals($exportedBy, $exportInfo->exportedby); + $this->assertTrue(file_exists($extract.'/'.$exportedUser.'/files')); + } + + public function testUserSelfExport() { + // Create a user + $user = $this->generateUser(); + \OC_User::setUserId($user); + $export = \OC_Migrate::export($user); + // Check it succeeded and exists + $this->assertTrue(json_decode($export)->success); + // Validate the export + $this->validateUserExport($user, $user, json_decode($export)->data); + } + + public function testUserOtherExport() { + $user = $this->generateUser(); + $user2 = $this->generateUser(); + \OC_User::setUserId($user2); + $export = \OC_Migrate::export($user); + // Check it succeeded and exists + $this->assertTrue(json_decode($export)->success); + // Validate the export + $this->validateUserExport($user2, $user, json_decode($export)->data); + } + + public function tearDown() { + $u = new OC_User(); + foreach($this->users as $user) { + $u->deleteUser($user); + } + foreach($this->tmpfiles as $file) { + \OC_Helper::rmdirr($file); + } + } + + + + +} diff --git a/tests/lib/ocs/privatedata.php b/tests/lib/ocs/privatedata.php index ea8413734f1..498ab718621 100644 --- a/tests/lib/ocs/privatedata.php +++ b/tests/lib/ocs/privatedata.php @@ -131,6 +131,7 @@ class Test_OC_OCS_Privatedata extends PHPUnit_Framework_TestCase /** * @param \OC_OCS_Result $result + * @param integer $expectedArraySize */ public function assertOcsResult($expectedArraySize, $result) { $this->assertEquals(100, $result->getStatusCode()); diff --git a/tests/lib/preferences.php b/tests/lib/preferences.php index a8236909ded..f1f6ed08003 100644 --- a/tests/lib/preferences.php +++ b/tests/lib/preferences.php @@ -144,58 +144,6 @@ class Test_Preferences_Object extends PHPUnit_Framework_TestCase { $this->assertEquals(array('foo'), $apps); } - public function testGetApps() - { - $statementMock = $this->getMock('\Doctrine\DBAL\Statement', array(), array(), '', false); - $statementMock->expects($this->exactly(2)) - ->method('fetchColumn') - ->will($this->onConsecutiveCalls('foo', false)); - $connectionMock = $this->getMock('\OC\DB\Connection', array(), array(), '', false); - $connectionMock->expects($this->once()) - ->method('executeQuery') - ->with($this->equalTo('SELECT DISTINCT `appid` FROM `*PREFIX*preferences` WHERE `userid` = ?'), - $this->equalTo(array('bar'))) - ->will($this->returnValue($statementMock)); - - $preferences = new OC\Preferences($connectionMock); - $apps = $preferences->getApps('bar'); - $this->assertEquals(array('foo'), $apps); - } - - public function testGetKeys() - { - $statementMock = $this->getMock('\Doctrine\DBAL\Statement', array(), array(), '', false); - $statementMock->expects($this->exactly(2)) - ->method('fetchColumn') - ->will($this->onConsecutiveCalls('foo', false)); - $connectionMock = $this->getMock('\OC\DB\Connection', array(), array(), '', false); - $connectionMock->expects($this->once()) - ->method('executeQuery') - ->with($this->equalTo('SELECT `configkey` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ?'), - $this->equalTo(array('bar', 'moo'))) - ->will($this->returnValue($statementMock)); - - $preferences = new OC\Preferences($connectionMock); - $keys = $preferences->getKeys('bar', 'moo'); - $this->assertEquals(array('foo'), $keys); - } - - public function testGetValue() - { - $connectionMock = $this->getMock('\OC\DB\Connection', array(), array(), '', false); - $connectionMock->expects($this->exactly(2)) - ->method('fetchAssoc') - ->with($this->equalTo('SELECT `configvalue` FROM `*PREFIX*preferences` WHERE `userid` = ? AND `appid` = ? AND `configkey` = ?'), - $this->equalTo(array('grg', 'bar', 'red'))) - ->will($this->onConsecutiveCalls(array('configvalue'=>'foo'), null)); - - $preferences = new OC\Preferences($connectionMock); - $value = $preferences->getValue('grg', 'bar', 'red'); - $this->assertEquals('foo', $value); - $value = $preferences->getValue('grg', 'bar', 'red', 'def'); - $this->assertEquals('def', $value); - } - public function testSetValue() { $connectionMock = $this->getMock('\OC\DB\Connection', array(), array(), '', false); diff --git a/tests/lib/share/share.php b/tests/lib/share/share.php index d6acee6c924..a89f100d97a 100644 --- a/tests/lib/share/share.php +++ b/tests/lib/share/share.php @@ -151,6 +151,10 @@ class Test_Share extends PHPUnit_Framework_TestCase { ); } + /** + * @param string $sharer + * @param string $receiver + */ protected function shareUserTestFileWithUser($sharer, $receiver) { OC_User::setUserId($sharer); $this->assertTrue( @@ -558,6 +562,9 @@ class Test_Share extends PHPUnit_Framework_TestCase { ); } + /** + * @param boolean|string $token + */ protected function getShareByValidToken($token) { $row = OCP\Share::getShareByToken($token); $this->assertInternalType( diff --git a/tests/lib/template/resourcelocator.php b/tests/lib/template/resourcelocator.php index d80d222e2c9..619560643fe 100644 --- a/tests/lib/template/resourcelocator.php +++ b/tests/lib/template/resourcelocator.php @@ -7,6 +7,11 @@ */ class Test_ResourceLocator extends PHPUnit_Framework_TestCase { + + /** + * @param string $theme + * @param string $form_factor + */ public function getResourceLocator( $theme, $form_factor, $core_map, $party_map, $appsroots ) { return $this->getMockForAbstractClass('OC\Template\ResourceLocator', array( $theme, $form_factor, $core_map, $party_map, $appsroots ), diff --git a/tests/lib/user.php b/tests/lib/user.php index fdf9e7a08e0..e2c3282a19f 100644 --- a/tests/lib/user.php +++ b/tests/lib/user.php @@ -9,8 +9,6 @@ namespace Test; -use OC\Hooks\PublicEmitter; - class User extends \PHPUnit_Framework_TestCase { /** * @var \OC_User_Backend | \PHPUnit_Framework_MockObject_MockObject $backend diff --git a/tests/testcleanuplistener.php b/tests/testcleanuplistener.php index a969ece6dd5..299a589ef4e 100644 --- a/tests/testcleanuplistener.php +++ b/tests/testcleanuplistener.php @@ -57,6 +57,9 @@ class TestCleanupListener implements PHPUnit_Framework_TestListener { return $this->verbosity === 'detail'; } + /** + * @param string $dir + */ private function unlinkDir($dir) { if ($dh = @opendir($dir)) { while (($file = readdir($dh)) !== false) { |