]> source.dussan.org Git - nextcloud-server.git/commitdiff
Allow admin to disable resharing of files
authorMichael Gapczynski <GapczynskiM@gmail.com>
Wed, 25 Apr 2012 15:51:18 +0000 (11:51 -0400)
committerMichael Gapczynski <GapczynskiM@gmail.com>
Wed, 25 Apr 2012 15:51:30 +0000 (11:51 -0400)
apps/files_sharing/ajax/toggleresharing.php [new file with mode: 0644]
apps/files_sharing/appinfo/app.php
apps/files_sharing/js/settings.js [new file with mode: 0644]
apps/files_sharing/settings.php [new file with mode: 0644]
apps/files_sharing/templates/settings.php [new file with mode: 0644]

diff --git a/apps/files_sharing/ajax/toggleresharing.php b/apps/files_sharing/ajax/toggleresharing.php
new file mode 100644 (file)
index 0000000..fd16b20
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+
+require_once('../../../lib/base.php');
+
+OC_JSON::checkAppEnabled('files_sharing');
+OC_JSON::checkAdminUser();
+error_log($_POST['resharing']);
+if ($_POST['resharing'] == true) {
+       error_log("enabling");
+       OC_Appconfig::setValue('files_sharing', 'resharing', 'yes');
+} else {
+       error_log("disabling");
+       OC_Appconfig::setValue('files_sharing', 'resharing', 'no');
+}
+
+?>
index 8049e9b0ae3cbcde3564f008c351ff8087642953..117b65d754fc4fb97acba49199663ed16a5c9a95 100644 (file)
@@ -3,10 +3,14 @@
 require_once('apps/files_sharing/sharedstorage.php');
 
 OC::$CLASSPATH['OC_Share'] = "apps/files_sharing/lib_share.php";
+OC_APP::registerAdmin('files_sharing', 'settings');
 OC_Hook::connect("OC_Filesystem", "post_delete", "OC_Share", "deleteItem");
 OC_Hook::connect("OC_Filesystem", "post_rename", "OC_Share", "renameItem");
 OC_Hook::connect("OC_Filesystem", "post_write", "OC_Share", "updateItem");
-OC_Util::addScript("files_sharing", "share");
+$dir = isset($_GET['dir']) ? $_GET['dir'] : '/';
+if ($dir != '/Shared' || OC_Appconfig::getValue('files_sharing', 'resharing', 'yes') == 'yes') {
+       OC_Util::addScript("files_sharing", "share");
+}
 OC_Util::addScript("3rdparty", "chosen/chosen.jquery.min");
 OC_Util::addStyle( 'files_sharing', 'sharing' );
 OC_Util::addStyle("3rdparty", "chosen/chosen");
diff --git a/apps/files_sharing/js/settings.js b/apps/files_sharing/js/settings.js
new file mode 100644 (file)
index 0000000..f1b1643
--- /dev/null
@@ -0,0 +1,9 @@
+$(document).ready(function() {
+       $('#allowResharing').bind('change', function() {
+               var checked = 1;
+               if (!$('#allowResharing').attr('checked')) {
+                       checked = 0;
+               }
+               $.post(OC.filePath('files_sharing','ajax','toggleresharing.php'), 'resharing='+checked);
+       });
+});
\ No newline at end of file
diff --git a/apps/files_sharing/settings.php b/apps/files_sharing/settings.php
new file mode 100644 (file)
index 0000000..b30c4f4
--- /dev/null
@@ -0,0 +1,9 @@
+<?php
+
+OC_Util::checkAdminUser();
+OC_Util::addScript('files_sharing', 'settings');
+$tmpl = new OC_Template('files_sharing', 'settings');
+$tmpl->assign('allowResharing', OC_Appconfig::getValue('files_sharing', 'resharing', 'yes'));
+return $tmpl->fetchPage();
+
+?>
\ No newline at end of file
diff --git a/apps/files_sharing/templates/settings.php b/apps/files_sharing/templates/settings.php
new file mode 100644 (file)
index 0000000..5b6ba5f
--- /dev/null
@@ -0,0 +1,6 @@
+<form id="resharing">
+       <fieldset class="personalblock">
+       <input type="checkbox" name="allowResharing" id="allowResharing" value="1" <?php if ($_['allowResharing'] == 'yes') echo ' checked="checked"'; ?> /> <label for="allowResharing"><?php echo $l->t('Enable Resharing'); ?></label> <br/>
+       <em><?php echo $l->t('Allow users to reshare files they don\'t own');?></em>
+       </fieldset>
+</form>
\ No newline at end of file