diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-02-27 13:44:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-27 13:44:34 +0100 |
commit | 7bc3c2e057c8c265ca7b1aa387dd1ba479690143 (patch) | |
tree | c02f1ec27b8037ef2f604829347e7efe2e3d34ab /lib | |
parent | 01f420c7ac38128c03975d7de7dd20190c4afcc1 (diff) | |
parent | 20ec0344a26faf725762e3b344b66bb45ef1a5a2 (diff) | |
download | nextcloud-server-7bc3c2e057c8c265ca7b1aa387dd1ba479690143.tar.gz nextcloud-server-7bc3c2e057c8c265ca7b1aa387dd1ba479690143.zip |
Merge pull request #7363 from nextcloud/default-share-perms
Let the admin configure the default share permissions
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/Settings/Admin/Sharing.php | 70 | ||||
-rw-r--r-- | lib/private/Settings/Manager.php | 2 | ||||
-rw-r--r-- | lib/private/Template/JSConfigHelper.php | 12 | ||||
-rw-r--r-- | lib/private/TemplateLayout.php | 3 |
4 files changed, 68 insertions, 19 deletions
diff --git a/lib/private/Settings/Admin/Sharing.php b/lib/private/Settings/Admin/Sharing.php index dbdacf78dab..dfc0b11478b 100644 --- a/lib/private/Settings/Admin/Sharing.php +++ b/lib/private/Settings/Admin/Sharing.php @@ -28,7 +28,9 @@ namespace OC\Settings\Admin; use OC\Share\Share; use OCP\AppFramework\Http\TemplateResponse; +use OCP\Constants; use OCP\IConfig; +use OCP\IL10N; use OCP\Settings\ISettings; use OCP\Util; @@ -36,11 +38,15 @@ class Sharing implements ISettings { /** @var IConfig */ private $config; + /** @var IL10N */ + private $l; + /** * @param IConfig $config */ - public function __construct(IConfig $config) { + public function __construct(IConfig $config, IL10N $l) { $this->config = $config; + $this->l = $l; } /** @@ -53,27 +59,59 @@ class Sharing implements ISettings { $parameters = [ // Built-In Sharing - 'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'), - 'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'), - 'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'), - 'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'), - 'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'), - 'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(), - 'onlyShareWithGroupMembers' => Share::shareWithGroupMembersOnly(), - 'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'), - 'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'), - 'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'), - 'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'), - 'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes', - 'shareExcludedGroupsList' => $excludeGroupsList, - 'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null), - 'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'), + 'allowGroupSharing' => $this->config->getAppValue('core', 'shareapi_allow_group_sharing', 'yes'), + 'allowLinks' => $this->config->getAppValue('core', 'shareapi_allow_links', 'yes'), + 'allowPublicUpload' => $this->config->getAppValue('core', 'shareapi_allow_public_upload', 'yes'), + 'allowResharing' => $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes'), + 'allowShareDialogUserEnumeration' => $this->config->getAppValue('core', 'shareapi_allow_share_dialog_user_enumeration', 'yes'), + 'enforceLinkPassword' => Util::isPublicLinkPasswordRequired(), + 'onlyShareWithGroupMembers' => Share::shareWithGroupMembersOnly(), + 'shareAPIEnabled' => $this->config->getAppValue('core', 'shareapi_enabled', 'yes'), + 'shareDefaultExpireDateSet' => $this->config->getAppValue('core', 'shareapi_default_expire_date', 'no'), + 'shareExpireAfterNDays' => $this->config->getAppValue('core', 'shareapi_expire_after_n_days', '7'), + 'shareEnforceExpireDate' => $this->config->getAppValue('core', 'shareapi_enforce_expire_date', 'no'), + 'shareExcludeGroups' => $this->config->getAppValue('core', 'shareapi_exclude_groups', 'no') === 'yes', + 'shareExcludedGroupsList' => $excludeGroupsList, + 'publicShareDisclaimerText' => $this->config->getAppValue('core', 'shareapi_public_link_disclaimertext', null), + 'enableLinkPasswordByDefault' => $this->config->getAppValue('core', 'shareapi_enable_link_password_by_default', 'no'), + 'shareApiDefaultPermissions' => $this->config->getAppValue('core', 'shareapi_default_permissions', Constants::PERMISSION_ALL), + 'shareApiDefaultPermissionsCheckboxes' => $this->getSharePermissionList(), ]; return new TemplateResponse('settings', 'settings/admin/sharing', $parameters, ''); } /** + * get share permission list for template + * + * @return array + */ + private function getSharePermissionList() { + return [ + [ + 'id' => 'cancreate', + 'label' => $this->l->t('Create'), + 'value' => Constants::PERMISSION_CREATE + ], + [ + 'id' => 'canupdate', + 'label' => $this->l->t('Change'), + 'value' => Constants::PERMISSION_UPDATE + ], + [ + 'id' => 'candelete', + 'label' => $this->l->t('Delete'), + 'value' => Constants::PERMISSION_DELETE + ], + [ + 'id' => 'canshare', + 'label' => $this->l->t('Share'), + 'value' => Constants::PERMISSION_SHARE + ], + ]; + } + + /** * @return string the section ID, e.g. 'sharing' */ public function getSection() { diff --git a/lib/private/Settings/Manager.php b/lib/private/Settings/Manager.php index 387460852ab..7111511eca2 100644 --- a/lib/private/Settings/Manager.php +++ b/lib/private/Settings/Manager.php @@ -271,7 +271,7 @@ class Manager implements IManager { } if ($section === 'sharing') { /** @var ISettings $form */ - $form = new Admin\Sharing($this->config); + $form = new Admin\Sharing($this->config, $this->l); $forms[$form->getPriority()] = [$form]; } if ($section === 'additional') { diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php index b8bff074200..b691a8a64cb 100644 --- a/lib/private/Template/JSConfigHelper.php +++ b/lib/private/Template/JSConfigHelper.php @@ -28,6 +28,7 @@ namespace OC\Template; use bantu\IniGetWrapper\IniGetWrapper; +use OC\CapabilitiesManager; use OCP\App\IAppManager; use OCP\Defaults; use OCP\IConfig; @@ -66,6 +67,9 @@ class JSConfigHelper { /** @var IURLGenerator */ private $urlGenerator; + /** @var CapabilitiesManager */ + private $capabilitiesManager; + /** * @param IL10N $l * @param Defaults $defaults @@ -76,6 +80,7 @@ class JSConfigHelper { * @param IGroupManager $groupManager * @param IniGetWrapper $iniWrapper * @param IURLGenerator $urlGenerator + * @param CapabilitiesManager $capabilitiesManager */ public function __construct(IL10N $l, Defaults $defaults, @@ -85,7 +90,8 @@ class JSConfigHelper { IConfig $config, IGroupManager $groupManager, IniGetWrapper $iniWrapper, - IURLGenerator $urlGenerator) { + IURLGenerator $urlGenerator, + CapabilitiesManager $capabilitiesManager) { $this->l = $l; $this->defaults = $defaults; $this->appManager = $appManager; @@ -95,6 +101,7 @@ class JSConfigHelper { $this->groupManager = $groupManager; $this->iniWrapper = $iniWrapper; $this->urlGenerator = $urlGenerator; + $this->capabilitiesManager = $capabilitiesManager; } public function getConfig() { @@ -146,6 +153,8 @@ class JSConfigHelper { $lastConfirmTimestamp = 0; } + $capabilities = $this->capabilitiesManager->getCapabilities(); + $array = [ "oc_debug" => $this->config->getSystemValue('debug', false) ? 'true' : 'false', "oc_isadmin" => $this->groupManager->isAdmin($uid) ? 'true' : 'false', @@ -252,6 +261,7 @@ class JSConfigHelper { 'longFooter' => $this->defaults->getLongFooter(), 'folder' => \OC_Util::getTheme(), ]), + "oc_capabilities" => json_encode($capabilities), ]; if ($this->currentUser !== null) { diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index eb8477ca9e9..0f2eb48bef3 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -160,7 +160,8 @@ class TemplateLayout extends \OC_Template { $this->config, \OC::$server->getGroupManager(), \OC::$server->getIniWrapper(), - \OC::$server->getURLGenerator() + \OC::$server->getURLGenerator(), + \OC::$server->getCapabilitiesManager() ); $this->assign('inline_ocjs', $jsConfigHelper->getConfig()); } else { |