@@ -62,7 +62,7 @@ |
||
| 62 | 62 | |
| 63 | 63 | $success = $this->helper->deleteServerConfiguration($configPrefix); |
| 64 | 64 | |
| 65 | - if($success) { |
|
| 65 | + if ($success) { |
|
| 66 | 66 | $output->writeln("Deleted configuration with configID '{$configPrefix}'"); |
| 67 | 67 | } else { |
| 68 | 68 | $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); |
@@ -32,39 +32,39 @@ |
||
| 32 | 32 | use \OCA\User_LDAP\Helper; |
| 33 | 33 | |
| 34 | 34 | class DeleteConfig extends Command { |
| 35 | - /** @var \OCA\User_LDAP\Helper */ |
|
| 36 | - protected $helper; |
|
| 35 | + /** @var \OCA\User_LDAP\Helper */ |
|
| 36 | + protected $helper; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * @param Helper $helper |
|
| 40 | - */ |
|
| 41 | - public function __construct(Helper $helper) { |
|
| 42 | - $this->helper = $helper; |
|
| 43 | - parent::__construct(); |
|
| 44 | - } |
|
| 38 | + /** |
|
| 39 | + * @param Helper $helper |
|
| 40 | + */ |
|
| 41 | + public function __construct(Helper $helper) { |
|
| 42 | + $this->helper = $helper; |
|
| 43 | + parent::__construct(); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - protected function configure() { |
|
| 47 | - $this |
|
| 48 | - ->setName('ldap:delete-config') |
|
| 49 | - ->setDescription('deletes an existing LDAP configuration') |
|
| 50 | - ->addArgument( |
|
| 51 | - 'configID', |
|
| 52 | - InputArgument::REQUIRED, |
|
| 53 | - 'the configuration ID' |
|
| 54 | - ) |
|
| 55 | - ; |
|
| 56 | - } |
|
| 46 | + protected function configure() { |
|
| 47 | + $this |
|
| 48 | + ->setName('ldap:delete-config') |
|
| 49 | + ->setDescription('deletes an existing LDAP configuration') |
|
| 50 | + ->addArgument( |
|
| 51 | + 'configID', |
|
| 52 | + InputArgument::REQUIRED, |
|
| 53 | + 'the configuration ID' |
|
| 54 | + ) |
|
| 55 | + ; |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 60 | - $configPrefix = $input->getArgument('configID'); |
|
| 59 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 60 | + $configPrefix = $input->getArgument('configID'); |
|
| 61 | 61 | |
| 62 | - $success = $this->helper->deleteServerConfiguration($configPrefix); |
|
| 62 | + $success = $this->helper->deleteServerConfiguration($configPrefix); |
|
| 63 | 63 | |
| 64 | - if($success) { |
|
| 65 | - $output->writeln("Deleted configuration with configID '{$configPrefix}'"); |
|
| 66 | - } else { |
|
| 67 | - $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); |
|
| 68 | - } |
|
| 69 | - } |
|
| 64 | + if($success) { |
|
| 65 | + $output->writeln("Deleted configuration with configID '{$configPrefix}'"); |
|
| 66 | + } else { |
|
| 67 | + $output->writeln("Cannot delete configuration with configID '{$configPrefix}'"); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | 'Dir', 'Sharer')); |
| 72 | 72 | $rows = array(); |
| 73 | 73 | $resultSet = $this->dui->getUsers(); |
| 74 | - foreach($resultSet as $user) { |
|
| 74 | + foreach ($resultSet as $user) { |
|
| 75 | 75 | $hAS = $user->getHasActiveShares() ? 'Y' : 'N'; |
| 76 | 76 | $lastLogin = ($user->getLastLogin() > 0) ? |
| 77 | 77 | $this->dateFormatter->formatDate($user->getLastLogin()) : '-'; |
@@ -34,61 +34,61 @@ |
||
| 34 | 34 | use OCP\IDateTimeFormatter; |
| 35 | 35 | |
| 36 | 36 | class ShowRemnants extends Command { |
| 37 | - /** @var \OCA\User_LDAP\User\DeletedUsersIndex */ |
|
| 38 | - protected $dui; |
|
| 37 | + /** @var \OCA\User_LDAP\User\DeletedUsersIndex */ |
|
| 38 | + protected $dui; |
|
| 39 | 39 | |
| 40 | - /** @var \OCP\IDateTimeFormatter */ |
|
| 41 | - protected $dateFormatter; |
|
| 40 | + /** @var \OCP\IDateTimeFormatter */ |
|
| 41 | + protected $dateFormatter; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * @param DeletedUsersIndex $dui |
|
| 45 | - * @param IDateTimeFormatter $dateFormatter |
|
| 46 | - */ |
|
| 47 | - public function __construct(DeletedUsersIndex $dui, IDateTimeFormatter $dateFormatter) { |
|
| 48 | - $this->dui = $dui; |
|
| 49 | - $this->dateFormatter = $dateFormatter; |
|
| 50 | - parent::__construct(); |
|
| 51 | - } |
|
| 43 | + /** |
|
| 44 | + * @param DeletedUsersIndex $dui |
|
| 45 | + * @param IDateTimeFormatter $dateFormatter |
|
| 46 | + */ |
|
| 47 | + public function __construct(DeletedUsersIndex $dui, IDateTimeFormatter $dateFormatter) { |
|
| 48 | + $this->dui = $dui; |
|
| 49 | + $this->dateFormatter = $dateFormatter; |
|
| 50 | + parent::__construct(); |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - protected function configure() { |
|
| 54 | - $this |
|
| 55 | - ->setName('ldap:show-remnants') |
|
| 56 | - ->setDescription('shows which users are not available on LDAP anymore, but have remnants in ownCloud.') |
|
| 57 | - ->addOption('json', null, InputOption::VALUE_NONE, 'return JSON array instead of pretty table.'); |
|
| 58 | - } |
|
| 53 | + protected function configure() { |
|
| 54 | + $this |
|
| 55 | + ->setName('ldap:show-remnants') |
|
| 56 | + ->setDescription('shows which users are not available on LDAP anymore, but have remnants in ownCloud.') |
|
| 57 | + ->addOption('json', null, InputOption::VALUE_NONE, 'return JSON array instead of pretty table.'); |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * executes the command, i.e. creeates and outputs a table of LDAP users marked as deleted |
|
| 62 | - * |
|
| 63 | - * {@inheritdoc} |
|
| 64 | - */ |
|
| 65 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 66 | - /** @var \Symfony\Component\Console\Helper\Table $table */ |
|
| 67 | - $table = $this->getHelperSet()->get('table'); |
|
| 68 | - $table->setHeaders(array( |
|
| 69 | - 'ownCloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login', |
|
| 70 | - 'Dir', 'Sharer')); |
|
| 71 | - $rows = array(); |
|
| 72 | - $resultSet = $this->dui->getUsers(); |
|
| 73 | - foreach($resultSet as $user) { |
|
| 74 | - $hAS = $user->getHasActiveShares() ? 'Y' : 'N'; |
|
| 75 | - $lastLogin = ($user->getLastLogin() > 0) ? |
|
| 76 | - $this->dateFormatter->formatDate($user->getLastLogin()) : '-'; |
|
| 77 | - $rows[] = array('ocName' => $user->getOCName(), |
|
| 78 | - 'displayName' => $user->getDisplayName(), |
|
| 79 | - 'uid' => $user->getUID(), |
|
| 80 | - 'dn' => $user->getDN(), |
|
| 81 | - 'lastLogin' => $lastLogin, |
|
| 82 | - 'homePath' => $user->getHomePath(), |
|
| 83 | - 'sharer' => $hAS |
|
| 84 | - ); |
|
| 85 | - } |
|
| 60 | + /** |
|
| 61 | + * executes the command, i.e. creeates and outputs a table of LDAP users marked as deleted |
|
| 62 | + * |
|
| 63 | + * {@inheritdoc} |
|
| 64 | + */ |
|
| 65 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
| 66 | + /** @var \Symfony\Component\Console\Helper\Table $table */ |
|
| 67 | + $table = $this->getHelperSet()->get('table'); |
|
| 68 | + $table->setHeaders(array( |
|
| 69 | + 'ownCloud name', 'Display Name', 'LDAP UID', 'LDAP DN', 'Last Login', |
|
| 70 | + 'Dir', 'Sharer')); |
|
| 71 | + $rows = array(); |
|
| 72 | + $resultSet = $this->dui->getUsers(); |
|
| 73 | + foreach($resultSet as $user) { |
|
| 74 | + $hAS = $user->getHasActiveShares() ? 'Y' : 'N'; |
|
| 75 | + $lastLogin = ($user->getLastLogin() > 0) ? |
|
| 76 | + $this->dateFormatter->formatDate($user->getLastLogin()) : '-'; |
|
| 77 | + $rows[] = array('ocName' => $user->getOCName(), |
|
| 78 | + 'displayName' => $user->getDisplayName(), |
|
| 79 | + 'uid' => $user->getUID(), |
|
| 80 | + 'dn' => $user->getDN(), |
|
| 81 | + 'lastLogin' => $lastLogin, |
|
| 82 | + 'homePath' => $user->getHomePath(), |
|
| 83 | + 'sharer' => $hAS |
|
| 84 | + ); |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - if ($input->getOption('json')) { |
|
| 88 | - $output->writeln(json_encode($rows)); |
|
| 89 | - } else { |
|
| 90 | - $table->setRows($rows); |
|
| 91 | - $table->render($output); |
|
| 92 | - } |
|
| 93 | - } |
|
| 87 | + if ($input->getOption('json')) { |
|
| 88 | + $output->writeln(json_encode($rows)); |
|
| 89 | + } else { |
|
| 90 | + $table->setRows($rows); |
|
| 91 | + $table->render($output); |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | } |
@@ -26,13 +26,13 @@ |
||
| 26 | 26 | namespace OCA\User_LDAP; |
| 27 | 27 | |
| 28 | 28 | abstract class LDAPUtility { |
| 29 | - protected $ldap; |
|
| 29 | + protected $ldap; |
|
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * constructor, make sure the subclasses call this one! |
|
| 33 | - * @param ILDAPWrapper $ldapWrapper an instance of an ILDAPWrapper |
|
| 34 | - */ |
|
| 35 | - public function __construct(ILDAPWrapper $ldapWrapper) { |
|
| 36 | - $this->ldap = $ldapWrapper; |
|
| 37 | - } |
|
| 31 | + /** |
|
| 32 | + * constructor, make sure the subclasses call this one! |
|
| 33 | + * @param ILDAPWrapper $ldapWrapper an instance of an ILDAPWrapper |
|
| 34 | + */ |
|
| 35 | + public function __construct(ILDAPWrapper $ldapWrapper) { |
|
| 36 | + $this->ldap = $ldapWrapper; |
|
| 37 | + } |
|
| 38 | 38 | } |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | // assign default values |
| 63 | 63 | $config = new Configuration('', false); |
| 64 | 64 | $defaults = $config->getDefaults(); |
| 65 | - foreach($defaults as $key => $default) { |
|
| 65 | + foreach ($defaults as $key => $default) { |
|
| 66 | 66 | $parameters[$key.'_default'] = $default; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -31,59 +31,59 @@ |
||
| 31 | 31 | use OCP\Template; |
| 32 | 32 | |
| 33 | 33 | class Admin implements ISettings { |
| 34 | - /** @var IL10N */ |
|
| 35 | - private $l; |
|
| 34 | + /** @var IL10N */ |
|
| 35 | + private $l; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param IL10N $l |
|
| 39 | - */ |
|
| 40 | - public function __construct(IL10N $l) { |
|
| 41 | - $this->l = $l; |
|
| 42 | - } |
|
| 37 | + /** |
|
| 38 | + * @param IL10N $l |
|
| 39 | + */ |
|
| 40 | + public function __construct(IL10N $l) { |
|
| 41 | + $this->l = $l; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @return TemplateResponse |
|
| 46 | - */ |
|
| 47 | - public function getForm() { |
|
| 48 | - $helper = new Helper(); |
|
| 49 | - $prefixes = $helper->getServerConfigurationPrefixes(); |
|
| 50 | - $hosts = $helper->getServerConfigurationHosts(); |
|
| 44 | + /** |
|
| 45 | + * @return TemplateResponse |
|
| 46 | + */ |
|
| 47 | + public function getForm() { |
|
| 48 | + $helper = new Helper(); |
|
| 49 | + $prefixes = $helper->getServerConfigurationPrefixes(); |
|
| 50 | + $hosts = $helper->getServerConfigurationHosts(); |
|
| 51 | 51 | |
| 52 | - $wControls = new Template('user_ldap', 'part.wizardcontrols'); |
|
| 53 | - $wControls = $wControls->fetchPage(); |
|
| 54 | - $sControls = new Template('user_ldap', 'part.settingcontrols'); |
|
| 55 | - $sControls = $sControls->fetchPage(); |
|
| 52 | + $wControls = new Template('user_ldap', 'part.wizardcontrols'); |
|
| 53 | + $wControls = $wControls->fetchPage(); |
|
| 54 | + $sControls = new Template('user_ldap', 'part.settingcontrols'); |
|
| 55 | + $sControls = $sControls->fetchPage(); |
|
| 56 | 56 | |
| 57 | - $parameters['serverConfigurationPrefixes'] = $prefixes; |
|
| 58 | - $parameters['serverConfigurationHosts'] = $hosts; |
|
| 59 | - $parameters['settingControls'] = $sControls; |
|
| 60 | - $parameters['wizardControls'] = $wControls; |
|
| 57 | + $parameters['serverConfigurationPrefixes'] = $prefixes; |
|
| 58 | + $parameters['serverConfigurationHosts'] = $hosts; |
|
| 59 | + $parameters['settingControls'] = $sControls; |
|
| 60 | + $parameters['wizardControls'] = $wControls; |
|
| 61 | 61 | |
| 62 | - // assign default values |
|
| 63 | - $config = new Configuration('', false); |
|
| 64 | - $defaults = $config->getDefaults(); |
|
| 65 | - foreach($defaults as $key => $default) { |
|
| 66 | - $parameters[$key.'_default'] = $default; |
|
| 67 | - } |
|
| 62 | + // assign default values |
|
| 63 | + $config = new Configuration('', false); |
|
| 64 | + $defaults = $config->getDefaults(); |
|
| 65 | + foreach($defaults as $key => $default) { |
|
| 66 | + $parameters[$key.'_default'] = $default; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - return new TemplateResponse('user_ldap', 'settings', $parameters); |
|
| 70 | - } |
|
| 69 | + return new TemplateResponse('user_ldap', 'settings', $parameters); |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - /** |
|
| 73 | - * @return string the section ID, e.g. 'sharing' |
|
| 74 | - */ |
|
| 75 | - public function getSection() { |
|
| 76 | - return 'ldap'; |
|
| 77 | - } |
|
| 72 | + /** |
|
| 73 | + * @return string the section ID, e.g. 'sharing' |
|
| 74 | + */ |
|
| 75 | + public function getSection() { |
|
| 76 | + return 'ldap'; |
|
| 77 | + } |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * @return int whether the form should be rather on the top or bottom of |
|
| 81 | - * the admin section. The forms are arranged in ascending order of the |
|
| 82 | - * priority values. It is required to return a value between 0 and 100. |
|
| 83 | - * |
|
| 84 | - * E.g.: 70 |
|
| 85 | - */ |
|
| 86 | - public function getPriority() { |
|
| 87 | - return 5; |
|
| 88 | - } |
|
| 79 | + /** |
|
| 80 | + * @return int whether the form should be rather on the top or bottom of |
|
| 81 | + * the admin section. The forms are arranged in ascending order of the |
|
| 82 | + * priority values. It is required to return a value between 0 and 100. |
|
| 83 | + * |
|
| 84 | + * E.g.: 70 |
|
| 85 | + */ |
|
| 86 | + public function getPriority() { |
|
| 87 | + return 5; |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig) { |
| 44 | 44 | parent::__construct($ldap); |
| 45 | - foreach($serverConfigPrefixes as $configPrefix) { |
|
| 45 | + foreach ($serverConfigPrefixes as $configPrefix) { |
|
| 46 | 46 | $this->backends[$configPrefix] = |
| 47 | 47 | new User_LDAP($this->getAccess($configPrefix), $ocConfig); |
| 48 | - if(is_null($this->refBackend)) { |
|
| 48 | + if (is_null($this->refBackend)) { |
|
| 49 | 49 | $this->refBackend = &$this->backends[$configPrefix]; |
| 50 | 50 | } |
| 51 | 51 | } |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | protected function walkBackends($uid, $method, $parameters) { |
| 62 | 62 | $cacheKey = $this->getUserCacheKey($uid); |
| 63 | - foreach($this->backends as $configPrefix => $backend) { |
|
| 63 | + foreach ($this->backends as $configPrefix => $backend) { |
|
| 64 | 64 | $instance = $backend; |
| 65 | - if(!method_exists($instance, $method) |
|
| 65 | + if (!method_exists($instance, $method) |
|
| 66 | 66 | && method_exists($this->getAccess($configPrefix), $method)) { |
| 67 | 67 | $instance = $this->getAccess($configPrefix); |
| 68 | 68 | } |
| 69 | - if($result = call_user_func_array(array($instance, $method), $parameters)) { |
|
| 69 | + if ($result = call_user_func_array(array($instance, $method), $parameters)) { |
|
| 70 | 70 | $this->writeToCache($cacheKey, $configPrefix); |
| 71 | 71 | return $result; |
| 72 | 72 | } |
@@ -86,22 +86,22 @@ discard block |
||
| 86 | 86 | $cacheKey = $this->getUserCacheKey($uid); |
| 87 | 87 | $prefix = $this->getFromCache($cacheKey); |
| 88 | 88 | //in case the uid has been found in the past, try this stored connection first |
| 89 | - if(!is_null($prefix)) { |
|
| 90 | - if(isset($this->backends[$prefix])) { |
|
| 89 | + if (!is_null($prefix)) { |
|
| 90 | + if (isset($this->backends[$prefix])) { |
|
| 91 | 91 | $instance = $this->backends[$prefix]; |
| 92 | - if(!method_exists($instance, $method) |
|
| 92 | + if (!method_exists($instance, $method) |
|
| 93 | 93 | && method_exists($this->getAccess($prefix), $method)) { |
| 94 | 94 | $instance = $this->getAccess($prefix); |
| 95 | 95 | } |
| 96 | 96 | $result = call_user_func_array(array($instance, $method), $parameters); |
| 97 | - if($result === $passOnWhen) { |
|
| 97 | + if ($result === $passOnWhen) { |
|
| 98 | 98 | //not found here, reset cache to null if user vanished |
| 99 | 99 | //because sometimes methods return false with a reason |
| 100 | 100 | $userExists = call_user_func_array( |
| 101 | 101 | array($this->backends[$prefix], 'userExists'), |
| 102 | 102 | array($uid) |
| 103 | 103 | ); |
| 104 | - if(!$userExists) { |
|
| 104 | + if (!$userExists) { |
|
| 105 | 105 | $this->writeToCache($cacheKey, null); |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | public function getUsers($search = '', $limit = 10, $offset = 0) { |
| 144 | 144 | //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
| 145 | 145 | $users = array(); |
| 146 | - foreach($this->backends as $backend) { |
|
| 146 | + foreach ($this->backends as $backend) { |
|
| 147 | 147 | $backendUsers = $backend->getUsers($search, $limit, $offset); |
| 148 | 148 | if (is_array($backendUsers)) { |
| 149 | 149 | $users = array_merge($users, $backendUsers); |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * @return string|false |
| 192 | 192 | */ |
| 193 | 193 | public function loginName2UserName($loginName) { |
| 194 | - $id = 'LOGINNAME,' . $loginName; |
|
| 194 | + $id = 'LOGINNAME,'.$loginName; |
|
| 195 | 195 | return $this->handleRequest($id, 'loginName2UserName', array($loginName)); |
| 196 | 196 | } |
| 197 | 197 | |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | * @return string|false with the username |
| 203 | 203 | */ |
| 204 | 204 | public function dn2UserName($dn) { |
| 205 | - $id = 'DN,' . $dn; |
|
| 205 | + $id = 'DN,'.$dn; |
|
| 206 | 206 | return $this->handleRequest($id, 'dn2UserName', array($dn)); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | public function getDisplayNames($search = '', $limit = null, $offset = null) { |
| 244 | 244 | //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
| 245 | 245 | $users = array(); |
| 246 | - foreach($this->backends as $backend) { |
|
| 246 | + foreach ($this->backends as $backend) { |
|
| 247 | 247 | $backendUsers = $backend->getDisplayNames($search, $limit, $offset); |
| 248 | 248 | if (is_array($backendUsers)) { |
| 249 | 249 | $users = $users + $backendUsers; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | */ |
| 288 | 288 | public function countUsers() { |
| 289 | 289 | $users = false; |
| 290 | - foreach($this->backends as $backend) { |
|
| 290 | + foreach ($this->backends as $backend) { |
|
| 291 | 291 | $backendUsers = $backend->countUsers(); |
| 292 | 292 | if ($backendUsers !== false) { |
| 293 | 293 | $users += $backendUsers; |
@@ -33,274 +33,274 @@ |
||
| 33 | 33 | use OCP\IConfig; |
| 34 | 34 | |
| 35 | 35 | class User_Proxy extends Proxy implements \OCP\IUserBackend, \OCP\UserInterface, IUserLDAP { |
| 36 | - private $backends = array(); |
|
| 37 | - private $refBackend = null; |
|
| 36 | + private $backends = array(); |
|
| 37 | + private $refBackend = null; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Constructor |
|
| 41 | - * @param array $serverConfigPrefixes array containing the config Prefixes |
|
| 42 | - */ |
|
| 43 | - public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig) { |
|
| 44 | - parent::__construct($ldap); |
|
| 45 | - foreach($serverConfigPrefixes as $configPrefix) { |
|
| 46 | - $this->backends[$configPrefix] = |
|
| 47 | - new User_LDAP($this->getAccess($configPrefix), $ocConfig); |
|
| 48 | - if(is_null($this->refBackend)) { |
|
| 49 | - $this->refBackend = &$this->backends[$configPrefix]; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - } |
|
| 39 | + /** |
|
| 40 | + * Constructor |
|
| 41 | + * @param array $serverConfigPrefixes array containing the config Prefixes |
|
| 42 | + */ |
|
| 43 | + public function __construct(array $serverConfigPrefixes, ILDAPWrapper $ldap, IConfig $ocConfig) { |
|
| 44 | + parent::__construct($ldap); |
|
| 45 | + foreach($serverConfigPrefixes as $configPrefix) { |
|
| 46 | + $this->backends[$configPrefix] = |
|
| 47 | + new User_LDAP($this->getAccess($configPrefix), $ocConfig); |
|
| 48 | + if(is_null($this->refBackend)) { |
|
| 49 | + $this->refBackend = &$this->backends[$configPrefix]; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * Tries the backends one after the other until a positive result is returned from the specified method |
|
| 56 | - * @param string $uid the uid connected to the request |
|
| 57 | - * @param string $method the method of the user backend that shall be called |
|
| 58 | - * @param array $parameters an array of parameters to be passed |
|
| 59 | - * @return mixed the result of the method or false |
|
| 60 | - */ |
|
| 61 | - protected function walkBackends($uid, $method, $parameters) { |
|
| 62 | - $cacheKey = $this->getUserCacheKey($uid); |
|
| 63 | - foreach($this->backends as $configPrefix => $backend) { |
|
| 64 | - $instance = $backend; |
|
| 65 | - if(!method_exists($instance, $method) |
|
| 66 | - && method_exists($this->getAccess($configPrefix), $method)) { |
|
| 67 | - $instance = $this->getAccess($configPrefix); |
|
| 68 | - } |
|
| 69 | - if($result = call_user_func_array(array($instance, $method), $parameters)) { |
|
| 70 | - $this->writeToCache($cacheKey, $configPrefix); |
|
| 71 | - return $result; |
|
| 72 | - } |
|
| 73 | - } |
|
| 74 | - return false; |
|
| 75 | - } |
|
| 54 | + /** |
|
| 55 | + * Tries the backends one after the other until a positive result is returned from the specified method |
|
| 56 | + * @param string $uid the uid connected to the request |
|
| 57 | + * @param string $method the method of the user backend that shall be called |
|
| 58 | + * @param array $parameters an array of parameters to be passed |
|
| 59 | + * @return mixed the result of the method or false |
|
| 60 | + */ |
|
| 61 | + protected function walkBackends($uid, $method, $parameters) { |
|
| 62 | + $cacheKey = $this->getUserCacheKey($uid); |
|
| 63 | + foreach($this->backends as $configPrefix => $backend) { |
|
| 64 | + $instance = $backend; |
|
| 65 | + if(!method_exists($instance, $method) |
|
| 66 | + && method_exists($this->getAccess($configPrefix), $method)) { |
|
| 67 | + $instance = $this->getAccess($configPrefix); |
|
| 68 | + } |
|
| 69 | + if($result = call_user_func_array(array($instance, $method), $parameters)) { |
|
| 70 | + $this->writeToCache($cacheKey, $configPrefix); |
|
| 71 | + return $result; |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | + return false; |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - /** |
|
| 78 | - * Asks the backend connected to the server that supposely takes care of the uid from the request. |
|
| 79 | - * @param string $uid the uid connected to the request |
|
| 80 | - * @param string $method the method of the user backend that shall be called |
|
| 81 | - * @param array $parameters an array of parameters to be passed |
|
| 82 | - * @param mixed $passOnWhen the result matches this variable |
|
| 83 | - * @return mixed the result of the method or false |
|
| 84 | - */ |
|
| 85 | - protected function callOnLastSeenOn($uid, $method, $parameters, $passOnWhen) { |
|
| 86 | - $cacheKey = $this->getUserCacheKey($uid); |
|
| 87 | - $prefix = $this->getFromCache($cacheKey); |
|
| 88 | - //in case the uid has been found in the past, try this stored connection first |
|
| 89 | - if(!is_null($prefix)) { |
|
| 90 | - if(isset($this->backends[$prefix])) { |
|
| 91 | - $instance = $this->backends[$prefix]; |
|
| 92 | - if(!method_exists($instance, $method) |
|
| 93 | - && method_exists($this->getAccess($prefix), $method)) { |
|
| 94 | - $instance = $this->getAccess($prefix); |
|
| 95 | - } |
|
| 96 | - $result = call_user_func_array(array($instance, $method), $parameters); |
|
| 97 | - if($result === $passOnWhen) { |
|
| 98 | - //not found here, reset cache to null if user vanished |
|
| 99 | - //because sometimes methods return false with a reason |
|
| 100 | - $userExists = call_user_func_array( |
|
| 101 | - array($this->backends[$prefix], 'userExists'), |
|
| 102 | - array($uid) |
|
| 103 | - ); |
|
| 104 | - if(!$userExists) { |
|
| 105 | - $this->writeToCache($cacheKey, null); |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - return $result; |
|
| 109 | - } |
|
| 110 | - } |
|
| 111 | - return false; |
|
| 112 | - } |
|
| 77 | + /** |
|
| 78 | + * Asks the backend connected to the server that supposely takes care of the uid from the request. |
|
| 79 | + * @param string $uid the uid connected to the request |
|
| 80 | + * @param string $method the method of the user backend that shall be called |
|
| 81 | + * @param array $parameters an array of parameters to be passed |
|
| 82 | + * @param mixed $passOnWhen the result matches this variable |
|
| 83 | + * @return mixed the result of the method or false |
|
| 84 | + */ |
|
| 85 | + protected function callOnLastSeenOn($uid, $method, $parameters, $passOnWhen) { |
|
| 86 | + $cacheKey = $this->getUserCacheKey($uid); |
|
| 87 | + $prefix = $this->getFromCache($cacheKey); |
|
| 88 | + //in case the uid has been found in the past, try this stored connection first |
|
| 89 | + if(!is_null($prefix)) { |
|
| 90 | + if(isset($this->backends[$prefix])) { |
|
| 91 | + $instance = $this->backends[$prefix]; |
|
| 92 | + if(!method_exists($instance, $method) |
|
| 93 | + && method_exists($this->getAccess($prefix), $method)) { |
|
| 94 | + $instance = $this->getAccess($prefix); |
|
| 95 | + } |
|
| 96 | + $result = call_user_func_array(array($instance, $method), $parameters); |
|
| 97 | + if($result === $passOnWhen) { |
|
| 98 | + //not found here, reset cache to null if user vanished |
|
| 99 | + //because sometimes methods return false with a reason |
|
| 100 | + $userExists = call_user_func_array( |
|
| 101 | + array($this->backends[$prefix], 'userExists'), |
|
| 102 | + array($uid) |
|
| 103 | + ); |
|
| 104 | + if(!$userExists) { |
|
| 105 | + $this->writeToCache($cacheKey, null); |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + return $result; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | + return false; |
|
| 112 | + } |
|
| 113 | 113 | |
| 114 | - /** |
|
| 115 | - * Check if backend implements actions |
|
| 116 | - * @param int $actions bitwise-or'ed actions |
|
| 117 | - * @return boolean |
|
| 118 | - * |
|
| 119 | - * Returns the supported actions as int to be |
|
| 120 | - * compared with OC_USER_BACKEND_CREATE_USER etc. |
|
| 121 | - */ |
|
| 122 | - public function implementsActions($actions) { |
|
| 123 | - //it's the same across all our user backends obviously |
|
| 124 | - return $this->refBackend->implementsActions($actions); |
|
| 125 | - } |
|
| 114 | + /** |
|
| 115 | + * Check if backend implements actions |
|
| 116 | + * @param int $actions bitwise-or'ed actions |
|
| 117 | + * @return boolean |
|
| 118 | + * |
|
| 119 | + * Returns the supported actions as int to be |
|
| 120 | + * compared with OC_USER_BACKEND_CREATE_USER etc. |
|
| 121 | + */ |
|
| 122 | + public function implementsActions($actions) { |
|
| 123 | + //it's the same across all our user backends obviously |
|
| 124 | + return $this->refBackend->implementsActions($actions); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - /** |
|
| 128 | - * Backend name to be shown in user management |
|
| 129 | - * @return string the name of the backend to be shown |
|
| 130 | - */ |
|
| 131 | - public function getBackendName() { |
|
| 132 | - return $this->refBackend->getBackendName(); |
|
| 133 | - } |
|
| 127 | + /** |
|
| 128 | + * Backend name to be shown in user management |
|
| 129 | + * @return string the name of the backend to be shown |
|
| 130 | + */ |
|
| 131 | + public function getBackendName() { |
|
| 132 | + return $this->refBackend->getBackendName(); |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * Get a list of all users |
|
| 137 | - * |
|
| 138 | - * @param string $search |
|
| 139 | - * @param null|int $limit |
|
| 140 | - * @param null|int $offset |
|
| 141 | - * @return string[] an array of all uids |
|
| 142 | - */ |
|
| 143 | - public function getUsers($search = '', $limit = 10, $offset = 0) { |
|
| 144 | - //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
|
| 145 | - $users = array(); |
|
| 146 | - foreach($this->backends as $backend) { |
|
| 147 | - $backendUsers = $backend->getUsers($search, $limit, $offset); |
|
| 148 | - if (is_array($backendUsers)) { |
|
| 149 | - $users = array_merge($users, $backendUsers); |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - return $users; |
|
| 153 | - } |
|
| 135 | + /** |
|
| 136 | + * Get a list of all users |
|
| 137 | + * |
|
| 138 | + * @param string $search |
|
| 139 | + * @param null|int $limit |
|
| 140 | + * @param null|int $offset |
|
| 141 | + * @return string[] an array of all uids |
|
| 142 | + */ |
|
| 143 | + public function getUsers($search = '', $limit = 10, $offset = 0) { |
|
| 144 | + //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
|
| 145 | + $users = array(); |
|
| 146 | + foreach($this->backends as $backend) { |
|
| 147 | + $backendUsers = $backend->getUsers($search, $limit, $offset); |
|
| 148 | + if (is_array($backendUsers)) { |
|
| 149 | + $users = array_merge($users, $backendUsers); |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + return $users; |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * check if a user exists |
|
| 157 | - * @param string $uid the username |
|
| 158 | - * @return boolean |
|
| 159 | - */ |
|
| 160 | - public function userExists($uid) { |
|
| 161 | - return $this->handleRequest($uid, 'userExists', array($uid)); |
|
| 162 | - } |
|
| 155 | + /** |
|
| 156 | + * check if a user exists |
|
| 157 | + * @param string $uid the username |
|
| 158 | + * @return boolean |
|
| 159 | + */ |
|
| 160 | + public function userExists($uid) { |
|
| 161 | + return $this->handleRequest($uid, 'userExists', array($uid)); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - /** |
|
| 165 | - * check if a user exists on LDAP |
|
| 166 | - * @param string|\OCA\User_LDAP\User\User $user either the ownCloud user |
|
| 167 | - * name or an instance of that user |
|
| 168 | - * @return boolean |
|
| 169 | - */ |
|
| 170 | - public function userExistsOnLDAP($user) { |
|
| 171 | - $id = ($user instanceof User) ? $user->getUsername() : $user; |
|
| 172 | - return $this->handleRequest($id, 'userExistsOnLDAP', array($user)); |
|
| 173 | - } |
|
| 164 | + /** |
|
| 165 | + * check if a user exists on LDAP |
|
| 166 | + * @param string|\OCA\User_LDAP\User\User $user either the ownCloud user |
|
| 167 | + * name or an instance of that user |
|
| 168 | + * @return boolean |
|
| 169 | + */ |
|
| 170 | + public function userExistsOnLDAP($user) { |
|
| 171 | + $id = ($user instanceof User) ? $user->getUsername() : $user; |
|
| 172 | + return $this->handleRequest($id, 'userExistsOnLDAP', array($user)); |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - /** |
|
| 176 | - * Check if the password is correct |
|
| 177 | - * @param string $uid The username |
|
| 178 | - * @param string $password The password |
|
| 179 | - * @return bool |
|
| 180 | - * |
|
| 181 | - * Check if the password is correct without logging in the user |
|
| 182 | - */ |
|
| 183 | - public function checkPassword($uid, $password) { |
|
| 184 | - return $this->handleRequest($uid, 'checkPassword', array($uid, $password)); |
|
| 185 | - } |
|
| 175 | + /** |
|
| 176 | + * Check if the password is correct |
|
| 177 | + * @param string $uid The username |
|
| 178 | + * @param string $password The password |
|
| 179 | + * @return bool |
|
| 180 | + * |
|
| 181 | + * Check if the password is correct without logging in the user |
|
| 182 | + */ |
|
| 183 | + public function checkPassword($uid, $password) { |
|
| 184 | + return $this->handleRequest($uid, 'checkPassword', array($uid, $password)); |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * returns the username for the given login name, if available |
|
| 189 | - * |
|
| 190 | - * @param string $loginName |
|
| 191 | - * @return string|false |
|
| 192 | - */ |
|
| 193 | - public function loginName2UserName($loginName) { |
|
| 194 | - $id = 'LOGINNAME,' . $loginName; |
|
| 195 | - return $this->handleRequest($id, 'loginName2UserName', array($loginName)); |
|
| 196 | - } |
|
| 187 | + /** |
|
| 188 | + * returns the username for the given login name, if available |
|
| 189 | + * |
|
| 190 | + * @param string $loginName |
|
| 191 | + * @return string|false |
|
| 192 | + */ |
|
| 193 | + public function loginName2UserName($loginName) { |
|
| 194 | + $id = 'LOGINNAME,' . $loginName; |
|
| 195 | + return $this->handleRequest($id, 'loginName2UserName', array($loginName)); |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - /** |
|
| 199 | - * returns the username for the given LDAP DN, if available |
|
| 200 | - * |
|
| 201 | - * @param string $dn |
|
| 202 | - * @return string|false with the username |
|
| 203 | - */ |
|
| 204 | - public function dn2UserName($dn) { |
|
| 205 | - $id = 'DN,' . $dn; |
|
| 206 | - return $this->handleRequest($id, 'dn2UserName', array($dn)); |
|
| 207 | - } |
|
| 198 | + /** |
|
| 199 | + * returns the username for the given LDAP DN, if available |
|
| 200 | + * |
|
| 201 | + * @param string $dn |
|
| 202 | + * @return string|false with the username |
|
| 203 | + */ |
|
| 204 | + public function dn2UserName($dn) { |
|
| 205 | + $id = 'DN,' . $dn; |
|
| 206 | + return $this->handleRequest($id, 'dn2UserName', array($dn)); |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - /** |
|
| 210 | - * get the user's home directory |
|
| 211 | - * @param string $uid the username |
|
| 212 | - * @return boolean |
|
| 213 | - */ |
|
| 214 | - public function getHome($uid) { |
|
| 215 | - return $this->handleRequest($uid, 'getHome', array($uid)); |
|
| 216 | - } |
|
| 209 | + /** |
|
| 210 | + * get the user's home directory |
|
| 211 | + * @param string $uid the username |
|
| 212 | + * @return boolean |
|
| 213 | + */ |
|
| 214 | + public function getHome($uid) { |
|
| 215 | + return $this->handleRequest($uid, 'getHome', array($uid)); |
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - /** |
|
| 219 | - * get display name of the user |
|
| 220 | - * @param string $uid user ID of the user |
|
| 221 | - * @return string display name |
|
| 222 | - */ |
|
| 223 | - public function getDisplayName($uid) { |
|
| 224 | - return $this->handleRequest($uid, 'getDisplayName', array($uid)); |
|
| 225 | - } |
|
| 218 | + /** |
|
| 219 | + * get display name of the user |
|
| 220 | + * @param string $uid user ID of the user |
|
| 221 | + * @return string display name |
|
| 222 | + */ |
|
| 223 | + public function getDisplayName($uid) { |
|
| 224 | + return $this->handleRequest($uid, 'getDisplayName', array($uid)); |
|
| 225 | + } |
|
| 226 | 226 | |
| 227 | - /** |
|
| 228 | - * checks whether the user is allowed to change his avatar in ownCloud |
|
| 229 | - * @param string $uid the ownCloud user name |
|
| 230 | - * @return boolean either the user can or cannot |
|
| 231 | - */ |
|
| 232 | - public function canChangeAvatar($uid) { |
|
| 233 | - return $this->handleRequest($uid, 'canChangeAvatar', array($uid), true); |
|
| 234 | - } |
|
| 227 | + /** |
|
| 228 | + * checks whether the user is allowed to change his avatar in ownCloud |
|
| 229 | + * @param string $uid the ownCloud user name |
|
| 230 | + * @return boolean either the user can or cannot |
|
| 231 | + */ |
|
| 232 | + public function canChangeAvatar($uid) { |
|
| 233 | + return $this->handleRequest($uid, 'canChangeAvatar', array($uid), true); |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - /** |
|
| 237 | - * Get a list of all display names and user ids. |
|
| 238 | - * @param string $search |
|
| 239 | - * @param string|null $limit |
|
| 240 | - * @param string|null $offset |
|
| 241 | - * @return array an array of all displayNames (value) and the corresponding uids (key) |
|
| 242 | - */ |
|
| 243 | - public function getDisplayNames($search = '', $limit = null, $offset = null) { |
|
| 244 | - //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
|
| 245 | - $users = array(); |
|
| 246 | - foreach($this->backends as $backend) { |
|
| 247 | - $backendUsers = $backend->getDisplayNames($search, $limit, $offset); |
|
| 248 | - if (is_array($backendUsers)) { |
|
| 249 | - $users = $users + $backendUsers; |
|
| 250 | - } |
|
| 251 | - } |
|
| 252 | - return $users; |
|
| 253 | - } |
|
| 236 | + /** |
|
| 237 | + * Get a list of all display names and user ids. |
|
| 238 | + * @param string $search |
|
| 239 | + * @param string|null $limit |
|
| 240 | + * @param string|null $offset |
|
| 241 | + * @return array an array of all displayNames (value) and the corresponding uids (key) |
|
| 242 | + */ |
|
| 243 | + public function getDisplayNames($search = '', $limit = null, $offset = null) { |
|
| 244 | + //we do it just as the /OC_User implementation: do not play around with limit and offset but ask all backends |
|
| 245 | + $users = array(); |
|
| 246 | + foreach($this->backends as $backend) { |
|
| 247 | + $backendUsers = $backend->getDisplayNames($search, $limit, $offset); |
|
| 248 | + if (is_array($backendUsers)) { |
|
| 249 | + $users = $users + $backendUsers; |
|
| 250 | + } |
|
| 251 | + } |
|
| 252 | + return $users; |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - /** |
|
| 256 | - * delete a user |
|
| 257 | - * @param string $uid The username of the user to delete |
|
| 258 | - * @return bool |
|
| 259 | - * |
|
| 260 | - * Deletes a user |
|
| 261 | - */ |
|
| 262 | - public function deleteUser($uid) { |
|
| 263 | - return $this->handleRequest($uid, 'deleteUser', array($uid)); |
|
| 264 | - } |
|
| 255 | + /** |
|
| 256 | + * delete a user |
|
| 257 | + * @param string $uid The username of the user to delete |
|
| 258 | + * @return bool |
|
| 259 | + * |
|
| 260 | + * Deletes a user |
|
| 261 | + */ |
|
| 262 | + public function deleteUser($uid) { |
|
| 263 | + return $this->handleRequest($uid, 'deleteUser', array($uid)); |
|
| 264 | + } |
|
| 265 | 265 | |
| 266 | - /** |
|
| 267 | - * @return bool |
|
| 268 | - */ |
|
| 269 | - public function hasUserListings() { |
|
| 270 | - return $this->refBackend->hasUserListings(); |
|
| 271 | - } |
|
| 266 | + /** |
|
| 267 | + * @return bool |
|
| 268 | + */ |
|
| 269 | + public function hasUserListings() { |
|
| 270 | + return $this->refBackend->hasUserListings(); |
|
| 271 | + } |
|
| 272 | 272 | |
| 273 | - /** |
|
| 274 | - * Count the number of users |
|
| 275 | - * @return int|bool |
|
| 276 | - */ |
|
| 277 | - public function countUsers() { |
|
| 278 | - $users = false; |
|
| 279 | - foreach($this->backends as $backend) { |
|
| 280 | - $backendUsers = $backend->countUsers(); |
|
| 281 | - if ($backendUsers !== false) { |
|
| 282 | - $users += $backendUsers; |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - return $users; |
|
| 286 | - } |
|
| 273 | + /** |
|
| 274 | + * Count the number of users |
|
| 275 | + * @return int|bool |
|
| 276 | + */ |
|
| 277 | + public function countUsers() { |
|
| 278 | + $users = false; |
|
| 279 | + foreach($this->backends as $backend) { |
|
| 280 | + $backendUsers = $backend->countUsers(); |
|
| 281 | + if ($backendUsers !== false) { |
|
| 282 | + $users += $backendUsers; |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + return $users; |
|
| 286 | + } |
|
| 287 | 287 | |
| 288 | - /** |
|
| 289 | - * Return access for LDAP interaction. |
|
| 290 | - * @param string $uid |
|
| 291 | - * @return Access instance of Access for LDAP interaction |
|
| 292 | - */ |
|
| 293 | - public function getLDAPAccess($uid) { |
|
| 294 | - return $this->handleRequest($uid, 'getLDAPAccess', array($uid)); |
|
| 295 | - } |
|
| 288 | + /** |
|
| 289 | + * Return access for LDAP interaction. |
|
| 290 | + * @param string $uid |
|
| 291 | + * @return Access instance of Access for LDAP interaction |
|
| 292 | + */ |
|
| 293 | + public function getLDAPAccess($uid) { |
|
| 294 | + return $this->handleRequest($uid, 'getLDAPAccess', array($uid)); |
|
| 295 | + } |
|
| 296 | 296 | |
| 297 | - /** |
|
| 298 | - * Return a new LDAP connection for the specified user. |
|
| 299 | - * The connection needs to be closed manually. |
|
| 300 | - * @param string $uid |
|
| 301 | - * @return resource of the LDAP connection |
|
| 302 | - */ |
|
| 303 | - public function getNewLDAPConnection($uid) { |
|
| 304 | - return $this->handleRequest($uid, 'getNewLDAPConnection', array($uid)); |
|
| 305 | - } |
|
| 297 | + /** |
|
| 298 | + * Return a new LDAP connection for the specified user. |
|
| 299 | + * The connection needs to be closed manually. |
|
| 300 | + * @param string $uid |
|
| 301 | + * @return resource of the LDAP connection |
|
| 302 | + */ |
|
| 303 | + public function getNewLDAPConnection($uid) { |
|
| 304 | + return $this->handleRequest($uid, 'getNewLDAPConnection', array($uid)); |
|
| 305 | + } |
|
| 306 | 306 | } |
@@ -29,19 +29,19 @@ |
||
| 29 | 29 | */ |
| 30 | 30 | class FilesystemHelper { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @brief states whether the filesystem was loaded |
|
| 34 | - * @return bool |
|
| 35 | - */ |
|
| 36 | - public function isLoaded() { |
|
| 37 | - return \OC\Files\Filesystem::$loaded; |
|
| 38 | - } |
|
| 32 | + /** |
|
| 33 | + * @brief states whether the filesystem was loaded |
|
| 34 | + * @return bool |
|
| 35 | + */ |
|
| 36 | + public function isLoaded() { |
|
| 37 | + return \OC\Files\Filesystem::$loaded; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * @brief initializes the filesystem for the given user |
|
| 42 | - * @param string $uid the ownCloud username of the user |
|
| 43 | - */ |
|
| 44 | - public function setup($uid) { |
|
| 45 | - \OC_Util::setupFS($uid); |
|
| 46 | - } |
|
| 40 | + /** |
|
| 41 | + * @brief initializes the filesystem for the given user |
|
| 42 | + * @param string $uid the ownCloud username of the user |
|
| 43 | + */ |
|
| 44 | + public function setup($uid) { |
|
| 45 | + \OC_Util::setupFS($uid); |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -28,13 +28,13 @@ |
||
| 28 | 28 | * @brief wraps around static ownCloud core methods |
| 29 | 29 | */ |
| 30 | 30 | class LogWrapper { |
| 31 | - protected $app = 'user_ldap'; |
|
| 31 | + protected $app = 'user_ldap'; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @brief states whether the filesystem was loaded |
|
| 35 | - * @return bool |
|
| 36 | - */ |
|
| 37 | - public function log($msg, $level) { |
|
| 38 | - \OCP\Util::writeLog($this->app, $msg, $level); |
|
| 39 | - } |
|
| 33 | + /** |
|
| 34 | + * @brief states whether the filesystem was loaded |
|
| 35 | + * @return bool |
|
| 36 | + */ |
|
| 37 | + public function log($msg, $level) { |
|
| 38 | + \OCP\Util::writeLog($this->app, $msg, $level); |
|
| 39 | + } |
|
| 40 | 40 | } |
@@ -22,7 +22,7 @@ |
||
| 22 | 22 | * |
| 23 | 23 | */ |
| 24 | 24 | $state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'doSet'); |
| 25 | -if($state === 'doSet') { |
|
| 25 | +if ($state === 'doSet') { |
|
| 26 | 26 | OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); |
| 27 | 27 | } |
| 28 | 28 | |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | $state = OCP\Config::getSystemValue('ldapIgnoreNamingRules', 'doSet'); |
| 25 | 25 | if($state === 'doSet') { |
| 26 | - OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); |
|
| 26 | + OCP\Config::setSystemValue('ldapIgnoreNamingRules', false); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | $helper = new \OCA\User_LDAP\Helper(); |
@@ -32,44 +32,44 @@ |
||
| 32 | 32 | $ldapWrapper = new OCA\User_LDAP\LDAP(); |
| 33 | 33 | $ocConfig = \OC::$server->getConfig(); |
| 34 | 34 | if(count($configPrefixes) === 1) { |
| 35 | - $dbc = \OC::$server->getDatabaseConnection(); |
|
| 36 | - $userManager = new OCA\User_LDAP\User\Manager($ocConfig, |
|
| 37 | - new OCA\User_LDAP\FilesystemHelper(), |
|
| 38 | - new OCA\User_LDAP\LogWrapper(), |
|
| 39 | - \OC::$server->getAvatarManager(), |
|
| 40 | - new \OCP\Image(), |
|
| 41 | - $dbc, |
|
| 42 | - \OC::$server->getUserManager() |
|
| 43 | - ); |
|
| 44 | - $connector = new OCA\User_LDAP\Connection($ldapWrapper, $configPrefixes[0]); |
|
| 45 | - $ldapAccess = new OCA\User_LDAP\Access($connector, $ldapWrapper, $userManager, $helper); |
|
| 35 | + $dbc = \OC::$server->getDatabaseConnection(); |
|
| 36 | + $userManager = new OCA\User_LDAP\User\Manager($ocConfig, |
|
| 37 | + new OCA\User_LDAP\FilesystemHelper(), |
|
| 38 | + new OCA\User_LDAP\LogWrapper(), |
|
| 39 | + \OC::$server->getAvatarManager(), |
|
| 40 | + new \OCP\Image(), |
|
| 41 | + $dbc, |
|
| 42 | + \OC::$server->getUserManager() |
|
| 43 | + ); |
|
| 44 | + $connector = new OCA\User_LDAP\Connection($ldapWrapper, $configPrefixes[0]); |
|
| 45 | + $ldapAccess = new OCA\User_LDAP\Access($connector, $ldapWrapper, $userManager, $helper); |
|
| 46 | 46 | |
| 47 | - $ldapAccess->setUserMapper(new OCA\User_LDAP\Mapping\UserMapping($dbc)); |
|
| 48 | - $ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc)); |
|
| 49 | - $userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig); |
|
| 50 | - $groupBackend = new \OCA\User_LDAP\Group_LDAP($ldapAccess); |
|
| 47 | + $ldapAccess->setUserMapper(new OCA\User_LDAP\Mapping\UserMapping($dbc)); |
|
| 48 | + $ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc)); |
|
| 49 | + $userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig); |
|
| 50 | + $groupBackend = new \OCA\User_LDAP\Group_LDAP($ldapAccess); |
|
| 51 | 51 | } else if(count($configPrefixes) > 1) { |
| 52 | - $userBackend = new OCA\User_LDAP\User_Proxy( |
|
| 53 | - $configPrefixes, $ldapWrapper, $ocConfig |
|
| 54 | - ); |
|
| 55 | - $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
| 52 | + $userBackend = new OCA\User_LDAP\User_Proxy( |
|
| 53 | + $configPrefixes, $ldapWrapper, $ocConfig |
|
| 54 | + ); |
|
| 55 | + $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | if(count($configPrefixes) > 0) { |
| 59 | - // register user backend |
|
| 60 | - OC_User::useBackend($userBackend); |
|
| 61 | - OC_Group::useBackend($groupBackend); |
|
| 59 | + // register user backend |
|
| 60 | + OC_User::useBackend($userBackend); |
|
| 61 | + OC_Group::useBackend($groupBackend); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | \OCP\Util::connectHook( |
| 65 | - '\OCA\Files_Sharing\API\Server2Server', |
|
| 66 | - 'preLoginNameUsedAsUserName', |
|
| 67 | - '\OCA\User_LDAP\Helper', |
|
| 68 | - 'loginName2UserName' |
|
| 65 | + '\OCA\Files_Sharing\API\Server2Server', |
|
| 66 | + 'preLoginNameUsedAsUserName', |
|
| 67 | + '\OCA\User_LDAP\Helper', |
|
| 68 | + 'loginName2UserName' |
|
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | if(OCP\App::isEnabled('user_webdavauth')) { |
| 72 | - OCP\Util::writeLog('user_ldap', |
|
| 73 | - 'user_ldap and user_webdavauth are incompatible. You may experience unexpected behaviour', |
|
| 74 | - OCP\Util::WARN); |
|
| 72 | + OCP\Util::writeLog('user_ldap', |
|
| 73 | + 'user_ldap and user_webdavauth are incompatible. You may experience unexpected behaviour', |
|
| 74 | + OCP\Util::WARN); |
|
| 75 | 75 | } |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | $configPrefixes = $helper->getServerConfigurationPrefixes(true); |
| 32 | 32 | $ldapWrapper = new OCA\User_LDAP\LDAP(); |
| 33 | 33 | $ocConfig = \OC::$server->getConfig(); |
| 34 | -if(count($configPrefixes) === 1) { |
|
| 34 | +if (count($configPrefixes) === 1) { |
|
| 35 | 35 | $dbc = \OC::$server->getDatabaseConnection(); |
| 36 | 36 | $userManager = new OCA\User_LDAP\User\Manager($ocConfig, |
| 37 | 37 | new OCA\User_LDAP\FilesystemHelper(), |
@@ -48,14 +48,14 @@ discard block |
||
| 48 | 48 | $ldapAccess->setGroupMapper(new OCA\User_LDAP\Mapping\GroupMapping($dbc)); |
| 49 | 49 | $userBackend = new OCA\User_LDAP\User_LDAP($ldapAccess, $ocConfig); |
| 50 | 50 | $groupBackend = new \OCA\User_LDAP\Group_LDAP($ldapAccess); |
| 51 | -} else if(count($configPrefixes) > 1) { |
|
| 51 | +} else if (count($configPrefixes) > 1) { |
|
| 52 | 52 | $userBackend = new OCA\User_LDAP\User_Proxy( |
| 53 | 53 | $configPrefixes, $ldapWrapper, $ocConfig |
| 54 | 54 | ); |
| 55 | - $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
| 55 | + $groupBackend = new OCA\User_LDAP\Group_Proxy($configPrefixes, $ldapWrapper); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | -if(count($configPrefixes) > 0) { |
|
| 58 | +if (count($configPrefixes) > 0) { |
|
| 59 | 59 | // register user backend |
| 60 | 60 | OC_User::useBackend($userBackend); |
| 61 | 61 | OC_Group::useBackend($groupBackend); |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | 'loginName2UserName' |
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | -if(OCP\App::isEnabled('user_webdavauth')) { |
|
| 71 | +if (OCP\App::isEnabled('user_webdavauth')) { |
|
| 72 | 72 | OCP\Util::writeLog('user_ldap', |
| 73 | 73 | 'user_ldap and user_webdavauth are incompatible. You may experience unexpected behaviour', |
| 74 | 74 | OCP\Util::WARN); |