Skip to content

Commit 3724192

Browse files
committed
Separate Settings implementation for <NC20 and >NC20
To remove and replace as soon as NC19 is out of support on Forms. Signed-off-by: Jonas Rittershofer <jotoeri@users.noreply.github.com>
1 parent d3fea49 commit 3724192

3 files changed

Lines changed: 205 additions & 87 deletions

File tree

lib/Activity/Settings/FormsActivitySettings.php

Lines changed: 10 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -23,93 +23,16 @@
2323

2424
namespace OCA\Forms\Activity\Settings;
2525

26-
use OCP\Activity\ISetting;
27-
use OCP\IL10N;
28-
29-
// TODO Move to extend OCP\Activity\ActivitySettings as soon as NC19 is out of support! Further remove Stream Methods then.
30-
abstract class FormsActivitySettings implements ISetting {
31-
protected $appName;
32-
33-
/** @var IL10N */
34-
protected $l10n;
35-
36-
public function __construct(string $appName,
37-
IL10N $l10n) {
38-
$this->appName = $appName;
39-
$this->l10n = $l10n;
40-
}
41-
42-
/**
43-
* Settings Group ID
44-
* @return string
45-
*/
46-
public function getGroupIdentifier(): string {
47-
return $this->appName;
48-
}
49-
50-
/**
51-
* Human Readable Group Title
52-
* @return string
53-
*/
54-
public function getGroupName(): string {
55-
return $this->l10n->t('Forms');
56-
}
57-
58-
/**
59-
* Priority of the Setting (0-100)
60-
* Using this as Forms-Basepriority
61-
* @return int
62-
*/
63-
public function getPriority(): int {
64-
return 60;
65-
}
66-
67-
/**
68-
* User can change Notification
69-
* @return bool
70-
*/
71-
public function canChangeNotification(): bool {
72-
return true;
73-
}
74-
75-
/**
76-
* Notification enabled by default
77-
*/
78-
public function isDefaultEnabledNotification(): bool {
79-
return true;
80-
}
81-
82-
/**
83-
* User can change Mail
84-
* @return bool
85-
*/
86-
public function canChangeMail(): bool {
87-
return true;
88-
}
89-
90-
/**
91-
* Mail disabled by default
92-
* @return bool
93-
*/
94-
public function isDefaultEnabledMail(): bool {
95-
return false;
96-
}
97-
98-
/**
99-
* User can change Stream
100-
* TODO REMOVE when NC19 out of support.
101-
* @return bool
102-
*/
103-
public function canChangeStream(): bool {
104-
return true;
26+
/** TODO
27+
* Move to only have the new version, as soon as Forms minversion is set to NC20
28+
* - Just rename FormsActivitySettings20 to FormsActivitySettings
29+
* - Delete this file and FormsActivitySettingsLegacy
30+
*/
31+
$version = \OCP\Util::getVersion()[0];
32+
if ($version >= 20) {
33+
abstract class FormsActivitySettings extends FormsActivitySettings20 {
10534
}
106-
107-
/**
108-
* Stream enabled by default
109-
* TODO REMOVE when NC19 out of support.
110-
* @return bool
111-
*/
112-
public function isDefaultEnabledStream(): bool {
113-
return true;
35+
} else {
36+
abstract class FormsActivitySettings extends FormsActivitySettingsLegacy {
11437
}
11538
}
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2021 Jonas Rittershofer <jotoeri@users.noreply.github.com>
4+
*
5+
* @author Jonas Rittershofer <jotoeri@users.noreply.github.com>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace OCA\Forms\Activity\Settings;
25+
26+
use OCP\Activity\ActivitySettings;
27+
use OCP\IL10N;
28+
29+
abstract class FormsActivitySettings20 extends ActivitySettings {
30+
protected $appName;
31+
32+
/** @var IL10N */
33+
protected $l10n;
34+
35+
public function __construct(string $appName,
36+
IL10N $l10n) {
37+
$this->appName = $appName;
38+
$this->l10n = $l10n;
39+
}
40+
41+
/**
42+
* Settings Group ID
43+
* @return string
44+
*/
45+
public function getGroupIdentifier(): string {
46+
return $this->appName;
47+
}
48+
49+
/**
50+
* Human Readable Group Title
51+
* @return string
52+
*/
53+
public function getGroupName(): string {
54+
return $this->l10n->t('Forms');
55+
}
56+
57+
/**
58+
* Priority of the Setting (0-100)
59+
* Using this as Forms-Basepriority
60+
* @return int
61+
*/
62+
public function getPriority(): int {
63+
return 60;
64+
}
65+
66+
/**
67+
* User can change Notification
68+
* @return bool
69+
*/
70+
public function canChangeNotification(): bool {
71+
return true;
72+
}
73+
74+
/**
75+
* Notification enabled by default
76+
*/
77+
public function isDefaultEnabledNotification(): bool {
78+
return true;
79+
}
80+
81+
/**
82+
* User can change Mail
83+
* @return bool
84+
*/
85+
public function canChangeMail(): bool {
86+
return true;
87+
}
88+
89+
/**
90+
* Mail disabled by default
91+
* @return bool
92+
*/
93+
public function isDefaultEnabledMail(): bool {
94+
return false;
95+
}
96+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php
2+
/**
3+
* @copyright Copyright (c) 2021 Jonas Rittershofer <jotoeri@users.noreply.github.com>
4+
*
5+
* @author Jonas Rittershofer <jotoeri@users.noreply.github.com>
6+
*
7+
* @license GNU AGPL version 3 or any later version
8+
*
9+
* This program is free software: you can redistribute it and/or modify
10+
* it under the terms of the GNU Affero General Public License as
11+
* published by the Free Software Foundation, either version 3 of the
12+
* License, or (at your option) any later version.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU Affero General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Affero General Public License
20+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21+
*
22+
*/
23+
24+
namespace OCA\Forms\Activity\Settings;
25+
26+
use OCP\Activity\ISetting;
27+
use OCP\IL10N;
28+
29+
abstract class FormsActivitySettingsLegacy implements ISetting {
30+
protected $appName;
31+
32+
/** @var IL10N */
33+
protected $l10n;
34+
35+
public function __construct(string $appName,
36+
IL10N $l10n) {
37+
$this->appName = $appName;
38+
$this->l10n = $l10n;
39+
}
40+
41+
/**
42+
* Settings Group ID
43+
* @return string
44+
*/
45+
public function getGroupIdentifier(): string {
46+
return $this->appName;
47+
}
48+
49+
/**
50+
* Human Readable Group Title
51+
* @return string
52+
*/
53+
public function getGroupName(): string {
54+
return $this->l10n->t('Forms');
55+
}
56+
57+
/**
58+
* Priority of the Setting (0-100)
59+
* Using this as Forms-Basepriority
60+
* @return int
61+
*/
62+
public function getPriority(): int {
63+
return 60;
64+
}
65+
66+
/**
67+
* User can change Mail
68+
* @return bool
69+
*/
70+
public function canChangeMail(): bool {
71+
return true;
72+
}
73+
74+
/**
75+
* Mail disabled by default
76+
* @return bool
77+
*/
78+
public function isDefaultEnabledMail(): bool {
79+
return false;
80+
}
81+
82+
/**
83+
* User can change Stream
84+
* TODO REMOVE when NC19 out of support.
85+
* @return bool
86+
*/
87+
public function canChangeStream(): bool {
88+
return true;
89+
}
90+
91+
/**
92+
* Stream enabled by default
93+
* TODO REMOVE when NC19 out of support.
94+
* @return bool
95+
*/
96+
public function isDefaultEnabledStream(): bool {
97+
return true;
98+
}
99+
}

0 commit comments

Comments
 (0)