protected function execute(InputInterface $input, OutputInterface $output) { $this->validateInput($input, $output); $this->readPassword($input, $output); $fromDB = \OC_DB::getConnection(); $toDB = $this->getToDBConnection($input, $output); if ($input->getOption('clear-schema')) { $this->clearSchema($toDB, $input, $output); } $this->createSchema($toDB, $input, $output); $toTables = $this->getTables($toDB); $fromTables = $this->getTables($fromDB); // warn/fail if there are more tables in 'from' database $extraFromTables = array_diff($fromTables, $toTables); if (!empty($extraFromTables)) { $output->writeln('<comment>The following tables will not be converted:</comment>'); $output->writeln($extraFromTables); if (!$input->getOption('all-apps')) { $output->writeln('<comment>Please note that tables belonging to available but currently not installed apps</comment>'); $output->writeln('<comment>can be included by specifying the --all-apps option.</comment>'); } /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */ $dialog = $this->getHelperSet()->get('dialog'); if (!$dialog->askConfirmation($output, '<question>Continue with the conversion (y/n)? [n] </question>', false)) { return; } } $intersectingTables = array_intersect($toTables, $fromTables); $this->convertDB($fromDB, $toDB, $intersectingTables, $input, $output); }
/** * @param \OC\Files\Storage\Storage|string $storage * @throws \RuntimeException */ public function __construct($storage) { if ($storage instanceof \OC\Files\Storage\Storage) { $this->storageId = $storage->getId(); } else { $this->storageId = $storage; } $this->storageId = self::adjustStorageId($this->storageId); $sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?'; $result = \OC_DB::executeAudited($sql, array($this->storageId)); if ($row = $result->fetchRow()) { $this->numericId = $row['numeric_id']; } else { $connection = \OC_DB::getConnection(); if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId])) { $this->numericId = \OC_DB::insertid('*PREFIX*storages'); } else { $result = \OC_DB::executeAudited($sql, array($this->storageId)); if ($row = $result->fetchRow()) { $this->numericId = $row['numeric_id']; } else { throw new \RuntimeException('Storage could neither be inserted nor be selected from the database'); } } } }
public function setUp() { $this->config = \OC::$server->getConfig(); $this->connection = \OC_DB::getConnection(); $this->oldDataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/'); $this->repair = new \OC\Repair\RepairLegacyStorages($this->config, $this->connection); }
/** * Send an email to {$limit} users * * @param int $limit Number of users we want to send an email to * @return int Number of users we sent an email to */ protected function runStep($limit) { // Get all users which should receive an email $affectedUsers = $this->mqHandler->getAffectedUsers($limit); if (empty($affectedUsers)) { // No users found to notify, mission abort return 0; } $preferences = new \OC\Preferences(\OC_DB::getConnection()); $userLanguages = $preferences->getValueForUsers('core', 'lang', $affectedUsers); $userEmails = $preferences->getValueForUsers('settings', 'email', $affectedUsers); // Get all items for these users // We don't use time() but "time() - 1" here, so we don't run into // runtime issues and delete emails later, which were created in the // same second, but were not collected for the emails. $sendTime = time() - 1; $mailData = $this->mqHandler->getItemsForUsers($affectedUsers, $sendTime); // Send Email $default_lang = \OC_Config::getValue('default_language', 'en'); foreach ($mailData as $user => $data) { if (!isset($userEmails[$user])) { // The user did not setup an email address // So we will not send an email :( continue; } $language = isset($userLanguages[$user]) ? $userLanguages[$user] : $default_lang; $this->mqHandler->sendEmailToUser($user, $userEmails[$user], $language, $data); } // Delete all entries we dealt with $this->mqHandler->deleteSentItems($affectedUsers, $sendTime); return sizeof($affectedUsers); }
public function setUp() { $this->connection = \OC_DB::getConnection(); if ($this->connection->getDriver() instanceof \Doctrine\DBAL\Driver\OCI8\Driver) { $this->markTestSkipped('DB migration tests arent supported on OCI'); } $this->manager = new \OC\DB\MDB2SchemaManager($this->connection); $this->tableName = 'test_' . uniqid(); }
public function setUp() { $this->connection = \OC_DB::getConnection(); if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) { $this->markTestSkipped("Test only relevant on MySql"); } $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix"); $this->tableName = uniqid($dbPrefix . "_enum_bit_test"); $this->connection->exec("CREATE TABLE {$this->tableName}(b BIT, e ENUM('1','2','3','4'))"); }
/** * @param string $table */ public function assertTableNotExist($table) { $platform = \OC_DB::getConnection()->getDatabasePlatform(); if ($platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) { // sqlite removes the tables after closing the DB $this->assertTrue(true); } else { $this->assertFalse(OC_DB::tableExists($table), 'Table ' . $table . ' exists.'); } }
public function setUp() { $this->connection = \OC_DB::getConnection(); if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) { $this->markTestSkipped("Test only relevant on Sqlite"); } $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix"); $this->tableName = uniqid($dbPrefix . "_enum_bit_test"); $this->connection->exec("CREATE TABLE {$this->tableName}(t0 tinyint unsigned, t1 tinyint)"); }
public function setUp() { $this->connection = \OC_DB::getConnection(); if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) { $this->markTestSkipped("Test only relevant on MySql"); } $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix"); $this->tableName = uniqid($dbPrefix . "_innodb_test"); $this->connection->exec("CREATE TABLE {$this->tableName}(id INT) ENGINE MyISAM"); $this->repair = new \OC\Repair\InnoDB(); }
protected function execute(InputInterface $input, OutputInterface $output) { $file = $input->getArgument('schema-xml'); $schemaManager = new \OC\DB\MDB2SchemaManager(\OC_DB::getConnection()); try { $result = $schemaManager->updateDbFromStructure($file, true); $output->writeln($result); } catch (\Exception $e) { $output->writeln('Failed to update database structure (' . $e . ')'); } }
protected function setUp() { parent::setUp(); $this->config = \OC::$server->getConfig(); $this->connection = \OC_DB::getConnection(); if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { $this->markTestSkipped('DB migration tests are not supported on OCI'); } $this->manager = new \OC\DB\MDB2SchemaManager($this->connection); $this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_')); }
/** * Returns the repair steps to be run before an * upgrade. * * @return array of RepairStep instances */ public static function getBeforeUpgradeRepairSteps() { $steps = array(new \OC\Repair\InnoDB(), new \OC\Repair\Collation(\OC::$server->getConfig(), \OC_DB::getConnection()), new \OC\Repair\SearchLuceneTables(), new \OC\Repair\RepairConfig()); //There is no need to delete all previews on every single update //only 7.0.0 thru 7.0.2 generated broken previews $currentVersion = \OC_Config::getValue('version'); if (version_compare($currentVersion, '7.0.0.0', '>=') && version_compare($currentVersion, '7.0.3.4', '<=')) { $steps[] = new \OC\Repair\Preview(); } return $steps; }
public function setUp() { $this->connection = \OC_DB::getConnection(); $this->config = \OC::$server->getConfig(); if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) { $this->markTestSkipped("Test only relevant on MySql"); } $dbPrefix = $this->config->getSystemValue("dbtableprefix"); $this->tableName = uniqid($dbPrefix . "_collation_test"); $this->connection->exec("CREATE TABLE {$this->tableName}(text VARCHAR(16)) COLLATE utf8_unicode_ci"); $this->repair = new TestCollationRepair($this->config, $this->connection); }
protected function setUp() { parent::setUp(); $this->config = \OC::$server->getConfig(); $this->connection = \OC_DB::getConnection(); $this->oldDataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/'); $this->repair = new \OC\Repair\RepairLegacyStorages($this->config, $this->connection); $this->warnings = []; $this->repair->listen('\\OC\\Repair', 'warning', function ($description) { $this->warnings[] = $description; }); }
public function setUp() { $this->connection = \OC_DB::getConnection(); if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { $this->markTestSkipped('DB migration tests are not supported on OCI'); } if ($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) { $this->markTestSkipped('DB migration tests are not supported on MSSQL'); } $this->manager = new \OC\DB\MDB2SchemaManager($this->connection); $this->tableName = 'test_' . uniqid(); }
protected function setUp() { parent::setUp(); $this->connection = \OC_DB::getConnection(); $this->config = \OC::$server->getConfig(); if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) { $this->markTestSkipped("Test only relevant on Sqlite"); } $dbPrefix = $this->config->getSystemValue('dbtableprefix', 'oc_'); $this->tableName = $this->getUniqueID($dbPrefix . 'autoinc_test'); $this->connection->exec('CREATE TABLE ' . $this->tableName . '("someid" INTEGER NOT NULL, "text" VARCHAR(16), PRIMARY KEY("someid"))'); $this->repair = new \OC\Repair\SqliteAutoincrement($this->connection); }
protected function setUp() { parent::setUp(); $this->connection = \OC_DB::getConnection(); if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { $this->markTestSkipped('DB migration tests are not supported on OCI'); } if ($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) { $this->markTestSkipped('DB migration tests are not supported on MSSQL'); } $this->manager = new \OC\DB\MDB2SchemaManager($this->connection); $this->tableName = strtolower($this->getUniqueID('oc_test_')); }
/** * Fix mime types */ public function run() { $connection = \OC_DB::getConnection(); if (!$connection->getDatabasePlatform() instanceof MySqlPlatform) { $this->emit('\\OC\\Repair', 'info', array('Not a mysql database -> nothing to no')); return; } $tables = $this->getAllMyIsamTables($connection); foreach ($tables as $table) { $connection->exec("ALTER TABLE {$table} ENGINE=InnoDB;"); $this->emit('\\OC\\Repair', 'info', array("Fixed {$table}")); } }
public function testAutoIncrement() { if (\OC::$server->getConfig()->getSystemValue('dbtype', 'sqlite') === 'oci') { $this->markTestSkipped('Adding auto increment columns in Oracle is not supported.'); } $connection = \OC_DB::getConnection(); $manager = new \OC\DB\MDB2SchemaManager($connection); $manager->createDbFromStructure(__DIR__ . '/ts-autoincrement-before.xml'); $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc')); $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc')); $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123')); $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123')); $manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml'); $this->assertTrue(true); }
public function testAutoIncrement() { $connection = \OC_DB::getConnection(); if ($connection->getDatabasePlatform() instanceof OraclePlatform) { $this->markTestSkipped('Adding auto increment columns in Oracle is not supported.'); } $manager = new \OC\DB\MDB2SchemaManager($connection); $manager->createDbFromStructure(__DIR__ . '/ts-autoincrement-before.xml'); $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc')); $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('abc')); $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123')); $connection->executeUpdate('insert into `*PREFIX*table` values (?)', array('123')); $manager->updateDbFromStructure(__DIR__ . '/ts-autoincrement-after.xml'); $this->assertTrue(true); }
public function __construct(array $urlParams = array()) { parent::__construct("config_history", $urlParams); $container = $this->getContainer(); $container->getServer()->registerService("AppConfig", function ($c) use($container) { return new ConfigHistoryAppConfig(\OC_DB::getConnection(), $container->query("ActivityData"), $container->query("CurrentUID")); }); $container->registerService("ActivityData", function ($c) { $serverContainer = $c->getServer(); return new Data($c->query("ConfigHistoryActivityManager"), $serverContainer->getDatabaseConnection(), $serverContainer->getUserSession()); }); $container->registerService("ConfigHistoryActivityManager", function ($c) { $serverContainer = $c->getServer(); return new ConfigHistoryActivityManager($serverContainer->getRequest(), $serverContainer->getUserSession(), $serverContainer->getConfig()); }); $container->registerService("CurrentUID", function ($c) { $user = $c->getServer()->getUserSession()->getUser(); return $user ? $user->getUID() : ""; }); $container->registerService("ConfigHistoryActivity", function ($c) { return new Activity($c->query("L10N"), $c->getServer()->getConfig()); }); $container->registerService("L10N", function ($c) { return $c->getServer()->getL10N("config_history"); }); $container->registerService("DataHelper", function ($c) { $serverContainer = $c->getServer(); return new DataHelper($c->query("ConfigHistoryActivityManager"), new ParameterHelper($c->query("ConfigHistoryActivityManager"), $serverContainer->getUserManager(), $serverContainer->getURLGenerator(), $serverContainer->getContactsManager(), new View(""), $serverContainer->getConfig(), $c->query("L10N"), $c->query("CurrentUID")), $c->query("L10N")); }); $container->registerService("GroupHelper", function ($c) { return new GroupHelper($c->query("ConfigHistoryActivityManager"), $c->query("DataHelper"), true); }); $container->registerService("UserSettings", function ($c) { $serverContainer = $c->getServer(); return new UserSettings($c->query("ConfigHistoryActivityManager"), $serverContainer->getConfig(), $c->query("ActivityData")); }); $container->registerService("ConfigHistoryController", function ($c) { return new ConfigHistory($c->query("AppName"), $c->query("Request"), $c->query("ActivityData"), $c->query("GroupHelper"), $c->query("UserSettings")); }); $container->query("ConfigHistoryActivityManager")->registerExtension(function () use($container) { return $container->query("ConfigHistoryActivity"); }); $container->query("ConfigHistoryActivity")->registerMessageHandler(new FilesExternalMessageHandler($container->query("L10N"))); $container->query("ConfigHistoryActivity")->registerMessageHandler(new DefaultMessageHandler($container->query("L10N"))); }
protected function execute(InputInterface $input, OutputInterface $output) { // TODO: inject DB connection/factory when possible $connection = \OC_DB::getConnection(); $connection->disableQueryStatementCaching(); $maintenanceMode = $this->config->getValue('maintenance', false); $this->config->setValue('maintenance', true); $this->repair->listen('\\OC\\Repair', 'step', function ($description) use($output) { $output->writeln(' - ' . $description); }); $this->repair->listen('\\OC\\Repair', 'info', function ($description) use($output) { $output->writeln(' - ' . $description); }); $this->repair->listen('\\OC\\Repair', 'error', function ($description) use($output) { $output->writeln(' - ERROR: ' . $description); }); $this->repair->run(); $this->config->setValue('maintenance', $maintenanceMode); }
protected function execute(InputInterface $input, OutputInterface $output) { $dui = new DeletedUsersIndex(new \OC\Preferences(\OC_DB::getConnection()), \OC::$server->getDatabaseConnection(), $this->getAccess()); /** @var \Symfony\Component\Console\Helper\Table $table */ $table = $this->getHelperSet()->get('table'); $table->setHeaders(array('ownCloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login', 'Dir', 'Sharer')); $rows = array(); $offset = 0; do { $resultSet = $dui->getUsers($offset); $offset += count($resultSet); foreach ($resultSet as $user) { $hAS = $user->getHasActiveShares() ? 'Y' : 'N'; $lastLogin = $user->getLastLogin() > 0 ? \OCP\Util::formatDate($user->getLastLogin()) : '-'; $rows[] = array($user->getOCName(), $user->getDisplayName(), $user->getUid(), $user->getDN(), $lastLogin, $user->getHomePath(), $hAS); } } while (count($resultSet) === 10); $table->setRows($rows); $table->render($output); }
/** * Fix duplicate entries in oc_lucene_status * * search_lucene prior to v0.5.0 did not have a primary key on the lucene_status table. Newer versions do, which * causes the migration check to fail because it tries to insert duplicate rows into the new schema. * * FIXME Currently, apps don't have a way of repairing anything before the migration check: * @link https://github.com/owncloud/core/issues/10980 * * As a result this repair step needs to live in the core repo, although it belongs into search_lucene: * @link https://github.com/owncloud/core/issues/10205#issuecomment-54957557 * * It will completely remove any rows that make a file id have more than one status: * fileid | status fileid | status * --------+-------- will become --------+-------- * 2 | E 3 | E * 2 | I * 3 | E * * search_lucene will then reindex the fileids without a status when the next indexing job is executed */ public function run() { if (\OC_DB::tableExists('lucene_status')) { $this->emit('\\OC\\Repair', 'info', array('removing duplicate entries from lucene_status')); $connection = \OC_DB::getConnection(); $query = $connection->prepare(' DELETE FROM `*PREFIX*lucene_status` WHERE `fileid` IN ( SELECT `fileid` FROM ( SELECT `fileid` FROM `*PREFIX*lucene_status` GROUP BY `fileid` HAVING count(`fileid`) > 1 ) AS `mysqlerr1093hack` )'); $query->execute(); } else { $this->emit('\\OC\\Repair', 'info', array('lucene_status table does not exist -> nothing to do')); } }
/** * Get the numeric id for a mimetype * * Mimetypes are stored as integers in the cache to prevent duplicated data of the (usually) fairly limited amount of unique mimetypes * If the supplied mimetype does not yet have a numeric id a new one will be generated * * @param string $mime * @return int */ public function getMimetypeId($mime) { if (empty($mime)) { // Can not insert empty string into Oracle NOT NULL column. $mime = 'application/octet-stream'; } if (empty(self::$mimetypeIds)) { $this->loadMimetypes(); } if (!isset(self::$mimetypeIds[$mime])) { try { $connection = \OC_DB::getConnection(); $connection->insertIfNotExist('*PREFIX*mimetypes', ['mimetype' => $mime]); $this->loadMimetypes(); } catch (\Doctrine\DBAL\DBALException $e) { \OC_Log::write('core', 'Exception during mimetype insertion: ' . $e->getmessage(), \OC_Log::DEBUG); return -1; } } return self::$mimetypeIds[$mime]; }
/** * @param \OC\Files\Storage\Storage|string $storage * @param bool $isAvailable * @throws \RuntimeException */ public function __construct($storage, $isAvailable = true) { if ($storage instanceof \OC\Files\Storage\Storage) { $this->storageId = $storage->getId(); } else { $this->storageId = $storage; } $this->storageId = self::adjustStorageId($this->storageId); if ($row = self::getStorageById($this->storageId)) { $this->numericId = $row['numeric_id']; } else { $connection = \OC_DB::getConnection(); if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $isAvailable])) { $this->numericId = \OC_DB::insertid('*PREFIX*storages'); } else { if ($row = self::getStorageById($this->storageId)) { $this->numericId = $row['numeric_id']; } else { throw new \RuntimeException('Storage could neither be inserted nor be selected from the database'); } } } }
* 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 storing user preferences. */ OC_Preferences::$object = new \OC\Preferences(OC_DB::getConnection()); class OC_Preferences { public static $object; /** * @brief Get all users using the preferences * @return array with user ids * * This function returns a list of all users that have at least one entry * in the preferences table. */ public static function getUsers() { return self::$object->getUsers(); } /**
* 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/>. * */ \OCP\App::checkAppEnabled('activity'); $forceUserLogout = false; if (!\OCP\User::isLoggedIn()) { if (!isset($_GET['token']) || strlen($_GET['token']) !== 30) { // Token missing or invalid header('HTTP/1.0 404 Not Found'); exit; } $preferences = new \OC\Preferences(\OC_DB::getConnection()); $users = $preferences->getUsersForValue('activity', 'rsstoken', $_GET['token']); if (sizeof($users) !== 1) { // User not found header('HTTP/1.0 404 Not Found'); exit; } // Token found login as that user \OC_User::setUserId(array_shift($users)); $forceUserLogout = true; } // check if the user has the right permissions. \OCP\User::checkLoggedIn(); // rss is of content type text/xml if (isset($_SERVER['HTTP_ACCEPT']) && stristr($_SERVER['HTTP_ACCEPT'], 'application/rss+xml')) { header('Content-Type: application/rss+xml');
/** * Returns the current session * * @return \OCP\IDBConnection */ function getDatabaseConnection() { return new ConnectionWrapper(\OC_DB::getConnection()); }
/** * Get the item of item type shared with a given user by source * @param string $itemType * @param string $itemSource * @param string $user User to whom the item was shared * @param string $owner Owner of the share * @param int $shareType only look for a specific share type * @return array Return list of items with file_target, permissions and expiration */ public static function getItemSharedWithUser($itemType, $itemSource, $user, $owner = null, $shareType = null) { $shares = array(); $fileDependent = false; $where = 'WHERE'; $fileDependentWhere = ''; if ($itemType === 'file' || $itemType === 'folder') { $fileDependent = true; $column = 'file_source'; $fileDependentWhere = 'INNER JOIN `*PREFIX*filecache` ON `file_source` = `*PREFIX*filecache`.`fileid` '; $fileDependentWhere .= 'INNER JOIN `*PREFIX*storages` ON `numeric_id` = `*PREFIX*filecache`.`storage` '; } else { $column = 'item_source'; } $select = self::createSelectStatement(self::FORMAT_NONE, $fileDependent); $where .= ' `' . $column . '` = ? AND `item_type` = ? '; $arguments = array($itemSource, $itemType); // for link shares $user === null if ($user !== null) { $where .= ' AND `share_with` = ? '; $arguments[] = $user; } if ($shareType !== null) { $where .= ' AND `share_type` = ? '; $arguments[] = $shareType; } if ($owner !== null) { $where .= ' AND `uid_owner` = ? '; $arguments[] = $owner; } $query = \OC_DB::prepare('SELECT ' . $select . ' FROM `*PREFIX*share` ' . $fileDependentWhere . $where); $result = \OC_DB::executeAudited($query, $arguments); while ($row = $result->fetchRow()) { if ($fileDependent && !self::isFileReachable($row['path'], $row['storage_id'])) { continue; } if ($fileDependent && (int) $row['file_parent'] === -1) { // if it is a mount point we need to get the path from the mount manager $mountManager = \OC\Files\Filesystem::getMountManager(); $mountPoint = $mountManager->findByStorageId($row['storage_id']); if (!empty($mountPoint)) { $path = $mountPoint[0]->getMountPoint(); $path = trim($path, '/'); $path = substr($path, strlen($owner) + 1); //normalize path to 'files/foo.txt` $row['path'] = $path; } else { \OC::$server->getLogger()->warning('Could not resolve mount point for ' . $row['storage_id'], ['app' => 'OCP\\Share']); } } $shares[] = $row; } //if didn't found a result than let's look for a group share. if (empty($shares) && $user !== null) { $groups = \OC_Group::getUserGroups($user); if (!empty($groups)) { $where = $fileDependentWhere . ' WHERE `' . $column . '` = ? AND `item_type` = ? AND `share_with` in (?)'; $arguments = array($itemSource, $itemType, $groups); $types = array(null, null, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY); if ($owner !== null) { $where .= ' AND `uid_owner` = ?'; $arguments[] = $owner; $types[] = null; } // TODO: inject connection, hopefully one day in the future when this // class isn't static anymore... $conn = \OC_DB::getConnection(); $result = $conn->executeQuery('SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where, $arguments, $types); while ($row = $result->fetch()) { $shares[] = $row; } } } return $shares; }