@@ -36,80 +36,80 @@ |
||
| 36 | 36 | * @package OCA\Files\BackgroundJob |
| 37 | 37 | */ |
| 38 | 38 | class ScanFiles extends \OC\BackgroundJob\TimedJob { |
| 39 | - /** @var IConfig */ |
|
| 40 | - private $config; |
|
| 41 | - /** @var IUserManager */ |
|
| 42 | - private $userManager; |
|
| 43 | - /** @var IDBConnection */ |
|
| 44 | - private $dbConnection; |
|
| 45 | - /** @var ILogger */ |
|
| 46 | - private $logger; |
|
| 47 | - /** Amount of users that should get scanned per execution */ |
|
| 48 | - const USERS_PER_SESSION = 500; |
|
| 39 | + /** @var IConfig */ |
|
| 40 | + private $config; |
|
| 41 | + /** @var IUserManager */ |
|
| 42 | + private $userManager; |
|
| 43 | + /** @var IDBConnection */ |
|
| 44 | + private $dbConnection; |
|
| 45 | + /** @var ILogger */ |
|
| 46 | + private $logger; |
|
| 47 | + /** Amount of users that should get scanned per execution */ |
|
| 48 | + const USERS_PER_SESSION = 500; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param IConfig|null $config |
|
| 52 | - * @param IUserManager|null $userManager |
|
| 53 | - * @param IDBConnection|null $dbConnection |
|
| 54 | - * @param ILogger|null $logger |
|
| 55 | - */ |
|
| 56 | - public function __construct(IConfig $config = null, |
|
| 57 | - IUserManager $userManager = null, |
|
| 58 | - IDBConnection $dbConnection = null, |
|
| 59 | - ILogger $logger = null) { |
|
| 60 | - // Run once per 10 minutes |
|
| 61 | - $this->setInterval(60 * 10); |
|
| 50 | + /** |
|
| 51 | + * @param IConfig|null $config |
|
| 52 | + * @param IUserManager|null $userManager |
|
| 53 | + * @param IDBConnection|null $dbConnection |
|
| 54 | + * @param ILogger|null $logger |
|
| 55 | + */ |
|
| 56 | + public function __construct(IConfig $config = null, |
|
| 57 | + IUserManager $userManager = null, |
|
| 58 | + IDBConnection $dbConnection = null, |
|
| 59 | + ILogger $logger = null) { |
|
| 60 | + // Run once per 10 minutes |
|
| 61 | + $this->setInterval(60 * 10); |
|
| 62 | 62 | |
| 63 | - if (is_null($userManager) || is_null($config)) { |
|
| 64 | - $this->fixDIForJobs(); |
|
| 65 | - } else { |
|
| 66 | - $this->config = $config; |
|
| 67 | - $this->userManager = $userManager; |
|
| 68 | - $this->logger = $logger; |
|
| 69 | - } |
|
| 70 | - } |
|
| 63 | + if (is_null($userManager) || is_null($config)) { |
|
| 64 | + $this->fixDIForJobs(); |
|
| 65 | + } else { |
|
| 66 | + $this->config = $config; |
|
| 67 | + $this->userManager = $userManager; |
|
| 68 | + $this->logger = $logger; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - protected function fixDIForJobs() { |
|
| 73 | - $this->config = \OC::$server->getConfig(); |
|
| 74 | - $this->userManager = \OC::$server->getUserManager(); |
|
| 75 | - $this->logger = \OC::$server->getLogger(); |
|
| 76 | - } |
|
| 72 | + protected function fixDIForJobs() { |
|
| 73 | + $this->config = \OC::$server->getConfig(); |
|
| 74 | + $this->userManager = \OC::$server->getUserManager(); |
|
| 75 | + $this->logger = \OC::$server->getLogger(); |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @param IUser $user |
|
| 80 | - */ |
|
| 81 | - protected function runScanner(IUser $user) { |
|
| 82 | - try { |
|
| 83 | - $scanner = new Scanner( |
|
| 84 | - $user->getUID(), |
|
| 85 | - $this->dbConnection, |
|
| 86 | - $this->logger |
|
| 87 | - ); |
|
| 88 | - $scanner->backgroundScan(''); |
|
| 89 | - } catch (\Exception $e) { |
|
| 90 | - $this->logger->logException($e, ['app' => 'files']); |
|
| 91 | - } |
|
| 92 | - \OC_Util::tearDownFS(); |
|
| 93 | - } |
|
| 78 | + /** |
|
| 79 | + * @param IUser $user |
|
| 80 | + */ |
|
| 81 | + protected function runScanner(IUser $user) { |
|
| 82 | + try { |
|
| 83 | + $scanner = new Scanner( |
|
| 84 | + $user->getUID(), |
|
| 85 | + $this->dbConnection, |
|
| 86 | + $this->logger |
|
| 87 | + ); |
|
| 88 | + $scanner->backgroundScan(''); |
|
| 89 | + } catch (\Exception $e) { |
|
| 90 | + $this->logger->logException($e, ['app' => 'files']); |
|
| 91 | + } |
|
| 92 | + \OC_Util::tearDownFS(); |
|
| 93 | + } |
|
| 94 | 94 | |
| 95 | - /** |
|
| 96 | - * @param $argument |
|
| 97 | - * @throws \Exception |
|
| 98 | - */ |
|
| 99 | - protected function run($argument) { |
|
| 100 | - $offset = $this->config->getAppValue('files', 'cronjob_scan_files', 0); |
|
| 101 | - $users = $this->userManager->search('', self::USERS_PER_SESSION, $offset); |
|
| 102 | - if (!count($users)) { |
|
| 103 | - // No users found, reset offset and retry |
|
| 104 | - $offset = 0; |
|
| 105 | - $users = $this->userManager->search('', self::USERS_PER_SESSION); |
|
| 106 | - } |
|
| 95 | + /** |
|
| 96 | + * @param $argument |
|
| 97 | + * @throws \Exception |
|
| 98 | + */ |
|
| 99 | + protected function run($argument) { |
|
| 100 | + $offset = $this->config->getAppValue('files', 'cronjob_scan_files', 0); |
|
| 101 | + $users = $this->userManager->search('', self::USERS_PER_SESSION, $offset); |
|
| 102 | + if (!count($users)) { |
|
| 103 | + // No users found, reset offset and retry |
|
| 104 | + $offset = 0; |
|
| 105 | + $users = $this->userManager->search('', self::USERS_PER_SESSION); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - $offset += self::USERS_PER_SESSION; |
|
| 109 | - $this->config->setAppValue('files', 'cronjob_scan_files', $offset); |
|
| 108 | + $offset += self::USERS_PER_SESSION; |
|
| 109 | + $this->config->setAppValue('files', 'cronjob_scan_files', $offset); |
|
| 110 | 110 | |
| 111 | - foreach ($users as $user) { |
|
| 112 | - $this->runScanner($user); |
|
| 113 | - } |
|
| 114 | - } |
|
| 111 | + foreach ($users as $user) { |
|
| 112 | + $this->runScanner($user); |
|
| 113 | + } |
|
| 114 | + } |
|
| 115 | 115 | } |
@@ -36,11 +36,11 @@ |
||
| 36 | 36 | // only legacy checkboxes (Advanced and Expert tab) need to be handled here, |
| 37 | 37 | // the Wizard-like tabs handle it on their own |
| 38 | 38 | $chkboxes = array('ldap_configuration_active', 'ldap_override_main_server', |
| 39 | - 'ldap_turn_off_cert_check'); |
|
| 39 | + 'ldap_turn_off_cert_check'); |
|
| 40 | 40 | foreach($chkboxes as $boxid) { |
| 41 | - if(!isset($_POST[$boxid])) { |
|
| 42 | - $_POST[$boxid] = 0; |
|
| 43 | - } |
|
| 41 | + if(!isset($_POST[$boxid])) { |
|
| 42 | + $_POST[$boxid] = 0; |
|
| 43 | + } |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $ldapWrapper = new OCA\User_LDAP\LDAP(); |
@@ -38,12 +38,12 @@ |
||
| 38 | 38 | |
| 39 | 39 | $newConfig = new \OCA\User_LDAP\Configuration($nk, false); |
| 40 | 40 | if(isset($_POST['copyConfig'])) { |
| 41 | - $originalConfig = new \OCA\User_LDAP\Configuration($_POST['copyConfig']); |
|
| 42 | - $newConfig->setConfiguration($originalConfig->getConfiguration()); |
|
| 41 | + $originalConfig = new \OCA\User_LDAP\Configuration($_POST['copyConfig']); |
|
| 42 | + $newConfig->setConfiguration($originalConfig->getConfiguration()); |
|
| 43 | 43 | } else { |
| 44 | - $configuration = new \OCA\User_LDAP\Configuration($nk, false); |
|
| 45 | - $newConfig->setConfiguration($configuration->getDefaults()); |
|
| 46 | - $resultData['defaults'] = $configuration->getDefaults(); |
|
| 44 | + $configuration = new \OCA\User_LDAP\Configuration($nk, false); |
|
| 45 | + $newConfig->setConfiguration($configuration->getDefaults()); |
|
| 46 | + $resultData['defaults'] = $configuration->getDefaults(); |
|
| 47 | 47 | } |
| 48 | 48 | $newConfig->saveConfiguration(); |
| 49 | 49 | |
@@ -29,12 +29,12 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class GroupMapping extends AbstractMapping { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * returns the DB table name which holds the mappings |
|
| 34 | - * @return string |
|
| 35 | - */ |
|
| 36 | - protected function getTableName() { |
|
| 37 | - return '*PREFIX*ldap_group_mapping'; |
|
| 38 | - } |
|
| 32 | + /** |
|
| 33 | + * returns the DB table name which holds the mappings |
|
| 34 | + * @return string |
|
| 35 | + */ |
|
| 36 | + protected function getTableName() { |
|
| 37 | + return '*PREFIX*ldap_group_mapping'; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |
@@ -29,12 +29,12 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class UserMapping extends AbstractMapping { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * returns the DB table name which holds the mappings |
|
| 34 | - * @return string |
|
| 35 | - */ |
|
| 36 | - protected function getTableName() { |
|
| 37 | - return '*PREFIX*ldap_user_mapping'; |
|
| 38 | - } |
|
| 32 | + /** |
|
| 33 | + * returns the DB table name which holds the mappings |
|
| 34 | + * @return string |
|
| 35 | + */ |
|
| 36 | + protected function getTableName() { |
|
| 37 | + return '*PREFIX*ldap_user_mapping'; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | 40 | } |
@@ -24,26 +24,26 @@ |
||
| 24 | 24 | |
| 25 | 25 | interface IUserLDAP { |
| 26 | 26 | |
| 27 | - //Functions used by LDAPProvider |
|
| 27 | + //Functions used by LDAPProvider |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Return access for LDAP interaction. |
|
| 31 | - * @param string $uid |
|
| 32 | - * @return Access instance of Access for LDAP interaction |
|
| 33 | - */ |
|
| 34 | - public function getLDAPAccess($uid); |
|
| 29 | + /** |
|
| 30 | + * Return access for LDAP interaction. |
|
| 31 | + * @param string $uid |
|
| 32 | + * @return Access instance of Access for LDAP interaction |
|
| 33 | + */ |
|
| 34 | + public function getLDAPAccess($uid); |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Return a new LDAP connection for the specified user. |
|
| 38 | - * @param string $uid |
|
| 39 | - * @return resource of the LDAP connection |
|
| 40 | - */ |
|
| 41 | - public function getNewLDAPConnection($uid); |
|
| 36 | + /** |
|
| 37 | + * Return a new LDAP connection for the specified user. |
|
| 38 | + * @param string $uid |
|
| 39 | + * @return resource of the LDAP connection |
|
| 40 | + */ |
|
| 41 | + public function getNewLDAPConnection($uid); |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Return the username for the given LDAP DN, if available. |
|
| 45 | - * @param string $dn |
|
| 46 | - * @return string|false with the username |
|
| 47 | - */ |
|
| 48 | - public function dn2UserName($dn); |
|
| 43 | + /** |
|
| 44 | + * Return the username for the given LDAP DN, if available. |
|
| 45 | + * @param string $dn |
|
| 46 | + * @return string|false with the username |
|
| 47 | + */ |
|
| 48 | + public function dn2UserName($dn); |
|
| 49 | 49 | } |
@@ -27,13 +27,13 @@ |
||
| 27 | 27 | |
| 28 | 28 | |
| 29 | 29 | abstract class BackendUtility { |
| 30 | - protected $access; |
|
| 30 | + protected $access; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * constructor, make sure the subclasses call this one! |
|
| 34 | - * @param Access $access an instance of Access for LDAP interaction |
|
| 35 | - */ |
|
| 36 | - public function __construct(Access $access) { |
|
| 37 | - $this->access = $access; |
|
| 38 | - } |
|
| 32 | + /** |
|
| 33 | + * constructor, make sure the subclasses call this one! |
|
| 34 | + * @param Access $access an instance of Access for LDAP interaction |
|
| 35 | + */ |
|
| 36 | + public function __construct(Access $access) { |
|
| 37 | + $this->access = $access; |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -28,52 +28,52 @@ |
||
| 28 | 28 | namespace OCA\User_LDAP; |
| 29 | 29 | |
| 30 | 30 | class WizardResult { |
| 31 | - protected $changes = array(); |
|
| 32 | - protected $options = array(); |
|
| 33 | - protected $markedChange = false; |
|
| 31 | + protected $changes = array(); |
|
| 32 | + protected $options = array(); |
|
| 33 | + protected $markedChange = false; |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * @param string $key |
|
| 37 | - * @param mixed $value |
|
| 38 | - */ |
|
| 39 | - public function addChange($key, $value) { |
|
| 40 | - $this->changes[$key] = $value; |
|
| 41 | - } |
|
| 35 | + /** |
|
| 36 | + * @param string $key |
|
| 37 | + * @param mixed $value |
|
| 38 | + */ |
|
| 39 | + public function addChange($key, $value) { |
|
| 40 | + $this->changes[$key] = $value; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * |
|
| 45 | - */ |
|
| 46 | - public function markChange() { |
|
| 47 | - $this->markedChange = true; |
|
| 48 | - } |
|
| 43 | + /** |
|
| 44 | + * |
|
| 45 | + */ |
|
| 46 | + public function markChange() { |
|
| 47 | + $this->markedChange = true; |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param string $key |
|
| 52 | - * @param array|string $values |
|
| 53 | - */ |
|
| 54 | - public function addOptions($key, $values) { |
|
| 55 | - if(!is_array($values)) { |
|
| 56 | - $values = array($values); |
|
| 57 | - } |
|
| 58 | - $this->options[$key] = $values; |
|
| 59 | - } |
|
| 50 | + /** |
|
| 51 | + * @param string $key |
|
| 52 | + * @param array|string $values |
|
| 53 | + */ |
|
| 54 | + public function addOptions($key, $values) { |
|
| 55 | + if(!is_array($values)) { |
|
| 56 | + $values = array($values); |
|
| 57 | + } |
|
| 58 | + $this->options[$key] = $values; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * @return bool |
|
| 63 | - */ |
|
| 64 | - public function hasChanges() { |
|
| 65 | - return (count($this->changes) > 0 || $this->markedChange); |
|
| 66 | - } |
|
| 61 | + /** |
|
| 62 | + * @return bool |
|
| 63 | + */ |
|
| 64 | + public function hasChanges() { |
|
| 65 | + return (count($this->changes) > 0 || $this->markedChange); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - /** |
|
| 69 | - * @return array |
|
| 70 | - */ |
|
| 71 | - public function getResultArray() { |
|
| 72 | - $result = array(); |
|
| 73 | - $result['changes'] = $this->changes; |
|
| 74 | - if(count($this->options) > 0) { |
|
| 75 | - $result['options'] = $this->options; |
|
| 76 | - } |
|
| 77 | - return $result; |
|
| 78 | - } |
|
| 68 | + /** |
|
| 69 | + * @return array |
|
| 70 | + */ |
|
| 71 | + public function getResultArray() { |
|
| 72 | + $result = array(); |
|
| 73 | + $result['changes'] = $this->changes; |
|
| 74 | + if(count($this->options) > 0) { |
|
| 75 | + $result['options'] = $this->options; |
|
| 76 | + } |
|
| 77 | + return $result; |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -30,31 +30,31 @@ |
||
| 30 | 30 | use OCA\User_LDAP\User_Proxy; |
| 31 | 31 | |
| 32 | 32 | abstract class UUIDFix extends QueuedJob { |
| 33 | - /** @var AbstractMapping */ |
|
| 34 | - protected $mapper; |
|
| 33 | + /** @var AbstractMapping */ |
|
| 34 | + protected $mapper; |
|
| 35 | 35 | |
| 36 | - /** @var Proxy */ |
|
| 37 | - protected $proxy; |
|
| 36 | + /** @var Proxy */ |
|
| 37 | + protected $proxy; |
|
| 38 | 38 | |
| 39 | - public function run($argument) { |
|
| 40 | - $isUser = $this->proxy instanceof User_Proxy; |
|
| 41 | - foreach($argument['records'] as $record) { |
|
| 42 | - $access = $this->proxy->getLDAPAccess($record['name']); |
|
| 43 | - $uuid = $access->getUUID($record['dn'], $isUser); |
|
| 44 | - if($uuid === false) { |
|
| 45 | - // record not found, no prob, continue with the next |
|
| 46 | - continue; |
|
| 47 | - } |
|
| 48 | - if($uuid !== $record['uuid']) { |
|
| 49 | - $this->mapper->setUUIDbyDN($uuid, $record['dn']); |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 39 | + public function run($argument) { |
|
| 40 | + $isUser = $this->proxy instanceof User_Proxy; |
|
| 41 | + foreach($argument['records'] as $record) { |
|
| 42 | + $access = $this->proxy->getLDAPAccess($record['name']); |
|
| 43 | + $uuid = $access->getUUID($record['dn'], $isUser); |
|
| 44 | + if($uuid === false) { |
|
| 45 | + // record not found, no prob, continue with the next |
|
| 46 | + continue; |
|
| 47 | + } |
|
| 48 | + if($uuid !== $record['uuid']) { |
|
| 49 | + $this->mapper->setUUIDbyDN($uuid, $record['dn']); |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param Proxy $proxy |
|
| 56 | - */ |
|
| 57 | - public function overrideProxy(Proxy $proxy) { |
|
| 58 | - $this->proxy = $proxy; |
|
| 59 | - } |
|
| 54 | + /** |
|
| 55 | + * @param Proxy $proxy |
|
| 56 | + */ |
|
| 57 | + public function overrideProxy(Proxy $proxy) { |
|
| 58 | + $this->proxy = $proxy; |
|
| 59 | + } |
|
| 60 | 60 | } |