ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilDiskQuotaSummaryNotification Class Reference
+ Inheritance diagram for ilDiskQuotaSummaryNotification:
+ Collaboration diagram for ilDiskQuotaSummaryNotification:

Public Member Functions

 __construct ($a_is_personal_workspace=false)
 {
Parameters
bool | false$a_is_personal_workspace
} More...
 
 send ()
 Send notifications. More...
 
- Public Member Functions inherited from ilMailNotification
 __construct ($a_is_personal_workspace=false)
 
 setType ($a_type)
 Set notification type. More...
 
 getType ()
 Get notification type. More...
 
 setSender ($a_usr_id)
 Set sender of mail. More...
 
 getSender ()
 get sender of mail More...
 
 setRecipients (array $a_rcp)
 
 getRecipients ()
 get array of recipients More...
 
 setAttachments ($a_att)
 Set attachments. More...
 
 getAttachments ()
 Get attachments. More...
 
 setLangModules (array $a_modules)
 Set lang modules. More...
 
 getUserLanguage ($a_usr_id)
 Get user language. More...
 
 setRefId ($a_id)
 
 getRefId ()
 
 getObjId ()
 
 setObjId ($a_obj_id)
 
 getObjType ()
 Get object type. More...
 
 setAdditionalInformation (array $a_info)
 Additional information for creating notification mails. More...
 
 getAdditionalInformation ()
 
 sendMail (array $a_rcp, $a_type, $a_parse_recipients=true)
 
 getBlockBorder ()
 Get (ascii) block border. More...
 

Additional Inherited Members

- Data Fields inherited from ilMailNotification
const SUBJECT_TITLE_LENGTH = 60
 
- Protected Member Functions inherited from ilMailNotification
 setSubject ($a_subject)
 
 getSubject ()
 
 setBody ($a_body)
 
 appendBody ($a_body)
 Append body text. More...
 
 getBody ()
 
 initLanguage ($a_usr_id)
 Init language. More...
 
 initLanguageByIso2Code ($a_code='')
 Init language by ISO2 code. More...
 
 setLanguage ($a_language)
 
 getLanguage ()
 
 getLanguageText ($a_keyword)
 
 getObjectTitle ($a_shorten=false)
 
 initMail ()
 
 getMail ()
 
 createPermanentLink ($a_params=array(), $a_append='')
 
 userToString ($a_usr_id)
 
 isRefIdAccessible ($a_user_id, $a_ref_id, $a_permission="read")
 Check if ref id is accessible for user. More...
 
- Protected Attributes inherited from ilMailNotification
 $type = null
 
 $sender = null
 
 $mail = null
 
 $subject = ''
 
 $body = ''
 
 $attachments = array()
 
 $language = null
 
 $lang_modules = array()
 
 $recipients = array()
 
 $ref_id = null
 
 $obj_id = null
 
 $obj_type = null
 
 $additional_info = array()
 
 $is_in_wsp
 
 $wsp_tree
 
 $wsp_access_handler
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilDiskQuotaSummaryNotification::__construct (   $a_is_personal_workspace = false)

{

Parameters
bool | false$a_is_personal_workspace
}

Reimplemented from ilMailNotification.

Definition at line 18 of file class.ilDiskQuotaSummaryNotification.php.

19 {
20 $dqs = new ilSetting('disk_quota');
21 $rcpt = $dqs->get('summary_rcpt');
22 $rcpt = explode(',', $rcpt);
23 $loginnames = array();
24 foreach ($rcpt as $loginname) {
25 $loginname = trim($loginname);
26 if (ilObjUser::_lookupId($loginname)) {
27 $loginnames[] = $loginname;
28 }
29 }
30 $this->setRecipients($loginnames);
31
32 parent::__construct($a_is_personal_workspace);
33 }
static _lookupId($a_user_str)
Lookup id by login.
ILIAS Setting Class.

References ilObjUser\_lookupId(), and ilMailNotification\setRecipients().

+ Here is the call graph for this function:

Member Function Documentation

◆ send()

ilDiskQuotaSummaryNotification::send ( )

Send notifications.

@access public

Definition at line 42 of file class.ilDiskQuotaSummaryNotification.php.

43 {
44 global $ilDB;
45
46 // parent::send();
47
48 if (count($this->getRecipients())) {
49 $res = $ilDB->queryf(
50 "SELECT u.usr_id,u.gender,u.firstname,u.lastname,u.login,u.email,u.last_login,u.active," .
51 "u.time_limit_unlimited, " . $ilDB->fromUnixtime("u.time_limit_from") . ", " . $ilDB->fromUnixtime("u.time_limit_until") . "," .
52
53 // Inactive users get the date 0001-01-01 so that they appear
54 // first when the list is sorted by this field. Users with
55 // unlimited access get the date 9999-12-31 so that they appear
56 // last.
57 "CASE WHEN u.active = 0 THEN '0001-01-01' ELSE CASE WHEN u.time_limit_unlimited=1 THEN '9999-12-31' ELSE " . $ilDB->fromUnixtime("u.time_limit_until") . " END END access_until," .
58
59 " CASE WHEN " . $ilDB->unixTimestamp() . " BETWEEN u.time_limit_from AND u.time_limit_until THEN 0 ELSE 1 END expired," .
60 "rq.role_disk_quota, system_role.rol_id role_id, " .
61 "p1.value+0 user_disk_quota," .
62 "p2.value+0 disk_usage, " .
63 "p3.value last_update, " .
64 "p5.value language, " .
65
66 // We add 0 to some of the values to convert them into a number.
67 // This is needed for correct sorting.
68 "CASE WHEN rq.role_disk_quota>p1.value+0 OR p1.value IS NULL THEN rq.role_disk_quota ELSE p1.value+0 END disk_quota " .
69 "FROM usr_data u " .
70
71 // Fetch the role with the highest disk quota value.
72 "JOIN (SELECT u.usr_id usr_id,MAX(rd.disk_quota) role_disk_quota " .
73 "FROM usr_data u " .
74 "JOIN rbac_ua ua ON ua.usr_id=u.usr_id " .
75 "JOIN rbac_fa fa ON fa.rol_id=ua.rol_id AND fa.parent=%s " .
76 "JOIN role_data rd ON rd.role_id=ua.rol_id WHERE u.usr_id=ua.usr_id GROUP BY u.usr_id) rq ON rq.usr_id=u.usr_id " .
77
78 // Fetch the system role in order to determine whether the user has unlimited disk quota
79 "LEFT JOIN rbac_ua system_role ON system_role.usr_id=u.usr_id AND system_role.rol_id = %s " .
80
81 // Fetch the user disk quota from table usr_pref
82 "LEFT JOIN usr_pref p1 ON p1.usr_id=u.usr_id AND p1.keyword = 'disk_quota' " .
83
84 // Fetch the disk usage from table usr_pref
85 "LEFT JOIN usr_pref p2 ON p2.usr_id=u.usr_id AND p2.keyword = 'disk_usage' " .
86
87 // Fetch the last update from table usr_pref
88 "LEFT JOIN usr_pref p3 ON p3.usr_id=u.usr_id AND p3.keyword = 'disk_usage.last_update' " .
89
90 // Fetch the language of the user
91 "LEFT JOIN usr_pref p5 ON p5.usr_id=u.usr_id AND p5.keyword = 'language' " .
92
93 // Fetch only users who have exceeded their quota, and who have
94 // access, and who have not received a reminder in the past seven days
95 // #8554 / #10301
96 'WHERE (((p1.value+0 > rq.role_disk_quota OR rq.role_disk_quota IS NULL) AND p2.value+0 > p1.value+0) OR
97 ((rq.role_disk_quota > p1.value+0 OR p1.value IS NULL) AND p2.value+0 > rq.role_disk_quota)) ' .
98 'AND (u.active=1 AND (u.time_limit_unlimited = 1 OR ' . $ilDB->unixTimestamp() . ' BETWEEN u.time_limit_from AND u.time_limit_until)) ',
99 array('integer','integer'),
100 array(ROLE_FOLDER_ID, SYSTEM_ROLE_ID)
101 );
102
103 $users = array();
104
105 $counter = 0;
106 while ($row = $ilDB->fetchAssoc($res)) {
107 $details = ilDiskQuotaChecker::_lookupDiskUsage($row['usr_id']);
108
109 $users[$counter]['disk_quota'] = $row['disk_quota'];
110 $users[$counter]['disk_usage'] = $details['disk_usage'];
111 $users[$counter]['email'] = $row['email'];
112 $users[$counter]['firstname'] = $row['firstname'];
113 $users[$counter]['lastname'] = $row['lastname'];
114
115 ++$counter;
116 }
117
118 if (count($users)) {
119 foreach ($this->getRecipients() as $rcp) {
120 $usrId = ilObjUser::_lookupId($rcp);
121
122 $this->initLanguage($usrId);
123 $this->initMail();
124
125 $this->setSubject($this->getLanguage()->txt('disk_quota_summary_subject'));
126
127 $this->setBody(ilMail::getSalutation($usrId, $this->getLanguage()));
128
129 $this->appendBody("\n\n");
130 $this->appendBody($this->getLanguage()->txt('disk_quota_exceeded_headline'));
131 $this->appendBody("\n\n");
132
133 $first = true;
134 $counter = 0;
135 $numUsers = count($users);
136 foreach ($users as $user) {
137 if (!$first) {
138 $this->appendBody("\n---------------------------------------------------\n\n");
139 }
140
141 $this->appendBody(
142 $this->getLanguage()->txt('fullname') . ': ' .
143 $user['lastname'] . ', ' . $user['firstname']
144 . "\n"
145 );
146 $this->appendBody(
147 $this->getLanguage()->txt('email') . ': ' .
148 $user['email']
149 . "\n"
150 );
151 $this->appendBody(
152 $this->getLanguage()->txt('disk_quota') . ': ' .
153 ilUtil::formatSize($user['disk_quota'], 'short', $this->getLanguage())
154 . "\n"
155 );
156 $this->appendBody(
157 $this->getLanguage()->txt('currently_used_disk_space') . ': ' .
158 ilUtil::formatSize($user['disk_usage'], 'short', $this->getLanguage())
159 . "\n"
160 );
161
162 $this->appendBody(
163 $this->getLanguage()->txt('usrf_profile_link') . ': ' .
164 ilUtil::_getHttpPath() . '/goto.php?target=usrf&client_id=' . CLIENT_ID
165 );
166
167 if ($counter < $numUsers - 1) {
168 $this->appendBody("\n");
169 }
170
171 ++$counter;
172 $first = false;
173 }
174
175 $this->getMail()->appendInstallationSignature(true);
176
177 $this->sendMail(array($rcp), array('system'), false);
178 }
179 }
180 }
181 }
$users
Definition: authpage.php:44
static _lookupDiskUsage($a_user_id)
Gets the disk usage info for the specified user account.
appendBody($a_body)
Append body text.
sendMail(array $a_rcp, $a_type, $a_parse_recipients=true)
initLanguage($a_usr_id)
Init language.
getRecipients()
get array of recipients
static getSalutation($a_usr_id, ilLanguage $a_language=null)
static _getHttpPath()
static formatSize($size, $a_mode='short', $a_lng=null)
Returns the specified file size value in a human friendly form.
$counter
foreach($_POST as $key=> $value) $res
global $ilDB

References $counter, $ilDB, $res, $row, $users, ilUtil\_getHttpPath(), ilDiskQuotaChecker\_lookupDiskUsage(), ilObjUser\_lookupId(), ilMailNotification\appendBody(), ilUtil\formatSize(), ilMailNotification\getLanguage(), ilMailNotification\getMail(), ilMailNotification\getRecipients(), ilMail\getSalutation(), ilMailNotification\initLanguage(), ilMailNotification\initMail(), ilMailNotification\sendMail(), ilMailNotification\setBody(), and ilMailNotification\setSubject().

+ Here is the call graph for this function:

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