summaryrefslogtreecommitdiffstats
path: root/apps/user_ldap/lib/jobs
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2014-12-20 17:08:26 +0100
committerArthur Schiwon <blizzz@owncloud.com>2014-12-20 18:28:29 +0100
commit61ed363f820a3b25b68289ed2c03ff5e5edfed91 (patch)
treeace78508902f8d20bc3de4666d90af1b0445ed5b /apps/user_ldap/lib/jobs
parent3ca70d647a36144e64cbe4b90ffa97b3d9b64470 (diff)
downloadnextcloud-server-61ed363f820a3b25b68289ed2c03ff5e5edfed91.tar.gz
nextcloud-server-61ed363f820a3b25b68289ed2c03ff5e5edfed91.zip
planned refactorings for OC 8
Diffstat (limited to 'apps/user_ldap/lib/jobs')
-rw-r--r--apps/user_ldap/lib/jobs/cleanup.php49
1 files changed, 24 insertions, 25 deletions
diff --git a/apps/user_ldap/lib/jobs/cleanup.php b/apps/user_ldap/lib/jobs/cleanup.php
index 56fb296609d..35252d6f6e5 100644
--- a/apps/user_ldap/lib/jobs/cleanup.php
+++ b/apps/user_ldap/lib/jobs/cleanup.php
@@ -11,6 +11,8 @@ namespace OCA\User_LDAP\Jobs;
use \OCA\user_ldap\User_Proxy;
use \OCA\user_ldap\lib\Helper;
use \OCA\user_ldap\lib\LDAP;
+use \OCA\User_LDAP\lib\User\DeletedUsersIndex;
+use \OCA\User_LDAP\Mapping\UserMapping;
/**
* Class CleanUp
@@ -45,6 +47,12 @@ class CleanUp extends \OC\BackgroundJob\TimedJob {
*/
protected $ldapHelper;
+ /** @var \OCA\User_LDAP\Mapping\UserMapping */
+ protected $mapping;
+
+ /** @var \OCA\User_LDAP\lib\User\DeletedUsersIndex */
+ protected $dui;
+
/**
* @var int $defaultIntervalMin default interval in minutes
*/
@@ -92,6 +100,19 @@ class CleanUp extends \OC\BackgroundJob\TimedJob {
} else {
$this->db = \OC::$server->getDatabaseConnection();
}
+
+ if(isset($arguments['mapping'])) {
+ $this->mapping = $arguments['mapping'];
+ } else {
+ $this->mapping = new UserMapping($this->db);
+ }
+
+ if(isset($arguments['deletedUsersIndex'])) {
+ $this->dui = $arguments['deletedUsersIndex'];
+ } else {
+ $this->dui = new DeletedUsersIndex(
+ $this->ocConfig, $this->db, $this->mapping);
+ }
}
/**
@@ -104,7 +125,7 @@ class CleanUp extends \OC\BackgroundJob\TimedJob {
if(!$this->isCleanUpAllowed()) {
return;
}
- $users = $this->getMappedUsers($this->limit, $this->getOffset());
+ $users = $this->mapping->getList($this->limit, $this->getOffset());
if(!is_array($users)) {
//something wrong? Let's start from the beginning next time and
//abort
@@ -169,33 +190,11 @@ class CleanUp extends \OC\BackgroundJob\TimedJob {
private function checkUser($user) {
if($this->userBackend->userExistsOnLDAP($user['name'])) {
//still available, all good
+
return;
}
- // TODO FIXME consolidate next line in DeletedUsersIndex
- // (impractical now, because of class dependencies)
- $this->ocConfig->setUserValue($user['name'], 'user_ldap', 'isDeleted', '1');
- }
-
- /**
- * returns a batch of users from the mappings table
- * @param int $limit
- * @param int $offset
- * @return array
- */
- public function getMappedUsers($limit, $offset) {
- $query = $this->db->prepare('
- SELECT
- `ldap_dn` AS `dn`,
- `owncloud_name` AS `name`,
- `directory_uuid` AS `uuid`
- FROM `*PREFIX*ldap_user_mapping`',
- $limit,
- $offset
- );
-
- $query->execute();
- return $query->fetchAll();
+ $this->dui->markUser($user['name']);
}
/**