diff --git a/scp/canned.php b/scp/canned.php index ae8ded5fe76017b4a65b3c75929088e4110127b6..88fdf4b81360e4b49b1b7208b14e56e723652449 100644 --- a/scp/canned.php +++ b/scp/canned.php @@ -37,6 +37,13 @@ $canned_form = new SimpleForm(array( )), )); +// Set fields' attachments so exsting files stay put +if ($canned + && $canned->attachments + && ($attachments = $canned_form->getField('attachments'))) { + $attachments->setAttachments($canned->attachments); +} + if ($_POST) { switch(strtolower($_POST['do'])) { case 'update': diff --git a/scp/faq.php b/scp/faq.php index 310809947f82b90d7b2f4238802aecda6a8b36a4..8b948c1421ff0b51e044410ce3f9d8ba0b296cb5 100644 --- a/scp/faq.php +++ b/scp/faq.php @@ -48,6 +48,21 @@ if ($langs = $cfg->getSecondaryLanguages()) { $faq_form = new SimpleForm($form_fields, $_POST); +// Set fields' attachments so exsting files stay put +if ($faq + && $faq->getAttachments()->window(array('inline' => false)) + && ($common_attachments = $faq_form->getField('attachments'))) { + // Common attachments + $common_attachments->setAttachments($faq->getAttachments()->window(array('inline' => false))); +} +if ($langs && $faq) { + // Multi-lingual system + foreach ($langs as $lang) { + $attachments = $faq_form->getField('attachments.'.$lang); + $attachments->setAttachments($faq->getAttachments($lang)->window(array('inline' => false))); + } +} + if ($_POST) { $errors=array(); // General attachments @@ -126,21 +141,6 @@ if ($_POST) { } } -else { - // Not a POST — load database-backed attachments to attachment fields - if ($langs && $faq) { - // Multi-lingual system - foreach ($langs as $lang) { - $attachments = $faq_form->getField('attachments.'.$lang); - $attachments->setAttachments($faq->getAttachments($lang)->window(array('inline' => false))); - } - } - if ($faq) { - // Common attachments - $attachments = $faq_form->getField('attachments'); - $attachments->setAttachments($faq->getAttachments()->window(array('inline' => false))); - } -} $inc='faq-categories.inc.php'; //FAQs landing page. if($faq) {