ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAccountMail Class Reference

Class ilAccountMail. More...

+ Collaboration diagram for ilAccountMail:

Public Member Functions

 __construct ()
 constructor public
 useLangVariablesAsFallback ($a_status)
 areLangVariablesUsedAsFallback ()
 setUserPassword ($a_pwd)
 set user password
 getUserPassword ()
 get user password
 setUser (&$a_user)
 Set user.
getUser ()
 get user object
 setTarget ($a_target)
 set repository item target
 getTarget ()
 get target
 reset ()
 reset all values
 readAccountMail ($a_lang)
 get new account mail array (including subject and message body)
 send ()
 Sends the mail with its object properties as MimeMail It first tries to read the mail body, subject and sender address from posted named formular fields.
 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

ilAccountMail::__construct ( )

constructor public

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

{
}

Member Function Documentation

ilAccountMail::addAttachment (   $a_filename,
  $a_display_name 
)

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

{
$this->attachments[$a_filename] = $a_display_name;
}
ilAccountMail::areLangVariablesUsedAsFallback ( )

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

References $lang_variables_as_fallback.

Referenced by send().

+ Here is the caller graph for this function:

ilAccountMail::getTarget ( )

get target

public

Returns
string repository item target

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

References $target.

{
return $this->target;
}
& ilAccountMail::getUser ( )

get user object

public

Returns
object user object

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

References $user.

Referenced by send().

{
return $this->user;
}

+ Here is the caller graph for this function:

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().

{
}

+ Here is the caller graph for this function:

ilAccountMail::readAccountMail (   $a_lang)

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

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

References ilObjUserFolder\_lookupNewAccountMail().

Referenced by send().

{
if (!is_array($this->amail[$a_lang]))
{
include_once('./Services/User/classes/class.ilObjUserFolder.php');
$this->amail[$a_lang] = ilObjUserFolder::_lookupNewAccountMail($a_lang);
$amail["body"] = trim($this->amail[$a_lang]["body"]);
$amail["subject"] = trim($this->amail[$a_lang]["subject"]);
}
return $this->amail[$a_lang];
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

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

Referenced by send().

{
global $ilSetting, $tree;
// determine salutation
switch ($a_user->getGender())
{
case "f" : $gender_salut = $a_amail["sal_f"];
break;
case "m" : $gender_salut = $a_amail["sal_m"];
break;
default : $gender_salut = $a_amail["sal_g"];
}
$gender_salut = trim($gender_salut);
$a_string = str_replace("[MAIL_SALUTATION]", $gender_salut, $a_string);
$a_string = str_replace("[LOGIN]", $a_user->getLogin(), $a_string);
$a_string = str_replace("[FIRST_NAME]", $a_user->getFirstname(), $a_string);
$a_string = str_replace("[LAST_NAME]", $a_user->getLastname(), $a_string);
// BEGIN Mail Include E-Mail Address in account mail
$a_string = str_replace("[EMAIL]", $a_user->getEmail(), $a_string);
// END Mail Include E-Mail Address in account mail
$a_string = str_replace("[PASSWORD]", $this->getUserPassword(), $a_string);
$a_string = str_replace("[ILIAS_URL]",
ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID, $a_string);
$a_string = str_replace("[CLIENT_NAME]", CLIENT_NAME, $a_string);
$a_string = str_replace("[ADMIN_MAIL]", $ilSetting->get("admin_email"),
$a_string);
// (no) password sections
if ($this->getUserPassword() == "")
{
// #12232
$a_string = preg_replace("/\[IF_PASSWORD\].*\[\/IF_PASSWORD\]/imsU", "", $a_string);
$a_string = preg_replace("/\[IF_NO_PASSWORD\](.*)\[\/IF_NO_PASSWORD\]/imsU", "$1", $a_string);
}
else
{
$a_string = preg_replace("/\[IF_NO_PASSWORD\].*\[\/IF_NO_PASSWORD\]/imsU", "", $a_string);
$a_string = preg_replace("/\[IF_PASSWORD\](.*)\[\/IF_PASSWORD\]/imsU", "$1", $a_string);
}
// #13346
if (!$a_user->getTimeLimitUnlimited())
{
// #6098
$a_string = preg_replace("/\[IF_TIMELIMIT\](.*)\[\/IF_TIMELIMIT\]/imsU", "$1", $a_string);
$timelimit_from = new ilDateTime($a_user->getTimeLimitFrom(), IL_CAL_UNIX);
$timelimit_until = new ilDateTime($a_user->getTimeLimitUntil(), IL_CAL_UNIX);
$timelimit = ilDatePresentation::formatPeriod($timelimit_from, $timelimit_until);
$a_string = str_replace("[TIMELIMIT]", $timelimit, $a_string);
}
else
{
$a_string = preg_replace("/\[IF_TIMELIMIT\](.*)\[\/IF_TIMELIMIT\]/imsU", "", $a_string);
}
// target
$tar = false;
if ($_GET["target"] != "")
{
$tarr = explode("_", $_GET["target"]);
if ($tree->isInTree($tarr[1]))
{
$obj_id = ilObject::_lookupObjId($tarr[1]);
$type = ilObject::_lookupType($obj_id);
if ($type == $tarr[0])
{
$a_string = str_replace("[TARGET_TITLE]", ilObject::_lookupTitle($obj_id),
$a_string);
$a_string = str_replace("[TARGET]",
ILIAS_HTTP_PATH."/goto.php?client_id=".CLIENT_ID."&target=".$_GET["target"],
$a_string);
// this looks complicated, but we may have no initilised $lng object here
// if mail is send during user creation in authentication
include_once("./Services/Language/classes/class.ilLanguage.php");
$a_string = str_replace("[TARGET_TYPE]",
ilLanguage::_lookupEntry($a_lang, "common", "obj_".$tarr[0]),
$a_string);
$tar = true;
}
}
}
// (no) target section
if (!$tar)
{
$a_string = preg_replace("/\[IF_TARGET\].*\[\/IF_TARGET\]/imsU", "", $a_string);
}
else
{
$a_string = preg_replace("/\[IF_TARGET\](.*)\[\/IF_TARGET\]/imsU", "$1", $a_string);
}
return $a_string;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAccountMail::reset ( )

reset all values

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

{
unset($this->u_password);
unset($this->user);
unset($this->target);
}
ilAccountMail::send ( )

Sends the mail with its object properties as MimeMail It first tries to read the mail body, subject and sender address from posted named formular fields.

If no field values found the defaults are used. Placehoders will be replaced by the appropriate data. public

Parameters
objectilUser

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

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

{
global $ilSetting;
$user =& $this->getUser();
if (!$user->getEmail())
{
return false;
}
// determine language and get account mail data
// fall back to default language if acccount mail data is not given for user language.
$amail = $this->readAccountMail($user->getLanguage());
if ($amail['body'] == '' || $amail['subject'] == '')
{
$amail = $this->readAccountMail($ilSetting->get('language'));
$lang = $ilSetting->get('language');
}
else
{
$lang = $user->getLanguage();
}
// fallback if mail data is still not given
($amail['body'] == '' || $amail['subject'] == ''))
{
$lang = $user->getLanguage();
$tmp_lang = new ilLanguage($lang);
// mail subject
$mail_subject = $tmp_lang->txt('reg_mail_subject');
$timelimit = "";
if (!$user->checkTimeLimit())
{
$tmp_lang->loadLanguageModule("registration");
// #6098
$timelimit_from = new ilDateTime($user->getTimeLimitFrom(), IL_CAL_UNIX);
$timelimit_until = new ilDateTime($user->getTimeLimitUntil(), IL_CAL_UNIX);
$timelimit = ilDatePresentation::formatPeriod($timelimit_from, $timelimit_until);
$timelimit = "\n".sprintf($tmp_lang->txt('reg_mail_body_timelimit'), $timelimit)."\n\n";
}
// mail body
$mail_body = $tmp_lang->txt('reg_mail_body_salutation').' '.$user->getFullname().",\n\n".
$tmp_lang->txt('reg_mail_body_text1')."\n\n".
$tmp_lang->txt('reg_mail_body_text2')."\n".
ILIAS_HTTP_PATH.'/login.php?client_id='.CLIENT_ID."\n";
$mail_body .= $tmp_lang->txt('login').': '.$user->getLogin()."\n";
$mail_body.= $tmp_lang->txt('passwd').': '.$this->u_password."\n";
$mail_body.= "\n".$timelimit;
$mail_body .= $tmp_lang->txt('reg_mail_body_text3')."\n\r";
$mail_body .= $user->getProfileAsString($tmp_lang);
}
else
{
// replace placeholders
$mail_subject = $this->replacePlaceholders($amail['subject'], $user, $amail, $lang);
$mail_body = $this->replacePlaceholders($amail['body'], $user, $amail, $lang);
}
// send the mail
include_once 'Services/Mail/classes/class.ilMimeMail.php';
$mmail = new ilMimeMail();
$mmail->autoCheck(false);
$mmail->From($ilSetting->get('admin_email'));
$mmail->Subject($mail_subject);
$mmail->To($user->getEmail());
$mmail->Body($mail_body);
foreach($this->attachments as $filename => $display_name)
{
$mmail->Attach($filename, "", "attachment", $display_name);
}
/*
echo "<br><br><b>From</b>:".$ilSetting->get("admin_email");
echo "<br><br><b>To</b>:".$user->getEmail();
echo "<br><br><b>Subject</b>:".$mail_subject;
echo "<br><br><b>Body</b>:".$mail_body;
return true;*/
$mmail->Send();
return true;
}

+ Here is the call graph for this function:

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.

{
$this->u_target = $a_target;
}
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.

{
$this->user =& $a_user;
}
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.

{
$this->u_password = $a_pwd;
}
ilAccountMail::useLangVariablesAsFallback (   $a_status)

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

{
$this->lang_variables_as_fallback = $a_status;
}

Field Documentation

ilAccountMail::$attachments = array()
private

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

ilAccountMail::$lang_variables_as_fallback = false
private

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

Referenced by areLangVariablesUsedAsFallback().

ilAccountMail::$target = ""

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

Referenced by getTarget().

ilAccountMail::$u_password = ""

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

Referenced by getUserPassword().

ilAccountMail::$user = ""

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

Referenced by getUser(), and send().


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