ILIAS  release_8 Revision v8.23
class.ilExerciseMailNotification.php
Go to the documentation of this file.
1 <?php
2 
23 {
24  public const TYPE_FEEDBACK_FILE_ADDED = 20;
25  public const TYPE_SUBMISSION_UPLOAD = 30;
26  public const TYPE_FEEDBACK_TEXT_ADDED = 40;
27 
28  protected ilObjUser $user;
29  protected int $ass_id;
30 
31  public function __construct()
32  {
33  global $DIC;
34 
35  $this->user = $DIC->user();
37  }
38 
39  public function setAssignmentId(int $a_val): void
40  {
41  $this->ass_id = $a_val;
42  }
43 
44  public function getAssignmentId(): int
45  {
46  return $this->ass_id;
47  }
48 
49  public function send(): bool
50  {
52  // parent::send();
53 
54  switch ($this->getType()) {
55  case self::TYPE_FEEDBACK_FILE_ADDED:
56 
57  foreach ($this->getRecipients() as $rcp) {
58  $this->initLanguage($rcp);
59  $this->initMail();
60  $this->setSubject(
61  sprintf(
62  $this->getLanguageText('exc_msg_new_feedback_file_uploaded'),
63  $this->getObjectTitle(true)
64  )
65  );
66  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
67  $this->appendBody("\n\n");
68  $this->appendBody(
69  $this->getLanguageText('exc_msg_new_feedback_file_uploaded2')
70  );
71  $this->appendBody("\n");
72  $this->appendBody(
73  $this->getLanguageText('obj_exc') . ": " . $this->getObjectTitle(true)
74  );
75  $this->appendBody("\n");
76  $this->appendBody(
77  $this->getLanguageText('exc_assignment') . ": " .
79  );
80  $this->appendBody("\n\n");
81  $this->appendBody($this->getLanguageText('exc_mail_permanent_link'));
82  $this->appendBody("\n");
83  $this->appendBody($this->createPermanentLink(array(), '_' . $this->getAssignmentId()) .
84  '#fb' . $this->getAssignmentId());
85  $this->getMail()->appendInstallationSignature(true);
86 
87  $this->sendMail(array($rcp));
88  }
89  break;
90 
91  case self::TYPE_SUBMISSION_UPLOAD:
92 
93  foreach ($this->getRecipients() as $rcp) {
94  $this->initLanguage($rcp);
95  $this->initMail();
96  $this->setSubject(
97  sprintf(
98  $this->getLanguageText('exc_submission_notification_subject'),
99  $this->getObjectTitle(true)
100  )
101  );
102  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
103  $this->appendBody("\n\n");
104  $this->appendBody(
105  sprintf($this->getLanguageText('exc_submission_notification_body'), $this->getObjectTitle(true))
106  );
107  $this->appendBody("\n");
108  $this->appendBody(
109  $this->getLanguageText('exc_assignment') . ": " .
111  );
112  $this->appendBody("\n");
113  $this->appendBody(
114  $this->getLanguageText('user') . ": " .
115  $ilUser->getFullname()
116  );
117  $this->appendBody("\n\n");
118  $this->appendBody(sprintf(
119  $this->getLanguageText('exc_submission_notification_link'),
120  $this->createPermanentLink()
121  ));
122 
124  $this->appendBody("\n\n");
125 
126  //new files uploaded
127  //$assignment = new ilExAssignment($this->getAssignmentId());
128  //$submission = new ilExSubmission($assignment, $ilUser->getId());
129 
130  // since mails are sent immediately after upload the files should always be new
131  //if($submission->lookupNewFiles($submission->getTutor()))
132  //{
133  $this->appendBody(sprintf(
134  $this->getLanguageText('exc_submission_downloads_notification_link'),
135  $this->createPermanentLink(array(), "_" . $this->getAssignmentId() . "_" . $ilUser->getId() . "_setdownload")
136  ));
137  //}
138  //else
139  //{
140  // $this->appendBody(sprintf($this->getLanguageText('exc_submission_downloads_notification_link'),
141  // $this->getLanguageText("exc_submission_no_new_files")));
142  //}
143  }
144 
145  $this->appendBody("\n\n");
146  $this->appendBody(sprintf(
147  $this->getLanguageText('exc_submission_and_grades_notification_link'),
148  $this->createPermanentLink(array(), "_" . $this->getAssignmentId() . "_grades")
149  ));
150 
151  $this->getMail()->appendInstallationSignature(true);
152 
153  $this->sendMail(array($rcp));
154  }
155  break;
156 
157  case self::TYPE_FEEDBACK_TEXT_ADDED:
158 
159  foreach ($this->getRecipients() as $rcp) {
160  $this->initLanguage($rcp);
161  $this->initMail();
162  $this->setSubject(
163  sprintf(
164  $this->getLanguageText('exc_msg_new_feedback_text_uploaded'),
165  $this->getObjectTitle(true)
166  )
167  );
168  $this->setBody(ilMail::getSalutation($rcp, $this->getLanguage()));
169  $this->appendBody("\n\n");
170  $this->appendBody(
171  $this->getLanguageText('exc_msg_new_feedback_text_uploaded2')
172  );
173  $this->appendBody("\n");
174  $this->appendBody(
175  $this->getLanguageText('obj_exc') . ": " . $this->getObjectTitle(true)
176  );
177  $this->appendBody("\n");
178  $this->appendBody(
179  $this->getLanguageText('exc_assignment') . ": " .
181  );
182  $this->appendBody("\n\n");
183  $this->appendBody($this->getLanguageText('exc_mail_permanent_link'));
184  $this->appendBody("\n");
185  $this->appendBody($this->createPermanentLink(array(), '_' . $this->getAssignmentId()) .
186  '#fb' . $this->getAssignmentId());
187  $this->getMail()->appendInstallationSignature(true);
188 
189  $this->sendMail(array($rcp));
190  }
191  break;
192  }
193  return true;
194  }
195 
199  protected function initLanguage(int $a_usr_id): void
200  {
201  parent::initLanguage($a_usr_id);
202  $this->getLanguage()->loadLanguageModule('exc');
203  }
204 }
sendMail(array $a_rcp, bool $a_parse_recipients=true)
static lookupTitle(int $a_id)
static lookupType(int $a_id)
initLanguage(int $a_usr_id)
Add language module exc.
const TYPE_UPLOAD
direct checks against const should be avoided, use type objects instead
global $DIC
Definition: feed.php:28
Base class for course/group mail notifications.
static getSalutation(int $a_usr_id, ?ilLanguage $a_language=null)
getLanguageText(string $a_keyword)
getObjectTitle(bool $a_shorten=false)
createPermanentLink(array $a_params=[], string $a_append='')
__construct(Container $dic, ilPlugin $plugin)
$ilUser
Definition: imgupload.php:34
setSubject(string $a_subject)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...