Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
256 changes: 131 additions & 125 deletions apps/files_sharing/css/sharetabview.css

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion apps/files_versions/tests/js/versionmodelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('OCA.Versions.VersionModel', function() {

var requestStub;
var requestDeferred;
var currentUserStub;

beforeEach(function() {
model = new VersionModel({
Expand All @@ -25,12 +26,13 @@ describe('OCA.Versions.VersionModel', function() {
name: 'some file.txt',
size: 150,
});
OC.currentUser = 'user0';
currentUserStub = sinon.stub(OC, 'getCurrentUser').returns({uid: 'user0'});

requestDeferred = new $.Deferred();
requestStub = sinon.stub(dav.Client.prototype, 'request').returns(requestDeferred.promise());
});
afterEach(function() {
currentUserStub.restore();
requestStub.restore();
});

Expand Down
41 changes: 35 additions & 6 deletions core/ajax/share.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$defaults,
\OC::$server->getURLGenerator()
);

$result = $mailNotification->sendInternalShareMail($recipientList, $itemSource, $itemType);

// if we were able to send to at least one recipient, mark as sent
Expand All @@ -143,7 +144,7 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
} else {
OCP\JSON::error([
'data' => [
'message' => $l->t("Couldn't send mail to following users: %s ",
'message' => $l->t("Couldn't send mail to following recipient(s): %s ",
implode(', ', $result)
)
]
Expand All @@ -160,6 +161,7 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
break;

case 'email':

// read and filter post variables
$filter = new MailNotificationFilter([
'link' => $_POST['link'],
Expand All @@ -168,9 +170,26 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
'expiration' => $_POST['expiration']
]);

// read post variables
$link = (string)$_POST['link'];
$file = (string)$_POST['file'];
$toAddress = (string)$_POST['toAddress'];
$options = array();
$emailBody = null;

if (isset($_POST['emailBody'])) {
$emailBody = trim((string)$_POST['emailBody']);
}

if (isset($_POST['bccSelf']) && $_POST['bccSelf'] === 'true') {
$options['bcc'] = \OC::$server->getUserSession()->getUser()->getEMailAddress();
}

$l10n = \OC::$server->getL10N('lib');

$mailNotification = new \OC\Share\MailNotifications(
\OC::$server->getUserSession()->getUser(),
\OC::$server->getL10N('lib'),
$l10n,
\OC::$server->getMailer(),
\OC::$server->getLogger(),
$defaults,
Expand All @@ -191,6 +210,16 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$filter->getToAddress(), $filter->getFile(), $filter->getLink(), $expiration
);

$subject = (string)$l10n->t('%s shared »%s« with you', [$this->senderDisplayName, $filename]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit surprised that we now suddenly have a hard-coded subject here. Was this subject always empty in the past ? Does it not come from the template if not set ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blame says you wrote this "a month ago" … but it's not working 🌵

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I need to consult with my past self...

if ($emailBody === null || $emailBody === '') {
list($htmlBody, $textBody) = $mailNotification->createMailBody($file, $link, $expiration);
} else {
$htmlBody = null;
$textBody = strip_tags($emailBody);
}

$result = $mailNotification->sendLinkShareMailFromBody($toAddress, $subject, $htmlBody, $textBody, $options);

if(empty($result)) {
// Get the token from the link
$linkParts = explode('/', $link);
Expand All @@ -217,7 +246,7 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
->setAuthor($currentUser)
->setAffectedUser($currentUser)
->setObject('files', $fileId, $path)
->setSubject(\OCA\Files_Sharing\Activity::SUBJECT_SHARED_EMAIL, [$path, $to_address]);
->setSubject(\OCA\Files_Sharing\Activity::SUBJECT_SHARED_EMAIL, [$path, $toAddress]);
\OC::$server->getActivityManager()->publish($event);
}
}
Expand All @@ -228,7 +257,7 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$l = \OC::$server->getL10N('core');
OCP\JSON::error([
'data' => [
'message' => $l->t("Couldn't send mail to following users: %s ",
'message' => $l->t("Couldn't send mail to following recipient(s): %s ",
implode(', ', $result)
)
]
Expand Down Expand Up @@ -323,12 +352,12 @@ function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
$sharedGroups = [];
if (isset($_GET['itemShares'])) {
if (isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER]) &&
is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) {
is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_USER])) {
$sharedUsers = $_GET['itemShares'][OCP\Share::SHARE_TYPE_USER];
}

if (isset($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP]) &&
is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])) {
is_array($_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP])) {
$sharedGroups = $_GET['itemShares'][OCP\Share::SHARE_TYPE_GROUP];
}
}
Expand Down
32 changes: 28 additions & 4 deletions core/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

/* Global Components */

/* Positioning */

.absolute-center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

.pull-left {
float: left;
}
Expand All @@ -24,7 +33,7 @@
clear: both;
}

.hidden {
.hidden.hidden {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate hidden?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. This a lesser version of the !important statement;

display: none;
}

Expand All @@ -41,10 +50,25 @@
font-weight:600;
}

.center {
text-align:center;
.text-small {
font-size: 80%;
}

.inlineblock {
display: inline-block;
}
}

/* Text */

.text-right {
text-align: right;
}

.center,
.text-center {
text-align: center;
}

.text-left {
text-align: left;
}
31 changes: 9 additions & 22 deletions core/css/jquery.ocdialog.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,29 +91,11 @@
height : 100%;
}

.error-message-global {
.error-message-global,
.success-message-global {
background-color : rgb(242, 222, 222);
border-bottom-color : rgb(235, 204, 209);
border-bottom-left-radius : 4px;
border-bottom-right-radius: 4px;
border-bottom-style : solid;
border-bottom-width : 1px;
border-image-outset : 0 0 0 0;
border-image-repeat : stretch stretch;
border-image-slice : 100% 100% 100% 100%;
border-image-source : none;
border-image-width : 1 1 1 1;
border-left-color : rgb(235, 204, 209);
border-left-style : solid;
border-left-width : 1px;
border-right-color : rgb(235, 204, 209);
border-right-style : solid;
border-right-width : 1px;
border-top-color : rgb(235, 204, 209);
border-top-left-radius : 4px;
border-top-right-radius : 4px;
border-top-style : solid;
border-top-width : 1px;
border : 1px solid rgb(235, 204, 209);
border-radius : 4px;
box-sizing : border-box;
color : rgb(169, 68, 66);
font-family : Verdana,sans-serif;
Expand All @@ -130,5 +112,10 @@
-moz-border-left-colors : none;
-moz-border-right-colors : none;
-moz-border-top-colors : none;
}

.success-message-global {
background-color: rgb(222, 242, 226);
border-color : rgb(177, 218, 186);
color : rgb(66, 169, 76);
}
20 changes: 20 additions & 0 deletions core/css/share.css
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,23 @@ a.showCruds:hover,a.unshare:hover {
padding-top: 12px;
color: #999;
}

/* Private Link share Form */

.emailPrivateLinkForm {
position: relative;
}

.emailPrivateLinkForm--send-indicator {
z-index: 2;
/* overriding default padding */
padding: 5px 15px !important;
}

.emailPrivateLinkForm--addAddressButton {
position: absolute;
right: 13px;
margin-top: -30px;
z-index: 1;
color: #999;
}
9 changes: 9 additions & 0 deletions core/js/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,15 @@
// remove status.php info as we already have the version above
unset($caps['core']['status']);
$array['oc_capabilities'] = json_encode($caps);

$user = \OC::$server->getUserSession()->getUser();
if ($user !== null) {
$array['oc_user'] = json_encode([
'uid' => $user->getUID(),
'displayName' => $user->getDisplayName(),
'email' => $user->getEMailAddress()
]);
}
}

// Allow hooks to modify the output values
Expand Down
12 changes: 6 additions & 6 deletions core/js/js.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
var oc_debug;
var oc_webroot;

var oc_current_user = document.getElementsByTagName('head')[0].getAttribute('data-user');
var oc_requesttoken = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken');

window.oc_config = window.oc_config || {};
Expand Down Expand Up @@ -82,7 +81,7 @@ var OC = {
* @type String
* @deprecated use {@link OC.getCurrentUser} instead
*/
currentUser: (typeof oc_current_user !== 'undefined') ? oc_current_user : false,
currentUser: (typeof oc_user !== 'undefined') ? oc_user.uid : false,
config: window.oc_config,
appConfig: window.oc_appconfig || {},
theme: window.oc_defaults || {},
Expand Down Expand Up @@ -322,12 +321,13 @@ var OC = {
* @since 9.0.0
*/
getCurrentUser: function () {
if (_.isUndefined(this._currentUserDisplayName)) {
this._currentUserDisplayName = document.getElementsByTagName('head')[0].getAttribute('data-user-displayname');
if (!_.isUndefined(window.oc_user)) {
return oc_user;
}
return {
uid: this.currentUser,
displayName: this._currentUserDisplayName
uid: null,
displayName: null,
email: null
};
},

Expand Down
2 changes: 1 addition & 1 deletion core/js/sharedialogexpirationview.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
cid: this.cid,
setExpirationLabel: t('core', 'Set expiration date'),
expirationLabel: t('core', 'Expiration'),
expirationDatePlaceholder: t('core', 'Expiration date'),
expirationDatePlaceholder: t('core', 'Choose an expiration date'),
defaultExpireMessage: defaultExpireMessage,
isExpirationSet: isExpirationSet,
isExpirationEnforced: isExpirationEnforced,
Expand Down
30 changes: 18 additions & 12 deletions core/js/sharedialoglinkshareview.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

var PASSWORD_PLACEHOLDER_STARS = '**********';
var PASSWORD_PLACEHOLDER_MESSAGE = t('core', 'Choose a password for the public link');
var PASSWORD_PLACEHOLDER_MESSAGE = t('core', 'Choose a password');
var TEMPLATE =
'<div class="error-message-global hidden"></div>' +
'<div class="public-link-modal">'+
Expand Down Expand Up @@ -194,11 +194,8 @@
success: function() {
if (self.mailView) {
// also send out email first
self.mailView.sendEmails().then(done).fail(function() {
done();
// re-show the popup
self.show();
});
// do not resolve on errors
self.mailView.sendEmails().then(done);
} else {
done();
}
Expand Down Expand Up @@ -243,7 +240,7 @@

publicUploadPossible : this._isPublicUploadPossible(),

publicUploadLabel : t('core', 'Upload only (File Drop)'),
publicUploadLabel : t('core', 'Upload only') + ' (File Drop)',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why you pulled "File Drop" out of the translation ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was an awful translation and we want to keep its original name (File Drop) across languages.

publicUploadDescription : t('core', 'Receive files from others without revealing the contents of the folder.'),
publicUploadValue : OC.PERMISSION_CREATE,
publicUploadSelected : this.model.get('permissions') === OC.PERMISSION_CREATE,
Expand Down Expand Up @@ -326,18 +323,27 @@
var self = this;
var title = t('files_sharing', 'Edit link share: {name}', {name: this.itemModel.getFileInfo().getFullPath()});
var buttons = [{
text: t('core', 'Save'),
click: _.bind(this._onClickSave, this),
defaultButton: true
}, {
text: t('core', 'Cancel'),
click: _.bind(this._onClickCancel, this)
}];

if (this.model.isNew()) {
title = t('files_sharing', 'Create link share: {name}', {name: this.itemModel.getFileInfo().getFullPath()});
buttons.unshift({
text: t('core', 'Share'),
click: _.bind(this._onClickSave, this),
defaultButton: true
})
}
else if (this.model.get('encryptedPassword')) {
else {
buttons.unshift({
text: t('core', 'Save'),
click: _.bind(this._onClickSave, this),
defaultButton: true
})
}

if (this.model.get('encryptedPassword')) {
buttons.push({
classes: 'removePassword -float-left',
text: t('core', 'Remove password'),
Expand Down
Loading