ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPRGMail Class Reference

Send mails to users (usually triggered by cron) More...

+ Collaboration diagram for ilPRGMail:

Public Member Functions

 __construct (protected ilComponentLogger $log, ilLanguage $lng)
 
 sendInformToReAssignMail (int $assignment_id, int $root_prg_id)
 
 resetExpiryInfoSentFor (int $assignment_id, int $root_prg_id)
 
 sendRiskyToFailMail (int $assignment_id, int $root_prg_id)
 
 resetRiskyToFailSentFor (int $assignment_id, int $root_prg_id)
 
 sendReAssignedMail (int $assignment_id, int $root_prg_id)
 

Protected Member Functions

 getAssignmentAndProgramme (int $assignment_id, int $root_prg_id)
 
 getUserLanguage (int $usr_id)
 
 txt (string $identifier, string $lang)
 
 sendMail (ilObjStudyProgramme $prg, ilPRGAssignment $assignment, string $subject, string $body_template)
 

Protected Attributes

const LANGMODULE = 'prg'
 
array $languages
 var <string, ilLanguage> $languages More...
 

Detailed Description

Send mails to users (usually triggered by cron)

Definition at line 24 of file class.ilPRGMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilPRGMail::__construct ( protected ilComponentLogger  $log,
ilLanguage  $lng 
)

Definition at line 33 of file class.ilPRGMail.php.

References $lng, ilLanguage\getLangKey(), and ilLanguage\loadLanguageModule().

36  {
37  $lng->loadLanguageModule(self::LANGMODULE);
38  $lng->loadLanguageModule("mail");
39  $this->languages[$lng->getLangKey()] = $lng;
40  }
getLangKey()
Return lang key.
loadLanguageModule(string $a_module)
Load language module.
global $lng
Definition: privfeed.php:31
+ Here is the call graph for this function:

Member Function Documentation

◆ getAssignmentAndProgramme()

ilPRGMail::getAssignmentAndProgramme ( int  $assignment_id,
int  $root_prg_id 
)
protected
Returns
array [ilPRGAssignment, ilObjStudyProgramme]

Definition at line 45 of file class.ilPRGMail.php.

References ilObjStudyProgramme\getInstanceByObjId().

Referenced by resetExpiryInfoSentFor(), resetRiskyToFailSentFor(), sendInformToReAssignMail(), sendReAssignedMail(), and sendRiskyToFailMail().

45  : array
46  {
47  $prg = ilObjStudyProgramme::getInstanceByObjId($root_prg_id);
48  $ass = $prg->getSpecificAssignment($assignment_id);
49  return [$ass, $prg];
50  }
static getInstanceByObjId(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getUserLanguage()

ilPRGMail::getUserLanguage ( int  $usr_id)
protected

Definition at line 52 of file class.ilPRGMail.php.

Referenced by sendMail(), sendReAssignedMail(), and sendRiskyToFailMail().

52  : string
53  {
54  return \ilObjUser::_getPreferences($usr_id)['language'];
55  }
+ Here is the caller graph for this function:

◆ resetExpiryInfoSentFor()

ilPRGMail::resetExpiryInfoSentFor ( int  $assignment_id,
int  $root_prg_id 
)

Definition at line 122 of file class.ilPRGMail.php.

References getAssignmentAndProgramme().

122  : void
123  {
124  list($ass, $prg) = $this->getAssignmentAndProgramme($assignment_id, $root_prg_id);
125  $now = new \DateTimeImmutable();
126  $vq = $ass->getProgressTree()->getValidityOfQualification();
127 
128  if ($vq && $vq > $now) {
129  $prg->resetExpiryInfoSentFor($ass);
130  }
131  }
getAssignmentAndProgramme(int $assignment_id, int $root_prg_id)
+ Here is the call graph for this function:

◆ resetRiskyToFailSentFor()

ilPRGMail::resetRiskyToFailSentFor ( int  $assignment_id,
int  $root_prg_id 
)

Definition at line 152 of file class.ilPRGMail.php.

References getAssignmentAndProgramme().

152  : void
153  {
154  list($ass, $prg) = $this->getAssignmentAndProgramme($assignment_id, $root_prg_id);
155  $now = new \DateTimeImmutable();
156  $deadline = $ass->getProgressTree()->getDeadline();
157  if ($deadline && $deadline > $now) {
158  $prg->resetRiskyToFailSentFor($ass);
159  }
160  }
getAssignmentAndProgramme(int $assignment_id, int $root_prg_id)
+ Here is the call graph for this function:

◆ sendInformToReAssignMail()

ilPRGMail::sendInformToReAssignMail ( int  $assignment_id,
int  $root_prg_id 
)

Definition at line 104 of file class.ilPRGMail.php.

References getAssignmentAndProgramme(), and sendMail().

104  : void
105  {
106  list($ass, $prg) = $this->getAssignmentAndProgramme($assignment_id, $root_prg_id);
107 
108  if (! $prg->getSettings()->getAutoMailSettings()->getReminderNotRestartedByUserDays() > 0) {
109  $this->log->write("Send info to re-assign mail is deactivated in study programme settings");
110  return;
111  }
112 
113  $subject = "info_to_re_assign_mail_subject";
114  $body_template = "info_to_re_assign_mail_body";
115  $sent = $this->sendMail($prg, $ass, $subject, $body_template);
116 
117  if ($sent) {
118  $prg->storeExpiryInfoSentFor($ass);
119  }
120  }
sendMail(ilObjStudyProgramme $prg, ilPRGAssignment $assignment, string $subject, string $body_template)
getAssignmentAndProgramme(int $assignment_id, int $root_prg_id)
+ Here is the call graph for this function:

◆ sendMail()

ilPRGMail::sendMail ( ilObjStudyProgramme  $prg,
ilPRGAssignment  $assignment,
string  $subject,
string  $body_template 
)
protected

Definition at line 69 of file class.ilPRGMail.php.

References Vendor\Package\$e, $lang, ilLink\_getStaticLink(), ANONYMOUS_USER_ID, ilObjStudyProgramme\getRefIdFor(), ilPRGAssignment\getRootId(), ilObject\getTitle(), ilPRGAssignment\getUserId(), ilPRGAssignment\getUserInformation(), getUserLanguage(), and txt().

Referenced by sendInformToReAssignMail(), sendReAssignedMail(), and sendRiskyToFailMail().

74  : bool {
75  $user_info = $assignment->getUserInformation();
76  $gender = $user_info->getGender() ?: 'anonymous';
77  $name = implode(' ', [$user_info->getFirstname(), $user_info->getLastname()]);
78  $login = $user_info->getLogin();
79  $prg_link = \ilLink::_getStaticLink(ilObjStudyProgramme::getRefIdFor($assignment->getRootId()), 'prg');
80 
81  $lang = $this->getUserLanguage($assignment->getUserId());
82  $salutation = $this->txt("mail_salutation_" . $gender, $lang);
83  $subject = $this->txt($subject, $lang);
84  $body_template = $this->txt($body_template, $lang);
85 
86  $body = sprintf(
87  $body_template,
88  $salutation,
89  $name,
90  $prg->getTitle()
91  )
92  . '<br /><br />' . $prg_link;
93 
94  $mail = new ilMail(ANONYMOUS_USER_ID);
95  try {
96  $mail->enqueue($login, '', '', $subject, $body, []);
97  return true;
98  } catch (Exception $e) {
99  $this->log->write($e->getMessage());
100  return false;
101  }
102  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
getUserLanguage(int $usr_id)
txt(string $identifier, string $lang)
$lang
Definition: xapiexit.php:25
static getRefIdFor(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendReAssignedMail()

ilPRGMail::sendReAssignedMail ( int  $assignment_id,
int  $root_prg_id 
)

Definition at line 162 of file class.ilPRGMail.php.

References $lang, getAssignmentAndProgramme(), getUserLanguage(), and sendMail().

162  : bool
163  {
164  list($ass, $prg) = $this->getAssignmentAndProgramme($assignment_id, $root_prg_id);
165 
166  if (! $prg->getSettings()->getAutoMailSettings()->getSendReAssignedMail()) {
167  $this->log->write("Send re assign mail is deactivated in study programme settings");
168  return false;
169  }
170 
171  $lang = $this->getUserLanguage($ass->getUserId());
172  $subject = "re_assigned_mail_subject";
173  $body_template = "re_assigned_mail_body";
174  $sent = $this->sendMail($prg, $ass, $subject, $body_template);
175 
176  return $sent;
177  }
sendMail(ilObjStudyProgramme $prg, ilPRGAssignment $assignment, string $subject, string $body_template)
getUserLanguage(int $usr_id)
getAssignmentAndProgramme(int $assignment_id, int $root_prg_id)
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:

◆ sendRiskyToFailMail()

ilPRGMail::sendRiskyToFailMail ( int  $assignment_id,
int  $root_prg_id 
)

Definition at line 133 of file class.ilPRGMail.php.

References $lang, getAssignmentAndProgramme(), getUserLanguage(), and sendMail().

133  : void
134  {
135  list($ass, $prg) = $this->getAssignmentAndProgramme($assignment_id, $root_prg_id);
136 
137  if (! $prg->getSettings()->getAutoMailSettings()->getProcessingEndsNotSuccessfulDays() > 0) {
138  $this->log->write("Send risky to fail mail is deactivated in study programme settings");
139  return;
140  }
141 
142  $lang = $this->getUserLanguage($ass->getUserId());
143  $subject = "risky_to_fail_mail_subject";
144  $body_template = "risky_to_fail_mail_body";
145  $sent = $this->sendMail($prg, $ass, $subject, $body_template);
146 
147  if ($sent) {
148  $prg->storeRiskyToFailSentFor($ass);
149  }
150  }
sendMail(ilObjStudyProgramme $prg, ilPRGAssignment $assignment, string $subject, string $body_template)
getUserLanguage(int $usr_id)
getAssignmentAndProgramme(int $assignment_id, int $root_prg_id)
$lang
Definition: xapiexit.php:25
+ Here is the call graph for this function:

◆ txt()

ilPRGMail::txt ( string  $identifier,
string  $lang 
)
protected

Definition at line 57 of file class.ilPRGMail.php.

References $lang, and $lng.

Referenced by sendMail().

57  : string
58  {
59  if(!array_key_exists($lang, $this->languages)) {
60  $lng = new \ilLanguage($lang);
61  $lng->loadLanguageModule(self::LANGMODULE);
62  $lng->loadLanguageModule("mail");
63  $this->languages[$lang] = $lng;
64  }
65  $lng = $this->languages[$lang];
66  return $lng->txtlng(self::LANGMODULE, $identifier, $lang);
67  }
$lang
Definition: xapiexit.php:25
global $lng
Definition: privfeed.php:31
+ Here is the caller graph for this function:

Field Documentation

◆ $languages

array ilPRGMail::$languages
protected

var <string, ilLanguage> $languages

Definition at line 31 of file class.ilPRGMail.php.

◆ LANGMODULE

const ilPRGMail::LANGMODULE = 'prg'
protected

Definition at line 26 of file class.ilPRGMail.php.


The documentation for this class was generated from the following file: