aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav
diff options
context:
space:
mode:
authorbrad2014 <brad2014@users.noreply.github.com>2019-07-17 16:47:15 -0700
committerbrad2014 <brad2014@users.noreply.github.com>2019-07-31 12:55:50 -0700
commit8d8bcea1d8cb7328e898654874348a64afc773e4 (patch)
treef2f17e83fe5da329476ce4a41548c2f7b26d108c /apps/dav
parent1a2923996059aadbcd69000a85d51304ec9a9f8e (diff)
downloadnextcloud-server-8d8bcea1d8cb7328e898654874348a64afc773e4.tar.gz
nextcloud-server-8d8bcea1d8cb7328e898654874348a64afc773e4.zip
Move dav.invitation_link_recipients from getSystemValue to getAppValue
Per @georgehrke change request for PR #12392, instead of setting dav.invitation_link_recipients in the system config.php file, we set it in the database table oc_appconfig. Furthermore, the value of the config variable is always a string: 'yes' to include links in imip mail, 'no' to exclude them, or a comma-separated list of email addresses and/or domains for which they should be included. If not specified in oc_appconfig, the default is 'yes'. Signed-off-by: brad2014 <brad2014@users.noreply.github.com>
Diffstat (limited to 'apps/dav')
-rw-r--r--apps/dav/lib/CalDAV/Schedule/IMipPlugin.php24
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php30
2 files changed, 26 insertions, 28 deletions
diff --git a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
index 7035d3c780f..56b3ab04ddc 100644
--- a/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
+++ b/apps/dav/lib/CalDAV/Schedule/IMipPlugin.php
@@ -249,28 +249,26 @@ class IMipPlugin extends SabreIMipPlugin {
** nextcloud server, to recipients who can access the nextcloud server via
** their internet/intranet. Issue #12156
**
+ ** The app setting is stored in the appconfig database table.
+ **
** For nextcloud servers accessible to the public internet, the default
- ** "dav.invitation_link_recipients" value "true" (all recipients) is appropriate.
+ ** "invitation_link_recipients" value "yes" (all recipients) is appropriate.
**
** When the nextcloud server is restricted behind a firewall, accessible
** only via an internal network or via vpn, you can set "dav.invitation_link_recipients"
- ** to the email address or email domain, or array of addresses or domains,
+ ** to the email address or email domain, or comma separated list of addresses or domains,
** of recipients who can access the server.
**
- ** To deliver URL's always, set invitation_link_recipients to boolean "true".
- ** To suppress URL's entirely, set invitation_link_recipients to boolean "false".
+ ** To always deliver URLs, set invitation_link_recipients to "yes".
+ ** To suppress URLs entirely, set invitation_link_recipients to boolean "no".
*/
$recipientDomain = substr(strrchr($recipient, "@"), 1);
- $invitationLinkRecipients = $this->config->getSystemValue('dav.invitation_link_recipients', true);
- if (is_array($invitationLinkRecipients)) {
- $invitationLinkRecipients = array_map('strtolower', $invitationLinkRecipients); // for case insensitive in_array
- }
- if ($invitationLinkRecipients === true
- || (is_string($invitationLinkRecipients) && strcasecmp($recipient, $invitationLinkRecipients) === 0)
- || (is_string($invitationLinkRecipients) && strcasecmp($recipientDomain, $invitationLinkRecipients) === 0)
- || (is_array($invitationLinkRecipients) && in_array(strtolower($recipient), $invitationLinkRecipients))
- || (is_array($invitationLinkRecipients) && in_array(strtolower($recipientDomain), $invitationLinkRecipients))) {
+ $invitationLinkRecipients = explode(',', preg_replace('/\s+/', '', strtolower($this->config->getAppValue('dav', 'invitation_link_recipients', 'yes'))));
+
+ if (strcmp('yes', $invitationLinkRecipients[0]) === 0
+ || in_array(strtolower($recipient), $invitationLinkRecipients)
+ || in_array(strtolower($recipientDomain), $invitationLinkRecipients)) {
$this->addResponseButtons($template, $l10n, $iTipMessage, $lastOccurrence);
}
}
diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
index 84da1d2727c..967f3a51481 100644
--- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
@@ -96,9 +96,9 @@ class IMipPluginTest extends TestCase {
public function testDelivery() {
$this->config
- ->method('getSystemValue')
- ->with('dav.invitation_link_recipients', true)
- ->willReturn(true);
+ ->method('getAppValue')
+ ->with('dav', 'invitation_link_recipients', 'yes')
+ ->willReturn('yes');
$message = $this->_testMessage();
$this->_expectSend();
@@ -108,9 +108,9 @@ class IMipPluginTest extends TestCase {
public function testFailedDelivery() {
$this->config
- ->method('getSystemValue')
- ->with('dav.invitation_link_recipients', true)
- ->willReturn(true);
+ ->method('getAppValue')
+ ->with('dav', 'invitation_link_recipients', 'yes')
+ ->willReturn('yes');
$message = $this->_testMessage();
$this->mailer
@@ -127,9 +127,9 @@ class IMipPluginTest extends TestCase {
public function testNoMessageSendForPastEvents($veventParams, $expectsMail) {
$this->config
- ->method('getSystemValue')
- ->with('dav.invitation_link_recipients', true)
- ->willReturn(true);
+ ->method('getAppValue')
+ ->with('dav', 'invitation_link_recipients', 'yes')
+ ->willReturn('yes');
$message = $this->_testMessage( $veventParams );
@@ -167,8 +167,8 @@ class IMipPluginTest extends TestCase {
$this->_expectSend($recipient, true, $has_buttons);
$this->config
- ->method('getSystemValue')
- ->with('dav.invitation_link_recipients', true)
+ ->method('getAppValue')
+ ->with('dav', 'invitation_link_recipients', 'yes')
->willReturn($config_setting);
$this->plugin->schedule($message);
@@ -178,13 +178,13 @@ class IMipPluginTest extends TestCase {
public function dataIncludeResponseButtons() {
return [
// dav.invitation_link_recipients, recipient, $has_buttons
- [ true, 'joe@internal.com', true],
+ [ 'yes', 'joe@internal.com', true],
[ 'joe@internal.com', 'joe@internal.com', true],
[ 'internal.com', 'joe@internal.com', true],
- [ ['pete@otherinternal.com', 'internal.com'], 'joe@internal.com', true],
- [ false, 'joe@internal.com', false],
+ [ 'pete@otherinternal.com,internal.com', 'joe@internal.com', true],
+ [ 'no', 'joe@internal.com', false],
[ 'internal.com', 'joe@external.com', false],
- [ ['jane@otherinternal.com', 'internal.com'], 'joe@otherinternal.com', false],
+ [ 'jane@otherinternal.com,internal.com', 'joe@otherinternal.com', false],
];
}