34 $mails = array(
'cnt' => 0,
'cnt_unread' => 0,
'set' => array());
37 $queryCount =
'SELECT COUNT(mail_id) cnt FROM mail '
38 .
'LEFT JOIN usr_data ON usr_id = sender_id '
39 .
'WHERE user_id = %s '
40 .
'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)) '
41 .
'AND folder_id = %s '
43 .
'SELECT COUNT(mail_id) cnt FROM mail '
44 .
'LEFT JOIN usr_data ON usr_id = sender_id '
45 .
'WHERE user_id = %s '
46 .
'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)) '
47 .
'AND folder_id = %s '
48 .
'AND m_status = %s';
52 array(
'integer',
'integer',
'integer',
'integer',
'text'),
53 array(self::$userId, self::$folderId, self::$userId, self::$folderId,
'unread')
56 while($cnt_row = $ilDB->fetchAssoc(
$res))
60 $mails[
'cnt'] = $cnt_row[
'cnt'];
62 else if($counter == 1)
64 $mails[
'cnt_unread'] = $cnt_row[
'cnt'];
75 if(self::$orderColumn ==
'rcp_to' && $ilDB->getDBType() ==
'oracle')
77 $sortColumn =
", CAST(rcp_to AS VARCHAR2(4000)) SORTCOL";
80 if(self::$orderColumn ==
'from')
85 WHEN (usr_id = '.ANONYMOUS_USER_ID.
') THEN firstname
86 ELSE '.$ilDB->quote(ilMail::_getIliasMailerName(),
'text').
'
92 $query =
'SELECT mail.*'.$sortColumn.
' '.$firstname.
' FROM mail '
93 .
'LEFT JOIN usr_data ON usr_id = sender_id '
94 .
'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)) '
95 .
'WHERE user_id = %s '
96 .
'AND folder_id = %s';
100 if(in_array(strtolower(self::$orderDirection), array(
'desc',
'asc')))
110 if(self::$orderColumn ==
'rcp_to' && $ilDB->getDBType() ==
'oracle')
112 $query .=
' ORDER BY SORTCOL '.$orderDirection;
114 else if(self::$orderColumn ==
'from')
117 .
' fname '.$orderDirection.
', '
118 .
' lastname '.$orderDirection.
', '
119 .
' login '.$orderDirection.
', '
120 .
' import_name '.$orderDirection;
122 else if(strlen(self::$orderColumn))
124 if(!in_array(strtolower(self::$orderColumn), array(
'm_subject',
'send_time',
'rcp_to')) &&
125 !$ilDB->tableColumnExists(
'mail', strtolower(self::$orderColumn)))
128 self::$orderColumn =
'send_time';
135 $query .=
' ORDER BY send_time DESC';
138 $ilDB->setLimit(self::$limit, self::$offset);
139 $res = $ilDB->queryF(
141 array(
'integer',
'integer'),
142 array(self::$userId, self::$folderId)
144 while(
$row = $ilDB->fetchAssoc(
$res))
146 $row[
'attachments'] = unserialize(stripslashes(
$row[
'attachments']));
147 $row[
'm_type'] = unserialize(stripslashes(
$row[
'm_type']));
148 $mails[
'set'][] =
$row;