function add($vars, &$errors) { if (!($id = self::create($vars, $errors))) { return false; } if ($faq = self::lookup($id)) { $faq->updateTopics($vars['topics']); if ($_FILES['attachments'] && ($files = AttachmentFile::format($_FILES['attachments']))) { $faq->attachments->upload($files); } // Inline images (attached to the draft) if (isset($vars['draft_id']) && $vars['draft_id']) { if ($draft = Draft::lookup($vars['draft_id'])) { $faq->attachments->upload($draft->getAttachmentIds(), true); } } $faq->reload(); } return $faq; }
// Delete drafts for all users for this canned response Draft::deleteForNamespace('canned.' . $canned->getId()); } elseif (!$errors['err']) { $errors['err'] = 'Error updating canned response. Try again!'; } break; case 'create': if ($id = Canned::create($_POST, $errors)) { $msg = 'Canned response added successfully'; $_REQUEST['a'] = null; //Upload attachments if ($_FILES['attachments'] && ($c = Canned::lookup($id)) && ($files = AttachmentFile::format($_FILES['attachments']))) { $c->attachments->upload($files); } // Attach inline attachments from the editor if (isset($_POST['draft_id']) && ($draft = Draft::lookup($_POST['draft_id']))) { $c->attachments->upload($draft->getAttachmentIds($_POST['response']), true); } // Delete this user's drafts for new canned-responses Draft::deleteForNamespace('canned', $thisstaff->getId()); } elseif (!$errors['err']) { $errors['err'] = 'Unable to add canned response. Correct error(s) below and try again.'; } break; case 'mass_process': if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { $errors['err'] = 'You must select at least one canned response'; } else { $count = count($_POST['ids']); switch (strtolower($_POST['a'])) { case 'enable':
} elseif(!$errors['err']) { $errors['err']=sprintf(__('Error updating %s. Try again!'), __('this canned response')); } break; case 'create': if(($id=Canned::create($_POST, $errors))) { $msg=sprintf(__('Successfully added %s'), Format::htmlchars($_POST['title'])); $_REQUEST['a']=null; //Upload attachments $keepers = $canned_form->getField('attachments')->getClean(); if (($c=Canned::lookup($id)) && $keepers) $c->attachments->upload($keepers); // Attach inline attachments from the editor if ($c && isset($_POST['draft_id']) && ($draft = Draft::lookup($_POST['draft_id']))) $c->attachments->upload( $draft->getAttachmentIds($_POST['response']), true); // Delete this user's drafts for new canned-responses Draft::deleteForNamespace('canned', $thisstaff->getId()); } elseif(!$errors['err']) { $errors['err']=sprintf(__('Unable to add %s. Correct error(s) below and try again.'), __('this canned response')); } break; case 'mass_process': if(!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) { $errors['err']=sprintf(__('You must select at least %s'), __('one canned response')); } else { $count=count($_POST['ids']);
function update($vars, &$errors) { if (!$this->save($this->getId(), $vars, $errors)) { return false; } $this->reload(); // Inline images (attached to the draft) if (isset($vars['draft_id']) && $vars['draft_id']) { if ($draft = Draft::lookup($vars['draft_id'])) { $this->attachments->deleteInlines(); $this->attachments->upload($draft->getAttachmentIds($this->getBody()), true); } } return true; }
function deleteDraft($id) { global $thisstaff; if (!$thisstaff) { Http::response(403, "Login required for draft edits"); } elseif (!($draft = Draft::lookup($id))) { Http::response(205, "Draft not found. Create one first"); } elseif ($draft->getStaffId() != $thisstaff->getId()) { Http::response(404, "Draft not found"); } $draft->delete(); }