33 require_once(
"Services/Mail/classes/class.ilMail.php");
106 $this->user_id = $a_user_id;
108 $this->table_mail_obj_data =
'mail_obj_data';
109 $this->table_tree =
'mail_tree';
113 $this->mtree =
new ilTree($this->user_id);
114 $this->mtree->setTableNames($this->table_tree,$this->table_mail_obj_data);
120 if (is_object($this->lng))
122 $this->lng->loadLanguageModule(
"mail");
124 $this->actions = array(
125 "moveMails" => $this->lng->txt(
"mail_move_to"),
126 "markMailsRead" => $this->lng->txt(
"mail_mark_read"),
127 "markMailsUnread" => $this->lng->txt(
"mail_mark_unread"),
128 "deleteMails" => $this->lng->txt(
"delete"));
132 $this->default_folder = array(
133 "b_inbox" =>
"inbox",
134 "c_trash" =>
"trash",
135 "d_drafts" =>
"drafts",
137 "z_local" =>
"local");
148 $res = $ilDB->queryf(
'
149 SELECT * FROM '.$this->table_mail_obj_data.
'
152 array(
'integer',
'text'),
153 array($this->user_id,
'inbox'));
168 $res = $ilDB->queryf(
'
169 SELECT * FROM '.$this->table_mail_obj_data.
'
172 array(
'integer',
'text'),
173 array($this->user_id,
'drafts'));
189 $res = $ilDB->queryf(
'
190 SELECT * FROM '.$this->table_mail_obj_data.
'
193 array(
'integer',
'text'),
194 array($this->user_id,
'trash'));
209 $res = $ilDB->queryf(
'
210 SELECT * FROM '.$this->table_mail_obj_data.
'
213 array(
'integer',
'text'),
214 array($this->user_id,
'sent'));
228 return $this->mtree->getRootID($this->user_id);
244 if ($folder_data[
"type"] ==
"user_folder" or $folder_data[
"type"] ==
"local")
246 #return array_merge($this->actions,array("add" => $this->lng->txt("mail_add_subfolder")));
263 include_once
'Services/Mail/classes/class.ilMailGlobalServices.php';
278 $root_id = $ilDB->nextId($this->table_mail_obj_data);
280 $res = $ilDB->manipulateF(
'
281 INSERT INTO '. $this->table_mail_obj_data .
'
287 VALUES( %s, %s, %s, %s)',
288 array(
'integer',
'integer',
'text',
'text'),
289 array($root_id, $this->user_id,
'a_root',
'root'));
291 $this->mtree->addTree($this->user_id,$root_id);
293 foreach ($this->default_folder as $key => $folder)
298 $last_id = $ilDB->nextId($this->table_mail_obj_data);
299 $statement = $ilDB->manipulateF(
'
300 INSERT INTO '. $this->table_mail_obj_data .
'
306 VALUES( %s, %s, %s, %s)',
307 array(
'integer',
'integer',
'text',
'text'),
308 array($last_id,$this->user_id, $key, $folder));
310 $this->mtree->insertNode($last_id,$root_id);
329 $next_id = $ilDB->nextId($this->table_mail_obj_data);
330 $statement = $ilDB->manipulateF(
'
331 INSERT INTO '. $this->table_mail_obj_data .
'
337 VALUES(%s,%s,%s,%s)',
338 array(
'integer',
'integer',
'text',
'text'),
339 array($next_id, $this->user_id, $a_folder_name,
'user_folder'));
342 $this->mtree->insertNode($next_id,$a_parent_id);
362 $statement = $ilDB->manipulateF(
'
363 UPDATE '. $this->table_mail_obj_data .
'
366 array(
'text',
'integer'),
367 array($a_new_folder_name, $a_obj_id));
382 $res = $ilDB->queryf(
'
383 SELECT obj_id FROM '. $this->table_mail_obj_data .
'
386 array(
'integer',
'text'),
387 array($this->user_id, $a_folder_name));
391 return $row->obj_id ?
true :
false;
404 SELECT title FROM mail_obj_data
412 if( array_key_exists(
$row[
'title'], $this->default_folder) )
417 include_once(
"Services/Mail/classes/class.ilMail.php");
418 $umail =
new ilMail($this->user_id);
421 $subtree = $this->mtree->getSubtree($this->mtree->getNodeData($a_folder_id));
424 $this->mtree->deleteTree($this->mtree->getNodeData($a_folder_id));
427 foreach($subtree as $node)
430 $mails = $umail->getMailsOfFolder($node[
"obj_id"]);
432 foreach ($mails as $mail)
434 $mail_ids[] = $mail[
"mail_id"];
437 if (is_array($mail_ids))
439 $umail->deleteMails($mail_ids);
443 $statement = $ilDB->manipulateF(
'
444 DELETE FROM '. $this->table_mail_obj_data .
'
447 array($node[
'obj_id']));
458 return $ilDB->getLastInsertId();
470 $res = $ilDB->queryf(
'
471 SELECT * FROM '. $this->table_mail_obj_data .
'
474 array(
'integer',
'integer'),
475 array($this->user_id, $a_obj_id));
480 "title" => stripslashes(
$row->title),
481 "type" =>
$row->m_type
493 $res = $ilDB->queryf(
'
494 SELECT * FROM '. $this->table_tree .
'
520 foreach ($this->default_folder as $key => $value)
522 $res = $ilDB->queryf(
'
523 SELECT obj_id,m_type FROM '. $this->table_mail_obj_data .
'
526 array(
'integer',
'text'),
527 array($this->user_id, $key));
531 $user_folder[] = array(
533 "type" =>
$row->m_type,
534 "obj_id" =>
$row->obj_id);
537 $res = $ilDB->queryf(
'
538 SELECT * FROM '. $this->table_tree.
', '. $this->table_mail_obj_data .
'
539 WHERE '. $this->table_mail_obj_data.
'.obj_id = '. $this->table_tree.
'.child
540 AND '. $this->table_tree.
'.depth > %s
541 AND '. $this->table_tree.
'.tree = %s
542 ORDER BY '. $this->table_mail_obj_data.
'.title ',
543 array(
'integer',
'integer'),
544 array(
'2', $this->user_id));
548 $user_folder[] = array(
549 "title" => stripslashes(
$row->title),
550 "type" =>
$row->m_type,
551 "obj_id" =>
$row->child);
564 $this->user_id = $a_user_id;
580 DELETE FROM mail_obj_data WHERE user_id = %s',
581 array(
'integer'), array($this->user_id)
585 DELETE FROM mail_options WHERE user_id = %s',
586 array(
'integer'), array($this->user_id)
590 DELETE FROM mail_saved WHERE user_id = %s',
591 array(
'integer'), array($this->user_id)
595 DELETE FROM mail_tree WHERE tree = %s',
596 array(
'integer'), array($this->user_id)
609 public function updateMailsOfDeletedUser($nameToShow)
620 WHERE sender_id = %s',
621 array(
'integer',
'text',
'integer'),
622 array(0, $nameToShow, $this->user_id));