diff options
Diffstat (limited to 'apps/user_status/lib/Db/UserStatusMapper.php')
-rw-r--r-- | apps/user_status/lib/Db/UserStatusMapper.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/apps/user_status/lib/Db/UserStatusMapper.php b/apps/user_status/lib/Db/UserStatusMapper.php index 14671bf8c34..f67cfcd472d 100644 --- a/apps/user_status/lib/Db/UserStatusMapper.php +++ b/apps/user_status/lib/Db/UserStatusMapper.php @@ -184,6 +184,23 @@ class UserStatusMapper extends QBMapper { $qb->executeStatement(); } + /** + * @param string $userId + * @return bool + * @throws \OCP\DB\Exception + */ + public function createBackupStatus(string $userId): bool { + // Prefix user account with an underscore because user_id is marked as unique + // in the table. Starting a username with an underscore is not allowed so this + // shouldn't create any trouble. + $qb = $this->db->getQueryBuilder(); + $qb->update($this->tableName) + ->set('is_backup', $qb->createNamedParameter(true, IQueryBuilder::PARAM_BOOL)) + ->set('user_id', $qb->createNamedParameter('_' . $userId)) + ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); + return $qb->executeStatement() > 0; + } + public function restoreBackupStatuses(array $ids): void { $qb = $this->db->getQueryBuilder(); $qb->update($this->tableName) |