12require_once(
"Services/Mail/classes/class.ilMail.php");
 
   74        $this->
ilias = $DIC[
'ilias'];
 
   75        $this->lng   = 
$DIC->language();
 
   76        $this->db    = 
$DIC->database();
 
   78        $this->user_id = $a_user_id;
 
   80        $this->table_mail_obj_data = 
'mail_obj_data';
 
   81        $this->table_tree = 
'mail_tree';
 
   84            $this->mtree = 
new ilTree($this->user_id);
 
   85            $this->mtree->setTableNames($this->table_tree, $this->table_mail_obj_data);
 
   91        if (is_object($this->lng)) {
 
   92            $this->lng->loadLanguageModule(
"mail");
 
   94            $this->actions = array(
 
   95                "moveMails"        => $this->lng->txt(
"mail_move_to"),
 
   96                "markMailsRead"   => $this->lng->txt(
"mail_mark_read"),
 
   97                "markMailsUnread" => $this->lng->txt(
"mail_mark_unread"),
 
   98                "deleteMails"      => $this->lng->txt(
"delete"));
 
  102        $this->default_folder = array(
 
  103            "b_inbox"     => 
"inbox",
 
  104            "c_trash"     => 
"trash",
 
  105            "d_drafts"    => 
"drafts",
 
  107            "z_local"     => 
"local");
 
  115        $res = $this->db->queryF(
 
  117                        SELECT obj_id FROM ' . $this->table_mail_obj_data . 
' 
  120            array(
'integer', 
'text'),
 
  121            array($this->user_id, 
'inbox')
 
  126        return $row[
'obj_id'];
 
  134        $res = $this->db->queryF(
 
  136                        SELECT obj_id FROM ' . $this->table_mail_obj_data . 
' 
  139            array(
'integer', 
'text'),
 
  140            array($this->user_id, 
'drafts')
 
  145        return $row[
'obj_id'];
 
  153        $res = $this->db->queryf(
 
  155                        SELECT obj_id FROM ' . $this->table_mail_obj_data . 
' 
  158            array(
'integer', 
'text'),
 
  159            array($this->user_id, 
'trash')
 
  164        return $row[
'obj_id'];
 
  172        $res = $this->db->queryf(
 
  174                        SELECT obj_id FROM ' . $this->table_mail_obj_data . 
' 
  177            array(
'integer', 
'text'),
 
  178            array($this->user_id, 
'sent')
 
  183        return $row[
'obj_id'];
 
  191        return $this->mtree->getRootID($this->user_id);
 
  206            if ($folder_data[
"type"] == 
"user_folder" or $folder_data[
"type"] == 
"local") {
 
  207                #return array_merge($this->actions,array("add" => $this->lng->txt("mail_add_subfolder")));
 
  220        $root_id = $this->db->nextId($this->table_mail_obj_data);
 
  221        $this->db->manipulateF(
 
  223                        INSERT INTO ' . $this->table_mail_obj_data . 
'  
  229                        VALUES(%s, %s, %s, %s)',
 
  230            array(
'integer',
'integer', 
'text', 
'text'),
 
  231            array($root_id, $this->user_id, 
'a_root', 
'root')
 
  233        $this->mtree->addTree($this->user_id, $root_id);
 
  235        foreach ($this->default_folder as 
$key => $folder) {
 
  236            $last_id = $this->db->nextId($this->table_mail_obj_data);
 
  237            $this->db->manipulateF(
 
  239                                INSERT INTO ' . $this->table_mail_obj_data . 
'  
  245                                VALUES(%s, %s, %s, %s)',
 
  246                array(
'integer',
'integer', 
'text', 
'text'),
 
  247                array($last_id, $this->user_id, 
$key, $folder)
 
  249            $this->mtree->insertNode($last_id, $root_id);
 
  265        $next_id = $this->db->nextId($this->table_mail_obj_data);
 
  266        $this->db->manipulateF(
 
  268                        INSERT INTO ' . $this->table_mail_obj_data . 
' 
  274                         VALUES(%s,%s,%s,%s)',
 
  275            array(
'integer',
'integer', 
'text', 
'text'),
 
  276            array($next_id, $this->user_id, $a_folder_name, 
'user_folder')
 
  278        $this->mtree->insertNode($next_id, $a_parent_id);
 
  295        $this->db->manipulateF(
 
  297                        UPDATE ' . $this->table_mail_obj_data . 
' 
  299                        WHERE obj_id = %s AND user_id = %s',
 
  300            array(
'text', 
'integer', 
'integer'),
 
  301            array($a_new_folder_name, $a_obj_id, $this->user_id)
 
  314        $res = $this->db->queryF(
 
  316                        SELECT obj_id FROM ' . $this->table_mail_obj_data . 
' 
  319            array(
'integer', 
'text'),
 
  320            array($this->user_id, $a_folder_name)
 
  324        return is_array(
$row) && 
$row[
'obj_id'] > 0 ? true : 
false;
 
  334        $query = $this->db->queryf(
 
  336                        SELECT obj_id, title FROM mail_obj_data 
  337                        WHERE obj_id = %s AND user_id = %s',
 
  338            array(
'integer', 
'integer'),
 
  339            array($a_folder_id, $this->user_id)
 
  343        if (!is_array(
$row) || array_key_exists(
$row[
'title'], $this->default_folder)) {
 
  347        require_once 
'Services/Mail/classes/class.ilMail.php';
 
  348        $umail = 
new ilMail($this->user_id);
 
  350        $subtree = $this->mtree->getSubtree($this->mtree->getNodeData($a_folder_id));
 
  351        $this->mtree->deleteTree($this->mtree->getNodeData($a_folder_id));
 
  353        foreach ($subtree as $node) {
 
  354            $mails    = $umail->getMailsOfFolder($node[
"obj_id"]);
 
  356            foreach ($mails as $mail) {
 
  357                $mail_ids[] = $mail[
"mail_id"];
 
  360            $umail->deleteMails($mail_ids);
 
  362            $this->db->manipulateF(
 
  364                                DELETE FROM ' . $this->table_mail_obj_data . 
'  
  365                                WHERE obj_id = %s AND user_id = %s',
 
  366                array(
'integer', 
'integer'),
 
  367                array($node[
'obj_id'], $this->user_id)
 
  381        $res = $this->db->queryF(
 
  383                        SELECT * FROM ' . $this->table_mail_obj_data . 
'  
  386            array(
'integer', 
'integer'),
 
  387            array($this->user_id, $a_obj_id)
 
  392            'obj_id' => 
$row[
'obj_id'],
 
  393            'title'  => 
$row[
'title'],
 
  394            'type'   => 
$row[
'm_type']
 
  405        $res = $this->db->queryF(
 
  407                        SELECT * FROM  ' . $this->table_tree . 
'  
  408                        WHERE child = %s AND tree = %s',
 
  409            array(
'integer', 
'integer'),
 
  410            array($a_obj_id, $this->user_id)
 
  414        return is_array(
$row) ? 
$row[
'parent'] : 0;
 
  429        $user_folder = array();
 
  431        foreach ($this->default_folder as 
$key => $value) {
 
  432            $res = $this->db->queryF(
 
  434                                SELECT obj_id, m_type 
  435                                FROM ' . $this->table_mail_obj_data . 
'  
  438                array(
'integer', 
'text'),
 
  439                array($this->user_id, 
$key)
 
  443            $user_folder[] = array(
 
  445                'type'   => 
$row[
'm_type'],
 
  446                'obj_id' => 
$row[
'obj_id']
 
  450        $res = $this->db->queryF(
 
  452                        SELECT * FROM ' . $this->table_tree . 
', ' . $this->table_mail_obj_data . 
' 
  453                        WHERE ' . $this->table_mail_obj_data . 
'.obj_id = ' . $this->table_tree . 
'.child  
  454                        AND ' . $this->table_tree . 
'.depth  > %s 
  455                        AND ' . $this->table_tree . 
'.tree  = %s 
  456                        ORDER BY ' . $this->table_tree . 
'.lft, ' . $this->table_mail_obj_data . 
'.title  ',
 
  457            array(
'integer', 
'integer'),
 
  458            array(2, $this->user_id)
 
  460        while (
$row = $this->db->fetchAssoc(
$res)) {
 
  461            $user_folder[] = array(
 
  462                'title'  => 
$row[
'title'],
 
  463                'type'   => 
$row[
'm_type'],
 
  464                'obj_id' => 
$row[
'child']
 
  476        $this->user_id = $a_user_id;
 
  485    public function delete()
 
  487        $this->db->manipulateF(
 
  489                        DELETE FROM mail_obj_data WHERE user_id = %s',
 
  491            array($this->user_id)
 
  494        $this->db->manipulateF(
 
  496                        DELETE FROM mail_options WHERE user_id = %s',
 
  498            array($this->user_id)
 
  501        $this->db->manipulateF(
 
  503                        DELETE FROM mail_saved WHERE user_id = %s',
 
  505            array($this->user_id)
 
  508        $this->db->manipulateF(
 
  510                        DELETE FROM mail_tree WHERE tree = %s',
 
  512            array($this->user_id)
 
  516        require_once 
'Services/Mail/classes/class.ilFileDataMail.php';
 
  518        $fdm->onUserDelete();
 
  521        $this->db->manipulateF(
 
  522            'DELETE FROM mail WHERE user_id = %s',
 
  524            array($this->user_id)
 
  537        $this->db->manipulateF(
 
  540                        SET sender_id = %s, import_name = %s 
  541                        WHERE sender_id = %s',
 
  542            array(
'integer', 
'text', 
'integer'),
 
  543            array(0, $nameToShow, $this->user_id)
 
An exception for terminatinating execution or to throw for unit testing.
This class handles all operations on files (attachments) in directory ilias_data/mail.
This class handles base functions for mail handling.
Mail Box class Base class for creating and handling mail boxes.
renameFolder($a_obj_id, $a_new_folder_name)
Rename a folder and check if the name already exists.
updateMailsOfDeletedUser($nameToShow)
Update existing mails.
getActions($a_mobj_id)
get all possible actions if no mobj_id is given or folder specific actions if mobj_id is given
folderNameExists($a_folder_name)
Checks whether or not the passed folder name exists in the context of the folder owner.
getTrashFolder()
get Id of the trash folder of an user
__construct($a_user_id=0)
ilMailbox constructor.
getSentFolder()
get Id of the sent folder of an user
createDefaultFolder()
Creates all default folders for a user.
getInboxFolder()
get Id of the inbox folder of an user
getRootFolderId()
get Id of the root folder of an user
getSubFolders($a_folder=0, $a_folder_parent=0)
Get all folders under a given folder/node id.
getDraftsFolder()
get Id of the inbox 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.
getParentFolderId($a_obj_id)
Get id of parent folder.
getFolderData($a_obj_id)
Fetches the data of a specific folder.
deleteFolder($a_folder_id)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
redirection script todo: (a better solution should control the processing via a xml file)
foreach($_POST as $key=> $value) $res