Skip to content
Snippets Groups Projects
Commit c456684c authored by JediKev's avatar JediKev
Browse files

issue: FAQ & Canned Attachments Dropping

This addresses an issue where FAQ & Canned Response attachments are dropping
when another agent edits the FAQ or Canned Response.
parent e5024184
No related branches found
No related tags found
No related merge requests found
...@@ -37,6 +37,13 @@ $canned_form = new SimpleForm(array( ...@@ -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) { if ($_POST) {
switch(strtolower($_POST['do'])) { switch(strtolower($_POST['do'])) {
case 'update': case 'update':
......
...@@ -48,6 +48,21 @@ if ($langs = $cfg->getSecondaryLanguages()) { ...@@ -48,6 +48,21 @@ if ($langs = $cfg->getSecondaryLanguages()) {
$faq_form = new SimpleForm($form_fields, $_POST); $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) { if ($_POST) {
$errors=array(); $errors=array();
// General attachments // General attachments
...@@ -126,21 +141,6 @@ if ($_POST) { ...@@ -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. $inc='faq-categories.inc.php'; //FAQs landing page.
if($faq) { if($faq) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment