@@ -39,33 +39,33 @@ |
||
39 | 39 | * @package OCA\DAV\Connector\Sabre |
40 | 40 | */ |
41 | 41 | class DummyGetResponsePlugin extends \Sabre\DAV\ServerPlugin { |
42 | - /** @var \Sabre\DAV\Server */ |
|
43 | - protected $server; |
|
42 | + /** @var \Sabre\DAV\Server */ |
|
43 | + protected $server; |
|
44 | 44 | |
45 | - /** |
|
46 | - * @param \Sabre\DAV\Server $server |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - function initialize(\Sabre\DAV\Server $server) { |
|
50 | - $this->server = $server; |
|
51 | - $this->server->on('method:GET', [$this, 'httpGet'], 200); |
|
52 | - } |
|
45 | + /** |
|
46 | + * @param \Sabre\DAV\Server $server |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + function initialize(\Sabre\DAV\Server $server) { |
|
50 | + $this->server = $server; |
|
51 | + $this->server->on('method:GET', [$this, 'httpGet'], 200); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @param RequestInterface $request |
|
56 | - * @param ResponseInterface $response |
|
57 | - * @return false |
|
58 | - */ |
|
59 | - function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
60 | - $string = 'This is the WebDAV interface. It can only be accessed by ' . |
|
61 | - 'WebDAV clients such as the Nextcloud desktop sync client.'; |
|
62 | - $stream = fopen('php://memory','r+'); |
|
63 | - fwrite($stream, $string); |
|
64 | - rewind($stream); |
|
54 | + /** |
|
55 | + * @param RequestInterface $request |
|
56 | + * @param ResponseInterface $response |
|
57 | + * @return false |
|
58 | + */ |
|
59 | + function httpGet(RequestInterface $request, ResponseInterface $response) { |
|
60 | + $string = 'This is the WebDAV interface. It can only be accessed by ' . |
|
61 | + 'WebDAV clients such as the Nextcloud desktop sync client.'; |
|
62 | + $stream = fopen('php://memory','r+'); |
|
63 | + fwrite($stream, $string); |
|
64 | + rewind($stream); |
|
65 | 65 | |
66 | - $response->setStatus(200); |
|
67 | - $response->setBody($stream); |
|
66 | + $response->setStatus(200); |
|
67 | + $response->setBody($stream); |
|
68 | 68 | |
69 | - return false; |
|
70 | - } |
|
69 | + return false; |
|
70 | + } |
|
71 | 71 | } |
@@ -37,57 +37,57 @@ |
||
37 | 37 | */ |
38 | 38 | class ConsoleOutput implements IOutput { |
39 | 39 | |
40 | - /** @var OutputInterface */ |
|
41 | - private $output; |
|
40 | + /** @var OutputInterface */ |
|
41 | + private $output; |
|
42 | 42 | |
43 | - /** @var ProgressBar */ |
|
44 | - private $progressBar; |
|
43 | + /** @var ProgressBar */ |
|
44 | + private $progressBar; |
|
45 | 45 | |
46 | - public function __construct(OutputInterface $output) { |
|
47 | - $this->output = $output; |
|
48 | - } |
|
46 | + public function __construct(OutputInterface $output) { |
|
47 | + $this->output = $output; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * @param string $message |
|
52 | - */ |
|
53 | - public function info($message) { |
|
54 | - $this->output->writeln("<info>$message</info>"); |
|
55 | - } |
|
50 | + /** |
|
51 | + * @param string $message |
|
52 | + */ |
|
53 | + public function info($message) { |
|
54 | + $this->output->writeln("<info>$message</info>"); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * @param string $message |
|
59 | - */ |
|
60 | - public function warning($message) { |
|
61 | - $this->output->writeln("<comment>$message</comment>"); |
|
62 | - } |
|
57 | + /** |
|
58 | + * @param string $message |
|
59 | + */ |
|
60 | + public function warning($message) { |
|
61 | + $this->output->writeln("<comment>$message</comment>"); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * @param int $max |
|
66 | - */ |
|
67 | - public function startProgress($max = 0) { |
|
68 | - if (!is_null($this->progressBar)) { |
|
69 | - $this->progressBar->finish(); |
|
70 | - } |
|
71 | - $this->progressBar = new ProgressBar($this->output); |
|
72 | - $this->progressBar->start($max); |
|
73 | - } |
|
64 | + /** |
|
65 | + * @param int $max |
|
66 | + */ |
|
67 | + public function startProgress($max = 0) { |
|
68 | + if (!is_null($this->progressBar)) { |
|
69 | + $this->progressBar->finish(); |
|
70 | + } |
|
71 | + $this->progressBar = new ProgressBar($this->output); |
|
72 | + $this->progressBar->start($max); |
|
73 | + } |
|
74 | 74 | |
75 | - /** |
|
76 | - * @param int $step |
|
77 | - * @param string $description |
|
78 | - */ |
|
79 | - public function advance($step = 1, $description = '') { |
|
80 | - if (!is_null($this->progressBar)) { |
|
81 | - $this->progressBar = new ProgressBar($this->output); |
|
82 | - $this->progressBar->start(); |
|
83 | - } |
|
84 | - $this->progressBar->advance($step); |
|
85 | - } |
|
75 | + /** |
|
76 | + * @param int $step |
|
77 | + * @param string $description |
|
78 | + */ |
|
79 | + public function advance($step = 1, $description = '') { |
|
80 | + if (!is_null($this->progressBar)) { |
|
81 | + $this->progressBar = new ProgressBar($this->output); |
|
82 | + $this->progressBar->start(); |
|
83 | + } |
|
84 | + $this->progressBar->advance($step); |
|
85 | + } |
|
86 | 86 | |
87 | - public function finishProgress() { |
|
88 | - if (is_null($this->progressBar)) { |
|
89 | - return; |
|
90 | - } |
|
91 | - $this->progressBar->finish(); |
|
92 | - } |
|
87 | + public function finishProgress() { |
|
88 | + if (is_null($this->progressBar)) { |
|
89 | + return; |
|
90 | + } |
|
91 | + $this->progressBar->finish(); |
|
92 | + } |
|
93 | 93 | } |
@@ -39,98 +39,98 @@ |
||
39 | 39 | |
40 | 40 | class ResetPassword extends Command { |
41 | 41 | |
42 | - /** @var IUserManager */ |
|
43 | - protected $userManager; |
|
44 | - |
|
45 | - public function __construct(IUserManager $userManager) { |
|
46 | - $this->userManager = $userManager; |
|
47 | - parent::__construct(); |
|
48 | - } |
|
49 | - |
|
50 | - protected function configure() { |
|
51 | - $this |
|
52 | - ->setName('user:resetpassword') |
|
53 | - ->setDescription('Resets the password of the named user') |
|
54 | - ->addArgument( |
|
55 | - 'user', |
|
56 | - InputArgument::REQUIRED, |
|
57 | - 'Username to reset password' |
|
58 | - ) |
|
59 | - ->addOption( |
|
60 | - 'password-from-env', |
|
61 | - null, |
|
62 | - InputOption::VALUE_NONE, |
|
63 | - 'read password from environment variable OC_PASS' |
|
64 | - ) |
|
65 | - ; |
|
66 | - } |
|
67 | - |
|
68 | - protected function execute(InputInterface $input, OutputInterface $output) { |
|
69 | - $username = $input->getArgument('user'); |
|
70 | - |
|
71 | - /** @var $user \OCP\IUser */ |
|
72 | - $user = $this->userManager->get($username); |
|
73 | - if (is_null($user)) { |
|
74 | - $output->writeln('<error>User does not exist</error>'); |
|
75 | - return 1; |
|
76 | - } |
|
77 | - |
|
78 | - if ($input->getOption('password-from-env')) { |
|
79 | - $password = getenv('OC_PASS'); |
|
80 | - if (!$password) { |
|
81 | - $output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>'); |
|
82 | - return 1; |
|
83 | - } |
|
84 | - } elseif ($input->isInteractive()) { |
|
85 | - /** @var QuestionHelper $helper */ |
|
86 | - $helper = $this->getHelper('question'); |
|
87 | - |
|
88 | - if (\OCP\App::isEnabled('encryption')) { |
|
89 | - $output->writeln( |
|
90 | - '<error>Warning: Resetting the password when using encryption will result in data loss!</error>' |
|
91 | - ); |
|
92 | - |
|
93 | - $question = new ConfirmationQuestion('Do you want to continue?'); |
|
94 | - if (!$helper->ask($input, $output, $question)) { |
|
95 | - return 1; |
|
96 | - } |
|
97 | - } |
|
98 | - |
|
99 | - $question = new Question('Enter a new password: '); |
|
100 | - $question->setHidden(true); |
|
101 | - $password = $helper->ask($input, $output, $question); |
|
102 | - |
|
103 | - if ($password === null) { |
|
104 | - $output->writeln("<error>Password cannot be empty!</error>"); |
|
105 | - return 1; |
|
106 | - } |
|
107 | - |
|
108 | - $question = new Question('Confirm the new password: '); |
|
109 | - $question->setHidden(true); |
|
110 | - $confirm = $helper->ask($input, $output, $question); |
|
111 | - |
|
112 | - if ($password !== $confirm) { |
|
113 | - $output->writeln("<error>Passwords did not match!</error>"); |
|
114 | - return 1; |
|
115 | - } |
|
116 | - } else { |
|
117 | - $output->writeln("<error>Interactive input or --password-from-env is needed for entering a new password!</error>"); |
|
118 | - return 1; |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - try { |
|
123 | - $success = $user->setPassword($password); |
|
124 | - } catch (\Exception $e) { |
|
125 | - $output->writeln('<error>' . $e->getMessage() . '</error>'); |
|
126 | - return 1; |
|
127 | - } |
|
128 | - |
|
129 | - if ($success) { |
|
130 | - $output->writeln("<info>Successfully reset password for " . $username . "</info>"); |
|
131 | - } else { |
|
132 | - $output->writeln("<error>Error while resetting password!</error>"); |
|
133 | - return 1; |
|
134 | - } |
|
135 | - } |
|
42 | + /** @var IUserManager */ |
|
43 | + protected $userManager; |
|
44 | + |
|
45 | + public function __construct(IUserManager $userManager) { |
|
46 | + $this->userManager = $userManager; |
|
47 | + parent::__construct(); |
|
48 | + } |
|
49 | + |
|
50 | + protected function configure() { |
|
51 | + $this |
|
52 | + ->setName('user:resetpassword') |
|
53 | + ->setDescription('Resets the password of the named user') |
|
54 | + ->addArgument( |
|
55 | + 'user', |
|
56 | + InputArgument::REQUIRED, |
|
57 | + 'Username to reset password' |
|
58 | + ) |
|
59 | + ->addOption( |
|
60 | + 'password-from-env', |
|
61 | + null, |
|
62 | + InputOption::VALUE_NONE, |
|
63 | + 'read password from environment variable OC_PASS' |
|
64 | + ) |
|
65 | + ; |
|
66 | + } |
|
67 | + |
|
68 | + protected function execute(InputInterface $input, OutputInterface $output) { |
|
69 | + $username = $input->getArgument('user'); |
|
70 | + |
|
71 | + /** @var $user \OCP\IUser */ |
|
72 | + $user = $this->userManager->get($username); |
|
73 | + if (is_null($user)) { |
|
74 | + $output->writeln('<error>User does not exist</error>'); |
|
75 | + return 1; |
|
76 | + } |
|
77 | + |
|
78 | + if ($input->getOption('password-from-env')) { |
|
79 | + $password = getenv('OC_PASS'); |
|
80 | + if (!$password) { |
|
81 | + $output->writeln('<error>--password-from-env given, but OC_PASS is empty!</error>'); |
|
82 | + return 1; |
|
83 | + } |
|
84 | + } elseif ($input->isInteractive()) { |
|
85 | + /** @var QuestionHelper $helper */ |
|
86 | + $helper = $this->getHelper('question'); |
|
87 | + |
|
88 | + if (\OCP\App::isEnabled('encryption')) { |
|
89 | + $output->writeln( |
|
90 | + '<error>Warning: Resetting the password when using encryption will result in data loss!</error>' |
|
91 | + ); |
|
92 | + |
|
93 | + $question = new ConfirmationQuestion('Do you want to continue?'); |
|
94 | + if (!$helper->ask($input, $output, $question)) { |
|
95 | + return 1; |
|
96 | + } |
|
97 | + } |
|
98 | + |
|
99 | + $question = new Question('Enter a new password: '); |
|
100 | + $question->setHidden(true); |
|
101 | + $password = $helper->ask($input, $output, $question); |
|
102 | + |
|
103 | + if ($password === null) { |
|
104 | + $output->writeln("<error>Password cannot be empty!</error>"); |
|
105 | + return 1; |
|
106 | + } |
|
107 | + |
|
108 | + $question = new Question('Confirm the new password: '); |
|
109 | + $question->setHidden(true); |
|
110 | + $confirm = $helper->ask($input, $output, $question); |
|
111 | + |
|
112 | + if ($password !== $confirm) { |
|
113 | + $output->writeln("<error>Passwords did not match!</error>"); |
|
114 | + return 1; |
|
115 | + } |
|
116 | + } else { |
|
117 | + $output->writeln("<error>Interactive input or --password-from-env is needed for entering a new password!</error>"); |
|
118 | + return 1; |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + try { |
|
123 | + $success = $user->setPassword($password); |
|
124 | + } catch (\Exception $e) { |
|
125 | + $output->writeln('<error>' . $e->getMessage() . '</error>'); |
|
126 | + return 1; |
|
127 | + } |
|
128 | + |
|
129 | + if ($success) { |
|
130 | + $output->writeln("<info>Successfully reset password for " . $username . "</info>"); |
|
131 | + } else { |
|
132 | + $output->writeln("<error>Error while resetting password!</error>"); |
|
133 | + return 1; |
|
134 | + } |
|
135 | + } |
|
136 | 136 | } |
@@ -29,141 +29,141 @@ |
||
29 | 29 | |
30 | 30 | class Entry implements IEntry { |
31 | 31 | |
32 | - /** @var string|int|null */ |
|
33 | - private $id = null; |
|
34 | - |
|
35 | - /** @var string */ |
|
36 | - private $fullName = ''; |
|
37 | - |
|
38 | - /** @var string[] */ |
|
39 | - private $emailAddresses = []; |
|
40 | - |
|
41 | - /** @var string|null */ |
|
42 | - private $avatar; |
|
43 | - |
|
44 | - /** @var IAction[] */ |
|
45 | - private $actions = []; |
|
46 | - |
|
47 | - /** @var array */ |
|
48 | - private $properties = []; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param string $id |
|
52 | - */ |
|
53 | - public function setId($id) { |
|
54 | - $this->id = $id; |
|
55 | - } |
|
56 | - |
|
57 | - /** |
|
58 | - * @param string $displayName |
|
59 | - */ |
|
60 | - public function setFullName($displayName) { |
|
61 | - $this->fullName = $displayName; |
|
62 | - } |
|
63 | - |
|
64 | - /** |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public function getFullName() { |
|
68 | - return $this->fullName; |
|
69 | - } |
|
70 | - |
|
71 | - /** |
|
72 | - * @param string $address |
|
73 | - */ |
|
74 | - public function addEMailAddress($address) { |
|
75 | - $this->emailAddresses[] = $address; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function getEMailAddresses() { |
|
82 | - return $this->emailAddresses; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @param string $avatar |
|
87 | - */ |
|
88 | - public function setAvatar($avatar) { |
|
89 | - $this->avatar = $avatar; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string |
|
94 | - */ |
|
95 | - public function getAvatar() { |
|
96 | - return $this->avatar; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @param IAction $action |
|
101 | - */ |
|
102 | - public function addAction(IAction $action) { |
|
103 | - $this->actions[] = $action; |
|
104 | - $this->sortActions(); |
|
105 | - } |
|
106 | - |
|
107 | - /** |
|
108 | - * @return IAction[] |
|
109 | - */ |
|
110 | - public function getActions() { |
|
111 | - return $this->actions; |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * sort the actions by priority and name |
|
116 | - */ |
|
117 | - private function sortActions() { |
|
118 | - usort($this->actions, function(IAction $action1, IAction $action2) { |
|
119 | - $prio1 = $action1->getPriority(); |
|
120 | - $prio2 = $action2->getPriority(); |
|
121 | - |
|
122 | - if ($prio1 === $prio2) { |
|
123 | - // Ascending order for same priority |
|
124 | - return strcasecmp($action1->getName(), $action2->getName()); |
|
125 | - } |
|
126 | - |
|
127 | - // Descending order when priority differs |
|
128 | - return $prio2 - $prio1; |
|
129 | - }); |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * @param array $contact key-value array containing additional properties |
|
134 | - */ |
|
135 | - public function setProperties(array $contact) { |
|
136 | - $this->properties = $contact; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * @param string $key |
|
141 | - * @return mixed |
|
142 | - */ |
|
143 | - public function getProperty($key) { |
|
144 | - if (!isset($this->properties[$key])) { |
|
145 | - return null; |
|
146 | - } |
|
147 | - return $this->properties[$key]; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * @return array |
|
152 | - */ |
|
153 | - public function jsonSerialize() { |
|
154 | - $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null; |
|
155 | - $otherActions = array_map(function(IAction $action) { |
|
156 | - return $action->jsonSerialize(); |
|
157 | - }, array_slice($this->actions, 1)); |
|
158 | - |
|
159 | - return [ |
|
160 | - 'id' => $this->id, |
|
161 | - 'fullName' => $this->fullName, |
|
162 | - 'avatar' => $this->getAvatar(), |
|
163 | - 'topAction' => $topAction, |
|
164 | - 'actions' => $otherActions, |
|
165 | - 'lastMessage' => '', |
|
166 | - ]; |
|
167 | - } |
|
32 | + /** @var string|int|null */ |
|
33 | + private $id = null; |
|
34 | + |
|
35 | + /** @var string */ |
|
36 | + private $fullName = ''; |
|
37 | + |
|
38 | + /** @var string[] */ |
|
39 | + private $emailAddresses = []; |
|
40 | + |
|
41 | + /** @var string|null */ |
|
42 | + private $avatar; |
|
43 | + |
|
44 | + /** @var IAction[] */ |
|
45 | + private $actions = []; |
|
46 | + |
|
47 | + /** @var array */ |
|
48 | + private $properties = []; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param string $id |
|
52 | + */ |
|
53 | + public function setId($id) { |
|
54 | + $this->id = $id; |
|
55 | + } |
|
56 | + |
|
57 | + /** |
|
58 | + * @param string $displayName |
|
59 | + */ |
|
60 | + public function setFullName($displayName) { |
|
61 | + $this->fullName = $displayName; |
|
62 | + } |
|
63 | + |
|
64 | + /** |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public function getFullName() { |
|
68 | + return $this->fullName; |
|
69 | + } |
|
70 | + |
|
71 | + /** |
|
72 | + * @param string $address |
|
73 | + */ |
|
74 | + public function addEMailAddress($address) { |
|
75 | + $this->emailAddresses[] = $address; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function getEMailAddresses() { |
|
82 | + return $this->emailAddresses; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @param string $avatar |
|
87 | + */ |
|
88 | + public function setAvatar($avatar) { |
|
89 | + $this->avatar = $avatar; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string |
|
94 | + */ |
|
95 | + public function getAvatar() { |
|
96 | + return $this->avatar; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @param IAction $action |
|
101 | + */ |
|
102 | + public function addAction(IAction $action) { |
|
103 | + $this->actions[] = $action; |
|
104 | + $this->sortActions(); |
|
105 | + } |
|
106 | + |
|
107 | + /** |
|
108 | + * @return IAction[] |
|
109 | + */ |
|
110 | + public function getActions() { |
|
111 | + return $this->actions; |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * sort the actions by priority and name |
|
116 | + */ |
|
117 | + private function sortActions() { |
|
118 | + usort($this->actions, function(IAction $action1, IAction $action2) { |
|
119 | + $prio1 = $action1->getPriority(); |
|
120 | + $prio2 = $action2->getPriority(); |
|
121 | + |
|
122 | + if ($prio1 === $prio2) { |
|
123 | + // Ascending order for same priority |
|
124 | + return strcasecmp($action1->getName(), $action2->getName()); |
|
125 | + } |
|
126 | + |
|
127 | + // Descending order when priority differs |
|
128 | + return $prio2 - $prio1; |
|
129 | + }); |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * @param array $contact key-value array containing additional properties |
|
134 | + */ |
|
135 | + public function setProperties(array $contact) { |
|
136 | + $this->properties = $contact; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * @param string $key |
|
141 | + * @return mixed |
|
142 | + */ |
|
143 | + public function getProperty($key) { |
|
144 | + if (!isset($this->properties[$key])) { |
|
145 | + return null; |
|
146 | + } |
|
147 | + return $this->properties[$key]; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * @return array |
|
152 | + */ |
|
153 | + public function jsonSerialize() { |
|
154 | + $topAction = !empty($this->actions) ? $this->actions[0]->jsonSerialize() : null; |
|
155 | + $otherActions = array_map(function(IAction $action) { |
|
156 | + return $action->jsonSerialize(); |
|
157 | + }, array_slice($this->actions, 1)); |
|
158 | + |
|
159 | + return [ |
|
160 | + 'id' => $this->id, |
|
161 | + 'fullName' => $this->fullName, |
|
162 | + 'avatar' => $this->getAvatar(), |
|
163 | + 'topAction' => $topAction, |
|
164 | + 'actions' => $otherActions, |
|
165 | + 'lastMessage' => '', |
|
166 | + ]; |
|
167 | + } |
|
168 | 168 | |
169 | 169 | } |
@@ -31,36 +31,36 @@ |
||
31 | 31 | */ |
32 | 32 | interface IEntry extends JsonSerializable { |
33 | 33 | |
34 | - /** |
|
35 | - * @since 12.0 |
|
36 | - * @return string |
|
37 | - */ |
|
38 | - public function getFullName(); |
|
34 | + /** |
|
35 | + * @since 12.0 |
|
36 | + * @return string |
|
37 | + */ |
|
38 | + public function getFullName(); |
|
39 | 39 | |
40 | - /** |
|
41 | - * @since 12.0 |
|
42 | - * @return string[] |
|
43 | - */ |
|
44 | - public function getEMailAddresses(); |
|
40 | + /** |
|
41 | + * @since 12.0 |
|
42 | + * @return string[] |
|
43 | + */ |
|
44 | + public function getEMailAddresses(); |
|
45 | 45 | |
46 | - /** |
|
47 | - * @since 12.0 |
|
48 | - * @return string|null image URI |
|
49 | - */ |
|
50 | - public function getAvatar(); |
|
46 | + /** |
|
47 | + * @since 12.0 |
|
48 | + * @return string|null image URI |
|
49 | + */ |
|
50 | + public function getAvatar(); |
|
51 | 51 | |
52 | - /** |
|
53 | - * @since 12.0 |
|
54 | - * @param IAction $action an action to show in the contacts menu |
|
55 | - */ |
|
56 | - public function addAction(IAction $action); |
|
52 | + /** |
|
53 | + * @since 12.0 |
|
54 | + * @param IAction $action an action to show in the contacts menu |
|
55 | + */ |
|
56 | + public function addAction(IAction $action); |
|
57 | 57 | |
58 | - /** |
|
59 | - * Get an arbitrary property from the contact |
|
60 | - * |
|
61 | - * @since 12.0 |
|
62 | - * @param string $key |
|
63 | - * @return mixed the value of the property or null |
|
64 | - */ |
|
65 | - public function getProperty($key); |
|
58 | + /** |
|
59 | + * Get an arbitrary property from the contact |
|
60 | + * |
|
61 | + * @since 12.0 |
|
62 | + * @param string $key |
|
63 | + * @return mixed the value of the property or null |
|
64 | + */ |
|
65 | + public function getProperty($key); |
|
66 | 66 | } |
@@ -39,313 +39,313 @@ |
||
39 | 39 | |
40 | 40 | class MDB2SchemaReader { |
41 | 41 | |
42 | - /** |
|
43 | - * @var string $DBTABLEPREFIX |
|
44 | - */ |
|
45 | - protected $DBTABLEPREFIX; |
|
42 | + /** |
|
43 | + * @var string $DBTABLEPREFIX |
|
44 | + */ |
|
45 | + protected $DBTABLEPREFIX; |
|
46 | 46 | |
47 | - /** |
|
48 | - * @var \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
49 | - */ |
|
50 | - protected $platform; |
|
47 | + /** |
|
48 | + * @var \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
49 | + */ |
|
50 | + protected $platform; |
|
51 | 51 | |
52 | - /** @var IConfig */ |
|
53 | - protected $config; |
|
52 | + /** @var IConfig */ |
|
53 | + protected $config; |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param \OCP\IConfig $config |
|
57 | - * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
58 | - */ |
|
59 | - public function __construct(IConfig $config, AbstractPlatform $platform) { |
|
60 | - $this->platform = $platform; |
|
61 | - $this->config = $config; |
|
62 | - $this->DBTABLEPREFIX = $config->getSystemValue('dbtableprefix', 'oc_'); |
|
63 | - } |
|
55 | + /** |
|
56 | + * @param \OCP\IConfig $config |
|
57 | + * @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform |
|
58 | + */ |
|
59 | + public function __construct(IConfig $config, AbstractPlatform $platform) { |
|
60 | + $this->platform = $platform; |
|
61 | + $this->config = $config; |
|
62 | + $this->DBTABLEPREFIX = $config->getSystemValue('dbtableprefix', 'oc_'); |
|
63 | + } |
|
64 | 64 | |
65 | - /** |
|
66 | - * @param string $file |
|
67 | - * @param Schema $schema |
|
68 | - * @return Schema |
|
69 | - * @throws \DomainException |
|
70 | - */ |
|
71 | - public function loadSchemaFromFile($file, Schema $schema) { |
|
72 | - $loadEntities = libxml_disable_entity_loader(false); |
|
73 | - $xml = simplexml_load_file($file); |
|
74 | - libxml_disable_entity_loader($loadEntities); |
|
75 | - foreach ($xml->children() as $child) { |
|
76 | - /** |
|
77 | - * @var \SimpleXMLElement $child |
|
78 | - */ |
|
79 | - switch ($child->getName()) { |
|
80 | - case 'name': |
|
81 | - case 'create': |
|
82 | - case 'overwrite': |
|
83 | - case 'charset': |
|
84 | - break; |
|
85 | - case 'table': |
|
86 | - $this->loadTable($schema, $child); |
|
87 | - break; |
|
88 | - default: |
|
89 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
65 | + /** |
|
66 | + * @param string $file |
|
67 | + * @param Schema $schema |
|
68 | + * @return Schema |
|
69 | + * @throws \DomainException |
|
70 | + */ |
|
71 | + public function loadSchemaFromFile($file, Schema $schema) { |
|
72 | + $loadEntities = libxml_disable_entity_loader(false); |
|
73 | + $xml = simplexml_load_file($file); |
|
74 | + libxml_disable_entity_loader($loadEntities); |
|
75 | + foreach ($xml->children() as $child) { |
|
76 | + /** |
|
77 | + * @var \SimpleXMLElement $child |
|
78 | + */ |
|
79 | + switch ($child->getName()) { |
|
80 | + case 'name': |
|
81 | + case 'create': |
|
82 | + case 'overwrite': |
|
83 | + case 'charset': |
|
84 | + break; |
|
85 | + case 'table': |
|
86 | + $this->loadTable($schema, $child); |
|
87 | + break; |
|
88 | + default: |
|
89 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
90 | 90 | |
91 | - } |
|
92 | - } |
|
93 | - return $schema; |
|
94 | - } |
|
91 | + } |
|
92 | + } |
|
93 | + return $schema; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * @param \Doctrine\DBAL\Schema\Schema $schema |
|
98 | - * @param \SimpleXMLElement $xml |
|
99 | - * @throws \DomainException |
|
100 | - */ |
|
101 | - private function loadTable($schema, $xml) { |
|
102 | - $table = null; |
|
103 | - foreach ($xml->children() as $child) { |
|
104 | - /** |
|
105 | - * @var \SimpleXMLElement $child |
|
106 | - */ |
|
107 | - switch ($child->getName()) { |
|
108 | - case 'name': |
|
109 | - $name = (string)$child; |
|
110 | - $name = str_replace('*dbprefix*', $this->DBTABLEPREFIX, $name); |
|
111 | - $name = $this->platform->quoteIdentifier($name); |
|
112 | - $table = $schema->createTable($name); |
|
113 | - break; |
|
114 | - case 'create': |
|
115 | - case 'overwrite': |
|
116 | - case 'charset': |
|
117 | - break; |
|
118 | - case 'declaration': |
|
119 | - if (is_null($table)) { |
|
120 | - throw new \DomainException('Table declaration before table name'); |
|
121 | - } |
|
122 | - $this->loadDeclaration($table, $child); |
|
123 | - break; |
|
124 | - default: |
|
125 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
96 | + /** |
|
97 | + * @param \Doctrine\DBAL\Schema\Schema $schema |
|
98 | + * @param \SimpleXMLElement $xml |
|
99 | + * @throws \DomainException |
|
100 | + */ |
|
101 | + private function loadTable($schema, $xml) { |
|
102 | + $table = null; |
|
103 | + foreach ($xml->children() as $child) { |
|
104 | + /** |
|
105 | + * @var \SimpleXMLElement $child |
|
106 | + */ |
|
107 | + switch ($child->getName()) { |
|
108 | + case 'name': |
|
109 | + $name = (string)$child; |
|
110 | + $name = str_replace('*dbprefix*', $this->DBTABLEPREFIX, $name); |
|
111 | + $name = $this->platform->quoteIdentifier($name); |
|
112 | + $table = $schema->createTable($name); |
|
113 | + break; |
|
114 | + case 'create': |
|
115 | + case 'overwrite': |
|
116 | + case 'charset': |
|
117 | + break; |
|
118 | + case 'declaration': |
|
119 | + if (is_null($table)) { |
|
120 | + throw new \DomainException('Table declaration before table name'); |
|
121 | + } |
|
122 | + $this->loadDeclaration($table, $child); |
|
123 | + break; |
|
124 | + default: |
|
125 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
126 | 126 | |
127 | - } |
|
128 | - } |
|
129 | - } |
|
127 | + } |
|
128 | + } |
|
129 | + } |
|
130 | 130 | |
131 | - /** |
|
132 | - * @param \Doctrine\DBAL\Schema\Table $table |
|
133 | - * @param \SimpleXMLElement $xml |
|
134 | - * @throws \DomainException |
|
135 | - */ |
|
136 | - private function loadDeclaration($table, $xml) { |
|
137 | - foreach ($xml->children() as $child) { |
|
138 | - /** |
|
139 | - * @var \SimpleXMLElement $child |
|
140 | - */ |
|
141 | - switch ($child->getName()) { |
|
142 | - case 'field': |
|
143 | - $this->loadField($table, $child); |
|
144 | - break; |
|
145 | - case 'index': |
|
146 | - $this->loadIndex($table, $child); |
|
147 | - break; |
|
148 | - default: |
|
149 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
131 | + /** |
|
132 | + * @param \Doctrine\DBAL\Schema\Table $table |
|
133 | + * @param \SimpleXMLElement $xml |
|
134 | + * @throws \DomainException |
|
135 | + */ |
|
136 | + private function loadDeclaration($table, $xml) { |
|
137 | + foreach ($xml->children() as $child) { |
|
138 | + /** |
|
139 | + * @var \SimpleXMLElement $child |
|
140 | + */ |
|
141 | + switch ($child->getName()) { |
|
142 | + case 'field': |
|
143 | + $this->loadField($table, $child); |
|
144 | + break; |
|
145 | + case 'index': |
|
146 | + $this->loadIndex($table, $child); |
|
147 | + break; |
|
148 | + default: |
|
149 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
150 | 150 | |
151 | - } |
|
152 | - } |
|
153 | - } |
|
151 | + } |
|
152 | + } |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * @param \Doctrine\DBAL\Schema\Table $table |
|
157 | - * @param \SimpleXMLElement $xml |
|
158 | - * @throws \DomainException |
|
159 | - */ |
|
160 | - private function loadField($table, $xml) { |
|
161 | - $options = array( 'notnull' => false ); |
|
162 | - foreach ($xml->children() as $child) { |
|
163 | - /** |
|
164 | - * @var \SimpleXMLElement $child |
|
165 | - */ |
|
166 | - switch ($child->getName()) { |
|
167 | - case 'name': |
|
168 | - $name = (string)$child; |
|
169 | - $name = $this->platform->quoteIdentifier($name); |
|
170 | - break; |
|
171 | - case 'type': |
|
172 | - $type = (string)$child; |
|
173 | - switch ($type) { |
|
174 | - case 'text': |
|
175 | - $type = 'string'; |
|
176 | - break; |
|
177 | - case 'clob': |
|
178 | - $type = 'text'; |
|
179 | - break; |
|
180 | - case 'timestamp': |
|
181 | - $type = 'datetime'; |
|
182 | - break; |
|
183 | - case 'numeric': |
|
184 | - $type = 'decimal'; |
|
185 | - break; |
|
186 | - } |
|
187 | - break; |
|
188 | - case 'length': |
|
189 | - $length = (string)$child; |
|
190 | - $options['length'] = $length; |
|
191 | - break; |
|
192 | - case 'unsigned': |
|
193 | - $unsigned = $this->asBool($child); |
|
194 | - $options['unsigned'] = $unsigned; |
|
195 | - break; |
|
196 | - case 'notnull': |
|
197 | - $notnull = $this->asBool($child); |
|
198 | - $options['notnull'] = $notnull; |
|
199 | - break; |
|
200 | - case 'autoincrement': |
|
201 | - $autoincrement = $this->asBool($child); |
|
202 | - $options['autoincrement'] = $autoincrement; |
|
203 | - break; |
|
204 | - case 'default': |
|
205 | - $default = (string)$child; |
|
206 | - $options['default'] = $default; |
|
207 | - break; |
|
208 | - case 'comments': |
|
209 | - $comment = (string)$child; |
|
210 | - $options['comment'] = $comment; |
|
211 | - break; |
|
212 | - case 'primary': |
|
213 | - $primary = $this->asBool($child); |
|
214 | - $options['primary'] = $primary; |
|
215 | - break; |
|
216 | - case 'precision': |
|
217 | - $precision = (string)$child; |
|
218 | - $options['precision'] = $precision; |
|
219 | - break; |
|
220 | - case 'scale': |
|
221 | - $scale = (string)$child; |
|
222 | - $options['scale'] = $scale; |
|
223 | - break; |
|
224 | - default: |
|
225 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
155 | + /** |
|
156 | + * @param \Doctrine\DBAL\Schema\Table $table |
|
157 | + * @param \SimpleXMLElement $xml |
|
158 | + * @throws \DomainException |
|
159 | + */ |
|
160 | + private function loadField($table, $xml) { |
|
161 | + $options = array( 'notnull' => false ); |
|
162 | + foreach ($xml->children() as $child) { |
|
163 | + /** |
|
164 | + * @var \SimpleXMLElement $child |
|
165 | + */ |
|
166 | + switch ($child->getName()) { |
|
167 | + case 'name': |
|
168 | + $name = (string)$child; |
|
169 | + $name = $this->platform->quoteIdentifier($name); |
|
170 | + break; |
|
171 | + case 'type': |
|
172 | + $type = (string)$child; |
|
173 | + switch ($type) { |
|
174 | + case 'text': |
|
175 | + $type = 'string'; |
|
176 | + break; |
|
177 | + case 'clob': |
|
178 | + $type = 'text'; |
|
179 | + break; |
|
180 | + case 'timestamp': |
|
181 | + $type = 'datetime'; |
|
182 | + break; |
|
183 | + case 'numeric': |
|
184 | + $type = 'decimal'; |
|
185 | + break; |
|
186 | + } |
|
187 | + break; |
|
188 | + case 'length': |
|
189 | + $length = (string)$child; |
|
190 | + $options['length'] = $length; |
|
191 | + break; |
|
192 | + case 'unsigned': |
|
193 | + $unsigned = $this->asBool($child); |
|
194 | + $options['unsigned'] = $unsigned; |
|
195 | + break; |
|
196 | + case 'notnull': |
|
197 | + $notnull = $this->asBool($child); |
|
198 | + $options['notnull'] = $notnull; |
|
199 | + break; |
|
200 | + case 'autoincrement': |
|
201 | + $autoincrement = $this->asBool($child); |
|
202 | + $options['autoincrement'] = $autoincrement; |
|
203 | + break; |
|
204 | + case 'default': |
|
205 | + $default = (string)$child; |
|
206 | + $options['default'] = $default; |
|
207 | + break; |
|
208 | + case 'comments': |
|
209 | + $comment = (string)$child; |
|
210 | + $options['comment'] = $comment; |
|
211 | + break; |
|
212 | + case 'primary': |
|
213 | + $primary = $this->asBool($child); |
|
214 | + $options['primary'] = $primary; |
|
215 | + break; |
|
216 | + case 'precision': |
|
217 | + $precision = (string)$child; |
|
218 | + $options['precision'] = $precision; |
|
219 | + break; |
|
220 | + case 'scale': |
|
221 | + $scale = (string)$child; |
|
222 | + $options['scale'] = $scale; |
|
223 | + break; |
|
224 | + default: |
|
225 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
226 | 226 | |
227 | - } |
|
228 | - } |
|
229 | - if (isset($name) && isset($type)) { |
|
230 | - if (isset($options['default']) && empty($options['default'])) { |
|
231 | - if (empty($options['notnull']) || !$options['notnull']) { |
|
232 | - unset($options['default']); |
|
233 | - $options['notnull'] = false; |
|
234 | - } else { |
|
235 | - $options['default'] = ''; |
|
236 | - } |
|
237 | - if ($type == 'integer' || $type == 'decimal') { |
|
238 | - $options['default'] = 0; |
|
239 | - } elseif ($type == 'boolean') { |
|
240 | - $options['default'] = false; |
|
241 | - } |
|
242 | - if (!empty($options['autoincrement']) && $options['autoincrement']) { |
|
243 | - unset($options['default']); |
|
244 | - } |
|
245 | - } |
|
246 | - if ($type === 'integer' && isset($options['default'])) { |
|
247 | - $options['default'] = (int)$options['default']; |
|
248 | - } |
|
249 | - if ($type === 'integer' && isset($options['length'])) { |
|
250 | - $length = $options['length']; |
|
251 | - if ($length < 4) { |
|
252 | - $type = 'smallint'; |
|
253 | - } else if ($length > 4) { |
|
254 | - $type = 'bigint'; |
|
255 | - } |
|
256 | - } |
|
257 | - if ($type === 'boolean' && isset($options['default'])) { |
|
258 | - $options['default'] = $this->asBool($options['default']); |
|
259 | - } |
|
260 | - if (!empty($options['autoincrement']) |
|
261 | - && !empty($options['notnull']) |
|
262 | - ) { |
|
263 | - $options['primary'] = true; |
|
264 | - } |
|
227 | + } |
|
228 | + } |
|
229 | + if (isset($name) && isset($type)) { |
|
230 | + if (isset($options['default']) && empty($options['default'])) { |
|
231 | + if (empty($options['notnull']) || !$options['notnull']) { |
|
232 | + unset($options['default']); |
|
233 | + $options['notnull'] = false; |
|
234 | + } else { |
|
235 | + $options['default'] = ''; |
|
236 | + } |
|
237 | + if ($type == 'integer' || $type == 'decimal') { |
|
238 | + $options['default'] = 0; |
|
239 | + } elseif ($type == 'boolean') { |
|
240 | + $options['default'] = false; |
|
241 | + } |
|
242 | + if (!empty($options['autoincrement']) && $options['autoincrement']) { |
|
243 | + unset($options['default']); |
|
244 | + } |
|
245 | + } |
|
246 | + if ($type === 'integer' && isset($options['default'])) { |
|
247 | + $options['default'] = (int)$options['default']; |
|
248 | + } |
|
249 | + if ($type === 'integer' && isset($options['length'])) { |
|
250 | + $length = $options['length']; |
|
251 | + if ($length < 4) { |
|
252 | + $type = 'smallint'; |
|
253 | + } else if ($length > 4) { |
|
254 | + $type = 'bigint'; |
|
255 | + } |
|
256 | + } |
|
257 | + if ($type === 'boolean' && isset($options['default'])) { |
|
258 | + $options['default'] = $this->asBool($options['default']); |
|
259 | + } |
|
260 | + if (!empty($options['autoincrement']) |
|
261 | + && !empty($options['notnull']) |
|
262 | + ) { |
|
263 | + $options['primary'] = true; |
|
264 | + } |
|
265 | 265 | |
266 | - $table->addColumn($name, $type, $options); |
|
267 | - if (!empty($options['primary']) && $options['primary']) { |
|
268 | - $table->setPrimaryKey(array($name)); |
|
269 | - } |
|
270 | - } |
|
271 | - } |
|
266 | + $table->addColumn($name, $type, $options); |
|
267 | + if (!empty($options['primary']) && $options['primary']) { |
|
268 | + $table->setPrimaryKey(array($name)); |
|
269 | + } |
|
270 | + } |
|
271 | + } |
|
272 | 272 | |
273 | - /** |
|
274 | - * @param \Doctrine\DBAL\Schema\Table $table |
|
275 | - * @param \SimpleXMLElement $xml |
|
276 | - * @throws \DomainException |
|
277 | - */ |
|
278 | - private function loadIndex($table, $xml) { |
|
279 | - $name = null; |
|
280 | - $fields = array(); |
|
281 | - foreach ($xml->children() as $child) { |
|
282 | - /** |
|
283 | - * @var \SimpleXMLElement $child |
|
284 | - */ |
|
285 | - switch ($child->getName()) { |
|
286 | - case 'name': |
|
287 | - $name = (string)$child; |
|
288 | - break; |
|
289 | - case 'primary': |
|
290 | - $primary = $this->asBool($child); |
|
291 | - break; |
|
292 | - case 'unique': |
|
293 | - $unique = $this->asBool($child); |
|
294 | - break; |
|
295 | - case 'field': |
|
296 | - foreach ($child->children() as $field) { |
|
297 | - /** |
|
298 | - * @var \SimpleXMLElement $field |
|
299 | - */ |
|
300 | - switch ($field->getName()) { |
|
301 | - case 'name': |
|
302 | - $field_name = (string)$field; |
|
303 | - $field_name = $this->platform->quoteIdentifier($field_name); |
|
304 | - $fields[] = $field_name; |
|
305 | - break; |
|
306 | - case 'sorting': |
|
307 | - break; |
|
308 | - default: |
|
309 | - throw new \DomainException('Unknown element: ' . $field->getName()); |
|
273 | + /** |
|
274 | + * @param \Doctrine\DBAL\Schema\Table $table |
|
275 | + * @param \SimpleXMLElement $xml |
|
276 | + * @throws \DomainException |
|
277 | + */ |
|
278 | + private function loadIndex($table, $xml) { |
|
279 | + $name = null; |
|
280 | + $fields = array(); |
|
281 | + foreach ($xml->children() as $child) { |
|
282 | + /** |
|
283 | + * @var \SimpleXMLElement $child |
|
284 | + */ |
|
285 | + switch ($child->getName()) { |
|
286 | + case 'name': |
|
287 | + $name = (string)$child; |
|
288 | + break; |
|
289 | + case 'primary': |
|
290 | + $primary = $this->asBool($child); |
|
291 | + break; |
|
292 | + case 'unique': |
|
293 | + $unique = $this->asBool($child); |
|
294 | + break; |
|
295 | + case 'field': |
|
296 | + foreach ($child->children() as $field) { |
|
297 | + /** |
|
298 | + * @var \SimpleXMLElement $field |
|
299 | + */ |
|
300 | + switch ($field->getName()) { |
|
301 | + case 'name': |
|
302 | + $field_name = (string)$field; |
|
303 | + $field_name = $this->platform->quoteIdentifier($field_name); |
|
304 | + $fields[] = $field_name; |
|
305 | + break; |
|
306 | + case 'sorting': |
|
307 | + break; |
|
308 | + default: |
|
309 | + throw new \DomainException('Unknown element: ' . $field->getName()); |
|
310 | 310 | |
311 | - } |
|
312 | - } |
|
313 | - break; |
|
314 | - default: |
|
315 | - throw new \DomainException('Unknown element: ' . $child->getName()); |
|
311 | + } |
|
312 | + } |
|
313 | + break; |
|
314 | + default: |
|
315 | + throw new \DomainException('Unknown element: ' . $child->getName()); |
|
316 | 316 | |
317 | - } |
|
318 | - } |
|
319 | - if (!empty($fields)) { |
|
320 | - if (isset($primary) && $primary) { |
|
321 | - if ($table->hasPrimaryKey()) { |
|
322 | - return; |
|
323 | - } |
|
324 | - $table->setPrimaryKey($fields, $name); |
|
325 | - } else { |
|
326 | - if (isset($unique) && $unique) { |
|
327 | - $table->addUniqueIndex($fields, $name); |
|
328 | - } else { |
|
329 | - $table->addIndex($fields, $name); |
|
330 | - } |
|
331 | - } |
|
332 | - } else { |
|
333 | - throw new \DomainException('Empty index definition: ' . $name . ' options:' . print_r($fields, true)); |
|
334 | - } |
|
335 | - } |
|
317 | + } |
|
318 | + } |
|
319 | + if (!empty($fields)) { |
|
320 | + if (isset($primary) && $primary) { |
|
321 | + if ($table->hasPrimaryKey()) { |
|
322 | + return; |
|
323 | + } |
|
324 | + $table->setPrimaryKey($fields, $name); |
|
325 | + } else { |
|
326 | + if (isset($unique) && $unique) { |
|
327 | + $table->addUniqueIndex($fields, $name); |
|
328 | + } else { |
|
329 | + $table->addIndex($fields, $name); |
|
330 | + } |
|
331 | + } |
|
332 | + } else { |
|
333 | + throw new \DomainException('Empty index definition: ' . $name . ' options:' . print_r($fields, true)); |
|
334 | + } |
|
335 | + } |
|
336 | 336 | |
337 | - /** |
|
338 | - * @param \SimpleXMLElement|string $xml |
|
339 | - * @return bool |
|
340 | - */ |
|
341 | - private function asBool($xml) { |
|
342 | - $result = (string)$xml; |
|
343 | - if ($result == 'true') { |
|
344 | - $result = true; |
|
345 | - } elseif ($result == 'false') { |
|
346 | - $result = false; |
|
347 | - } |
|
348 | - return (bool)$result; |
|
349 | - } |
|
337 | + /** |
|
338 | + * @param \SimpleXMLElement|string $xml |
|
339 | + * @return bool |
|
340 | + */ |
|
341 | + private function asBool($xml) { |
|
342 | + $result = (string)$xml; |
|
343 | + if ($result == 'true') { |
|
344 | + $result = true; |
|
345 | + } elseif ($result == 'false') { |
|
346 | + $result = false; |
|
347 | + } |
|
348 | + return (bool)$result; |
|
349 | + } |
|
350 | 350 | |
351 | 351 | } |
@@ -7,23 +7,23 @@ |
||
7 | 7 | |
8 | 8 | class RootCollection extends AbstractPrincipalCollection { |
9 | 9 | |
10 | - /** |
|
11 | - * This method returns a node for a principal. |
|
12 | - * |
|
13 | - * The passed array contains principal information, and is guaranteed to |
|
14 | - * at least contain a uri item. Other properties may or may not be |
|
15 | - * supplied by the authentication backend. |
|
16 | - * |
|
17 | - * @param array $principalInfo |
|
18 | - * @return AvatarHome |
|
19 | - */ |
|
20 | - public function getChildForPrincipal(array $principalInfo) { |
|
21 | - $avatarManager = \OC::$server->getAvatarManager(); |
|
22 | - return new AvatarHome($principalInfo, $avatarManager); |
|
23 | - } |
|
10 | + /** |
|
11 | + * This method returns a node for a principal. |
|
12 | + * |
|
13 | + * The passed array contains principal information, and is guaranteed to |
|
14 | + * at least contain a uri item. Other properties may or may not be |
|
15 | + * supplied by the authentication backend. |
|
16 | + * |
|
17 | + * @param array $principalInfo |
|
18 | + * @return AvatarHome |
|
19 | + */ |
|
20 | + public function getChildForPrincipal(array $principalInfo) { |
|
21 | + $avatarManager = \OC::$server->getAvatarManager(); |
|
22 | + return new AvatarHome($principalInfo, $avatarManager); |
|
23 | + } |
|
24 | 24 | |
25 | - public function getName() { |
|
26 | - return 'avatars'; |
|
27 | - } |
|
25 | + public function getName() { |
|
26 | + return 'avatars'; |
|
27 | + } |
|
28 | 28 | |
29 | 29 | } |
@@ -33,87 +33,87 @@ |
||
33 | 33 | |
34 | 34 | class CalDAVRemoveEmptyValue implements IRepairStep { |
35 | 35 | |
36 | - /** @var IDBConnection */ |
|
37 | - private $db; |
|
38 | - |
|
39 | - /** @var CalDavBackend */ |
|
40 | - private $calDavBackend; |
|
41 | - |
|
42 | - /** @var ILogger */ |
|
43 | - private $logger; |
|
44 | - |
|
45 | - /** |
|
46 | - * @param IDBConnection $db |
|
47 | - * @param CalDavBackend $calDavBackend |
|
48 | - * @param ILogger $logger |
|
49 | - */ |
|
50 | - public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) { |
|
51 | - $this->db = $db; |
|
52 | - $this->calDavBackend = $calDavBackend; |
|
53 | - $this->logger = $logger; |
|
54 | - } |
|
55 | - |
|
56 | - public function getName() { |
|
57 | - return 'Fix broken values of calendar objects'; |
|
58 | - } |
|
59 | - |
|
60 | - public function run(IOutput $output) { |
|
61 | - $pattern = ';VALUE=:'; |
|
62 | - $count = $warnings = 0; |
|
63 | - |
|
64 | - $objects = $this->getInvalidObjects($pattern); |
|
65 | - |
|
66 | - $output->startProgress(count($objects)); |
|
67 | - foreach ($objects as $row) { |
|
68 | - $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
69 | - $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
70 | - |
|
71 | - if ($data !== $calObject['calendardata']) { |
|
72 | - $output->advance(); |
|
73 | - |
|
74 | - try { |
|
75 | - $this->calDavBackend->getDenormalizedData($data); |
|
76 | - } catch (InvalidDataException $e) { |
|
77 | - $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
78 | - 'app' => 'dav', |
|
79 | - 'cal' => (int)$row['calendarid'], |
|
80 | - 'uri' => $row['uri'], |
|
81 | - ]); |
|
82 | - $warnings++; |
|
83 | - continue; |
|
84 | - } |
|
85 | - |
|
86 | - $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
87 | - $count++; |
|
88 | - } |
|
89 | - } |
|
90 | - $output->finishProgress(); |
|
91 | - |
|
92 | - if ($warnings > 0) { |
|
93 | - $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
94 | - } |
|
95 | - if ($count > 0) { |
|
96 | - $output->info(sprintf('Updated %d events', $count)); |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - protected function getInvalidObjects($pattern) { |
|
101 | - $query = $this->db->getQueryBuilder(); |
|
102 | - $query->select(['calendarid', 'uri']) |
|
103 | - ->from('calendarobjects') |
|
104 | - ->where($query->expr()->like( |
|
105 | - 'calendardata', |
|
106 | - $query->createNamedParameter( |
|
107 | - '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
108 | - IQueryBuilder::PARAM_STR |
|
109 | - ), |
|
110 | - IQueryBuilder::PARAM_STR |
|
111 | - )); |
|
112 | - |
|
113 | - $result = $query->execute(); |
|
114 | - $rows = $result->fetchAll(); |
|
115 | - $result->closeCursor(); |
|
116 | - |
|
117 | - return $rows; |
|
118 | - } |
|
36 | + /** @var IDBConnection */ |
|
37 | + private $db; |
|
38 | + |
|
39 | + /** @var CalDavBackend */ |
|
40 | + private $calDavBackend; |
|
41 | + |
|
42 | + /** @var ILogger */ |
|
43 | + private $logger; |
|
44 | + |
|
45 | + /** |
|
46 | + * @param IDBConnection $db |
|
47 | + * @param CalDavBackend $calDavBackend |
|
48 | + * @param ILogger $logger |
|
49 | + */ |
|
50 | + public function __construct(IDBConnection $db, CalDavBackend $calDavBackend, ILogger $logger) { |
|
51 | + $this->db = $db; |
|
52 | + $this->calDavBackend = $calDavBackend; |
|
53 | + $this->logger = $logger; |
|
54 | + } |
|
55 | + |
|
56 | + public function getName() { |
|
57 | + return 'Fix broken values of calendar objects'; |
|
58 | + } |
|
59 | + |
|
60 | + public function run(IOutput $output) { |
|
61 | + $pattern = ';VALUE=:'; |
|
62 | + $count = $warnings = 0; |
|
63 | + |
|
64 | + $objects = $this->getInvalidObjects($pattern); |
|
65 | + |
|
66 | + $output->startProgress(count($objects)); |
|
67 | + foreach ($objects as $row) { |
|
68 | + $calObject = $this->calDavBackend->getCalendarObject((int)$row['calendarid'], $row['uri']); |
|
69 | + $data = preg_replace('/' . $pattern . '/', ':', $calObject['calendardata']); |
|
70 | + |
|
71 | + if ($data !== $calObject['calendardata']) { |
|
72 | + $output->advance(); |
|
73 | + |
|
74 | + try { |
|
75 | + $this->calDavBackend->getDenormalizedData($data); |
|
76 | + } catch (InvalidDataException $e) { |
|
77 | + $this->logger->info('Calendar object for calendar {cal} with uri {uri} still invalid', [ |
|
78 | + 'app' => 'dav', |
|
79 | + 'cal' => (int)$row['calendarid'], |
|
80 | + 'uri' => $row['uri'], |
|
81 | + ]); |
|
82 | + $warnings++; |
|
83 | + continue; |
|
84 | + } |
|
85 | + |
|
86 | + $this->calDavBackend->updateCalendarObject((int)$row['calendarid'], $row['uri'], $data); |
|
87 | + $count++; |
|
88 | + } |
|
89 | + } |
|
90 | + $output->finishProgress(); |
|
91 | + |
|
92 | + if ($warnings > 0) { |
|
93 | + $output->warning(sprintf('%d events could not be updated, see log file for more information', $warnings)); |
|
94 | + } |
|
95 | + if ($count > 0) { |
|
96 | + $output->info(sprintf('Updated %d events', $count)); |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + protected function getInvalidObjects($pattern) { |
|
101 | + $query = $this->db->getQueryBuilder(); |
|
102 | + $query->select(['calendarid', 'uri']) |
|
103 | + ->from('calendarobjects') |
|
104 | + ->where($query->expr()->like( |
|
105 | + 'calendardata', |
|
106 | + $query->createNamedParameter( |
|
107 | + '%' . $this->db->escapeLikeParameter($pattern) . '%', |
|
108 | + IQueryBuilder::PARAM_STR |
|
109 | + ), |
|
110 | + IQueryBuilder::PARAM_STR |
|
111 | + )); |
|
112 | + |
|
113 | + $result = $query->execute(); |
|
114 | + $rows = $result->fetchAll(); |
|
115 | + $result->closeCursor(); |
|
116 | + |
|
117 | + return $rows; |
|
118 | + } |
|
119 | 119 | } |
@@ -27,21 +27,21 @@ |
||
27 | 27 | |
28 | 28 | class CompFilter implements XmlDeserializable { |
29 | 29 | |
30 | - /** |
|
31 | - * @param Reader $reader |
|
32 | - * @throws BadRequest |
|
33 | - * @return string |
|
34 | - */ |
|
35 | - static function xmlDeserialize(Reader $reader) { |
|
36 | - $att = $reader->parseAttributes(); |
|
37 | - $componentName = $att['name']; |
|
30 | + /** |
|
31 | + * @param Reader $reader |
|
32 | + * @throws BadRequest |
|
33 | + * @return string |
|
34 | + */ |
|
35 | + static function xmlDeserialize(Reader $reader) { |
|
36 | + $att = $reader->parseAttributes(); |
|
37 | + $componentName = $att['name']; |
|
38 | 38 | |
39 | - $reader->parseInnerTree(); |
|
39 | + $reader->parseInnerTree(); |
|
40 | 40 | |
41 | - if (!is_string($componentName)) { |
|
42 | - throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | - } |
|
41 | + if (!is_string($componentName)) { |
|
42 | + throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}comp-filter requires a valid name attribute'); |
|
43 | + } |
|
44 | 44 | |
45 | - return $componentName; |
|
46 | - } |
|
45 | + return $componentName; |
|
46 | + } |
|
47 | 47 | } |