some clean-up
This commit is contained in:
parent
10cf1b3a4e
commit
36574241f8
|
@ -97,50 +97,28 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
|
|||
$noMail = array();
|
||||
$recipientList = array();
|
||||
|
||||
if ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
|
||||
$users = \OC_Group::usersInGroup($recipient);
|
||||
foreach ($users as $user) {
|
||||
$email = OC_Preferences::getValue($user, 'settings', 'email', '');
|
||||
if ($email !== '' || $recipient === \OCP\User::getUser()) {
|
||||
$recipientList[] = array(
|
||||
'email' => $email,
|
||||
'displayName' => \OCP\User::getDisplayName($user),
|
||||
'uid' => $user,
|
||||
);
|
||||
} else {
|
||||
$noMail[] = \OCP\User::getDisplayName($user);
|
||||
}
|
||||
}
|
||||
} else { // shared to a single user
|
||||
$email = OC_Preferences::getValue($recipient, 'settings', 'email', '');
|
||||
if ($email !== '') {
|
||||
$recipientList[] = array(
|
||||
'email' => $email,
|
||||
'displayName' => \OCP\User::getDisplayName($recipient),
|
||||
'uid' => $recipient,
|
||||
);
|
||||
} else {
|
||||
$noMail[] = \OCP\User::getDisplayName($recipient);
|
||||
}
|
||||
if($shareType === \OCP\Share::SHARE_TYPE_USER) {
|
||||
$recipientList[] = $recipient;
|
||||
} elseif ($shareType === \OCP\Share::SHARE_TYPE_GROUP) {
|
||||
$recipientList = \OC_Group::usersInGroup($recipient);
|
||||
}
|
||||
|
||||
// send mail to all recipients with an email address
|
||||
foreach ($recipientList as $recipient) {
|
||||
//get correct target folder name
|
||||
$email = OC_Preferences::getValue($recipient, 'settings', 'email', '');
|
||||
|
||||
$users = \OCP\Share::getItemSharedWithUser($itemType, $itemSource, $recipient['uid']);
|
||||
$targetName = $users[0]['file_target'];
|
||||
if ($email !== '') {
|
||||
$displayName = \OCP\User::getDisplayName($recipient);
|
||||
$items = \OCP\Share::getItemSharedWithUser($itemType, $itemSource, $recipient);
|
||||
$filename = $items[0]['file_target'];
|
||||
|
||||
//$share = $shareManager->getShares($itemType, array('shareWith' => $recipient['uid'], 'isShareWithUser' => true, 'itemSource' => $itemSource));
|
||||
//$targetName = $share[0]->getItemTarget();
|
||||
if ($itemType === 'folder') {
|
||||
$foldername = "/Shared/" . $targetName;
|
||||
$filename = $targetName;
|
||||
$foldername = "/Shared/" . $filename;
|
||||
} else {
|
||||
// if it is a file we can just link to the Shared folder,
|
||||
// that's the place where the user will find the file
|
||||
$foldername = "/Shared";
|
||||
$filename = $targetName;
|
||||
}
|
||||
|
||||
$url = \OCP\Util::linkToAbsolute('files', 'index.php', array("dir" => $foldername));
|
||||
|
@ -148,8 +126,8 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
|
|||
|
||||
try {
|
||||
OCP\Util::sendMail(
|
||||
$recipient['email'],
|
||||
$recipient['displayName'],
|
||||
$email,
|
||||
$displayName,
|
||||
$subject,
|
||||
$text,
|
||||
$from,
|
||||
|
@ -158,6 +136,9 @@ if (isset($_POST['action']) && isset($_POST['itemType']) && isset($_POST['itemSo
|
|||
} catch (Exception $exception) {
|
||||
$noMail[] = \OCP\User::getDisplayName($recipient['displayName']);
|
||||
}
|
||||
} else {
|
||||
$noMail[] = \OCP\User::getDisplayName($recipient);
|
||||
}
|
||||
}
|
||||
|
||||
\OCP\Share::setSendMailStatus($itemType, $itemSource, $shareType, true);
|
||||
|
|
Loading…
Reference in New Issue