diff options
author | Georg Ehrke <dev@georgswebsite.de> | 2012-04-26 18:08:49 +0200 |
---|---|---|
committer | Georg Ehrke <dev@georgswebsite.de> | 2012-04-26 18:08:49 +0200 |
commit | 2b10371bdeb2c8a3d5cc2617ada5cf8195c264c9 (patch) | |
tree | f25b463c90992764887416c3082098fed6ecac65 /apps/files_sharing | |
parent | 40f95ffdf3edf9ab45c15bd5b9018d7f4d92baa9 (diff) | |
parent | 127796218314c6b1f19ba86f74caa913375aac8d (diff) | |
download | nextcloud-server-2b10371bdeb2c8a3d5cc2617ada5cf8195c264c9.tar.gz nextcloud-server-2b10371bdeb2c8a3d5cc2617ada5cf8195c264c9.zip |
fix merge conflicts
Diffstat (limited to 'apps/files_sharing')
-rw-r--r-- | apps/files_sharing/ajax/email.php | 15 | ||||
-rw-r--r-- | apps/files_sharing/ajax/toggleresharing.php | 13 | ||||
-rw-r--r-- | apps/files_sharing/appinfo/app.php | 9 | ||||
-rw-r--r-- | apps/files_sharing/js/settings.js | 9 | ||||
-rw-r--r-- | apps/files_sharing/js/share.js | 21 | ||||
-rw-r--r-- | apps/files_sharing/lib_share.php | 28 | ||||
-rw-r--r-- | apps/files_sharing/settings.php | 9 | ||||
-rw-r--r-- | apps/files_sharing/templates/settings.php | 6 |
8 files changed, 107 insertions, 3 deletions
diff --git a/apps/files_sharing/ajax/email.php b/apps/files_sharing/ajax/email.php new file mode 100644 index 00000000000..d6d53c49bff --- /dev/null +++ b/apps/files_sharing/ajax/email.php @@ -0,0 +1,15 @@ +<?php + +require_once('../../../lib/base.php'); + +OC_JSON::checkLoggedIn(); +OC_JSON::checkAppEnabled('files_sharing'); +$user = OC_User::getUser(); +// TODO translations +$subject = $user + ' ' + 'shared a file with you'; +$link = $_POST['link'] + '&f=' + $_POST['f']; +$text = $user + ' ' + 'shared the file' + ' ' + $_POST['f'] + ' ' + 'with you.' + ' ' + 'It is available for download here:' + ' ' + $link; +$fromaddress = OC_Preferences::getValue($user, 'settings', 'email', 'owncloud.org'); +OC_Mail::send($_POST['toaddress'], $_POST['toaddress'], $subject, $text, $fromaddress, $user); + +?>
\ No newline at end of file diff --git a/apps/files_sharing/ajax/toggleresharing.php b/apps/files_sharing/ajax/toggleresharing.php new file mode 100644 index 00000000000..72af1eedec1 --- /dev/null +++ b/apps/files_sharing/ajax/toggleresharing.php @@ -0,0 +1,13 @@ +<?php + +require_once('../../../lib/base.php'); + +OC_JSON::checkAppEnabled('files_sharing'); +OC_JSON::checkAdminUser(); +if ($_POST['resharing'] == true) { + OC_Appconfig::setValue('files_sharing', 'resharing', 'yes'); +} else { + OC_Appconfig::setValue('files_sharing', 'resharing', 'no'); +} + +?> diff --git a/apps/files_sharing/appinfo/app.php b/apps/files_sharing/appinfo/app.php index 8049e9b0ae3..645f4f5e4f2 100644 --- a/apps/files_sharing/appinfo/app.php +++ b/apps/files_sharing/appinfo/app.php @@ -3,10 +3,17 @@ 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"); +OC_Hook::connect('OC_User', 'post_deleteUser', 'OC_Share', 'removeUser'); +OC_Hook::connect('OC_User', 'post_addToGroup', 'OC_Share', 'addToGroupShare'); +OC_Hook::connect('OC_User', 'post_removeFromGroup', 'OC_Share', 'removeFromGroupShare'); +$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 index 00000000000..bb7d79fecbb --- /dev/null +++ b/apps/files_sharing/js/settings.js @@ -0,0 +1,9 @@ +$(document).ready(function() { + $('#allowResharing').bind('change', function() { + var checked = 1; + if (!this.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/js/share.js b/apps/files_sharing/js/share.js index 54d749d833e..4125fd14d25 100644 --- a/apps/files_sharing/js/share.js +++ b/apps/files_sharing/js/share.js @@ -163,6 +163,9 @@ $(document).ready(function() { data: data, success: function(){ $('#link').hide('blind'); + $('#emailBreak').remove(); + $('#email').hide('blind'); + $('#emailButton').hide('blind'); } }); } @@ -172,6 +175,14 @@ $(document).ready(function() { $(this).focus(); $(this).select(); }); + + $('#emailButton').live('click', function() { + $('#email').css('font-weight', 'bold'); + $('#email').animate({ fontWeight: 'normal' }, 2000, function() { + $(this).val(''); + }).val('Email sent'); + $.post(OC.filePath('files_sharing','ajax','email.php'), 'toaddress='+$('#email').val()+'&link='+$('#link').val()); + }); }); function createDropdown(filename, files) { @@ -183,10 +194,12 @@ function createDropdown(filename, files) { html += '<ul id="shared_list"></ul>'; html += '</div>'; html += '<div id="public">'; - html += '<input type="checkbox" name="makelink" id="makelink" value="1" /><label for="makelink">make public</label>'; + html += '<input type="checkbox" name="makelink" id="makelink" value="1" /><label for="makelink">Share with private link</label>'; //html += '<input type="checkbox" name="public_link_write" id="public_link_write" value="1" /><label for="public_link_write">allow upload</label>'; html += '<br />'; html += '<input id="link" style="display:none; width:90%;" />'; + html += '<input id="email" style="display:none; width:65%;" value="" placeholder="Email link to person" />'; + html += '<input id="emailButton" style="display:none;" type="submit" value="Send" />'; html += '</div>'; if (filename) { $('tr').filterAttr('data-file',filename).addClass('mouseOver'); @@ -241,5 +254,9 @@ function showPublicLink(token, file) { $('#makelink').attr('checked', true); $('#link').data('token', token); $('#link').val(parent.location.protocol+'//'+location.host+OC.linkTo('files_sharing','get.php')+'?token='+token+'&f='+file); - $('#link').show('blind'); + $('#link').show('blind', function() { + $('#link').after('<br id="emailBreak" />'); + $('#email').show('blind'); + $('#emailButton').show('blind'); + }); } diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php index 673984f393b..62ac05a5952 100644 --- a/apps/files_sharing/lib_share.php +++ b/apps/files_sharing/lib_share.php @@ -436,6 +436,34 @@ class OC_Share { } } + public static function removeUser($arguments) { + $query = OC_DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_owner = ? OR uid_shared_with '.self::getUsersAndGroups($arguments['uid'])); + $query->execute(array($arguments['uid'])); + } + + public static function addToGroupShare($arguments) { + $length = -strlen($arguments['gid']) - 1; + $query = OC_DB::prepare('SELECT uid_owner, source, permissions FROM *PREFIX*sharing WHERE SUBSTR(uid_shared_with, '.$length.') = ?'); + $gid = '@'.$arguments['gid']; + $result = $query->execute(array($gid))->fetchAll(); + if (count($result) > 0) { + $query = OC_DB::prepare('INSERT INTO *PREFIX*sharing VALUES(?,?,?,?,?)'); + $sharedFolder = '/'.$arguments['uid'].'/files/Shared/'; + $lastSource = ''; + for ($i = 0; $i < count($result) - 1; $i++) { + if ($result[$i]['source'] != $lastSource) { + $query->execute(array($result[$i]['uid_owner'], $arguments['uid'].'@'.$arguments['gid'], $result[$i]['source'], $sharedFolder.basename($result[$i]['source']), $result[$i]['permissions'])); + $lastSource = $result[$i]['source']; + } + } + } + } + + public static function removeFromGroupShare($arguments) { + $query = OC_DB::prepare('DELETE FROM *PREFIX*sharing WHERE uid_shared_with = ?'); + $query->execute(array($arguments['uid'].'@'.$arguments['gid'])); + } + } ?> diff --git a/apps/files_sharing/settings.php b/apps/files_sharing/settings.php new file mode 100644 index 00000000000..b30c4f45cde --- /dev/null +++ b/apps/files_sharing/settings.php @@ -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 index 00000000000..5b6ba5f33ee --- /dev/null +++ b/apps/files_sharing/templates/settings.php @@ -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 |