@@ -29,40 +29,40 @@ |
||
29 | 29 | |
30 | 30 | class FedAuth extends AbstractBasic { |
31 | 31 | |
32 | - /** @var DbHandler */ |
|
33 | - private $db; |
|
32 | + /** @var DbHandler */ |
|
33 | + private $db; |
|
34 | 34 | |
35 | - /** |
|
36 | - * FedAuth constructor. |
|
37 | - * |
|
38 | - * @param DbHandler $db |
|
39 | - */ |
|
40 | - public function __construct(DbHandler $db) { |
|
41 | - $this->db = $db; |
|
42 | - $this->principalPrefix = 'principals/system/'; |
|
35 | + /** |
|
36 | + * FedAuth constructor. |
|
37 | + * |
|
38 | + * @param DbHandler $db |
|
39 | + */ |
|
40 | + public function __construct(DbHandler $db) { |
|
41 | + $this->db = $db; |
|
42 | + $this->principalPrefix = 'principals/system/'; |
|
43 | 43 | |
44 | - // setup realm |
|
45 | - $defaults = new \OCP\Defaults(); |
|
46 | - $this->realm = $defaults->getName(); |
|
47 | - } |
|
44 | + // setup realm |
|
45 | + $defaults = new \OCP\Defaults(); |
|
46 | + $this->realm = $defaults->getName(); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Validates a username and password |
|
51 | - * |
|
52 | - * This method should return true or false depending on if login |
|
53 | - * succeeded. |
|
54 | - * |
|
55 | - * @param string $username |
|
56 | - * @param string $password |
|
57 | - * @return bool |
|
58 | - */ |
|
59 | - protected function validateUserPass($username, $password) { |
|
60 | - return $this->db->auth($username, $password); |
|
61 | - } |
|
49 | + /** |
|
50 | + * Validates a username and password |
|
51 | + * |
|
52 | + * This method should return true or false depending on if login |
|
53 | + * succeeded. |
|
54 | + * |
|
55 | + * @param string $username |
|
56 | + * @param string $password |
|
57 | + * @return bool |
|
58 | + */ |
|
59 | + protected function validateUserPass($username, $password) { |
|
60 | + return $this->db->auth($username, $password); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * @inheritdoc |
|
65 | - */ |
|
66 | - public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
67 | - } |
|
63 | + /** |
|
64 | + * @inheritdoc |
|
65 | + */ |
|
66 | + public function challenge(RequestInterface $request, ResponseInterface $response) { |
|
67 | + } |
|
68 | 68 | } |
@@ -29,32 +29,32 @@ |
||
29 | 29 | |
30 | 30 | class LastUsedController extends Controller { |
31 | 31 | |
32 | - /** @var IConfig */ |
|
33 | - protected $config; |
|
32 | + /** @var IConfig */ |
|
33 | + protected $config; |
|
34 | 34 | |
35 | - /** @var IUserSession */ |
|
36 | - protected $userSession; |
|
35 | + /** @var IUserSession */ |
|
36 | + protected $userSession; |
|
37 | 37 | |
38 | - /** |
|
39 | - * @param string $appName |
|
40 | - * @param IRequest $request |
|
41 | - * @param IConfig $config |
|
42 | - * @param IUserSession $userSession |
|
43 | - */ |
|
44 | - public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) { |
|
45 | - parent::__construct($appName, $request); |
|
46 | - $this->config = $config; |
|
47 | - $this->userSession = $userSession; |
|
48 | - } |
|
38 | + /** |
|
39 | + * @param string $appName |
|
40 | + * @param IRequest $request |
|
41 | + * @param IConfig $config |
|
42 | + * @param IUserSession $userSession |
|
43 | + */ |
|
44 | + public function __construct($appName, IRequest $request, IConfig $config, IUserSession $userSession) { |
|
45 | + parent::__construct($appName, $request); |
|
46 | + $this->config = $config; |
|
47 | + $this->userSession = $userSession; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @NoAdminRequired |
|
52 | - */ |
|
53 | - public function getLastUsedTagIds() { |
|
54 | - $lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]'); |
|
55 | - $tagIds = json_decode($lastUsed, true); |
|
56 | - return new DataResponse(array_map(function ($id) { |
|
57 | - return (string) $id; |
|
58 | - }, $tagIds)); |
|
59 | - } |
|
50 | + /** |
|
51 | + * @NoAdminRequired |
|
52 | + */ |
|
53 | + public function getLastUsedTagIds() { |
|
54 | + $lastUsed = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'systemtags', 'last_used', '[]'); |
|
55 | + $tagIds = json_decode($lastUsed, true); |
|
56 | + return new DataResponse(array_map(function ($id) { |
|
57 | + return (string) $id; |
|
58 | + }, $tagIds)); |
|
59 | + } |
|
60 | 60 | } |
@@ -31,30 +31,30 @@ |
||
31 | 31 | use OCP\Command\ICommand; |
32 | 32 | |
33 | 33 | class Expire implements ICommand { |
34 | - use FileAccess; |
|
34 | + use FileAccess; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - private $user; |
|
36 | + /** |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + private $user; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string $user |
|
43 | - */ |
|
44 | - public function __construct($user) { |
|
45 | - $this->user = $user; |
|
46 | - } |
|
41 | + /** |
|
42 | + * @param string $user |
|
43 | + */ |
|
44 | + public function __construct($user) { |
|
45 | + $this->user = $user; |
|
46 | + } |
|
47 | 47 | |
48 | - public function handle() { |
|
49 | - $userManager = \OC::$server->getUserManager(); |
|
50 | - if (!$userManager->userExists($this->user)) { |
|
51 | - // User has been deleted already |
|
52 | - return; |
|
53 | - } |
|
48 | + public function handle() { |
|
49 | + $userManager = \OC::$server->getUserManager(); |
|
50 | + if (!$userManager->userExists($this->user)) { |
|
51 | + // User has been deleted already |
|
52 | + return; |
|
53 | + } |
|
54 | 54 | |
55 | - \OC_Util::tearDownFS(); |
|
56 | - \OC_Util::setupFS($this->user); |
|
57 | - Trashbin::expire($this->user); |
|
58 | - \OC_Util::tearDownFS(); |
|
59 | - } |
|
55 | + \OC_Util::tearDownFS(); |
|
56 | + \OC_Util::setupFS($this->user); |
|
57 | + Trashbin::expire($this->user); |
|
58 | + \OC_Util::tearDownFS(); |
|
59 | + } |
|
60 | 60 | } |
@@ -27,91 +27,91 @@ |
||
27 | 27 | use OCP\Notification\IManager; |
28 | 28 | |
29 | 29 | class Listener { |
30 | - /** @var IManager */ |
|
31 | - protected $notificationManager; |
|
30 | + /** @var IManager */ |
|
31 | + protected $notificationManager; |
|
32 | 32 | |
33 | - /** @var IUserManager */ |
|
34 | - protected $userManager; |
|
33 | + /** @var IUserManager */ |
|
34 | + protected $userManager; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Listener constructor. |
|
38 | - * |
|
39 | - * @param IManager $notificationManager |
|
40 | - * @param IUserManager $userManager |
|
41 | - */ |
|
42 | - public function __construct( |
|
43 | - IManager $notificationManager, |
|
44 | - IUserManager $userManager |
|
45 | - ) { |
|
46 | - $this->notificationManager = $notificationManager; |
|
47 | - $this->userManager = $userManager; |
|
48 | - } |
|
36 | + /** |
|
37 | + * Listener constructor. |
|
38 | + * |
|
39 | + * @param IManager $notificationManager |
|
40 | + * @param IUserManager $userManager |
|
41 | + */ |
|
42 | + public function __construct( |
|
43 | + IManager $notificationManager, |
|
44 | + IUserManager $userManager |
|
45 | + ) { |
|
46 | + $this->notificationManager = $notificationManager; |
|
47 | + $this->userManager = $userManager; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param CommentsEvent $event |
|
52 | - */ |
|
53 | - public function evaluate(CommentsEvent $event) { |
|
54 | - $comment = $event->getComment(); |
|
50 | + /** |
|
51 | + * @param CommentsEvent $event |
|
52 | + */ |
|
53 | + public function evaluate(CommentsEvent $event) { |
|
54 | + $comment = $event->getComment(); |
|
55 | 55 | |
56 | - $mentions = $this->extractMentions($comment->getMentions()); |
|
57 | - if (empty($mentions)) { |
|
58 | - // no one to notify |
|
59 | - return; |
|
60 | - } |
|
56 | + $mentions = $this->extractMentions($comment->getMentions()); |
|
57 | + if (empty($mentions)) { |
|
58 | + // no one to notify |
|
59 | + return; |
|
60 | + } |
|
61 | 61 | |
62 | - $notification = $this->instantiateNotification($comment); |
|
62 | + $notification = $this->instantiateNotification($comment); |
|
63 | 63 | |
64 | - foreach ($mentions as $uid) { |
|
65 | - if (($comment->getActorType() === 'users' && $uid === $comment->getActorId()) |
|
66 | - || !$this->userManager->userExists($uid) |
|
67 | - ) { |
|
68 | - // do not notify unknown users or yourself |
|
69 | - continue; |
|
70 | - } |
|
64 | + foreach ($mentions as $uid) { |
|
65 | + if (($comment->getActorType() === 'users' && $uid === $comment->getActorId()) |
|
66 | + || !$this->userManager->userExists($uid) |
|
67 | + ) { |
|
68 | + // do not notify unknown users or yourself |
|
69 | + continue; |
|
70 | + } |
|
71 | 71 | |
72 | - $notification->setUser($uid); |
|
73 | - if ($event->getEvent() === CommentsEvent::EVENT_DELETE |
|
74 | - || $event->getEvent() === CommentsEvent::EVENT_PRE_UPDATE) { |
|
75 | - $this->notificationManager->markProcessed($notification); |
|
76 | - } else { |
|
77 | - $this->notificationManager->notify($notification); |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
72 | + $notification->setUser($uid); |
|
73 | + if ($event->getEvent() === CommentsEvent::EVENT_DELETE |
|
74 | + || $event->getEvent() === CommentsEvent::EVENT_PRE_UPDATE) { |
|
75 | + $this->notificationManager->markProcessed($notification); |
|
76 | + } else { |
|
77 | + $this->notificationManager->notify($notification); |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * creates a notification instance and fills it with comment data |
|
84 | - * |
|
85 | - * @param IComment $comment |
|
86 | - * @return \OCP\Notification\INotification |
|
87 | - */ |
|
88 | - public function instantiateNotification(IComment $comment) { |
|
89 | - $notification = $this->notificationManager->createNotification(); |
|
90 | - $notification |
|
91 | - ->setApp('comments') |
|
92 | - ->setObject('comment', $comment->getId()) |
|
93 | - ->setSubject('mention', [ $comment->getObjectType(), $comment->getObjectId() ]) |
|
94 | - ->setDateTime($comment->getCreationDateTime()); |
|
82 | + /** |
|
83 | + * creates a notification instance and fills it with comment data |
|
84 | + * |
|
85 | + * @param IComment $comment |
|
86 | + * @return \OCP\Notification\INotification |
|
87 | + */ |
|
88 | + public function instantiateNotification(IComment $comment) { |
|
89 | + $notification = $this->notificationManager->createNotification(); |
|
90 | + $notification |
|
91 | + ->setApp('comments') |
|
92 | + ->setObject('comment', $comment->getId()) |
|
93 | + ->setSubject('mention', [ $comment->getObjectType(), $comment->getObjectId() ]) |
|
94 | + ->setDateTime($comment->getCreationDateTime()); |
|
95 | 95 | |
96 | - return $notification; |
|
97 | - } |
|
96 | + return $notification; |
|
97 | + } |
|
98 | 98 | |
99 | - /** |
|
100 | - * flattens the mention array returned from comments to a list of user ids. |
|
101 | - * |
|
102 | - * @param array $mentions |
|
103 | - * @return string[] containing the mentions, e.g. ['alice', 'bob'] |
|
104 | - */ |
|
105 | - public function extractMentions(array $mentions) { |
|
106 | - if (empty($mentions)) { |
|
107 | - return []; |
|
108 | - } |
|
109 | - $uids = []; |
|
110 | - foreach ($mentions as $mention) { |
|
111 | - if ($mention['type'] === 'user') { |
|
112 | - $uids[] = $mention['id']; |
|
113 | - } |
|
114 | - } |
|
115 | - return $uids; |
|
116 | - } |
|
99 | + /** |
|
100 | + * flattens the mention array returned from comments to a list of user ids. |
|
101 | + * |
|
102 | + * @param array $mentions |
|
103 | + * @return string[] containing the mentions, e.g. ['alice', 'bob'] |
|
104 | + */ |
|
105 | + public function extractMentions(array $mentions) { |
|
106 | + if (empty($mentions)) { |
|
107 | + return []; |
|
108 | + } |
|
109 | + $uids = []; |
|
110 | + foreach ($mentions as $mention) { |
|
111 | + if ($mention['type'] === 'user') { |
|
112 | + $uids[] = $mention['id']; |
|
113 | + } |
|
114 | + } |
|
115 | + return $uids; |
|
116 | + } |
|
117 | 117 | } |
@@ -33,39 +33,39 @@ |
||
33 | 33 | use Symfony\Component\Console\Output\OutputInterface; |
34 | 34 | |
35 | 35 | class CreateEmptyConfig extends Command { |
36 | - /** @var \OCA\User_LDAP\Helper */ |
|
37 | - protected $helper; |
|
36 | + /** @var \OCA\User_LDAP\Helper */ |
|
37 | + protected $helper; |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param Helper $helper |
|
41 | - */ |
|
42 | - public function __construct(Helper $helper) { |
|
43 | - $this->helper = $helper; |
|
44 | - parent::__construct(); |
|
45 | - } |
|
39 | + /** |
|
40 | + * @param Helper $helper |
|
41 | + */ |
|
42 | + public function __construct(Helper $helper) { |
|
43 | + $this->helper = $helper; |
|
44 | + parent::__construct(); |
|
45 | + } |
|
46 | 46 | |
47 | - protected function configure() { |
|
48 | - $this |
|
49 | - ->setName('ldap:create-empty-config') |
|
50 | - ->setDescription('creates an empty LDAP configuration') |
|
51 | - ->addOption( |
|
52 | - 'only-print-prefix', |
|
53 | - 'p', |
|
54 | - InputOption::VALUE_NONE, |
|
55 | - 'outputs only the prefix' |
|
56 | - ) |
|
57 | - ; |
|
58 | - } |
|
47 | + protected function configure() { |
|
48 | + $this |
|
49 | + ->setName('ldap:create-empty-config') |
|
50 | + ->setDescription('creates an empty LDAP configuration') |
|
51 | + ->addOption( |
|
52 | + 'only-print-prefix', |
|
53 | + 'p', |
|
54 | + InputOption::VALUE_NONE, |
|
55 | + 'outputs only the prefix' |
|
56 | + ) |
|
57 | + ; |
|
58 | + } |
|
59 | 59 | |
60 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | - $configPrefix = $this->helper->getNextServerConfigurationPrefix(); |
|
62 | - $configHolder = new Configuration($configPrefix); |
|
63 | - $configHolder->saveConfiguration(); |
|
60 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
61 | + $configPrefix = $this->helper->getNextServerConfigurationPrefix(); |
|
62 | + $configHolder = new Configuration($configPrefix); |
|
63 | + $configHolder->saveConfiguration(); |
|
64 | 64 | |
65 | - $prose = ''; |
|
66 | - if (!$input->getOption('only-print-prefix')) { |
|
67 | - $prose = 'Created new configuration with configID '; |
|
68 | - } |
|
69 | - $output->writeln($prose . "{$configPrefix}"); |
|
70 | - } |
|
65 | + $prose = ''; |
|
66 | + if (!$input->getOption('only-print-prefix')) { |
|
67 | + $prose = 'Created new configuration with configID '; |
|
68 | + } |
|
69 | + $output->writeln($prose . "{$configPrefix}"); |
|
70 | + } |
|
71 | 71 | } |
@@ -32,39 +32,39 @@ |
||
32 | 32 | use Symfony\Component\Console\Output\OutputInterface; |
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 | } |
@@ -29,31 +29,31 @@ |
||
29 | 29 | use OCA\User_LDAP\User_Proxy; |
30 | 30 | |
31 | 31 | abstract class UUIDFix extends QueuedJob { |
32 | - /** @var AbstractMapping */ |
|
33 | - protected $mapper; |
|
32 | + /** @var AbstractMapping */ |
|
33 | + protected $mapper; |
|
34 | 34 | |
35 | - /** @var Proxy */ |
|
36 | - protected $proxy; |
|
35 | + /** @var Proxy */ |
|
36 | + protected $proxy; |
|
37 | 37 | |
38 | - public function run($argument) { |
|
39 | - $isUser = $this->proxy instanceof User_Proxy; |
|
40 | - foreach ($argument['records'] as $record) { |
|
41 | - $access = $this->proxy->getLDAPAccess($record['name']); |
|
42 | - $uuid = $access->getUUID($record['dn'], $isUser); |
|
43 | - if ($uuid === false) { |
|
44 | - // record not found, no prob, continue with the next |
|
45 | - continue; |
|
46 | - } |
|
47 | - if ($uuid !== $record['uuid']) { |
|
48 | - $this->mapper->setUUIDbyDN($uuid, $record['dn']); |
|
49 | - } |
|
50 | - } |
|
51 | - } |
|
38 | + public function run($argument) { |
|
39 | + $isUser = $this->proxy instanceof User_Proxy; |
|
40 | + foreach ($argument['records'] as $record) { |
|
41 | + $access = $this->proxy->getLDAPAccess($record['name']); |
|
42 | + $uuid = $access->getUUID($record['dn'], $isUser); |
|
43 | + if ($uuid === false) { |
|
44 | + // record not found, no prob, continue with the next |
|
45 | + continue; |
|
46 | + } |
|
47 | + if ($uuid !== $record['uuid']) { |
|
48 | + $this->mapper->setUUIDbyDN($uuid, $record['dn']); |
|
49 | + } |
|
50 | + } |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param Proxy $proxy |
|
55 | - */ |
|
56 | - public function overrideProxy(Proxy $proxy) { |
|
57 | - $this->proxy = $proxy; |
|
58 | - } |
|
53 | + /** |
|
54 | + * @param Proxy $proxy |
|
55 | + */ |
|
56 | + public function overrideProxy(Proxy $proxy) { |
|
57 | + $this->proxy = $proxy; |
|
58 | + } |
|
59 | 59 | } |
@@ -29,11 +29,11 @@ |
||
29 | 29 | */ |
30 | 30 | class GroupMapping extends AbstractMapping { |
31 | 31 | |
32 | - /** |
|
33 | - * returns the DB table name which holds the mappings |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - protected function getTableName() { |
|
37 | - return '*PREFIX*ldap_group_mapping'; |
|
38 | - } |
|
32 | + /** |
|
33 | + * returns the DB table name which holds the mappings |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + protected function getTableName() { |
|
37 | + return '*PREFIX*ldap_group_mapping'; |
|
38 | + } |
|
39 | 39 | } |
@@ -29,11 +29,11 @@ |
||
29 | 29 | */ |
30 | 30 | class UserMapping extends AbstractMapping { |
31 | 31 | |
32 | - /** |
|
33 | - * returns the DB table name which holds the mappings |
|
34 | - * @return string |
|
35 | - */ |
|
36 | - protected function getTableName() { |
|
37 | - return '*PREFIX*ldap_user_mapping'; |
|
38 | - } |
|
32 | + /** |
|
33 | + * returns the DB table name which holds the mappings |
|
34 | + * @return string |
|
35 | + */ |
|
36 | + protected function getTableName() { |
|
37 | + return '*PREFIX*ldap_user_mapping'; |
|
38 | + } |
|
39 | 39 | } |