Mail Box class Base class for creating and handling mail boxes.
More...
Mail Box class Base class for creating and handling mail boxes.
- Author
- Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
- Version
- $Id$
Definition at line 29 of file class.ilMailbox.php.
◆ __construct()
| ilMailbox::__construct |
( |
protected int |
$usrId | ) |
|
Definition at line 52 of file class.ilMailbox.php.
References $DIC, and ILIAS\Repository\lng().
60 $this->
lng = $DIC->language();
61 $this->db = $DIC->database();
62 $this->table_mail_obj_data =
'mail_obj_data';
63 $this->table_tree =
'mail_tree';
65 $this->mtree =
new ilTree($this->usrId);
66 $this->mtree->setTableNames($this->table_tree, $this->table_mail_obj_data);
71 if (is_object($this->
lng)) {
72 $this->
lng->loadLanguageModule(
"mail");
75 'moveMails' => $this->
lng->txt(
'mail_move_to'),
76 'markMailsRead' => $this->
lng->txt(
'mail_mark_read'),
77 'markMailsUnread' => $this->
lng->txt(
'mail_mark_unread'),
78 'deleteMails' => $this->
lng->txt(
'delete'),
◆ addFolder()
| ilMailbox::addFolder |
( |
int |
$parentFolderId, |
|
|
string |
$name |
|
) |
| |
Definition at line 182 of file class.ilMailbox.php.
References folderNameExists().
188 $nextId = $this->db->nextId($this->table_mail_obj_data);
189 $this->db->manipulateF(
190 'INSERT INTO ' . $this->table_mail_obj_data .
191 ' (obj_id, user_id, title, m_type) VALUES(%s,%s,%s,%s)',
192 [
'integer',
'integer',
'text',
'text'],
193 [$nextId, $this->usrId, $name,
'user_folder']
195 $this->mtree->insertNode($nextId, $parentFolderId);
folderNameExists(string $name)
◆ createDefaultFolder()
| ilMailbox::createDefaultFolder |
( |
| ) |
|
Creates all default folders for a user.
This method should only be called when a user object is created.
Definition at line 159 of file class.ilMailbox.php.
References ILIAS\LTI\ToolProvider\$key.
161 $rootFolderId = $this->db->nextId($this->table_mail_obj_data);
162 $this->db->manipulateF(
163 'INSERT INTO ' . $this->table_mail_obj_data .
164 ' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
165 [
'integer',
'integer',
'text',
'text'],
166 [$rootFolderId, $this->usrId,
'a_root',
'root']
168 $this->mtree->addTree($this->usrId, $rootFolderId);
170 foreach ($this->defaultFolders as
$key => $folder) {
171 $last_id = $this->db->nextId($this->table_mail_obj_data);
172 $this->db->manipulateF(
173 'INSERT INTO ' . $this->table_mail_obj_data .
174 ' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
175 [
'integer',
'integer',
'text',
'text'],
176 [$last_id, $this->usrId,
$key, $folder]
178 $this->mtree->insertNode($last_id, $rootFolderId);
◆ delete()
Definition at line 357 of file class.ilMailbox.php.
359 $this->db->manipulateF(
360 'DELETE FROM mail_obj_data WHERE user_id = %s',
365 $this->db->manipulateF(
366 'DELETE FROM mail_options WHERE user_id = %s',
371 $this->db->manipulateF(
372 'DELETE FROM mail_saved WHERE user_id = %s',
377 $this->db->manipulateF(
378 'DELETE FROM mail_tree WHERE tree = %s',
383 $this->db->manipulateF(
384 'DELETE FROM mail_auto_responder WHERE sender_id = %s OR receiver_id = %s',
385 [
'integer',
'integer'],
386 [$this->usrId, $this->usrId]
392 $fdm->onUserDelete();
395 $this->db->manipulateF(
396 'DELETE FROM mail WHERE user_id = %s',
This class handles all operations on files (attachments) in directory ilias_data/mail.
◆ deleteFolder()
| ilMailbox::deleteFolder |
( |
int |
$folderId | ) |
|
- Exceptions
-
Definition at line 230 of file class.ilMailbox.php.
References ILIAS\Repository\int().
232 $query = $this->db->queryF(
233 'SELECT obj_id, title FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
234 [
'integer',
'integer'],
235 [$folderId, $this->usrId]
237 $row = $this->db->fetchAssoc($query);
239 if (!is_array($row) || array_key_exists($row[
'title'], $this->defaultFolders)) {
243 $mailer =
new ilMail($this->usrId);
245 $subtree = $this->mtree->getSubTree($this->mtree->getNodeData($folderId));
246 $this->mtree->deleteTree($this->mtree->getNodeData($folderId));
248 foreach ($subtree as $node) {
249 $nodeId = (
int) $node[
'obj_id'];
251 $mails = $mailer->getMailsOfFolder($nodeId);
254 foreach ($mails as $mail) {
255 $mailIds[] = (
int) $mail[
'mail_id'];
258 $mailer->deleteMails($mailIds);
260 $this->db->manipulateF(
261 'DELETE FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
262 [
'integer',
'integer'],
263 [$nodeId, $this->usrId]
◆ folderNameExists()
| ilMailbox::folderNameExists |
( |
string |
$name | ) |
|
|
protected |
Definition at line 215 of file class.ilMailbox.php.
References $res.
Referenced by addFolder(), and renameFolder().
217 $res = $this->db->queryF(
218 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
220 [$this->usrId, $name]
222 $row = $this->db->fetchAssoc(
$res);
224 return is_array($row) && $row[
'obj_id'] > 0;
◆ getActions()
| ilMailbox::getActions |
( |
int |
$folderId | ) |
|
- Returns
- array{moveMails: string, markMailsRead: string, markMailsUnread: string, deleteMails: string}
Definition at line 151 of file class.ilMailbox.php.
References $actions.
◆ getDraftsFolder()
| ilMailbox::getDraftsFolder |
( |
| ) |
|
Definition at line 109 of file class.ilMailbox.php.
References $res.
111 $res = $this->db->queryF(
112 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
114 [$this->usrId,
'drafts']
117 $row = $this->db->fetchAssoc(
$res);
119 return (
int) $row[
'obj_id'];
◆ getFolderData()
| ilMailbox::getFolderData |
( |
int |
$folderId | ) |
|
- Returns
- array{obj_id: int, title: string, type: string}|null
Definition at line 273 of file class.ilMailbox.php.
References $res, and ILIAS\Repository\int().
Referenced by isOwnedFolder().
275 $res = $this->db->queryF(
276 'SELECT * FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND obj_id = %s',
277 [
'integer',
'integer'],
278 [$this->usrId, $folderId]
280 $row = $this->db->fetchAssoc(
$res);
282 if (is_array($row)) {
284 'obj_id' => (
int) $row[
'obj_id'],
285 'title' => (
string) $row[
'title'],
286 'type' => (string) $row[
'm_type'],
◆ getInboxFolder()
| ilMailbox::getInboxFolder |
( |
| ) |
|
Definition at line 96 of file class.ilMailbox.php.
References $res.
98 $res = $this->db->queryF(
99 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
101 [$this->usrId,
'inbox']
104 $row = $this->db->fetchAssoc(
$res);
106 return (
int) $row[
'obj_id'];
◆ getParentFolderId()
| ilMailbox::getParentFolderId |
( |
int |
$folderId | ) |
|
Definition at line 293 of file class.ilMailbox.php.
References $res, and ILIAS\Repository\int().
295 $res = $this->db->queryF(
296 'SELECT * FROM ' . $this->table_tree .
' WHERE child = %s AND tree = %s',
297 [
'integer',
'integer'],
298 [$folderId, $this->usrId]
300 $row = $this->db->fetchAssoc(
$res);
302 return is_array($row) ? (
int) $row[
'parent'] : 0;
◆ getRooFolder()
| ilMailbox::getRooFolder |
( |
| ) |
|
Definition at line 83 of file class.ilMailbox.php.
References $res.
85 $res = $this->db->queryF(
86 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
88 [$this->usrId,
'root']
91 $row = $this->db->fetchAssoc(
$res);
93 return (
int) $row[
'obj_id'];
◆ getSentFolder()
| ilMailbox::getSentFolder |
( |
| ) |
|
Definition at line 135 of file class.ilMailbox.php.
References $res.
137 $res = $this->db->queryF(
138 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
140 [$this->usrId,
'sent']
143 $row = $this->db->fetchAssoc(
$res);
145 return (
int) $row[
'obj_id'];
◆ getSubFolders()
| ilMailbox::getSubFolders |
( |
| ) |
|
Definition at line 305 of file class.ilMailbox.php.
References ILIAS\LTI\ToolProvider\$key, $res, and ILIAS\Repository\int().
309 foreach (array_keys($this->defaultFolders) as
$key) {
310 $res = $this->db->queryF(
311 'SELECT obj_id, m_type FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
315 $row = $this->db->fetchAssoc(
$res);
319 'type' => (string) $row[
'm_type'],
320 'obj_id' => (
int) $row[
'obj_id'],
324 $query = implode(
' ', [
325 'SELECT * FROM ' . $this->table_tree .
', ' . $this->table_mail_obj_data,
326 'WHERE ' . $this->table_mail_obj_data .
'.obj_id = ' . $this->table_tree .
'.child',
327 'AND ' . $this->table_tree .
'.depth > %s',
328 'AND ' . $this->table_tree .
'.tree = %s',
329 'ORDER BY ' . $this->table_tree .
'.lft, ' . $this->table_mail_obj_data .
'.title',
331 $res = $this->db->queryF(
333 [
'integer',
'integer'],
336 while ($row = $this->db->fetchAssoc(
$res)) {
338 'title' => (string) $row[
'title'],
339 'type' => (
string) $row[
'm_type'],
340 'obj_id' => (
int) $row[
'child'],
◆ getTrashFolder()
| ilMailbox::getTrashFolder |
( |
| ) |
|
Definition at line 122 of file class.ilMailbox.php.
References $res.
124 $res = $this->db->queryF(
125 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
127 [$this->usrId,
'trash']
130 $row = $this->db->fetchAssoc(
$res);
132 return (
int) $row[
'obj_id'];
◆ getUsrId()
◆ isOwnedFolder()
| ilMailbox::isOwnedFolder |
( |
int |
$folderId | ) |
|
◆ renameFolder()
| ilMailbox::renameFolder |
( |
int |
$folderId, |
|
|
string |
$name |
|
) |
| |
Definition at line 200 of file class.ilMailbox.php.
References folderNameExists().
206 $this->db->manipulateF(
207 'UPDATE ' . $this->table_mail_obj_data .
' SET title = %s WHERE obj_id = %s AND user_id = %s',
208 [
'text',
'integer',
'integer'],
209 [$name, $folderId, $this->usrId]
folderNameExists(string $name)
◆ setUsrId()
| ilMailbox::setUsrId |
( |
int |
$usrId | ) |
|
◆ updateMailsOfDeletedUser()
| ilMailbox::updateMailsOfDeletedUser |
( |
string |
$nameToShow | ) |
|
Update existing mails.
Set sender id to 0 and import name to login name. This is only necessary for deleted users.
Definition at line 406 of file class.ilMailbox.php.
408 $this->db->manipulateF(
409 'UPDATE mail SET sender_id = %s, import_name = %s WHERE sender_id = %s',
410 [
'integer',
'text',
'integer'],
411 [0, $nameToShow, $this->usrId]
◆ $actions
| array ilMailbox::$actions |
|
protected |
◆ $db
◆ $defaultFolders
| array ilMailbox::$defaultFolders |
|
protected |
◆ $lng
◆ $mtree
◆ $table_mail_obj_data
| array string ilMailbox::$table_mail_obj_data |
|
protected |
Initial value:=> 'trash',
'd_drafts' => 'drafts',
'e_sent' => 'sent',
'z_local' => 'local',
]
Definition at line 44 of file class.ilMailbox.php.
◆ $table_tree
| string ilMailbox::$table_tree |
|
protected |
The documentation for this class was generated from the following file: