/** * @static * @param array $usr_ids */ public static function preloadUserObjects(array $usr_ids) { /** * @var $ilDB ilDB */ global $ilDB; $usr_ids_to_request = array_diff($usr_ids, self::$requested_usr_ids); self::$requested_usr_ids = array_merge(self::$requested_usr_ids, $usr_ids_to_request); self::$requested_usr_ids_key_map = array_flip(self::$requested_usr_ids); if ($usr_ids_to_request) { $in = $ilDB->in('ud.usr_id', $usr_ids_to_request, false, 'integer'); $query = "\n\t\t\t\tSELECT ud.usr_id, login, firstname, lastname, title, gender, pprof.value public_profile,pup.value public_upload, pupgen.value public_gender\n\t\t\t\tFROM usr_data ud\n\t\t\t\tLEFT JOIN usr_pref pprof ON pprof.usr_id = ud.usr_id AND pprof.keyword = %s\n\t\t\t\tLEFT JOIN usr_pref pupgen ON pupgen.usr_id = ud.usr_id AND pupgen.keyword = %s\n\t\t\t\tLEFT JOIN usr_pref pup ON pup.usr_id = ud.usr_id AND pup.keyword = %s\n\t\t\t\tWHERE {$in}\n\t\t\t"; $res = $ilDB->queryF($query, array('text', 'text', 'text'), array('public_profile', 'public_gender', 'public_upload')); while ($row = $ilDB->fetchAssoc($res)) { $user = new ilObjUser(); $user->setId($row['usr_id']); $user->setLogin($row['login']); $user->setGender($row['gender']); $user->setTitle($row['title']); $user->setFirstname($row['firstname']); $user->setLastname($row['lastname']); $user->setPref('public_profile', $row['public_profile']); $user->setPref('public_upload', $row['public_upload']); $user->setPref('public_gender', $row['public_gender']); self::$user_instances[$row['usr_id']] = $user; } } }
/** * @param array $data */ protected function preloadData(array $data) { $usr_ids = array(); foreach ($data as $mail) { if ($mail['sender_id'] && $mail['sender_id'] != ANONYMOUS_USER_ID) { $usr_ids[$mail['sender_id']] = $mail['sender_id']; } } ilMailUserCache::preloadUserObjects($usr_ids); }
/** * 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; }
/** * fetchTableData * @access protected * @return ilMailFolderTableGUI * */ protected function fetchTableData() { global $ilUser; $this->determineOffsetAndOrder(); require_once 'Services/Mail/classes/class.ilMailBoxQuery.php'; 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(); } 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('HeaderIcon.png'); $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') . ')'; } } } $mail['mailclass'] = $mail['m_status'] == 'read' ? 'mailread' : 'mailunread'; if ($this->isDraftFolder()) { $this->ctrl->setParameterByClass('ilmailformgui', 'mail_id', $mail['mail_id']); $this->ctrl->setParameterByClass('ilmailformgui', 'type', 'draft'); $mail['mail_link_read'] = $this->ctrl->getLinkTargetByClass('ilmailformgui'); $this->ctrl->clearParametersByClass('ilmailformgui'); } else { $this->ctrl->setParameter($this->_parentObject, 'mail_id', $mail['mail_id']); $mail['mail_link_read'] = $this->ctrl->getLinkTarget($this->_parentObject, 'showMail'); $this->ctrl->clearParameters($this->_parentObject); } $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']); // table title $txt_folder = ''; $img_folder = ''; 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'; } $this->setTitleData($txt_folder, $data['cnt'], $data['cnt_unread'], $img_folder); return $this; }