Public Member Functions | |
ilMailbox ($a_user_id=0) | |
Constructor. | |
getInboxFolder () | |
get Id of the inbox folder of an user public | |
getDraftsFolder () | |
get Id of the inbox folder of an user public | |
getTrashFolder () | |
get Id of the trash folder of an user public | |
getSentFolder () | |
get Id of the sent folder of an user public | |
getRootFolderId () | |
get Id of the root folder of an user public | |
getActions ($a_mobj_id) | |
get all possible actions if no mobj_id is given or folder specific actions if mobj_id is given | |
createDefaultFolder () | |
create all default folders public | |
addFolder ($a_parent_id, $a_folder_name) | |
add folder | |
renameFolder ($a_obj_id, $a_new_folder_name) | |
rename folder and check if the name already exists | |
folderNameExists ($a_folder_name) | |
rename folder and check if the name already exists | |
deleteFolder ($a_folder_id) | |
add folder | |
getLastInsertId () | |
getFolderData ($a_obj_id) | |
get data of a specific folder | |
getParentFolderId ($a_obj_id) | |
get id of parent folder | |
getSubFolders ($a_folder=0, $a_folder_parent=0) | |
get all folders under given node | |
setUserId ($a_user_id) | |
set user_id | |
delete () | |
deletes user's mailbox and all db entries related to mailbox TODO: stefan, bitte nochmal kontrollieren, ob auch wirklich alles gel�scht wird. | |
updateMailsOfDeletedUser () | |
Update existing mails. | |
Static Public Member Functions | |
hasNewMail ($a_user_id) | |
Static method check if new mail exists in inbox folder public. | |
_countNewMails ($a_user_id) | |
Static method check how many unread mails are in inbox public. | |
Data Fields | |
$ilias | |
$lng | |
$mtree | |
$user_id | |
$actions | |
$default_folder | |
$table_mail_obj_data | |
$table_tree |
Definition at line 36 of file class.ilMailbox.php.
ilMailbox::_countNewMails | ( | $ | a_user_id | ) | [static] |
Static method check how many unread mails are in inbox public.
Definition at line 273 of file class.ilMailbox.php.
References $ilias, $query, and $row.
Referenced by ilMainMenuGUI::setTemplateVars().
{ global $ilias; if (!$a_user_id) { return 0; } // CHECK FOR SYSTEM MAIL $query = "SELECT count(*) as cnt FROM mail WHERE folder_id = 0 AND user_id = '".$a_user_id."' ". "AND m_status = 'unread'"; $row = $ilias->db->getRow($query,DB_FETCHMODE_OBJECT); $query = "SELECT count(*) as cnt FROM mail AS m,mail_obj_data AS mo ". "WHERE m.user_id = mo.user_id ". "AND m.folder_id = mo.obj_id ". "AND mo.type = 'inbox' ". "AND m.user_id = '".$a_user_id."' ". "AND m.m_status = 'unread'"; $row2 = $ilias->db->getRow($query,DB_FETCHMODE_OBJECT); return $row->cnt + $row2->cnt; }
ilMailbox::addFolder | ( | $ | a_parent_id, | |
$ | a_folder_name | |||
) |
add folder
integer | id of parent folder | |
string | name of folder |
Definition at line 337 of file class.ilMailbox.php.
References $query, $res, folderNameExists(), and getLastInsertId().
{ if ($this->folderNameExists($a_folder_name)) { return 0; } // ENTRY IN mail_obj_data $query = "INSERT INTO $this->table_mail_obj_data ". "SET user_id = '$this->user_id',". "title = '".addslashes($a_folder_name)."',". "type = 'user_folder'"; $res = $this->ilias->db->query($query); // ENTRY IN mail_tree $new_id = $this->getLastInsertId(); $this->mtree->insertNode($new_id,$a_parent_id); return $new_id; }
ilMailbox::createDefaultFolder | ( | ) |
create all default folders public
Definition at line 303 of file class.ilMailbox.php.
References $key, $query, $res, and getLastInsertId().
{ $root_id = $this->getLastInsertId(); ++$root_id; $query = "INSERT INTO $this->table_mail_obj_data ". "SET obj_id = '".$root_id."',". "user_id = '$this->user_id',". "title = 'a_root',". "type = 'root'"; $res = $this->ilias->db->query($query); $this->mtree->addTree($this->user_id,$root_id); foreach ($this->default_folder as $key => $folder) { $last_id = $this->getLastInsertId(); ++$last_id; $query = "INSERT INTO $this->table_mail_obj_data ". "SET obj_id = '".$last_id."',". "user_id = '$this->user_id',". "title = '$key',". "type = '$folder'"; $res = $this->ilias->db->query($query); $this->mtree->insertNode($last_id,$root_id); } }
ilMailbox::delete | ( | ) |
deletes user's mailbox and all db entries related to mailbox TODO: stefan, bitte nochmal kontrollieren, ob auch wirklich alles gel�scht wird.
Vielleicht hab ich was �bersehen. - shofmann, 15.7.03
public
Definition at line 542 of file class.ilMailbox.php.
References $q.
{ $q = "DELETE FROM mail_obj_data WHERE user_id='".$this->user_id."'"; $this->ilias->db->query($q); $q = "DELETE FROM mail_options WHERE user_id='".$this->user_id."'"; $this->ilias->db->query($q); $q = "DELETE FROM mail_saved WHERE user_id='".$this->user_id."'"; $this->ilias->db->query($q); $q = "DELETE FROM mail_tree WHERE tree='".$this->user_id."'"; $this->ilias->db->query($q); return true; }
ilMailbox::deleteFolder | ( | $ | a_folder_id | ) |
add folder
integer | id of parent folder public |
Definition at line 400 of file class.ilMailbox.php.
References $query, $res, and $umail.
{ include_once("classes/class.ilMail.php"); $umail = new ilMail($this->user_id); // SAVE SUBTREE DATA $subtree = $this->mtree->getSubtree($this->mtree->getNodeData($a_folder_id)); // DELETE ENTRY IN TREE $this->mtree->deleteTree($this->mtree->getNodeData($a_folder_id)); // DELETE ENTRY IN mobj_data foreach($subtree as $node) { // DELETE mail(s) of folder(s) $mails = $umail->getMailsOfFolder($node["obj_id"]); foreach ($mails as $mail) { $mail_ids[] = $mail["mail_id"]; } if (is_array($mail_ids)) { $umail->deleteMails($mail_ids); } // DELETE mobj_data entries $query = "DELETE FROM $this->table_mail_obj_data ". "WHERE obj_id = '".$node["obj_id"]."'"; $res = $this->ilias->db->query($query); } return true; }
ilMailbox::folderNameExists | ( | $ | a_folder_name | ) |
rename folder and check if the name already exists
string | new name of folder |
Definition at line 385 of file class.ilMailbox.php.
Referenced by addFolder(), and renameFolder().
{ $query = "SELECT obj_id FROM $this->table_mail_obj_data ". "WHERE user_id = '".$this->user_id."' ". "AND title = '".addslashes($a_folder_name)."'"; $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT); return $row->obj_id ? true : false; }
ilMailbox::getActions | ( | $ | a_mobj_id | ) |
get all possible actions if no mobj_id is given or folder specific actions if mobj_id is given
integer | mobj_id public |
Definition at line 213 of file class.ilMailbox.php.
References $folder_data, and getFolderData().
{ if ($a_mobj_id) { $folder_data = $this->getFolderData($a_mobj_id); if ($folder_data["type"] == "user_folder" or $folder_data["type"] == "local") { return array_merge($this->actions,array("add" => $this->lng->txt("mail_add_subfolder"))); } } return $this->actions; }
ilMailbox::getDraftsFolder | ( | ) |
get Id of the inbox folder of an user public
Definition at line 159 of file class.ilMailbox.php.
ilMailbox::getFolderData | ( | $ | a_obj_id | ) |
get data of a specific folder
int | id of parent folder public |
Definition at line 453 of file class.ilMailbox.php.
Referenced by getActions().
{ $query = "SELECT * FROM $this->table_mail_obj_data ". "WHERE user_id = '".$this->user_id."' ". "AND obj_id = '".$a_obj_id."'"; $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT); return array( "title" => stripslashes($row->title), "type" => $row->type ); }
ilMailbox::getInboxFolder | ( | ) |
get Id of the inbox folder of an user public
Definition at line 145 of file class.ilMailbox.php.
ilMailbox::getLastInsertId | ( | ) |
Definition at line 437 of file class.ilMailbox.php.
References $query, $res, and $row.
Referenced by addFolder(), and createDefaultFolder().
{ $query = "SELECT MAX(obj_id) FROM $this->table_mail_obj_data "; $res = $this->ilias->db->query($query); while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { return $row["MAX(obj_id)"] ? $row["MAX(obj_id)"] : 0; } }
ilMailbox::getParentFolderId | ( | $ | a_obj_id | ) |
get id of parent folder
integer | id of folder public |
Definition at line 471 of file class.ilMailbox.php.
ilMailbox::getRootFolderId | ( | ) |
get Id of the root folder of an user public
Definition at line 201 of file class.ilMailbox.php.
Referenced by getSubFolders().
{
return $this->mtree->getRootID($this->user_id);
}
ilMailbox::getSentFolder | ( | ) |
get Id of the sent folder of an user public
Definition at line 187 of file class.ilMailbox.php.
ilMailbox::getSubFolders | ( | $ | a_folder = 0 , |
|
$ | a_folder_parent = 0 | |||
) |
get all folders under given node
integer | obj_id | |
integer | parent_id public |
Definition at line 485 of file class.ilMailbox.php.
References $key, $query, $res, $row, and getRootFolderId().
{ if (!$a_folder) { $a_folder = $this->getRootFolderId(); } foreach ($this->default_folder as $key => $value) { $query = "SELECT obj_id,type FROM $this->table_mail_obj_data ". "WHERE user_id = $this->user_id ". "AND title = '".$key."'"; $row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT); $user_folder[] = array( "title" => $key, "type" => $row->type, "obj_id" => $row->obj_id); } $query = "SELECT * FROM $this->table_tree, $this->table_mail_obj_data ". "WHERE $this->table_mail_obj_data.obj_id = $this->table_tree.child ". "AND $this->table_tree.depth > '2' ". "AND $this->table_tree.tree = '".$this->user_id."' ". "ORDER BY $this->table_mail_obj_data.title"; $res = $this->ilias->db->query($query); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $user_folder[] = array( "title" => stripslashes($row->title), "type" => $row->type, "obj_id" => $row->child); } return $user_folder; }
ilMailbox::getTrashFolder | ( | ) |
get Id of the trash folder of an user public
Definition at line 173 of file class.ilMailbox.php.
ilMailbox::hasNewMail | ( | $ | a_user_id | ) | [static] |
Static method check if new mail exists in inbox folder public.
Definition at line 235 of file class.ilMailbox.php.
References $ilias, $query, and $row.
Referenced by ilSoapUserAdministration::hasNewMail(), and ilMainMenuGUI::setTemplateVars().
{ global $ilias; if (!$a_user_id) { return 0; } // CHECK FOR SYSTEM MAIL $query = "SELECT mail_id FROM mail WHERE folder_id = 0 AND user_id = '".$a_user_id."' ". "AND m_status = 'unread'"; $row = $ilias->db->getRow($query,DB_FETCHMODE_OBJECT); if($row->mail_id) { return $row->mail_id; } $query = "SELECT m.mail_id FROM mail AS m,mail_obj_data AS mo ". "WHERE m.user_id = mo.user_id ". "AND m.folder_id = mo.obj_id ". "AND mo.type = 'inbox' ". "AND m.user_id = '".$a_user_id."' ". "AND m.m_status = 'unread'"; $row = $ilias->db->getRow($query,DB_FETCHMODE_OBJECT); return $row ? $row->mail_id : 0; }
ilMailbox::ilMailbox | ( | $ | a_user_id = 0 |
) |
Constructor.
integer | user_id of mailbox public |
Definition at line 100 of file class.ilMailbox.php.
{ global $ilias,$lng; $this->ilias = &$ilias; $this->lng = &$lng; $this->user_id = $a_user_id; $this->table_mail_obj_data = 'mail_obj_data'; $this->table_tree = 'mail_tree'; if ($a_user_id) { $this->mtree = new ilTree($this->user_id); $this->mtree->setTableNames($this->table_tree,$this->table_mail_obj_data); } // i added this, becaus if i create a new user automatically during // CAS authentication, we have no $lng variable (alex, 16.6.2006) // (alternative: make createDefaultFolder call static in ilObjUser->saveAsNew()) if (is_object($this->lng)) { $this->lng->loadLanguageModule("mail"); $this->actions = array( "move" => $this->lng->txt("mail_move_to"), "mark_read" => $this->lng->txt("mail_mark_read"), "mark_unread" => $this->lng->txt("mail_mark_unread"), "delete" => $this->lng->txt("delete")); } // array contains basic folders and there lng translation for every new user $this->default_folder = array( "b_inbox" => "inbox", "c_trash" => "trash", "d_drafts" => "drafts", "e_sent" => "sent", "z_local" => "local"); }
ilMailbox::renameFolder | ( | $ | a_obj_id, | |
$ | a_new_folder_name | |||
) |
rename folder and check if the name already exists
integer | id folder | |
string | new name of folder |
Definition at line 364 of file class.ilMailbox.php.
References $query, $res, and folderNameExists().
{ if ($this->folderNameExists($a_new_folder_name)) { return false; } $query = "UPDATE $this->table_mail_obj_data ". "SET title = '".addslashes($a_new_folder_name)."' ". "WHERE obj_id = '".$a_obj_id."'"; $res = $this->ilias->db->query($query); return true; }
ilMailbox::setUserId | ( | $ | a_user_id | ) |
set user_id
integer | id of user public |
Definition at line 529 of file class.ilMailbox.php.
{ $this->user_id = $a_user_id; }
ilMailbox::updateMailsOfDeletedUser | ( | ) |
Update existing mails.
Set sender id to null and import name to login name. This is only necessary for deleted users.
public
Definition at line 566 of file class.ilMailbox.php.
References $query, $tmp_user, and ilObjectFactory::getInstanceByObjId().
{ $tmp_user =& ilObjectFactory::getInstanceByObjId($this->user_id,false); $query = "UPDATE mail SET sender_id = '0',import_name = '".$tmp_user->getLogin()."' ". "WHERE sender_id = '".$this->user_id."'"; $this->ilias->db->query($query); return true; }
ilMailbox::$actions |
Definition at line 72 of file class.ilMailbox.php.
ilMailbox::$default_folder |
Definition at line 79 of file class.ilMailbox.php.
ilMailbox::$ilias |
Definition at line 43 of file class.ilMailbox.php.
Referenced by _countNewMails(), hasNewMail(), and ilMailbox().
ilMailbox::$lng |
Definition at line 50 of file class.ilMailbox.php.
Referenced by ilMailbox().
ilMailbox::$mtree |
Definition at line 57 of file class.ilMailbox.php.
ilMailbox::$table_mail_obj_data |
Definition at line 86 of file class.ilMailbox.php.
ilMailbox::$table_tree |
Definition at line 93 of file class.ilMailbox.php.
ilMailbox::$user_id |
Definition at line 64 of file class.ilMailbox.php.