Definition at line 24 of file class.ilMailbox.php.
◆ __construct()
ilMailbox::__construct |
( |
protected int |
$usr_id | ) |
|
Definition at line 41 of file class.ilMailbox.php.
References $DIC, and ILIAS\Repository\lng().
49 $this->
lng = $DIC->language();
50 $this->db = $DIC->database();
51 $this->table_mail_obj_data =
'mail_obj_data';
52 $this->table_tree =
'mail_tree';
54 $this->mtree =
new ilTree($this->usr_id);
55 $this->mtree->setTableNames($this->table_tree, $this->table_mail_obj_data);
57 $this->
lng->loadLanguageModule(
'mail');
◆ addFolder()
ilMailbox::addFolder |
( |
int |
$parent_folder_id, |
|
|
string |
$name |
|
) |
| |
Definition at line 151 of file class.ilMailbox.php.
References folderNameExists().
157 $next_id = $this->db->nextId($this->table_mail_obj_data);
158 $this->db->manipulateF(
159 'INSERT INTO ' . $this->table_mail_obj_data .
160 ' (obj_id, user_id, title, m_type) VALUES(%s,%s,%s,%s)',
161 [
'integer',
'integer',
'text',
'text'],
162 [$next_id, $this->usr_id, $name,
'user_folder']
164 $this->mtree->insertNode($next_id, $parent_folder_id);
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 128 of file class.ilMailbox.php.
130 $root_folder_id = $this->db->nextId($this->table_mail_obj_data);
131 $this->db->manipulateF(
132 'INSERT INTO ' . $this->table_mail_obj_data .
133 ' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
134 [
'integer',
'integer',
'text',
'text'],
135 [$root_folder_id, $this->usr_id,
'a_root',
'root']
137 $this->mtree->addTree($this->usr_id, $root_folder_id);
139 foreach ($this->default_folders as $key => $folder) {
140 $last_id = $this->db->nextId($this->table_mail_obj_data);
141 $this->db->manipulateF(
142 'INSERT INTO ' . $this->table_mail_obj_data .
143 ' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
144 [
'integer',
'integer',
'text',
'text'],
145 [$last_id, $this->usr_id, $key, $folder]
147 $this->mtree->insertNode($last_id, $root_folder_id);
◆ delete()
Definition at line 327 of file class.ilMailbox.php.
329 $this->db->manipulateF(
330 'DELETE FROM mail_obj_data WHERE user_id = %s',
335 $this->db->manipulateF(
336 'DELETE FROM mail_options WHERE user_id = %s',
341 $this->db->manipulateF(
342 'DELETE FROM mail_saved WHERE user_id = %s',
347 $this->db->manipulateF(
348 'DELETE FROM mail_tree WHERE tree = %s',
353 $this->db->manipulateF(
354 'DELETE FROM mail_auto_responder WHERE sender_id = %s OR receiver_id = %s',
355 [
'integer',
'integer'],
356 [$this->usr_id, $this->usr_id]
362 $fdm->onUserDelete();
365 $this->db->manipulateF(
366 'DELETE FROM mail WHERE user_id = %s',
◆ deleteFolder()
ilMailbox::deleteFolder |
( |
int |
$folder_id | ) |
|
- Exceptions
-
Definition at line 199 of file class.ilMailbox.php.
References ILIAS\Repository\int().
201 $query = $this->db->queryF(
202 'SELECT obj_id, title FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
203 [
'integer',
'integer'],
204 [$folder_id, $this->usr_id]
206 $row = $this->db->fetchAssoc($query);
208 if (!is_array($row) || array_key_exists($row[
'title'], $this->default_folders)) {
212 $mailer =
new ilMail($this->usr_id);
214 $subtree = $this->mtree->getSubTree($this->mtree->getNodeData($folder_id));
215 $this->mtree->deleteTree($this->mtree->getNodeData($folder_id));
217 foreach ($subtree as $node) {
218 $node_id = (
int) $node[
'obj_id'];
220 $mails = $mailer->getMailsOfFolder($node_id);
223 foreach ($mails as $mail) {
224 $mail_ids[] = (
int) $mail[
'mail_id'];
227 $mailer->deleteMails($mail_ids);
229 $this->db->manipulateF(
230 'DELETE FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
231 [
'integer',
'integer'],
232 [$node_id, $this->usr_id]
◆ folderNameExists()
ilMailbox::folderNameExists |
( |
string |
$name | ) |
|
|
protected |
Definition at line 184 of file class.ilMailbox.php.
References $res.
Referenced by addFolder(), and renameFolder().
186 $res = $this->db->queryF(
187 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
189 [$this->usr_id, $name]
191 $row = $this->db->fetchAssoc(
$res);
193 return is_array($row) && $row[
'obj_id'] > 0;
◆ getDraftsFolder()
ilMailbox::getDraftsFolder |
( |
| ) |
|
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->usr_id,
'drafts']
94 $row = $this->db->fetchAssoc(
$res);
96 return (
int) $row[
'obj_id'];
◆ getFolderData()
ilMailbox::getFolderData |
( |
int |
$folder_id | ) |
|
Definition at line 239 of file class.ilMailbox.php.
References $res, getFolderDataFromRow(), and null.
Referenced by isOwnedFolder().
241 $res = $this->db->queryF(
242 'SELECT * FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND obj_id = %s',
243 [
'integer',
'integer'],
244 [$this->usr_id, $folder_id]
246 $row = $this->db->fetchAssoc(
$res);
248 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 73 of file class.ilMailbox.php.
References $res.
75 $res = $this->db->queryF(
76 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
78 [$this->usr_id,
'inbox']
81 $row = $this->db->fetchAssoc(
$res);
83 return (
int) $row[
'obj_id'];
◆ getParentFolderId()
ilMailbox::getParentFolderId |
( |
int |
$folder_id | ) |
|
Definition at line 267 of file class.ilMailbox.php.
References $res, and ILIAS\Repository\int().
269 $res = $this->db->queryF(
270 'SELECT * FROM ' . $this->table_tree .
' WHERE child = %s AND tree = %s',
271 [
'integer',
'integer'],
272 [$folder_id, $this->usr_id]
274 $row = $this->db->fetchAssoc(
$res);
276 return is_array($row) ? (
int) $row[
'parent'] : 0;
◆ getRooFolder()
ilMailbox::getRooFolder |
( |
| ) |
|
Definition at line 60 of file class.ilMailbox.php.
References $res.
62 $res = $this->db->queryF(
63 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
65 [$this->usr_id,
'root']
68 $row = $this->db->fetchAssoc(
$res);
70 return (
int) $row[
'obj_id'];
◆ getSentFolder()
ilMailbox::getSentFolder |
( |
| ) |
|
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->usr_id,
'sent']
120 $row = $this->db->fetchAssoc(
$res);
122 return (
int) $row[
'obj_id'];
◆ getSubFolders()
ilMailbox::getSubFolders |
( |
| ) |
|
- Returns
- list<MailFolderData>
Definition at line 282 of file class.ilMailbox.php.
References $res, and getFolderDataFromRow().
286 foreach (array_keys($this->default_folders) as $key) {
287 $res = $this->db->queryF(
288 'SELECT * FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
290 [$this->usr_id, $key]
292 $row = $this->db->fetchAssoc(
$res);
293 if (is_array($row)) {
298 $query = implode(
' ', [
299 'SELECT * FROM ' . $this->table_tree .
', ' . $this->table_mail_obj_data,
300 'WHERE ' . $this->table_mail_obj_data .
'.obj_id = ' . $this->table_tree .
'.child',
301 'AND ' . $this->table_tree .
'.depth > %s',
302 'AND ' . $this->table_tree .
'.tree = %s',
303 'ORDER BY ' . $this->table_tree .
'.lft, ' . $this->table_mail_obj_data .
'.title',
305 $res = $this->db->queryF(
307 [
'integer',
'integer'],
310 while ($row = $this->db->fetchAssoc(
$res)) {
314 return $user_folders;
getFolderDataFromRow(array $row)
◆ getTrashFolder()
ilMailbox::getTrashFolder |
( |
| ) |
|
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->usr_id,
'trash']
107 $row = $this->db->fetchAssoc(
$res);
109 return (
int) $row[
'obj_id'];
◆ getUsrId()
◆ isOwnedFolder()
ilMailbox::isOwnedFolder |
( |
int |
$folder_id | ) |
|
◆ renameFolder()
ilMailbox::renameFolder |
( |
int |
$folder_id, |
|
|
string |
$name |
|
) |
| |
Definition at line 169 of file class.ilMailbox.php.
References folderNameExists().
175 $this->db->manipulateF(
176 'UPDATE ' . $this->table_mail_obj_data .
' SET title = %s WHERE obj_id = %s AND user_id = %s',
177 [
'text',
'integer',
'integer'],
178 [$name, $folder_id, $this->usr_id]
folderNameExists(string $name)
◆ setUsrId()
ilMailbox::setUsrId |
( |
int |
$usr_id | ) |
|
◆ updateMailsOfDeletedUser()
ilMailbox::updateMailsOfDeletedUser |
( |
string |
$name_to_show | ) |
|
Update existing mails.
Set sender id to 0 and import name to login name. This is only necessary for deleted users.
Definition at line 376 of file class.ilMailbox.php.
378 $this->db->manipulateF(
379 'UPDATE mail SET sender_id = %s, import_name = %s WHERE sender_id = %s',
380 [
'integer',
'text',
'integer'],
381 [0, $name_to_show, $this->usr_id]
◆ $db
◆ $default_folders
array ilMailbox::$default_folders |
|
private |
◆ $lng
◆ $mtree
readonly ilTree ilMailbox::$mtree |
|
private |
◆ $table_mail_obj_data
array readonly string ilMailbox::$table_mail_obj_data |
|
private |
Initial value:=> 'trash',
'd_drafts' => 'drafts',
'e_sent' => 'sent',
'z_local' => 'local',
]
Definition at line 33 of file class.ilMailbox.php.
◆ $table_tree
readonly string ilMailbox::$table_tree |
|
private |
The documentation for this class was generated from the following file: