diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2014-12-20 16:33:37 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2014-12-20 16:33:37 +0100 |
commit | 3ca70d647a36144e64cbe4b90ffa97b3d9b64470 (patch) | |
tree | 54fc06af6ed11d28a900a96e9f778d34e83c30b4 /apps/user_ldap | |
parent | 144d95de7dde29cd85e795cdcd7ac1576639d641 (diff) | |
download | nextcloud-server-3ca70d647a36144e64cbe4b90ffa97b3d9b64470.tar.gz nextcloud-server-3ca70d647a36144e64cbe4b90ffa97b3d9b64470.zip |
move from \OC\Preferences to \OCP\IConfig
Diffstat (limited to 'apps/user_ldap')
-rw-r--r-- | apps/user_ldap/command/showremnants.php | 36 | ||||
-rw-r--r-- | apps/user_ldap/lib/user/deletedusersindex.php | 57 | ||||
-rw-r--r-- | apps/user_ldap/lib/user/manager.php | 2 | ||||
-rw-r--r-- | apps/user_ldap/lib/user/offlineuser.php | 10 |
4 files changed, 38 insertions, 67 deletions
diff --git a/apps/user_ldap/command/showremnants.php b/apps/user_ldap/command/showremnants.php index fb9fc54ff6a..8144a54cbee 100644 --- a/apps/user_ldap/command/showremnants.php +++ b/apps/user_ldap/command/showremnants.php @@ -41,7 +41,7 @@ class ShowRemnants extends Command { protected function execute(InputInterface $input, OutputInterface $output) { $dui = new DeletedUsersIndex( - new \OC\Preferences(\OC_DB::getConnection()), + \OC::$server->getConfig(), \OC::$server->getDatabaseConnection(), $this->mapper ); @@ -52,25 +52,21 @@ class ShowRemnants extends Command { '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); + $resultSet = $dui->getUsers(); + 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 + ); + } $table->setRows($rows); $table->render($output); diff --git a/apps/user_ldap/lib/user/deletedusersindex.php b/apps/user_ldap/lib/user/deletedusersindex.php index e544d29bad5..62abe2e10de 100644 --- a/apps/user_ldap/lib/user/deletedusersindex.php +++ b/apps/user_ldap/lib/user/deletedusersindex.php @@ -32,9 +32,9 @@ use OCA\User_LDAP\Mapping\UserMapping; */ class DeletedUsersIndex { /** - * @var \OC\Preferences $preferences + * @var \OCP\IConfig $config */ - protected $preferences; + protected $config; /** * @var \OCP\IDBConnection $db @@ -47,64 +47,41 @@ class DeletedUsersIndex { protected $mapping; /** - * @var int $limit - */ - protected $limit = 10; - - /** * @var array $deletedUsers */ protected $deletedUsers = false; - public function __construct(\OC\Preferences $preferences, \OCP\IDBConnection $db, UserMapping $mapping) { - $this->preferences = $preferences; + public function __construct(\OCP\IConfig $config, \OCP\IDBConnection $db, UserMapping $mapping) { + $this->config = $config; $this->db = $db; $this->mapping = $mapping; } /** - * returns key to be used against $this->deletedUsers - * @param int $limit - * @param int $offset - * @return string - */ - private function getDeletedUsersCacheKey($limit, $offset) { - return strval($limit) . '.' . strval($offset); - } - - /** * reads LDAP users marked as deleted from the database - * @param int $offset * @return OCA\user_ldap\lib\user\OfflineUser[] */ - private function fetchDeletedUsers($offset) { - $deletedUsers = $this->preferences->getUsersForValue( - 'user_ldap', 'isDeleted', '1', $this->limit, $offset); - $key = $this->getDeletedUsersCacheKey($this->limit, $offset); + private function fetchDeletedUsers() { + $deletedUsers = $this->config->getUsersForUserValue( + 'user_ldap', 'isDeleted', '1'); $userObjects = array(); foreach($deletedUsers as $user) { - $userObjects[] = new OfflineUser($user, $this->preferences, $this->db, $this->mapping); + $userObjects[] = new OfflineUser($user, $this->config, $this->db, $this->mapping); } - $this->deletedUsers[$key] = $userObjects; - if(count($userObjects) > 0) { - $this->hasUsers(); - } - return $this->deletedUsers[$key]; + return $this->deletedUsers; } /** * returns all LDAP users that are marked as deleted - * @param int|null $offset * @return OCA\user_ldap\lib\user\OfflineUser[] */ - public function getUsers($offset = null) { - $key = $this->getDeletedUsersCacheKey($this->limit, $offset); - if(is_array($this->deletedUsers) && isset($this->deletedUsers[$key])) { - return $this->deletedUsers[$key]; + public function getUsers() { + if(is_array($this->deletedUsers)) { + return $this->deletedUsers; } - return $this->fetchDeletedUsers($offset); + return $this->fetchDeletedUsers(); } /** @@ -113,12 +90,10 @@ class DeletedUsersIndex { */ public function hasUsers() { if($this->deletedUsers === false) { - $this->fetchDeletedUsers(0); + $this->fetchDeletedUsers(); } - foreach($this->deletedUsers as $batch) { - if(count($batch) > 0) { - return true; - } + if(is_array($this->deletedUsers) && count($this->deletedUsers) > 0) { + return true; } return false; } diff --git a/apps/user_ldap/lib/user/manager.php b/apps/user_ldap/lib/user/manager.php index cd4f4441e1d..431609071e6 100644 --- a/apps/user_ldap/lib/user/manager.php +++ b/apps/user_ldap/lib/user/manager.php @@ -152,7 +152,7 @@ class Manager { public function getDeletedUser($id) { return new OfflineUser( $id, - new \OC\Preferences(\OC_DB::getConnection()), + $this->ocConfig, \OC::$server->getDatabaseConnection(), $this->access->getUserMapper()); } diff --git a/apps/user_ldap/lib/user/offlineuser.php b/apps/user_ldap/lib/user/offlineuser.php index 7cf48bc05b1..9383320fae2 100644 --- a/apps/user_ldap/lib/user/offlineuser.php +++ b/apps/user_ldap/lib/user/offlineuser.php @@ -59,9 +59,9 @@ class OfflineUser { */ protected $hasActiveShares; /** - * @var \OC\Preferences $preferences + * @var \OCP\IConfig $config */ - protected $preferences; + protected $config; /** * @var \OCP\IDBConnection $db */ @@ -71,9 +71,9 @@ class OfflineUser { */ protected $mapping; - public function __construct($ocName, \OC\Preferences $preferences, \OCP\IDBConnection $db, UserMapping $mapping) { + public function __construct($ocName, \OCP\IConfig $config, \OCP\IDBConnection $db, UserMapping $mapping) { $this->ocName = $ocName; - $this->preferences = $preferences; + $this->config = $config; $this->db = $db; $this->mapping = $mapping; $this->fetchDetails(); @@ -173,7 +173,7 @@ class OfflineUser { 'lastLogin' => 'login' ); foreach($properties as $property => $app) { - $this->$property = $this->preferences->getValue($this->ocName, $app, $property, ''); + $this->$property = $this->config->getUserValue($this->ocName, $app, $property, ''); } $dn = $this->mapping->getDNByName($this->ocName); |