ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilAccountMail Class Reference

Class ilAccountMail. More...

+ Collaboration diagram for ilAccountMail:

Public Member Functions

 __construct ()
 constructor public More...
 
 useLangVariablesAsFallback ($a_status)
 
 areLangVariablesUsedAsFallback ()
 
 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 Attributes

 $lang_variables_as_fallback = false
 
 $attachments = array()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilAccountMail::__construct ( )

constructor public

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

45  {
46  }

Member Function Documentation

◆ addAttachment()

ilAccountMail::addAttachment (   $a_filename,
  $a_display_name 
)

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

339  {
340  $this->attachments[$a_filename] = $a_display_name;
341  }

◆ areLangVariablesUsedAsFallback()

ilAccountMail::areLangVariablesUsedAsFallback ( )

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

References $lang_variables_as_fallback.

Referenced by readAccountMail().

54  {
56  }
+ Here is the caller graph for this function:

◆ getTarget()

ilAccountMail::getTarget ( )

get target

public

Returns
string repository item target

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

References $target.

121  {
122  return $this->target;
123  }

◆ getUser()

& ilAccountMail::getUser ( )

get user object

public

Returns
object user object

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

References $user.

Referenced by readAccountMail().

99  {
100  return $this->user;
101  }
+ 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 75 of file class.ilAccountMail.php.

References $u_password.

Referenced by replacePlaceholders().

76  {
77  return $this->u_password;
78  }
+ 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 138 of file class.ilAccountMail.php.

References $filename, $GLOBALS, $ilSetting, $lang, $user, ilObjUserFolder\_lookupNewAccountMail(), areLangVariablesUsedAsFallback(), ilDatePresentation\formatPeriod(), getUser(), IL_CAL_UNIX, and replacePlaceholders().

139  {
140  if (!is_array($this->amail[$a_lang])) {
141  include_once('./Services/User/classes/class.ilObjUserFolder.php');
142  $this->amail[$a_lang] = ilObjUserFolder::_lookupNewAccountMail($a_lang);
143  $amail["body"] = trim($amail["body"]);
144  $amail["subject"] = trim($amail["subject"]);
145  }
146 
147  return $this->amail[$a_lang];
148  }
static _lookupNewAccountMail($a_lang)
+ Here is the call graph for this function:

◆ replacePlaceholders()

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

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

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

Referenced by readAccountMail().

240  {
241  global $ilSetting, $tree;
242 
243  // determine salutation
244  switch ($a_user->getGender()) {
245  case "f": $gender_salut = $a_amail["sal_f"];
246  break;
247  case "m": $gender_salut = $a_amail["sal_m"];
248  break;
249  default: $gender_salut = $a_amail["sal_g"];
250  }
251  $gender_salut = trim($gender_salut);
252 
253  $a_string = str_replace("[MAIL_SALUTATION]", $gender_salut, $a_string);
254  $a_string = str_replace("[LOGIN]", $a_user->getLogin(), $a_string);
255  $a_string = str_replace("[FIRST_NAME]", $a_user->getFirstname(), $a_string);
256  $a_string = str_replace("[LAST_NAME]", $a_user->getLastname(), $a_string);
257  // BEGIN Mail Include E-Mail Address in account mail
258  $a_string = str_replace("[EMAIL]", $a_user->getEmail(), $a_string);
259  // END Mail Include E-Mail Address in account mail
260  $a_string = str_replace("[PASSWORD]", $this->getUserPassword(), $a_string);
261  $a_string = str_replace(
262  "[ILIAS_URL]",
263  ILIAS_HTTP_PATH . "/login.php?client_id=" . CLIENT_ID,
264  $a_string
265  );
266  $a_string = str_replace("[CLIENT_NAME]", CLIENT_NAME, $a_string);
267  $a_string = str_replace(
268  "[ADMIN_MAIL]",
269  $ilSetting->get("admin_email"),
270  $a_string
271  );
272 
273  // (no) password sections
274  if ($this->getUserPassword() == "") {
275  // #12232
276  $a_string = preg_replace("/\[IF_PASSWORD\].*\[\/IF_PASSWORD\]/imsU", "", $a_string);
277  $a_string = preg_replace("/\[IF_NO_PASSWORD\](.*)\[\/IF_NO_PASSWORD\]/imsU", "$1", $a_string);
278  } else {
279  $a_string = preg_replace("/\[IF_NO_PASSWORD\].*\[\/IF_NO_PASSWORD\]/imsU", "", $a_string);
280  $a_string = preg_replace("/\[IF_PASSWORD\](.*)\[\/IF_PASSWORD\]/imsU", "$1", $a_string);
281  }
282 
283  // #13346
284  if (!$a_user->getTimeLimitUnlimited()) {
285  // #6098
286  $a_string = preg_replace("/\[IF_TIMELIMIT\](.*)\[\/IF_TIMELIMIT\]/imsU", "$1", $a_string);
287  $timelimit_from = new ilDateTime($a_user->getTimeLimitFrom(), IL_CAL_UNIX);
288  $timelimit_until = new ilDateTime($a_user->getTimeLimitUntil(), IL_CAL_UNIX);
289  $timelimit = ilDatePresentation::formatPeriod($timelimit_from, $timelimit_until);
290  $a_string = str_replace("[TIMELIMIT]", $timelimit, $a_string);
291  } else {
292  $a_string = preg_replace("/\[IF_TIMELIMIT\](.*)\[\/IF_TIMELIMIT\]/imsU", "", $a_string);
293  }
294 
295  // target
296  $tar = false;
297  if ($_GET["target"] != "") {
298  $tarr = explode("_", $_GET["target"]);
299  if ($tree->isInTree($tarr[1])) {
300  $obj_id = ilObject::_lookupObjId($tarr[1]);
301  $type = ilObject::_lookupType($obj_id);
302  if ($type == $tarr[0]) {
303  $a_string = str_replace(
304  "[TARGET_TITLE]",
305  ilObject::_lookupTitle($obj_id),
306  $a_string
307  );
308  $a_string = str_replace(
309  "[TARGET]",
310  ILIAS_HTTP_PATH . "/goto.php?client_id=" . CLIENT_ID . "&target=" . $_GET["target"],
311  $a_string
312  );
313 
314  // this looks complicated, but we may have no initilised $lng object here
315  // if mail is send during user creation in authentication
316  include_once("./Services/Language/classes/class.ilLanguage.php");
317  $a_string = str_replace(
318  "[TARGET_TYPE]",
319  ilLanguage::_lookupEntry($a_lang, "common", "obj_" . $tarr[0]),
320  $a_string
321  );
322 
323  $tar = true;
324  }
325  }
326  }
327 
328  // (no) target section
329  if (!$tar) {
330  $a_string = preg_replace("/\[IF_TARGET\].*\[\/IF_TARGET\]/imsU", "", $a_string);
331  } else {
332  $a_string = preg_replace("/\[IF_TARGET\](.*)\[\/IF_TARGET\]/imsU", "$1", $a_string);
333  }
334 
335  return $a_string;
336  }
$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 128 of file class.ilAccountMail.php.

References user().

129  {
130  unset($this->u_password);
131  unset($this->user);
132  unset($this->target);
133  }
user()
Definition: user.php:4
+ Here is the call graph for this function:

◆ 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 109 of file class.ilAccountMail.php.

110  {
111  $this->u_target = $a_target;
112  }

◆ 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 87 of file class.ilAccountMail.php.

References user().

88  {
89  $this->user =&$a_user;
90  }
user()
Definition: user.php:4
+ 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 64 of file class.ilAccountMail.php.

65  {
66  $this->u_password = $a_pwd;
67  }

◆ useLangVariablesAsFallback()

ilAccountMail::useLangVariablesAsFallback (   $a_status)

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

49  {
50  $this->lang_variables_as_fallback = $a_status;
51  }

Field Documentation

◆ $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 getUser(), and readAccountMail().


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