Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
e2b3d4c4
Commit
e2b3d4c4
authored
Mar 30, 2009
by
Richard Mansfield
Browse files
Remove some scripts no longer required for blogpost attachments
parent
e1e88b1f
Changes
4
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/blog/attachedfiles.json.php
deleted
100644 → 0
View file @
e1e88b1f
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-blog
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
define
(
'JSON'
,
1
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
safe_require
(
'artefact'
,
'blog'
);
$limit
=
param_integer
(
'limit'
,
null
);
$offset
=
param_integer
(
'offset'
,
0
);
$id
=
param_integer
(
'blogpost'
,
0
);
if
(
$id
)
{
$blogpost
=
new
ArtefactTypeBlogPost
(
$id
);
$blogpost
->
check_permission
();
if
(
!
$filelist
=
$blogpost
->
get_attachments
())
{
$filelist
=
array
();
}
}
else
{
$filelist
=
array
();
}
$result
=
array
(
'count'
=>
count
(
$filelist
),
'limit'
=>
$limit
,
'offset'
=>
$offset
,
'data'
=>
$filelist
,
'error'
=>
false
,
'message'
=>
false
,
);
json_headers
();
print
json_encode
(
$result
);
?>
htdocs/artefact/blog/downloadtemp.php
deleted
100644 → 0
View file @
e1e88b1f
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-file
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
require_once
(
'file.php'
);
$uploadnumber
=
param_integer
(
'tempfile'
);
safe_require
(
'artefact'
,
'blog'
);
$path
=
ArtefactTypeBlogPost
::
get_temp_file_path
(
$uploadnumber
);
serve_file
(
$path
,
''
,
get_field
(
'artefact_blog_blogpost_file_pending'
,
'filetype'
,
'id'
,
$uploadnumber
));
?>
htdocs/artefact/blog/saveblogpost.json.php
deleted
100644 → 0
View file @
e1e88b1f
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-blog
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
define
(
'JSON'
,
1
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
global
$USER
;
json_headers
();
$title
=
param_variable
(
'title'
);
$draft
=
param_boolean
(
'draft'
);
$blog
=
param_integer
(
'blog'
);
$blogpost
=
param_integer
(
'blogpost'
);
$uploads
=
json_decode
(
param_variable
(
'uploads'
));
$artefacts
=
json_decode
(
param_variable
(
'artefacts'
));
$body
=
param_variable
(
'body'
);
if
(
!
get_account_preference
(
$USER
->
get
(
'id'
),
'wysiwyg'
))
{
$body
=
format_whitespace
(
$body
);
}
$tags
=
param_variable
(
'tags'
);
safe_require
(
'artefact'
,
'blog'
);
// Check whether the sum of the sizes of the newly uploaded files
// would exceed the user's quota.
if
(
!
empty
(
$uploads
))
{
$uploadsize
=
0
;
foreach
(
$uploads
as
$upload
)
{
$uploadsize
+=
ArtefactTypeBlogPost
::
temp_attachment_size
(
$upload
->
data
->
tempfilename
);
}
if
(
!
$USER
->
quota_allowed
(
$uploadsize
))
{
json_reply
(
'local'
,
get_string
(
'newattachmentsexceedquota'
,
'artefact.blog'
));
}
}
// Get blogpost instance
$postobj
=
new
ArtefactTypeBlogPost
(
$blogpost
,
null
);
$postobj
->
set
(
'title'
,
$title
);
$postobj
->
set
(
'description'
,
$body
);
$postobj
->
set
(
'tags'
,
preg_split
(
"/\s*,\s*/"
,
trim
(
$tags
)));
$postobj
->
set
(
'published'
,
!
$draft
);
if
(
!
$blogpost
)
{
$postobj
->
set
(
'parent'
,
$blog
);
$postobj
->
set
(
'owner'
,
$USER
->
id
);
}
else
if
(
$postobj
->
get
(
'owner'
)
!=
$USER
->
id
)
{
json_reply
(
'local'
,
get_string
(
'youarenottheownerofthisblogpost'
,
'artefact.blog'
));
}
$postobj
->
commit
();
$blogpost
=
$postobj
->
get
(
'id'
);
// Delete old attachments in the db that no longer appear in the list
// of artefacts
$old
=
$postobj
->
attachment_id_list
();
foreach
(
$old
as
$o
)
{
if
(
!
in_array
(
$o
,
$artefacts
))
{
$postobj
->
detach
(
$o
);
}
}
// Add new artefacts as attachments
foreach
(
$artefacts
as
$a
)
{
if
(
!
in_array
(
$a
,
$old
))
{
$postobj
->
attach
(
$a
);
}
}
// Add the newly uploaded files to myfiles and then to the blog post.
$uploadartefact
=
array
();
if
(
!
empty
(
$uploads
))
{
foreach
(
$uploads
as
$upload
)
{
if
(
!
$fileid
=
$postobj
->
save_attachment
(
$upload
->
data
))
{
json_reply
(
'local'
,
get_string
(
'errorsavingattachments'
,
'artefact.blog'
));
// Things could be in a bad state.
}
$uploadartefact
[
$upload
->
id
]
=
$fileid
;
}
}
// <img> tags in the body of the post may refer to newly uploaded
// files. Because these files have been moved to permanent locations,
// we need to go through the body of the post and change the 'src' and
// 'alt' attributes of all images that refer to uploaded files.
if
(
!
empty
(
$uploadartefact
))
{
$originalbody
=
$body
;
foreach
(
$uploadartefact
as
$k
=>
$v
)
{
$regexps
=
array
(
'/<img([^>]+)src="([^>]+)downloadtemp.php\?tempfile='
.
$k
.
'/'
,
'/alt="uploaded:'
.
$k
.
'"/'
);
$subs
=
array
(
'<img$1src="'
.
get_config
(
'wwwroot'
)
.
'artefact/file/download.php?file='
.
$v
,
'alt="artefact:'
.
$v
.
'"'
);
$body
=
preg_replace
(
$regexps
,
$subs
,
$body
);
}
if
(
$body
!=
$originalbody
)
{
$postobj
=
new
ArtefactTypeBlogPost
(
$blogpost
,
null
);
$postobj
->
set
(
'description'
,
$body
);
$postobj
->
commit
();
}
}
json_reply
(
false
,
get_string
(
'blogpostsaved'
,
'artefact.blog'
));
?>
htdocs/artefact/blog/upload.php
deleted
100644 → 0
View file @
e1e88b1f
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage artefact-blog
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define
(
'INTERNAL'
,
1
);
define
(
'IFRAME'
,
1
);
require
(
dirname
(
dirname
(
dirname
(
__FILE__
)))
.
'/init.php'
);
// Upload a temporary file to attach to a blog post.
// The uploaded file will not be saved as an artefact until the blog post is saved.
$result
=
new
StdClass
;
$result
->
title
=
param_variable
(
'title'
);
$result
->
description
=
param_variable
(
'description'
,
null
);
$result
->
tags
=
param_variable
(
'tags'
,
null
);
$result
->
uploadnumber
=
param_integer
(
'uploadnumber'
);
// id of target iframe
// Ignore possible file name clashes; they should be dealt with in the
// javascript on the edit blog post page.
safe_require
(
'artefact'
,
'blog'
);
$attach
=
ArtefactTypeBlogPost
::
save_attachment_temporary
(
'userfile'
);
if
(
!
$attach
->
error
)
{
$result
->
error
=
false
;
$result
->
artefacttype
=
$attach
->
type
;
$result
->
tempfilename
=
$attach
->
tempfilename
;
$result
->
message
=
get_string
(
'uploadoffilecomplete'
,
'artefact.file'
,
$result
->
title
);
}
else
{
$result
->
error
=
'local'
;
$result
->
message
=
get_string
(
'uploadoffilefailed'
,
'artefact.file'
,
$result
->
title
)
.
': '
.
$attach
->
error
;
}
$r
=
json_encode
(
$result
);
$frame
=
<<<
EOF
<
html
><
head
><
script
>
<!--
function
senduploadresult
()
{
var
x
=
{
$r
};
parent
.
uploader
.
getresult
(
x
);
}
// -->
</
script
></
head
>
<
body
onload
=
"senduploadresult()"
></
body
>
</
html
>
EOF
;
header
(
'Content-type: text/html'
);
echo
$frame
;
?>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment