diff options
author | Arthur Schiwon <blizzz@owncloud.com> | 2014-12-20 17:08:26 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@owncloud.com> | 2014-12-20 18:28:29 +0100 |
commit | 61ed363f820a3b25b68289ed2c03ff5e5edfed91 (patch) | |
tree | ace78508902f8d20bc3de4666d90af1b0445ed5b /apps/user_ldap/command | |
parent | 3ca70d647a36144e64cbe4b90ffa97b3d9b64470 (diff) | |
download | nextcloud-server-61ed363f820a3b25b68289ed2c03ff5e5edfed91.tar.gz nextcloud-server-61ed363f820a3b25b68289ed2c03ff5e5edfed91.zip |
planned refactorings for OC 8
Diffstat (limited to 'apps/user_ldap/command')
-rw-r--r-- | apps/user_ldap/command/checkuser.php | 35 |
1 files changed, 13 insertions, 22 deletions
diff --git a/apps/user_ldap/command/checkuser.php b/apps/user_ldap/command/checkuser.php index 96c6c832356..5b1dc36c1d0 100644 --- a/apps/user_ldap/command/checkuser.php +++ b/apps/user_ldap/command/checkuser.php @@ -16,6 +16,7 @@ use Symfony\Component\Console\Output\OutputInterface; use OCA\user_ldap\lib\user\User; use OCA\User_LDAP\lib\user\Manager; +use OCA\User_LDAP\lib\User\DeletedUsersIndex; use OCA\user_ldap\lib\Helper; use OCA\user_ldap\User_Proxy; @@ -26,18 +27,22 @@ class CheckUser extends Command { /** @var \OCA\User_LDAP\lib\Helper */ protected $helper; - /** @var \OCP\IConfig */ - protected $config; + /** @var \OCA\User_LDAP\lib\User\DeletedUsersIndex */ + protected $dui; + + /** @var \OCA\User_LDAP\Mapping\UserMapping */ + protected $mapping; /** * @param OCA\user_ldap\User_Proxy $uBackend * @param OCA\User_LDAP\lib\Helper $helper * @param OCP\IConfig $config */ - public function __construct(User_Proxy $uBackend, Helper $helper, \OCP\IConfig $config) { + public function __construct(User_Proxy $uBackend, Helper $helper, DeletedUsersIndex $dui, UserMapping $mapping) { $this->backend = $uBackend; $this->helper = $helper; - $this->config = $config; + $this->dui = $dui; + $this->mapping = $mapping; parent::__construct(); } @@ -70,10 +75,7 @@ class CheckUser extends Command { return; } - // TODO FIXME consolidate next line in DeletedUsersIndex - // (impractical now, because of class dependencies) - $this->config->setUserValue($uid, 'user_ldap', 'isDeleted', '1'); - + $this->dui->markUser($uid); $output->writeln('The user does not exists on LDAP anymore.'); $output->writeln('Clean up the user\'s remnants by: ./occ user:delete "' . $uid . '"'); @@ -86,22 +88,11 @@ class CheckUser extends Command { * checks whether a user is actually mapped * @param string $ocName the username as used in ownCloud * @throws \Exception - * @return bool + * @return true */ protected function confirmUserIsMapped($ocName) { - //TODO FIXME this should go to Mappings in OC 8 - $db = \OC::$server->getDatabaseConnection(); - $query = $db->prepare(' - SELECT - `ldap_dn` AS `dn` - FROM `*PREFIX*ldap_user_mapping` - WHERE `owncloud_name` = ?' - ); - - $query->execute(array($ocName)); - $result = $query->fetchColumn(); - - if($result === false) { + $dn = $this->mapping->getDNByName($ocName); + if ($dn === false) { throw new \Exception('The given user is not a recognized LDAP user.'); } |