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 |
( |
int |
$a_user_id | ) |
|
Definition at line 53 of file class.ilMailbox.php.
References $DIC, and ILIAS\Repository\lng().
61 $this->
lng = $DIC->language();
62 $this->db = $DIC->database();
64 $this->usrId = $a_user_id;
65 $this->table_mail_obj_data =
'mail_obj_data';
66 $this->table_tree =
'mail_tree';
68 $this->mtree =
new ilTree($this->usrId);
69 $this->mtree->setTableNames($this->table_tree, $this->table_mail_obj_data);
74 if (is_object($this->
lng)) {
75 $this->
lng->loadLanguageModule(
"mail");
78 'moveMails' => $this->
lng->txt(
'mail_move_to'),
79 'markMailsRead' => $this->
lng->txt(
'mail_mark_read'),
80 'markMailsUnread' => $this->
lng->txt(
'mail_mark_unread'),
81 'deleteMails' => $this->
lng->txt(
'delete'),
◆ addFolder()
ilMailbox::addFolder |
( |
int |
$parentFolderId, |
|
|
string |
$name |
|
) |
| |
Definition at line 186 of file class.ilMailbox.php.
References folderNameExists().
192 $nextId = $this->db->nextId($this->table_mail_obj_data);
193 $this->db->manipulateF(
194 'INSERT INTO ' . $this->table_mail_obj_data .
195 ' (obj_id, user_id, title, m_type) VALUES(%s,%s,%s,%s)',
196 [
'integer',
'integer',
'text',
'text'],
197 [$nextId, $this->usrId,
$name,
'user_folder']
199 $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 163 of file class.ilMailbox.php.
References ILIAS\LTI\ToolProvider\$key.
165 $rootFolderId = $this->db->nextId($this->table_mail_obj_data);
166 $this->db->manipulateF(
167 'INSERT INTO ' . $this->table_mail_obj_data .
168 ' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
169 [
'integer',
'integer',
'text',
'text'],
170 [$rootFolderId, $this->usrId,
'a_root',
'root']
172 $this->mtree->addTree($this->usrId, $rootFolderId);
174 foreach ($this->defaultFolders as
$key => $folder) {
175 $last_id = $this->db->nextId($this->table_mail_obj_data);
176 $this->db->manipulateF(
177 'INSERT INTO ' . $this->table_mail_obj_data .
178 ' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
179 [
'integer',
'integer',
'text',
'text'],
180 [$last_id, $this->usrId,
$key, $folder]
182 $this->mtree->insertNode($last_id, $rootFolderId);
◆ delete()
Definition at line 361 of file class.ilMailbox.php.
363 $this->db->manipulateF(
364 'DELETE FROM mail_obj_data WHERE user_id = %s',
369 $this->db->manipulateF(
370 'DELETE FROM mail_options WHERE user_id = %s',
375 $this->db->manipulateF(
376 'DELETE FROM mail_saved WHERE user_id = %s',
381 $this->db->manipulateF(
382 'DELETE FROM mail_tree WHERE tree = %s',
390 $fdm->onUserDelete();
393 $this->db->manipulateF(
394 '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 234 of file class.ilMailbox.php.
References $query, and ILIAS\Repository\int().
236 $query = $this->db->queryF(
237 'SELECT obj_id, title FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
238 [
'integer',
'integer'],
239 [$folderId, $this->usrId]
241 $row = $this->db->fetchAssoc(
$query);
243 if (!is_array($row) || array_key_exists($row[
'title'], $this->defaultFolders)) {
247 $mailer =
new ilMail($this->usrId);
249 $subtree = $this->mtree->getSubTree($this->mtree->getNodeData($folderId));
250 $this->mtree->deleteTree($this->mtree->getNodeData($folderId));
252 foreach ($subtree as $node) {
253 $nodeId = (
int) $node[
'obj_id'];
255 $mails = $mailer->getMailsOfFolder($nodeId);
258 foreach ($mails as $mail) {
259 $mailIds[] = (
int) $mail[
'mail_id'];
262 $mailer->deleteMails($mailIds);
264 $this->db->manipulateF(
265 'DELETE FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
266 [
'integer',
'integer'],
267 [$nodeId, $this->usrId]
◆ folderNameExists()
ilMailbox::folderNameExists |
( |
string |
$name | ) |
|
|
protected |
Definition at line 219 of file class.ilMailbox.php.
References $res.
Referenced by addFolder(), and renameFolder().
221 $res = $this->db->queryF(
222 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
224 [$this->usrId,
$name]
226 $row = $this->db->fetchAssoc(
$res);
228 return is_array($row) && $row[
'obj_id'] > 0;
◆ getActions()
ilMailbox::getActions |
( |
int |
$folderId | ) |
|
- Parameters
-
- Returns
- array{moveMails: string, markMailsRead: string, markMailsUnread: string, deleteMails: string}
Definition at line 155 of file class.ilMailbox.php.
References $actions.
◆ getDraftsFolder()
ilMailbox::getDraftsFolder |
( |
| ) |
|
Definition at line 112 of file class.ilMailbox.php.
References $res.
114 $res = $this->db->queryF(
115 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
117 [$this->usrId,
'drafts']
120 $row = $this->db->fetchAssoc(
$res);
122 return (
int) $row[
'obj_id'];
◆ getFolderData()
ilMailbox::getFolderData |
( |
int |
$folderId | ) |
|
- Returns
- array{obj_id: int, title: string, type: string}|null
Definition at line 277 of file class.ilMailbox.php.
References $res, and ILIAS\Repository\int().
Referenced by isOwnedFolder().
279 $res = $this->db->queryF(
280 'SELECT * FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND obj_id = %s',
281 [
'integer',
'integer'],
282 [$this->usrId, $folderId]
284 $row = $this->db->fetchAssoc(
$res);
286 if (is_array($row)) {
288 'obj_id' => (
int) $row[
'obj_id'],
289 'title' => (
string) $row[
'title'],
290 'type' => (string) $row[
'm_type'],
◆ getInboxFolder()
ilMailbox::getInboxFolder |
( |
| ) |
|
Definition at line 99 of file class.ilMailbox.php.
References $res.
101 $res = $this->db->queryF(
102 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
104 [$this->usrId,
'inbox']
107 $row = $this->db->fetchAssoc(
$res);
109 return (
int) $row[
'obj_id'];
◆ getParentFolderId()
ilMailbox::getParentFolderId |
( |
int |
$folderId | ) |
|
Definition at line 297 of file class.ilMailbox.php.
References $res, and ILIAS\Repository\int().
299 $res = $this->db->queryF(
300 'SELECT * FROM ' . $this->table_tree .
' WHERE child = %s AND tree = %s',
301 [
'integer',
'integer'],
302 [$folderId, $this->usrId]
304 $row = $this->db->fetchAssoc(
$res);
306 return is_array($row) ? (
int) $row[
'parent'] : 0;
◆ getRooFolder()
ilMailbox::getRooFolder |
( |
| ) |
|
Definition at line 86 of file class.ilMailbox.php.
References $res.
88 $res = $this->db->queryF(
89 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
91 [$this->usrId,
'root']
94 $row = $this->db->fetchAssoc(
$res);
96 return (
int) $row[
'obj_id'];
◆ getSentFolder()
ilMailbox::getSentFolder |
( |
| ) |
|
Definition at line 138 of file class.ilMailbox.php.
References $res.
140 $res = $this->db->queryF(
141 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
143 [$this->usrId,
'sent']
146 $row = $this->db->fetchAssoc(
$res);
148 return (
int) $row[
'obj_id'];
◆ getSubFolders()
ilMailbox::getSubFolders |
( |
| ) |
|
Definition at line 309 of file class.ilMailbox.php.
References ILIAS\LTI\ToolProvider\$key, $query, $res, and ILIAS\Repository\int().
313 foreach ($this->defaultFolders as
$key => $value) {
314 $res = $this->db->queryF(
315 'SELECT obj_id, m_type FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
319 $row = $this->db->fetchAssoc(
$res);
323 'type' => (string) $row[
'm_type'],
324 'obj_id' => (
int) $row[
'obj_id'],
329 'SELECT * FROM ' . $this->table_tree .
', ' . $this->table_mail_obj_data,
330 'WHERE ' . $this->table_mail_obj_data .
'.obj_id = ' . $this->table_tree .
'.child',
331 'AND ' . $this->table_tree .
'.depth > %s',
332 'AND ' . $this->table_tree .
'.tree = %s',
333 'ORDER BY ' . $this->table_tree .
'.lft, ' . $this->table_mail_obj_data .
'.title',
335 $res = $this->db->queryF(
337 [
'integer',
'integer'],
340 while ($row = $this->db->fetchAssoc(
$res)) {
342 'title' => (string) $row[
'title'],
343 'type' => (
string) $row[
'm_type'],
344 'obj_id' => (
int) $row[
'child'],
◆ getTrashFolder()
ilMailbox::getTrashFolder |
( |
| ) |
|
Definition at line 125 of file class.ilMailbox.php.
References $res.
127 $res = $this->db->queryF(
128 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
130 [$this->usrId,
'trash']
133 $row = $this->db->fetchAssoc(
$res);
135 return (
int) $row[
'obj_id'];
◆ getUsrId()
◆ isOwnedFolder()
ilMailbox::isOwnedFolder |
( |
int |
$folderId | ) |
|
◆ renameFolder()
ilMailbox::renameFolder |
( |
int |
$folderId, |
|
|
string |
$name |
|
) |
| |
Definition at line 204 of file class.ilMailbox.php.
References folderNameExists().
210 $this->db->manipulateF(
211 'UPDATE ' . $this->table_mail_obj_data .
' SET title = %s WHERE obj_id = %s AND user_id = %s',
212 [
'text',
'integer',
'integer'],
213 [
$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 404 of file class.ilMailbox.php.
406 $this->db->manipulateF(
407 'UPDATE mail SET sender_id = %s, import_name = %s WHERE sender_id = %s',
408 [
'integer',
'text',
'integer'],
409 [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 45 of file class.ilMailbox.php.
◆ $table_tree
string ilMailbox::$table_tree |
|
protected |
◆ $usrId
The documentation for this class was generated from the following file: