Skip to content
Snippets Groups Projects
Commit 85240484 authored by Jared Hancock's avatar Jared Hancock
Browse files

Fix fatal crash when adding a new page

Also add images on pages to the drop-down list for image choosing, and fix
display of images on the client portal.
parent 4fa8fa11
No related branches found
No related tags found
No related merge requests found
......@@ -256,7 +256,7 @@ class DraftAjaxAPI extends AjaxController {
$sql = 'SELECT distinct f.id, COALESCE(a.type, f.ft) FROM '.FILE_TABLE
.' f LEFT JOIN '.ATTACHMENT_TABLE.' a ON (a.file_id = f.id)
WHERE (a.`type` IN (\'C\', \'F\', \'T\') OR f.ft = \'L\')
WHERE (a.`type` IN (\'C\', \'F\', \'T\', \'P\') OR f.ft = \'L\')
AND f.`type` LIKE \'image/%\'';
if (!($res = db_query($sql)))
Http::response(500, 'Unable to lookup files');
......@@ -267,6 +267,7 @@ class DraftAjaxAPI extends AjaxController {
'F' => 'FAQ Articles',
'T' => 'Email Templates',
'L' => 'Logos',
'P' => 'Pages',
);
while (list($id, $type) = db_fetch_row($res)) {
$f = AttachmentFile::lookup($id);
......
......@@ -70,7 +70,7 @@ class Page {
return $this->ht['body'];
}
function getBodyWithImages() {
return Format::viewableImages($this->getBody());
return Format::viewableImages($this->getBody(), ROOT_PATH.'image.php');
}
function getNotes() {
......
......@@ -28,8 +28,9 @@ if($_POST) {
$msg='Page added successfully';
// Attach inline attachments from the editor
if (isset($_POST['draft_id'])
&& ($draft = Draft::lookup($_POST['draft_id'])))
$c->attachments->upload(
&& ($draft = Draft::lookup($_POST['draft_id']))
&& ($page = Page::lookup($pageId)))
$page->attachments->upload(
$draft->getAttachmentIds($_POST['response']), true);
Draft::deleteForNamespace('page');
} elseif(!$errors['err'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment