$summaryoptions = array('maxfiles' => 99, 'maxbytes' => $CFG->maxbytes, 'trusttext' => true, 'context' => $sitecontext, 'subdirs' => file_area_contains_subdirs($sitecontext, 'blog', 'post', $entry->id)); $attachmentoptions = array('subdirs' => false, 'maxfiles' => 99, 'maxbytes' => $CFG->maxbytes); $blogeditform = new blog_edit_form(null, compact('entry', 'summaryoptions', 'attachmentoptions', 'sitecontext', 'courseid', 'modid')); $entry = file_prepare_standard_editor($entry, 'summary', $summaryoptions, $sitecontext, 'blog', 'post', $entry->id); $entry = file_prepare_standard_filemanager($entry, 'attachment', $attachmentoptions, $sitecontext, 'blog', 'attachment', $entry->id); if (!empty($CFG->usetags) && !empty($entry->id)) { include_once $CFG->dirroot . '/tag/lib.php'; $entry->tags = tag_get_tags_array('post', $entry->id); } $entry->action = $action; // set defaults $blogeditform->set_data($entry); if ($blogeditform->is_cancelled()) { redirect($returnurl); } else { if ($data = $blogeditform->get_data()) { switch ($action) { case 'add': $blogentry = new blog_entry(null, $data, $blogeditform); $blogentry->add(); $blogentry->edit($data, $blogeditform, $summaryoptions, $attachmentoptions); break; case 'edit': if (empty($entry->id)) { print_error('wrongentryid', 'blog'); } $entry->edit($data, $blogeditform, $summaryoptions, $attachmentoptions); break; default: print_error('invalidaction'); }
$optionsyes = array('id' => $id, 'action' => 'delete', 'confirm' => 1, 'sesskey' => sesskey(), 'courseid' => $courseid); $optionsno = array('userid' => $existing->userid, 'courseid' => $courseid); print_header("{$SITE->shortname}: {$strblogs}", $SITE->fullname); blog_print_entry($existing); echo '<br />'; notice_yesno(get_string('blogdeleteconfirm', 'blog'), 'edit.php', 'index.php', $optionsyes, $optionsno, 'post', 'get'); print_footer(); die; } } require_once 'edit_form.php'; $blogeditform = new blog_edit_form(null, compact('existing', 'sitecontext')); if ($blogeditform->is_cancelled()) { redirect($returnurl); } else { if ($fromform = $blogeditform->get_data()) { //save stuff in db switch ($action) { case 'add': do_add($fromform, $blogeditform); break; case 'edit': if (!$existing) { error('Incorrect blog post id'); } do_edit($fromform, $blogeditform); break; default: error('Unknown action!'); } redirect($returnurl);