|
19 | 19 | * @since 2003-02-12 |
20 | 20 | */ |
21 | 21 |
|
| 22 | +use phpMyFAQ\Attachment\AttachmentException; |
| 23 | +use phpMyFAQ\Attachment\AttachmentFactory; |
22 | 24 | use phpMyFAQ\Category; |
23 | 25 | use phpMyFAQ\Enums\PermissionType; |
24 | 26 | use phpMyFAQ\Export\Pdf; |
25 | 27 | use phpMyFAQ\Filter; |
| 28 | +use phpMyFAQ\Helper\AttachmentHelper; |
26 | 29 | use phpMyFAQ\Language; |
27 | 30 | use phpMyFAQ\Strings; |
28 | 31 | use phpMyFAQ\Tags; |
|
100 | 103 |
|
101 | 104 | $request = Request::createFromGlobals(); |
102 | 105 | $currentCategory = Filter::filterVar($request->query->get('cat'), FILTER_VALIDATE_INT); |
103 | | -$id = Filter::filterVar($request->query->get('id'), FILTER_VALIDATE_INT); |
| 106 | +$faqId = Filter::filterVar($request->query->get('id'), FILTER_VALIDATE_INT); |
104 | 107 | $getAll = Filter::filterVar($request->query->get('getAll'), FILTER_VALIDATE_BOOLEAN, false); |
105 | 108 |
|
106 | 109 | $faq = $container->get('phpmyfaq.faq'); |
|
130 | 133 | $filename = 'FAQs.pdf'; |
131 | 134 | $pdfFile = $pdf->generate(0, true, $lang); |
132 | 135 | } else { |
133 | | - if (is_null($currentCategory) || is_null($id)) { |
| 136 | + if (is_null($currentCategory) || is_null($faqId)) { |
134 | 137 | $response->isRedirect($faqConfig->getDefaultUrl()); |
135 | 138 | $response->send(); |
136 | 139 | exit(); |
137 | 140 | } |
138 | 141 |
|
139 | | - $faq->getFaq($id); |
| 142 | + $faq->getFaq($faqId); |
140 | 143 | $faq->faqRecord['category_id'] = $currentCategory; |
141 | 144 |
|
142 | | - $filename = 'FAQ-' . $id . '-' . $lang . '.pdf'; |
| 145 | + if ($faqConfig->get('records.disableAttachments') && 'yes' === $faq->faqRecord['active']) { |
| 146 | + try { |
| 147 | + $attachmentHelper = new AttachmentHelper(); |
| 148 | + $attList = AttachmentFactory::fetchByRecordId($faqConfig, $faqId); |
| 149 | + $faq->faqRecord['attachmentList'] = $attachmentHelper->getAttachmentList($attList); |
| 150 | + } catch (AttachmentException) { |
| 151 | + // handle exception |
| 152 | + } |
| 153 | + } |
| 154 | + |
| 155 | + $filename = 'FAQ-' . $faqId . '-' . $lang . '.pdf'; |
143 | 156 | $pdfFile = $pdf->generateFile($faq->faqRecord, $filename); |
144 | 157 | } |
145 | 158 |
|
|
0 commit comments