From d6fb2afa8580b7d12b1f0cfc2bb8fb29e01a087f Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 25 Nov 2013 23:49:05 +0100 Subject: show a message at the log-in screen if inital encryption take place --- apps/files_encryption/lib/util.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'apps/files_encryption/lib') diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index b208a808bac..78d0ff88c8e 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -1253,16 +1253,22 @@ class Util { /** * @brief check if files are already migrated to the encryption system + * @param string $uid user Id * @return migration status, false = in case of no record * @note If records are not being returned, check for a hidden space * at the start of the uid in db */ - public function getMigrationStatus() { + public function getMigrationStatus($uid = null) { - $sql = 'SELECT `migration_status` FROM `*PREFIX*encryption` WHERE `uid` = ?'; + if($uid && \OCP\User::userExists($uid)) { + $userId = $uid; + } else { + $userId = $this->uid; + } - $args = array($this->userId); + $sql = 'SELECT `migration_status` FROM `*PREFIX*encryption` WHERE `uid` = ?'; + $args = array($userId); $query = \OCP\DB::prepare($sql); $result = $query->execute($args); @@ -1282,11 +1288,11 @@ class Util { // If no record is found if (empty($migrationStatus)) { - \OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $this->userId . ", no record found", \OCP\Util::ERROR); + \OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $userId . ", no record found", \OCP\Util::ERROR); // insert missing entry in DB with status open $sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`,`migration_status`) VALUES (?,?,?,?)'; $args = array( - $this->userId, + $userId, 'server-side', 0, self::MIGRATION_OPEN -- cgit v1.2.3 From 35a6ad255d6b45e68c18ebcdb36ff0f99311d888 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Tue, 26 Nov 2013 11:38:45 +0100 Subject: fix typo in var name --- apps/files_encryption/lib/util.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'apps/files_encryption/lib') diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 78d0ff88c8e..62f2f8b9022 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -1263,7 +1263,7 @@ class Util { if($uid && \OCP\User::userExists($uid)) { $userId = $uid; } else { - $userId = $this->uid; + $userId = $this->userId; } $sql = 'SELECT `migration_status` FROM `*PREFIX*encryption` WHERE `uid` = ?'; -- cgit v1.2.3 From 060e0ad0cd668529f13a97b866a371e505e8fa3e Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Wed, 27 Nov 2013 15:35:32 +0100 Subject: with the latest changes in master $this-userID is always the correct ID, so we no longer need the extra parameter --- apps/files_encryption/ajax/getMigrationStatus.php | 2 +- apps/files_encryption/lib/util.php | 44 +++++++++++------------ 2 files changed, 21 insertions(+), 25 deletions(-) (limited to 'apps/files_encryption/lib') diff --git a/apps/files_encryption/ajax/getMigrationStatus.php b/apps/files_encryption/ajax/getMigrationStatus.php index a28ebfac7f7..4da035a97d4 100644 --- a/apps/files_encryption/ajax/getMigrationStatus.php +++ b/apps/files_encryption/ajax/getMigrationStatus.php @@ -18,7 +18,7 @@ $migrationCompleted = true; if ($user !== '' && $password !== '') { if (\OCP\User::checkPassword($user, $password)) { $util = new Util(new \OC_FilesystemView('/'), $user); - if ($util->getMigrationStatus($user) !== Util::MIGRATION_COMPLETED) { + if ($util->getMigrationStatus() !== Util::MIGRATION_COMPLETED) { $migrationCompleted = false; } } diff --git a/apps/files_encryption/lib/util.php b/apps/files_encryption/lib/util.php index 62f2f8b9022..7e46a5016a3 100644 --- a/apps/files_encryption/lib/util.php +++ b/apps/files_encryption/lib/util.php @@ -1253,22 +1253,15 @@ class Util { /** * @brief check if files are already migrated to the encryption system - * @param string $uid user Id * @return migration status, false = in case of no record * @note If records are not being returned, check for a hidden space * at the start of the uid in db */ - public function getMigrationStatus($uid = null) { - - if($uid && \OCP\User::userExists($uid)) { - $userId = $uid; - } else { - $userId = $this->userId; - } + public function getMigrationStatus() { $sql = 'SELECT `migration_status` FROM `*PREFIX*encryption` WHERE `uid` = ?'; - $args = array($userId); + $args = array($this->userId); $query = \OCP\DB::prepare($sql); $result = $query->execute($args); @@ -1288,21 +1281,24 @@ class Util { // If no record is found if (empty($migrationStatus)) { - \OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $userId . ", no record found", \OCP\Util::ERROR); - // insert missing entry in DB with status open - $sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`,`migration_status`) VALUES (?,?,?,?)'; - $args = array( - $userId, - 'server-side', - 0, - self::MIGRATION_OPEN - ); - $query = \OCP\DB::prepare($sql); - $query->execute($args); - - return self::MIGRATION_OPEN; - // If a record is found - } else { + \OCP\Util::writeLog('Encryption library', "Could not get migration status for " . $this->userId . ", no record found", \OCP\Util::ERROR); + // insert missing entry in DB with status open if the user exists + if (\OCP\User::userExists($this->userId)) { + $sql = 'INSERT INTO `*PREFIX*encryption` (`uid`,`mode`,`recovery_enabled`,`migration_status`) VALUES (?,?,?,?)'; + $args = array( + $this->userId, + 'server-side', + 0, + self::MIGRATION_OPEN + ); + $query = \OCP\DB::prepare($sql); + $query->execute($args); + + return self::MIGRATION_OPEN; + } else { + return false; + } + } else { // If a record is found return (int)$migrationStatus[0]; } -- cgit v1.2.3