Mail Box class Base class for creating and handling mail boxes.
More...
|
| folderNameExists ($a_folder_name) |
| Checks whether or not the passed folder name exists in the context of the folder owner. 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 13 of file class.ilMailbox.php.
◆ __construct()
ilMailbox::__construct |
( |
|
$a_user_id = 0 | ) |
|
ilMailbox constructor.
- Parameters
-
Definition at line 69 of file class.ilMailbox.php.
References $DIC.
73 $this->
ilias = $DIC[
'ilias'];
74 $this->lng = $DIC->language();
75 $this->db = $DIC->database();
77 $this->user_id = $a_user_id;
79 $this->table_mail_obj_data =
'mail_obj_data';
80 $this->table_tree =
'mail_tree';
83 $this->mtree =
new ilTree($this->user_id);
84 $this->mtree->setTableNames($this->table_tree, $this->table_mail_obj_data);
90 if (is_object($this->lng)) {
91 $this->lng->loadLanguageModule(
"mail");
93 $this->actions = array(
94 "moveMails" => $this->lng->txt(
"mail_move_to"),
95 "markMailsRead" => $this->lng->txt(
"mail_mark_read"),
96 "markMailsUnread" => $this->lng->txt(
"mail_mark_unread"),
97 "deleteMails" => $this->lng->txt(
"delete"));
101 $this->default_folder = array(
102 "b_inbox" =>
"inbox",
103 "c_trash" =>
"trash",
104 "d_drafts" =>
"drafts",
106 "z_local" =>
"local");
redirection script todo: (a better solution should control the processing via a xml file) ...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
◆ addFolder()
ilMailbox::addFolder |
( |
|
$a_parent_id, |
|
|
|
$a_folder_name |
|
) |
| |
Adds a new mail folder with the passed name under the given parent folder.
- Parameters
-
integer | $a_parent_id | Id of parent folder |
string | $a_folder_name | Name of tje folder to be created |
- Returns
- integer The new id of the created folder
Definition at line 257 of file class.ilMailbox.php.
References folderNameExists().
263 $next_id = $this->db->nextId($this->table_mail_obj_data);
264 $this->db->manipulateF(
266 INSERT INTO ' . $this->table_mail_obj_data .
' 272 VALUES(%s,%s,%s,%s)',
273 array(
'integer',
'integer',
'text',
'text'),
274 array($next_id, $this->user_id, $a_folder_name,
'user_folder')
276 $this->mtree->insertNode($next_id, $a_parent_id);
folderNameExists($a_folder_name)
Checks whether or not the passed folder name exists in the context of the folder owner.
◆ 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 216 of file class.ilMailbox.php.
References $key.
218 $root_id = $this->db->nextId($this->table_mail_obj_data);
219 $this->db->manipulateF(
221 INSERT INTO ' . $this->table_mail_obj_data .
' 227 VALUES(%s, %s, %s, %s)',
228 array(
'integer',
'integer',
'text',
'text'),
229 array($root_id, $this->user_id,
'a_root',
'root')
231 $this->mtree->addTree($this->user_id, $root_id);
233 foreach ($this->default_folder as
$key => $folder) {
234 $last_id = $this->db->nextId($this->table_mail_obj_data);
235 $this->db->manipulateF(
237 INSERT INTO ' . $this->table_mail_obj_data .
' 243 VALUES(%s, %s, %s, %s)',
244 array(
'integer',
'integer',
'text',
'text'),
245 array($last_id, $this->user_id,
$key, $folder)
247 $this->mtree->insertNode($last_id, $root_id);
◆ delete()
deletes user's mailbox and all db entries related to mailbox TODO: stefan, bitte nochmal kontrollieren, ob auch wirklich alles gel�scht wird.
Vielleicht hab ich was �bersehen. - shofmann, 15.7.03
- Returns
- boolean true on successful deletion
Definition at line 491 of file class.ilMailbox.php.
493 $this->db->manipulateF(
495 DELETE FROM mail_obj_data WHERE user_id = %s',
497 array($this->user_id)
500 $this->db->manipulateF(
502 DELETE FROM mail_options WHERE user_id = %s',
504 array($this->user_id)
507 $this->db->manipulateF(
509 DELETE FROM mail_saved WHERE user_id = %s',
511 array($this->user_id)
514 $this->db->manipulateF(
516 DELETE FROM mail_tree WHERE tree = %s',
518 array($this->user_id)
522 require_once
'Services/Mail/classes/class.ilFileDataMail.php';
524 $fdm->onUserDelete();
527 $this->db->manipulateF(
528 'DELETE FROM mail WHERE user_id = %s',
530 array($this->user_id)
◆ deleteFolder()
ilMailbox::deleteFolder |
( |
|
$a_folder_id | ) |
|
- Parameters
-
- Returns
- bool
- Exceptions
-
Definition at line 330 of file class.ilMailbox.php.
References $query, and $row.
332 $query = $this->db->queryf(
334 SELECT obj_id, title FROM mail_obj_data 335 WHERE obj_id = %s AND user_id = %s',
336 array(
'integer',
'integer'),
337 array($a_folder_id, $this->user_id)
341 if (!is_array(
$row) || array_key_exists(
$row[
'title'], $this->default_folder)) {
345 require_once
'Services/Mail/classes/class.ilMail.php';
346 $umail =
new ilMail($this->user_id);
348 $subtree = $this->mtree->getSubtree($this->mtree->getNodeData($a_folder_id));
349 $this->mtree->deleteTree($this->mtree->getNodeData($a_folder_id));
351 foreach ($subtree as $node) {
352 $mails = $umail->getMailsOfFolder($node[
"obj_id"]);
354 foreach ($mails as $mail) {
355 $mail_ids[] = $mail[
"mail_id"];
358 $umail->deleteMails($mail_ids);
360 $this->db->manipulateF(
362 DELETE FROM ' . $this->table_mail_obj_data .
' 363 WHERE obj_id = %s AND user_id = %s',
364 array(
'integer',
'integer'),
365 array($node[
'obj_id'], $this->user_id)
◆ folderNameExists()
ilMailbox::folderNameExists |
( |
|
$a_folder_name | ) |
|
|
protected |
Checks whether or not the passed folder name exists in the context of the folder owner.
- Parameters
-
string | $a_folder_name | The new name of folder |
- Returns
- boolean
Definition at line 310 of file class.ilMailbox.php.
References $res, and $row.
Referenced by addFolder(), and renameFolder().
312 $res = $this->db->queryF(
314 SELECT obj_id FROM ' . $this->table_mail_obj_data .
' 317 array(
'integer',
'text'),
318 array($this->user_id, $a_folder_name)
322 return is_array(
$row) &&
$row[
'obj_id'] > 0 ? true :
false;
foreach($_POST as $key=> $value) $res
◆ getActions()
ilMailbox::getActions |
( |
|
$a_mobj_id | ) |
|
get all possible actions if no mobj_id is given or folder specific actions if mobj_id is given
- Parameters
-
- Returns
- array possible actions
Definition at line 200 of file class.ilMailbox.php.
References $actions, and getFolderData().
205 if ($folder_data[
"type"] ==
"user_folder" or $folder_data[
"type"] ==
"local") {
getFolderData($a_obj_id)
Fetches the data of a specific folder.
◆ getDraftsFolder()
ilMailbox::getDraftsFolder |
( |
| ) |
|
get Id of the inbox folder of an user
Definition at line 131 of file class.ilMailbox.php.
References $res, and $row.
133 $res = $this->db->queryF(
135 SELECT obj_id FROM ' . $this->table_mail_obj_data .
' 138 array(
'integer',
'text'),
139 array($this->user_id,
'drafts')
144 return $row[
'obj_id'];
foreach($_POST as $key=> $value) $res
◆ getFolderData()
ilMailbox::getFolderData |
( |
|
$a_obj_id | ) |
|
Fetches the data of a specific folder.
- Parameters
-
- Returns
- array
Definition at line 377 of file class.ilMailbox.php.
References $res, and $row.
Referenced by getActions(), and isOwnedFolder().
379 $res = $this->db->queryF(
381 SELECT * FROM ' . $this->table_mail_obj_data .
' 384 array(
'integer',
'integer'),
385 array($this->user_id, $a_obj_id)
390 'obj_id' =>
$row[
'obj_id'],
391 'title' =>
$row[
'title'],
392 'type' =>
$row[
'm_type']
foreach($_POST as $key=> $value) $res
◆ getInboxFolder()
ilMailbox::getInboxFolder |
( |
| ) |
|
get Id of the inbox folder of an user
Definition at line 112 of file class.ilMailbox.php.
References $res, and $row.
114 $res = $this->db->queryF(
116 SELECT obj_id FROM ' . $this->table_mail_obj_data .
' 119 array(
'integer',
'text'),
120 array($this->user_id,
'inbox')
125 return $row[
'obj_id'];
foreach($_POST as $key=> $value) $res
◆ getParentFolderId()
ilMailbox::getParentFolderId |
( |
|
$a_obj_id | ) |
|
Get id of parent folder.
- Parameters
-
- Returns
- int
Definition at line 401 of file class.ilMailbox.php.
References $res, and $row.
403 $res = $this->db->queryF(
405 SELECT * FROM ' . $this->table_tree .
' 406 WHERE child = %s AND tree = %s',
407 array(
'integer',
'integer'),
408 array($a_obj_id, $this->user_id)
412 return is_array(
$row) ?
$row[
'parent'] : 0;
foreach($_POST as $key=> $value) $res
◆ getRootFolderId()
ilMailbox::getRootFolderId |
( |
| ) |
|
◆ getSentFolder()
ilMailbox::getSentFolder |
( |
| ) |
|
get Id of the sent folder of an user
Definition at line 169 of file class.ilMailbox.php.
References $res, and $row.
171 $res = $this->db->queryf(
173 SELECT obj_id FROM ' . $this->table_mail_obj_data .
' 176 array(
'integer',
'text'),
177 array($this->user_id,
'sent')
182 return $row[
'obj_id'];
foreach($_POST as $key=> $value) $res
◆ getSubFolders()
ilMailbox::getSubFolders |
( |
|
$a_folder = 0 , |
|
|
|
$a_folder_parent = 0 |
|
) |
| |
Get all folders under a given folder/node id.
- Parameters
-
int | $a_folder | |
int | $a_folder_parent | |
- Returns
- array
Definition at line 421 of file class.ilMailbox.php.
References $key, $res, $row, and getRootFolderId().
427 $user_folder = array();
429 foreach ($this->default_folder as
$key => $value) {
430 $res = $this->db->queryF(
432 SELECT obj_id, m_type 433 FROM ' . $this->table_mail_obj_data .
' 436 array(
'integer',
'text'),
437 array($this->user_id,
$key)
441 $user_folder[] = array(
443 'type' =>
$row[
'm_type'],
444 'obj_id' =>
$row[
'obj_id']
448 $res = $this->db->queryF(
450 SELECT * FROM ' . $this->table_tree .
', ' . $this->table_mail_obj_data .
' 451 WHERE ' . $this->table_mail_obj_data .
'.obj_id = ' . $this->table_tree .
'.child 452 AND ' . $this->table_tree .
'.depth > %s 453 AND ' . $this->table_tree .
'.tree = %s 454 ORDER BY ' . $this->table_tree .
'.lft, ' . $this->table_mail_obj_data .
'.title ',
455 array(
'integer',
'integer'),
456 array(2, $this->user_id)
458 while (
$row = $this->db->fetchAssoc(
$res)) {
459 $user_folder[] = array(
460 'title' =>
$row[
'title'],
461 'type' =>
$row[
'm_type'],
462 'obj_id' =>
$row[
'child']
getRootFolderId()
get Id of the root folder of an user
foreach($_POST as $key=> $value) $res
◆ getTrashFolder()
ilMailbox::getTrashFolder |
( |
| ) |
|
get Id of the trash folder of an user
Definition at line 150 of file class.ilMailbox.php.
References $res, and $row.
152 $res = $this->db->queryf(
154 SELECT obj_id FROM ' . $this->table_mail_obj_data .
' 157 array(
'integer',
'text'),
158 array($this->user_id,
'trash')
163 return $row[
'obj_id'];
foreach($_POST as $key=> $value) $res
◆ getUserId()
◆ isOwnedFolder()
ilMailbox::isOwnedFolder |
( |
int |
$folderId | ) |
|
- Parameters
-
- Returns
- bool
Definition at line 557 of file class.ilMailbox.php.
References getFolderData().
561 return $folderData[
'obj_id'] == $folderId;
getFolderData($a_obj_id)
Fetches the data of a specific folder.
◆ renameFolder()
ilMailbox::renameFolder |
( |
|
$a_obj_id, |
|
|
|
$a_new_folder_name |
|
) |
| |
Rename a folder and check if the name already exists.
- Parameters
-
integer | $a_obj_id | The id of the folder to be renamed |
string | $a_new_folder_name | The new name of the folder |
- Returns
- boolean
Definition at line 287 of file class.ilMailbox.php.
References folderNameExists().
293 $this->db->manipulateF(
295 UPDATE ' . $this->table_mail_obj_data .
' 297 WHERE obj_id = %s AND user_id = %s',
298 array(
'text',
'integer',
'integer'),
299 array($a_new_folder_name, $a_obj_id, $this->user_id)
folderNameExists($a_folder_name)
Checks whether or not the passed folder name exists in the context of the folder owner.
◆ setUserId()
ilMailbox::setUserId |
( |
|
$a_user_id | ) |
|
◆ updateMailsOfDeletedUser()
ilMailbox::updateMailsOfDeletedUser |
( |
|
$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 541 of file class.ilMailbox.php.
543 $this->db->manipulateF(
546 SET sender_id = %s, import_name = %s 547 WHERE sender_id = %s',
548 array(
'integer',
'text',
'integer'),
549 array(0, $nameToShow, $this->user_id)
◆ $actions
ilMailbox::$actions = array() |
|
protected |
◆ $db
◆ $default_folder
ilMailbox::$default_folder = array() |
|
protected |
◆ $ilias
◆ $lng
◆ $mtree
◆ $table_mail_obj_data
ilMailbox::$table_mail_obj_data |
|
protected |
◆ $table_tree
◆ $user_id
The documentation for this class was generated from the following file: