diff --git a/include/class.canned.php b/include/class.canned.php index 5a396b8bd2d8b7284cdfb69ab3f01d88385f8340..8c842776af205ac4e66881922b9d32d1d13716ca 100644 --- a/include/class.canned.php +++ b/include/class.canned.php @@ -110,8 +110,7 @@ class Canned { 'attachments__type'=>'C', 'attachments__object_id'=>$this->getId(), 'attachments__inline' => $inlines, - )) - ->all(); + )); } function getNumFilters() { diff --git a/include/class.forms.php b/include/class.forms.php index 0b6da8f275f0f5a75fc08c3f618279bdd2aff058..be6c35e5b92509c216948a1780b34917db4c1b95 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -2241,6 +2241,10 @@ class FileUploadField extends FormField { return $this->attachments ? $this->attachments->getAll() : array(); } + function setAttachments(GenericAttachments $att) { + $this->attachments = $att; + } + function getConfiguration() { $config = parent::getConfiguration(); $_types = self::getFileTypes(); diff --git a/include/staff/cannedresponse.inc.php b/include/staff/cannedresponse.inc.php index 8e407d25319dae991eaa3ba51e7e849e7abaf8c3..4679c14c0fb1aab857019f0bc0c63a1fa45be717 100644 --- a/include/staff/cannedresponse.inc.php +++ b/include/staff/cannedresponse.inc.php @@ -93,11 +93,12 @@ $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); </div> <?php $attachments = $canned_form->getField('attachments'); - if ($canned && ($files=$canned->getAttachedFiles())) { - $ids = array(); - foreach ($files as $f) - $ids[] = $f->id; - $attachments->value = $ids; + if ($canned) { + $attachments->setAttachments($canned->attachments); + if ($files = $canned->getAttachedFiles()) { + $ids = $files->values_flat('id')->all(); + $attachments->value = $ids; + } } print $attachments->render(); ?> <br/> diff --git a/scp/canned.php b/scp/canned.php index 34edc39a069b8a2524de622f555b52b28d127d15..129d1993bea8870d09585dbb98e9900a7d0ff2ad 100644 --- a/scp/canned.php +++ b/scp/canned.php @@ -50,8 +50,8 @@ if ($_POST) { $keepers = $canned_form->getField('attachments')->getClean(); $attachments = $canned->attachments->getSeparates(); //current list of attachments. foreach($attachments as $k=>$file) { - if($file['id'] && !in_array($file['id'], $keepers)) { - $canned->attachments->delete($file['id']); + if(isset($file->id) && !in_array($file->id, $keepers)) { + $canned->attachments->delete($file->id); } }