35 $mails = [
'cnt' => 0,
'cnt_unread' => 0,
'set' => []];
38 'mail_filter_sender' =>
'CONCAT(CONCAT(firstname, lastname), login)',
39 'mail_filter_recipients' =>
'CONCAT(CONCAT(rcp_to, rcp_cc), rcp_bcc)',
40 'mail_filter_subject' =>
'm_subject',
41 'mail_filter_body' =>
'm_message',
42 'mail_filter_attach' =>
'' 46 if (isset(self::$filter[
'mail_filter']) && strlen(self::$filter[
'mail_filter'])) {
48 if (strlen($column) && isset(self::$filter[
$key]) && (
int) self::$filter[$key]) {
49 $filter_parts[] = $DIC->database()->like(
52 '%%' . self::$filter[
'mail_filter'] .
'%%',
61 $filter_qry =
'AND (' . implode(
' OR ', $filter_parts) .
')';
64 if (isset(self::$filter[
'mail_filter_only_unread']) && self::$filter[
'mail_filter_only_unread']) {
65 $filter_qry .=
' AND m_status = ' . $DIC->database()->quote(
'unread',
'text') .
' ';
68 if (isset(self::$filter[
'mail_filter_only_with_attachments']) && self::$filter[
'mail_filter_only_with_attachments']) {
69 $filter_qry .=
' AND attachments != ' . $DIC->database()->quote(serialize(null),
'text') .
' ';
72 if (isset(self::$filter[
'period']) && is_array(self::$filter[
'period'])) {
73 $dateFilterParts = [];
75 if (null !== self::$filter[
'period'][
'start']) {
76 $dateFilterParts[] =
'send_time >= ' . $DIC->database()->quote(
77 (
new \
DateTimeImmutable(
'@' . self::$filter[
'period'][
'start']))->format(
'Y-m-d 00:00:00'),
82 if (null !== self::$filter[
'period'][
'end']) {
83 $dateFilterParts[] =
'send_time <= ' . $DIC->database()->quote(
84 (
new \
DateTimeImmutable(
'@' . self::$filter[
'period'][
'end']))->format(
'Y-m-d 23:59:59'),
89 if (count($dateFilterParts) > 0) {
90 $filter_qry .=
' AND (' . implode(
' AND ', $dateFilterParts) .
') ';
95 $queryCount =
'SELECT COUNT(mail_id) cnt FROM mail ' 96 .
'LEFT JOIN usr_data ON usr_id = sender_id ' 97 .
'WHERE user_id = %s ' 98 .
'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)) ' 99 .
'AND folder_id = %s ' 102 if (self::$filtered_ids) {
103 $queryCount .=
' AND ' . $DIC->database()->in(
'mail_id', self::$filtered_ids,
false,
'integer') .
' ';
106 $queryCount .=
' UNION ALL ' 107 .
'SELECT COUNT(mail_id) cnt FROM mail ' 108 .
'LEFT JOIN usr_data ON usr_id = sender_id ' 109 .
'WHERE user_id = %s ' 110 .
'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)) ' 111 .
'AND folder_id = %s ' 113 .
'AND m_status = %s';
115 if (self::$filtered_ids) {
116 $queryCount .=
' AND ' . $DIC->database()->in(
'mail_id', self::$filtered_ids,
false,
'integer') .
' ';
119 $res = $DIC->database()->queryF(
121 [
'integer',
'integer',
'integer',
'integer',
'text'],
122 [self::$userId, self::$folderId, self::$userId, self::$folderId,
'unread']
126 while ($cnt_row = $DIC->database()->fetchAssoc(
$res)) {
127 if ($counter === 0) {
128 $mails[
'cnt'] = $cnt_row[
'cnt'];
130 if ($counter === 1) {
131 $mails[
'cnt_unread'] = $cnt_row[
'cnt'];
141 $firstnameSelection =
'';
142 if (self::$orderColumn ===
'from') {
144 $firstnameSelection =
' 146 WHEN (usr_id = ' . ANONYMOUS_USER_ID .
') THEN firstname 147 ELSE ' . $DIC->database()->quote(ilMail::_getIliasMailerName(),
'text') .
' 153 $query =
'SELECT mail.*' . $sortColumn .
' ' . $firstnameSelection .
' FROM mail ' 154 .
'LEFT JOIN usr_data ON usr_id = sender_id ' 155 .
'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)) ' 156 .
'WHERE user_id = %s ' 158 .
'AND folder_id = %s';
160 if (self::$filtered_ids) {
161 $query .=
' AND ' . $DIC->database()->in(
'mail_id', self::$filtered_ids,
false,
'integer') .
' ';
165 if (in_array(strtolower(self::$orderDirection), array(
'desc',
'asc'))) {
169 if (self::$orderColumn ===
'from') {
175 } elseif (strlen(self::$orderColumn) > 0) {
177 !in_array(strtolower(self::$orderColumn), [
'm_subject',
'send_time',
'rcp_to']) &&
178 !$DIC->database()->tableColumnExists(
'mail', strtolower(self::$orderColumn))) {
180 self::$orderColumn =
'send_time';
185 $query .=
' ORDER BY send_time DESC';
188 $DIC->database()->setLimit(self::$limit, self::$offset);
189 $res = $DIC->database()->queryF(
191 [
'integer',
'integer'],
192 [self::$userId, self::$folderId]
194 while (
$row = $DIC->database()->fetchAssoc(
$res)) {
195 $row[
'attachments'] = unserialize(stripslashes(
$row[
'attachments']));
196 $row[
'm_type'] = unserialize(stripslashes(
$row[
'm_type']));
197 $mails[
'set'][] =
$row;
static _getMailBoxListData()
_getMailBoxListData
foreach($_POST as $key=> $value) $res