ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilAccountMail Class Reference

Class ilAccountMail. More...

+ Collaboration diagram for ilAccountMail:

Public Member Functions

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

Data Fields

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

Private Attributes

 $lang_variables_as_fallback = false

Detailed Description

Member Function Documentation

ilAccountMail::areLangVariablesUsedAsFallback ( )

Definition at line 72 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 139 of file class.ilAccountMail.php.

References $target.

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

get user object

public

Returns
object user object

Definition at line 117 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 94 of file class.ilAccountMail.php.

References $u_password.

Referenced by replacePlaceholders().

{
}

+ Here is the caller graph for this function:

ilAccountMail::ilAccountMail ( )

constructor public

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

{
}
ilAccountMail::readAccountMail (   $a_lang)

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

Definition at line 157 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($amail["body"]);
$amail["subject"] = trim($amail["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 249 of file class.ilAccountMail.php.

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

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() == "")
{
$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("./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 = 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;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilAccountMail::reset ( )

reset all values

Definition at line 147 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 178 of file class.ilAccountMail.php.

References $ilSetting, $lang, $user, areLangVariablesUsedAsFallback(), 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();
}
// 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');
// 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";
$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);
/*
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 128 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 106 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 83 of file class.ilAccountMail.php.

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

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

{
$this->lang_variables_as_fallback = $a_status;
}

Field Documentation

ilAccountMail::$lang_variables_as_fallback = false
private

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

Referenced by areLangVariablesUsedAsFallback().

ilAccountMail::$target = ""

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

Referenced by getTarget().

ilAccountMail::$u_password = ""

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

Referenced by getUserPassword().

ilAccountMail::$user = ""

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

Referenced by getUser(), and send().


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