ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilAccountMail Class Reference

Class ilAccountMail. More...

+ Collaboration diagram for ilAccountMail:

Public Member Functions

 __construct ()
 constructor public More...
 
 useLangVariablesAsFallback ($a_status)
 
 areLangVariablesUsedAsFallback ()
 
 shouldAttachConfiguredFiles ()
 
 setAttachConfiguredFiles (bool $attachConfiguredFiles)
 
 setUserPassword ($a_pwd)
 set user password More...
 
 getUserPassword ()
 get user password More...
 
 setUser (&$a_user)
 Set user. More...
 
getUser ()
 get user object More...
 
 setTarget ($a_target)
 set repository item target More...
 
 getTarget ()
 get target More...
 
 reset ()
 reset all values More...
 
 readAccountMail ($a_lang)
 get new account mail array (including subject and message body) More...
 
 replacePlaceholders ($a_string, &$a_user, $a_amail, $a_lang)
 
 addAttachment ($a_filename, $a_display_name)
 

Data Fields

 $u_password = ""
 
 $user = ""
 
 $target = ""
 

Private Member Functions

 addAttachments ($mailData)
 

Private Attributes

 $lang_variables_as_fallback = false
 
 $attachments = array()
 
 $attachConfiguredFiles = false
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAccountMail::__construct ( )

constructor public

Definition at line 47 of file class.ilAccountMail.php.

48  {
49  }

Member Function Documentation

◆ addAttachment()

ilAccountMail::addAttachment (   $a_filename,
  $a_display_name 
)

Definition at line 387 of file class.ilAccountMail.php.

Referenced by addAttachments().

388  {
389  $this->attachments[$a_filename] = $a_display_name;
390  }
+ Here is the caller graph for this function:

◆ addAttachments()

ilAccountMail::addAttachments (   $mailData)
private

Definition at line 180 of file class.ilAccountMail.php.

References $filename, $GLOBALS, $ilSetting, $lang, $user, addAttachment(), areLangVariablesUsedAsFallback(), ilDatePresentation\formatPeriod(), getUser(), IL_CAL_UNIX, readAccountMail(), replacePlaceholders(), shouldAttachConfiguredFiles(), and USER_FOLDER_ID.

181  {
182  if ($this->shouldAttachConfiguredFiles() && isset($mailData['att_file'])) {
184  $fs->create();
185 
186  $pathToFile = '/' . implode('/', array_map(function ($pathPart) {
187  return trim($pathPart, '/');
188  }, [
189  $fs->getAbsolutePath(),
190  $mailData['lang'],
191  ]));
192 
193  $this->addAttachment($pathToFile, $mailData['att_file']);
194  }
195  }
addAttachment($a_filename, $a_display_name)
const USER_FOLDER_ID
Class ilObjUserFolder.
+ Here is the call graph for this function:

◆ areLangVariablesUsedAsFallback()

ilAccountMail::areLangVariablesUsedAsFallback ( )

Definition at line 56 of file class.ilAccountMail.php.

References $lang_variables_as_fallback.

Referenced by addAttachments().

57  {
59  }
+ Here is the caller graph for this function:

◆ getTarget()

ilAccountMail::getTarget ( )

get target

public

Returns
string repository item target

Definition at line 147 of file class.ilAccountMail.php.

References $target.

148  {
149  return $this->target;
150  }

◆ getUser()

& ilAccountMail::getUser ( )

get user object

public

Returns
object user object

Definition at line 125 of file class.ilAccountMail.php.

References $user.

Referenced by addAttachments().

126  {
127  return $this->user;
128  }
+ Here is the caller graph for this function:

◆ getUserPassword()

ilAccountMail::getUserPassword ( )

get user password

public

Returns
string users password as plain text

Definition at line 94 of file class.ilAccountMail.php.

References $u_password.

Referenced by replacePlaceholders().

95  {
96  return $this->u_password;
97  }
+ Here is the caller graph for this function:

◆ readAccountMail()

ilAccountMail::readAccountMail (   $a_lang)

get new account mail array (including subject and message body)

Definition at line 165 of file class.ilAccountMail.php.

References ilObjUserFolder\_lookupNewAccountMail().

Referenced by addAttachments().

166  {
167  if (!is_array($this->amail[$a_lang])) {
168  include_once('./Services/User/classes/class.ilObjUserFolder.php');
169  $this->amail[$a_lang] = ilObjUserFolder::_lookupNewAccountMail($a_lang);
170  $amail["body"] = trim($amail["body"]);
171  $amail["subject"] = trim($amail["subject"]);
172  }
173 
174  return $this->amail[$a_lang];
175  }
static _lookupNewAccountMail($a_lang)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replacePlaceholders()

ilAccountMail::replacePlaceholders (   $a_string,
$a_user,
  $a_amail,
  $a_lang 
)

Definition at line 288 of file class.ilAccountMail.php.

References $_GET, $ilSetting, $tree, $type, ilLanguage\_lookupEntry(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilDatePresentation\formatPeriod(), getUserPassword(), and IL_CAL_UNIX.

Referenced by addAttachments().

289  {
290  global $ilSetting, $tree;
291 
292  // determine salutation
293  switch ($a_user->getGender()) {
294  case "f": $gender_salut = $a_amail["sal_f"];
295  break;
296  case "m": $gender_salut = $a_amail["sal_m"];
297  break;
298  default: $gender_salut = $a_amail["sal_g"];
299  }
300  $gender_salut = trim($gender_salut);
301 
302  $a_string = str_replace("[MAIL_SALUTATION]", $gender_salut, $a_string);
303  $a_string = str_replace("[LOGIN]", $a_user->getLogin(), $a_string);
304  $a_string = str_replace("[FIRST_NAME]", $a_user->getFirstname(), $a_string);
305  $a_string = str_replace("[LAST_NAME]", $a_user->getLastname(), $a_string);
306  // BEGIN Mail Include E-Mail Address in account mail
307  $a_string = str_replace("[EMAIL]", $a_user->getEmail(), $a_string);
308  // END Mail Include E-Mail Address in account mail
309  $a_string = str_replace("[PASSWORD]", $this->getUserPassword(), $a_string);
310  $a_string = str_replace(
311  "[ILIAS_URL]",
312  ILIAS_HTTP_PATH . "/login.php?client_id=" . CLIENT_ID,
313  $a_string
314  );
315  $a_string = str_replace("[CLIENT_NAME]", CLIENT_NAME, $a_string);
316  $a_string = str_replace(
317  "[ADMIN_MAIL]",
318  $ilSetting->get("admin_email"),
319  $a_string
320  );
321 
322  // (no) password sections
323  if ($this->getUserPassword() == "") {
324  // #12232
325  $a_string = preg_replace("/\[IF_PASSWORD\].*\[\/IF_PASSWORD\]/imsU", "", $a_string);
326  $a_string = preg_replace("/\[IF_NO_PASSWORD\](.*)\[\/IF_NO_PASSWORD\]/imsU", "$1", $a_string);
327  } else {
328  $a_string = preg_replace("/\[IF_NO_PASSWORD\].*\[\/IF_NO_PASSWORD\]/imsU", "", $a_string);
329  $a_string = preg_replace("/\[IF_PASSWORD\](.*)\[\/IF_PASSWORD\]/imsU", "$1", $a_string);
330  }
331 
332  // #13346
333  if (!$a_user->getTimeLimitUnlimited()) {
334  // #6098
335  $a_string = preg_replace("/\[IF_TIMELIMIT\](.*)\[\/IF_TIMELIMIT\]/imsU", "$1", $a_string);
336  $timelimit_from = new ilDateTime($a_user->getTimeLimitFrom(), IL_CAL_UNIX);
337  $timelimit_until = new ilDateTime($a_user->getTimeLimitUntil(), IL_CAL_UNIX);
338  $timelimit = ilDatePresentation::formatPeriod($timelimit_from, $timelimit_until);
339  $a_string = str_replace("[TIMELIMIT]", $timelimit, $a_string);
340  } else {
341  $a_string = preg_replace("/\[IF_TIMELIMIT\](.*)\[\/IF_TIMELIMIT\]/imsU", "", $a_string);
342  }
343 
344  // target
345  $tar = false;
346  if ($_GET["target"] != "") {
347  $tarr = explode("_", $_GET["target"]);
348  if ($tree->isInTree($tarr[1])) {
349  $obj_id = ilObject::_lookupObjId($tarr[1]);
350  $type = ilObject::_lookupType($obj_id);
351  if ($type == $tarr[0]) {
352  $a_string = str_replace(
353  "[TARGET_TITLE]",
354  ilObject::_lookupTitle($obj_id),
355  $a_string
356  );
357  $a_string = str_replace(
358  "[TARGET]",
359  ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $_GET["target"],
360  $a_string
361  );
362 
363  // this looks complicated, but we may have no initilised $lng object here
364  // if mail is send during user creation in authentication
365  include_once("./Services/Language/classes/class.ilLanguage.php");
366  $a_string = str_replace(
367  "[TARGET_TYPE]",
368  ilLanguage::_lookupEntry($a_lang, "common", "obj_" . $tarr[0]),
369  $a_string
370  );
371 
372  $tar = true;
373  }
374  }
375  }
376 
377  // (no) target section
378  if (!$tar) {
379  $a_string = preg_replace("/\[IF_TARGET\].*\[\/IF_TARGET\]/imsU", "", $a_string);
380  } else {
381  $a_string = preg_replace("/\[IF_TARGET\](.*)\[\/IF_TARGET\]/imsU", "$1", $a_string);
382  }
383 
384  return $a_string;
385  }
$type
$_GET["client_id"]
static _lookupTitle($a_id)
lookup object title
static _lookupEntry($a_lang_key, $a_mod, $a_id)
const IL_CAL_UNIX
static _lookupObjId($a_id)
Date and time handling
static _lookupType($a_id, $a_reference=false)
lookup object type
getUserPassword()
get user password
static formatPeriod(ilDateTime $start, ilDateTime $end, $a_skip_starting_day=false)
Format a period of two date Shows: 14.
global $ilSetting
Definition: privfeed.php:17
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

ilAccountMail::reset ( )

reset all values

Definition at line 155 of file class.ilAccountMail.php.

References user().

156  {
157  unset($this->u_password);
158  unset($this->user);
159  unset($this->target);
160  }
user()
Definition: user.php:4
+ Here is the call graph for this function:

◆ setAttachConfiguredFiles()

ilAccountMail::setAttachConfiguredFiles ( bool  $attachConfiguredFiles)
Parameters
bool$attachConfiguredFiles

Definition at line 72 of file class.ilAccountMail.php.

References $attachConfiguredFiles.

73  {
74  $this->attachConfiguredFiles = $attachConfiguredFiles;
75  }

◆ setTarget()

ilAccountMail::setTarget (   $a_target)

set repository item target

public

Parameters
string$a_targettarget as used in permanent links, e.g. crs_123

Definition at line 136 of file class.ilAccountMail.php.

137  {
138  $this->u_target = $a_target;
139  }

◆ setUser()

ilAccountMail::setUser ( $a_user)

Set user.

The user object should provide email, language login, gender, first and last name

public

Parameters
object$a_useruser object

Definition at line 106 of file class.ilAccountMail.php.

References ilObject\getId(), and user().

107  {
108  if (
109  $this->user instanceof ilObjUser &&
110  $a_user instanceof ilObjUser &&
111  $a_user->getId() != $this->user->getId()
112  ) {
113  $this->attachments = [];
114  }
115 
116  $this->user = &$a_user;
117  }
user()
Definition: user.php:4
getId()
get object id public
+ Here is the call graph for this function:

◆ setUserPassword()

ilAccountMail::setUserPassword (   $a_pwd)

set user password

public

Parameters
string$a_pwdusers password as plain text

Definition at line 83 of file class.ilAccountMail.php.

84  {
85  $this->u_password = $a_pwd;
86  }

◆ shouldAttachConfiguredFiles()

ilAccountMail::shouldAttachConfiguredFiles ( )
Returns
bool

Definition at line 64 of file class.ilAccountMail.php.

References $attachConfiguredFiles.

Referenced by addAttachments().

64  : bool
65  {
67  }
+ Here is the caller graph for this function:

◆ useLangVariablesAsFallback()

ilAccountMail::useLangVariablesAsFallback (   $a_status)

Definition at line 51 of file class.ilAccountMail.php.

52  {
53  $this->lang_variables_as_fallback = $a_status;
54  }

Field Documentation

◆ $attachConfiguredFiles

ilAccountMail::$attachConfiguredFiles = false
private

◆ $attachments

ilAccountMail::$attachments = array()
private

Definition at line 38 of file class.ilAccountMail.php.

◆ $lang_variables_as_fallback

ilAccountMail::$lang_variables_as_fallback = false
private

Definition at line 36 of file class.ilAccountMail.php.

Referenced by areLangVariablesUsedAsFallback().

◆ $target

ilAccountMail::$target = ""

Definition at line 34 of file class.ilAccountMail.php.

Referenced by getTarget().

◆ $u_password

ilAccountMail::$u_password = ""

Definition at line 20 of file class.ilAccountMail.php.

Referenced by getUserPassword().

◆ $user

ilAccountMail::$user = ""

Definition at line 27 of file class.ilAccountMail.php.

Referenced by addAttachments(), and getUser().


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