47         $mails = [
'cnt' => 0, 
'cnt_unread' => 0, 
'set' => []];
    50             'mail_filter_sender' => 
'CONCAT(CONCAT(firstname, lastname), login)',
    51             'mail_filter_recipients' => 
'CONCAT(CONCAT(rcp_to, rcp_cc), rcp_bcc)',
    52             'mail_filter_subject' => 
'm_subject',
    53             'mail_filter_body' => 
'm_message',
    54             'mail_filter_attach' => 
'',
    59             isset(self::$filter[
'mail_filter']) &&
    60             is_string(self::$filter[
'mail_filter']) &&
    61             self::$filter[
'mail_filter'] !== 
''    64                 if ($column !== 
'' && isset(self::$filter[
$key]) && (
int) self::$filter[$key]) {
    65                     $filter_parts[] = $DIC->database()->like(
    68                         '%%' . self::$filter[
'mail_filter'] . 
'%%',
    76         if ($filter_parts !== []) {
    77             $filter_qry = 
'AND (' . implode(
' OR ', $filter_parts) . 
')';
    80         if (isset(self::$filter[
'mail_filter_only_unread']) && self::$filter[
'mail_filter_only_unread']) {
    81             $filter_qry .= 
' AND m_status = ' . $DIC->database()->quote(
'unread', 
'text') . 
' ';
    85             isset(self::$filter[
'mail_filter_only_with_attachments']) &&
    86             self::$filter[
'mail_filter_only_with_attachments']
    88             $filter_qry .= 
' AND attachments != ' . $DIC->database()->quote(serialize(null), 
'text') . 
' ';
    89             $filter_qry .= 
' AND attachments != ' . $DIC->database()->quote(serialize([]), 
'text') . 
' ';
    92         if (isset(self::$filter[
'mail_filter_only_user_mails']) && self::$filter[
'mail_filter_only_user_mails']) {
    96         if (isset(self::$filter[
'period']) && is_array(self::$filter[
'period'])) {
    97             $dateFilterParts = [];
    99             if (null !== self::$filter[
'period'][
'start']) {
   100                 $dateFilterParts[] = 
'send_time >= ' . $DIC->database()->quote(
   102                         '@' . self::$filter[
'period'][
'start']
   103                     ))->format(
'Y-m-d 00:00:00'),
   108             if (null !== self::$filter[
'period'][
'end']) {
   109                 $dateFilterParts[] = 
'send_time <= ' . $DIC->database()->quote(
   111                         '@' . self::$filter[
'period'][
'end']
   112                     ))->format(
'Y-m-d 23:59:59'),
   117             if (count($dateFilterParts) > 0) {
   118                 $filter_qry .= 
' AND (' . implode(
' AND ', $dateFilterParts) . 
') ';
   122         $queryCount = 
'SELECT COUNT(mail_id) cnt FROM mail '   123                     . 
'LEFT JOIN usr_data ON usr_id = sender_id '   124                     . 
'WHERE user_id = %s '   125                     . 
'AND ((sender_id > 0 AND sender_id IS NOT NULL '   126                     . 
'AND usr_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) '   127                     . 
'AND folder_id = %s '   130         if (self::$filtered_ids) {
   131             $queryCount .= 
' AND ' . $DIC->database()->in(
   139         $queryCount .= 
' UNION ALL '   140                     . 
'SELECT COUNT(mail_id) cnt FROM mail '   141                     . 
'LEFT JOIN usr_data ON usr_id = sender_id '   142                     . 
'WHERE user_id = %s '   143                     . 
'AND ((sender_id > 0 AND sender_id IS NOT NULL '   144                     . 
'AND usr_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) '   145                     . 
'AND folder_id = %s '   147                     . 
'AND m_status = %s';
   149         if (self::$filtered_ids) {
   150             $queryCount .= 
' AND ' . $DIC->database()->in(
   158         $res = $DIC->database()->queryF(
   160             [
'integer', 
'integer', 
'integer', 
'integer', 
'text'],
   161             [self::$userId, self::$folderId, self::$userId, self::$folderId, 
'unread']
   165         while ($cnt_row = $DIC->database()->fetchAssoc(
$res)) {
   166             if ($counter === 0) {
   167                 $mails[
'cnt'] = (
int) $cnt_row[
'cnt'];
   168             } elseif ($counter === 1) {
   169                 $mails[
'cnt_unread'] = (
int) $cnt_row[
'cnt'];
   178         $firstnameSelection = 
'';
   179         if (self::$orderColumn === 
'from') {
   181             $firstnameSelection = 
'   189         $query = 
'SELECT mail.*' . $sortColumn . 
' ' . $firstnameSelection . 
' FROM mail '   190                . 
'LEFT JOIN usr_data ON usr_id = sender_id '   191                . 
'AND ((sender_id > 0 AND sender_id IS NOT NULL '   192                . 
'AND usr_id IS NOT NULL) OR (sender_id = 0 OR sender_id IS NULL)) '   193                . 
'WHERE user_id = %s '   195                . 
'AND folder_id = %s';
   197         if (self::$filtered_ids) {
   198             $query .= 
' AND ' . $DIC->database()->in(
   207         if (in_array(strtolower(self::$orderDirection), [
'desc', 
'asc'], 
true)) {
   211         if (self::$orderColumn === 
'from') {
   212             $query .= 
' ORDER BY '   217         } elseif (self::$orderColumn !== 
'') {
   219                 !in_array(strtolower(self::$orderColumn), [
'm_subject', 
'send_time', 
'rcp_to'], 
true) &&
   220                 !$DIC->database()->tableColumnExists(
'mail', strtolower(self::$orderColumn))) {
   222                 self::$orderColumn = 
'send_time';
   225             $query .= 
' ORDER BY ' . strtolower(self::$orderColumn) . 
' ' . 
$orderDirection;
   227             $query .= 
' ORDER BY send_time DESC';
   230         $DIC->database()->setLimit(self::$limit, self::$offset);
   231         $res = $DIC->database()->queryF(
   233             [
'integer', 
'integer'],
   234             [self::$userId, self::$folderId]
   236         while ($row = $DIC->database()->fetchAssoc(
$res)) {
   237             if (isset($row[
'attachments'])) {
   238                 $row[
'attachments'] = (array) unserialize(
   239                     stripslashes($row[
'attachments']),
   240                     [
'allowed_classes' => 
false]
   243                 $row[
'attachments'] = [];
   246             if (isset($row[
'mail_id'])) {
   247                 $row[
'mail_id'] = (
int) $row[
'mail_id'];
   250             if (isset($row[
'user_id'])) {
   251                 $row[
'user_id'] = (
int) $row[
'user_id'];
   254             if (isset($row[
'folder_id'])) {
   255                 $row[
'folder_id'] = (
int) $row[
'folder_id'];
   258             if (isset($row[
'sender_id'])) {
   259                 $row[
'sender_id'] = (
int) $row[
'sender_id'];
   262             $mails[
'set'][] = $row;
 
static string $orderDirection
 
static _getIliasMailerName()