Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable publishing when Sharing by link is disabled #526

Merged
merged 3 commits into from
Jul 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions controller/viewcontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,15 @@ private function getTemplateParams() {
$appVersion = $this->config->getAppValue($this->appName, 'installed_version');
$isIE = $this->request->isUserAgent([Request::USER_AGENT_IE]);
$defaultColor = $this->config->getAppValue('theming', 'color', '#0082C9');
$canSharePublicLink = $this->config->getAppValue('core', 'shareapi_allow_links', 'yes');

return [
'appVersion' => $appVersion,
'isIE' => $isIE,
'defaultColor' => $defaultColor,
'shareeCanEditShares' => $shareeCanEditShares ? 'yes' : 'no',
'shareeCanEditCalendarProperties' => $shareeCanEditCalendarProperties ? 'yes' : 'no',
'canSharePublicLink' => $canSharePublicLink,
];
}

Expand Down
1 change: 1 addition & 0 deletions js/app/controllers/calendarlistcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ app.controller('CalendarListController', ['$scope', '$rootScope', '$window', 'Ha
$scope.publicdavdesc = t('calendar', 'CalDAV address for clients');

$scope.isSharingAPI = isSharingAPI;
$scope.canSharePublicLink = constants.canSharePublicLink;

$scope.$watchCollection('calendars', function(newCalendars, oldCalendars) {
newCalendars = newCalendars || [];
Expand Down
2 changes: 2 additions & 0 deletions js/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ app.config(['$provide', '$httpProvider',
const publicSharingToken = angular.element('#fullcalendar').attr('data-publicSharingToken');
const shareeCanEditShares = angular.element('#fullcalendar').attr('data-shareeCanEditShares') === 'yes';
const shareeCanEditCalendarProperties = angular.element('#fullcalendar').attr('data-shareeCanEditCalendarProperties') === 'yes';
const canSharePublicLink = angular.element('#fullcalendar').attr('data-canSharePublicLink') === 'yes';
$provide.constant('constants', {
initialView,
emailAddress,
Expand All @@ -79,6 +80,7 @@ app.config(['$provide', '$httpProvider',
publicSharingToken,
shareeCanEditShares,
shareeCanEditCalendarProperties,
canSharePublicLink,
SHARE_TYPE_USER: 0,
SHARE_TYPE_GROUP: 1
});
Expand Down
2 changes: 1 addition & 1 deletion templates/part.calendarlist.item.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ class="checkbox"
</span>
</li>
</ul>
<div class="publishing" ng-if="item.calendar.isPublishable()">
<div class="publishing" ng-if="item.calendar.isPublishable() && canSharePublicLink">
<input type="checkbox" name="publish"
class="checkbox"
id="checkbox_publish_calendar_{{ $index }}"
Expand Down
1 change: 1 addition & 0 deletions templates/part.fullcalendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class="calendar"
data-publicSharingToken="<?php p($_['token']); ?>"
data-shareeCanEditShares="<?php p($_['shareeCanEditShares']); ?>"
data-shareeCanEditCalendarProperties="<?php p($_['shareeCanEditCalendarProperties']); ?>"
data-canSharePublicLink="<?php p($_['canSharePublicLink']); ?>"
fc
id="fullcalendar">
</div>
52 changes: 41 additions & 11 deletions tests/php/controller/viewcontrollerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ public function testIndex($serverVersion, $isIE, $shareeActions, $shareeCanEdit)
->with('theming', 'color', '#0082C9')
->will($this->returnValue('#ff00ff'));

$this->config->expects($this->at(3))
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('yes'));

$this->userSession->expects($this->once())
->method('getUser')
->will($this->returnValue($this->dummyUser));
Expand All @@ -94,22 +99,22 @@ public function testIndex($serverVersion, $isIE, $shareeActions, $shareeCanEdit)
->method('getEMailAddress')
->will($this->returnValue('[email protected]'));

$this->config->expects($this->at(3))
$this->config->expects($this->at(4))
->method('getUserValue')
->with('user123', $this->appName, 'currentView', null)
->will($this->returnValue('someView'));

$this->config->expects($this->at(4))
$this->config->expects($this->at(5))
->method('getUserValue')
->with('user123', $this->appName, 'skipPopover', 'no')
->will($this->returnValue('someSkipPopoverValue'));

$this->config->expects($this->at(5))
$this->config->expects($this->at(6))
->method('getUserValue')
->with('user123', $this->appName, 'showWeekNr', 'no')
->will($this->returnValue('someShowWeekNrValue'));

$this->config->expects($this->at(6))
$this->config->expects($this->at(7))
->method('getUserValue')
->with('user123', $this->appName, 'firstRun', null)
->will($this->returnValue('someFirstRunValue'));
Expand All @@ -124,6 +129,7 @@ public function testIndex($serverVersion, $isIE, $shareeActions, $shareeCanEdit)
'skipPopover' => 'someSkipPopoverValue',
'weekNumbers' => 'someShowWeekNrValue',
'firstRun' => 'someFirstRunValue',
'canSharePublicLink' => 'yes',
'defaultColor' => '#ff00ff',
'isPublic' => false,
'isEmbedded' => false,
Expand Down Expand Up @@ -178,21 +184,26 @@ public function testIndexNoMonthFallback() {
->will($this->returnValue('#ff00ff'));

$this->config->expects($this->at(3))
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('no'));

$this->config->expects($this->at(4))
->method('getUserValue')
->with('user123', $this->appName, 'currentView', null)
->will($this->returnValue(null));

$this->config->expects($this->at(4))
$this->config->expects($this->at(5))
->method('getUserValue')
->with('user123', $this->appName, 'skipPopover', 'no')
->will($this->returnValue('someSkipPopoverValue'));

$this->config->expects($this->at(5))
$this->config->expects($this->at(6))
->method('getUserValue')
->with('user123', $this->appName, 'showWeekNr', 'no')
->will($this->returnValue('someShowWeekNrValue'));

$this->config->expects($this->at(6))
$this->config->expects($this->at(7))
->method('getUserValue')
->with('user123', $this->appName, 'firstRun', null)
->will($this->returnValue('someFirstRunValue'));
Expand All @@ -214,6 +225,7 @@ public function testIndexNoMonthFallback() {
'token' => '',
'shareeCanEditShares' => 'no',
'shareeCanEditCalendarProperties' => 'yes',
'canSharePublicLink' => 'no'
], $actual->getParams());
$this->assertEquals('main', $actual->getTemplateName());
}
Expand Down Expand Up @@ -255,27 +267,32 @@ public function testIndexFirstRunDetection($initialView, $expectedFirstRun, $exp
->will($this->returnValue('#ff00ff'));

$this->config->expects($this->at(3))
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('no'));

$this->config->expects($this->at(4))
->method('getUserValue')
->with('user123', $this->appName, 'currentView', null)
->will($this->returnValue($initialView));

$this->config->expects($this->at(4))
$this->config->expects($this->at(5))
->method('getUserValue')
->with('user123', $this->appName, 'skipPopover', 'no')
->will($this->returnValue('someSkipPopoverValue'));

$this->config->expects($this->at(5))
$this->config->expects($this->at(6))
->method('getUserValue')
->with('user123', $this->appName, 'showWeekNr', 'no')
->will($this->returnValue('someShowWeekNrValue'));

$this->config->expects($this->at(6))
$this->config->expects($this->at(7))
->method('getUserValue')
->with('user123', $this->appName, 'firstRun', null)
->will($this->returnValue(null));

if ($expectsSetRequest) {
$this->config->expects($this->at(7))
$this->config->expects($this->at(8))
->method('setUserValue')
->with('user123');
}
Expand All @@ -297,6 +314,7 @@ public function testIndexFirstRunDetection($initialView, $expectedFirstRun, $exp
'token' => '',
'shareeCanEditShares' => 'yes',
'shareeCanEditCalendarProperties' => 'no',
'canSharePublicLink' => 'no'
], $actual->getParams());
$this->assertEquals('main', $actual->getTemplateName());
}
Expand Down Expand Up @@ -332,6 +350,11 @@ public function testPublicIndex($serverVersion, $isIE, $shareeActions, $shareeCa
->with('theming', 'color', '#0082C9')
->will($this->returnValue('#ff00ff'));

$this->config->expects($this->at(3))
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('no'));

$this->request->expects($this->at(1))
->method('getServerProtocol')
->will($this->returnValue('fancy_protocol'));
Expand Down Expand Up @@ -389,6 +412,7 @@ public function testPublicIndex($serverVersion, $isIE, $shareeActions, $shareeCa
'token' => 'fancy_token_123',
'shareeCanEditShares' => $shareeActions,
'shareeCanEditCalendarProperties' => $shareeCanEdit,
'canSharePublicLink' => 'no',
], $actual->getParams());
$this->assertEquals('main', $actual->getTemplateName());
}
Expand Down Expand Up @@ -417,6 +441,11 @@ public function testPublicIndexWithBranding($serverVersion, $isIE, $shareeAction
->with('theming', 'color', '#0082C9')
->will($this->returnValue('#ff00ff'));

$this->config->expects($this->at(3))
->method('getAppValue')
->with('core', 'shareapi_allow_links', 'yes')
->will($this->returnValue('no'));

$this->request->expects($this->at(1))
->method('getServerProtocol')
->will($this->returnValue('fancy_protocol'));
Expand Down Expand Up @@ -474,6 +503,7 @@ public function testPublicIndexWithBranding($serverVersion, $isIE, $shareeAction
'token' => 'fancy_token_123',
'shareeCanEditShares' => $shareeActions,
'shareeCanEditCalendarProperties' => $shareeCanEdit,
'canSharePublicLink' => 'no',
], $actual->getParams());
$this->assertEquals('public', $actual->getTemplateName());
}
Expand Down