12 require_once(
"Services/Mail/classes/class.ilMail.php");
84 $this->user_id = $a_user_id;
86 $this->table_mail_obj_data =
'mail_obj_data';
87 $this->table_tree =
'mail_tree';
91 $this->mtree =
new ilTree($this->user_id);
92 $this->mtree->setTableNames($this->table_tree,$this->table_mail_obj_data);
98 if (is_object($this->lng))
100 $this->lng->loadLanguageModule(
"mail");
102 $this->actions = array(
103 "moveMails" => $this->lng->txt(
"mail_move_to"),
104 "markMailsRead" => $this->lng->txt(
"mail_mark_read"),
105 "markMailsUnread" => $this->lng->txt(
"mail_mark_unread"),
106 "deleteMails" => $this->lng->txt(
"delete"));
110 $this->default_folder = array(
111 "b_inbox" =>
"inbox",
112 "c_trash" =>
"trash",
113 "d_drafts" =>
"drafts",
115 "z_local" =>
"local");
122 public function getInboxFolder()
129 $res = $ilDB->queryF(
' 130 SELECT obj_id FROM '.$this->table_mail_obj_data.
' 133 array(
'integer',
'text'),
134 array($this->user_id,
'inbox')
139 return $row[
'obj_id'];
146 public function getDraftsFolder()
153 $res = $ilDB->queryF(
' 154 SELECT obj_id FROM '.$this->table_mail_obj_data.
' 157 array(
'integer',
'text'),
158 array($this->user_id,
'drafts')
163 return $row[
'obj_id'];
170 public function getTrashFolder()
177 $res = $ilDB->queryf(
' 178 SELECT obj_id FROM '.$this->table_mail_obj_data.
' 181 array(
'integer',
'text'),
182 array($this->user_id,
'trash')
187 return $row[
'obj_id'];
194 public function getSentFolder()
201 $res = $ilDB->queryf(
' 202 SELECT obj_id FROM '.$this->table_mail_obj_data.
' 205 array(
'integer',
'text'),
206 array($this->user_id,
'sent')
211 return $row[
'obj_id'];
220 return $this->mtree->getRootID($this->user_id);
236 if ($folder_data[
"type"] ==
"user_folder" or $folder_data[
"type"] ==
"local")
238 #return array_merge($this->actions,array("add" => $this->lng->txt("mail_add_subfolder"))); 255 include_once
'Services/Mail/classes/class.ilMailGlobalServices.php';
270 $root_id = $ilDB->nextId($this->table_mail_obj_data);
272 $res = $ilDB->manipulateF(
' 273 INSERT INTO '. $this->table_mail_obj_data .
' 279 VALUES( %s, %s, %s, %s)',
280 array(
'integer',
'integer',
'text',
'text'),
281 array($root_id, $this->user_id,
'a_root',
'root'));
283 $this->mtree->addTree($this->user_id,$root_id);
285 foreach ($this->default_folder as $key => $folder)
290 $last_id = $ilDB->nextId($this->table_mail_obj_data);
291 $statement = $ilDB->manipulateF(
' 292 INSERT INTO '. $this->table_mail_obj_data .
' 298 VALUES( %s, %s, %s, %s)',
299 array(
'integer',
'integer',
'text',
'text'),
300 array($last_id,$this->user_id, $key, $folder));
302 $this->mtree->insertNode($last_id,$root_id);
321 $next_id = $ilDB->nextId($this->table_mail_obj_data);
322 $statement = $ilDB->manipulateF(
' 323 INSERT INTO '. $this->table_mail_obj_data .
' 329 VALUES(%s,%s,%s,%s)',
330 array(
'integer',
'integer',
'text',
'text'),
331 array($next_id, $this->user_id, $a_folder_name,
'user_folder'));
334 $this->mtree->insertNode($next_id,$a_parent_id);
354 $statement = $ilDB->manipulateF(
' 355 UPDATE '. $this->table_mail_obj_data .
' 358 array(
'text',
'integer'),
359 array($a_new_folder_name, $a_obj_id));
374 $res = $ilDB->queryf(
' 375 SELECT obj_id FROM '. $this->table_mail_obj_data .
' 378 array(
'integer',
'text'),
379 array($this->user_id, $a_folder_name));
383 return $row->obj_id ? true :
false;
396 SELECT title FROM mail_obj_data 404 if( array_key_exists(
$row[
'title'], $this->default_folder) )
409 include_once(
"Services/Mail/classes/class.ilMail.php");
410 $umail =
new ilMail($this->user_id);
413 $subtree = $this->mtree->getSubtree($this->mtree->getNodeData($a_folder_id));
416 $this->mtree->deleteTree($this->mtree->getNodeData($a_folder_id));
419 foreach($subtree as $node)
422 $mails = $umail->getMailsOfFolder($node[
"obj_id"]);
424 foreach ($mails as $mail)
426 $mail_ids[] = $mail[
"mail_id"];
429 if (is_array($mail_ids))
431 $umail->deleteMails($mail_ids);
435 $statement = $ilDB->manipulateF(
' 436 DELETE FROM '. $this->table_mail_obj_data .
' 439 array($node[
'obj_id']));
450 return $ilDB->getLastInsertId();
462 $res = $ilDB->queryf(
' 463 SELECT * FROM '. $this->table_mail_obj_data .
' 466 array(
'integer',
'integer'),
467 array($this->user_id, $a_obj_id));
472 "obj_id" =>
$row->obj_id,
473 "title" => stripslashes(
$row->title),
474 "type" =>
$row->m_type
486 $res = $ilDB->queryf(
' 487 SELECT * FROM '. $this->table_tree .
' 513 foreach ($this->default_folder as $key => $value)
515 $res = $ilDB->queryf(
' 516 SELECT obj_id,m_type FROM '. $this->table_mail_obj_data .
' 519 array(
'integer',
'text'),
520 array($this->user_id, $key));
524 $user_folder[] = array(
526 "type" =>
$row->m_type,
527 "obj_id" =>
$row->obj_id);
530 $res = $ilDB->queryf(
' 531 SELECT * FROM '. $this->table_tree.
', '. $this->table_mail_obj_data .
' 532 WHERE '. $this->table_mail_obj_data.
'.obj_id = '. $this->table_tree.
'.child 533 AND '. $this->table_tree.
'.depth > %s 534 AND '. $this->table_tree.
'.tree = %s 535 ORDER BY '. $this->table_mail_obj_data.
'.title ',
536 array(
'integer',
'integer'),
537 array(
'2', $this->user_id));
541 $user_folder[] = array(
542 "title" => stripslashes(
$row->title),
543 "type" =>
$row->m_type,
544 "obj_id" =>
$row->child);
557 $this->user_id = $a_user_id;
576 DELETE FROM mail_obj_data WHERE user_id = %s',
577 array(
'integer'), array($this->user_id)
581 DELETE FROM mail_options WHERE user_id = %s',
582 array(
'integer'), array($this->user_id)
586 DELETE FROM mail_saved WHERE user_id = %s',
587 array(
'integer'), array($this->user_id)
591 DELETE FROM mail_tree WHERE tree = %s',
592 array(
'integer'), array($this->user_id)
596 require_once
'Services/Mail/classes/class.ilFileDataMail.php';
598 $fdm->onUserDelete();
602 'DELETE FROM mail WHERE user_id = %s',
604 array($this->user_id)
617 public function updateMailsOfDeletedUser($nameToShow)
628 WHERE sender_id = %s',
629 array(
'integer',
'text',
'integer'),
630 array(0, $nameToShow, $this->user_id));
This class handles all operations on files (attachments) in directory ilias_data/mail.
getRootFolderId()
get Id of the root folder of an user public
const DB_FETCHMODE_OBJECT
addFolder($a_parent_id, $a_folder_name)
add folder
folderNameExists($a_folder_name)
rename folder and check if the name already exists
getFolderData($a_obj_id)
get data of a specific folder
setUserId($a_user_id)
set user_id
Mail Box class Base class for creating and handling mail boxes.
Class Mail this class handles base functions for mail handling.
createDefaultFolder()
create all default folders public
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 folder and check if the name already exists
_countNewMails($a_user_id)
Static method check how many unread mails are in inbox public.
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 given node
getActions($a_mobj_id)
get all possible actions if no mobj_id is given or folder specific actions if mobj_id is given ...
static getNumberOfNewMailsByUserId($usr_id)
Determines the number of new mails for the passed user id and stores this information in a local cach...
__construct($a_user_id=0)
Constructor.
deleteFolder($a_folder_id)
add folder