31 public static function _getMailBoxListData()
39 $mails = array(
'cnt' => 0,
'cnt_unread' => 0,
'set' => array());
42 'mail_filter_sender' =>
'CONCAT(CONCAT(firstname, lastname), login)',
43 'mail_filter_recipients' => ($ilDB->getDBType() ==
'oracle' ?
44 "CONCAT(CONCAT(CAST(rcp_to AS VARCHAR2(4000)), CAST(rcp_cc AS VARCHAR2(4000))), CAST(rcp_bcc AS VARCHAR2(4000))))" :
45 "CONCAT(CONCAT(rcp_to, rcp_cc), rcp_bcc)"),
46 'mail_filter_subject' =>
'm_subject',
47 'mail_filter_body' =>
'm_message',
48 'mail_filter_attach' =>
''
50 $filter_parts = array();
51 if(isset(self::$filter[
'mail_filter']) && strlen(self::$filter[
'mail_filter']))
53 foreach(
$filter as $key => $column)
55 if(strlen($column) && isset(self::$filter[$key]) && (
int)self::$filter[$key])
57 $filter_parts[] = $ilDB->like($column,
'text',
'%%'.self::$filter[
'mail_filter'].
'%%',
false);
64 $filter_qry =
'AND ('.implode(
' OR ', $filter_parts).
')';
67 $queryCount =
'SELECT COUNT(mail_id) cnt FROM mail '
68 .
'LEFT JOIN usr_data ON usr_id = sender_id '
69 .
'WHERE user_id = %s '
70 .
'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)) '
71 .
'AND folder_id = %s '
74 .
'SELECT COUNT(mail_id) cnt FROM mail '
75 .
'LEFT JOIN usr_data ON usr_id = sender_id '
76 .
'WHERE user_id = %s '
77 .
'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)) '
78 .
'AND folder_id = %s '
80 .
'AND m_status = %s';
82 if(self::$filtered_ids)
84 $queryCount .=
' AND '.$ilDB->in(
'mail_id', self::$filtered_ids,
false,
'integer').
' ';
89 array(
'integer',
'integer',
'integer',
'integer',
'text'),
90 array(self::$userId, self::$folderId, self::$userId, self::$folderId,
'unread')
93 while($cnt_row = $ilDB->fetchAssoc(
$res))
97 $mails[
'cnt'] = $cnt_row[
'cnt'];
99 else if($counter == 1)
101 $mails[
'cnt_unread'] = $cnt_row[
'cnt'];
112 if(self::$orderColumn ==
'rcp_to' && $ilDB->getDBType() ==
'oracle')
114 $sortColumn =
", CAST(rcp_to AS VARCHAR2(4000)) SORTCOL";
118 if(self::$orderColumn ==
'from')
123 WHEN (usr_id = '.ANONYMOUS_USER_ID.
') THEN firstname
124 ELSE '.$ilDB->quote(ilMail::_getIliasMailerName(),
'text').
'
130 $query =
'SELECT mail.*'.$sortColumn.
' '.$firstname.
' FROM mail '
131 .
'LEFT JOIN usr_data ON usr_id = sender_id '
132 .
'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)) '
133 .
'WHERE user_id = %s '
135 .
'AND folder_id = %s';
137 if(self::$filtered_ids)
139 $query .=
' AND '.$ilDB->in(
'mail_id', self::$filtered_ids,
false,
'integer').
' ';
144 if(in_array(strtolower(self::$orderDirection), array(
'desc',
'asc')))
154 if(self::$orderColumn ==
'rcp_to' && $ilDB->getDBType() ==
'oracle')
156 $query .=
' ORDER BY SORTCOL '.$orderDirection;
158 else if(self::$orderColumn ==
'from')
161 .
' fname '.$orderDirection.
', '
162 .
' lastname '.$orderDirection.
', '
163 .
' login '.$orderDirection.
', '
164 .
' import_name '.$orderDirection;
166 else if(strlen(self::$orderColumn))
168 if(!in_array(strtolower(self::$orderColumn), array(
'm_subject',
'send_time',
'rcp_to')) &&
169 !$ilDB->tableColumnExists(
'mail', strtolower(self::$orderColumn)))
172 self::$orderColumn =
'send_time';
179 $query .=
' ORDER BY send_time DESC';
182 $ilDB->setLimit(self::$limit, self::$offset);
183 $res = $ilDB->queryF(
185 array(
'integer',
'integer'),
186 array(self::$userId, self::$folderId)
188 while(
$row = $ilDB->fetchAssoc(
$res))
190 $row[
'attachments'] = unserialize(stripslashes(
$row[
'attachments']));
191 $row[
'm_type'] = unserialize(stripslashes(
$row[
'm_type']));
192 $mails[
'set'][] =
$row;