@@ -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); |
@@ -1,47 +1,47 @@ discard block |
||
1 | 1 | <?php |
2 | - use \OCA\Files_External\Lib\Backend\Backend; |
|
3 | - use \OCA\Files_External\Lib\Auth\AuthMechanism; |
|
4 | - use \OCA\Files_External\Lib\DefinitionParameter; |
|
5 | - use \OCA\Files_External\Service\BackendService; |
|
2 | + use \OCA\Files_External\Lib\Backend\Backend; |
|
3 | + use \OCA\Files_External\Lib\Auth\AuthMechanism; |
|
4 | + use \OCA\Files_External\Lib\DefinitionParameter; |
|
5 | + use \OCA\Files_External\Service\BackendService; |
|
6 | 6 | |
7 | - $canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting']; |
|
7 | + $canCreateMounts = $_['visibilityType'] === BackendService::VISIBILITY_ADMIN || $_['allowUserMounting']; |
|
8 | 8 | |
9 | - $l->t("Enable encryption"); |
|
10 | - $l->t("Enable previews"); |
|
11 | - $l->t("Enable sharing"); |
|
12 | - $l->t("Check for changes"); |
|
13 | - $l->t("Never"); |
|
14 | - $l->t("Once every direct access"); |
|
9 | + $l->t("Enable encryption"); |
|
10 | + $l->t("Enable previews"); |
|
11 | + $l->t("Enable sharing"); |
|
12 | + $l->t("Check for changes"); |
|
13 | + $l->t("Never"); |
|
14 | + $l->t("Once every direct access"); |
|
15 | 15 | |
16 | - script('files_external', 'settings'); |
|
17 | - style('files_external', 'settings'); |
|
16 | + script('files_external', 'settings'); |
|
17 | + style('files_external', 'settings'); |
|
18 | 18 | |
19 | - // load custom JS |
|
20 | - foreach ($_['backends'] as $backend) { |
|
21 | - /** @var Backend $backend */ |
|
22 | - $scripts = $backend->getCustomJs(); |
|
23 | - foreach ($scripts as $script) { |
|
24 | - script('files_external', $script); |
|
25 | - } |
|
26 | - } |
|
27 | - foreach ($_['authMechanisms'] as $authMechanism) { |
|
28 | - /** @var AuthMechanism $authMechanism */ |
|
29 | - $scripts = $authMechanism->getCustomJs(); |
|
30 | - foreach ($scripts as $script) { |
|
31 | - script('files_external', $script); |
|
32 | - } |
|
33 | - } |
|
19 | + // load custom JS |
|
20 | + foreach ($_['backends'] as $backend) { |
|
21 | + /** @var Backend $backend */ |
|
22 | + $scripts = $backend->getCustomJs(); |
|
23 | + foreach ($scripts as $script) { |
|
24 | + script('files_external', $script); |
|
25 | + } |
|
26 | + } |
|
27 | + foreach ($_['authMechanisms'] as $authMechanism) { |
|
28 | + /** @var AuthMechanism $authMechanism */ |
|
29 | + $scripts = $authMechanism->getCustomJs(); |
|
30 | + foreach ($scripts as $script) { |
|
31 | + script('files_external', $script); |
|
32 | + } |
|
33 | + } |
|
34 | 34 | |
35 | - function writeParameterInput($parameter, $options, $classes = []) { |
|
36 | - $value = ''; |
|
37 | - if (isset($options[$parameter->getName()])) { |
|
38 | - $value = $options[$parameter->getName()]; |
|
39 | - } |
|
40 | - $placeholder = $parameter->getText(); |
|
41 | - $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL); |
|
35 | + function writeParameterInput($parameter, $options, $classes = []) { |
|
36 | + $value = ''; |
|
37 | + if (isset($options[$parameter->getName()])) { |
|
38 | + $value = $options[$parameter->getName()]; |
|
39 | + } |
|
40 | + $placeholder = $parameter->getText(); |
|
41 | + $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL); |
|
42 | 42 | |
43 | - switch ($parameter->getType()) { |
|
44 | - case DefinitionParameter::VALUE_PASSWORD: ?> |
|
43 | + switch ($parameter->getType()) { |
|
44 | + case DefinitionParameter::VALUE_PASSWORD: ?> |
|
45 | 45 | <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
46 | 46 | <input type="password" |
47 | 47 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | placeholder="<?php p($placeholder); ?>" |
51 | 51 | /> |
52 | 52 | <?php |
53 | - break; |
|
54 | - case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
53 | + break; |
|
54 | + case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
55 | 55 | <?php $checkboxId = uniqid("checkbox_"); ?> |
56 | 56 | <div> |
57 | 57 | <label> |
@@ -65,16 +65,16 @@ discard block |
||
65 | 65 | </label> |
66 | 66 | </div> |
67 | 67 | <?php |
68 | - break; |
|
69 | - case DefinitionParameter::VALUE_HIDDEN: ?> |
|
68 | + break; |
|
69 | + case DefinitionParameter::VALUE_HIDDEN: ?> |
|
70 | 70 | <input type="hidden" |
71 | 71 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
72 | 72 | data-parameter="<?php p($parameter->getName()); ?>" |
73 | 73 | value="<?php p($value); ?>" |
74 | 74 | /> |
75 | 75 | <?php |
76 | - break; |
|
77 | - default: ?> |
|
76 | + break; |
|
77 | + default: ?> |
|
78 | 78 | <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
79 | 79 | <input type="text" |
80 | 80 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
@@ -83,8 +83,8 @@ discard block |
||
83 | 83 | placeholder="<?php p($placeholder); ?>" |
84 | 84 | /> |
85 | 85 | <?php |
86 | - } |
|
87 | - } |
|
86 | + } |
|
87 | + } |
|
88 | 88 | ?> |
89 | 89 | |
90 | 90 | <form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>"> |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | <?php p($l->t('Add storage')); ?> |
123 | 123 | </option> |
124 | 124 | <?php |
125 | - $sortedBackends = array_filter($_['backends'], function($backend) use ($_) { |
|
126 | - return $backend->isVisibleFor($_['visibilityType']); |
|
127 | - }); |
|
128 | - uasort($sortedBackends, function($a, $b) { |
|
129 | - return strcasecmp($a->getText(), $b->getText()); |
|
130 | - }); |
|
131 | - ?> |
|
125 | + $sortedBackends = array_filter($_['backends'], function($backend) use ($_) { |
|
126 | + return $backend->isVisibleFor($_['visibilityType']); |
|
127 | + }); |
|
128 | + uasort($sortedBackends, function($a, $b) { |
|
129 | + return strcasecmp($a->getText(), $b->getText()); |
|
130 | + }); |
|
131 | + ?> |
|
132 | 132 | <?php foreach ($sortedBackends as $backend): ?> |
133 | 133 | <?php if ($backend->getDeprecateTo()) continue; // ignore deprecated backends ?> |
134 | 134 | <option value="<?php p($backend->getIdentifier()); ?>"><?php p($backend->getText()); ?></option> |
@@ -169,10 +169,10 @@ discard block |
||
169 | 169 | <p id="userMountingBackends"<?php if ($_['allowUserMounting'] != 'yes'): ?> class="hidden"<?php endif; ?>> |
170 | 170 | <?php p($l->t('Allow users to mount the following external storage')); ?><br /> |
171 | 171 | <?php |
172 | - $userBackends = array_filter($_['backends'], function($backend) { |
|
173 | - return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
|
174 | - }); |
|
175 | - ?> |
|
172 | + $userBackends = array_filter($_['backends'], function($backend) { |
|
173 | + return $backend->isAllowedVisibleFor(BackendService::VISIBILITY_PERSONAL); |
|
174 | + }); |
|
175 | + ?> |
|
176 | 176 | <?php $i = 0; foreach ($userBackends as $backend): ?> |
177 | 177 | <?php if ($deprecateTo = $backend->getDeprecateTo()): ?> |
178 | 178 | <input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" /> |
@@ -41,44 +41,44 @@ |
||
41 | 41 | $is_optional = $parameter->isFlagSet(DefinitionParameter::FLAG_OPTIONAL); |
42 | 42 | |
43 | 43 | switch ($parameter->getType()) { |
44 | - case DefinitionParameter::VALUE_PASSWORD: ?> |
|
45 | - <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
|
46 | - <input type="password" |
|
44 | + case DefinitionParameter::VALUE_PASSWORD: ?> |
|
45 | + <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
|
46 | + <input type="password" |
|
47 | 47 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
48 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
48 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
49 | 49 | value="<?php p($value); ?>" |
50 | 50 | placeholder="<?php p($placeholder); ?>" |
51 | 51 | /> |
52 | 52 | <?php |
53 | - break; |
|
54 | - case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
55 | - <?php $checkboxId = uniqid("checkbox_"); ?> |
|
53 | + break; |
|
54 | + case DefinitionParameter::VALUE_BOOLEAN: ?> |
|
55 | + <?php $checkboxId = uniqid("checkbox_"); ?> |
|
56 | 56 | <div> |
57 | 57 | <label> |
58 | 58 | <input type="checkbox" |
59 | 59 | id="<?php p($checkboxId); ?>" |
60 | 60 | <?php if (!empty($classes)): ?> class="checkbox <?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
61 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
61 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
62 | 62 | <?php if ($value === true): ?> checked="checked"<?php endif; ?> |
63 | - /> |
|
63 | + /> |
|
64 | 64 | <?php p($placeholder); ?> |
65 | 65 | </label> |
66 | 66 | </div> |
67 | 67 | <?php |
68 | - break; |
|
69 | - case DefinitionParameter::VALUE_HIDDEN: ?> |
|
70 | - <input type="hidden" |
|
68 | + break; |
|
69 | + case DefinitionParameter::VALUE_HIDDEN: ?> |
|
70 | + <input type="hidden" |
|
71 | 71 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
72 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
72 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
73 | 73 | value="<?php p($value); ?>" |
74 | 74 | /> |
75 | 75 | <?php |
76 | - break; |
|
77 | - default: ?> |
|
78 | - <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
|
79 | - <input type="text" |
|
76 | + break; |
|
77 | + default: ?> |
|
78 | + <?php if ($is_optional) { $classes[] = 'optional'; } ?> |
|
79 | + <input type="text" |
|
80 | 80 | <?php if (!empty($classes)): ?> class="<?php p(implode(' ', $classes)); ?>"<?php endif; ?> |
81 | - data-parameter="<?php p($parameter->getName()); ?>" |
|
81 | + data-parameter="<?php p($parameter->getName()); ?>" |
|
82 | 82 | value="<?php p($value); ?>" |
83 | 83 | placeholder="<?php p($placeholder); ?>" |
84 | 84 | /> |
@@ -87,9 +87,9 @@ |
||
87 | 87 | } |
88 | 88 | ?> |
89 | 89 | |
90 | -<form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>"> |
|
90 | +<form data-can-create="<?php echo $canCreateMounts ? 'true' : 'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled'] ? 'true' : 'false'; ?>"> |
|
91 | 91 | <h2><?php p($l->t('External storage')); ?></h2> |
92 | - <?php if (isset($_['dependencies']) and ($_['dependencies']<>'') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> |
|
92 | + <?php if (isset($_['dependencies']) and ($_['dependencies'] <> '') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> |
|
93 | 93 | <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'> |
94 | 94 | <thead> |
95 | 95 | <tr> |
@@ -89,7 +89,10 @@ discard block |
||
89 | 89 | |
90 | 90 | <form data-can-create="<?php echo $canCreateMounts?'true':'false' ?>" id="files_external" class="section" data-encryption-enabled="<?php echo $_['encryptionEnabled']?'true': 'false'; ?>"> |
91 | 91 | <h2><?php p($l->t('External storage')); ?></h2> |
92 | - <?php if (isset($_['dependencies']) and ($_['dependencies']<>'') and $canCreateMounts) print_unescaped(''.$_['dependencies'].''); ?> |
|
92 | + <?php if (isset($_['dependencies']) and ($_['dependencies']<>'') and $canCreateMounts) { |
|
93 | + print_unescaped(''.$_['dependencies'].''); |
|
94 | +} |
|
95 | +?> |
|
93 | 96 | <table id="externalStorage" class="grid" data-admin='<?php print_unescaped(json_encode($_['visibilityType'] === BackendService::VISIBILITY_ADMIN)); ?>'> |
94 | 97 | <thead> |
95 | 98 | <tr> |
@@ -98,7 +101,10 @@ discard block |
||
98 | 101 | <th><?php p($l->t('External storage')); ?></th> |
99 | 102 | <th><?php p($l->t('Authentication')); ?></th> |
100 | 103 | <th><?php p($l->t('Configuration')); ?></th> |
101 | - <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN) print_unescaped('<th>'.$l->t('Available for').'</th>'); ?> |
|
104 | + <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN) { |
|
105 | + print_unescaped('<th>'.$l->t('Available for').'</th>'); |
|
106 | +} |
|
107 | +?> |
|
102 | 108 | <th> </th> |
103 | 109 | <th> </th> |
104 | 110 | </tr> |
@@ -130,7 +136,10 @@ discard block |
||
130 | 136 | }); |
131 | 137 | ?> |
132 | 138 | <?php foreach ($sortedBackends as $backend): ?> |
133 | - <?php if ($backend->getDeprecateTo()) continue; // ignore deprecated backends ?> |
|
139 | + <?php if ($backend->getDeprecateTo()) { |
|
140 | + continue; |
|
141 | +} |
|
142 | +// ignore deprecated backends ?> |
|
134 | 143 | <option value="<?php p($backend->getIdentifier()); ?>"><?php p($backend->getText()); ?></option> |
135 | 144 | <?php endforeach; ?> |
136 | 145 | </select> |
@@ -163,7 +172,10 @@ discard block |
||
163 | 172 | |
164 | 173 | <?php if ($_['visibilityType'] === BackendService::VISIBILITY_ADMIN): ?> |
165 | 174 | <input type="checkbox" name="allowUserMounting" id="allowUserMounting" class="checkbox" |
166 | - value="1" <?php if ($_['allowUserMounting'] == 'yes') print_unescaped(' checked="checked"'); ?> /> |
|
175 | + value="1" <?php if ($_['allowUserMounting'] == 'yes') { |
|
176 | + print_unescaped(' checked="checked"'); |
|
177 | +} |
|
178 | +?> /> |
|
167 | 179 | <label for="allowUserMounting"><?php p($l->t('Allow users to mount external storage')); ?></label> <span id="userMountingMsg" class="msg"></span> |
168 | 180 | |
169 | 181 | <p id="userMountingBackends"<?php if ($_['allowUserMounting'] != 'yes'): ?> class="hidden"<?php endif; ?>> |
@@ -176,8 +188,14 @@ discard block |
||
176 | 188 | <?php $i = 0; foreach ($userBackends as $backend): ?> |
177 | 189 | <?php if ($deprecateTo = $backend->getDeprecateTo()): ?> |
178 | 190 | <input type="hidden" id="allowUserMountingBackends<?php p($i); ?>" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" data-deprecate-to="<?php p($deprecateTo->getIdentifier()); ?>" /> |
179 | - <?php else: ?> |
|
180 | - <input type="checkbox" id="allowUserMountingBackends<?php p($i); ?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) print_unescaped(' checked="checked"'); ?> /> |
|
191 | + <?php else { |
|
192 | + : ?> |
|
193 | + <input type="checkbox" id="allowUserMountingBackends<?php p($i); |
|
194 | +} |
|
195 | +?>" class="checkbox" name="allowUserMountingBackends[]" value="<?php p($backend->getIdentifier()); ?>" <?php if ($backend->isVisibleFor(BackendService::VISIBILITY_PERSONAL)) { |
|
196 | + print_unescaped(' checked="checked"'); |
|
197 | +} |
|
198 | +?> /> |
|
181 | 199 | <label for="allowUserMountingBackends<?php p($i); ?>"><?php p($backend->getText()); ?></label> <br /> |
182 | 200 | <?php endif; ?> |
183 | 201 | <?php $i++; ?> |