Beispiel #1
0
function handleGetGallery($token, $path)
{
    $owner = OC_Gallery_Sharing::getTokenOwner($token);
    $apath = OC_Gallery_Sharing::getPath($token);
    if ($path == false) {
        $root = $apath;
    } else {
        $root = rtrim($apath, '/') . $path;
    }
    $r = OC_Gallery_Album::find($owner, null, $root);
    $albums = array();
    $photos = array();
    $albumId = -1;
    if ($row = $r->fetchRow()) {
        $albumId = $row['album_id'];
    }
    if ($albumId != -1) {
        if (OC_Gallery_Sharing::isRecursive($token)) {
            $r = OC_Gallery_Album::find($owner, null, null, $root);
            while ($row = $r->fetchRow()) {
                $albums[] = $row['album_name'];
            }
        }
        $r = OC_Gallery_Photo::find($albumId);
        while ($row = $r->fetchRow()) {
            $photos[] = $row['file_path'];
        }
    }
    OCP\JSON::success(array('albums' => $albums, 'photos' => $photos));
}