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 32 of file class.ilMailbox.php.
◆ __construct()
ilMailbox::__construct |
( |
protected int |
$usrId | ) |
|
Definition at line 49 of file class.ilMailbox.php.
References $DIC, and ILIAS\Repository\lng().
57 $this->
lng = $DIC->language();
58 $this->db = $DIC->database();
59 $this->table_mail_obj_data =
'mail_obj_data';
60 $this->table_tree =
'mail_tree';
62 $this->mtree =
new ilTree($this->usrId);
63 $this->mtree->setTableNames($this->table_tree, $this->table_mail_obj_data);
65 $this->
lng->loadLanguageModule(
'mail');
◆ addFolder()
ilMailbox::addFolder |
( |
int |
$parentFolderId, |
|
|
string |
$name |
|
) |
| |
Definition at line 159 of file class.ilMailbox.php.
References folderNameExists().
165 $nextId = $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 [$nextId, $this->usrId, $name,
'user_folder']
172 $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 136 of file class.ilMailbox.php.
138 $rootFolderId = $this->db->nextId($this->table_mail_obj_data);
139 $this->db->manipulateF(
140 'INSERT INTO ' . $this->table_mail_obj_data .
141 ' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
142 [
'integer',
'integer',
'text',
'text'],
143 [$rootFolderId, $this->usrId,
'a_root',
'root']
145 $this->mtree->addTree($this->usrId, $rootFolderId);
147 foreach ($this->defaultFolders as $key => $folder) {
148 $last_id = $this->db->nextId($this->table_mail_obj_data);
149 $this->db->manipulateF(
150 'INSERT INTO ' . $this->table_mail_obj_data .
151 ' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
152 [
'integer',
'integer',
'text',
'text'],
153 [$last_id, $this->usrId, $key, $folder]
155 $this->mtree->insertNode($last_id, $rootFolderId);
◆ delete()
Definition at line 335 of file class.ilMailbox.php.
337 $this->db->manipulateF(
338 'DELETE FROM mail_obj_data WHERE user_id = %s',
343 $this->db->manipulateF(
344 'DELETE FROM mail_options WHERE user_id = %s',
349 $this->db->manipulateF(
350 'DELETE FROM mail_saved WHERE user_id = %s',
355 $this->db->manipulateF(
356 'DELETE FROM mail_tree WHERE tree = %s',
361 $this->db->manipulateF(
362 'DELETE FROM mail_auto_responder WHERE sender_id = %s OR receiver_id = %s',
363 [
'integer',
'integer'],
364 [$this->usrId, $this->usrId]
370 $fdm->onUserDelete();
373 $this->db->manipulateF(
374 '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 207 of file class.ilMailbox.php.
References ILIAS\Repository\int().
209 $query = $this->db->queryF(
210 'SELECT obj_id, title FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
211 [
'integer',
'integer'],
212 [$folderId, $this->usrId]
214 $row = $this->db->fetchAssoc($query);
216 if (!is_array($row) || array_key_exists($row[
'title'], $this->defaultFolders)) {
220 $mailer =
new ilMail($this->usrId);
222 $subtree = $this->mtree->getSubTree($this->mtree->getNodeData($folderId));
223 $this->mtree->deleteTree($this->mtree->getNodeData($folderId));
225 foreach ($subtree as $node) {
226 $nodeId = (
int) $node[
'obj_id'];
228 $mails = $mailer->getMailsOfFolder($nodeId);
231 foreach ($mails as $mail) {
232 $mailIds[] = (
int) $mail[
'mail_id'];
235 $mailer->deleteMails($mailIds);
237 $this->db->manipulateF(
238 'DELETE FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
239 [
'integer',
'integer'],
240 [$nodeId, $this->usrId]
◆ folderNameExists()
ilMailbox::folderNameExists |
( |
string |
$name | ) |
|
|
protected |
Definition at line 192 of file class.ilMailbox.php.
References $res.
Referenced by addFolder(), and renameFolder().
194 $res = $this->db->queryF(
195 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
197 [$this->usrId, $name]
199 $row = $this->db->fetchAssoc(
$res);
201 return is_array($row) && $row[
'obj_id'] > 0;
◆ getDraftsFolder()
ilMailbox::getDraftsFolder |
( |
| ) |
|
Definition at line 94 of file class.ilMailbox.php.
References $res.
96 $res = $this->db->queryF(
97 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
99 [$this->usrId,
'drafts']
102 $row = $this->db->fetchAssoc(
$res);
104 return (
int) $row[
'obj_id'];
◆ getFolderData()
ilMailbox::getFolderData |
( |
int |
$folderId | ) |
|
Definition at line 247 of file class.ilMailbox.php.
References $res, getFolderDataFromRow(), and null.
Referenced by isOwnedFolder().
249 $res = $this->db->queryF(
250 'SELECT * FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND obj_id = %s',
251 [
'integer',
'integer'],
252 [$this->usrId, $folderId]
254 $row = $this->db->fetchAssoc(
$res);
256 if (is_array($row)) {
getFolderDataFromRow(array $row)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
◆ getFolderDataFromRow()
ilMailbox::getFolderDataFromRow |
( |
array |
$row | ) |
|
|
private |
◆ getInboxFolder()
ilMailbox::getInboxFolder |
( |
| ) |
|
Definition at line 81 of file class.ilMailbox.php.
References $res.
83 $res = $this->db->queryF(
84 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
86 [$this->usrId,
'inbox']
89 $row = $this->db->fetchAssoc(
$res);
91 return (
int) $row[
'obj_id'];
◆ getParentFolderId()
ilMailbox::getParentFolderId |
( |
int |
$folderId | ) |
|
Definition at line 275 of file class.ilMailbox.php.
References $res, and ILIAS\Repository\int().
277 $res = $this->db->queryF(
278 'SELECT * FROM ' . $this->table_tree .
' WHERE child = %s AND tree = %s',
279 [
'integer',
'integer'],
280 [$folderId, $this->usrId]
282 $row = $this->db->fetchAssoc(
$res);
284 return is_array($row) ? (
int) $row[
'parent'] : 0;
◆ getRooFolder()
ilMailbox::getRooFolder |
( |
| ) |
|
Definition at line 68 of file class.ilMailbox.php.
References $res.
70 $res = $this->db->queryF(
71 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
73 [$this->usrId,
'root']
76 $row = $this->db->fetchAssoc(
$res);
78 return (
int) $row[
'obj_id'];
◆ getSentFolder()
ilMailbox::getSentFolder |
( |
| ) |
|
Definition at line 120 of file class.ilMailbox.php.
References $res.
122 $res = $this->db->queryF(
123 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
125 [$this->usrId,
'sent']
128 $row = $this->db->fetchAssoc(
$res);
130 return (
int) $row[
'obj_id'];
◆ getSubFolders()
ilMailbox::getSubFolders |
( |
| ) |
|
- Returns
- MailFolderData[]
Definition at line 290 of file class.ilMailbox.php.
References $res, and getFolderDataFromRow().
294 foreach (array_keys($this->defaultFolders) as $key) {
295 $res = $this->db->queryF(
296 'SELECT * FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
300 $row = $this->db->fetchAssoc(
$res);
301 if (is_array($row)) {
306 $query = implode(
' ', [
307 'SELECT * FROM ' . $this->table_tree .
', ' . $this->table_mail_obj_data,
308 'WHERE ' . $this->table_mail_obj_data .
'.obj_id = ' . $this->table_tree .
'.child',
309 'AND ' . $this->table_tree .
'.depth > %s',
310 'AND ' . $this->table_tree .
'.tree = %s',
311 'ORDER BY ' . $this->table_tree .
'.lft, ' . $this->table_mail_obj_data .
'.title',
313 $res = $this->db->queryF(
315 [
'integer',
'integer'],
318 while ($row = $this->db->fetchAssoc(
$res)) {
getFolderDataFromRow(array $row)
◆ getTrashFolder()
ilMailbox::getTrashFolder |
( |
| ) |
|
Definition at line 107 of file class.ilMailbox.php.
References $res.
109 $res = $this->db->queryF(
110 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
112 [$this->usrId,
'trash']
115 $row = $this->db->fetchAssoc(
$res);
117 return (
int) $row[
'obj_id'];
◆ getUsrId()
◆ isOwnedFolder()
ilMailbox::isOwnedFolder |
( |
int |
$folderId | ) |
|
◆ renameFolder()
ilMailbox::renameFolder |
( |
int |
$folderId, |
|
|
string |
$name |
|
) |
| |
Definition at line 177 of file class.ilMailbox.php.
References folderNameExists().
183 $this->db->manipulateF(
184 'UPDATE ' . $this->table_mail_obj_data .
' SET title = %s WHERE obj_id = %s AND user_id = %s',
185 [
'text',
'integer',
'integer'],
186 [$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 384 of file class.ilMailbox.php.
386 $this->db->manipulateF(
387 'UPDATE mail SET sender_id = %s, import_name = %s WHERE sender_id = %s',
388 [
'integer',
'text',
'integer'],
389 [0, $nameToShow, $this->usrId]
◆ $db
◆ $defaultFolders
array ilMailbox::$defaultFolders |
|
private |
◆ $lng
◆ $mtree
◆ $table_mail_obj_data
array string ilMailbox::$table_mail_obj_data |
|
private |
Initial value:=> 'trash',
'd_drafts' => 'drafts',
'e_sent' => 'sent',
'z_local' => 'local',
]
Definition at line 41 of file class.ilMailbox.php.
◆ $table_tree
string ilMailbox::$table_tree |
|
private |
The documentation for this class was generated from the following file: