Mail Box class Base class for creating and handling mail boxes. More...
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 | |
Mail Box class Base class for creating and handling mail boxes.
Definition at line 35 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 282 of file class.ilMailbox.php.
References $ilias.
Referenced by ilMainMenuGUI::setTemplateVars().
{
global $ilDB;
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 = ".$ilDB->quote($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 = ".$ilDB->quote($a_user_id)." ".
"AND m.m_status = 'unread'";
$row2 = $ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return $row->cnt + $row2->cnt;
}
Here is the caller graph for this function:| ilMailbox::addFolder | ( | $ | a_parent_id, | |
| $ | a_folder_name | |||
| ) |
add folder
| integer | id of parent folder | |
| string | name of folder |
Definition at line 349 of file class.ilMailbox.php.
References $res, folderNameExists(), and getLastInsertId().
{
global $ilDB;
if ($this->folderNameExists($a_folder_name))
{
return 0;
}
// ENTRY IN mail_obj_data
$query = "INSERT INTO $this->table_mail_obj_data ".
"SET user_id = ".$ilDB->quote($this->user_id).", ".
"title = ".$ilDB->quote($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;
}
Here is the call graph for this function:| ilMailbox::createDefaultFolder | ( | ) |
create all default folders public
Definition at line 313 of file class.ilMailbox.php.
References $res, and getLastInsertId().
{
global $ilDB;
$root_id = $this->getLastInsertId();
++$root_id;
$query = "INSERT INTO $this->table_mail_obj_data ".
"SET obj_id = ".$ilDB->quote($root_id).",".
"user_id = ".$ilDB->quote($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 = ".$ilDB->quote($last_id).", ".
"user_id = ".$ilDB->quote($this->user_id).", ".
"title = ".$ilDB->quote($key).", ".
"type = ".$ilDB->quote($folder);
$res = $this->ilias->db->query($query);
$this->mtree->insertNode($last_id,$root_id);
}
}
Here is the call graph for this function:| 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 570 of file class.ilMailbox.php.
{
global $ilDB;
$q = "DELETE FROM mail_obj_data WHERE user_id=".$ilDB->quote($this->user_id)." ";
$this->ilias->db->query($q);
$q = "DELETE FROM mail_options WHERE user_id= ".$ilDB->quote($this->user_id)." ";
$this->ilias->db->query($q);
$q = "DELETE FROM mail_saved WHERE user_id= ".$ilDB->quote($this->user_id)." ";
$this->ilias->db->query($q);
$q = "DELETE FROM mail_tree WHERE tree=".$ilDB->quote($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 418 of file class.ilMailbox.php.
References $res.
{
global $ilDB;
include_once("Services/Mail/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 = ".$ilDB->quote($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 401 of file class.ilMailbox.php.
Referenced by addFolder(), and renameFolder().
{
global $ilDB;
$query = "SELECT obj_id FROM $this->table_mail_obj_data ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ".
"AND title = ".$ilDB->quote($a_folder_name)." ";
$row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return $row->obj_id ? true : false;
}
Here is the caller graph for this function:| 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 220 of file class.ilMailbox.php.
References 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;
}
}
return $this->actions;
}
Here is the call graph for this function:| ilMailbox::getDraftsFolder | ( | ) |
get Id of the inbox folder of an user public
Definition at line 160 of file class.ilMailbox.php.
{
global $ilDB;
$query = "SELECT * FROM ".$this->table_mail_obj_data ." ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ".
"AND type = 'drafts'";
$row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return $row->obj_id;
}
| ilMailbox::getFolderData | ( | $ | a_obj_id | ) |
get data of a specific folder
| int | id of parent folder public |
Definition at line 475 of file class.ilMailbox.php.
Referenced by getActions().
{
global $ilDB;
$query = "SELECT * FROM $this->table_mail_obj_data ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ".
"AND obj_id = ".$ilDB->quote($a_obj_id)." ";
$row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return array(
"title" => stripslashes($row->title),
"type" => $row->type
);
}
Here is the caller graph for this function:| ilMailbox::getInboxFolder | ( | ) |
get Id of the inbox folder of an user public
Definition at line 144 of file class.ilMailbox.php.
{
global $ilDB;
$query = "SELECT * FROM ".$this->table_mail_obj_data." ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ".
"AND type = 'inbox'";
$row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return $row->obj_id;
}
| ilMailbox::getLastInsertId | ( | ) |
Definition at line 457 of file class.ilMailbox.php.
References $res.
Referenced by addFolder(), and createDefaultFolder().
{
global $ilDB;
$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;
}
}
Here is the caller graph for this function:| ilMailbox::getParentFolderId | ( | $ | a_obj_id | ) |
get id of parent folder
| integer | id of folder public |
Definition at line 495 of file class.ilMailbox.php.
{
global $ilDB;
$query = "SELECT * FROM $this->table_tree ".
"WHERE child = ".$ilDB->quote($a_obj_id)." ";
$row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return $row->parent;
}
| ilMailbox::getRootFolderId | ( | ) |
get Id of the root folder of an user public
Definition at line 208 of file class.ilMailbox.php.
Referenced by getSubFolders().
{
return $this->mtree->getRootID($this->user_id);
}
Here is the caller graph for this function:| ilMailbox::getSentFolder | ( | ) |
get Id of the sent folder of an user public
Definition at line 192 of file class.ilMailbox.php.
{
global $ilDB;
$query = "SELECT * FROM $this->table_mail_obj_data ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ".
"AND type = 'sent'";
$row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return $row->obj_id;
}
| 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 511 of file class.ilMailbox.php.
References $res, and getRootFolderId().
{
global $ilDB;
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 = ".$ilDB->quote($this->user_id). " ".
"AND title = ".$ilDB->quote($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 = ".$ilDB->quote($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;
}
Here is the call graph for this function:| ilMailbox::getTrashFolder | ( | ) |
get Id of the trash folder of an user public
Definition at line 176 of file class.ilMailbox.php.
{
global $ilDB;
$query = "SELECT * FROM ".$this->table_mail_obj_data ." ".
"WHERE user_id = ".$ilDB->quote($this->user_id)." ".
"AND type = 'trash'";
$row = $this->ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return $row->obj_id;
}
| ilMailbox::hasNewMail | ( | $ | a_user_id | ) | [static] |
Static method check if new mail exists in inbox folder public.
Definition at line 243 of file class.ilMailbox.php.
References $ilias.
Referenced by ilSoapUserAdministration::hasNewMail(), and ilMainMenuGUI::setTemplateVars().
{
global $ilDB;
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 = ".$ilDB->quote($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 = ".$ilDB->quote($a_user_id)." ".
"AND m.m_status = 'unread'";
$row = $ilias->db->getRow($query,DB_FETCHMODE_OBJECT);
return $row ? $row->mail_id : 0;
}
Here is the caller graph for this function:| ilMailbox::ilMailbox | ( | $ | a_user_id = 0 |
) |
Constructor.
| integer | user_id of mailbox public |
Definition at line 99 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(
"moveMails" => $this->lng->txt("mail_move_to"),
"markMailsRead" => $this->lng->txt("mail_mark_read"),
"markMailsUnread" => $this->lng->txt("mail_mark_unread"),
"deleteMails" => $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 378 of file class.ilMailbox.php.
References $res, and folderNameExists().
{
global $ilDB;
if ($this->folderNameExists($a_new_folder_name))
{
return false;
}
$query = "UPDATE $this->table_mail_obj_data ".
"SET title = ".$ilDB->quote($a_new_folder_name)." ".
"WHERE obj_id = ".$ilDB->quote($a_obj_id)." ";
$res = $this->ilias->db->query($query);
return true;
}
Here is the call graph for this function:| ilMailbox::setUserId | ( | $ | a_user_id | ) |
set user_id
| integer | id of user public |
Definition at line 557 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 596 of file class.ilMailbox.php.
References ilObjectFactory::getInstanceByObjId().
{
global $ilDB;
$tmp_user =& ilObjectFactory::getInstanceByObjId($this->user_id,false);
$query = "UPDATE mail SET sender_id = '0',import_name = ".$ilDB->quote($tmp_user->getLogin())." ".
"WHERE sender_id = ".$ilDB->quote($this->user_id)." ";
$this->ilias->db->query($query);
return true;
}
Here is the call graph for this function:| ilMailbox::$actions |
Definition at line 71 of file class.ilMailbox.php.
| ilMailbox::$default_folder |
Definition at line 78 of file class.ilMailbox.php.
| ilMailbox::$ilias |
Definition at line 42 of file class.ilMailbox.php.
Referenced by _countNewMails(), hasNewMail(), and ilMailbox().
| ilMailbox::$lng |
Definition at line 49 of file class.ilMailbox.php.
Referenced by ilMailbox().
| ilMailbox::$mtree |
Definition at line 56 of file class.ilMailbox.php.
| ilMailbox::$table_mail_obj_data |
Definition at line 85 of file class.ilMailbox.php.
| ilMailbox::$table_tree |
Definition at line 92 of file class.ilMailbox.php.
| ilMailbox::$user_id |
Definition at line 63 of file class.ilMailbox.php.
1.7.1