Commit 11109d1c authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Create blogfiles folder in blogpost class

parent f17a9e6b
......@@ -581,6 +581,13 @@ class ArtefactTypeBlogPost extends ArtefactType {
* Save a temporary uploaded file to the myfiles area.
*/
public function save_attachment($directory, $filename, $title, $description) {
// Create the blogfiles folder if it doesn't exist yet.
$blogfilesid = self::blogfiles_folder_id();
if (!$blogfilesid) {
return false;
}
global $USER;
safe_require('artefact', 'file');
......@@ -590,7 +597,7 @@ class ArtefactTypeBlogPost extends ArtefactType {
$data->description = $description;
$data->owner = $USER->get('id');
$data->adminfiles = 0; // No admin blogs yet...
$data->parent = self::blogfiles_folder_id();
$data->parent = $blogfilesid;
$path = self::$blogattachmentroot . $directory . '/' . $filename;
......
......@@ -92,14 +92,6 @@ foreach ($artefacts as $a) {
// Add the newly uploaded files to myfiles and then to the blog post.
if (!empty($uploads)) {
// Create the blogfiles folder if it doesn't exist yet.
$blogfilesid = ArtefactTypeBlogPost::blogfiles_folder_id();
if (!$blogfilesid) {
json_reply('local', get_string('erroraccessingblogfilesfolder', 'artefact.blog'));
}
// Turn all the uploaded files into artefacts.
foreach ($uploads as $upload) {
if (!$postobj->save_attachment(session_id() . $createid, $upload->id,
$upload->title, $upload->description)) {
......@@ -108,8 +100,6 @@ if (!empty($uploads)) {
}
}
json_reply(false, get_string('blogpostsaved', 'artefact.blog'));
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment