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");
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'];
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'];
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'];
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'];
190 return $this->mtree->getRootID($this->user_id);
205 if ($folder_data[
"type"] ==
"user_folder" or $folder_data[
"type"] ==
"local") {
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);
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);
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)
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;
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)
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']
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;
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']
474 $this->user_id = $a_user_id;
491 public function delete()
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)
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)
561 return $folderData[
'obj_id'] == $folderId;
updateMailsOfDeletedUser($nameToShow)
Update existing mails.
getSentFolder()
get Id of the sent folder of an user
getRootFolderId()
get Id of the root folder of an user
addFolder($a_parent_id, $a_folder_name)
Adds a new mail folder with the passed name under the given parent folder.
folderNameExists($a_folder_name)
Checks whether or not the passed folder name exists in the context of the folder owner.
getFolderData($a_obj_id)
Fetches the data of a specific folder.
foreach($_POST as $key=> $value) $res
getTrashFolder()
get Id of the trash folder of an user
Mail Box class Base class for creating and handling mail boxes.
createDefaultFolder()
Creates all default folders for a user.
getParentFolderId($a_obj_id)
Get id of parent folder.
redirection script todo: (a better solution should control the processing via a xml file) ...
renameFolder($a_obj_id, $a_new_folder_name)
Rename a folder and check if the name already exists.
getInboxFolder()
get Id of the inbox folder of an user
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getSubFolders($a_folder=0, $a_folder_parent=0)
Get all folders under a given folder/node id.
getActions($a_mobj_id)
get all possible actions if no mobj_id is given or folder specific actions if mobj_id is given ...
__construct($a_user_id=0)
ilMailbox constructor.
getDraftsFolder()
get Id of the inbox folder of an user
deleteFolder($a_folder_id)
isOwnedFolder(int $folderId)