Class ilAccountMail. More...
Public Member Functions | |
ilAccountMail () | |
constructor public | |
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) | |
Data Fields | |
$u_password = "" | |
$user = "" | |
$target = "" |
Class ilAccountMail.
Sends e-mail to newly created accounts.
Definition at line 33 of file class.ilAccountMail.php.
ilAccountMail::getTarget | ( | ) |
get target
public
Definition at line 127 of file class.ilAccountMail.php.
{
return $this->target;
}
& ilAccountMail::getUser | ( | ) |
get user object
public
Definition at line 105 of file class.ilAccountMail.php.
Referenced by send().
{
return $this->user;
}
ilAccountMail::getUserPassword | ( | ) |
get user password
public
Definition at line 82 of file class.ilAccountMail.php.
Referenced by replacePlaceholders().
{
return $this->u_password;
}
ilAccountMail::ilAccountMail | ( | ) |
ilAccountMail::readAccountMail | ( | $ | a_lang | ) |
get new account mail array (including subject and message body)
Definition at line 145 of file class.ilAccountMail.php.
References ilObjUserFolder::_lookupNewAccountMail().
Referenced by send().
{ if (!is_array($this->amail[$a_lang])) { include_once("classes/class.ilObjUserFolder.php"); $this->amail[$a_lang] = ilObjUserFolder::_lookupNewAccountMail($a_lang); $amail["body"] = trim($amail["body"]); $amail["subject"] = trim($amail["subject"]); } return $this->amail[$a_lang]; }
ilAccountMail::replacePlaceholders | ( | $ | a_string, | |
&$ | a_user, | |||
$ | a_amail, | |||
$ | a_lang | |||
) |
Definition at line 213 of file class.ilAccountMail.php.
References $_GET, $obj_id, $tree, $type, ilLanguage::_lookupEntry(), _lookupObjId(), ilObject::_lookupTitle(), ilObject::_lookupType(), and getUserPassword().
Referenced by send().
{ global $ilSetting, $tree; // determine salutation $gender_salut = ($a_user->getGender() == "f") ? $a_amail["sal_f"] : ($a_user->getGender() == "m") ? $a_amail["sal_m"] : $a_amail["sal_g"]; if (trim($gender_salut) == "") { $gender_salut = $a_amail["sal_g"]; } $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); $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() == "") { $a_string = eregi_replace("\[".$ws."IF_PASSWORD".$ws."\].*\[\/".$ws."IF_PASSWORD".$ws."\]", "", $a_string); $a_string = eregi_replace("\[".$ws."IF_NO_PASSWORD".$ws."\](.*)\[\/".$ws."IF_NO_PASSWORD".$ws."\]", "\\1", $a_string); } else { $a_string = eregi_replace("\[".$ws."IF_NO_PASSWORD".$ws."\].*\[\/".$ws."IF_NO_PASSWORD".$ws."\]", "", $a_string); $a_string = eregi_replace("\[".$ws."IF_PASSWORD".$ws."\](.*)\[\/".$ws."IF_PASSWORD".$ws."\]", "\\1", $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("./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 = eregi_replace("\[".$ws."IF_TARGET".$ws."\].*\[\/".$ws."IF_TARGET".$ws."\]", "", $a_string); } else { $a_string = eregi_replace("\[".$ws."IF_TARGET".$ws."\](.*)\[\/".$ws."IF_TARGET".$ws."\]", "\\1", $a_string); } return $a_string; }
ilAccountMail::reset | ( | ) |
reset all values
Definition at line 135 of file class.ilAccountMail.php.
{ $this->u_password = ""; $this->user = ""; $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
object | ilUser |
Definition at line 166 of file class.ilAccountMail.php.
References $lang, $user, getUser(), 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(); } // 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 "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); /* 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; }
ilAccountMail::setTarget | ( | $ | a_target | ) |
set repository item target
public
string | $a_target target as used in permanent links, e.g. crs_123 |
Definition at line 116 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
object | $a_user user object |
Definition at line 94 of file class.ilAccountMail.php.
{ $this->user =& $a_user; }
ilAccountMail::setUserPassword | ( | $ | a_pwd | ) |
set user password
public
string | $a_pwd users password as plain text |
Definition at line 71 of file class.ilAccountMail.php.
{ $this->u_password = $a_pwd; }
ilAccountMail::$target = "" |
Definition at line 54 of file class.ilAccountMail.php.
ilAccountMail::$u_password = "" |
Definition at line 40 of file class.ilAccountMail.php.
ilAccountMail::$user = "" |
Definition at line 47 of file class.ilAccountMail.php.
Referenced by send().