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 12 of file class.ilMailbox.php.
◆ __construct()
ilMailbox::__construct |
( |
|
$a_user_id = 0 | ) |
|
ilMailbox constructor.
- Parameters
-
Definition at line 42 of file class.ilMailbox.php.
References $DIC.
46 $this->lng = $DIC->language();
47 $this->db = $DIC->database();
49 $this->usrId = (int) $a_user_id;
50 $this->table_mail_obj_data =
'mail_obj_data';
51 $this->table_tree =
'mail_tree';
54 $this->mtree =
new ilTree($this->usrId);
55 $this->mtree->setTableNames($this->table_tree, $this->table_mail_obj_data);
61 if (is_object($this->lng)) {
62 $this->lng->loadLanguageModule(
"mail");
65 'moveMails' => $this->lng->txt(
'mail_move_to'),
66 'markMailsRead' => $this->lng->txt(
'mail_mark_read'),
67 'markMailsUnread' => $this->lng->txt(
'mail_mark_unread'),
68 'deleteMails' => $this->lng->txt(
'delete')
73 $this->defaultFolders = [
76 'd_drafts' =>
'drafts',
◆ addFolder()
ilMailbox::addFolder |
( |
int |
$parentFolderId, |
|
|
string |
$name |
|
) |
| |
- Parameters
-
int | $parentFolderId | |
string | $name | |
- Returns
- int
Definition at line 199 of file class.ilMailbox.php.
References folderNameExists().
205 $nextId = (int) $this->db->nextId($this->table_mail_obj_data);
206 $this->db->manipulateF(
207 'INSERT INTO ' . $this->table_mail_obj_data .
' (obj_id, user_id, title, m_type) VALUES(%s,%s,%s,%s)',
208 [
'integer',
'integer',
'text',
'text'],
209 [$nextId, $this->usrId,
$name,
'user_folder']
211 $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 173 of file class.ilMailbox.php.
175 $rootFolderId = (int) $this->db->nextId($this->table_mail_obj_data);
176 $this->db->manipulateF(
177 'INSERT INTO ' . $this->table_mail_obj_data .
' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
178 [
'integer',
'integer',
'text',
'text'],
179 [$rootFolderId, $this->usrId,
'a_root',
'root']
181 $this->mtree->addTree($this->usrId, $rootFolderId);
183 foreach ($this->defaultFolders as $key => $folder) {
184 $last_id = $this->db->nextId($this->table_mail_obj_data);
185 $this->db->manipulateF(
186 'INSERT INTO ' . $this->table_mail_obj_data .
' (obj_id, user_id, title, m_type) VALUES(%s, %s, %s, %s)',
187 [
'integer',
'integer',
'text',
'text'],
188 [$last_id, $this->usrId, $key, $folder]
190 $this->mtree->insertNode($last_id, $rootFolderId);
◆ delete()
Definition at line 397 of file class.ilMailbox.php.
399 $this->db->manipulateF(
400 'DELETE FROM mail_obj_data WHERE user_id = %s',
405 $this->db->manipulateF(
406 'DELETE FROM mail_options WHERE user_id = %s',
411 $this->db->manipulateF(
412 'DELETE FROM mail_saved WHERE user_id = %s',
417 $this->db->manipulateF(
418 'DELETE FROM mail_tree WHERE tree = %s',
425 $fdm->onUserDelete();
428 $this->db->manipulateF(
429 'DELETE FROM mail WHERE user_id = %s',
◆ deleteFolder()
ilMailbox::deleteFolder |
( |
|
$folderId | ) |
|
- Parameters
-
- Returns
- bool
- Exceptions
-
Definition at line 257 of file class.ilMailbox.php.
References $query.
259 $query = $this->db->queryF(
260 'SELECT obj_id, title FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
261 [
'integer',
'integer'],
262 [$folderId, $this->usrId]
264 $row = $this->db->fetchAssoc(
$query);
266 if (!is_array($row) || array_key_exists($row[
'title'], $this->defaultFolders)) {
270 $mailer =
new ilMail($this->usrId);
272 $subtree = $this->mtree->getSubtree($this->mtree->getNodeData($folderId));
273 $this->mtree->deleteTree($this->mtree->getNodeData($folderId));
275 foreach ($subtree as $node) {
276 $nodeId = (int) $node[
'obj_id'];
278 $mails = $mailer->getMailsOfFolder($nodeId);
281 foreach ($mails as $mail) {
282 $mailIds[] = $mail[
'mail_id'];
285 $mailer->deleteMails($mailIds);
287 $this->db->manipulateF(
288 'DELETE FROM ' . $this->table_mail_obj_data .
' WHERE obj_id = %s AND user_id = %s',
289 [
'integer',
'integer'],
290 [$nodeId, $this->usrId]
◆ folderNameExists()
ilMailbox::folderNameExists |
( |
string |
$name | ) |
|
|
protected |
- Parameters
-
- Returns
- bool
Definition at line 240 of file class.ilMailbox.php.
References $res.
Referenced by addFolder(), and renameFolder().
242 $res = $this->db->queryF(
243 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
245 [$this->usrId,
$name]
247 $row = $this->db->fetchAssoc(
$res);
249 return is_array($row) && $row[
'obj_id'] > 0 ? true :
false;
foreach($_POST as $key=> $value) $res
◆ getActions()
ilMailbox::getActions |
( |
|
$folderId | ) |
|
◆ getDraftsFolder()
ilMailbox::getDraftsFolder |
( |
| ) |
|
- Returns
- int
Definition at line 101 of file class.ilMailbox.php.
References $res.
103 $res = $this->db->queryF(
104 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
106 [$this->usrId,
'drafts']
109 $row = $this->db->fetchAssoc(
$res);
111 return (
int) $row[
'obj_id'];
foreach($_POST as $key=> $value) $res
◆ getFolderData()
ilMailbox::getFolderData |
( |
|
$folderId | ) |
|
- Parameters
-
- Returns
- array
Definition at line 301 of file class.ilMailbox.php.
References $res.
Referenced by getActions(), and isOwnedFolder().
303 $res = $this->db->queryF(
304 'SELECT * FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND obj_id = %s',
305 [
'integer',
'integer'],
306 [$this->usrId, $folderId]
308 $row = $this->db->fetchAssoc(
$res);
311 'obj_id' => (int) $row[
'obj_id'],
312 'title' => (
string) $row[
'title'],
313 'type' => (string) $row[
'm_type'],
foreach($_POST as $key=> $value) $res
◆ getInboxFolder()
ilMailbox::getInboxFolder |
( |
| ) |
|
- Returns
- int
Definition at line 85 of file class.ilMailbox.php.
References $res.
87 $res = $this->db->queryF(
88 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
90 [$this->usrId,
'inbox']
93 $row = $this->db->fetchAssoc(
$res);
95 return (
int) $row[
'obj_id'];
foreach($_POST as $key=> $value) $res
◆ getParentFolderId()
ilMailbox::getParentFolderId |
( |
int |
$folderId | ) |
|
- Parameters
-
- Returns
- int
Definition at line 321 of file class.ilMailbox.php.
References $res.
323 $res = $this->db->queryF(
324 'SELECT * FROM ' . $this->table_tree .
' WHERE child = %s AND tree = %s',
325 [
'integer',
'integer'],
326 [$folderId, $this->usrId]
328 $row = $this->db->fetchAssoc(
$res);
330 return is_array($row) ? (int) $row[
'parent'] : 0;
foreach($_POST as $key=> $value) $res
◆ getRootFolderId()
ilMailbox::getRootFolderId |
( |
| ) |
|
|
private |
◆ getSentFolder()
ilMailbox::getSentFolder |
( |
| ) |
|
- Returns
- int
Definition at line 133 of file class.ilMailbox.php.
References $res.
135 $res = $this->db->queryF(
136 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
138 [$this->usrId,
'sent']
141 $row = $this->db->fetchAssoc(
$res);
143 return (
int) $row[
'obj_id'];
foreach($_POST as $key=> $value) $res
◆ getSubFolders()
ilMailbox::getSubFolders |
( |
| ) |
|
- Returns
- array
Definition at line 336 of file class.ilMailbox.php.
References $query, and $res.
340 foreach ($this->defaultFolders as $key => $value) {
341 $res = $this->db->queryF(
342 'SELECT obj_id, m_type FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND title = %s',
346 $row = $this->db->fetchAssoc(
$res);
349 'title' => (string) $key,
350 'type' => (
string) $row[
'm_type'],
351 'obj_id' => (int) $row[
'obj_id'],
356 'SELECT * FROM ' . $this->table_tree .
', ' . $this->table_mail_obj_data,
357 'WHERE ' . $this->table_mail_obj_data .
'.obj_id = ' . $this->table_tree .
'.child',
358 'AND ' . $this->table_tree .
'.depth > %s',
359 'AND ' . $this->table_tree .
'.tree = %s',
360 'ORDER BY ' . $this->table_tree .
'.lft, ' . $this->table_mail_obj_data .
'.title' 362 $res = $this->db->queryF(
364 [
'integer',
'integer'],
367 while ($row = $this->db->fetchAssoc(
$res)) {
369 'title' => (string) $row[
'title'],
370 'type' => (
string) $row[
'm_type'],
371 'obj_id' => (int) $row[
'child'],
foreach($_POST as $key=> $value) $res
◆ getTrashFolder()
ilMailbox::getTrashFolder |
( |
| ) |
|
- Returns
- int
Definition at line 117 of file class.ilMailbox.php.
References $res.
119 $res = $this->db->queryF(
120 'SELECT obj_id FROM ' . $this->table_mail_obj_data .
' WHERE user_id = %s AND m_type = %s',
122 [$this->usrId,
'trash']
125 $row = $this->db->fetchAssoc(
$res);
127 return (
int) $row[
'obj_id'];
foreach($_POST as $key=> $value) $res
◆ getUsrId()
◆ isOwnedFolder()
ilMailbox::isOwnedFolder |
( |
int |
$folderId | ) |
|
◆ renameFolder()
ilMailbox::renameFolder |
( |
int |
$folderId, |
|
|
string |
$name |
|
) |
| |
- Parameters
-
- Returns
- bool
Definition at line 221 of file class.ilMailbox.php.
References folderNameExists().
227 $this->db->manipulateF(
228 'UPDATE ' . $this->table_mail_obj_data .
' SET title = %s WHERE obj_id = %s AND user_id = %s',
229 [
'text',
'integer',
'integer'],
230 [
$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.
- Parameters
-
Definition at line 440 of file class.ilMailbox.php.
442 $this->db->manipulateF(
443 'UPDATE mail SET sender_id = %s, import_name = %s WHERE sender_id = %s',
444 [
'integer',
'text',
'integer'],
445 [0, $nameToShow, $this->usrId]
◆ $actions
◆ $db
◆ $defaultFolders
ilMailbox::$defaultFolders = [] |
|
protected |
◆ $lng
◆ $mtree
◆ $table_mail_obj_data
ilMailbox::$table_mail_obj_data |
|
protected |
◆ $table_tree
◆ $usrId
The documentation for this class was generated from the following file: