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");
126 $res = $ilDB->queryf(
'
127 SELECT * FROM '.$this->table_mail_obj_data.
'
130 array(
'integer',
'text'),
131 array($this->user_id,
'inbox'));
146 $res = $ilDB->queryf(
'
147 SELECT * FROM '.$this->table_mail_obj_data.
'
150 array(
'integer',
'text'),
151 array($this->user_id,
'drafts'));
167 $res = $ilDB->queryf(
'
168 SELECT * FROM '.$this->table_mail_obj_data.
'
171 array(
'integer',
'text'),
172 array($this->user_id,
'trash'));
187 $res = $ilDB->queryf(
'
188 SELECT * FROM '.$this->table_mail_obj_data.
'
191 array(
'integer',
'text'),
192 array($this->user_id,
'sent'));
206 return $this->mtree->getRootID($this->user_id);
222 if ($folder_data[
"type"] ==
"user_folder" or $folder_data[
"type"] ==
"local")
224 #return array_merge($this->actions,array("add" => $this->lng->txt("mail_add_subfolder")));
241 include_once
'Services/Mail/classes/class.ilMailGlobalServices.php';
256 $root_id = $ilDB->nextId($this->table_mail_obj_data);
258 $res = $ilDB->manipulateF(
'
259 INSERT INTO '. $this->table_mail_obj_data .
'
265 VALUES( %s, %s, %s, %s)',
266 array(
'integer',
'integer',
'text',
'text'),
267 array($root_id, $this->user_id,
'a_root',
'root'));
269 $this->mtree->addTree($this->user_id,$root_id);
271 foreach ($this->default_folder as $key => $folder)
276 $last_id = $ilDB->nextId($this->table_mail_obj_data);
277 $statement = $ilDB->manipulateF(
'
278 INSERT INTO '. $this->table_mail_obj_data .
'
284 VALUES( %s, %s, %s, %s)',
285 array(
'integer',
'integer',
'text',
'text'),
286 array($last_id,$this->user_id, $key, $folder));
288 $this->mtree->insertNode($last_id,$root_id);
307 $next_id = $ilDB->nextId($this->table_mail_obj_data);
308 $statement = $ilDB->manipulateF(
'
309 INSERT INTO '. $this->table_mail_obj_data .
'
315 VALUES(%s,%s,%s,%s)',
316 array(
'integer',
'integer',
'text',
'text'),
317 array($next_id, $this->user_id, $a_folder_name,
'user_folder'));
320 $this->mtree->insertNode($next_id,$a_parent_id);
340 $statement = $ilDB->manipulateF(
'
341 UPDATE '. $this->table_mail_obj_data .
'
344 array(
'text',
'integer'),
345 array($a_new_folder_name, $a_obj_id));
360 $res = $ilDB->queryf(
'
361 SELECT obj_id FROM '. $this->table_mail_obj_data .
'
364 array(
'integer',
'text'),
365 array($this->user_id, $a_folder_name));
369 return $row->obj_id ?
true :
false;
382 SELECT title FROM mail_obj_data
390 if( array_key_exists(
$row[
'title'], $this->default_folder) )
395 include_once(
"Services/Mail/classes/class.ilMail.php");
396 $umail =
new ilMail($this->user_id);
399 $subtree = $this->mtree->getSubtree($this->mtree->getNodeData($a_folder_id));
402 $this->mtree->deleteTree($this->mtree->getNodeData($a_folder_id));
405 foreach($subtree as $node)
408 $mails = $umail->getMailsOfFolder($node[
"obj_id"]);
410 foreach ($mails as $mail)
412 $mail_ids[] = $mail[
"mail_id"];
415 if (is_array($mail_ids))
417 $umail->deleteMails($mail_ids);
421 $statement = $ilDB->manipulateF(
'
422 DELETE FROM '. $this->table_mail_obj_data .
'
425 array($node[
'obj_id']));
436 return $ilDB->getLastInsertId();
448 $res = $ilDB->queryf(
'
449 SELECT * FROM '. $this->table_mail_obj_data .
'
452 array(
'integer',
'integer'),
453 array($this->user_id, $a_obj_id));
458 "title" => stripslashes(
$row->title),
459 "type" =>
$row->m_type
471 $res = $ilDB->queryf(
'
472 SELECT * FROM '. $this->table_tree .
'
498 foreach ($this->default_folder as $key => $value)
500 $res = $ilDB->queryf(
'
501 SELECT obj_id,m_type FROM '. $this->table_mail_obj_data .
'
504 array(
'integer',
'text'),
505 array($this->user_id, $key));
509 $user_folder[] = array(
511 "type" =>
$row->m_type,
512 "obj_id" =>
$row->obj_id);
515 $res = $ilDB->queryf(
'
516 SELECT * FROM '. $this->table_tree.
', '. $this->table_mail_obj_data .
'
517 WHERE '. $this->table_mail_obj_data.
'.obj_id = '. $this->table_tree.
'.child
518 AND '. $this->table_tree.
'.depth > %s
519 AND '. $this->table_tree.
'.tree = %s
520 ORDER BY '. $this->table_mail_obj_data.
'.title ',
521 array(
'integer',
'integer'),
522 array(
'2', $this->user_id));
526 $user_folder[] = array(
527 "title" => stripslashes(
$row->title),
528 "type" =>
$row->m_type,
529 "obj_id" =>
$row->child);
542 $this->user_id = $a_user_id;
561 DELETE FROM mail_obj_data WHERE user_id = %s',
562 array(
'integer'), array($this->user_id)
566 DELETE FROM mail_options WHERE user_id = %s',
567 array(
'integer'), array($this->user_id)
571 DELETE FROM mail_saved WHERE user_id = %s',
572 array(
'integer'), array($this->user_id)
576 DELETE FROM mail_tree WHERE tree = %s',
577 array(
'integer'), array($this->user_id)
581 require_once
'Services/Mail/classes/class.ilFileDataMail.php';
583 $fdm->onUserDelete();
587 'DELETE FROM mail WHERE user_id = %s',
589 array($this->user_id)
602 public function updateMailsOfDeletedUser($nameToShow)
613 WHERE sender_id = %s',
614 array(
'integer',
'text',
'integer'),
615 array(0, $nameToShow, $this->user_id));