/** * @return bool */ public function checkInput() { global $lng; $ok = parent::checkInput(); $query = ilUtil::stripSlashes($_POST[$this->getPostVar()]); if (!$ok) { return false; } include_once 'Services/Mail/classes/class.ilMailLuceneQueryParser.php'; try { ilMailLuceneQueryParser::validateQuery($query); return true; } catch (Exception $e) { $this->setAlert($lng->txt($e->getMessage())); return false; } }
/** * fetchTableData * @access protected * @return ilMailFolderTableGUI * */ protected function fetchTableData() { /** * @var $ilUser ilObjUser */ global $ilUser; // table title if ($this->_folderNode['m_type'] == 'user_folder') { $txt_folder = $this->_folderNode['title']; $img_folder = 'icon_user_folder.png'; } else { $txt_folder = $this->lng->txt('mail_' . $this->_folderNode['title']); $img_folder = 'icon' . substr($this->_folderNode['title'], 1) . '.png'; } try { if ($this->isLuceneSearchEnabled()) { include_once 'Services/Mail/classes/class.ilMailLuceneQueryParser.php'; $query_parser = new ilMailLuceneQueryParser($this->filter['mail_filter']); $query_parser->setFields(array('title' => (bool) $this->filter['mail_filter_subject'], 'content' => (bool) $this->filter['mail_filter_body'], 'mattachment' => (bool) $this->filter['mail_filter_attach'], 'msender' => (bool) $this->filter['mail_filter_sender'], 'mrcp' => (bool) $this->filter['mail_filter_recipients'])); $query_parser->parse(); require_once 'Services/Mail/classes/class.ilMailLuceneSearcher.php'; require_once 'Services/Mail/classes/class.ilMailSearchResult.php'; $result = new ilMailSearchResult(); $searcher = new ilMailLuceneSearcher($query_parser, $result); $searcher->search($ilUser->getId(), $this->_currentFolderId); if (!$result->getIds()) { throw new ilException('mail_search_empty_result'); } ilMailBoxQuery::$filtered_ids = $result->getIds(); ilMailBoxQuery::$filter = array(); } else { ilMailBoxQuery::$filter = (array) $this->filter; } $this->determineOffsetAndOrder(); ilMailBoxQuery::$folderId = $this->_currentFolderId; ilMailBoxQuery::$userId = $ilUser->getId(); ilMailBoxQuery::$limit = $this->getLimit(); ilMailBoxQuery::$offset = $this->getOffset(); ilMailBoxQuery::$orderDirection = $this->getOrderDirection(); ilMailBoxQuery::$orderColumn = $this->getOrderField(); $data = ilMailBoxQuery::_getMailBoxListData(); if (!count($data['set']) && $this->getOffset() > 0) { $this->resetOffset(); ilMailBoxQuery::$limit = $this->getLimit(); ilMailBoxQuery::$offset = $this->getOffset(); $data = ilMailBoxQuery::_getMailBoxListData(); } } catch (Exception $e) { $this->setTitleData($txt_folder, 0, 0, $img_folder); if ('mail_search_empty_result' == $e->getMessage()) { $data['set'] = array(); $data['cnt'] = 0; } else { throw $e; } } if (!$this->isDraftFolder() && !$this->isSentFolder()) { $user_ids = array(); foreach ($data['set'] as $mail) { if ($mail['sender_id'] && $mail['sender_id'] != ANONYMOUS_USER_ID) { $user_ids[$mail['sender_id']] = $mail['sender_id']; } } ilMailUserCache::preloadUserObjects($user_ids); } $counter = 0; foreach ($data['set'] as $key => $mail) { ++$counter; if (is_array($this->getSelectedItems()) && in_array($mail['mail_id'], $this->getSelectedItems())) { $mail['checked'] = ' checked="checked" '; } if ($this->isDraftFolder() || $this->isSentFolder()) { $mail['rcp_to'] = $mail['mail_login'] = $this->_parentObject->umail->formatNamesForOutput($mail['rcp_to']); } else { if ($mail['sender_id'] == ANONYMOUS_USER_ID) { $mail['img_sender'] = ilUtil::getImagePath('HeaderIconAvatar.svg'); $mail['from'] = $mail['mail_login'] = $mail['alt_sender'] = ilMail::_getIliasMailerName(); } else { $user = ilMailUserCache::getUserObjectById($mail['sender_id']); if ($user) { $mail['img_sender'] = $user->getPersonalPicturePath('xxsmall'); $mail['from'] = $mail['mail_login'] = $mail['alt_sender'] = $user->getPublicName(); } else { $mail['from'] = $mail['mail_login'] = $mail['import_name'] . ' (' . $this->lng->txt('user_deleted') . ')'; } } } if ($this->isDraftFolder()) { $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', $mail['mail_id']); $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'draft'); $link_mark_as_read = $this->ctrl->getLinkTargetByClass('ilmailformgui'); $this->ctrl->clearParametersByClass('ilmailformgui'); } else { $this->ctrl->setParameter($this->_parentObject, 'mail_id', $mail['mail_id']); $link_mark_as_read = $this->ctrl->getLinkTarget($this->_parentObject, 'showMail'); $this->ctrl->clearParameters($this->_parentObject); } $css_class = $mail['m_status'] == 'read' ? 'mailread' : 'mailunread'; if ($this->isLuceneSearchEnabled()) { $search_result = array(); foreach ($result->getFields($mail['mail_id']) as $content) { if ('title' == $content[0]) { $mail['msr_subject_link_read'] = $link_mark_as_read; $mail['msr_subject_mailclass'] = $css_class; $mail['msr_subject'] = $content[1]; } else { $search_result[] = $content[1]; } } $mail['msr_data'] = implode('', array_map(function ($value) { return '<p>' . $value . '</p>'; }, $search_result)); if (!$mail['msr_subject']) { $mail['msr_subject_link_read'] = $link_mark_as_read; $mail['msr_subject_mailclass'] = $css_class; $mail['msr_subject'] = htmlspecialchars($mail['m_subject']); } } else { $mail['mail_link_read'] = $link_mark_as_read; $mail['mailclass'] = $css_class; $mail['mail_subject'] = htmlspecialchars($mail['m_subject']); } $mail['mail_date'] = ilDatePresentation::formatDate(new ilDateTime($mail['send_time'], IL_CAL_DATETIME)); $data['set'][$key] = $mail; } $this->setData($data['set']); $this->setMaxCount($data['cnt']); $this->setNumerOfMails($data['cnt']); $this->setTitleData($txt_folder, $data['cnt'], $data['cnt_unread'], $img_folder); return $this; }