From 5d50868a611e27333e73d85440e732c50037b081 Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Fri, 11 Sep 2009 05:52:22 +0000 Subject: [PATCH] MDL-19744 Fixed blog attachments --- blog/edit.php | 9 +++++++-- blog/edit_form.php | 12 ++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/blog/edit.php b/blog/edit.php index 5fac155a49..a00a967cb2 100755 --- a/blog/edit.php +++ b/blog/edit.php @@ -139,8 +139,11 @@ if (!empty($existing)) { $textfieldoptions = array('trusttext'=>true, 'subdirs'=>true); $blogeditform = new blog_edit_form(null, compact('existing', 'sitecontext', 'textfieldoptions', 'id')); +$draftitemid = file_get_submitted_draft_itemid('attachments'); +file_prepare_draft_area($draftitemid, $PAGE->context, 'blog_attachment', empty($id)?null:$id); -$existing = file_prepare_standard_editor($existing, 'summary', $textfieldoptions, $PAGE->get_context()); +$draftid_editor = file_get_submitted_draft_itemid('summary'); +$currenttext = file_prepare_draft_area($draftid_editor, $PAGE->context, 'blog_post', empty($id) ? null : $id, array('subdirs'=>true), @$existing->summary); if ($blogeditform->is_cancelled()){ redirect($returnurl); @@ -218,7 +221,9 @@ switch ($action) { $entry->modid = $modid; $entry->courseid = $courseid; - +$entry->attachments = $draftitemid; +$entry->summary = array('text' => @$existing->summary, 'format' => empty($existing->summaryformat) ? FORMAT_HTML : $existing->summaryformat, 'itemid' => $draftid_editor); +$entry->summaryformat = (empty($existing->summaryformat)) ? FORMAT_HTML : $existing->summaryformat; $PAGE->requires->data_for_js('blog_edit_existing', $entry); // done here in order to allow deleting of entries with wrong user id above diff --git a/blog/edit_form.php b/blog/edit_form.php index cbe982bf8f..279366e590 100644 --- a/blog/edit_form.php +++ b/blog/edit_form.php @@ -36,18 +36,18 @@ class blog_edit_form extends moodleform { $mform->addElement('text', 'subject', get_string('entrytitle', 'blog'), 'size="60"'); $textfieldoptions = array('trusttext'=>true, 'subdirs'=>true); - $mform->addElement('editor', 'summary_editor', get_string('entrybody', 'blog'), null, $summaryoptions); + $mform->addElement('editor', 'summary', get_string('entrybody', 'blog'), null, $summaryoptions); $mform->setType('subject', PARAM_TEXT); $mform->addRule('subject', get_string('emptytitle', 'blog'), 'required', null, 'client'); - $mform->setType('summary_editor', PARAM_RAW); - $mform->addRule('summary_editor', get_string('emptybody', 'blog'), 'required', null, 'client'); - $mform->setHelpButton('summary_editor', array('writing', 'richtext2'), false, 'editorhelpbutton'); + $mform->setType('summary', PARAM_RAW); + $mform->addRule('summary', get_string('emptybody', 'blog'), 'required', null, 'client'); + $mform->setHelpButton('summary', array('writing', 'richtext2'), false, 'editorhelpbutton'); - $mform->addElement('format', 'format', get_string('format')); + $mform->addElement('format', 'summaryformat', get_string('format')); - $mform->addElement('file', 'attachment', get_string('attachment', 'forum')); + $mform->addElement('filemanager', 'attachments', get_string('attachment', 'forum')); //disable publishstate options that are not allowed $publishstates = array(); -- 2.39.5