Skip to content

Commit

Permalink
add switch to enable features
Browse files Browse the repository at this point in the history
  • Loading branch information
mrow4a committed Mar 29, 2019
1 parent af3f878 commit ec25a02
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
4 changes: 3 additions & 1 deletion js/viewer/attributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ OC.Plugins.register('OC.Share.ShareItemModel', {
var mimetype = model.getFileInfo().getMimeType();
var folderMimeType = 'httpd/unix-directory';
if ((odfViewer.isSupportedMimeType(mimetype) || mimetype === folderMimeType) &&
OC.appConfig.richdocuments && OC.appConfig.richdocuments.defaultShareAttributes) {
OC.appConfig.richdocuments &&
OC.appConfig.richdocuments.secureViewAllowed &&
OC.appConfig.richdocuments.defaultShareAttributes) {
/** @type OC.Share.Types.RegisteredShareAttribute **/
var secureViewCanDownload = {
"scope": "permissions",
Expand Down
14 changes: 14 additions & 0 deletions lib/AppConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,18 @@ public function getUserValue($userId, $key) {
public function setUserValue($userId, $key, $value) {
return $this->config->setAppValue($userId, $this->appName, $key, $value);
}

/**
* Check if app can have enterprise features enabled
*
* @return bool
*/
public function enterpriseFeaturesEnabled() {
if ($this->config->getAppValue('enterprise_key', 'license-key', null) === null &&
$this->config->getSystemValue('license-key', null) === null) {
return false;
}

return true;
}
}
1 change: 1 addition & 0 deletions lib/Controller/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function adminIndex() {
'external_apps' => $this->appConfig->getAppValue('external_apps'),
'canonical_webroot' => $this->appConfig->getAppValue('canonical_webroot'),
'menu_option' => $this->appConfig->getAppValue('menu_option'),
'secure_view_allowed' => $this->appConfig->enterpriseFeaturesEnabled() ? 'true' : 'false',
'secure_view_option' => $this->appConfig->getAppValue('secure_view_option'),
'secure_view_can_download_default' => $this->appConfig->getAppValue('secure_view_can_download_default'),
'secure_view_can_print_default' => $this->appConfig->getAppValue('secure_view_can_print_default'),
Expand Down
8 changes: 5 additions & 3 deletions lib/HookHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ public static function addViewerScripts() {
}

public static function addConfigScripts($array) {
$appConfig = new AppConfig(\OC::$server->getConfig());
$config = \OC::$server->getConfig();
$richdocumentsConfig = new AppConfig($config);
$array['array']['oc_appconfig']['richdocuments'] = [
'defaultShareAttributes' => [
'secureViewCanDownload' => $appConfig->getAppValue('secure_view_can_dowload_default'),
'secureViewCanPrint' => $appConfig->getAppValue('secure_view_can_print_default'),
'secureViewCanDownload' => $richdocumentsConfig->getAppValue('secure_view_can_dowload_default'),
'secureViewCanPrint' => $richdocumentsConfig->getAppValue('secure_view_can_print_default'),
],
'secureViewAllowed' => $richdocumentsConfig->enterpriseFeaturesEnabled()
];
}
}
10 changes: 8 additions & 2 deletions templates/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,14 @@
<label for="enable_menu_option_cb-richdocuments"><?php p($l->t('Use Menu option')) ?></label>

<br/>
<input type="checkbox" id="enable_secure_view_option_cb-richdocuments" <?php p($_['secure_view_option'] === 'true' ? 'checked' : '') ?> />
<label for="enable_secure_view_option_cb-richdocuments"><?php p($l->t('Enable Secure View for read-only shares')) ?></label>
<input type="checkbox" id="enable_secure_view_option_cb-richdocuments" <?php if ($_['secure_view_option'] === 'true') {
p('checked />');
} elseif ($_['secure_view_allowed'] !== 'true') {
p('disabled />');
} else {
p(' />');
}?>
<label for="enable_secure_view_option_cb-richdocuments"><?php p($l->t('Enable Secure View for read-only shares (requires enterprise version)')) ?></label>
<div id="enable-share-attributes-defaults" style="padding-left: 28px;" class="indent <?php if ($_['secure_view_option'] !== 'true') {
p('hidden');
} ?>" >
Expand Down

0 comments on commit ec25a02

Please sign in to comment.