ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilDiskQuotaReminderMail Class Reference

Class ilDiskQuotaReminderMail. More...

+ Collaboration diagram for ilDiskQuotaReminderMail:

Public Member Functions

 __construct ()
 constructor @access public More...
 
 useLangVariablesAsFallback ($a_status)
 
 areLangVariablesUsedAsFallback ()
 
 setData ($a_data)
 Sets used to fill in the placeholders in the mail. More...
 
 reset ()
 reset all values More...
 
 readMailTemplate ($a_lang)
 get new mail template array (including subject and message body) More...
 
 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. More...
 
 replacePlaceholders ($a_string, $a_amail, $a_lang)
 

Private Member Functions

 getLng ($a_lang)
 

Private Attributes

 $lang_variables_as_fallback = true
 
 $data
 Data used to fill in the placeholders in the mail. More...
 
 $tmp_lng
 

Detailed Description

Class ilDiskQuotaReminderMail.

Sends e-mail to users who have exceeded their disk quota.

Author
Werner Randelshofer werne.nosp@m.r.ra.nosp@m.ndels.nosp@m.hofe.nosp@m.r@hsl.nosp@m.u.ch
Version
$Id$

Definition at line 13 of file class.ilDiskQuotaReminderMail.php.

Constructor & Destructor Documentation

◆ __construct()

ilDiskQuotaReminderMail::__construct ( )

constructor @access public

Definition at line 28 of file class.ilDiskQuotaReminderMail.php.

29 {
30 }

Member Function Documentation

◆ areLangVariablesUsedAsFallback()

ilDiskQuotaReminderMail::areLangVariablesUsedAsFallback ( )

Definition at line 37 of file class.ilDiskQuotaReminderMail.php.

References $lang_variables_as_fallback.

Referenced by send().

+ Here is the caller graph for this function:

◆ getLng()

ilDiskQuotaReminderMail::getLng (   $a_lang)
private

Definition at line 161 of file class.ilDiskQuotaReminderMail.php.

161 {
162 if ($this->tmp_lng == null || $this->tmp_lng->lang_key != $a_lang)
163 {
164 $this->tmp_lng = new ilLanguage($lang);
165 }
166 return $this->tmp_lng;
167 }
language handling

References $lang, and $tmp_lng.

Referenced by replacePlaceholders(), and send().

+ Here is the caller graph for this function:

◆ readMailTemplate()

ilDiskQuotaReminderMail::readMailTemplate (   $a_lang)

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

Definition at line 77 of file class.ilDiskQuotaReminderMail.php.

78 {
79 if (!is_array($this->amail[$a_lang]))
80 {
81 require_once('./Services/WebDAV/classes/class.ilObjDiskQuotaSettings.php');
82 $this->amail[$a_lang] = ilObjDiskQuotaSettings::_lookupReminderMailTemplate($a_lang);
83 $this->amail["body"] = trim($this->amail["body"]);
84 $this->amail["subject"] = trim($this->amail["subject"]);
85 }
86
87 return $this->amail[$a_lang];
88 }
_lookupReminderMailTemplate($a_lang)
Looks up the mail template for the specified language.

References ilObjDiskQuotaSettings\_lookupReminderMailTemplate().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ replacePlaceholders()

ilDiskQuotaReminderMail::replacePlaceholders (   $a_string,
  $a_amail,
  $a_lang 
)

Definition at line 169 of file class.ilDiskQuotaReminderMail.php.

170 {
171 global $ilSetting, $tree;
172
173 $tmp_lang = $this->getLng($a_lang);
174
175 // determine salutation
176 switch ($this->data['gender'])
177 {
178 case "f" : $gender_salut = $a_amail["sal_f"];
179 break;
180 case "m" : $gender_salut = $a_amail["sal_m"];
181 break;
182 default : $gender_salut = $a_amail["sal_g"];
183 }
184 $gender_salut = trim($gender_salut);
185
186 $a_string = str_replace("[MAIL_SALUTATION]", $gender_salut, $a_string);
187 $a_string = str_replace("[LOGIN]", $this->data['login'], $a_string);
188 $a_string = str_replace("[FIRST_NAME]", $this->data['firstname'], $a_string);
189 $a_string = str_replace("[LAST_NAME]", $this->data['lastname'], $a_string);
190 // BEGIN Mail Include E-Mail Address in account mail
191 $a_string = str_replace("[EMAIL]", $this->data['email'], $a_string);
192 $a_string = str_replace("[ILIAS_URL]",
193 ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID, $a_string);
194 $a_string = str_replace("[CLIENT_NAME]", CLIENT_NAME, $a_string);
195 $a_string = str_replace("[ADMIN_MAIL]", $ilSetting->get("admin_email"),
196 $a_string);
197
198 require_once './Services/Utilities/classes/class.ilFormat.php';
199 $a_string = str_replace("[DISK_QUOTA]", ilFormat::formatSize($this->data['disk_quota'],'short',$tmp_lang), $a_string);
200 $a_string = str_replace("[DISK_USAGE]", ilFormat::formatSize($this->data['disk_usage'],'short',$tmp_lang), $a_string);
201
202 $disk_usage_details = '';
203 foreach ($this->data['disk_usage_details'] as $details)
204 {
205 $disk_usage_details .= ilFormat::formatFloat($details['count'],0,true,$tmp_lang).' '.$tmp_lang->txt($details['type']).' '.ilFormat::formatSize($details['size'],'short',$tmp_lang)."\n";
206 }
207 $a_string = str_replace("[DISK_USAGE_DETAILS]", $disk_usage_details, $a_string);
208
209 return $a_string;
210 }
static formatFloat($size, $a_decimals, $a_suppress_dot_zero=false, $a_mode='short', $a_lng=null)
Returns the specified float in human friendly form.
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
global $ilSetting
Definition: privfeed.php:40

References $ilSetting, ilFormat\formatFloat(), ilFormat\formatSize(), and getLng().

Referenced by send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reset()

ilDiskQuotaReminderMail::reset ( )

reset all values

Definition at line 69 of file class.ilDiskQuotaReminderMail.php.

70 {
71 unset($this->data);
72 }

◆ send()

ilDiskQuotaReminderMail::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. @access public

Parameters
objectilUser

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

99 {
100 global $ilSetting;
101
102 // determine language and get account mail data
103 // fall back to default language if acccount mail data is not given for user language.
104 $amail = $this->readMailTemplate($this->data['language']);
105 if ($amail['body'] == '' || $amail['subject'] == '')
106 {
107 $amail = $this->readMailTemplate($ilSetting->get('language'));
108 $lang = $ilSetting->get('language');
109 }
110 else
111 {
112 $lang = $this->data['language'];
113 }
114
115 // fallback if mail data is still not given
116 if($this->areLangVariablesUsedAsFallback() &&
117 ($amail['body'] == '' || $amail['subject'] == ''))
118 {
119 $lang = $this->data['language'];
120 $tmp_lang = $this->getLng($lang);
121
122 // mail subject
123 $mail_subject = $tmp_lang->txt('disk_quota_mail_subject');
124
125 // mail body
126 $mail_body = $tmp_lang->txt('disk_quota_mail_body_salutation').' '.$data['firstname'].' '.$data['lastname'].",\n\n".
127 $tmp_lang->txt('disk_quota_body_text1')."\n\n".
128 $tmp_lang->txt('disk_quota_body_text2')."\n".
129 ILIAS_HTTP_PATH.'/login.php?client_id='.CLIENT_ID."\n";
130 $mail_body .= $tmp_lang->txt('login').': '.$data['firstname']."\n";
131 $mail_body.= "\n";
132 $mail_body .= $tmp_lang->txt('disk_quota_mail_body_text3')."\n\r";
133 //$mail_body .= $user->getProfileAsString($tmp_lang);
134 }
135 else
136 {
137 // replace placeholders
138 $mail_subject = $this->replacePlaceholders($amail['subject'], $amail, $lang);
139 $mail_body = $this->replacePlaceholders($amail['body'], $amail, $lang);
140 }
141
142 // send the mail
143 include_once 'Services/Mail/classes/class.ilMimeMail.php';
144 $mmail = new ilMimeMail();
145 $mmail->autoCheck(false);
146 $mmail->From($ilSetting->get('admin_email'));
147 $mmail->Subject($mail_subject);
148 $mmail->To($this->data['email']);
149 $mmail->Body($mail_body);
150 $mmail->Send();
151
152 include_once 'Services/Mail/classes/class.ilMail.php';
153 $mail = new ilMail($_SESSION["AccountId"]);
154 $mail->sendMail($this->data['login'],"","",$mail_subject,$mail_body,array(),array("normal"));
155
156
157
158 return true;
159 }
$_SESSION["AccountId"]
replacePlaceholders($a_string, $a_amail, $a_lang)
$data
Data used to fill in the placeholders in the mail.
readMailTemplate($a_lang)
get new mail template array (including subject and message body)
Class Mail this class handles base functions for mail handling.
this class encapsulates the PHP mail() function.

References $_SESSION, $data, $ilSetting, $lang, areLangVariablesUsedAsFallback(), getLng(), readMailTemplate(), and replacePlaceholders().

+ Here is the call graph for this function:

◆ setData()

ilDiskQuotaReminderMail::setData (   $a_data)

Sets used to fill in the placeholders in the mail.

The following key value pairs must be supplied:

'language' string language of user 'gender' string gender of user 'm' or 'f' 'firstname' string firstname of the user 'lastname' string lastname of the user 'email' string email address of the user 'login' string login of the user 'disk_quota' integer disk quota in bytes of the user 'disk_usage' integer disk usage in bytes of the user 'disk_usage_details' associative array with the values returned by ilDiskQuotaChecker::_lookupDiskUsage($a_usr_id)

Parameters
$a_dataarray Key value pairs with the name of the placeholder as keys.

Definition at line 61 of file class.ilDiskQuotaReminderMail.php.

62 {
63 $this->data = $a_data;
64 }

◆ useLangVariablesAsFallback()

ilDiskQuotaReminderMail::useLangVariablesAsFallback (   $a_status)

Definition at line 32 of file class.ilDiskQuotaReminderMail.php.

33 {
34 $this->lang_variables_as_fallback = $a_status;
35 }

Field Documentation

◆ $data

ilDiskQuotaReminderMail::$data
private

Data used to fill in the placeholders in the mail.

Contains key value pairs with the name of the placeholder as keys.

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

Referenced by send().

◆ $lang_variables_as_fallback

ilDiskQuotaReminderMail::$lang_variables_as_fallback = true
private

Definition at line 15 of file class.ilDiskQuotaReminderMail.php.

Referenced by areLangVariablesUsedAsFallback().

◆ $tmp_lng

ilDiskQuotaReminderMail::$tmp_lng
private

Definition at line 22 of file class.ilDiskQuotaReminderMail.php.

Referenced by getLng().


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