Merge branch 'master' into fix_file_cache_updater_master
This commit is contained in:
commit
e1e4c7c214
11 changed files with 129 additions and 68 deletions
|
@ -334,8 +334,13 @@ $(document).ready(function() {
|
||||||
var result=$.parseJSON(response);
|
var result=$.parseJSON(response);
|
||||||
|
|
||||||
delete data.jqXHR;
|
delete data.jqXHR;
|
||||||
|
|
||||||
if (typeof result[0] === 'undefined') {
|
if (result.status === 'error' && result.data && result.data.message){
|
||||||
|
data.textStatus = 'servererror';
|
||||||
|
data.errorThrown = result.data.message;
|
||||||
|
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
|
||||||
|
fu._trigger('fail', e, data);
|
||||||
|
} else if (typeof result[0] === 'undefined') {
|
||||||
data.textStatus = 'servererror';
|
data.textStatus = 'servererror';
|
||||||
data.errorThrown = t('files', 'Could not get result from server.');
|
data.errorThrown = t('files', 'Could not get result from server.');
|
||||||
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
|
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
|
||||||
|
|
|
@ -4,14 +4,14 @@ body {
|
||||||
|
|
||||||
#header {
|
#header {
|
||||||
background: #1d2d44 url('%webroot%/core/img/noise.png') repeat;
|
background: #1d2d44 url('%webroot%/core/img/noise.png') repeat;
|
||||||
height:2.5em;
|
height:32px;
|
||||||
left:0;
|
left:0;
|
||||||
line-height:2.5em;
|
line-height:32px;
|
||||||
position:fixed;
|
position:fixed;
|
||||||
right:0;
|
right:0;
|
||||||
top:0;
|
top:0;
|
||||||
z-index:100;
|
z-index:100;
|
||||||
padding:.5em;
|
padding:7px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#details {
|
#details {
|
||||||
|
@ -24,13 +24,18 @@ body {
|
||||||
font-weight:700;
|
font-weight:700;
|
||||||
margin: 0 0.4em 0 0;
|
margin: 0 0.4em 0 0;
|
||||||
padding: 0 5px;
|
padding: 0 5px;
|
||||||
height: 27px;
|
height: 32px;
|
||||||
float: left;
|
float: left;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-right #details {
|
.header-right #details {
|
||||||
margin-right: 2em;
|
margin-right: 28px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-right {
|
||||||
|
padding: 0;
|
||||||
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#public_upload {
|
#public_upload {
|
||||||
|
@ -90,7 +95,7 @@ thead{
|
||||||
#data-upload-form {
|
#data-upload-form {
|
||||||
position: relative;
|
position: relative;
|
||||||
right: 0;
|
right: 0;
|
||||||
height: 27px;
|
height: 32px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
float: right;
|
float: right;
|
||||||
|
@ -109,27 +114,20 @@ thead{
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
#download span {
|
|
||||||
position: relative;
|
|
||||||
bottom: 3px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#publicUploadButtonMock {
|
#publicUploadButtonMock {
|
||||||
position:relative;
|
position:relative;
|
||||||
display:block;
|
display:block;
|
||||||
width:100%;
|
width:100%;
|
||||||
height:27px;
|
height:32px;
|
||||||
cursor:pointer;
|
cursor:pointer;
|
||||||
z-index:10;
|
z-index:10;
|
||||||
background-image:url('%webroot%/core/img/actions/upload.svg');
|
background-image:url('%webroot%/core/img/actions/upload.svg');
|
||||||
background-repeat:no-repeat;
|
background-repeat:no-repeat;
|
||||||
background-position:7px 6px;
|
background-position:7px 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#publicUploadButtonMock span {
|
#publicUploadButtonMock span {
|
||||||
margin: 0 5px 0 28px;
|
margin: 0 5px 0 28px;
|
||||||
position: relative;
|
|
||||||
top: -2px;
|
|
||||||
color: #555;
|
color: #555;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,14 +35,14 @@ $(document).ready(function() {
|
||||||
if ($(tr).data('id') != $('#dropdown').attr('data-item-source')) {
|
if ($(tr).data('id') != $('#dropdown').attr('data-item-source')) {
|
||||||
OC.Share.hideDropDown(function () {
|
OC.Share.hideDropDown(function () {
|
||||||
$(tr).addClass('mouseOver');
|
$(tr).addClass('mouseOver');
|
||||||
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
|
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
OC.Share.hideDropDown();
|
OC.Share.hideDropDown();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$(tr).addClass('mouseOver');
|
$(tr).addClass('mouseOver');
|
||||||
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions);
|
OC.Share.showDropDown(itemType, $(tr).data('id'), appendTo, true, possiblePermissions, filename);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,8 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
|
||||||
$_POST['itemSource'],
|
$_POST['itemSource'],
|
||||||
$shareType,
|
$shareType,
|
||||||
$shareWith,
|
$shareWith,
|
||||||
$_POST['permissions']
|
$_POST['permissions'],
|
||||||
|
$_POST['itemSourceName']
|
||||||
);
|
);
|
||||||
|
|
||||||
if (is_string($token)) {
|
if (is_string($token)) {
|
||||||
|
|
|
@ -136,8 +136,17 @@ OC.Share={
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
},
|
},
|
||||||
share:function(itemType, itemSource, shareType, shareWith, permissions, callback) {
|
share:function(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, callback) {
|
||||||
$.post(OC.filePath('core', 'ajax', 'share.php'), { action: 'share', itemType: itemType, itemSource: itemSource, shareType: shareType, shareWith: shareWith, permissions: permissions }, function(result) {
|
$.post(OC.filePath('core', 'ajax', 'share.php'),
|
||||||
|
{
|
||||||
|
action: 'share',
|
||||||
|
itemType: itemType,
|
||||||
|
itemSource: itemSource,
|
||||||
|
shareType: shareType,
|
||||||
|
shareWith: shareWith,
|
||||||
|
permissions: permissions,
|
||||||
|
itemSourceName: itemSourceName
|
||||||
|
}, function (result) {
|
||||||
if (result && result.status === 'success') {
|
if (result && result.status === 'success') {
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(result.data);
|
callback(result.data);
|
||||||
|
@ -170,9 +179,9 @@ OC.Share={
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions) {
|
showDropDown:function(itemType, itemSource, appendTo, link, possiblePermissions, filename) {
|
||||||
var data = OC.Share.loadItem(itemType, itemSource);
|
var data = OC.Share.loadItem(itemType, itemSource);
|
||||||
var html = '<div id="dropdown" class="drop" data-item-type="'+itemType+'" data-item-source="'+itemSource+'">';
|
var html = '<div id="dropdown" class="drop" data-item-type="'+itemType+'" data-item-source="'+itemSource+'"" data-item-source-name="'+filename+'">';
|
||||||
if (data !== false && data.reshare !== false && data.reshare.uid_owner !== undefined) {
|
if (data !== false && data.reshare !== false && data.reshare.uid_owner !== undefined) {
|
||||||
if (data.reshare.share_type == OC.Share.SHARE_TYPE_GROUP) {
|
if (data.reshare.share_type == OC.Share.SHARE_TYPE_GROUP) {
|
||||||
html += '<span class="reshare">'+t('core', 'Shared with you and the group {group} by {owner}', {group: escapeHTML(data.reshare.share_with), owner: escapeHTML(data.reshare.displayname_owner)})+'</span>';
|
html += '<span class="reshare">'+t('core', 'Shared with you and the group {group} by {owner}', {group: escapeHTML(data.reshare.share_with), owner: escapeHTML(data.reshare.displayname_owner)})+'</span>';
|
||||||
|
@ -276,12 +285,13 @@ OC.Share={
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
var itemType = $('#dropdown').data('item-type');
|
var itemType = $('#dropdown').data('item-type');
|
||||||
var itemSource = $('#dropdown').data('item-source');
|
var itemSource = $('#dropdown').data('item-source');
|
||||||
|
var itemSourceName = $('#dropdown').data('item-source-name');
|
||||||
var shareType = selected.item.value.shareType;
|
var shareType = selected.item.value.shareType;
|
||||||
var shareWith = selected.item.value.shareWith;
|
var shareWith = selected.item.value.shareWith;
|
||||||
$(this).val(shareWith);
|
$(this).val(shareWith);
|
||||||
// Default permissions are Edit (CRUD) and Share
|
// Default permissions are Edit (CRUD) and Share
|
||||||
var permissions = OC.PERMISSION_ALL;
|
var permissions = OC.PERMISSION_ALL;
|
||||||
OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, function() {
|
OC.Share.share(itemType, itemSource, shareType, shareWith, permissions, itemSourceName, function() {
|
||||||
OC.Share.addShareWith(shareType, shareWith, selected.item.label, permissions, possiblePermissions);
|
OC.Share.addShareWith(shareType, shareWith, selected.item.label, permissions, possiblePermissions);
|
||||||
$('#shareWith').val('');
|
$('#shareWith').val('');
|
||||||
OC.Share.updateIcon(itemType, itemSource);
|
OC.Share.updateIcon(itemType, itemSource);
|
||||||
|
@ -573,9 +583,10 @@ $(document).ready(function() {
|
||||||
$(document).on('change', '#dropdown #linkCheckbox', function() {
|
$(document).on('change', '#dropdown #linkCheckbox', function() {
|
||||||
var itemType = $('#dropdown').data('item-type');
|
var itemType = $('#dropdown').data('item-type');
|
||||||
var itemSource = $('#dropdown').data('item-source');
|
var itemSource = $('#dropdown').data('item-source');
|
||||||
|
var itemSourceName = $('#dropdown').data('item-source-name');
|
||||||
if (this.checked) {
|
if (this.checked) {
|
||||||
// Create a link
|
// Create a link
|
||||||
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, function(data) {
|
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', OC.PERMISSION_READ, itemSourceName, function(data) {
|
||||||
OC.Share.showLink(data.token, null, itemSource);
|
OC.Share.showLink(data.token, null, itemSource);
|
||||||
OC.Share.updateIcon(itemType, itemSource);
|
OC.Share.updateIcon(itemType, itemSource);
|
||||||
});
|
});
|
||||||
|
@ -604,6 +615,7 @@ $(document).ready(function() {
|
||||||
var allowPublicUpload = $(this).is(':checked');
|
var allowPublicUpload = $(this).is(':checked');
|
||||||
var itemType = $('#dropdown').data('item-type');
|
var itemType = $('#dropdown').data('item-type');
|
||||||
var itemSource = $('#dropdown').data('item-source');
|
var itemSource = $('#dropdown').data('item-source');
|
||||||
|
var itemSourceName = $('#dropdown').data('item-source-name');
|
||||||
var permissions = 0;
|
var permissions = 0;
|
||||||
|
|
||||||
// Calculate permissions
|
// Calculate permissions
|
||||||
|
@ -614,7 +626,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the share information
|
// Update the share information
|
||||||
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions, function(data) {
|
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions, itemSourceName, function(data) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -623,6 +635,7 @@ $(document).ready(function() {
|
||||||
if (!$('#showPassword').is(':checked') ) {
|
if (!$('#showPassword').is(':checked') ) {
|
||||||
var itemType = $('#dropdown').data('item-type');
|
var itemType = $('#dropdown').data('item-type');
|
||||||
var itemSource = $('#dropdown').data('item-source');
|
var itemSource = $('#dropdown').data('item-source');
|
||||||
|
var itemSourceName = $('#dropdown').data('item-source-name');
|
||||||
var allowPublicUpload = $('#sharingDialogAllowPublicUpload').is(':checked');
|
var allowPublicUpload = $('#sharingDialogAllowPublicUpload').is(':checked');
|
||||||
var permissions = 0;
|
var permissions = 0;
|
||||||
|
|
||||||
|
@ -634,7 +647,7 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions);
|
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, '', permissions, itemSourceName);
|
||||||
} else {
|
} else {
|
||||||
$('#linkPassText').focus();
|
$('#linkPassText').focus();
|
||||||
}
|
}
|
||||||
|
@ -648,6 +661,7 @@ $(document).ready(function() {
|
||||||
var dropDown = $('#dropdown');
|
var dropDown = $('#dropdown');
|
||||||
var itemType = dropDown.data('item-type');
|
var itemType = dropDown.data('item-type');
|
||||||
var itemSource = dropDown.data('item-source');
|
var itemSource = dropDown.data('item-source');
|
||||||
|
var itemSourceName = $('#dropdown').data('item-source-name');
|
||||||
var permissions = 0;
|
var permissions = 0;
|
||||||
|
|
||||||
// Calculate permissions
|
// Calculate permissions
|
||||||
|
@ -657,7 +671,7 @@ $(document).ready(function() {
|
||||||
permissions = OC.PERMISSION_READ;
|
permissions = OC.PERMISSION_READ;
|
||||||
}
|
}
|
||||||
|
|
||||||
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, function() {
|
OC.Share.share(itemType, itemSource, OC.Share.SHARE_TYPE_LINK, $('#linkPassText').val(), permissions, itemSourceName, function() {
|
||||||
console.log("password set to: '" + linkPassText.val() +"' by event: " + event.type);
|
console.log("password set to: '" + linkPassText.val() +"' by event: " + event.type);
|
||||||
linkPassText.val('');
|
linkPassText.val('');
|
||||||
linkPassText.attr('placeholder', t('core', 'Password protected'));
|
linkPassText.attr('placeholder', t('core', 'Password protected'));
|
||||||
|
|
4
lib/private/files/cache/cache.php
vendored
4
lib/private/files/cache/cache.php
vendored
|
@ -64,6 +64,10 @@ class Cache {
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getMimetypeId($mime) {
|
public function getMimetypeId($mime) {
|
||||||
|
if (empty($mime)) {
|
||||||
|
// Can not insert empty string into Oracle NOT NULL column.
|
||||||
|
$mime = 'application/octet-stream';
|
||||||
|
}
|
||||||
if (empty(self::$mimetypeIds)) {
|
if (empty(self::$mimetypeIds)) {
|
||||||
$this->loadMimetypes();
|
$this->loadMimetypes();
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,6 @@ class Detection {
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function detect($path) {
|
public function detect($path) {
|
||||||
$isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://');
|
|
||||||
|
|
||||||
if (@is_dir($path)) {
|
if (@is_dir($path)) {
|
||||||
// directories are easy
|
// directories are easy
|
||||||
return "httpd/unix-directory";
|
return "httpd/unix-directory";
|
||||||
|
@ -76,9 +74,11 @@ class Detection {
|
||||||
$info = @strtolower(finfo_file($finfo, $path));
|
$info = @strtolower(finfo_file($finfo, $path));
|
||||||
if ($info) {
|
if ($info) {
|
||||||
$mimeType = substr($info, 0, strpos($info, ';'));
|
$mimeType = substr($info, 0, strpos($info, ';'));
|
||||||
|
return empty($mimeType) ? 'application/octet-stream' : $mimeType;
|
||||||
}
|
}
|
||||||
finfo_close($finfo);
|
finfo_close($finfo);
|
||||||
}
|
}
|
||||||
|
$isWrapped = (strpos($path, '://') !== false) and (substr($path, 0, 7) === 'file://');
|
||||||
if (!$isWrapped and $mimeType === 'application/octet-stream' && function_exists("mime_content_type")) {
|
if (!$isWrapped and $mimeType === 'application/octet-stream' && function_exists("mime_content_type")) {
|
||||||
// use mime magic extension if available
|
// use mime magic extension if available
|
||||||
$mimeType = mime_content_type($path);
|
$mimeType = mime_content_type($path);
|
||||||
|
@ -94,6 +94,10 @@ class Detection {
|
||||||
//trim the newline
|
//trim the newline
|
||||||
$mimeType = trim($reply);
|
$mimeType = trim($reply);
|
||||||
|
|
||||||
|
if (empty($mimeType)) {
|
||||||
|
$mimeType = 'application/octet-stream';
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return $mimeType;
|
return $mimeType;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,27 +88,27 @@ class URLGenerator implements IURLGenerator {
|
||||||
if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
|
if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) {
|
||||||
return \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
|
return \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image";
|
||||||
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
|
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg")
|
||||||
&& file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
|
&& file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) {
|
||||||
return \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png";
|
return \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png";
|
||||||
} elseif (file_exists(\OC_App::getAppPath($app) . "/img/$image")) {
|
} elseif (file_exists(\OC_App::getAppPath($app) . "/img/$image")) {
|
||||||
return \OC_App::getAppWebPath($app) . "/img/$image";
|
return \OC_App::getAppWebPath($app) . "/img/$image";
|
||||||
} elseif (!file_exists(\OC_App::getAppPath($app) . "/img/$basename.svg")
|
} elseif (!file_exists(\OC_App::getAppPath($app) . "/img/$basename.svg")
|
||||||
&& file_exists(\OC_App::getAppPath($app) . "/img/$basename.png")) {
|
&& file_exists(\OC_App::getAppPath($app) . "/img/$basename.png")) {
|
||||||
return \OC_App::getAppPath($app) . "/img/$basename.png";
|
return \OC_App::getAppPath($app) . "/img/$basename.png";
|
||||||
} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
|
} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) {
|
||||||
return \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
|
return \OC::$WEBROOT . "/themes/$theme/$app/img/$image";
|
||||||
} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
|
} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg")
|
||||||
&& file_exists(\OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png"))) {
|
&& file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) {
|
||||||
return \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png";
|
return \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png";
|
||||||
} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
|
} elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) {
|
||||||
return \OC::$WEBROOT . "/$app/img/$image";
|
return \OC::$WEBROOT . "/$app/img/$image";
|
||||||
} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
|
} elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg")
|
||||||
&& file_exists(\OC::$WEBROOT . "/$app/img/$basename.png"))) {
|
&& file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) {
|
||||||
return \OC::$WEBROOT . "/$app/img/$basename.png";
|
return \OC::$WEBROOT . "/$app/img/$basename.png";
|
||||||
} elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
|
} elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) {
|
||||||
return \OC::$WEBROOT . "/themes/$theme/core/img/$image";
|
return \OC::$WEBROOT . "/themes/$theme/core/img/$image";
|
||||||
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
|
} elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg")
|
||||||
&& file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
|
&& file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) {
|
||||||
return \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
|
return \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png";
|
||||||
} elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
|
} elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) {
|
||||||
return \OC::$WEBROOT . "/core/img/$image";
|
return \OC::$WEBROOT . "/core/img/$image";
|
||||||
|
|
|
@ -187,18 +187,25 @@ class OC_User {
|
||||||
public static function deleteUser($uid) {
|
public static function deleteUser($uid) {
|
||||||
$user = self::getManager()->get($uid);
|
$user = self::getManager()->get($uid);
|
||||||
if ($user) {
|
if ($user) {
|
||||||
$user->delete();
|
$result = $user->delete();
|
||||||
|
|
||||||
// We have to delete the user from all groups
|
// if delete was successful we clean-up the rest
|
||||||
foreach (OC_Group::getUserGroups($uid) as $i) {
|
if ($result) {
|
||||||
OC_Group::removeFromGroup($uid, $i);
|
|
||||||
|
// We have to delete the user from all groups
|
||||||
|
foreach (OC_Group::getUserGroups($uid) as $i) {
|
||||||
|
OC_Group::removeFromGroup($uid, $i);
|
||||||
|
}
|
||||||
|
// Delete the user's keys in preferences
|
||||||
|
OC_Preferences::deleteUser($uid);
|
||||||
|
|
||||||
|
// Delete user files in /data/
|
||||||
|
OC_Helper::rmdirr(OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid . '/');
|
||||||
|
|
||||||
|
// Remove it from the Cache
|
||||||
|
self::getManager()->delete($uid);
|
||||||
}
|
}
|
||||||
// Delete the user's keys in preferences
|
|
||||||
OC_Preferences::deleteUser($uid);
|
|
||||||
|
|
||||||
// Delete user files in /data/
|
|
||||||
OC_Helper::rmdirr(OC_Config::getValue('datadirectory', OC::$SERVERROOT . '/data') . '/' . $uid . '/');
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -118,6 +118,20 @@ class Manager extends PublicEmitter {
|
||||||
return ($user !== null);
|
return ($user !== null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* remove deleted user from cache
|
||||||
|
*
|
||||||
|
* @param string $uid
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function delete($uid) {
|
||||||
|
if (isset($this->cachedUsers[$uid])) {
|
||||||
|
unset($this->cachedUsers[$uid]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the password is valid for the user
|
* Check if the password is valid for the user
|
||||||
*
|
*
|
||||||
|
|
|
@ -428,33 +428,45 @@ class Share {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Share an item with a user, group, or via private link
|
* Share an item with a user, group, or via private link
|
||||||
* @param string Item type
|
* @param string $itemType
|
||||||
* @param string Item source
|
* @param string $itemSource
|
||||||
* @param int SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
|
* @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
|
||||||
* @param string User or group the item is being shared with
|
* @param string $shareWith User or group the item is being shared with
|
||||||
* @param int CRUDS permissions
|
* @param int $permissions CRUDS
|
||||||
* @return bool|string Returns true on success or false on failure, Returns token on success for links
|
* @param null $itemSourceName
|
||||||
*/
|
* @throws \Exception
|
||||||
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions) {
|
* @internal param \OCP\Item $string type
|
||||||
|
* @internal param \OCP\Item $string source
|
||||||
|
* @internal param \OCP\SHARE_TYPE_USER $int , SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
|
||||||
|
* @internal param \OCP\User $string or group the item is being shared with
|
||||||
|
* @internal param \OCP\CRUDS $int permissions
|
||||||
|
* @return bool|string Returns true on success or false on failure, Returns token on success for links
|
||||||
|
*/
|
||||||
|
public static function shareItem($itemType, $itemSource, $shareType, $shareWith, $permissions, $itemSourceName = null) {
|
||||||
$uidOwner = \OC_User::getUser();
|
$uidOwner = \OC_User::getUser();
|
||||||
$sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
|
$sharingPolicy = \OC_Appconfig::getValue('core', 'shareapi_share_policy', 'global');
|
||||||
|
|
||||||
|
if (is_null($itemSourceName)) {
|
||||||
|
$itemSourceName = $itemSource;
|
||||||
|
}
|
||||||
|
|
||||||
// Verify share type and sharing conditions are met
|
// Verify share type and sharing conditions are met
|
||||||
if ($shareType === self::SHARE_TYPE_USER) {
|
if ($shareType === self::SHARE_TYPE_USER) {
|
||||||
if ($shareWith == $uidOwner) {
|
if ($shareWith == $uidOwner) {
|
||||||
$message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is the item owner';
|
$message = 'Sharing '.$itemSourceName.' failed, because the user '.$shareWith.' is the item owner';
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
if (!\OC_User::userExists($shareWith)) {
|
if (!\OC_User::userExists($shareWith)) {
|
||||||
$message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' does not exist';
|
$message = 'Sharing '.$itemSourceName.' failed, because the user '.$shareWith.' does not exist';
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
if ($sharingPolicy == 'groups_only') {
|
if ($sharingPolicy == 'groups_only') {
|
||||||
$inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith));
|
$inGroup = array_intersect(\OC_Group::getUserGroups($uidOwner), \OC_Group::getUserGroups($shareWith));
|
||||||
if (empty($inGroup)) {
|
if (empty($inGroup)) {
|
||||||
$message = 'Sharing '.$itemSource.' failed, because the user '
|
$message = 'Sharing '.$itemSourceName.' failed, because the user '
|
||||||
.$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of';
|
.$shareWith.' is not a member of any groups that '.$uidOwner.' is a member of';
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
|
@ -467,19 +479,19 @@ class Share {
|
||||||
// owner and is not a user share, this use case is for increasing
|
// owner and is not a user share, this use case is for increasing
|
||||||
// permissions for a specific user
|
// permissions for a specific user
|
||||||
if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
|
if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
|
||||||
$message = 'Sharing '.$itemSource.' failed, because this item is already shared with '.$shareWith;
|
$message = 'Sharing '.$itemSourceName.' failed, because this item is already shared with '.$shareWith;
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if ($shareType === self::SHARE_TYPE_GROUP) {
|
} else if ($shareType === self::SHARE_TYPE_GROUP) {
|
||||||
if (!\OC_Group::groupExists($shareWith)) {
|
if (!\OC_Group::groupExists($shareWith)) {
|
||||||
$message = 'Sharing '.$itemSource.' failed, because the group '.$shareWith.' does not exist';
|
$message = 'Sharing '.$itemSourceName.' failed, because the group '.$shareWith.' does not exist';
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) {
|
if ($sharingPolicy == 'groups_only' && !\OC_Group::inGroup($uidOwner, $shareWith)) {
|
||||||
$message = 'Sharing '.$itemSource.' failed, because '
|
$message = 'Sharing '.$itemSourceName.' failed, because '
|
||||||
.$uidOwner.' is not a member of the group '.$shareWith;
|
.$uidOwner.' is not a member of the group '.$shareWith;
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
|
@ -492,7 +504,7 @@ class Share {
|
||||||
// owner and is not a group share, this use case is for increasing
|
// owner and is not a group share, this use case is for increasing
|
||||||
// permissions for a specific user
|
// permissions for a specific user
|
||||||
if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
|
if ($checkExists['uid_owner'] != $uidOwner || $checkExists['share_type'] == $shareType) {
|
||||||
$message = 'Sharing '.$itemSource.' failed, because this item is already shared with '.$shareWith;
|
$message = 'Sharing '.$itemSourceName.' failed, because this item is already shared with '.$shareWith;
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
|
@ -534,14 +546,14 @@ class Share {
|
||||||
$token = \OC_Util::generateRandomBytes(self::TOKEN_LENGTH);
|
$token = \OC_Util::generateRandomBytes(self::TOKEN_LENGTH);
|
||||||
}
|
}
|
||||||
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions,
|
$result = self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions,
|
||||||
null, $token);
|
null, $token, $itemSourceName);
|
||||||
if ($result) {
|
if ($result) {
|
||||||
return $token;
|
return $token;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$message = 'Sharing '.$itemSource.' failed, because sharing with links is not allowed';
|
$message = 'Sharing '.$itemSourceName.' failed, because sharing with links is not allowed';
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
return false;
|
return false;
|
||||||
|
@ -600,7 +612,7 @@ class Share {
|
||||||
// return false;
|
// return false;
|
||||||
// } else {
|
// } else {
|
||||||
// Put the item into the database
|
// Put the item into the database
|
||||||
return self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions);
|
return self::put($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $permissions, null, null, $itemSourceName);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1320,20 +1332,22 @@ class Share {
|
||||||
* @return bool Returns true on success or false on failure
|
* @return bool Returns true on success or false on failure
|
||||||
*/
|
*/
|
||||||
private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
|
private static function put($itemType, $itemSource, $shareType, $shareWith, $uidOwner,
|
||||||
$permissions, $parentFolder = null, $token = null) {
|
$permissions, $parentFolder = null, $token = null, $itemSourceName = null) {
|
||||||
$backend = self::getBackend($itemType);
|
$backend = self::getBackend($itemType);
|
||||||
|
|
||||||
// Check if this is a reshare
|
// Check if this is a reshare
|
||||||
if ($checkReshare = self::getItemSharedWithBySource($itemType, $itemSource, self::FORMAT_NONE, null, true)) {
|
if ($checkReshare = self::getItemSharedWithBySource($itemType, $itemSource, self::FORMAT_NONE, null, true)) {
|
||||||
|
|
||||||
// Check if attempting to share back to owner
|
// Check if attempting to share back to owner
|
||||||
if ($checkReshare['uid_owner'] == $shareWith && $shareType == self::SHARE_TYPE_USER) {
|
if ($checkReshare['uid_owner'] == $shareWith && $shareType == self::SHARE_TYPE_USER) {
|
||||||
$message = 'Sharing '.$itemSource.' failed, because the user '.$shareWith.' is the original sharer';
|
$message = 'Sharing '.$itemSourceName.' failed, because the user '.$shareWith.' is the original sharer';
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
// Check if share permissions is granted
|
// Check if share permissions is granted
|
||||||
if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & PERMISSION_SHARE) {
|
if (self::isResharingAllowed() && (int)$checkReshare['permissions'] & PERMISSION_SHARE) {
|
||||||
if (~(int)$checkReshare['permissions'] & $permissions) {
|
if (~(int)$checkReshare['permissions'] & $permissions) {
|
||||||
$message = 'Sharing '.$itemSource
|
$message = 'Sharing '.$itemSourceName
|
||||||
.' failed, because the permissions exceed permissions granted to '.$uidOwner;
|
.' failed, because the permissions exceed permissions granted to '.$uidOwner;
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
|
@ -1347,7 +1361,7 @@ class Share {
|
||||||
$filePath = $checkReshare['file_target'];
|
$filePath = $checkReshare['file_target'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$message = 'Sharing '.$itemSource.' failed, because resharing is not allowed';
|
$message = 'Sharing '.$itemSourceName.' failed, because resharing is not allowed';
|
||||||
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
\OC_Log::write('OCP\Share', $message, \OC_Log::ERROR);
|
||||||
throw new \Exception($message);
|
throw new \Exception($message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue