Skip to content
Open
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
3 changes: 2 additions & 1 deletion components/ILIAS/Badge/classes/class.ilBadgeHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use ILIAS\Notifications\Model\ilNotificationLink;
use ILIAS\Notifications\Model\ilNotificationParameter;
use ILIAS\Badge\GlobalScreen\BadgeNotificationProvider;
use ILIAS\Mail\Attachments\MailAttachments;

/**
* Class ilBadgeHandler
Expand Down Expand Up @@ -537,7 +538,7 @@ public function sendNotification(
'',
$lng->txt('badge_notification_subject'),
$ntf->composeAndGetMessage($user_id, null, 'read', true),
[]
MailAttachments::empty()
);


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

declare(strict_types=1);

use ILIAS\Mail\Attachments\MailAttachments;

/**
* Distributes calendar mail notifications
* @author Stefan Meyer <smeyer.ilias@gmx.de>
Expand Down Expand Up @@ -462,17 +464,19 @@ protected function addAttachment(): void
$ics_filename = 'appointment_' . (new DateTimeImmutable('now'))->format('Ymd_His_u') . '.ics';

$attachment = new ilFileDataMail($this->getSender());
$effective_ics_filename = $attachment->storeAsAttachment(
$rcid = $attachment->createCollectionFromContent(
$ics_filename,
$export->getExportString()
);

$this->setAttachments([$effective_ics_filename]);
$this->setAttachments(
$rcid !== null
? MailAttachments::fromIrss($rcid)
: MailAttachments::empty()
);
}

protected function deleteAttachments(): void
{
$attachment = new ilFileDataMail($this->getSender());
$attachment->unlinkFiles($this->getAttachments());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use ILIAS\Cron\Job\Schedule\JobScheduleType;
use ILIAS\Cron\Job\JobResult;
use ILIAS\Cron\CronJob;
use ILIAS\Mail\Attachments\MailAttachments;

class ilTimingsCronReminder extends CronJob
{
Expand Down Expand Up @@ -309,7 +310,7 @@ protected function sendExceededMail(int $user_id, array $ref_ids, string $mail_b
'',
$this->user_lang->txt('timings_cron_reminder_exceeded_subject'),
$mail_body,
[],
MailAttachments::empty(),
true
);
$this->log->debug('...mail send for user ' . $user_id . ' to mail ' . $login . ' has exceeded timings for ' . $mail_body);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

namespace ILIAS\EmployeeTalk\Notification;

use ILIAS\Mail\Attachments\MailAttachments;

class Notification
{
protected \ilObjUser $to;
Expand Down Expand Up @@ -117,10 +119,10 @@ public function send(): void
}

$attachment_name = 'appointments.ics';
$attachment->storeAsAttachment(
$attachment_name,
$this->attachment
);
$rcid = $attachment->createCollectionFromContent($attachment_name, $this->attachment);
$attachments = $rcid !== null
? MailAttachments::fromIrss($rcid)
: MailAttachments::empty();

$mail = new \ilMail(ANONYMOUS_USER_ID);
$mail->enqueue(
Expand All @@ -129,10 +131,8 @@ public function send(): void
'',
$subject,
$notif->composeAndGetMessage($this->to->getId(), null, '', true),
[$attachment_name]
$attachments
);

$attachment->unlinkFile($attachment_name);
}

protected function getTalkGoto(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
*********************************************************************/

use ILIAS\Mail\Attachments\MailAttachments;

/**
*
* TODO: import/export reminder data with the exercise/assignment.
Expand Down Expand Up @@ -561,7 +563,7 @@ protected function sendReminders(array $reminders): int
"",
$subject,
$message,
array()
MailAttachments::empty()
);
}

Expand Down
23 changes: 10 additions & 13 deletions components/ILIAS/Exercise/classes/class.ilObjExercise.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
use ILIAS\Filesystem\Exception\IOException;
use ILIAS\Exercise\InternalService;
use ILIAS\Exercise\Assignment\Mandatory\MandatoryAssignmentsManager;
use ILIAS\Mail\Attachments\MailAttachments;
use ILIAS\ResourceStorage\Identification\ResourceIdentification;

/**
* Class ilObjExercise
Expand Down Expand Up @@ -455,15 +457,16 @@ public function sendAssignment(ilExAssignment $a_ass, array $a_members): void
// instruction files
$if = $this->service->domain()->assignment()->instructionFiles($a_ass->getId());
$files = $if->getFiles();
$file_names = [];
$attachments = MailAttachments::empty();
if (count($files) > 0) {
$mfile_obj = new ilFileDataMail($GLOBALS['DIC']['ilUser']->getId());
$source_ids = [];
foreach ($if->getFiles() as $file) {
$file_names[] = $file["name"];
$mfile_obj->storeAsAttachment(
$file["name"],
$if->getStream($file["rid"])->getContents()
);
$source_ids[] = new ResourceIdentification($file['rid']);
}
$rcid = $mfile_obj->createCollectionFromForeignResources($source_ids);
if ($rcid !== null) {
$attachments = MailAttachments::fromIrss($rcid);
}
}

Expand All @@ -485,16 +488,10 @@ public function sendAssignment(ilExAssignment $a_ass, array $a_members): void
"",
$subject,
$body,
$file_names
$attachments
);
unset($tmp_mail_obj);

// remove tmp files
if (count($file_names) && $mfile_obj) {
$mfile_obj->unlinkFiles($file_names);
unset($mfile_obj);
}

// set recipients mail status
foreach ($a_members as $member_id) {
$member_status = $a_ass->getMemberStatus($member_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

declare(strict_types=1);

use ILIAS\Mail\Attachments\MailAttachments;
use ILIAS\ResourceStorage\Identification\ResourceCollectionIdentification;

/**
* Class ilForumCronNotificationDataProvider
* @author Nadia Matuschek <nmatuschek@databay.de>
Expand Down Expand Up @@ -46,6 +49,7 @@ class ilForumCronNotificationDataProvider implements ilForumNotificationMailData
private readonly string $import_name;
/** @var list<string> */
private array $attachments = [];
private ?MailAttachments $mail_attachments = null;
/** @var int[] */
private array $cron_recipients = [];
private readonly int $post_update_user_id;
Expand Down Expand Up @@ -105,13 +109,31 @@ protected function read(): void

private function readAttachments(): void
{
if (ilForumProperties::isSendAttachmentsByMailEnabled()) {
$fileDataForum = new ilFileDataForum($this->getObjId(), $this->getPostId());
$filesOfPost = $fileDataForum->getFilesOfPost();
if (!ilForumProperties::isSendAttachmentsByMailEnabled()) {
return;
}

foreach ($filesOfPost as $attachment) {
$this->attachments[] = $attachment['name'];
}
$fileDataForum = new ilFileDataForum($this->getObjId(), $this->getPostId());
foreach ($fileDataForum->getFilesOfPost() as $attachment) {
$this->attachments[] = $attachment['name'];
}

$post = new ilForumPost($this->getPostId());
$rcid_string = $post->getRCID();
if ($rcid_string === '' || $rcid_string === ilForumPost::NO_RCID) {
return;
}

global $DIC;
$forum_collection = $DIC->resourceStorage()->collection()->get(
new ResourceCollectionIdentification($rcid_string)
);
$fileDataMail = new ilFileDataMail(ANONYMOUS_USER_ID);
$mail_rcid = $fileDataMail->createCollectionFromForeignResources(
iterator_to_array($forum_collection->getResourceIdentifications(), false)
);
if ($mail_rcid !== null) {
$this->mail_attachments = MailAttachments::fromIrss($mail_rcid);
}
}

Expand Down Expand Up @@ -216,6 +238,11 @@ public function getAttachments(): array
return $this->attachments;
}

public function getMailAttachments(): MailAttachments
{
return $this->mail_attachments ?? MailAttachments::empty();
}

public function getPosDisplayUserId(): int
{
return $this->pos_display_user_id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

declare(strict_types=1);

use ILIAS\Mail\Attachments\MailAttachments;

/**
* @author Niels Theen <ntheen@databay.de>
*/
Expand Down Expand Up @@ -360,7 +362,7 @@ private function createMailValueObjectsWithAttachments(
'',
ilStr::strLen($subjectText) > 255 ? ilStr::substr($subjectText, 0, 255) : $subjectText,
$bodyText,
$this->provider->getAttachments(),
$this->provider->getMailAttachments(),
false,
false
);
Expand Down Expand Up @@ -393,7 +395,7 @@ private function createMailValueObjectWithoutAttachments(
'',
ilStr::strLen($subjectText) > 255 ? ilStr::substr($subjectText, 0, 255) : $subjectText,
$bodyText,
[],
MailAttachments::empty(),
false,
false
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

declare(strict_types=1);

use ILIAS\Mail\Attachments\MailAttachments;
use ILIAS\ResourceStorage\Identification\ResourceCollectionIdentification;

/**
* Class ilForumNotificationDataProvider
* @author Nadia Matuschek <nmatuschek@databay.de>
Expand All @@ -35,6 +38,7 @@ class ilForumNotificationDataProvider implements ilForumNotificationMailData
protected string $thread_title = '';
/** @var array<string, string> */
protected array $attachments = [];
private ?MailAttachments $mail_attachments = null;
private readonly ilDBInterface $db;
private readonly ilAccessHandler $access;
private readonly ilObjUser $user;
Expand Down Expand Up @@ -148,6 +152,11 @@ public function getAttachments(): array
return $this->attachments;
}

public function getMailAttachments(): MailAttachments
{
return $this->mail_attachments ?? MailAttachments::empty();
}

public function getPosUserAlias(): string
{
return $this->objPost->getUserAlias();
Expand Down Expand Up @@ -314,16 +323,30 @@ public function determineClosestContainer(int $frm_ref_id): ?ilObject

private function readAttachments(): void
{
if (ilForumProperties::isSendAttachmentsByMailEnabled()) {
$fileDataForum = new ilFileDataForum($this->getObjId(), $this->objPost->getId());
$filesOfPost = $fileDataForum->getFilesOfPost();
if (!ilForumProperties::isSendAttachmentsByMailEnabled()) {
return;
}

$fileDataMail = new ilFileDataMail(ANONYMOUS_USER_ID);
$fileDataForum = new ilFileDataForum($this->getObjId(), $this->objPost->getId());
foreach ($fileDataForum->getFilesOfPost() as $attachment) {
$this->attachments[$attachment['path']] = $attachment['name'];
}

foreach ($filesOfPost as $attachment) {
$this->attachments[$attachment['path']] = $attachment['name'];
$fileDataMail->copyAttachmentFile($attachment['path'], $attachment['name']);
}
$rcid_string = $this->objPost->getRCID();
if ($rcid_string === '' || $rcid_string === ilForumPost::NO_RCID) {
return;
}

global $DIC;
$forum_collection = $DIC->resourceStorage()->collection()->get(
new ResourceCollectionIdentification($rcid_string)
);
$fileDataMail = new ilFileDataMail(ANONYMOUS_USER_ID);
$mail_rcid = $fileDataMail->createCollectionFromForeignResources(
iterator_to_array($forum_collection->getResourceIdentifications(), false)
);
if ($mail_rcid !== null) {
$this->mail_attachments = MailAttachments::fromIrss($mail_rcid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected function appendAttachments(): void
$this->appendBody($this->getLanguageText('attachment') . ': ' . $attachment . "\n");
}
$this->appendBody("\n------------------------------------------------------------\n");
$this->setAttachments($this->provider->getAttachments());
$this->setAttachments($this->provider->getMailAttachments());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

declare(strict_types=1);

use ILIAS\Mail\Attachments\MailAttachments;

/**
* Interface ilForumNotificationMailData
* @author Nadia Matuschek <nmatuschek@databay.de>
Expand Down Expand Up @@ -71,5 +73,7 @@ public function getCensorshipComment(): string;

public function getAttachments(): array;

public function getMailAttachments(): MailAttachments;

public function getDeletedBy(): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*
*********************************************************************/

use ILIAS\Mail\Attachments\MailAttachments;

/**
* Class ilLearningModuleNotification class
*
Expand Down Expand Up @@ -109,7 +111,7 @@ public function send(): void
"",
$subject,
$message,
[]
MailAttachments::empty()
);
}
}
Expand Down
Loading
Loading