diff --git a/lib/l10n/fr.js b/lib/l10n/fr.js
index 9660650b4f..014b6c24e5 100644
--- a/lib/l10n/fr.js
+++ b/lib/l10n/fr.js
@@ -146,6 +146,10 @@ OC.L10N.register(
"Data directory (%s) is invalid" : "Le répertoire (%s) n'est pas valide",
"Please check that the data directory contains a file \".ocdata\" in its root." : "Veuillez vérifier que le répertoire de données contient un fichier \".ocdata\" à sa racine.",
"Could not obtain lock type %d on \"%s\"." : "Impossible d'obtenir le verrouillage de type %d sur \"%s\".",
- "Storage not available" : "Support de stockage non disponible"
+ "Storage unauthorized. %s" : "Espace de stockage non autorisé. %s",
+ "Storage incomplete configuration. %s" : "Configuration de l'espace de stockage incomplète. %s",
+ "Storage connection error. %s" : "Erreur de connexion à l'espace stockage. %s",
+ "Storage not available" : "Support de stockage non disponible",
+ "Storage connection timeout. %s" : "Le délai d'attente pour la connexion à l'espace de stockage a été dépassé. %s"
},
"nplurals=2; plural=(n > 1);");
diff --git a/lib/l10n/fr.json b/lib/l10n/fr.json
index a388630993..feaae43bf4 100644
--- a/lib/l10n/fr.json
+++ b/lib/l10n/fr.json
@@ -144,6 +144,10 @@
"Data directory (%s) is invalid" : "Le répertoire (%s) n'est pas valide",
"Please check that the data directory contains a file \".ocdata\" in its root." : "Veuillez vérifier que le répertoire de données contient un fichier \".ocdata\" à sa racine.",
"Could not obtain lock type %d on \"%s\"." : "Impossible d'obtenir le verrouillage de type %d sur \"%s\".",
- "Storage not available" : "Support de stockage non disponible"
+ "Storage unauthorized. %s" : "Espace de stockage non autorisé. %s",
+ "Storage incomplete configuration. %s" : "Configuration de l'espace de stockage incomplète. %s",
+ "Storage connection error. %s" : "Erreur de connexion à l'espace stockage. %s",
+ "Storage not available" : "Support de stockage non disponible",
+ "Storage connection timeout. %s" : "Le délai d'attente pour la connexion à l'espace de stockage a été dépassé. %s"
},"pluralForm" :"nplurals=2; plural=(n > 1);"
}
\ No newline at end of file
diff --git a/lib/l10n/lt_LT.js b/lib/l10n/lt_LT.js
index f73b1fdc87..402167cb3c 100644
--- a/lib/l10n/lt_LT.js
+++ b/lib/l10n/lt_LT.js
@@ -4,7 +4,9 @@ OC.L10N.register(
"Cannot write into \"config\" directory!" : "Negalima rašyti į \"config\" aplanką!",
"This can usually be fixed by giving the webserver write access to the config directory" : "Tai gali būti ištaisyta suteikiant web serveriui rašymo teises į config aplanką",
"See %s" : "Žiūrėk %s",
+ "Sample configuration detected" : "Aptiktas konfigūracijos pavyzdys",
"PHP %s or higher is required." : "Reikalinga PHP %s arba aukštesnė.",
+ "Following databases are supported: %s" : "Palaikomos duomenų bazės: %s",
"Help" : "Pagalba",
"Personal" : "Asmeniniai",
"Users" : "Vartotojai",
diff --git a/lib/l10n/lt_LT.json b/lib/l10n/lt_LT.json
index e9acd6f295..c4efe38665 100644
--- a/lib/l10n/lt_LT.json
+++ b/lib/l10n/lt_LT.json
@@ -2,7 +2,9 @@
"Cannot write into \"config\" directory!" : "Negalima rašyti į \"config\" aplanką!",
"This can usually be fixed by giving the webserver write access to the config directory" : "Tai gali būti ištaisyta suteikiant web serveriui rašymo teises į config aplanką",
"See %s" : "Žiūrėk %s",
+ "Sample configuration detected" : "Aptiktas konfigūracijos pavyzdys",
"PHP %s or higher is required." : "Reikalinga PHP %s arba aukštesnė.",
+ "Following databases are supported: %s" : "Palaikomos duomenų bazės: %s",
"Help" : "Pagalba",
"Personal" : "Asmeniniai",
"Users" : "Vartotojai",
diff --git a/lib/l10n/nl.js b/lib/l10n/nl.js
index 24e087a50f..f4201778f7 100644
--- a/lib/l10n/nl.js
+++ b/lib/l10n/nl.js
@@ -147,6 +147,10 @@ OC.L10N.register(
"Data directory (%s) is invalid" : "Data directory (%s) is ongeldig",
"Please check that the data directory contains a file \".ocdata\" in its root." : "Verifieer dat de data directory een bestand \".ocdata\" in de hoofdmap heeft.",
"Could not obtain lock type %d on \"%s\"." : "Kon geen lock type %d krijgen op \"%s\".",
- "Storage not available" : "Opslag niet beschikbaar"
+ "Storage unauthorized. %s" : "Opslag niet toegestaan. %s",
+ "Storage incomplete configuration. %s" : "Incomplete opslagconfiguratie. %s",
+ "Storage connection error. %s" : "Opslagverbindingsfout. %s",
+ "Storage not available" : "Opslag niet beschikbaar",
+ "Storage connection timeout. %s" : "Opslagverbinding time-out. %s"
},
"nplurals=2; plural=(n != 1);");
diff --git a/lib/l10n/nl.json b/lib/l10n/nl.json
index 691f3e0824..c8981f8fd4 100644
--- a/lib/l10n/nl.json
+++ b/lib/l10n/nl.json
@@ -145,6 +145,10 @@
"Data directory (%s) is invalid" : "Data directory (%s) is ongeldig",
"Please check that the data directory contains a file \".ocdata\" in its root." : "Verifieer dat de data directory een bestand \".ocdata\" in de hoofdmap heeft.",
"Could not obtain lock type %d on \"%s\"." : "Kon geen lock type %d krijgen op \"%s\".",
- "Storage not available" : "Opslag niet beschikbaar"
+ "Storage unauthorized. %s" : "Opslag niet toegestaan. %s",
+ "Storage incomplete configuration. %s" : "Incomplete opslagconfiguratie. %s",
+ "Storage connection error. %s" : "Opslagverbindingsfout. %s",
+ "Storage not available" : "Opslag niet beschikbaar",
+ "Storage connection timeout. %s" : "Opslagverbinding time-out. %s"
},"pluralForm" :"nplurals=2; plural=(n != 1);"
}
\ No newline at end of file
diff --git a/lib/l10n/pt_BR.js b/lib/l10n/pt_BR.js
index 8078d369b7..2595d5dfd3 100644
--- a/lib/l10n/pt_BR.js
+++ b/lib/l10n/pt_BR.js
@@ -147,6 +147,10 @@ OC.L10N.register(
"Data directory (%s) is invalid" : "Diretório de dados (%s) é inválido",
"Please check that the data directory contains a file \".ocdata\" in its root." : "Por favor, verifique se o diretório de dados contém um arquivo \".ocdata\" em sua raiz.",
"Could not obtain lock type %d on \"%s\"." : "Não foi possível obter tipo de bloqueio %d em \"%s\".",
- "Storage not available" : "Armazanamento não disponível"
+ "Storage unauthorized. %s" : "Armazenamento não autorizado. %s",
+ "Storage incomplete configuration. %s" : "Incompleta configuração de armazenamento. %s",
+ "Storage connection error. %s" : "Erro na conexão de armazenamento. %s",
+ "Storage not available" : "Armazanamento não disponível",
+ "Storage connection timeout. %s" : "Tempo limite de conexão de armazenamento. %s"
},
"nplurals=2; plural=(n > 1);");
diff --git a/lib/l10n/pt_BR.json b/lib/l10n/pt_BR.json
index 5987c1e2ac..0da54181b3 100644
--- a/lib/l10n/pt_BR.json
+++ b/lib/l10n/pt_BR.json
@@ -145,6 +145,10 @@
"Data directory (%s) is invalid" : "Diretório de dados (%s) é inválido",
"Please check that the data directory contains a file \".ocdata\" in its root." : "Por favor, verifique se o diretório de dados contém um arquivo \".ocdata\" em sua raiz.",
"Could not obtain lock type %d on \"%s\"." : "Não foi possível obter tipo de bloqueio %d em \"%s\".",
- "Storage not available" : "Armazanamento não disponível"
+ "Storage unauthorized. %s" : "Armazenamento não autorizado. %s",
+ "Storage incomplete configuration. %s" : "Incompleta configuração de armazenamento. %s",
+ "Storage connection error. %s" : "Erro na conexão de armazenamento. %s",
+ "Storage not available" : "Armazanamento não disponível",
+ "Storage connection timeout. %s" : "Tempo limite de conexão de armazenamento. %s"
},"pluralForm" :"nplurals=2; plural=(n > 1);"
}
\ No newline at end of file
diff --git a/lib/private/app.php b/lib/private/app.php
index c6e235eda4..abf12264c5 100644
--- a/lib/private/app.php
+++ b/lib/private/app.php
@@ -360,37 +360,6 @@ class OC_App {
$appManager->disableApp($app);
}
- /**
- * marks a navigation entry as active
- *
- * @param string $id id of the entry
- * @return bool
- *
- * This function sets a navigation entry as active and removes the 'active'
- * property from all other entries. The templates can use this for
- * highlighting the current position of the user.
- *
- * @deprecated Use \OC::$server->getNavigationManager()->setActiveEntry() instead
- */
- public static function setActiveNavigationEntry($id) {
- OC::$server->getNavigationManager()->setActiveEntry($id);
- return true;
- }
-
- /**
- * gets the active Menu entry
- *
- * @return string id or empty string
- *
- * This function returns the id of the active navigation entry (set by
- * setActiveNavigationEntry
- *
- * @deprecated Use \OC::$server->getNavigationManager()->getActiveEntry() instead
- */
- public static function getActiveNavigationEntry() {
- return OC::$server->getNavigationManager()->getActiveEntry();
- }
-
/**
* Returns the Settings Navigation
*
@@ -505,9 +474,13 @@ class OC_App {
* search for an app in all app-directories
*
* @param string $appId
- * @return mixed (bool|string)
+ * @return false|string
*/
protected static function findAppInDirectories($appId) {
+ $sanitizedAppId = self::cleanAppId($appId);
+ if($sanitizedAppId !== $appId) {
+ return false;
+ }
static $app_dir = array();
if (isset($app_dir[$appId])) {
diff --git a/lib/private/app/infoparser.php b/lib/private/app/infoparser.php
index 789f01e5bc..22f705884b 100644
--- a/lib/private/app/infoparser.php
+++ b/lib/private/app/infoparser.php
@@ -61,7 +61,7 @@ class InfoParser {
if ($xml == false) {
return null;
}
- $array = $this->xmlToArray($xml, false);
+ $array = $this->xmlToArray($xml);
if (is_null($array)) {
return null;
}
diff --git a/lib/private/appframework/utility/simplecontainer.php b/lib/private/appframework/utility/simplecontainer.php
index bcae351e02..e55d4e20a8 100644
--- a/lib/private/appframework/utility/simplecontainer.php
+++ b/lib/private/appframework/utility/simplecontainer.php
@@ -29,9 +29,7 @@ namespace OC\AppFramework\Utility;
use ReflectionClass;
use ReflectionException;
use Closure;
-
use Pimple\Container;
-
use OCP\AppFramework\QueryException;
use OCP\IContainer;
diff --git a/lib/private/apphelper.php b/lib/private/apphelper.php
index 9084d2b8ab..478787b21d 100644
--- a/lib/private/apphelper.php
+++ b/lib/private/apphelper.php
@@ -36,6 +36,12 @@ class AppHelper implements \OCP\IHelper {
* @deprecated 8.1.0 Use \OCP\IServerContainer::getHTTPClientService
*/
public function getUrlContent($url) {
- return \OC_Util::getUrlContent($url);
+ try {
+ $client = \OC::$server->getHTTPClientService()->newClient();
+ $response = $client->get($url);
+ return $response->getBody();
+ } catch (\Exception $e) {
+ return false;
+ }
}
}
diff --git a/lib/private/db/querybuilder/querybuilder.php b/lib/private/db/querybuilder/querybuilder.php
index 02d8ee4344..741da4efc2 100644
--- a/lib/private/db/querybuilder/querybuilder.php
+++ b/lib/private/db/querybuilder/querybuilder.php
@@ -324,6 +324,28 @@ class QueryBuilder implements IQueryBuilder {
return $this;
}
+ /**
+ * Specifies an item that is to be returned uniquely in the query result.
+ *
+ *
+ * $qb = $conn->getQueryBuilder()
+ * ->selectDistinct('type')
+ * ->from('users');
+ *
+ *
+ * @param mixed $select The selection expressions.
+ *
+ * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ */
+ public function selectDistinct($select) {
+
+ $this->queryBuilder->addSelect(
+ 'DISTINCT ' . $this->helper->quoteColumnName($select)
+ );
+
+ return $this;
+ }
+
/**
* Adds an item that is to be returned in the query result.
*
@@ -1024,14 +1046,46 @@ class QueryBuilder implements IQueryBuilder {
}
/**
+ * Used to get the id of the last inserted element
+ * @return int
+ * @throws \BadMethodCallException When being called before an insert query has been run.
+ */
+ public function getLastInsertId() {
+ $from = $this->getQueryPart('from');
+
+ if ($this->getType() === \Doctrine\DBAL\Query\QueryBuilder::INSERT && !empty($from)) {
+ return (int) $this->connection->lastInsertId($from['table']);
+ }
+
+ throw new \BadMethodCallException('Invalid call to getLastInsertId without using insert() before.');
+ }
+
+ /**
+ * Returns the table name quoted and with database prefix as needed by the implementation
+ *
* @param string $table
* @return string
*/
- private function getTableName($table) {
+ public function getTableName($table) {
if ($this->automaticTablePrefix === false || strpos($table, '*PREFIX*') === 0) {
return $this->helper->quoteColumnName($table);
}
return $this->helper->quoteColumnName('*PREFIX*' . $table);
}
+
+ /**
+ * Returns the column name quoted and with table alias prefix as needed by the implementation
+ *
+ * @param string $column
+ * @param string $tableAlias
+ * @return string
+ */
+ public function getColumnName($column, $tableAlias = '') {
+ if ($tableAlias !== '') {
+ $tableAlias .= '.';
+ }
+
+ return $this->helper->quoteColumnName($tableAlias . $column);
+ }
}
diff --git a/lib/private/db/querybuilder/quotehelper.php b/lib/private/db/querybuilder/quotehelper.php
index 4b62fee6a6..5ceb76bbf9 100644
--- a/lib/private/db/querybuilder/quotehelper.php
+++ b/lib/private/db/querybuilder/quotehelper.php
@@ -61,7 +61,7 @@ class QuoteHelper {
}
if (substr_count($string, '.')) {
- list($alias, $columnName) = explode('.', $string);
+ list($alias, $columnName) = explode('.', $string, 2);
if ($columnName === '*') {
return $string;
diff --git a/lib/private/files.php b/lib/private/files.php
index af10f3e1e3..1cda28496c 100644
--- a/lib/private/files.php
+++ b/lib/private/files.php
@@ -115,7 +115,7 @@ class OC_Files {
self::lockFiles($view, $dir, $files);
$streamer->sendHeaders($name);
- $executionTime = intval(ini_get('max_execution_time'));
+ $executionTime = intval(OC::$server->getIniWrapper()->getNumeric('max_execution_time'));
set_time_limit(0);
if ($getType === self::ZIP_FILES) {
foreach ($files as $file) {
diff --git a/lib/private/files/filesystem.php b/lib/private/files/filesystem.php
index 9f243c15a4..9d1b715068 100644
--- a/lib/private/files/filesystem.php
+++ b/lib/private/files/filesystem.php
@@ -58,7 +58,6 @@
namespace OC\Files;
-use OC\Cache\File;
use OC\Files\Config\MountProviderCollection;
use OC\Files\Storage\StorageFactory;
use OCP\Files\Config\IMountProvider;
diff --git a/lib/private/files/view.php b/lib/private/files/view.php
index 7854790d0e..6abefff419 100644
--- a/lib/private/files/view.php
+++ b/lib/private/files/view.php
@@ -1427,13 +1427,9 @@ class View {
if ($mimetype_filter) {
$files = array_filter($files, function (FileInfo $file) use ($mimetype_filter) {
if (strpos($mimetype_filter, '/')) {
- if ($file->getMimetype() === $mimetype_filter) {
- $result[] = $file;
- }
+ return $file->getMimetype() === $mimetype_filter;
} else {
- if ($file->getMimePart() === $mimetype_filter) {
- $result[] = $file;
- }
+ return $file->getMimePart() === $mimetype_filter;
}
});
}
diff --git a/lib/private/helper.php b/lib/private/helper.php
index 3cad77e666..78a567638e 100644
--- a/lib/private/helper.php
+++ b/lib/private/helper.php
@@ -441,7 +441,7 @@ class OC_Helper {
// Default check will be done with $path directories :
$dirs = explode(PATH_SEPARATOR, $path);
// WARNING : We have to check if open_basedir is enabled :
- $obd = ini_get('open_basedir');
+ $obd = OC::$server->getIniWrapper()->getString('open_basedir');
if ($obd != "none") {
$obd_values = explode(PATH_SEPARATOR, $obd);
if (count($obd_values) > 0 and $obd_values[0]) {
@@ -701,8 +701,9 @@ class OC_Helper {
* @return int PHP upload file size limit
*/
public static function uploadLimit() {
- $upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
- $post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
+ $ini = \OC::$server->getIniWrapper();
+ $upload_max_filesize = OCP\Util::computerFileSize($ini->get('upload_max_filesize'));
+ $post_max_size = OCP\Util::computerFileSize($ini->get('post_max_size'));
if ((int)$upload_max_filesize === 0 and (int)$post_max_size === 0) {
return INF;
} elseif ((int)$upload_max_filesize === 0 or (int)$post_max_size === 0) {
@@ -722,12 +723,13 @@ class OC_Helper {
if (!function_exists($function_name)) {
return false;
}
- $disabled = explode(',', ini_get('disable_functions'));
+ $ini = \OC::$server->getIniWrapper();
+ $disabled = explode(',', $ini->get('disable_functions'));
$disabled = array_map('trim', $disabled);
if (in_array($function_name, $disabled)) {
return false;
}
- $disabled = explode(',', ini_get('suhosin.executor.func.blacklist'));
+ $disabled = explode(',', $ini->get('suhosin.executor.func.blacklist'));
$disabled = array_map('trim', $disabled);
if (in_array($function_name, $disabled)) {
return false;
diff --git a/lib/private/l10n.php b/lib/private/l10n.php
index 86335bce92..7835285bd4 100644
--- a/lib/private/l10n.php
+++ b/lib/private/l10n.php
@@ -116,13 +116,17 @@ class OC_L10N implements \OCP\IL10N {
$preferred_language = str_replace('-', '_', $preferred_language);
foreach ($available as $available_language) {
if ($preferred_language === strtolower($available_language)) {
- self::$language = $available_language;
+ if (!self::$language) {
+ self::$language = $available_language;
+ }
return $available_language;
}
}
foreach ($available as $available_language) {
if (substr($preferred_language, 0, 2) === $available_language) {
- self::$language = $available_language;
+ if (!self::$language) {
+ self::$language = $available_language;
+ }
return $available_language;
}
}
@@ -407,7 +411,7 @@ class OC_L10N implements \OCP\IL10N {
* If nothing works it returns 'en'
*/
public static function findLanguage($app = null) {
- if(self::$language != '') {
+ if (self::$language != '' && self::languageExists($app, self::$language)) {
return self::$language;
}
diff --git a/lib/private/memcache/apc.php b/lib/private/memcache/apc.php
index f768cdc1c6..e38b4bd3a3 100644
--- a/lib/private/memcache/apc.php
+++ b/lib/private/memcache/apc.php
@@ -115,9 +115,9 @@ class APC extends Cache implements IMemcache {
static public function isAvailable() {
if (!extension_loaded('apc')) {
return false;
- } elseif (!ini_get('apc.enabled')) {
+ } elseif (!\OC::$server->getIniWrapper()->getBool('apc.enabled')) {
return false;
- } elseif (!ini_get('apc.enable_cli') && \OC::$CLI) {
+ } elseif (!\OC::$server->getIniWrapper()->getBool('apc.enable_cli') && \OC::$CLI) {
return false;
} else {
return true;
diff --git a/lib/private/memcache/apcu.php b/lib/private/memcache/apcu.php
index 9a8da2ae60..84147233ef 100644
--- a/lib/private/memcache/apcu.php
+++ b/lib/private/memcache/apcu.php
@@ -28,9 +28,9 @@ class APCu extends APC {
static public function isAvailable() {
if (!extension_loaded('apcu')) {
return false;
- } elseif (!ini_get('apc.enabled')) {
+ } elseif (!\OC::$server->getIniWrapper()->getBool('apc.enabled')) {
return false;
- } elseif (!ini_get('apc.enable_cli') && \OC::$CLI) {
+ } elseif (!\OC::$server->getIniWrapper()->getBool('apc.enable_cli') && \OC::$CLI) {
return false;
} elseif (version_compare(phpversion('apc'), '4.0.6') === -1) {
return false;
diff --git a/lib/private/memcache/xcache.php b/lib/private/memcache/xcache.php
index a6265ed562..0d2e43a1c1 100644
--- a/lib/private/memcache/xcache.php
+++ b/lib/private/memcache/xcache.php
@@ -118,13 +118,13 @@ class XCache extends Cache implements IMemcache {
if (\OC::$CLI && !getenv('XCACHE_TEST')) {
return false;
}
- if (!function_exists('xcache_unset_by_prefix') && ini_get('xcache.admin.enable_auth')) {
+ if (!function_exists('xcache_unset_by_prefix') && \OC::$server->getIniWrapper()->getBool('xcache.admin.enable_auth')) {
// We do not want to use XCache if we can not clear it without
// using the administration function xcache_clear_cache()
// AND administration functions are password-protected.
return false;
}
- $var_size = (int)ini_get('xcache.var_size');
+ $var_size = \OC::$server->getIniWrapper()->getNumeric('xcache.var_size');
if (!$var_size) {
return false;
}
diff --git a/lib/private/repair.php b/lib/private/repair.php
index f6ac7ebe65..d870b472c4 100644
--- a/lib/private/repair.php
+++ b/lib/private/repair.php
@@ -40,7 +40,6 @@ use OC\Repair\SqliteAutoincrement;
use OC\Repair\DropOldTables;
use OC\Repair\FillETags;
use OC\Repair\InnoDB;
-use OC\Repair\RepairConfig;
use OC\Repair\RepairLegacyStorages;
use OC\Repair\RepairMimeTypes;
use OC\Repair\SearchLuceneTables;
@@ -107,7 +106,6 @@ class Repair extends BasicEmitter {
return [
new RepairMimeTypes(\OC::$server->getConfig()),
new RepairLegacyStorages(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
- new RepairConfig(),
new AssetCache(),
new FillETags(\OC::$server->getDatabaseConnection()),
new CleanTags(\OC::$server->getDatabaseConnection()),
@@ -138,13 +136,12 @@ class Repair extends BasicEmitter {
* @return array of RepairStep instances
*/
public static function getBeforeUpgradeRepairSteps() {
- $steps = array(
+ $steps = [
new InnoDB(),
new Collation(\OC::$server->getConfig(), \OC_DB::getConnection()),
new SqliteAutoincrement(\OC_DB::getConnection()),
new SearchLuceneTables(),
- new RepairConfig()
- );
+ ];
//There is no need to delete all previews on every single update
//only 7.0.0 through 7.0.2 generated broken previews
diff --git a/lib/private/security/trusteddomainhelper.php b/lib/private/security/trusteddomainhelper.php
index 6dbaadfdb6..c1a397dd52 100644
--- a/lib/private/security/trusteddomainhelper.php
+++ b/lib/private/security/trusteddomainhelper.php
@@ -74,16 +74,11 @@ class TrustedDomainHelper {
return false;
}
- // TODO: Workaround for older instances still with port applied. Remove for ownCloud 9.
- if(in_array($domainWithPort, $trustedList)) {
- return true;
- }
-
// Always allow access from localhost
if (preg_match(Request::REGEX_LOCALHOST, $domain) === 1) {
return true;
}
- return in_array($domain, $trustedList);
+ return in_array($domain, $trustedList, true);
}
}
diff --git a/lib/private/session/cryptowrapper.php b/lib/private/session/cryptowrapper.php
index c79778587e..177f11ffb7 100644
--- a/lib/private/session/cryptowrapper.php
+++ b/lib/private/session/cryptowrapper.php
@@ -23,7 +23,6 @@
namespace OC\Session;
-use OCP\AppFramework\Utility\ITimeFactory;
use OCP\IConfig;
use OCP\IRequest;
use OCP\ISession;
diff --git a/lib/private/share/mailnotifications.php b/lib/private/share/mailnotifications.php
index f45d80b37c..4d282158ba 100644
--- a/lib/private/share/mailnotifications.php
+++ b/lib/private/share/mailnotifications.php
@@ -176,10 +176,12 @@ class MailNotifications {
$subject = (string)$this->l->t('%s shared »%s« with you', [$this->senderDisplayName, $filename]);
list($htmlBody, $textBody) = $this->createMailBody($filename, $link, $expiration);
+ $recipient = str_replace([', ', '; ', ',', ';', ' '], ',', $recipient);
+ $recipients = explode(',', $recipient);
try {
$message = $this->mailer->createMessage();
$message->setSubject($subject);
- $message->setTo([$recipient]);
+ $message->setTo($recipients);
$message->setHtmlBody($htmlBody);
$message->setPlainBody($textBody);
$message->setFrom([
diff --git a/lib/private/share/share.php b/lib/private/share/share.php
index 70f9a6e892..8899df2563 100644
--- a/lib/private/share/share.php
+++ b/lib/private/share/share.php
@@ -745,10 +745,8 @@ class Share extends Constants {
// The check for each user in the group is done inside the put() function
if ($checkExists = self::getItems($itemType, $itemSource, self::SHARE_TYPE_GROUP, $shareWith,
null, self::FORMAT_NONE, null, 1, true, true)) {
- // Only allow the same share to occur again if it is the same
- // owner and is not a group share, this use case is for increasing
- // permissions for a specific user
- if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
+
+ if ($checkExists['share_with'] === $shareWith && $checkExists['share_type'] === \OCP\Share::SHARE_TYPE_GROUP) {
$message = 'Sharing %s failed, because this item is already shared with %s';
$message_t = $l->t('Sharing %s failed, because this item is already shared with %s', array($itemSourceName, $shareWith));
\OCP\Util::writeLog('OCP\Share', sprintf($message, $itemSourceName, $shareWith), \OCP\Util::DEBUG);
diff --git a/lib/private/systemtag/systemtagmanager.php b/lib/private/systemtag/systemtagmanager.php
index 8caf10d69d..7f239dc84c 100644
--- a/lib/private/systemtag/systemtagmanager.php
+++ b/lib/private/systemtag/systemtagmanager.php
@@ -63,7 +63,7 @@ class SystemTagManager implements ISystemTagManager {
/**
* {@inheritdoc}
*/
- public function getTagsById($tagIds) {
+ public function getTagsByIds($tagIds) {
if (!is_array($tagIds)) {
$tagIds = [$tagIds];
}
@@ -242,7 +242,7 @@ class SystemTagManager implements ISystemTagManager {
$tagNotFoundException = null;
try {
- $this->getTagsById($tagIds);
+ $this->getTagsByIds($tagIds);
} catch (TagNotFoundException $e) {
$tagNotFoundException = $e;
}
diff --git a/lib/private/systemtag/systemtagobjectmapper.php b/lib/private/systemtag/systemtagobjectmapper.php
index 75f2631a01..988fa66d77 100644
--- a/lib/private/systemtag/systemtagobjectmapper.php
+++ b/lib/private/systemtag/systemtagobjectmapper.php
@@ -171,6 +171,10 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
public function haveTag($objIds, $objectType, $tagId, $all = true) {
$this->assertTagsExist([$tagId]);
+ if (!is_array($objIds)) {
+ $objIds = [$objIds];
+ }
+
$query = $this->connection->getQueryBuilder();
if (!$all) {
@@ -209,7 +213,7 @@ class SystemTagObjectMapper implements ISystemTagObjectMapper {
* @throws \OCP\SystemTag\TagNotFoundException if at least one tag did not exist
*/
private function assertTagsExist($tagIds) {
- $tags = $this->tagManager->getTagsById($tagIds);
+ $tags = $this->tagManager->getTagsByIds($tagIds);
if (count($tags) !== count($tagIds)) {
// at least one tag missing, bail out
$foundTagIds = array_map(
diff --git a/lib/private/template.php b/lib/private/template.php
index 1476a964ef..d794dacac2 100644
--- a/lib/private/template.php
+++ b/lib/private/template.php
@@ -226,12 +226,12 @@ class OC_Template extends \OC\Template\Base {
// Add custom headers
$headers = '';
foreach(OC_Util::$headers as $header) {
- $headers .= '<'.OC_Util::sanitizeHTML($header['tag']);
+ $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']);
foreach($header['attributes'] as $name=>$value) {
- $headers .= ' '.OC_Util::sanitizeHTML($name).'="'.OC_Util::sanitizeHTML($value).'"';
+ $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"';
}
if ($header['text'] !== null) {
- $headers .= '>'.OC_Util::sanitizeHTML($header['text']).''.OC_Util::sanitizeHTML($header['tag']).'>';
+ $headers .= '>'.\OCP\Util::sanitizeHTML($header['text']).''.\OCP\Util::sanitizeHTML($header['tag']).'>';
} else {
$headers .= '/>';
}
diff --git a/lib/private/template/functions.php b/lib/private/template/functions.php
index 79d18632d2..d156d26f9c 100644
--- a/lib/private/template/functions.php
+++ b/lib/private/template/functions.php
@@ -33,7 +33,7 @@
* @param string $string the string which will be escaped and printed
*/
function p($string) {
- print(OC_Util::sanitizeHTML($string));
+ print(\OCP\Util::sanitizeHTML($string));
}
/**
@@ -262,7 +262,7 @@ function html_select_options($options, $selected, $params=array()) {
$label = $label[$label_name];
}
$select = in_array($value, $selected) ? ' selected="selected"' : '';
- $html .= '
'."\n";
+ $html .= '
'."\n";
}
return $html;
}
diff --git a/lib/private/tempmanager.php b/lib/private/tempmanager.php
index 365d639389..ac44b76d68 100644
--- a/lib/private/tempmanager.php
+++ b/lib/private/tempmanager.php
@@ -213,7 +213,7 @@ class TempManager implements ITempManager {
if ($temp = $this->config->getSystemValue('tempdirectory', null)) {
$directories[] = $temp;
}
- if ($temp = ini_get('upload_tmp_dir')) {
+ if ($temp = \OC::$server->getIniWrapper()->get('upload_tmp_dir')) {
$directories[] = $temp;
}
if ($temp = getenv('TMP')) {
diff --git a/lib/private/util.php b/lib/private/util.php
index ac42b96de2..eb188b649e 100644
--- a/lib/private/util.php
+++ b/lib/private/util.php
@@ -947,6 +947,14 @@ class OC_Util {
$parameters['redirect_url'] = $_REQUEST['redirect_url'];
}
+ $parameters['canResetPassword'] = true;
+ if (!\OC::$server->getSystemConfig()->getValue('lost_password_link')) {
+ $user = \OC::$server->getUserManager()->get($_REQUEST['user']);
+ if ($user instanceof IUser) {
+ $parameters['canResetPassword'] = $user->canChangePassword();
+ }
+ }
+
$parameters['alt_login'] = OC_App::getAlternativeLogIns();
$parameters['rememberLoginAllowed'] = self::rememberLoginAllowed();
\OC_Hook::emit('OC_Util', 'pre_displayLoginPage', array('parameters' => $parameters));
@@ -1169,14 +1177,16 @@ class OC_Util {
* This function is used to sanitize HTML and should be applied on any
* string or array of strings before displaying it on a web page.
*
- * @param string|array &$value
+ * @param string|array $value
* @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter.
*/
- public static function sanitizeHTML(&$value) {
+ public static function sanitizeHTML($value) {
if (is_array($value)) {
- array_walk_recursive($value, 'OC_Util::sanitizeHTML');
+ $value = array_map(function($value) {
+ return self::sanitizeHTML($value);
+ }, $value);
} else {
- //Specify encoding for PHP<5.4
+ // Specify encoding for PHP<5.4
$value = htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8');
}
return $value;
@@ -1237,7 +1247,11 @@ class OC_Util {
// accessing the file via http
$url = OC_Helper::makeURLAbsolute(OC::$WEBROOT . '/data' . $fileName);
- $content = self::getUrlContent($url);
+ try {
+ $content = \OC::$server->getHTTPClientService()->newClient()->get($url)->getBody();
+ } catch (\Exception $e) {
+ $content = false;
+ }
// cleanup
@unlink($testFile);
@@ -1312,23 +1326,6 @@ class OC_Util {
return \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate($length, \OCP\Security\ISecureRandom::CHAR_LOWER.\OCP\Security\ISecureRandom::CHAR_DIGITS);
}
- /**
- * Get URL content
- * @param string $url Url to get content
- * @throws Exception If the URL does not start with http:// or https://
- * @return string of the response or false on error
- * This function get the content of a page via curl, if curl is enabled.
- * If not, file_get_contents is used.
- * @deprecated Use \OC::$server->getHTTPClientService()->newClient()->get($url);
- */
- public static function getUrlContent($url) {
- try {
- return \OC::$server->getHTTPHelper()->getUrlContent($url);
- } catch (\Exception $e) {
- throw $e;
- }
- }
-
/**
* Checks whether the server is running on Windows
*
@@ -1418,7 +1415,7 @@ class OC_Util {
}
// XCache
if (function_exists('xcache_clear_cache')) {
- if (ini_get('xcache.admin.enable_auth')) {
+ if (\OC::$server->getIniWrapper()->getBool('xcache.admin.enable_auth')) {
\OCP\Util::writeLog('core', 'XCache opcode cache will not be cleared because "xcache.admin.enable_auth" is enabled.', \OCP\Util::WARN);
} else {
@xcache_clear_cache(XC_TYPE_PHP, 0);
diff --git a/lib/public/app.php b/lib/public/app.php
index c66d988c31..cc41484262 100644
--- a/lib/public/app.php
+++ b/lib/public/app.php
@@ -82,7 +82,8 @@ class App {
* @since 4.0.0
*/
public static function setActiveNavigationEntry( $id ) {
- return \OC_App::setActiveNavigationEntry( $id );
+ \OC::$server->getNavigationManager()->setActiveEntry($id);
+ return true;
}
/**
diff --git a/lib/public/db/querybuilder/iquerybuilder.php b/lib/public/db/querybuilder/iquerybuilder.php
index beb922b7fe..dd3ee7da5f 100644
--- a/lib/public/db/querybuilder/iquerybuilder.php
+++ b/lib/public/db/querybuilder/iquerybuilder.php
@@ -256,6 +256,22 @@ interface IQueryBuilder {
*/
public function selectAlias($select, $alias);
+ /**
+ * Specifies an item that is to be returned uniquely in the query result.
+ *
+ *
+ * $qb = $conn->getQueryBuilder()
+ * ->selectDistinct('type')
+ * ->from('users');
+ *
+ *
+ * @param mixed $select The selection expressions.
+ *
+ * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
+ * @since 9.0.0
+ */
+ public function selectDistinct($select);
+
/**
* Adds an item that is to be returned in the query result.
*
@@ -796,4 +812,31 @@ interface IQueryBuilder {
* @since 8.2.0
*/
public function createFunction($call);
+
+ /**
+ * Used to get the id of the last inserted element
+ * @return int
+ * @throws \BadMethodCallException When being called before an insert query has been run.
+ * @since 9.0.0
+ */
+ public function getLastInsertId();
+
+ /**
+ * Returns the table name quoted and with database prefix as needed by the implementation
+ *
+ * @param string $table
+ * @return string
+ * @since 9.0.0
+ */
+ public function getTableName($table);
+
+ /**
+ * Returns the column name quoted and with table alias prefix as needed by the implementation
+ *
+ * @param string $column
+ * @param string $tableAlias
+ * @return string
+ * @since 9.0.0
+ */
+ public function getColumnName($column, $tableAlias = '');
}
diff --git a/lib/public/systemtag/isystemtagmanager.php b/lib/public/systemtag/isystemtagmanager.php
index 4e3b263e56..6e8fed36dc 100644
--- a/lib/public/systemtag/isystemtagmanager.php
+++ b/lib/public/systemtag/isystemtagmanager.php
@@ -41,7 +41,7 @@ interface ISystemTagManager {
*
* @since 9.0.0
*/
- public function getTagsById($tagIds);
+ public function getTagsByIds($tagIds);
/**
* Returns the tag object matching the given attributes.
diff --git a/lib/public/util.php b/lib/public/util.php
index 110028368d..4e783b764e 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -497,11 +497,11 @@ class Util {
* string or array of strings before displaying it on a web page.
*
* @param string|array $value
- * @return string|array an array of sanitized strings or a single sinitized string, depends on the input parameter.
+ * @return string|array an array of sanitized strings or a single sanitized string, depends on the input parameter.
* @since 4.5.0
*/
- public static function sanitizeHTML( $value ) {
- return(\OC_Util::sanitizeHTML($value));
+ public static function sanitizeHTML($value) {
+ return \OC_Util::sanitizeHTML($value);
}
/**
diff --git a/lib/repair/repairconfig.php b/lib/repair/repairconfig.php
deleted file mode 100644
index 66fdd47269..0000000000
--- a/lib/repair/repairconfig.php
+++ /dev/null
@@ -1,80 +0,0 @@
-
- * @author Morris Jobke
- *
- * @copyright Copyright (c) 2015, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program 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, version 3,
- * along with this program. If not, see
- *
- */
-
-namespace OC\Repair;
-
-use OC\Hooks\BasicEmitter;
-use OC\RepairStep;
-use Sabre\DAV\Exception;
-
-/**
- * Class RepairConfig
- *
- * @package OC\Repair
- */
-class RepairConfig extends BasicEmitter implements RepairStep {
-
- /**
- * @return string
- */
- public function getName() {
- return 'Repair config';
- }
-
- /**
- * Updates the configuration after running an update
- */
- public function run() {
- $this->addSecret();
- $this->removePortsFromTrustedDomains();
- }
-
- /**
- * Adds a secret to config.php
- */
- private function addSecret() {
- if(\OC::$server->getConfig()->getSystemValue('secret', null) === null) {
- $secret = \OC::$server->getSecureRandom()->getMediumStrengthGenerator()->generate(48);
- \OC::$server->getConfig()->setSystemValue('secret', $secret);
- }
- }
-
-
- /**
- * Remove ports from existing trusted domains in config.php
- */
- private function removePortsFromTrustedDomains() {
- $trustedDomains = \OC::$server->getConfig()->getSystemValue('trusted_domains', array());
- $newTrustedDomains = array();
- foreach($trustedDomains as $domain) {
- $pos = strrpos($domain, ':');
- if ($pos !== false) {
- $port = substr($domain, $pos + 1);
- if (is_numeric($port)) {
- $domain = substr($domain, 0, $pos);
- }
- }
- $newTrustedDomains[] = $domain;
- }
- \OC::$server->getConfig()->setSystemValue('trusted_domains', $newTrustedDomains);
- }
-}
diff --git a/settings/admin.php b/settings/admin.php
index bccb117174..ae4340cf14 100644
--- a/settings/admin.php
+++ b/settings/admin.php
@@ -33,7 +33,7 @@
use OC\Lock\NoopLockingProvider;
OC_Util::checkAdminUser();
-OC_App::setActiveNavigationEntry("admin");
+\OC::$server->getNavigationManager()->setActiveEntry("admin");
$template = new OC_Template('settings', 'admin', 'user');
$l = \OC::$server->getL10N('settings');
diff --git a/settings/application.php b/settings/application.php
index f9ee0121db..729e61b592 100644
--- a/settings/application.php
+++ b/settings/application.php
@@ -136,7 +136,8 @@ class Application extends App {
$c->query('Mailer'),
$c->query('DefaultMailAddress'),
$c->query('URLGenerator'),
- $c->query('OCP\\App\\IAppManager')
+ $c->query('OCP\\App\\IAppManager'),
+ $c->query('OCP\\IAvatarManager')
);
});
$container->registerService('LogSettingsController', function(IContainer $c) {
diff --git a/settings/controller/userscontroller.php b/settings/controller/userscontroller.php
index 827f74c4c8..8ad975fd66 100644
--- a/settings/controller/userscontroller.php
+++ b/settings/controller/userscontroller.php
@@ -27,7 +27,6 @@
namespace OC\Settings\Controller;
use OC\AppFramework\Http;
-use OC\Settings\Factory\SubAdminFactory;
use OC\User\User;
use OCP\App\IAppManager;
use OCP\AppFramework\Controller;
@@ -43,6 +42,7 @@ use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Mail\IMailer;
+use OCP\IAvatarManager;
/**
* @package OC\Settings\Controller
@@ -74,6 +74,8 @@ class UsersController extends Controller {
private $isEncryptionAppEnabled;
/** @var bool contains the state of the admin recovery setting */
private $isRestoreEnabled = false;
+ /** @var IAvatarManager */
+ private $avatarManager;
/**
* @param string $appName
@@ -104,7 +106,8 @@ class UsersController extends Controller {
IMailer $mailer,
$fromMailAddress,
IURLGenerator $urlGenerator,
- IAppManager $appManager) {
+ IAppManager $appManager,
+ IAvatarManager $avatarManager) {
parent::__construct($appName, $request);
$this->userManager = $userManager;
$this->groupManager = $groupManager;
@@ -117,6 +120,7 @@ class UsersController extends Controller {
$this->mailer = $mailer;
$this->fromMailAddress = $fromMailAddress;
$this->urlGenerator = $urlGenerator;
+ $this->avatarManager = $avatarManager;
// check for encryption state - TODO see formatUserForIndex
$this->isEncryptionAppEnabled = $appManager->isEnabledForUser('encryption');
@@ -168,6 +172,12 @@ class UsersController extends Controller {
if (is_null($displayName)) {
$displayName = '';
}
+
+ $avatarAvailable = false;
+ if ($this->config->getSystemValue('enable_avatars', true) === true) {
+ $avatarAvailable = $this->avatarManager->getAvatar($user->getUID())->exists();
+ }
+
return [
'name' => $user->getUID(),
'displayname' => $user->getDisplayName(),
@@ -179,6 +189,7 @@ class UsersController extends Controller {
'backend' => $user->getBackendClassName(),
'email' => $displayName,
'isRestoreDisabled' => !$restorePossible,
+ 'isAvatarAvailable' => $avatarAvailable,
];
}
diff --git a/settings/help.php b/settings/help.php
index aa89277d88..60719a3df9 100644
--- a/settings/help.php
+++ b/settings/help.php
@@ -30,7 +30,7 @@ OC_Util::checkLoggedIn();
// Load the files we need
OC_Util::addStyle( "settings", "settings" );
-OC_App::setActiveNavigationEntry( "help" );
+\OC::$server->getNavigationManager()->setActiveEntry('help');
if(isset($_GET['mode']) and $_GET['mode'] === 'admin') {
diff --git a/settings/js/users/users.js b/settings/js/users/users.js
index aeecac7b24..2f8a964baf 100644
--- a/settings/js/users/users.js
+++ b/settings/js/users/users.js
@@ -64,8 +64,12 @@ var UserList = {
/**
* Avatar or placeholder
*/
- if ($tr.find('div.avatardiv').length){
- $('div.avatardiv', $tr).avatar(user.name, 32, undefined, undefined, undefined, user.displayname);
+ if ($tr.find('div.avatardiv').length) {
+ if (user.isAvatarAvailable === true) {
+ $('div.avatardiv', $tr).avatar(user.name, 32, undefined, undefined, undefined, user.displayname);
+ } else {
+ $('div.avatardiv', $tr).imageplaceholder(user.displayname);
+ }
}
/**
diff --git a/settings/personal.php b/settings/personal.php
index 6c2ac35145..9a71439358 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -165,6 +165,7 @@ $l = \OC::$server->getL10N('settings');
$formsAndMore = [];
$formsAndMore[]= ['anchor' => 'clientsbox', 'section-name' => $l->t('Sync clients')];
$formsAndMore[]= ['anchor' => 'passwordform', 'section-name' => $l->t('Personal info')];
+$formsAndMore[]= ['anchor' => 'groups', 'section-name' => $l->t('Groups')];
$forms=OC_App::getForms('personal');
diff --git a/settings/templates/admin.php b/settings/templates/admin.php
index 0721c0e0af..f3de51a23c 100644
--- a/settings/templates/admin.php
+++ b/settings/templates/admin.php
@@ -56,7 +56,7 @@ if ($_['mail_smtpmode'] == 'qmail') {
if (isset($form['anchor'])) {
$anchor = '#' . $form['anchor'];
$sectionName = $form['section-name'];
- print_unescaped(sprintf("%s", OC_Util::sanitizeHTML($anchor), OC_Util::sanitizeHTML($sectionName)));
+ print_unescaped(sprintf("%s", \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName)));
}
}?>
diff --git a/settings/templates/personal.php b/settings/templates/personal.php
index 0eba71d77d..09194ea3e3 100644
--- a/settings/templates/personal.php
+++ b/settings/templates/personal.php
@@ -14,7 +14,7 @@
if (isset($form['anchor'])) {
$anchor = '#' . $form['anchor'];
$sectionName = $form['section-name'];
- print_unescaped(sprintf("%s", OC_Util::sanitizeHTML($anchor), OC_Util::sanitizeHTML($sectionName)));
+ print_unescaped(sprintf("%s", \OCP\Util::sanitizeHTML($anchor), \OCP\Util::sanitizeHTML($sectionName)));
}
}?>
diff --git a/settings/users.php b/settings/users.php
index 2795032a16..ccf1bcd9e1 100644
--- a/settings/users.php
+++ b/settings/users.php
@@ -35,7 +35,7 @@
OC_Util::checkSubAdminUser();
-OC_App::setActiveNavigationEntry( 'core_users' );
+\OC::$server->getNavigationManager()->setActiveEntry('core_users');
$userManager = \OC_User::getManager();
$groupManager = \OC_Group::getManager();
diff --git a/tests/core/avatar/avatarcontrollertest.php b/tests/core/avatar/avatarcontrollertest.php
index efe41763ff..a113add72b 100644
--- a/tests/core/avatar/avatarcontrollertest.php
+++ b/tests/core/avatar/avatarcontrollertest.php
@@ -23,14 +23,11 @@ namespace OC\Core\Avatar;
use OC;
use OC\Core\Application;
use OCP\AppFramework\IAppContainer;
-use OC\Files\Filesystem;
use OCP\AppFramework\Http;
-use OCP\Image;
use OCP\Files\Folder;
use OCP\Files\File;
use OCP\IUser;
use OCP\IAvatar;
-
use Test\Traits\UserTrait;
/**
diff --git a/tests/karma.config.js b/tests/karma.config.js
index dc621ae0f7..df09ee1b31 100644
--- a/tests/karma.config.js
+++ b/tests/karma.config.js
@@ -67,7 +67,8 @@ module.exports = function(config) {
// up with the global namespace/classes/state
'apps/files_external/js/app.js',
'apps/files_external/js/mountsfilelist.js',
- 'apps/files_external/js/settings.js'
+ 'apps/files_external/js/settings.js',
+ 'apps/files_external/js/statusmanager.js'
],
testFiles: ['apps/files_external/tests/js/*.js']
},
diff --git a/tests/lib/appframework/http/RequestTest.php b/tests/lib/appframework/http/RequestTest.php
index 92a2cc01dd..32603d0da5 100644
--- a/tests/lib/appframework/http/RequestTest.php
+++ b/tests/lib/appframework/http/RequestTest.php
@@ -10,7 +10,6 @@
namespace OC\AppFramework\Http;
-use OC\Security\Crypto;
use OCP\Security\ISecureRandom;
use OCP\IConfig;
diff --git a/tests/lib/db/querybuilder/querybuildertest.php b/tests/lib/db/querybuilder/querybuildertest.php
index ca3901ad04..c8e029d9e4 100644
--- a/tests/lib/db/querybuilder/querybuildertest.php
+++ b/tests/lib/db/querybuilder/querybuildertest.php
@@ -48,12 +48,12 @@ class QueryBuilderTest extends \Test\TestCase {
$this->queryBuilder = new QueryBuilder($this->connection);
}
- protected function createTestingRows() {
+ protected function createTestingRows($appId = 'testFirstResult') {
$qB = $this->connection->getQueryBuilder();
for ($i = 1; $i < 10; $i++) {
$qB->insert('*PREFIX*appconfig')
->values([
- 'appid' => $qB->expr()->literal('testFirstResult'),
+ 'appid' => $qB->expr()->literal($appId),
'configkey' => $qB->expr()->literal('testing' . $i),
'configvalue' => $qB->expr()->literal(100 - $i),
])
@@ -80,11 +80,11 @@ class QueryBuilderTest extends \Test\TestCase {
return $rows;
}
- protected function deleteTestingRows() {
+ protected function deleteTestingRows($appId = 'testFirstResult') {
$qB = $this->connection->getQueryBuilder();
$qB->delete('*PREFIX*appconfig')
- ->where($qB->expr()->eq('appid', $qB->expr()->literal('testFirstResult')))
+ ->where($qB->expr()->eq('appid', $qB->expr()->literal($appId)))
->execute();
}
@@ -272,6 +272,34 @@ class QueryBuilderTest extends \Test\TestCase {
$this->deleteTestingRows();
}
+ public function testSelectDistinct() {
+ $this->deleteTestingRows('testFirstResult1');
+ $this->deleteTestingRows('testFirstResult2');
+ $this->createTestingRows('testFirstResult1');
+ $this->createTestingRows('testFirstResult2');
+
+ $this->queryBuilder->selectDistinct('appid');
+
+ $this->queryBuilder->from('*PREFIX*appconfig')
+ ->where($this->queryBuilder->expr()->in(
+ 'appid',
+ [$this->queryBuilder->expr()->literal('testFirstResult1'), $this->queryBuilder->expr()->literal('testFirstResult2')]
+ ))
+ ->orderBy('appid', 'DESC');
+
+ $query = $this->queryBuilder->execute();
+ $rows = $query->fetchAll();
+ $query->closeCursor();
+
+ $this->assertEquals(
+ [['appid' => 'testFirstResult2'], ['appid' => 'testFirstResult1']],
+ $rows
+ );
+
+ $this->deleteTestingRows('testFirstResult1');
+ $this->deleteTestingRows('testFirstResult2');
+ }
+
public function dataAddSelect() {
$queryBuilder = new QueryBuilder(\OC::$server->getDatabaseConnection());
return [
@@ -1086,6 +1114,31 @@ class QueryBuilderTest extends \Test\TestCase {
);
}
+ public function testGetLastInsertId() {
+ $qB = $this->connection->getQueryBuilder();
+
+ try {
+ $qB->getLastInsertId();
+ $this->fail('getLastInsertId() should throw an exception, when being called before insert()');
+ } catch (\BadMethodCallException $e) {
+ $this->assertTrue(true);
+ }
+
+ $qB->insert('appconfig')
+ ->values([
+ 'appid' => $qB->expr()->literal('testFirstResult'),
+ 'configkey' => $qB->expr()->literal('testing' . 50),
+ 'configvalue' => $qB->expr()->literal(100 - 50),
+ ])
+ ->execute();
+
+ $actual = $qB->getLastInsertId();
+
+ $this->assertNotNull($actual);
+ $this->assertInternalType('int', $actual);
+ $this->assertEquals($this->connection->lastInsertId('*PREFIX*appconfig'), $actual);
+ }
+
public function dataGetTableName() {
return [
['*PREFIX*table', null, '`*PREFIX*table`'],
@@ -1112,7 +1165,27 @@ class QueryBuilderTest extends \Test\TestCase {
$this->assertSame(
$expected,
- $this->invokePrivate($this->queryBuilder, 'getTableName', [$tableName])
+ $this->queryBuilder->getTableName($tableName)
+ );
+ }
+
+ public function dataGetColumnName() {
+ return [
+ ['column', '', '`column`'],
+ ['column', 'a', 'a.`column`'],
+ ];
+ }
+
+ /**
+ * @dataProvider dataGetColumnName
+ * @param string $column
+ * @param string $prefix
+ * @param string $expected
+ */
+ public function testGetColumnName($column, $prefix, $expected) {
+ $this->assertSame(
+ $expected,
+ $this->queryBuilder->getColumnName($column, $prefix)
);
}
}
diff --git a/tests/lib/files/view.php b/tests/lib/files/view.php
index 186cf28d7c..1fc4b9ab68 100644
--- a/tests/lib/files/view.php
+++ b/tests/lib/files/view.php
@@ -2389,4 +2389,39 @@ class View extends \Test\TestCase {
$view = new \OC\Files\View('/' . $this->user . '/files');
$this->assertEquals('foo', $view->rmdir('mount'));
}
+
+ public function mimeFilterProvider() {
+ return [
+ [null, ['test1.txt', 'test2.txt', 'test3.md', 'test4.png']],
+ ['text/plain', ['test1.txt', 'test2.txt']],
+ ['text/markdown', ['test3.md']],
+ ['text', ['test1.txt', 'test2.txt', 'test3.md']],
+ ];
+ }
+
+ /**
+ * @param string $filter
+ * @param string[] $expected
+ * @dataProvider mimeFilterProvider
+ */
+ public function testGetDirectoryContentMimeFilter($filter, $expected) {
+ $storage1 = new Temporary();
+ $root = $this->getUniqueID('/');
+ \OC\Files\Filesystem::mount($storage1, array(), $root . '/');
+ $view = new \OC\Files\View($root);
+
+ $view->file_put_contents('test1.txt', 'asd');
+ $view->file_put_contents('test2.txt', 'asd');
+ $view->file_put_contents('test3.md', 'asd');
+ $view->file_put_contents('test4.png', '');
+
+ $content = $view->getDirectoryContent('', $filter);
+
+ $files = array_map(function(FileInfo $info) {
+ return $info->getName();
+ }, $content);
+ sort($files);
+
+ $this->assertEquals($expected, $files);
+ }
}
diff --git a/tests/lib/security/trusteddomainhelper.php b/tests/lib/security/trusteddomainhelper.php
index c8d5ffa587..52a8f1be63 100644
--- a/tests/lib/security/trusteddomainhelper.php
+++ b/tests/lib/security/trusteddomainhelper.php
@@ -64,6 +64,8 @@ class TrustedDomainHelperTest extends \Test\TestCase {
// do not trust invalid localhosts
[$trustedHostTestList, 'localhost:1:2', false],
[$trustedHostTestList, 'localhost: evil.host', false],
+ // do not trust casting
+ [[1], '1', false],
];
}
diff --git a/tests/lib/share/MailNotificationsTest.php b/tests/lib/share/MailNotificationsTest.php
index 2124a8bf13..8684886e79 100644
--- a/tests/lib/share/MailNotificationsTest.php
+++ b/tests/lib/share/MailNotificationsTest.php
@@ -123,7 +123,23 @@ class MailNotificationsTest extends \Test\TestCase {
$this->assertSame([], $mailNotifications->sendLinkShareMail('lukas@owncloud.com', 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
}
- public function testSendLinkShareMailWithReplyTo() {
+ public function dataSendLinkShareMailWithReplyTo() {
+ return [
+ ['lukas@owncloud.com', ['lukas@owncloud.com']],
+ ['lukas@owncloud.com nickvergessen@owncloud.com', ['lukas@owncloud.com', 'nickvergessen@owncloud.com']],
+ ['lukas@owncloud.com,nickvergessen@owncloud.com', ['lukas@owncloud.com', 'nickvergessen@owncloud.com']],
+ ['lukas@owncloud.com, nickvergessen@owncloud.com', ['lukas@owncloud.com', 'nickvergessen@owncloud.com']],
+ ['lukas@owncloud.com;nickvergessen@owncloud.com', ['lukas@owncloud.com', 'nickvergessen@owncloud.com']],
+ ['lukas@owncloud.com; nickvergessen@owncloud.com', ['lukas@owncloud.com', 'nickvergessen@owncloud.com']],
+ ];
+ }
+
+ /**
+ * @dataProvider dataSendLinkShareMailWithReplyTo
+ * @param string $to
+ * @param array $expectedTo
+ */
+ public function testSendLinkShareMailWithReplyTo($to, array $expectedTo) {
$message = $this->getMockBuilder('\OC\Mail\Message')
->disableOriginalConstructor()->getMock();
@@ -134,7 +150,7 @@ class MailNotificationsTest extends \Test\TestCase {
$message
->expects($this->once())
->method('setTo')
- ->with(['lukas@owncloud.com']);
+ ->with($expectedTo);
$message
->expects($this->once())
->method('setHtmlBody');
@@ -167,7 +183,7 @@ class MailNotificationsTest extends \Test\TestCase {
$this->logger,
$this->defaults
);
- $this->assertSame([], $mailNotifications->sendLinkShareMail('lukas@owncloud.com', 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
+ $this->assertSame([], $mailNotifications->sendLinkShareMail($to, 'MyFile', 'https://owncloud.com/file/?foo=bar', 3600));
}
public function testSendLinkShareMailException() {
diff --git a/tests/lib/systemtag/systemtagmanagertest.php b/tests/lib/systemtag/systemtagmanagertest.php
index 8498b85519..97c072f33f 100644
--- a/tests/lib/systemtag/systemtagmanagertest.php
+++ b/tests/lib/systemtag/systemtagmanagertest.php
@@ -250,7 +250,7 @@ class SystemTagManagerTest extends TestCase {
$tag1 = $this->tagManager->createTag('one', true, false);
$tag2 = $this->tagManager->createTag('two', false, true);
- $tagList = $this->tagManager->getTagsById([$tag1->getId(), $tag2->getId()]);
+ $tagList = $this->tagManager->getTagsByIds([$tag1->getId(), $tag2->getId()]);
$this->assertCount(2, $tagList);
@@ -270,7 +270,7 @@ class SystemTagManagerTest extends TestCase {
*/
public function testGetNonExistingTagsById() {
$tag1 = $this->tagManager->createTag('one', true, false);
- $this->tagManager->getTagsById([$tag1->getId(), 100, 101]);
+ $this->tagManager->getTagsByIds([$tag1->getId(), 100, 101]);
}
/**
@@ -278,7 +278,7 @@ class SystemTagManagerTest extends TestCase {
*/
public function testGetInvalidTagIdFormat() {
$tag1 = $this->tagManager->createTag('one', true, false);
- $this->tagManager->getTagsById([$tag1->getId() . 'suffix']);
+ $this->tagManager->getTagsByIds([$tag1->getId() . 'suffix']);
}
public function updateTagProvider() {
diff --git a/tests/lib/systemtag/systemtagobjectmappertest.php b/tests/lib/systemtag/systemtagobjectmappertest.php
index 43d0b8c696..4ea80c216e 100644
--- a/tests/lib/systemtag/systemtagobjectmappertest.php
+++ b/tests/lib/systemtag/systemtagobjectmappertest.php
@@ -74,7 +74,7 @@ class SystemTagObjectMapperTest extends TestCase {
$this->tag3 = new SystemTag(3, 'testtag3', false, false);
$this->tagManager->expects($this->any())
- ->method('getTagsById')
+ ->method('getTagsByIds')
->will($this->returnCallback(function($tagIds) {
$result = [];
if (in_array(1, $tagIds)) {
diff --git a/tests/lib/util.php b/tests/lib/util.php
index 9b82be3695..fa559c17c8 100644
--- a/tests/lib/util.php
+++ b/tests/lib/util.php
@@ -95,16 +95,22 @@ class Test_Util extends \Test\TestCase {
}
function testSanitizeHTML() {
- $badArray = array(
+ $badArray = [
'While it is unusual to pass an array',
'this function actually it.',
- 'And therefore there needs to be a for it!'
- );
- $goodArray = array(
+ 'And therefore there needs to be a for it!',
+ [
+ 'And It Even May Nest',
+ ],
+ ];
+ $goodArray = [
'While it is unusual to pass an array',
'this function actually <blink>supports</blink> it.',
- 'And therefore there needs to be a <script>alert("Unit"+'test')</script> for it!'
- );
+ 'And therefore there needs to be a <script>alert("Unit"+'test')</script> for it!',
+ [
+ 'And It Even May <strong>Nest</strong>'
+ ],
+ ];
$result = OC_Util::sanitizeHTML($badArray);
$this->assertEquals($goodArray, $result);
diff --git a/tests/settings/controller/userscontrollertest.php b/tests/settings/controller/userscontrollertest.php
index b52d6c66aa..e1e3c4d4b6 100644
--- a/tests/settings/controller/userscontrollertest.php
+++ b/tests/settings/controller/userscontrollertest.php
@@ -54,6 +54,30 @@ class UsersControllerTest extends \Test\TestCase {
->disableOriginalConstructor()->getMock();
$this->container['OCP\\App\\IAppManager'] = $this->getMockBuilder('OCP\\App\\IAppManager')
->disableOriginalConstructor()->getMock();
+
+
+ /*
+ * Set default avtar behaviour for whole testsuite
+ */
+ $this->container['OCP\\IAvatarManager'] = $this->getMock('OCP\IAvatarManager');
+
+ $avatarExists = $this->getMock('OCP\IAvatar');
+ $avatarExists->method('exists')->willReturn(true);
+ $avatarNotExists = $this->getMock('OCP\IAvatar');
+ $avatarNotExists->method('exists')->willReturn(false);
+ $this->container['OCP\\IAvatarManager']
+ ->method('getAvatar')
+ ->will($this->returnValueMap([
+ ['foo', $avatarExists],
+ ['bar', $avatarExists],
+ ['admin', $avatarNotExists],
+ ]));
+
+ $this->container['Config']
+ ->method('getSystemValue')
+ ->with('enable_avatars', true)
+ ->willReturn(true);
+
}
public function testIndexAdmin() {
@@ -62,7 +86,7 @@ class UsersControllerTest extends \Test\TestCase {
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('foo'));
$foo
@@ -86,7 +110,7 @@ class UsersControllerTest extends \Test\TestCase {
$admin = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$admin
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('admin'));
$admin
@@ -112,7 +136,7 @@ class UsersControllerTest extends \Test\TestCase {
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('bar'));
$bar
@@ -188,7 +212,6 @@ class UsersControllerTest extends \Test\TestCase {
->method('getSubAdmin')
->will($this->returnValue($subadmin));
-
$expectedResponse = new DataResponse(
array(
0 => array(
@@ -202,6 +225,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => 'OC_User_Database',
'email' => 'foo@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
1 => array(
'name' => 'admin',
@@ -214,6 +238,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => '\Test\Util\User\Dummy',
'email' => 'admin@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => false,
),
2 => array(
'name' => 'bar',
@@ -226,6 +251,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => '\Test\Util\User\Dummy',
'email' => 'bar@dummy.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
)
);
@@ -246,7 +272,7 @@ class UsersControllerTest extends \Test\TestCase {
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('foo'));
$foo
@@ -270,7 +296,7 @@ class UsersControllerTest extends \Test\TestCase {
$admin = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$admin
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('admin'));
$admin
@@ -296,7 +322,7 @@ class UsersControllerTest extends \Test\TestCase {
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('bar'));
$bar
@@ -401,6 +427,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => '\Test\Util\User\Dummy',
'email' => 'bar@dummy.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
],
1=> [
'name' => 'foo',
@@ -413,6 +440,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => 'OC_User_Database',
'email' => 'foo@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
],
2 => [
'name' => 'admin',
@@ -425,6 +453,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => '\Test\Util\User\Dummy',
'email' => 'admin@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => false,
],
]
);
@@ -443,7 +472,7 @@ class UsersControllerTest extends \Test\TestCase {
$foo = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$foo
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('foo'));
$foo
@@ -467,7 +496,7 @@ class UsersControllerTest extends \Test\TestCase {
$admin = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$admin
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('admin'));
$admin
@@ -493,7 +522,7 @@ class UsersControllerTest extends \Test\TestCase {
$bar = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$bar
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('bar'));
$bar
@@ -553,6 +582,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => 'OC_User_Database',
'email' => 'foo@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
1 => array(
'name' => 'admin',
@@ -565,6 +595,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => '\Test\Util\User\Dummy',
'email' => 'admin@bar.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => false,
),
2 => array(
'name' => 'bar',
@@ -577,6 +608,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => '\Test\Util\User\Dummy',
'email' => 'bar@dummy.com',
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
)
);
@@ -590,7 +622,7 @@ class UsersControllerTest extends \Test\TestCase {
$user = $this->getMockBuilder('\OC\User\User')
->disableOriginalConstructor()->getMock();
$user
- ->expects($this->exactly(2))
+ ->expects($this->exactly(3))
->method('getUID')
->will($this->returnValue('foo'));
$user
@@ -648,6 +680,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => 'OC_User_Database',
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
)
)
);
@@ -719,6 +752,7 @@ class UsersControllerTest extends \Test\TestCase {
'subadmin' => array(),
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
Http::STATUS_CREATED
);
@@ -807,6 +841,7 @@ class UsersControllerTest extends \Test\TestCase {
'subadmin' => [],
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
Http::STATUS_CREATED
);
@@ -889,6 +924,7 @@ class UsersControllerTest extends \Test\TestCase {
'subadmin' => array(),
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
Http::STATUS_CREATED
);
@@ -984,6 +1020,7 @@ class UsersControllerTest extends \Test\TestCase {
'subadmin' => [],
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
),
Http::STATUS_CREATED
);
@@ -1480,6 +1517,7 @@ class UsersControllerTest extends \Test\TestCase {
'backend' => $backend,
'email' => null,
'isRestoreDisabled' => false,
+ 'isAvatarAvailable' => true,
];
return [$user, $result];