svg" data-dir='' style='background-image:url("")'>
+
svg" data-dir='' style='background-image:url("")'>
">
\ No newline at end of file
diff --git a/apps/files/templates/part.list.php b/apps/files/templates/part.list.php
old mode 100644
new mode 100755
index b2db4cbb8df..4506630c16d
--- a/apps/files/templates/part.list.php
+++ b/apps/files/templates/part.list.php
@@ -1,9 +1,9 @@
200) $relative_date_color = 200;
$name = str_replace('+','%20',urlencode($file['name']));
@@ -11,7 +11,7 @@
$directory = str_replace('+','%20',urlencode($file['directory']));
$directory = str_replace('%2F','/', $directory); ?>
' data-write=''>
- |
+ |
@@ -27,7 +27,7 @@
|
- |
+ |
|
diff --git a/apps/files_encryption/settings.php b/apps/files_encryption/settings.php
index aed9079529c..0a0d4d1abba 100755
--- a/apps/files_encryption/settings.php
+++ b/apps/files_encryption/settings.php
@@ -6,7 +6,7 @@
* See the COPYING-README file.
*/
-$tmpl = new OC_Template( 'files_encryption', 'settings');
+$tmpl = new OCP\Template( 'files_encryption', 'settings');
$blackList=explode(',',OCP\Config::getAppValue('files_encryption','type_blacklist','jpg,png,jpeg,avi,mpg,mpeg,mkv,mp3,oga,ogv,ogg'));
$enabled=(OCP\Config::getAppValue('files_encryption','enable_encryption','true')=='true');
$tmpl->assign('blacklist',$blackList);
diff --git a/apps/files_sharing/ajax/getitem.php b/apps/files_sharing/ajax/getitem.php
index d9404f7e3b4..6eed0408238 100755
--- a/apps/files_sharing/ajax/getitem.php
+++ b/apps/files_sharing/ajax/getitem.php
@@ -1,36 +1,69 @@
$gid, 'permissions' => $rows[$i]['permissions'], 'users' => OC_Group::usersInGroup($gid), 'parentFolder' => false));
+ } else {
+ $group = array(array('gid' => $gid, 'permissions' => $rows[$i]['permissions'], 'users' => OC_Group::usersInGroup($gid), 'parentFolder' => basename($path)));
+ }
+ if (!isset($item['groups'])) {
+ $item['groups'] = $group;
+ } else if (is_array($item['groups'])) {
+ $gidExists = false;
+ $currentGroups = $item['groups'];
+ // Check if the group is already included
+ foreach ($currentGroups as $g) {
+ if ($g['gid'] == $gid) {
+ $gidExists = true;
+ }
+ }
+ if (!$gidExists) {
+ $item['groups'] = array_merge($item['groups'], $group);
+ }
+ }
+ } else {
+ if ($path == $source) {
+ $user = array(array('uid' => $uid_shared_with, 'permissions' => $rows[$i]['permissions'], 'parentFolder' => false));
+ } else {
+ $user = array(array('uid' => $uid_shared_with, 'permissions' => $rows[$i]['permissions'], 'parentFolder' => basename($path)));
+ }
+ if (!isset($item['users'])) {
+ $item['users'] = $user;
+ } else if (is_array($item['users'])) {
+ $item['users'] = array_merge($item['users'], $user);
+ }
+ }
}
- $parentUsers[basename($source)."-".$i] = $values[$i];
}
- $users = array_merge($users, $parentUsers);
}
- $source = dirname($source);
-}
-if (!empty($users)) {
- OCP\JSON::encodedPrint($users);
+ $path = dirname($path);
}
+
+OCP\JSON::success(array('data' => $item));
+
+?>
diff --git a/apps/files_sharing/ajax/getstatuses.php b/apps/files_sharing/ajax/getstatuses.php
new file mode 100644
index 00000000000..c1892e7e2a2
--- /dev/null
+++ b/apps/files_sharing/ajax/getstatuses.php
@@ -0,0 +1,25 @@
+ $items));
+
+?>
\ No newline at end of file
diff --git a/apps/files_sharing/ajax/setpermissions.php b/apps/files_sharing/ajax/setpermissions.php
index 73f59d73db2..2f4c5da9788 100755
--- a/apps/files_sharing/ajax/setpermissions.php
+++ b/apps/files_sharing/ajax/setpermissions.php
@@ -1,13 +1,14 @@
diff --git a/apps/files_sharing/ajax/share.php b/apps/files_sharing/ajax/share.php
index 4863170f57c..4478144e92f 100755
--- a/apps/files_sharing/ajax/share.php
+++ b/apps/files_sharing/ajax/share.php
@@ -1,31 +1,33 @@
getToken();
+ $path = ltrim($source, '/');
+ $source = $userDirectory.$source;
+ // Check if the file exists or if the file is being reshared
+ if ($source && (OC_FILESYSTEM::file_exists($path) && OC_FILESYSTEM::is_readable($path) || OC_Share::getSource($source))) {
+ try {
+ $shared = new OC_Share($source, $uid_shared_with, $permissions);
+ // If this is a private link, return the token
+ if ($uid_shared_with == OC_Share::PUBLICLINK) {
+ OCP\JSON::success(array('data' => $shared->getToken()));
+ } else {
+ OCP\JSON::success();
+ }
+ } catch (Exception $exception) {
+ OCP\Util::writeLog('files_sharing', 'Unexpected Error : '.$exception->getMessage(), OCP\Util::ERROR);
+ OCP\JSON::error(array('data' => array('message' => $exception->getMessage())));
}
- } catch (Exception $exception) {
- OCP\Util::writeLog('files_sharing',"Unexpected Error : ".$exception->getMessage(),OCP\Util::ERROR);
- echo "false";
+ } else {
+ OCP\Util::writeLog('files_sharing', 'File does not exist or is not readable :'.$source, OCP\Util::ERROR);
+ OCP\JSON::error(array('data' => array('message' => 'File does not exist or is not readable')));
}
}
diff --git a/apps/files_sharing/ajax/unshare.php b/apps/files_sharing/ajax/unshare.php
index 5056c59a3d4..9088bf42663 100755
--- a/apps/files_sharing/ajax/unshare.php
+++ b/apps/files_sharing/ajax/unshare.php
@@ -1,12 +1,13 @@
diff --git a/apps/files_sharing/ajax/userautocomplete.php b/apps/files_sharing/ajax/userautocomplete.php
index 73b5f126984..99cc81bce04 100755
--- a/apps/files_sharing/ajax/userautocomplete.php
+++ b/apps/files_sharing/ajax/userautocomplete.php
@@ -1,7 +1,4 @@
";
$groups[] = "
";
$groups[] = "";
diff --git a/apps/files_sharing/css/sharing.css b/apps/files_sharing/css/sharing.css
index 5acd9af589a..c4b4540e9d1 100644
--- a/apps/files_sharing/css/sharing.css
+++ b/apps/files_sharing/css/sharing.css
@@ -6,8 +6,9 @@
-moz-box-shadow:0 1px 1px #777; -webkit-box-shadow:0 1px 1px #777; box-shadow:0 1px 1px #777;
-moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em;
-moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; }
-#shared_list { padding:0.5em; list-style-type: none; }
-#public { border-top:1px solid #ddd; padding-top:0.5em; }
+#sharedWithList { padding:0.5em; list-style-type: none; }
+#privateLink { border-top:1px solid #ddd; padding-top:0.5em; }
a.unshare { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em !important; opacity:.5; }
a.unshare:hover { opacity:1; }
#share_with { width: 16em; }
+#privateLink label, .edit { font-weight:normal; }
diff --git a/apps/files_sharing/get.php b/apps/files_sharing/get.php
index de3bc5f46dc..2b2c9dd07fd 100755
--- a/apps/files_sharing/get.php
+++ b/apps/files_sharing/get.php
@@ -17,7 +17,7 @@ if ($source !== false) {
$source .= $subPath;
if (!OC_Filesystem::file_exists($source)) {
header("HTTP/1.0 404 Not Found");
- $tmpl = new OC_Template("", "404", "guest");
+ $tmpl = new OCP\Template("", "404", "guest");
$tmpl->assign("file", $subPath);
$tmpl->printPage();
exit;
@@ -49,15 +49,15 @@ if ($source !== false) {
}
// Load the files we need
OCP\Util::addStyle("files", "files");
- $breadcrumbNav = new OC_Template("files", "part.breadcrumb", "");
+ $breadcrumbNav = new OCP\Template("files", "part.breadcrumb", "");
$breadcrumbNav->assign("breadcrumb", $breadcrumb);
$breadcrumbNav->assign("baseURL", OCP\Util::linkTo("files_sharing", "get.php")."?token=".$token."&path=");
- $list = new OC_Template("files", "part.list", "");
+ $list = new OCP\Template("files", "part.list", "");
$list->assign("files", $files);
$list->assign("baseURL", OCP\Util::linkTo("files_sharing", "get.php")."?token=".$token."&path=");
$list->assign("downloadURL", OCP\Util::linkTo("files_sharing", "get.php")."?token=".$token."&path=");
$list->assign("readonly", true);
- $tmpl = new OC_Template("files", "index", "user");
+ $tmpl = new OCP\Template("files", "index", "user");
$tmpl->assign("fileList", $list->fetchPage());
$tmpl->assign("breadcrumb", $breadcrumbNav->fetchPage());
$tmpl->assign("readonly", true);
@@ -78,7 +78,7 @@ if ($source !== false) {
}
} else {
header("HTTP/1.0 404 Not Found");
- $tmpl = new OC_Template("", "404", "guest");
+ $tmpl = new OCP\Template("", "404", "guest");
$tmpl->printPage();
die();
}
diff --git a/apps/files_sharing/js/share.js b/apps/files_sharing/js/share.js
index 4125fd14d25..7bfaa1f0c69 100644
--- a/apps/files_sharing/js/share.js
+++ b/apps/files_sharing/js/share.js
@@ -1,100 +1,276 @@
-$(document).ready(function() {
- var shared_status = {};
- if (typeof FileActions !== 'undefined') {
- FileActions.register('all', 'Share', function(filename) {
- if (scanFiles.scanning){return;}//workaround to prevent additional http request block scanning feedback
- var icon;
- if (typeof filename == 'undefined') {
- return false;
- }
- var file = $('#dir').val()+'/'+filename;
- if(shared_status[file])
- return shared_status[file].icon;
- $.ajax({
- type: 'GET',
- url: OC.linkTo('files_sharing', 'ajax/getitem.php'),
- dataType: 'json',
- data: {source: file},
- async: false,
- success: function(users) {
- if (users) {
- icon = OC.imagePath('core', 'actions/shared');
- $.each(users, function(index, row) {
- if (row.uid_shared_with == 'public') {
- icon = OC.imagePath('core', 'actions/public');
- }
- });
+OC.Share={
+ icons:[],
+ itemUsers:[],
+ itemGroups:[],
+ itemPrivateLink:false,
+ usersAndGroups:[],
+ loadIcons:function() {
+ // Cache all icons for shared files
+ $.getJSON(OC.filePath('files_sharing', 'ajax', 'getstatuses.php'), function(result) {
+ if (result && result.status === 'success') {
+ $.each(result.data, function(item, hasPrivateLink) {
+ if (hasPrivateLink) {
+ OC.Share.icons[item] = OC.imagePath('core', 'actions/public');
} else {
- icon = OC.imagePath('core', 'actions/share');
- }
- shared_status[file]= { timestamp: new Date().getTime(), icon: icon };
- }
- });
- return icon;
- }, function(filename) {
- if (($('#dropdown').length > 0)) {
- $('#dropdown').hide('blind', function() {
- var dropdownFile = $('#dropdown').data('file')
- var file = $('#dir').val()+'/'+filename;
- $('#dropdown').remove();
- $('tr').removeClass('mouseOver');
- if (dropdownFile != file) {
- createDropdown(filename, file);
+ OC.Share.icons[item] = OC.imagePath('core', 'actions/shared');
}
});
+ }
+ });
+ },
+ loadItem:function(item) {
+ $.ajax({type: 'GET', url: OC.filePath('files_sharing', 'ajax', 'getitem.php'), data: { item: item }, async: false, success: function(result) {
+ if (result && result.status === 'success') {
+ var item = result.data;
+ OC.Share.itemUsers = item.users;
+ OC.Share.itemGroups = item.groups;
+ OC.Share.itemPrivateLink = item.privateLink;
+ }
+ }});
+ },
+ share:function(source, uid_shared_with, permissions, callback) {
+ $.post(OC.filePath('files_sharing', 'ajax', 'share.php'), { sources: source, uid_shared_with: uid_shared_with, permissions: permissions }, function(result) {
+ if (result && result.status === 'success') {
+ if (callback) {
+ callback(result.data);
+ }
} else {
- createDropdown(filename, $('#dir').val()+'/'+filename);
+ OC.dialogs.alert(result.data.message, 'Error while sharing');
+ }
+ });
+ },
+ unshare:function(source, uid_shared_with, callback) {
+ $.post(OC.filePath('files_sharing', 'ajax', 'unshare.php'), { source: source, uid_shared_with: uid_shared_with }, function(result) {
+ if (result && result.status === 'success') {
+ if (callback) {
+ callback();
+ }
+ } else {
+ OC.dialogs.alert('Error', 'Error while unsharing');
+ }
+ });
+ },
+ changePermissions:function(source, uid_shared_with, permissions) {
+ $.post(OC.filePath('files_sharing','ajax','setpermissions.php'), { source: source, uid_shared_with: uid_shared_with, permissions: permissions }, function(result) {
+ if (!result || result.status !== 'success') {
+ OC.dialogs.alert('Error', 'Error while changing permissions');
+ }
+ });
+ },
+ showDropDown:function(item, appendTo) {
+ OC.Share.loadItem(item);
+ var html = '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += 'Groups: ';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '
';
+ html += '';
+ html += '
';
+ html += '';
+ html += '';
+ html += '';
+ html += '
';
+ $(html).appendTo(appendTo);
+ if (OC.Share.usersAndGroups.length < 1) {
+ $.getJSON(OC.filePath('files_sharing', 'ajax', 'userautocomplete.php'), function(users) {
+ if (users) {
+ OC.Share.usersAndGroups = users;
+ $.each(users, function(index, user) {
+ $(user).appendTo('#share_with');
+ });
+ $('#share_with').trigger('liszt:updated');
+ }
+ });
+ } else {
+ $.each(OC.Share.usersAndGroups, function(index, user) {
+ $(user).appendTo('#share_with');
+ });
+ $('#share_with').trigger('liszt:updated');
+ }
+ if (OC.Share.itemUsers) {
+ $.each(OC.Share.itemUsers, function(index, user) {
+ if (user.parentFolder) {
+ OC.Share.addSharedWith(user.uid, user.permissions, false, user.parentFolder);
+ } else {
+ OC.Share.addSharedWith(user.uid, user.permissions, false, false);
+ }
+ });
+ }
+ if (OC.Share.itemGroups) {
+ $.each(OC.Share.itemGroups, function(index, group) {
+ if (group.parentFolder) {
+ OC.Share.addSharedWith(group.gid, group.permissions, group.users, group.parentFolder);
+ } else {
+ OC.Share.addSharedWith(group.gid, group.permissions, group.users, false);
+ }
+ });
+ }
+ if (OC.Share.itemPrivateLink) {
+ OC.Share.showPrivateLink(item, OC.Share.itemPrivateLink);
+ }
+ $('#dropdown').show('blind');
+ $('#share_with').chosen();
+ },
+ hideDropDown:function(callback) {
+ $('#dropdown').hide('blind', function() {
+ $('#dropdown').remove();
+ if (callback) {
+ callback.call();
+ }
+ });
+ },
+ addSharedWith:function(uid_shared_with, permissions, isGroup, parentFolder) {
+ if (parentFolder) {
+ var sharedWith = '
Parent folder '+parentFolder+' shared with '+uid_shared_with+'';
+ } else {
+ var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"');
+ var style = ((permissions == 0) ? 'style="display:none;"' : '');
+ var sharedWith = '
';
+ sharedWith += '
';
+ sharedWith += uid_shared_with;
+ sharedWith += '';
+ sharedWith += '';
+ sharedWith += '';
+ }
+ if (isGroup) {
+ // Groups are added to a different list
+ $('#groups').show();
+ $(sharedWith).appendTo('#groupList');
+ // Remove group from select form
+ $('#share_with option[value="'+uid_shared_with+'(group)"]').remove();
+ $('#share_with').trigger('liszt:updated');
+ // Remove users in group from select form
+ $.each(isGroup, function(index, user) {
+ $('#share_with option[value="'+user+'"]').remove();
+ $('#share_with').trigger('liszt:updated');
+ });
+ } else {
+ $(sharedWith).appendTo('#userList');
+ // Remove user from select form
+ $('#share_with option[value="'+uid_shared_with+'"]').remove();
+ $('#share_with').trigger('liszt:updated');
+ }
+
+ },
+ removeSharedWith:function(uid_shared_with) {
+ var option;
+ if ($('#userList li[data-uid_shared_with="'+uid_shared_with+'"]').length > 0) {
+ $('#userList li[data-uid_shared_with="'+uid_shared_with+'"]').remove();
+ option = '
';
+ } else if ($('#groupList li[data-uid_shared_with="'+uid_shared_with+'"]').length > 0) {
+ $('#groupList li[data-uid_shared_with="'+uid_shared_with+'"]').remove();
+ if ($('#groupList li').length < 1) {
+ $('#groups').hide();
+ }
+ option = '
';
+ }
+ $(option).appendTo('#share_with');
+ $('#share_with').trigger('liszt:updated');
+ },
+ showPrivateLink:function(item, token) {
+ $('#privateLinkCheckbox').attr('checked', true);
+ var link = parent.location.protocol+'//'+location.host+OC.linkTo('files_sharing','get.php')+'?token='+token;
+ if (token.indexOf('&path=') == -1) {
+ link += '&file=' + item;
+ } else {
+ // Disable checkbox if inside a shared parent folder
+ $('#privateLinkCheckbox').attr('disabled', 'true');
+ }
+ $('#privateLinkText').val(link);
+ $('#privateLinkText').show('blind', function() {
+ $('#privateLinkText').after('
');
+ $('#email').show();
+ $('#emailButton').show();
+ });
+ },
+ hidePrivateLink:function() {
+ $('#privateLinkText').hide('blind');
+ $('#emailBreak').remove();
+ $('#email').hide();
+ $('#emailButton').hide();
+ },
+ emailPrivateLink: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());
+ },
+ dirname:function(path) {
+ return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
+ }
+}
+
+$(document).ready(function() {
+ OC.Share.loadIcons();
+
+ if (typeof FileActions !== 'undefined') {
+ FileActions.register('all', 'Share', function(filename) {
+ // Return the correct sharing icon
+ if (scanFiles.scanning) { return; } // workaround to prevent additional http request block scanning feedback
+ var item = $('#dir').val() + '/' + filename;
+ // Check if icon is in cache
+ if (OC.Share.icons[item]) {
+ return OC.Share.icons[item];
+ } else {
+ var last = '';
+ var path = OC.Share.dirname(item);
+ // Search for possible parent folders that are shared
+ while (path != last) {
+ if (OC.Share.icons[path]) {
+ OC.Share.icons[item] = OC.Share.icons[path];
+ return OC.Share.icons[item];
+ }
+ last = path;
+ path = OC.Share.dirname(path);
+ }
+ OC.Share.icons[item] = OC.imagePath('core', 'actions/share');
+ return OC.Share.icons[item];
+ }
+ }, function(filename) {
+ var file = $('#dir').val() + '/' + filename;
+ var appendTo = $('tr').filterAttr('data-file',filename).find('td.filename');
+ // Check if drop down is already visible for a different file
+ if (($('#dropdown').length > 0)) {
+ if (file != $('#dropdown').data('item')) {
+ OC.Share.hideDropDown(function () {
+ $('tr').removeClass('mouseOver');
+ $('tr').filterAttr('data-file',filename).addClass('mouseOver');
+ OC.Share.showDropDown(file, appendTo);
+ });
+ }
+ } else {
+ $('tr').filterAttr('data-file',filename).addClass('mouseOver');
+ OC.Share.showDropDown(file, appendTo);
}
});
};
-
- $('.share').click(function(event) {
- event.preventDefault();
- event.stopPropagation();
- var filenames = getSelectedFiles('name');
- var length = filenames.length;
- var files = '';
- for (var i = 0; i < length; i++) {
- files += $('#dir').val()+'/'+filenames[i]+';';
- }
- createDropdown(false, files);
- });
$(this).click(function(event) {
if (!($(event.target).hasClass('drop')) && $(event.target).parents().index($('#dropdown')) == -1) {
if ($('#dropdown').is(':visible')) {
- delete shared_status[$('#dropdown').data('file')]; //Remove File from icon cache
- $('#dropdown').hide('blind', function() {
- $('#dropdown').remove();
+ OC.Share.hideDropDown(function() {
$('tr').removeClass('mouseOver');
});
}
}
});
-
- $('#share_with').live('change', function() {
- var source = $('#dropdown').data('file');
- var uid_shared_with = $(this).val();
- var permissions = 0;
- var data = 'sources='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions);
- $.ajax({
- type: 'POST',
- url: OC.linkTo('files_sharing','ajax/share.php'),
- cache: false,
- data: data,
- success: function(result) {
- if (result !== 'false') {
- addUser(uid_shared_with, permissions, false);
- }
- }
- });
- });
-
- $('#shared_list > li').live('mouseenter', function(event) {
+
+ $('#sharedWithList li').live('mouseenter', function(event) {
+ // Show permissions and unshare button
$(':hidden', this).show();
});
- $('#shared_list > li').live('mouseleave', function(event) {
+ $('#sharedWithList li').live('mouseleave', function(event) {
+ // Hide permissions and unshare button
$('a', this).hide();
if (!$('input:[type=checkbox]', this).is(':checked')) {
$('input:[type=checkbox]', this).hide();
@@ -102,161 +278,85 @@ $(document).ready(function() {
}
});
- $('.permissions').live('change', function() {
- var permissions = (this.checked) ? 1 : 0;
- var source = $('#dropdown').data('file');
- var uid_shared_with = $(this).parent().data('uid_shared_with');
- var data = 'source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions);
- $.ajax({
- type: 'GET',
- url: OC.linkTo('files_sharing','ajax/setpermissions.php'),
- cache: false,
- data: data
- });
- });
-
- $('.unshare').live('click', function(event) {
- event.preventDefault();
- var user = $(this).parent();
- var source = $('#dropdown').data('file');
- var uid_shared_with = user.data('uid_shared_with');
- var data = 'source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with);
- $.ajax({
- type: 'GET',
- url: OC.linkTo('files_sharing','ajax/unshare.php'),
- cache: false,
- data: data,
- success: function() {
- var option = '
';
- $(user).remove();
- $(option).appendTo('#share_with');
- $('#share_with').trigger('liszt:updated');
+ $('#share_with').live('change', function() {
+ var item = $('#dropdown').data('item');
+ var uid_shared_with = $(this).val();
+ var pos = uid_shared_with.indexOf('(group)');
+ var isGroup = false;
+ if (pos != -1) {
+ // Remove '(group)' from uid_shared_with
+ uid_shared_with = uid_shared_with.substr(0, pos);
+ isGroup = true;
+ }
+ OC.Share.share(item, uid_shared_with, 0, function() {
+ if (isGroup) {
+ // Reload item because we don't know which users are in the group
+ OC.Share.loadItem(item);
+ var users;
+ $.each(OC.Share.itemGroups, function(index, group) {
+ if (group.gid == uid_shared_with) {
+ users = group.users;
+ }
+ });
+ OC.Share.addSharedWith(uid_shared_with, 0, users, false);
+ } else {
+ OC.Share.addSharedWith(uid_shared_with, 0, false, false);
+ }
+ // Change icon
+ if (!OC.Share.itemPrivateLink) {
+ OC.Share.icons[item] = OC.imagePath('core', 'actions/shared');
}
});
});
- $('#makelink').live('change', function() {
+ $('.unshare').live('click', function() {
+ var item = $('#dropdown').data('item');
+ var uid_shared_with = $(this).parent().data('uid_shared_with');
+ OC.Share.unshare(item, uid_shared_with, function() {
+ OC.Share.removeSharedWith(uid_shared_with);
+ // Reload item to update cached users and groups for the icon check
+ OC.Share.loadItem(item);
+ // Change icon
+ if (!OC.Share.itemPrivateLink && !OC.Share.itemUsers && !OC.Share.itemGroups) {
+ OC.Share.icons[item] = OC.imagePath('core', 'actions/share');
+ }
+ });
+ });
+
+ $('.permissions').live('change', function() {
+ var permissions = (this.checked) ? 1 : 0;
+ OC.Share.changePermissions($('#dropdown').data('item'), $(this).parent().data('uid_shared_with'), permissions);
+ });
+
+ $('#privateLinkCheckbox').live('change', function() {
+ var item = $('#dropdown').data('item');
if (this.checked) {
- var source = $('#dropdown').data('file');
- var uid_shared_with = 'public';
- var permissions = 0;
- var data = 'sources='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with)+'&permissions='+encodeURIComponent(permissions);
- $.ajax({
- type: 'POST',
- url: OC.linkTo('files_sharing','ajax/share.php'),
- cache: false,
- data: data,
- success: function(token) {
- if (token) {
- showPublicLink(token, source.substr(source.lastIndexOf('/')));
- }
- }
+ // Create a private link
+ OC.Share.share(item, 'public', 0, function(token) {
+ OC.Share.showPrivateLink(item, token);
+ // Change icon
+ OC.Share.icons[item] = OC.imagePath('core', 'actions/public');
});
} else {
- var source = $('#dropdown').data('file');
- var uid_shared_with = 'public';
- var data = 'source='+encodeURIComponent(source)+'&uid_shared_with='+encodeURIComponent(uid_shared_with);
- $.ajax({
- type: 'GET',
- url: OC.linkTo('files_sharing','ajax/unshare.php'),
- cache: false,
- data: data,
- success: function(){
- $('#link').hide('blind');
- $('#emailBreak').remove();
- $('#email').hide('blind');
- $('#emailButton').hide('blind');
+ // Delete private link
+ OC.Share.unshare(item, 'public', function() {
+ OC.Share.hidePrivateLink();
+ // Change icon
+ if (OC.Share.itemUsers || OC.Share.itemGroups) {
+ OC.Share.icons[item] = OC.imagePath('core', 'actions/shared');
+ } else {
+ OC.Share.icons[item] = OC.imagePath('core', 'actions/share');
}
});
}
});
- $('#link').live('click', function() {
+ $('#privateLinkText').live('click', 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());
+ OC.Share.emailPrivateLink();
});
-});
-
-function createDropdown(filename, files) {
- var html = '
';
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += '';
- //html += '';
- html += '
';
- html += '';
- html += '';
- html += '';
- html += '
';
- if (filename) {
- $('tr').filterAttr('data-file',filename).addClass('mouseOver');
- $(html).appendTo($('tr').filterAttr('data-file',filename).find('td.filename'));
- } else {
- $(html).appendTo($('thead .share'));
- }
- $.getJSON(OC.linkTo('files_sharing', 'ajax/userautocomplete.php'), function(users) {
- if (users) {
- $.each(users, function(index, row) {
- $(row).appendTo('#share_with');
- });
- $('#share_with').trigger('liszt:updated');
- }
- });
- $.getJSON(OC.linkTo('files_sharing', 'ajax/getitem.php'), { source: files }, function(users) {
- if (users) {
- $.each(users, function(index, row) {
- if (row.uid_shared_with == 'public') {
- showPublicLink(row.token, '/'+filename);
- } else if (isNaN(index)) {
- addUser(row.uid_shared_with, row.permissions, index.substr(0, index.lastIndexOf('-')));
- } else {
- addUser(row.uid_shared_with, row.permissions, false);
- }
- });
- }
- });
- $('#dropdown').show('blind');
- $('#share_with').chosen();
-}
-
-function addUser(uid_shared_with, permissions, parentFolder) {
- if (parentFolder) {
- var user = '
Parent folder '+parentFolder+' shared with '+uid_shared_with+'';
- } else {
- var checked = ((permissions > 0) ? 'checked="checked"' : 'style="display:none;"');
- var style = ((permissions == 0) ? 'style="display:none;"' : '');
- var user = '
';
- user += '
';
- user += uid_shared_with;
- user += '';
- user += '';
- user += '';
- }
- $('#share_with option[value="'+uid_shared_with+'"]').remove();
- $('#share_with').trigger('liszt:updated');
- $(user).appendTo('#shared_list');
-}
-
-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', function() {
- $('#link').after('
');
- $('#email').show('blind');
- $('#emailButton').show('blind');
- });
-}
+});
\ No newline at end of file
diff --git a/apps/files_sharing/lib_share.php b/apps/files_sharing/lib_share.php
index 71cca309776..c2340bdc181 100755
--- a/apps/files_sharing/lib_share.php
+++ b/apps/files_sharing/lib_share.php
@@ -69,7 +69,7 @@ class OC_Share {
}
foreach ($uid_shared_with as $uid) {
// Check if this item is already shared with the user
- $checkSource = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with ".self::getUsersAndGroups($uid));
+ $checkSource = OCP\DB::prepare("SELECT source FROM *PREFIX*sharing WHERE source = ? AND uid_shared_with ".self::getUsersAndGroups($uid, false));
$resultCheckSource = $checkSource->execute(array($source))->fetchAll();
// TODO Check if the source is inside a folder
if (count($resultCheckSource) > 0 && !isset($gid)) {
@@ -98,15 +98,8 @@ class OC_Share {
$uid = $uid."@".$gid;
}
$query->execute(array($uid_owner, $uid, $source, $target, $permissions));
- // Add file to filesystem cache
- $userDirectory = "/".OCP\USER::getUser()."/files";
- $data = OC_Filecache::get(substr($source, strlen($userDirectory)));
- $parentQuery = OCP\DB::prepare('SELECT id FROM *PREFIX*fscache WHERE path=?');
- $parentResult = $parentQuery->execute(array($sharedFolder))->fetchRow();
- $parent = $parentResult['id'];
- $is_writeable = $permissions & OC_Share::WRITE;
- $cacheQuery = OCP\DB::prepare('INSERT INTO *PREFIX*fscache(parent, name, path, size, mtime, ctime, mimetype, mimepart, user, writable) VALUES(?,?,?,?,?,?,?,?,?,?)');
- $cacheQuery->execute(array($parent, basename($target), $target, $data['size'], $data['mtime'], $data['ctime'], $data['mimetype'], dirname($data['mimetype']), $uid, $is_writeable));
+ // Update mtime of shared folder to invoke a file cache rescan
+ OC_Filesystem::getStorage($sharedFolder)->touch($sharedFolder);
}
}
}
@@ -125,7 +118,7 @@ class OC_Share {
* @param $uid (Optional) The uid to get the user groups for, a gid to get the users in a group, or if not set the current user
* @return An IN operator as a string
*/
- private static function getUsersAndGroups($uid = null) {
+ private static function getUsersAndGroups($uid = null, $includePrivateLinks = true) {
$in = " IN(";
if (isset($uid) && OC_Group::groupExists($uid)) {
$users = OC_Group::usersInGroup($uid);
@@ -152,7 +145,9 @@ class OC_Share {
$in .= ", '".$uid."@".$group."'";
}
}
- $in .= ", '".self::PUBLICLINK."'";
+ if ($includePrivateLinks) {
+ $in .= ", '".self::PUBLICLINK."'";
+ }
$in .= ")";
return $in;
}
@@ -381,6 +376,9 @@ class OC_Share {
$source = self::cleanPath($source);
$query = OCP\DB::prepare("DELETE FROM *PREFIX*sharing WHERE SUBSTR(source, 1, ?) = ? AND uid_owner = ? AND uid_shared_with ".self::getUsersAndGroups($uid_shared_with));
$query->execute(array(strlen($source), $source, OCP\USER::getUser()));
+ // Update mtime of shared folder to invoke a file cache rescan
+ $sharedFolder = '/'.$uid_shared_with.'/files/Shared';
+ OC_Filesystem::getStorage($sharedFolder)->touch($sharedFolder);
}
/**
diff --git a/apps/files_sharing/list.php b/apps/files_sharing/list.php
index 2fe6bc88e63..2fd24840d36 100755
--- a/apps/files_sharing/list.php
+++ b/apps/files_sharing/list.php
@@ -30,7 +30,7 @@ OCP\App::setActiveNavigationEntry("files_sharing_list");
OCP\Util::addscript("files_sharing", "list");
-$tmpl = new OC_Template("files_sharing", "list", "user");
+$tmpl = new OCP\Template("files_sharing", "list", "user");
$tmpl->assign("shared_items", OC_Share::getMySharedItems());
$tmpl->printPage();
diff --git a/apps/files_sharing/settings.php b/apps/files_sharing/settings.php
index a7bdf7b9195..7b63a26515a 100755
--- a/apps/files_sharing/settings.php
+++ b/apps/files_sharing/settings.php
@@ -2,7 +2,7 @@
OCP\User::checkAdminUser();
OCP\Util::addscript('files_sharing', 'settings');
-$tmpl = new OC_Template('files_sharing', 'settings');
+$tmpl = new OCP\Template('files_sharing', 'settings');
$tmpl->assign('allowResharing', OCP\Config::getAppValue('files_sharing', 'resharing', 'yes'));
return $tmpl->fetchPage();
diff --git a/apps/files_versions/history.php b/apps/files_versions/history.php
index eb8886239d3..4306e416400 100755
--- a/apps/files_versions/history.php
+++ b/apps/files_versions/history.php
@@ -24,7 +24,7 @@ require_once( '../../lib/base.php' );
OCP\User::checkLoggedIn( );
OCP\Util::addStyle('files_versions','versions');
-$tmpl = new OC_Template( 'files_versions', 'history', 'user' );
+$tmpl = new OCP\Template( 'files_versions', 'history', 'user' );
if ( isset( $_GET['path'] ) ) {
diff --git a/apps/files_versions/settings.php b/apps/files_versions/settings.php
index 59609de15b4..5f9e60fc589 100755
--- a/apps/files_versions/settings.php
+++ b/apps/files_versions/settings.php
@@ -4,7 +4,7 @@ OCP\User::checkAdminUser();
OCP\Util::addscript( 'files_versions', 'versions' );
-$tmpl = new OC_Template( 'files_versions', 'settings');
+$tmpl = new OCP\Template( 'files_versions', 'settings');
return $tmpl->fetchPage();
?>
diff --git a/apps/gallery/appinfo/info.xml b/apps/gallery/appinfo/info.xml
index 7dc85374b0b..5b5ee0f731b 100644
--- a/apps/gallery/appinfo/info.xml
+++ b/apps/gallery/appinfo/info.xml
@@ -6,5 +6,6 @@
Bartek Przybylski
2
Dedicated pictures application
+
diff --git a/apps/gallery/index.php b/apps/gallery/index.php
index cf8bea14216..e47fb3db5d6 100755
--- a/apps/gallery/index.php
+++ b/apps/gallery/index.php
@@ -38,7 +38,7 @@ if (!isset($_GET['view'])) {
while ($row = $result->fetchRow())
$r[] = $row;
- $tmpl = new OC_Template( 'gallery', 'index', 'user' );
+ $tmpl = new OCP\Template( 'gallery', 'index', 'user' );
$tmpl->assign('r', $r);
$tmpl->printPage();
} else {
@@ -48,7 +48,7 @@ if (!isset($_GET['view'])) {
while ($p = $result->fetchRow())
$photos[] = $p['file_path'];
- $tmpl = new OC_Template( 'gallery', 'view_album', 'user' );
+ $tmpl = new OCP\Template( 'gallery', 'view_album', 'user' );
$tmpl->assign('photos', $photos);
$tmpl->assign('albumName', $_GET['view']);
$tmpl->printPage();
diff --git a/apps/media/appinfo/info.xml b/apps/media/appinfo/info.xml
index 01145d4a944..ea5b77c9c8f 100644
--- a/apps/media/appinfo/info.xml
+++ b/apps/media/appinfo/info.xml
@@ -6,5 +6,6 @@
AGPL
Robin Appelman
2
+
diff --git a/apps/media/index.php b/apps/media/index.php
index e2911361ea2..906d7bacb6e 100755
--- a/apps/media/index.php
+++ b/apps/media/index.php
@@ -41,7 +41,7 @@ OCP\Util::addStyle('media','music');
OCP\App::setActiveNavigationEntry( 'media_index' );
-$tmpl = new OC_Template( 'media', 'music', 'user' );
+$tmpl = new OCP\Template( 'media', 'music', 'user' );
$tmpl->printPage();
?>
diff --git a/apps/media/settings.php b/apps/media/settings.php
old mode 100644
new mode 100755
index 133440a9af6..227298fafec
--- a/apps/media/settings.php
+++ b/apps/media/settings.php
@@ -1,6 +1,6 @@
fetchPage();
?>
diff --git a/apps/media/templates/music.php b/apps/media/templates/music.php
old mode 100644
new mode 100755
index 3959d989472..589d6b52475
--- a/apps/media/templates/music.php
+++ b/apps/media/templates/music.php
@@ -1,11 +1,11 @@
diff --git a/apps/media/templates/player.php b/apps/media/templates/player.php
old mode 100644
new mode 100755
index 146c743250e..4d478ec5f50
--- a/apps/media/templates/player.php
+++ b/apps/media/templates/player.php
@@ -1,7 +1,7 @@
printPage();
exit;
}
@@ -10,8 +10,8 @@ if(!isset($_)){//allow the template to be loaded standalone
\ No newline at end of file
diff --git a/apps/remoteStorage/settings.php b/apps/remoteStorage/settings.php
old mode 100644
new mode 100755
index fa85f77a535..9c48549fe6d
--- a/apps/remoteStorage/settings.php
+++ b/apps/remoteStorage/settings.php
@@ -1,7 +1,7 @@
fetchPage();
?>
diff --git a/apps/tasks/ajax/addtaskform.php b/apps/tasks/ajax/addtaskform.php
old mode 100644
new mode 100755
index 20797f31aba..d86232e2da5
--- a/apps/tasks/ajax/addtaskform.php
+++ b/apps/tasks/ajax/addtaskform.php
@@ -8,7 +8,7 @@ $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true);
$category_options = OC_Calendar_App::getCategoryOptions();
$percent_options = range(0, 100, 10);
$priority_options = OC_Task_App::getPriorityOptions();
-$tmpl = new OC_Template('tasks','part.addtaskform');
+$tmpl = new OCP\Template('tasks','part.addtaskform');
$tmpl->assign('calendars',$calendars);
$tmpl->assign('category_options', $category_options);
$tmpl->assign('percent_options', $percent_options);
diff --git a/apps/tasks/ajax/edittask.php b/apps/tasks/ajax/edittask.php
old mode 100644
new mode 100755
index 78d1f193938..edcc8a7cdcd
--- a/apps/tasks/ajax/edittask.php
+++ b/apps/tasks/ajax/edittask.php
@@ -19,7 +19,7 @@ OC_Task_App::updateVCalendarFromRequest($_POST, $vcalendar);
OC_Calendar_Object::edit($id, $vcalendar->serialize());
$priority_options = OC_Task_App::getPriorityOptions();
-$tmpl = new OC_Template('tasks','part.details');
+$tmpl = new OCP\Template('tasks','part.details');
$tmpl->assign('priority_options', $priority_options);
$tmpl->assign('details', $vcalendar->VTODO);
$tmpl->assign('id', $id);
diff --git a/apps/tasks/ajax/edittaskform.php b/apps/tasks/ajax/edittaskform.php
old mode 100644
new mode 100755
index a439a0c0317..e5a0a7297c5
--- a/apps/tasks/ajax/edittaskform.php
+++ b/apps/tasks/ajax/edittaskform.php
@@ -12,7 +12,7 @@ $category_options = OC_Calendar_App::getCategoryOptions();
$percent_options = range(0, 100, 10);
$priority_options = OC_Task_App::getPriorityOptions();
-$tmpl = new OC_Template('tasks','part.edittaskform');
+$tmpl = new OCP\Template('tasks','part.edittaskform');
$tmpl->assign('category_options', $category_options);
$tmpl->assign('percent_options', $percent_options);
$tmpl->assign('priority_options', $priority_options);
diff --git a/apps/tasks/ajax/getdetails.php b/apps/tasks/ajax/getdetails.php
old mode 100644
new mode 100755
index 34ddaa7791a..4ce469e0c9c
--- a/apps/tasks/ajax/getdetails.php
+++ b/apps/tasks/ajax/getdetails.php
@@ -15,7 +15,7 @@ if (!$details){
}
$priority_options = OC_Task_App::getPriorityOptions();
-$tmpl = new OC_Template('tasks','part.details');
+$tmpl = new OCP\Template('tasks','part.details');
$tmpl->assign('priority_options', $priority_options);
$tmpl->assign('details',$details->VTODO);
$tmpl->assign('id',$id);
diff --git a/apps/tasks/index.php b/apps/tasks/index.php
old mode 100644
new mode 100755
index 8ed5f410434..5e17ca454ec
--- a/apps/tasks/index.php
+++ b/apps/tasks/index.php
@@ -28,7 +28,7 @@ OCP\App::setActiveNavigationEntry('tasks_index');
$categories = OC_Calendar_App::getCategoryOptions();
$l10n = new OC_L10N('tasks');
$priority_options = OC_Task_App::getPriorityOptions();
-$output = new OC_Template('tasks', 'tasks', 'user');
+$output = new OCP\Template('tasks', 'tasks', 'user');
$output->assign('priority_options', $priority_options);
$output->assign('categories', $categories);
$output -> printPage();
diff --git a/apps/tasks/templates/part.taskform.php b/apps/tasks/templates/part.taskform.php
old mode 100644
new mode 100755
index da984d830bd..c00560903b0
--- a/apps/tasks/templates/part.taskform.php
+++ b/apps/tasks/templates/part.taskform.php
@@ -6,7 +6,7 @@
-
?>)
+
diff --git a/apps/tasks/templates/tasks.php b/apps/tasks/templates/tasks.php
old mode 100644
new mode 100755
index 98698400797..ab6138b613f
--- a/apps/tasks/templates/tasks.php
+++ b/apps/tasks/templates/tasks.php
@@ -17,13 +17,13 @@
-
t('More') ?>
+
t('More') ?>
-
t('Less') ?>
+
t('Less') ?>