Commit 9f171de5 authored by Alan McNatty's avatar Alan McNatty
Browse files

Added support for tags and description (also cleaned up unneccessary catch code)

parent a76e0a2e
...@@ -46,9 +46,7 @@ try { ...@@ -46,9 +46,7 @@ try {
$token = param_variable('token'); $token = param_variable('token');
$token = trim($token); $token = trim($token);
} }
catch (ParameterException $e) { catch (ParameterException $e) { }
$token = '';
}
if ($token == '') { if ($token == '') {
header($protocol.' 500 Auth token cannot be blank'); header($protocol.' 500 Auth token cannot be blank');
...@@ -59,9 +57,7 @@ $username = ''; ...@@ -59,9 +57,7 @@ $username = '';
try { try {
$username = param_variable('username'); $username = param_variable('username');
} }
catch (ParameterException $e) { catch (ParameterException $e) { }
$username = '';
}
if ($username == '') { if ($username == '') {
header($protocol.' 500 Username cannot be blank'); header($protocol.' 500 Username cannot be blank');
...@@ -113,6 +109,7 @@ catch (ParameterException $e) { ...@@ -113,6 +109,7 @@ catch (ParameterException $e) {
$data->parent = null; $data->parent = null;
} }
// Set title
$title = ''; $title = '';
try { try {
$title = param_variable('title'); $title = param_variable('title');
...@@ -122,9 +119,20 @@ catch (ParameterException $e) { ...@@ -122,9 +119,20 @@ catch (ParameterException $e) {
$title = $_FILES['userfile']['name']; $title = $_FILES['userfile']['name'];
} }
$title = $title ? basename($title) : get_string('file', 'artefact.file'); $title = $title ? basename($title) : get_string('file', 'artefact.file');
$data->title = ArtefactTypeFileBase::get_new_file_title($title, $data->parent, $data->owner); $data->title = ArtefactTypeFileBase::get_new_file_title($title, $data->parent, $data->owner);
// Set description
try {
$data->description = param_variable('description');
}
catch (ParameterException $e) { }
// Set tags
try {
$data->tags = explode(" ", param_variable('tags'));
}
catch (ParameterException $e) { }
try { try {
$newid = ArtefactTypeFile::save_uploaded_file('userfile', $data); $newid = ArtefactTypeFile::save_uploaded_file('userfile', $data);
} }
......
Markdown is supported
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