Skip to content

Commit

Permalink
MDL-19744 Fixed blog attachments
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasconnault committed Sep 11, 2009
1 parent 0961861 commit 5d50868
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
9 changes: 7 additions & 2 deletions blog/edit.php
Expand Up @@ -139,8 +139,11 @@

$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);
Expand Down Expand Up @@ -218,7 +221,9 @@

$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
Expand Down
12 changes: 6 additions & 6 deletions blog/edit_form.php
Expand Up @@ -36,18 +36,18 @@ function definition() {

$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();
Expand Down

0 comments on commit 5d50868

Please sign in to comment.