Beispiel #1
0
<?php

gatekeeper();
$guid = get_input('guid');
$file = get_entity($guid);
if (!$file) {
    http_response_code(404);
    exit;
}
if (!$file->canEdit()) {
    http_response_code(403);
    exit;
}
$browser = new PleioFileBrowser();
try {
    $options = array('title' => get_input('title'), 'access_id' => (int) get_input('access_id'), 'write_access_id' => (int) get_input('write_access_id'), 'tags' => string_to_tag_array(get_input('tags')), 'parent_guid' => (int) get_input('parent_guid'));
    if ($_FILES['file']) {
        $options['filename'] = $_FILES['file']['name'];
        $options['stream'] = file_get_contents($_FILES['file']['tmp_name']);
        $options['type'] = $_FILES['file']['type'];
    }
    $browser->updateFile($file, $options);
} catch (Exception $e) {
    http_response_code(500);
}
Beispiel #2
0
<?php

$browser = new PleioFileBrowser();
$dbprefix = elgg_get_config('dbprefix');
$container_guid = (int) get_input('containerGuid');
$limit = (int) get_input('limit', 100);
$offset = (int) get_input('offset', 0);
$user = elgg_get_logged_in_user_entity();
if ($limit < 1 | $limit > 100) {
    $limit = 100;
}
if ($offset < 0) {
    $offset = 0;
}
if ($container_guid) {
    $container = get_entity($container_guid);
    if (!$container) {
        http_response_code(404);
        exit;
    }
} else {
    $container = null;
}
$json = array();
if ($container) {
    $json['guid'] = $container->guid;
    if ($container instanceof ElggUser | $container instanceof ElggGroup) {
        elgg_set_page_owner_guid($container->guid);
        $json['title'] = $container->name;
        $json['accessId'] = get_default_access();
        $json['writeAccessId'] = ACCESS_PRIVATE;
Beispiel #3
0
<?php

$container_guid = elgg_extract("container_guid", $vars, elgg_get_page_owner_guid());
$current_folder = elgg_extract("folder", $vars);
$browser = new PleioFileBrowser();
$container = get_entity($container_guid);
$parse_folder = function ($folder, $prefix = "") use(&$parse_folder) {
    if ($folder['folder'] instanceof ElggUser | $folder['folder'] instanceof ElggGroup) {
        $title = elgg_echo('pleiofile:main_folder');
    } else {
        $title = $folder['folder']->title;
    }
    $json = array();
    $json[$folder['folder']->guid] = $prefix . ' ' . $title;
    $children = array();
    foreach ($folder['children'] as $child) {
        $children = $children + $parse_folder($child, $prefix . '-');
    }
    return $json + $children;
};
$vars["options_values"] = $parse_folder($browser->getFolderTree($container));
$vars["value"] = $current_folder;
echo elgg_view("input/dropdown", $vars);
Beispiel #4
0
<?php

gatekeeper();
$guid = get_input('guid');
$folder = get_entity($guid);
if (!$folder) {
    http_response_code(404);
    exit;
}
if (!$folder->canEdit()) {
    http_response_code(403);
    exit;
}
$browser = new PleioFileBrowser();
try {
    $browser->updateFolder($folder, array('title' => get_input('title'), 'tags' => string_to_tag_array(get_input('tags')), 'parent_guid' => get_input('parent_guid'), 'access_id' => (int) get_input('access_id'), 'update_children' => get_input('update_children') == 'true', 'write_access_id' => (int) get_input('write_access_id')));
} catch (Exception $e) {
    http_response_code(500);
}
Beispiel #5
0
<?php

gatekeeper();
$guid = get_input('guid');
$item = get_entity($guid);
if (!$item) {
    http_response_code(404);
    exit;
}
if (!$item->canEdit()) {
    http_response_code(403);
    exit;
}
$browser = new PleioFileBrowser();
if ($item instanceof ElggFile) {
    $browser->deleteFile($item);
} else {
    $browser->deleteFolder($item);
}
Beispiel #6
0
<?php

gatekeeper();
$parent_guid = get_input('parent_guid');
$parent = get_entity($parent_guid);
if (!$parent) {
    http_response_code(404);
    exit;
}
if (!$parent->canWriteToContainer()) {
    http_response_code(403);
    exit;
}
$browser = new PleioFileBrowser();
try {
    $browser->createFolder($parent, array('title' => get_input('title'), 'tags' => string_to_tag_array(get_input('tags')), 'access_id' => (int) get_input('access_id'), 'write_access_id' => (int) get_input('write_access_id')));
} catch (Exception $e) {
    http_response_code(500);
}
Beispiel #7
0
<?php

gatekeeper();
$parent_guid = get_input('parent_guid');
if ($parent_guid != 0) {
    $parent = get_entity($parent_guid);
} else {
    $parent = elgg_get_logged_in_user_entity();
}
if (!$parent) {
    http_response_code(404);
    exit;
}
if (!$parent->canWriteToContainer()) {
    http_response_code(403);
    exit;
}
if ($_FILES['file']['error'] !== 0) {
    http_response_code(500);
    exit;
}
$browser = new PleioFileBrowser();
try {
    $file = $browser->createFile($parent, array('filename' => $_FILES['file']['name'], 'stream' => file_get_contents($_FILES['file']['tmp_name']), 'access_id' => get_input('access_id'), 'write_access_id' => get_input('write_access_id'), 'type' => $_FILES['file']['type']));
    add_to_river('river/object/file/create', 'create', elgg_get_logged_in_user_guid(), $file->guid);
} catch (Exception $e) {
    http_response_code(500);
    exit;
}
Beispiel #8
0
<?php

$container_guid = get_input('containerGuid');
$container = get_entity($container_guid);
if (!$container) {
    http_response_code(404);
    exit;
}
if (!$container instanceof ElggUser && !$container instanceof ElggGroup) {
    http_response_code(404);
    exit;
}
$browser = new PleioFileBrowser();
$parse_folder = function ($folder) use(&$parse_folder) {
    if ($folder['folder'] instanceof ElggUser | $folder['folder'] instanceof ElggGroup) {
        $title = elgg_echo('pleiofile:main_folder');
    } else {
        $title = $folder['folder']->title;
    }
    $json = array('guid' => $folder['folder']->guid, 'title' => $title);
    $json['children'] = array();
    foreach ($folder['children'] as $child) {
        $json['children'][] = $parse_folder($child);
    }
    return $json;
};
$list = $browser->getFolderTree($container);
$json = $parse_folder($list);
header('Content-Type: application/json');
echo json_encode($json, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);