@@ -27,40 +27,40 @@ |
||
27 | 27 | |
28 | 28 | class Admin implements ISettings { |
29 | 29 | |
30 | - /** @var SettingsManager */ |
|
31 | - private $settingsManager; |
|
30 | + /** @var SettingsManager */ |
|
31 | + private $settingsManager; |
|
32 | 32 | |
33 | - public function __construct(SettingsManager $settingsManager) { |
|
34 | - $this->settingsManager = $settingsManager; |
|
35 | - } |
|
33 | + public function __construct(SettingsManager $settingsManager) { |
|
34 | + $this->settingsManager = $settingsManager; |
|
35 | + } |
|
36 | 36 | |
37 | - /** |
|
38 | - * @return TemplateResponse |
|
39 | - */ |
|
40 | - public function getForm() { |
|
41 | - $parameters = [ |
|
42 | - 'sendPasswordMail' => $this->settingsManager->sendPasswordByMail(), |
|
43 | - 'enforcePasswordProtection' => $this->settingsManager->enforcePasswordProtection() |
|
44 | - ]; |
|
37 | + /** |
|
38 | + * @return TemplateResponse |
|
39 | + */ |
|
40 | + public function getForm() { |
|
41 | + $parameters = [ |
|
42 | + 'sendPasswordMail' => $this->settingsManager->sendPasswordByMail(), |
|
43 | + 'enforcePasswordProtection' => $this->settingsManager->enforcePasswordProtection() |
|
44 | + ]; |
|
45 | 45 | |
46 | - return new TemplateResponse('sharebymail', 'settings-admin', $parameters, ''); |
|
47 | - } |
|
46 | + return new TemplateResponse('sharebymail', 'settings-admin', $parameters, ''); |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * @return string the section ID, e.g. 'sharing' |
|
51 | - */ |
|
52 | - public function getSection() { |
|
53 | - return 'sharing'; |
|
54 | - } |
|
49 | + /** |
|
50 | + * @return string the section ID, e.g. 'sharing' |
|
51 | + */ |
|
52 | + public function getSection() { |
|
53 | + return 'sharing'; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @return int whether the form should be rather on the top or bottom of |
|
58 | - * the admin section. The forms are arranged in ascending order of the |
|
59 | - * priority values. It is required to return a value between 0 and 100. |
|
60 | - * |
|
61 | - * E.g.: 70 |
|
62 | - */ |
|
63 | - public function getPriority() { |
|
64 | - return 40; |
|
65 | - } |
|
56 | + /** |
|
57 | + * @return int whether the form should be rather on the top or bottom of |
|
58 | + * the admin section. The forms are arranged in ascending order of the |
|
59 | + * priority values. It is required to return a value between 0 and 100. |
|
60 | + * |
|
61 | + * E.g.: 70 |
|
62 | + */ |
|
63 | + public function getPriority() { |
|
64 | + return 40; |
|
65 | + } |
|
66 | 66 | } |
@@ -12,11 +12,11 @@ |
||
12 | 12 | |
13 | 13 | <p> |
14 | 14 | <input id="sendPasswordMail" type="checkbox" class="checkbox" <?php if ($_['sendPasswordMail']) { |
15 | - p('checked'); |
|
15 | + p('checked'); |
|
16 | 16 | } ?> /> |
17 | 17 | <label for="sendPasswordMail"><?php p($l->t('Send password by mail')); ?></label><br/> |
18 | 18 | <input id="enforcePasswordProtection" type="checkbox" class="checkbox" <?php if ($_['enforcePasswordProtection']) { |
19 | - p('checked'); |
|
19 | + p('checked'); |
|
20 | 20 | } ?> /> |
21 | 21 | <label for="enforcePasswordProtection"><?php p($l->t('Enforce password protection')); ?></label> |
22 | 22 | </p> |
@@ -5,7 +5,7 @@ |
||
5 | 5 | use OCP\AppFramework\Http; |
6 | 6 | |
7 | 7 | class NotSubAdminException extends \Exception { |
8 | - public function __construct() { |
|
9 | - parent::__construct('Logged in user must be at least a sub admin', Http::STATUS_FORBIDDEN); |
|
10 | - } |
|
8 | + public function __construct() { |
|
9 | + parent::__construct('Logged in user must be at least a sub admin', Http::STATUS_FORBIDDEN); |
|
10 | + } |
|
11 | 11 | } |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | $container = $this->getContainer(); |
18 | 18 | $server = $container->getServer(); |
19 | 19 | |
20 | - $container->registerService(NewUserMailHelper::class, function (SimpleContainer $c) use ($server) { |
|
20 | + $container->registerService(NewUserMailHelper::class, function(SimpleContainer $c) use ($server) { |
|
21 | 21 | return new NewUserMailHelper( |
22 | 22 | $server->query(Defaults::class), |
23 | 23 | $server->getURLGenerator(), |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | Util::getDefaultEmailAddress('no-reply') |
31 | 31 | ); |
32 | 32 | }); |
33 | - $container->registerService('ProvisioningApiMiddleware', function (SimpleContainer $c) use ($server) { |
|
33 | + $container->registerService('ProvisioningApiMiddleware', function(SimpleContainer $c) use ($server) { |
|
34 | 34 | $user = $server->getUserManager()->get($c['UserId']); |
35 | 35 | $isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false; |
36 | 36 | $isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false; |
@@ -37,35 +37,35 @@ |
||
37 | 37 | use OCP\Util; |
38 | 38 | |
39 | 39 | class Application extends App { |
40 | - public function __construct(array $urlParams = []) { |
|
41 | - parent::__construct('provisioning_api', $urlParams); |
|
40 | + public function __construct(array $urlParams = []) { |
|
41 | + parent::__construct('provisioning_api', $urlParams); |
|
42 | 42 | |
43 | - $container = $this->getContainer(); |
|
44 | - $server = $container->getServer(); |
|
43 | + $container = $this->getContainer(); |
|
44 | + $server = $container->getServer(); |
|
45 | 45 | |
46 | - $container->registerService(NewUserMailHelper::class, function (SimpleContainer $c) use ($server) { |
|
47 | - return new NewUserMailHelper( |
|
48 | - $server->query(Defaults::class), |
|
49 | - $server->getURLGenerator(), |
|
50 | - $server->getL10NFactory(), |
|
51 | - $server->getMailer(), |
|
52 | - $server->getSecureRandom(), |
|
53 | - new TimeFactory(), |
|
54 | - $server->getConfig(), |
|
55 | - $server->getCrypto(), |
|
56 | - Util::getDefaultEmailAddress('no-reply') |
|
57 | - ); |
|
58 | - }); |
|
59 | - $container->registerService('ProvisioningApiMiddleware', function (SimpleContainer $c) use ($server) { |
|
60 | - $user = $server->getUserManager()->get($c['UserId']); |
|
61 | - $isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false; |
|
62 | - $isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false; |
|
63 | - return new ProvisioningApiMiddleware( |
|
64 | - $c->query(IControllerMethodReflector::class), |
|
65 | - $isAdmin, |
|
66 | - $isSubAdmin |
|
67 | - ); |
|
68 | - }); |
|
69 | - $container->registerMiddleWare('ProvisioningApiMiddleware'); |
|
70 | - } |
|
46 | + $container->registerService(NewUserMailHelper::class, function (SimpleContainer $c) use ($server) { |
|
47 | + return new NewUserMailHelper( |
|
48 | + $server->query(Defaults::class), |
|
49 | + $server->getURLGenerator(), |
|
50 | + $server->getL10NFactory(), |
|
51 | + $server->getMailer(), |
|
52 | + $server->getSecureRandom(), |
|
53 | + new TimeFactory(), |
|
54 | + $server->getConfig(), |
|
55 | + $server->getCrypto(), |
|
56 | + Util::getDefaultEmailAddress('no-reply') |
|
57 | + ); |
|
58 | + }); |
|
59 | + $container->registerService('ProvisioningApiMiddleware', function (SimpleContainer $c) use ($server) { |
|
60 | + $user = $server->getUserManager()->get($c['UserId']); |
|
61 | + $isAdmin = $user !== null ? $server->getGroupManager()->isAdmin($user->getUID()) : false; |
|
62 | + $isSubAdmin = $user !== null ? $server->getGroupManager()->getSubAdmin()->isSubAdmin($user) : false; |
|
63 | + return new ProvisioningApiMiddleware( |
|
64 | + $c->query(IControllerMethodReflector::class), |
|
65 | + $isAdmin, |
|
66 | + $isSubAdmin |
|
67 | + ); |
|
68 | + }); |
|
69 | + $container->registerMiddleWare('ProvisioningApiMiddleware'); |
|
70 | + } |
|
71 | 71 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } else { |
90 | 90 | $p = new ProgressBar($output); |
91 | 91 | $p->start(); |
92 | - $this->userManager->callForSeenUsers(function (IUser $user) use ($p) { |
|
92 | + $this->userManager->callForSeenUsers(function(IUser $user) use ($p) { |
|
93 | 93 | $p->advance(); |
94 | 94 | $this->expireVersionsForUser($user); |
95 | 95 | }); |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | \OC_Util::setupFS($user); |
117 | 117 | |
118 | 118 | // Check if this user has a version directory |
119 | - $view = new \OC\Files\View('/' . $user); |
|
119 | + $view = new \OC\Files\View('/'.$user); |
|
120 | 120 | if (!$view->is_dir('/files_versions')) { |
121 | 121 | return false; |
122 | 122 | } |
@@ -36,92 +36,92 @@ |
||
36 | 36 | |
37 | 37 | class ExpireVersions extends Command { |
38 | 38 | |
39 | - /** |
|
40 | - * @var Expiration |
|
41 | - */ |
|
42 | - private $expiration; |
|
39 | + /** |
|
40 | + * @var Expiration |
|
41 | + */ |
|
42 | + private $expiration; |
|
43 | 43 | |
44 | - /** |
|
45 | - * @var IUserManager |
|
46 | - */ |
|
47 | - private $userManager; |
|
44 | + /** |
|
45 | + * @var IUserManager |
|
46 | + */ |
|
47 | + private $userManager; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param IUserManager $userManager |
|
51 | - * @param Expiration $expiration |
|
52 | - */ |
|
53 | - public function __construct(IUserManager $userManager, |
|
54 | - Expiration $expiration) { |
|
55 | - parent::__construct(); |
|
49 | + /** |
|
50 | + * @param IUserManager $userManager |
|
51 | + * @param Expiration $expiration |
|
52 | + */ |
|
53 | + public function __construct(IUserManager $userManager, |
|
54 | + Expiration $expiration) { |
|
55 | + parent::__construct(); |
|
56 | 56 | |
57 | - $this->userManager = $userManager; |
|
58 | - $this->expiration = $expiration; |
|
59 | - } |
|
57 | + $this->userManager = $userManager; |
|
58 | + $this->expiration = $expiration; |
|
59 | + } |
|
60 | 60 | |
61 | - protected function configure() { |
|
62 | - $this |
|
63 | - ->setName('versions:expire') |
|
64 | - ->setDescription('Expires the users file versions') |
|
65 | - ->addArgument( |
|
66 | - 'user_id', |
|
67 | - InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
68 | - 'expire file versions of the given user(s), if no user is given file versions for all users will be expired.' |
|
69 | - ); |
|
70 | - } |
|
61 | + protected function configure() { |
|
62 | + $this |
|
63 | + ->setName('versions:expire') |
|
64 | + ->setDescription('Expires the users file versions') |
|
65 | + ->addArgument( |
|
66 | + 'user_id', |
|
67 | + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
68 | + 'expire file versions of the given user(s), if no user is given file versions for all users will be expired.' |
|
69 | + ); |
|
70 | + } |
|
71 | 71 | |
72 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
73 | - $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
74 | - if (!$maxAge) { |
|
75 | - $output->writeln("No expiry configured."); |
|
76 | - return; |
|
77 | - } |
|
72 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
73 | + $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
74 | + if (!$maxAge) { |
|
75 | + $output->writeln("No expiry configured."); |
|
76 | + return; |
|
77 | + } |
|
78 | 78 | |
79 | - $users = $input->getArgument('user_id'); |
|
80 | - if (!empty($users)) { |
|
81 | - foreach ($users as $user) { |
|
82 | - if ($this->userManager->userExists($user)) { |
|
83 | - $output->writeln("Remove deleted files of <info>$user</info>"); |
|
84 | - $userObject = $this->userManager->get($user); |
|
85 | - $this->expireVersionsForUser($userObject); |
|
86 | - } else { |
|
87 | - $output->writeln("<error>Unknown user $user</error>"); |
|
88 | - } |
|
89 | - } |
|
90 | - } else { |
|
91 | - $p = new ProgressBar($output); |
|
92 | - $p->start(); |
|
93 | - $this->userManager->callForSeenUsers(function (IUser $user) use ($p) { |
|
94 | - $p->advance(); |
|
95 | - $this->expireVersionsForUser($user); |
|
96 | - }); |
|
97 | - $p->finish(); |
|
98 | - $output->writeln(''); |
|
99 | - } |
|
100 | - } |
|
79 | + $users = $input->getArgument('user_id'); |
|
80 | + if (!empty($users)) { |
|
81 | + foreach ($users as $user) { |
|
82 | + if ($this->userManager->userExists($user)) { |
|
83 | + $output->writeln("Remove deleted files of <info>$user</info>"); |
|
84 | + $userObject = $this->userManager->get($user); |
|
85 | + $this->expireVersionsForUser($userObject); |
|
86 | + } else { |
|
87 | + $output->writeln("<error>Unknown user $user</error>"); |
|
88 | + } |
|
89 | + } |
|
90 | + } else { |
|
91 | + $p = new ProgressBar($output); |
|
92 | + $p->start(); |
|
93 | + $this->userManager->callForSeenUsers(function (IUser $user) use ($p) { |
|
94 | + $p->advance(); |
|
95 | + $this->expireVersionsForUser($user); |
|
96 | + }); |
|
97 | + $p->finish(); |
|
98 | + $output->writeln(''); |
|
99 | + } |
|
100 | + } |
|
101 | 101 | |
102 | - public function expireVersionsForUser(IUser $user) { |
|
103 | - $uid = $user->getUID(); |
|
104 | - if (!$this->setupFS($uid)) { |
|
105 | - return; |
|
106 | - } |
|
107 | - Storage::expireOlderThanMaxForUser($uid); |
|
108 | - } |
|
102 | + public function expireVersionsForUser(IUser $user) { |
|
103 | + $uid = $user->getUID(); |
|
104 | + if (!$this->setupFS($uid)) { |
|
105 | + return; |
|
106 | + } |
|
107 | + Storage::expireOlderThanMaxForUser($uid); |
|
108 | + } |
|
109 | 109 | |
110 | - /** |
|
111 | - * Act on behalf on versions item owner |
|
112 | - * @param string $user |
|
113 | - * @return boolean |
|
114 | - */ |
|
115 | - protected function setupFS($user) { |
|
116 | - \OC_Util::tearDownFS(); |
|
117 | - \OC_Util::setupFS($user); |
|
110 | + /** |
|
111 | + * Act on behalf on versions item owner |
|
112 | + * @param string $user |
|
113 | + * @return boolean |
|
114 | + */ |
|
115 | + protected function setupFS($user) { |
|
116 | + \OC_Util::tearDownFS(); |
|
117 | + \OC_Util::setupFS($user); |
|
118 | 118 | |
119 | - // Check if this user has a version directory |
|
120 | - $view = new \OC\Files\View('/' . $user); |
|
121 | - if (!$view->is_dir('/files_versions')) { |
|
122 | - return false; |
|
123 | - } |
|
119 | + // Check if this user has a version directory |
|
120 | + $view = new \OC\Files\View('/' . $user); |
|
121 | + if (!$view->is_dir('/files_versions')) { |
|
122 | + return false; |
|
123 | + } |
|
124 | 124 | |
125 | - return true; |
|
126 | - } |
|
125 | + return true; |
|
126 | + } |
|
127 | 127 | } |
@@ -32,81 +32,81 @@ |
||
32 | 32 | |
33 | 33 | class CleanUp extends Command { |
34 | 34 | |
35 | - /** @var IUserManager */ |
|
36 | - protected $userManager; |
|
35 | + /** @var IUserManager */ |
|
36 | + protected $userManager; |
|
37 | 37 | |
38 | - /** @var IRootFolder */ |
|
39 | - protected $rootFolder; |
|
38 | + /** @var IRootFolder */ |
|
39 | + protected $rootFolder; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param IRootFolder $rootFolder |
|
43 | - * @param IUserManager $userManager |
|
44 | - */ |
|
45 | - public function __construct(IRootFolder $rootFolder, IUserManager $userManager) { |
|
46 | - parent::__construct(); |
|
47 | - $this->userManager = $userManager; |
|
48 | - $this->rootFolder = $rootFolder; |
|
49 | - } |
|
41 | + /** |
|
42 | + * @param IRootFolder $rootFolder |
|
43 | + * @param IUserManager $userManager |
|
44 | + */ |
|
45 | + public function __construct(IRootFolder $rootFolder, IUserManager $userManager) { |
|
46 | + parent::__construct(); |
|
47 | + $this->userManager = $userManager; |
|
48 | + $this->rootFolder = $rootFolder; |
|
49 | + } |
|
50 | 50 | |
51 | - protected function configure() { |
|
52 | - $this |
|
53 | - ->setName('versions:cleanup') |
|
54 | - ->setDescription('Delete versions') |
|
55 | - ->addArgument( |
|
56 | - 'user_id', |
|
57 | - InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
58 | - 'delete versions of the given user(s), if no user is given all versions will be deleted' |
|
59 | - ); |
|
60 | - } |
|
51 | + protected function configure() { |
|
52 | + $this |
|
53 | + ->setName('versions:cleanup') |
|
54 | + ->setDescription('Delete versions') |
|
55 | + ->addArgument( |
|
56 | + 'user_id', |
|
57 | + InputArgument::OPTIONAL | InputArgument::IS_ARRAY, |
|
58 | + 'delete versions of the given user(s), if no user is given all versions will be deleted' |
|
59 | + ); |
|
60 | + } |
|
61 | 61 | |
62 | 62 | |
63 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
64 | - $users = $input->getArgument('user_id'); |
|
65 | - if (!empty($users)) { |
|
66 | - foreach ($users as $user) { |
|
67 | - if ($this->userManager->userExists($user)) { |
|
68 | - $output->writeln("Delete versions of <info>$user</info>"); |
|
69 | - $this->deleteVersions($user); |
|
70 | - } else { |
|
71 | - $output->writeln("<error>Unknown user $user</error>"); |
|
72 | - } |
|
73 | - } |
|
74 | - } else { |
|
75 | - $output->writeln('Delete all versions'); |
|
76 | - foreach ($this->userManager->getBackends() as $backend) { |
|
77 | - $name = get_class($backend); |
|
63 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
64 | + $users = $input->getArgument('user_id'); |
|
65 | + if (!empty($users)) { |
|
66 | + foreach ($users as $user) { |
|
67 | + if ($this->userManager->userExists($user)) { |
|
68 | + $output->writeln("Delete versions of <info>$user</info>"); |
|
69 | + $this->deleteVersions($user); |
|
70 | + } else { |
|
71 | + $output->writeln("<error>Unknown user $user</error>"); |
|
72 | + } |
|
73 | + } |
|
74 | + } else { |
|
75 | + $output->writeln('Delete all versions'); |
|
76 | + foreach ($this->userManager->getBackends() as $backend) { |
|
77 | + $name = get_class($backend); |
|
78 | 78 | |
79 | - if ($backend instanceof IUserBackend) { |
|
80 | - $name = $backend->getBackendName(); |
|
81 | - } |
|
79 | + if ($backend instanceof IUserBackend) { |
|
80 | + $name = $backend->getBackendName(); |
|
81 | + } |
|
82 | 82 | |
83 | - $output->writeln("Delete versions for users on backend <info>$name</info>"); |
|
83 | + $output->writeln("Delete versions for users on backend <info>$name</info>"); |
|
84 | 84 | |
85 | - $limit = 500; |
|
86 | - $offset = 0; |
|
87 | - do { |
|
88 | - $users = $backend->getUsers('', $limit, $offset); |
|
89 | - foreach ($users as $user) { |
|
90 | - $output->writeln(" <info>$user</info>"); |
|
91 | - $this->deleteVersions($user); |
|
92 | - } |
|
93 | - $offset += $limit; |
|
94 | - } while (count($users) >= $limit); |
|
95 | - } |
|
96 | - } |
|
97 | - } |
|
85 | + $limit = 500; |
|
86 | + $offset = 0; |
|
87 | + do { |
|
88 | + $users = $backend->getUsers('', $limit, $offset); |
|
89 | + foreach ($users as $user) { |
|
90 | + $output->writeln(" <info>$user</info>"); |
|
91 | + $this->deleteVersions($user); |
|
92 | + } |
|
93 | + $offset += $limit; |
|
94 | + } while (count($users) >= $limit); |
|
95 | + } |
|
96 | + } |
|
97 | + } |
|
98 | 98 | |
99 | 99 | |
100 | - /** |
|
101 | - * delete versions for the given user |
|
102 | - * |
|
103 | - * @param string $user |
|
104 | - */ |
|
105 | - protected function deleteVersions($user) { |
|
106 | - \OC_Util::tearDownFS(); |
|
107 | - \OC_Util::setupFS($user); |
|
108 | - if ($this->rootFolder->nodeExists('/' . $user . '/files_versions')) { |
|
109 | - $this->rootFolder->get('/' . $user . '/files_versions')->delete(); |
|
110 | - } |
|
111 | - } |
|
100 | + /** |
|
101 | + * delete versions for the given user |
|
102 | + * |
|
103 | + * @param string $user |
|
104 | + */ |
|
105 | + protected function deleteVersions($user) { |
|
106 | + \OC_Util::tearDownFS(); |
|
107 | + \OC_Util::setupFS($user); |
|
108 | + if ($this->rootFolder->nodeExists('/' . $user . '/files_versions')) { |
|
109 | + $this->rootFolder->get('/' . $user . '/files_versions')->delete(); |
|
110 | + } |
|
111 | + } |
|
112 | 112 | } |
@@ -105,8 +105,8 @@ |
||
105 | 105 | protected function deleteVersions($user) { |
106 | 106 | \OC_Util::tearDownFS(); |
107 | 107 | \OC_Util::setupFS($user); |
108 | - if ($this->rootFolder->nodeExists('/' . $user . '/files_versions')) { |
|
109 | - $this->rootFolder->get('/' . $user . '/files_versions')->delete(); |
|
108 | + if ($this->rootFolder->nodeExists('/'.$user.'/files_versions')) { |
|
109 | + $this->rootFolder->get('/'.$user.'/files_versions')->delete(); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | } |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | return; |
67 | 67 | } |
68 | 68 | |
69 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
69 | + $this->userManager->callForSeenUsers(function(IUser $user) { |
|
70 | 70 | $uid = $user->getUID(); |
71 | 71 | if (!$this->setupFS($uid)) { |
72 | 72 | return; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | \OC_Util::setupFS($user); |
86 | 86 | |
87 | 87 | // Check if this user has a versions directory |
88 | - $view = new \OC\Files\View('/' . $user); |
|
88 | + $view = new \OC\Files\View('/'.$user); |
|
89 | 89 | if (!$view->is_dir('/files_versions')) { |
90 | 90 | return false; |
91 | 91 | } |
@@ -31,56 +31,56 @@ |
||
31 | 31 | use OCP\IUserManager; |
32 | 32 | |
33 | 33 | class ExpireVersions extends \OC\BackgroundJob\TimedJob { |
34 | - public const ITEMS_PER_SESSION = 1000; |
|
34 | + public const ITEMS_PER_SESSION = 1000; |
|
35 | 35 | |
36 | - /** |
|
37 | - * @var Expiration |
|
38 | - */ |
|
39 | - private $expiration; |
|
36 | + /** |
|
37 | + * @var Expiration |
|
38 | + */ |
|
39 | + private $expiration; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @var IUserManager |
|
43 | - */ |
|
44 | - private $userManager; |
|
41 | + /** |
|
42 | + * @var IUserManager |
|
43 | + */ |
|
44 | + private $userManager; |
|
45 | 45 | |
46 | - public function __construct(IUserManager $userManager, Expiration $expiration) { |
|
47 | - // Run once per 30 minutes |
|
48 | - $this->setInterval(60 * 30); |
|
46 | + public function __construct(IUserManager $userManager, Expiration $expiration) { |
|
47 | + // Run once per 30 minutes |
|
48 | + $this->setInterval(60 * 30); |
|
49 | 49 | |
50 | - $this->expiration = $expiration; |
|
51 | - $this->userManager = $userManager; |
|
52 | - } |
|
50 | + $this->expiration = $expiration; |
|
51 | + $this->userManager = $userManager; |
|
52 | + } |
|
53 | 53 | |
54 | - protected function run($argument) { |
|
55 | - $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
56 | - if (!$maxAge) { |
|
57 | - return; |
|
58 | - } |
|
54 | + protected function run($argument) { |
|
55 | + $maxAge = $this->expiration->getMaxAgeAsTimestamp(); |
|
56 | + if (!$maxAge) { |
|
57 | + return; |
|
58 | + } |
|
59 | 59 | |
60 | - $this->userManager->callForSeenUsers(function (IUser $user) { |
|
61 | - $uid = $user->getUID(); |
|
62 | - if (!$this->setupFS($uid)) { |
|
63 | - return; |
|
64 | - } |
|
65 | - Storage::expireOlderThanMaxForUser($uid); |
|
66 | - }); |
|
67 | - } |
|
60 | + $this->userManager->callForSeenUsers(function (IUser $user) { |
|
61 | + $uid = $user->getUID(); |
|
62 | + if (!$this->setupFS($uid)) { |
|
63 | + return; |
|
64 | + } |
|
65 | + Storage::expireOlderThanMaxForUser($uid); |
|
66 | + }); |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Act on behalf on trash item owner |
|
71 | - * @param string $user |
|
72 | - * @return boolean |
|
73 | - */ |
|
74 | - protected function setupFS($user) { |
|
75 | - \OC_Util::tearDownFS(); |
|
76 | - \OC_Util::setupFS($user); |
|
69 | + /** |
|
70 | + * Act on behalf on trash item owner |
|
71 | + * @param string $user |
|
72 | + * @return boolean |
|
73 | + */ |
|
74 | + protected function setupFS($user) { |
|
75 | + \OC_Util::tearDownFS(); |
|
76 | + \OC_Util::setupFS($user); |
|
77 | 77 | |
78 | - // Check if this user has a versions directory |
|
79 | - $view = new \OC\Files\View('/' . $user); |
|
80 | - if (!$view->is_dir('/files_versions')) { |
|
81 | - return false; |
|
82 | - } |
|
78 | + // Check if this user has a versions directory |
|
79 | + $view = new \OC\Files\View('/' . $user); |
|
80 | + if (!$view->is_dir('/files_versions')) { |
|
81 | + return false; |
|
82 | + } |
|
83 | 83 | |
84 | - return true; |
|
85 | - } |
|
84 | + return true; |
|
85 | + } |
|
86 | 86 | } |
@@ -99,7 +99,7 @@ |
||
99 | 99 | $this->checker->writeCoreSignature($x509, $rsa, $path); |
100 | 100 | $output->writeln('Successfully signed "core"'); |
101 | 101 | } catch (\Exception $e) { |
102 | - $output->writeln('Error: ' . $e->getMessage()); |
|
102 | + $output->writeln('Error: '.$e->getMessage()); |
|
103 | 103 | return 1; |
104 | 104 | } |
105 | 105 | return 0; |
@@ -38,69 +38,69 @@ |
||
38 | 38 | * @package OC\Core\Command\Integrity |
39 | 39 | */ |
40 | 40 | class SignCore extends Command { |
41 | - /** @var Checker */ |
|
42 | - private $checker; |
|
43 | - /** @var FileAccessHelper */ |
|
44 | - private $fileAccessHelper; |
|
41 | + /** @var Checker */ |
|
42 | + private $checker; |
|
43 | + /** @var FileAccessHelper */ |
|
44 | + private $fileAccessHelper; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @param Checker $checker |
|
48 | - * @param FileAccessHelper $fileAccessHelper |
|
49 | - */ |
|
50 | - public function __construct(Checker $checker, |
|
51 | - FileAccessHelper $fileAccessHelper) { |
|
52 | - parent::__construct(null); |
|
53 | - $this->checker = $checker; |
|
54 | - $this->fileAccessHelper = $fileAccessHelper; |
|
55 | - } |
|
46 | + /** |
|
47 | + * @param Checker $checker |
|
48 | + * @param FileAccessHelper $fileAccessHelper |
|
49 | + */ |
|
50 | + public function __construct(Checker $checker, |
|
51 | + FileAccessHelper $fileAccessHelper) { |
|
52 | + parent::__construct(null); |
|
53 | + $this->checker = $checker; |
|
54 | + $this->fileAccessHelper = $fileAccessHelper; |
|
55 | + } |
|
56 | 56 | |
57 | - protected function configure() { |
|
58 | - $this |
|
59 | - ->setName('integrity:sign-core') |
|
60 | - ->setDescription('Sign core using a private key.') |
|
61 | - ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') |
|
62 | - ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing') |
|
63 | - ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Path of core to sign'); |
|
64 | - } |
|
57 | + protected function configure() { |
|
58 | + $this |
|
59 | + ->setName('integrity:sign-core') |
|
60 | + ->setDescription('Sign core using a private key.') |
|
61 | + ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') |
|
62 | + ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing') |
|
63 | + ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Path of core to sign'); |
|
64 | + } |
|
65 | 65 | |
66 | - /** |
|
67 | - * {@inheritdoc } |
|
68 | - */ |
|
69 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
70 | - $privateKeyPath = $input->getOption('privateKey'); |
|
71 | - $keyBundlePath = $input->getOption('certificate'); |
|
72 | - $path = $input->getOption('path'); |
|
73 | - if (is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { |
|
74 | - $output->writeln('--privateKey, --certificate and --path are required.'); |
|
75 | - return null; |
|
76 | - } |
|
66 | + /** |
|
67 | + * {@inheritdoc } |
|
68 | + */ |
|
69 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
70 | + $privateKeyPath = $input->getOption('privateKey'); |
|
71 | + $keyBundlePath = $input->getOption('certificate'); |
|
72 | + $path = $input->getOption('path'); |
|
73 | + if (is_null($privateKeyPath) || is_null($keyBundlePath) || is_null($path)) { |
|
74 | + $output->writeln('--privateKey, --certificate and --path are required.'); |
|
75 | + return null; |
|
76 | + } |
|
77 | 77 | |
78 | - $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
|
79 | - $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
|
78 | + $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
|
79 | + $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
|
80 | 80 | |
81 | - if ($privateKey === false) { |
|
82 | - $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
|
83 | - return null; |
|
84 | - } |
|
81 | + if ($privateKey === false) { |
|
82 | + $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
|
83 | + return null; |
|
84 | + } |
|
85 | 85 | |
86 | - if ($keyBundle === false) { |
|
87 | - $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
|
88 | - return null; |
|
89 | - } |
|
86 | + if ($keyBundle === false) { |
|
87 | + $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
|
88 | + return null; |
|
89 | + } |
|
90 | 90 | |
91 | - $rsa = new RSA(); |
|
92 | - $rsa->loadKey($privateKey); |
|
93 | - $x509 = new X509(); |
|
94 | - $x509->loadX509($keyBundle); |
|
95 | - $x509->setPrivateKey($rsa); |
|
91 | + $rsa = new RSA(); |
|
92 | + $rsa->loadKey($privateKey); |
|
93 | + $x509 = new X509(); |
|
94 | + $x509->loadX509($keyBundle); |
|
95 | + $x509->setPrivateKey($rsa); |
|
96 | 96 | |
97 | - try { |
|
98 | - $this->checker->writeCoreSignature($x509, $rsa, $path); |
|
99 | - $output->writeln('Successfully signed "core"'); |
|
100 | - } catch (\Exception $e) { |
|
101 | - $output->writeln('Error: ' . $e->getMessage()); |
|
102 | - return 1; |
|
103 | - } |
|
104 | - return 0; |
|
105 | - } |
|
97 | + try { |
|
98 | + $this->checker->writeCoreSignature($x509, $rsa, $path); |
|
99 | + $output->writeln('Successfully signed "core"'); |
|
100 | + } catch (\Exception $e) { |
|
101 | + $output->writeln('Error: ' . $e->getMessage()); |
|
102 | + return 1; |
|
103 | + } |
|
104 | + return 0; |
|
105 | + } |
|
106 | 106 | } |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity'); |
82 | 82 | $output->writeln('This command requires the --path, --privateKey and --certificate.'); |
83 | 83 | $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); |
84 | - $output->writeln('For more information please consult the documentation: '. $documentationUrl); |
|
84 | + $output->writeln('For more information please consult the documentation: '.$documentationUrl); |
|
85 | 85 | return null; |
86 | 86 | } |
87 | 87 | |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | $this->checker->writeAppSignature($path, $x509, $rsa); |
108 | 108 | $output->writeln('Successfully signed "'.$path.'"'); |
109 | 109 | } catch (\Exception $e) { |
110 | - $output->writeln('Error: ' . $e->getMessage()); |
|
110 | + $output->writeln('Error: '.$e->getMessage()); |
|
111 | 111 | return 1; |
112 | 112 | } |
113 | 113 | return 0; |
@@ -39,76 +39,76 @@ |
||
39 | 39 | * @package OC\Core\Command\Integrity |
40 | 40 | */ |
41 | 41 | class SignApp extends Command { |
42 | - /** @var Checker */ |
|
43 | - private $checker; |
|
44 | - /** @var FileAccessHelper */ |
|
45 | - private $fileAccessHelper; |
|
46 | - /** @var IURLGenerator */ |
|
47 | - private $urlGenerator; |
|
42 | + /** @var Checker */ |
|
43 | + private $checker; |
|
44 | + /** @var FileAccessHelper */ |
|
45 | + private $fileAccessHelper; |
|
46 | + /** @var IURLGenerator */ |
|
47 | + private $urlGenerator; |
|
48 | 48 | |
49 | - /** |
|
50 | - * @param Checker $checker |
|
51 | - * @param FileAccessHelper $fileAccessHelper |
|
52 | - * @param IURLGenerator $urlGenerator |
|
53 | - */ |
|
54 | - public function __construct(Checker $checker, |
|
55 | - FileAccessHelper $fileAccessHelper, |
|
56 | - IURLGenerator $urlGenerator) { |
|
57 | - parent::__construct(null); |
|
58 | - $this->checker = $checker; |
|
59 | - $this->fileAccessHelper = $fileAccessHelper; |
|
60 | - $this->urlGenerator = $urlGenerator; |
|
61 | - } |
|
49 | + /** |
|
50 | + * @param Checker $checker |
|
51 | + * @param FileAccessHelper $fileAccessHelper |
|
52 | + * @param IURLGenerator $urlGenerator |
|
53 | + */ |
|
54 | + public function __construct(Checker $checker, |
|
55 | + FileAccessHelper $fileAccessHelper, |
|
56 | + IURLGenerator $urlGenerator) { |
|
57 | + parent::__construct(null); |
|
58 | + $this->checker = $checker; |
|
59 | + $this->fileAccessHelper = $fileAccessHelper; |
|
60 | + $this->urlGenerator = $urlGenerator; |
|
61 | + } |
|
62 | 62 | |
63 | - protected function configure() { |
|
64 | - $this |
|
65 | - ->setName('integrity:sign-app') |
|
66 | - ->setDescription('Signs an app using a private key.') |
|
67 | - ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Application to sign') |
|
68 | - ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') |
|
69 | - ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing'); |
|
70 | - } |
|
63 | + protected function configure() { |
|
64 | + $this |
|
65 | + ->setName('integrity:sign-app') |
|
66 | + ->setDescription('Signs an app using a private key.') |
|
67 | + ->addOption('path', null, InputOption::VALUE_REQUIRED, 'Application to sign') |
|
68 | + ->addOption('privateKey', null, InputOption::VALUE_REQUIRED, 'Path to private key to use for signing') |
|
69 | + ->addOption('certificate', null, InputOption::VALUE_REQUIRED, 'Path to certificate to use for signing'); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * {@inheritdoc } |
|
74 | - */ |
|
75 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
76 | - $path = $input->getOption('path'); |
|
77 | - $privateKeyPath = $input->getOption('privateKey'); |
|
78 | - $keyBundlePath = $input->getOption('certificate'); |
|
79 | - if (is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { |
|
80 | - $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity'); |
|
81 | - $output->writeln('This command requires the --path, --privateKey and --certificate.'); |
|
82 | - $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); |
|
83 | - $output->writeln('For more information please consult the documentation: '. $documentationUrl); |
|
84 | - return null; |
|
85 | - } |
|
72 | + /** |
|
73 | + * {@inheritdoc } |
|
74 | + */ |
|
75 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
76 | + $path = $input->getOption('path'); |
|
77 | + $privateKeyPath = $input->getOption('privateKey'); |
|
78 | + $keyBundlePath = $input->getOption('certificate'); |
|
79 | + if (is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) { |
|
80 | + $documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity'); |
|
81 | + $output->writeln('This command requires the --path, --privateKey and --certificate.'); |
|
82 | + $output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"'); |
|
83 | + $output->writeln('For more information please consult the documentation: '. $documentationUrl); |
|
84 | + return null; |
|
85 | + } |
|
86 | 86 | |
87 | - $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
|
88 | - $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
|
87 | + $privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath); |
|
88 | + $keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath); |
|
89 | 89 | |
90 | - if ($privateKey === false) { |
|
91 | - $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
|
92 | - return null; |
|
93 | - } |
|
90 | + if ($privateKey === false) { |
|
91 | + $output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath)); |
|
92 | + return null; |
|
93 | + } |
|
94 | 94 | |
95 | - if ($keyBundle === false) { |
|
96 | - $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
|
97 | - return null; |
|
98 | - } |
|
95 | + if ($keyBundle === false) { |
|
96 | + $output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath)); |
|
97 | + return null; |
|
98 | + } |
|
99 | 99 | |
100 | - $rsa = new RSA(); |
|
101 | - $rsa->loadKey($privateKey); |
|
102 | - $x509 = new X509(); |
|
103 | - $x509->loadX509($keyBundle); |
|
104 | - $x509->setPrivateKey($rsa); |
|
105 | - try { |
|
106 | - $this->checker->writeAppSignature($path, $x509, $rsa); |
|
107 | - $output->writeln('Successfully signed "'.$path.'"'); |
|
108 | - } catch (\Exception $e) { |
|
109 | - $output->writeln('Error: ' . $e->getMessage()); |
|
110 | - return 1; |
|
111 | - } |
|
112 | - return 0; |
|
113 | - } |
|
100 | + $rsa = new RSA(); |
|
101 | + $rsa->loadKey($privateKey); |
|
102 | + $x509 = new X509(); |
|
103 | + $x509->loadX509($keyBundle); |
|
104 | + $x509->setPrivateKey($rsa); |
|
105 | + try { |
|
106 | + $this->checker->writeAppSignature($path, $x509, $rsa); |
|
107 | + $output->writeln('Successfully signed "'.$path.'"'); |
|
108 | + } catch (\Exception $e) { |
|
109 | + $output->writeln('Error: ' . $e->getMessage()); |
|
110 | + return 1; |
|
111 | + } |
|
112 | + return 0; |
|
113 | + } |
|
114 | 114 | } |