} catch (ParameterException $e) {
}
// Set tags
try {
    $data->tags = explode(" ", param_variable('tags'));
} catch (ParameterException $e) {
}
if (get_config('licensemetadata')) {
    // Set licensing information
    try {
        $license = license_coalesce(null, param_variable('license'), param_variable('license_other', null));
        $licensor = param_variable('licensor');
        $licensorurl = param_variable('licensorurl');
    } catch (ParameterException $e) {
    }
}
try {
    $newid = ArtefactTypeFile::save_uploaded_file('userfile', $data);
} catch (QuotaExceededException $e) {
    JSONResponse('fail', 'Quota exceeded');
} catch (UploadException $e) {
    JSONResponse('fail', 'Failed to save file');
}
// Here we need to create a new hash - update our own store of it and return it too the handset
JSONResponse("success", $USER->refresh_mobileuploadtoken($token));
function JSONResponse($key, $value)
{
    header('Content-Type: application/json');
    echo json_encode(array($key => $value));
    exit;
}
Example #2
0
    } else {
        $postobj = new ArtefactTypeBlogPost($blogpost, null);
        $postobj->set('title', $title);
        $postobj->set('description', $description);
        $postobj->set('tags', $tags);
        $postobj->set('published', !$draft);
        $postobj->set('allowcomments', (int) $allowcomments);
        $postobj->set('parent', $blog);
        $postobj->set('owner', $USER->id);
        $postobj->commit();
    }
}
// Check to see if we're creating a journal entry
// -- Finally attach the file to the blog post once uploaded and --
if ($artefact_id && $postobj) {
    // If we created or matched a blog post and created an artefact
    // attach the artefact to the blog.
    $postobj->attach($artefact_id);
}
// Here we need to create a new hash - update our own store of it and return it to the handset
jsonreply(array('success' => $USER->refresh_mobileuploadtoken($token)));
function jsonreply($arr)
{
    global $json;
    if ($json) {
        $arr['sync'] = $json;
    }
    header('Content-Type: application/json');
    echo json_encode($arr);
    exit;
}
Example #3
0
foreach ($blogs->data as $blog) {
    if (!$blog->locked) {
        $blogs_arr[] = array("id" => $blog->id, "blog" => $blog->title);
        $blogposts = ArtefactTypeBlogpost::get_posts($blog->id, $blogs->limit, $blogs->offset, null);
        foreach ($blogposts['data'] as $blogpost) {
            if (!$blogpost->locked) {
                $blogposts_arr[] = array("id" => $blogpost->id, "blogpost" => $blogpost->title);
            }
        }
    }
}
if (count($blogs_arr) > 0) {
    $json['blogs'] = $blogs_arr;
}
if (count($blogposts_arr) > 0) {
    $json['blogposts'] = $blogposts_arr;
}
// OK - let's add folders
$folders_arr = array();
$folders = ArtefactTypeFile::get_my_files_data(0, $USER->id, null, null, array("artefacttype" => array("folder")));
foreach ($folders as $folder) {
    if (!$folder->locked) {
        $folders_arr[] = array("id" => $folder->id, "folder" => $folder->title);
    }
}
if (count($folders_arr) > 0) {
    $json['folders'] = $folders_arr;
}
// Here we need to create a new hash - update our own store of it and return it to the handset
mobile_api_json_reply(array('success' => $USER->refresh_mobileuploadtoken($token), 'sync' => $json));