ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMailBoxQuery Class Reference

Mail query class. More...

+ Collaboration diagram for ilMailBoxQuery:

Static Public Member Functions

static _getMailBoxListData ()
 _getMailBoxListData

Static Public Attributes

static $folderId = -1
static $userId = -1
static $limit = 0
static $offset = 0
static $orderDirection = ''
static $orderColumn = ''

Detailed Description

Mail query class.

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 12 of file class.ilMailBoxQuery.php.

Member Function Documentation

static ilMailBoxQuery::_getMailBoxListData ( )
static

_getMailBoxListData

public

Returns
array Array of mails

Definition at line 29 of file class.ilMailBoxQuery.php.

References $ilDB, $orderDirection, $query, $res, and $row.

Referenced by ilMailFolderTableGUI\fetchTableData().

{
global $ilDB;
// initialize array
$mails = array('cnt' => 0, 'cnt_unread' => 0, 'set' => array());
// count query
$queryCount = 'SELECT COUNT(mail_id) cnt FROM mail '
. 'LEFT JOIN usr_data ON usr_id = sender_id '
. 'WHERE user_id = %s '
. 'AND ((sender_id > 0 AND sender_id IS NOT NULL AND usr_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) '
. 'AND folder_id = %s '
. 'UNION ALL '
. 'SELECT COUNT(mail_id) cnt FROM mail '
. 'LEFT JOIN usr_data ON usr_id = sender_id '
. 'WHERE user_id = %s '
. 'AND ((sender_id > 0 AND sender_id IS NOT NULL AND usr_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) '
. 'AND folder_id = %s '
. 'AND m_status = %s';
$res = $ilDB->queryf(
$queryCount,
array('integer', 'integer', 'integer', 'integer', 'text'),
array(self::$userId, self::$folderId, self::$userId, self::$folderId, 'unread')
);
$counter = 0;
while($cnt_row = $ilDB->fetchAssoc($res))
{
if($counter == 0)
{
$mails['cnt'] = $cnt_row['cnt'];
}
else if($counter == 1)
{
$mails['cnt_unread'] = $cnt_row['cnt'];
}
else
{
break;
}
++$counter;
}
$sortColumn = '';
if(self::$orderColumn == 'rcp_to' && $ilDB->getDBType() == 'oracle')
{
$sortColumn = ", CAST(rcp_to AS VARCHAR2(4000)) SORTCOL";
}
// item query
$query = 'SELECT mail.*'.$sortColumn.' FROM mail '
. 'LEFT JOIN usr_data ON usr_id = sender_id '
. 'AND ((sender_id > 0 AND sender_id IS NOT NULL AND usr_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) '
. 'WHERE user_id = %s '
. 'AND folder_id = %s';
// order direction
if(in_array(strtolower(self::$orderDirection), array('desc', 'asc')))
{
}
else
{
$orderDirection = 'ASC';
}
// order column
if(self::$orderColumn == 'rcp_to' && $ilDB->getDBType() == 'oracle')
{
$query .= ' ORDER BY SORTCOL '.$orderDirection;
}
else if(strlen(self::$orderColumn) &&
$ilDB->tableColumnExists('mail', strtolower(self::$orderColumn)))
{
$query .= ' ORDER BY '.strtolower(self::$orderColumn).' '.$orderDirection;
}
else if(self::$orderColumn == 'from')
{
$query .= ' ORDER BY '
. ' firstname '.$orderDirection.', '
. ' lastname '.$orderDirection.', '
. ' login '.$orderDirection.', '
. ' import_name '.$orderDirection;
}
else
{
$query .= ' ORDER BY send_time DESC';
}
$ilDB->setLimit(self::$limit, self::$offset);
$res = $ilDB->queryf(
array('integer', 'integer'),
array(self::$userId, self::$folderId)
);
while($row = $ilDB->fetchAssoc($res))
{
$row['attachments'] = unserialize(stripslashes($row['attachments']));
$row['m_type'] = unserialize(stripslashes($row['m_type']));
$mails['set'][] = $row;
}
return $mails;
}

+ Here is the caller graph for this function:

Field Documentation

ilMailBoxQuery::$folderId = -1
static

Definition at line 14 of file class.ilMailBoxQuery.php.

Referenced by ilMailFolderTableGUI\fetchTableData().

ilMailBoxQuery::$limit = 0
static

Definition at line 16 of file class.ilMailBoxQuery.php.

Referenced by ilMailFolderTableGUI\fetchTableData().

ilMailBoxQuery::$offset = 0
static

Definition at line 17 of file class.ilMailBoxQuery.php.

Referenced by ilMailFolderTableGUI\fetchTableData().

ilMailBoxQuery::$orderColumn = ''
static

Definition at line 19 of file class.ilMailBoxQuery.php.

Referenced by ilMailFolderTableGUI\fetchTableData().

ilMailBoxQuery::$orderDirection = ''
static
ilMailBoxQuery::$userId = -1
static

Definition at line 15 of file class.ilMailBoxQuery.php.

Referenced by ilMailFolderTableGUI\fetchTableData().


The documentation for this class was generated from the following file: