gallery sharing, experimental version
This commit is contained in:
parent
e0cbefc727
commit
cbdcb68c2b
|
@ -111,9 +111,48 @@ function handleGetGallery($path) {
|
||||||
$p[] = utf8_encode($r['file_path']);
|
$p[] = utf8_encode($r['file_path']);
|
||||||
}
|
}
|
||||||
|
|
||||||
OC_JSON::success(array('albums'=>$a, 'photos'=>$p));
|
$r = OC_Gallery_Sharing::getEntryByAlbumId($album_details['album_id']);
|
||||||
|
$shared = false;
|
||||||
|
$recursive = false;
|
||||||
|
$token = '';
|
||||||
|
if ($row = $r->fetchRow()) {
|
||||||
|
$shared = true;
|
||||||
|
$recursive = ($row['recursive'] == 1)? true : false;
|
||||||
|
$token = $row['token'];
|
||||||
|
}
|
||||||
|
|
||||||
|
OC_JSON::success(array('albums'=>$a, 'photos'=>$p, 'shared' => $shared, 'recursive' => $recursive, 'token' => $token));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleShare($path, $share, $recursive) {
|
||||||
|
$recursive = $recursive == 'true' ? 1 : 0;
|
||||||
|
$owner = OC_User::getUser();
|
||||||
|
$r = OC_Gallery_Album::find($owner, null, $path);
|
||||||
|
if ($row = $r->fetchRow()) {
|
||||||
|
$albumId = $row['album_id'];
|
||||||
|
} else {
|
||||||
|
OC_JSON::error(array('cause' => 'Couldn\'t find requested gallery'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($share == false) {
|
||||||
|
OC_Gallery_Sharing::remove($albumId);
|
||||||
|
OC_JSON::success(array('sharing' => false));
|
||||||
|
} else { // share, yeah \o/
|
||||||
|
$r = OC_Gallery_Sharing::getEntryByAlbumId($albumId);
|
||||||
|
if (($row = $r->fetchRow())) { // update entry
|
||||||
|
OC_Gallery_Sharing::updateSharingByToken($row['token'], $recursive);
|
||||||
|
OC_JSON::success(array('sharing' => true, 'token' => $row['token'], 'recursive' => $recursive == 1 ? true : false ));
|
||||||
|
} else { // and new sharing entry
|
||||||
|
$date = new DateTime();
|
||||||
|
$token = md5($owner . $date->getTimestamp());
|
||||||
|
OC_Gallery_Sharing::addShared($token, intval($albumId), $recursive);
|
||||||
|
OC_JSON::success(array('sharing' => true, 'token' => $token, 'recursive' => $recursive == 1 ? true : false ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($_GET['operation']) {
|
if ($_GET['operation']) {
|
||||||
switch($_GET['operation']) {
|
switch($_GET['operation']) {
|
||||||
case 'rename':
|
case 'rename':
|
||||||
|
@ -136,6 +175,9 @@ if ($_GET['operation']) {
|
||||||
case 'get_gallery':
|
case 'get_gallery':
|
||||||
handleGetGallery($_GET['path']);
|
handleGetGallery($_GET['path']);
|
||||||
break;
|
break;
|
||||||
|
case 'share':
|
||||||
|
handleShare($_GET['path'], $_GET['share'] == 'true' ? true : false, $_GET['recursive']);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
OC_JSON::error(array('cause' => 'Unknown operation'));
|
OC_JSON::error(array('cause' => 'Unknown operation'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ownCloud - gallery application
|
||||||
|
*
|
||||||
|
* @author Bartek Przybylski
|
||||||
|
* @copyright 2012 Bartek Przybylski bartek@alefzero.eu
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This library 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 AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('../../../lib/base.php');
|
||||||
|
|
||||||
|
if (!isset($_GET['token']) || !isset($_GET['operation'])) {
|
||||||
|
OC_JSON::error(array('cause' => 'Not enought arguments'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$operation = $_GET['operation'];
|
||||||
|
$token = $_GET['token'];
|
||||||
|
|
||||||
|
if (!OC_Gallery_Sharing::isTokenValid($token)) {
|
||||||
|
OC_JSON::error(array('cause' => 'Given token is not valid'));
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
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'];
|
||||||
|
}
|
||||||
|
|
||||||
|
OC_JSON::success(array('albums' => $albums, 'photos' => $photos));
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleGetThumbnail($token, $imgpath) {
|
||||||
|
$owner = OC_Gallery_Sharing::getTokenOwner($token);
|
||||||
|
$image = OC_Gallery_Photo::getThumbnail($imgpath, $owner);
|
||||||
|
if ($image) {
|
||||||
|
OC_Response::enableCaching(3600 * 24); // 24 hour
|
||||||
|
$image->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleGetAlbumThumbnail($token, $albumname)
|
||||||
|
{
|
||||||
|
$owner = OC_Gallery_Sharing::getTokenOwner($token);
|
||||||
|
$file = OC_Config::getValue("datadirectory").'/'. $owner .'/gallery/'.$albumname.'.png';
|
||||||
|
$image = new OC_Image($file);
|
||||||
|
if ($image->valid()) {
|
||||||
|
$image->centerCrop();
|
||||||
|
$image->resize(200);
|
||||||
|
$image->fixOrientation();
|
||||||
|
OC_Response::enableCaching(3600 * 24); // 24 hour
|
||||||
|
$image->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleGetPhoto($token, $photo) {
|
||||||
|
$owner = OC_Gallery_Sharing::getTokenOwner($token);
|
||||||
|
if (OC_User::isLoggedIn())
|
||||||
|
$file = OC::$CONFIG_DATADIRECTORY.urldecode($photo);
|
||||||
|
else
|
||||||
|
$file = OC::$CONFIG_DATADIRECTORY.'/'.$owner.'/files'.urldecode($photo);
|
||||||
|
header('Content-Type: '.OC_Image::getMimeTypeForFile($file));
|
||||||
|
OC_Response::sendFile($file);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($operation) {
|
||||||
|
case 'get_gallery':
|
||||||
|
handleGetGallery($token, isset($_GET['path'])? $_GET['path'] : false);
|
||||||
|
break;
|
||||||
|
case 'get_thumbnail':
|
||||||
|
handleGetThumbnail($token, urldecode($_GET['img']));
|
||||||
|
break;
|
||||||
|
case 'get_album_thumbnail':
|
||||||
|
handleGetAlbumThumbnail($token, urldecode($_GET['albumname']));
|
||||||
|
break;
|
||||||
|
case 'get_photo':
|
||||||
|
handleGetPhoto($token, urldecode($_GET['photo']));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
OC::$CLASSPATH['OC_Gallery_Album'] = 'apps/gallery/lib/album.php';
|
OC::$CLASSPATH['OC_Gallery_Album'] = 'apps/gallery/lib/album.php';
|
||||||
OC::$CLASSPATH['OC_Gallery_Photo'] = 'apps/gallery/lib/photo.php';
|
OC::$CLASSPATH['OC_Gallery_Photo'] = 'apps/gallery/lib/photo.php';
|
||||||
OC::$CLASSPATH['OC_Gallery_Scanner'] = 'apps/gallery/lib/scanner.php';
|
OC::$CLASSPATH['OC_Gallery_Scanner'] = 'apps/gallery/lib/scanner.php';
|
||||||
|
OC::$CLASSPATH['OC_Gallery_Sharing'] = 'apps/gallery/lib/sharing.php';
|
||||||
OC::$CLASSPATH['OC_Gallery_Hooks_Handlers'] = 'apps/gallery/lib/hooks_handlers.php';
|
OC::$CLASSPATH['OC_Gallery_Hooks_Handlers'] = 'apps/gallery/lib/hooks_handlers.php';
|
||||||
|
|
||||||
$l = new OC_L10N('gallery');
|
$l = new OC_L10N('gallery');
|
||||||
|
|
|
@ -67,4 +67,28 @@
|
||||||
</field>
|
</field>
|
||||||
</declaration>
|
</declaration>
|
||||||
</table>
|
</table>
|
||||||
|
<table>
|
||||||
|
<name>*dbprefix*gallery_sharing</name>
|
||||||
|
<declaration>
|
||||||
|
<field>
|
||||||
|
<name>token</name>
|
||||||
|
<type>text</type>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
<length>64</length>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>gallery_id</name>
|
||||||
|
<type>integer</type>
|
||||||
|
<default>0</default>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
<length>4</length>
|
||||||
|
</field>
|
||||||
|
<field>
|
||||||
|
<name>recursive</name>
|
||||||
|
<type>integer</type>
|
||||||
|
<notnull>true</notnull>
|
||||||
|
<length>1</length>
|
||||||
|
</field>
|
||||||
|
</declaration>
|
||||||
|
</table>
|
||||||
</database>
|
</database>
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
body { background-color: #eee; margin: 0; padding: 0;}
|
||||||
|
#gallery_list { height: 100%; width: 80%; background-color: white; margin: 0 auto; box-shadow: 0 0 8px #888; }
|
||||||
|
div.gallery_box { width: 200px; position:relative; text-align: center; border: 0; display: inline-block; margin: 5pt; vertical-align: top; padding: 5px 5px 5px 5px; position: relative; cursor: pointer; -webkit-transition: color 0.5s ease-in-out; -o-transition: color 0.5s ease-in-out; -moz-transition: color 0.5s ease-in-out;color: #BBB;}
|
||||||
|
div.gallery_box:hover { color: black; }
|
||||||
|
div.gallery_box h1 {font-size: 17px; font-weight: normal;}
|
||||||
|
div#breadcrumb { border: 0; width: 70%; margin: 0 auto; padding: 25px 0; font-family: Verdana; text-align: center;}
|
||||||
|
span.breadcrumbelement { margin: 10px; margin-right: 0; cursor: pointer;}
|
||||||
|
span.inside { background-image: url('../img/breadcrumb.png'); padding-left: 20px; background-position: left; background-repeat: no-repeat;}
|
|
@ -16,3 +16,5 @@ div.gallery_control_overlay a { color:white; }
|
||||||
#g-settings {position: absolute; left 13.5em; top: 0;}
|
#g-settings {position: absolute; left 13.5em; top: 0;}
|
||||||
input[type=button] { -webkit-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out; -o-transition: opacity 0.5s ease-in-out; opacity: 1}
|
input[type=button] { -webkit-transition: opacity 0.5s ease-in-out; -moz-transition: opacity 0.5s ease-in-out; -o-transition: opacity 0.5s ease-in-out; opacity: 1}
|
||||||
input[type=button]:disabled { opacity: 0.5 }
|
input[type=button]:disabled { opacity: 0.5 }
|
||||||
|
.ui-dialog tr {background-color: #eee;}
|
||||||
|
.ui-dialog input {width: 90%;}
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 220 B |
|
@ -4,7 +4,7 @@
|
||||||
* ownCloud - gallery application
|
* ownCloud - gallery application
|
||||||
*
|
*
|
||||||
* @author Bartek Przybylski
|
* @author Bartek Przybylski
|
||||||
* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
|
* @copyright 2012 Bartek Przybylski bartek@alefzero.eu
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
@ -29,9 +29,6 @@ OC_App::setActiveNavigationEntry( 'gallery_index' );
|
||||||
|
|
||||||
if (!file_exists(OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery')) {
|
if (!file_exists(OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery')) {
|
||||||
mkdir(OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery');
|
mkdir(OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery');
|
||||||
$f = fopen(OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/.htaccess', 'w');
|
|
||||||
fwrite($f, "allow from all");
|
|
||||||
fclose($f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($_GET['view'])) {
|
if (!isset($_GET['view'])) {
|
||||||
|
|
|
@ -30,17 +30,57 @@ function albumClick(title) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shareGallery() {
|
||||||
|
var existing_token = '';
|
||||||
|
if (Albums.token)
|
||||||
|
existing_token = document.location.origin + OC.linkTo('gallery', 'sharing.php') + '?token=' + Albums.token;
|
||||||
|
var form_fields = [{text: 'Share', name: 'share', type: 'checkbox', value: Albums.shared},
|
||||||
|
{text: 'Share recursive', name: 'recursive', type: 'checkbox', value: Albums.recursive},
|
||||||
|
{text: 'Shared gallery address', name: 'address', type: 'text', value: existing_token}];
|
||||||
|
OC.dialogs.form(form_fields, t('gallery', 'Share gallery'), function(values){
|
||||||
|
var p = '';
|
||||||
|
for (var i in paths) p += '/'+paths[i];
|
||||||
|
if (p == '') p = '/';
|
||||||
|
$.getJSON(OC.filePath('gallery', 'ajax', 'galleryOp.php'), {operation: 'share', path: p, share: values[0].value, recursive: values[1].value}, function(r) {
|
||||||
|
if (r.status == 'success') {
|
||||||
|
Albums.shared = r.sharing;
|
||||||
|
if (Albums.shared) {
|
||||||
|
Albums.token = r.token;
|
||||||
|
Albums.recursive = r.recursive;
|
||||||
|
} else {
|
||||||
|
Albums.token = '';
|
||||||
|
Albums.recursive = false;
|
||||||
|
}
|
||||||
|
var actual_addr = '';
|
||||||
|
if (Albums.token)
|
||||||
|
actual_addr = document.location.origin + OC.linkTo('gallery', 'sharing.php') + '?token=' + Albums.token;
|
||||||
|
$('input[name="address"]').val(actual_addr);
|
||||||
|
} else {
|
||||||
|
OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Internal error'));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function albumClickHandler(r) {
|
function albumClickHandler(r) {
|
||||||
Albums.photos = [];
|
Albums.photos = [];
|
||||||
Albums.albums = [];
|
Albums.albums = [];
|
||||||
if (r.status == 'success') {
|
if (r.status == 'success') {
|
||||||
for (var i in r.albums) {
|
for (var i in r.albums) {
|
||||||
var a = r.albums[i];
|
var a = r.albums[i];
|
||||||
Albums.add(a.name, a.numOfItems,a.path);
|
Albums.add(a.name, a.numOfItems, a.path, a.shared, a.recursive, a.token);
|
||||||
}
|
}
|
||||||
for (var i in r.photos) {
|
for (var i in r.photos) {
|
||||||
Albums.photos.push(r.photos[i]);
|
Albums.photos.push(r.photos[i]);
|
||||||
}
|
}
|
||||||
|
Albums.shared = r.shared;
|
||||||
|
if (Albums.shared) {
|
||||||
|
Albums.recursive = r.recursive;
|
||||||
|
Albums.token = r.token;
|
||||||
|
} else {
|
||||||
|
Albums.recursive = false;
|
||||||
|
Albums.token = '';
|
||||||
|
}
|
||||||
var targetDiv = document.getElementById('gallery_list');
|
var targetDiv = document.getElementById('gallery_list');
|
||||||
if (targetDiv) {
|
if (targetDiv) {
|
||||||
$(targetDiv).html('');
|
$(targetDiv).html('');
|
||||||
|
@ -54,7 +94,7 @@ function albumClickHandler(r) {
|
||||||
OC.dialogs.alert(t('gallery', 'Error: no such layer `gallery_list`'), t('gallery', 'Internal error'));
|
OC.dialogs.alert(t('gallery', 'Error: no such layer `gallery_list`'), t('gallery', 'Internal error'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
OC.dialogs.alert(t('gallery', 'Error: ') + r.message, t('gallery', 'Internal error'));
|
OC.dialogs.alert(t('gallery', 'Error: ') + r.cause, t('gallery', 'Internal error'));
|
||||||
}
|
}
|
||||||
$('#g-album-loading').hide();
|
$('#g-album-loading').hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,12 +8,15 @@ Albums={
|
||||||
// the album cover
|
// the album cover
|
||||||
albums:new Array(),
|
albums:new Array(),
|
||||||
photos:new Array(),
|
photos:new Array(),
|
||||||
|
shared: false,
|
||||||
|
recursive: false,
|
||||||
|
token: '',
|
||||||
// add simply adds new album to internal structure
|
// add simply adds new album to internal structure
|
||||||
// however albums names must be unique so other
|
// however albums names must be unique so other
|
||||||
// album with the same name wont be insered,
|
// album with the same name wont be insered,
|
||||||
// and false will be returned
|
// and false will be returned
|
||||||
// true on success
|
// true on success
|
||||||
add: function(album_name, num,path) {
|
add: function(album_name, num, path) {
|
||||||
if (Albums.albums[album_name] != undefined) return false;
|
if (Albums.albums[album_name] != undefined) return false;
|
||||||
Albums.albums[album_name] = {name: album_name, numOfCovers: num, path:path};
|
Albums.albums[album_name] = {name: album_name, numOfCovers: num, path:path};
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
$(document).ready(function() {
|
||||||
|
$.getJSON('ajax/sharing.php', {operation: 'get_gallery', token: TOKEN}, albumClickHandler);
|
||||||
|
});
|
||||||
|
|
||||||
|
var paths = [];
|
||||||
|
var counter = 0;
|
||||||
|
|
||||||
|
function returnTo(num) {
|
||||||
|
while (num != counter) {
|
||||||
|
paths.pop();
|
||||||
|
$('.breadcrumbelement:last').remove();
|
||||||
|
counter--;
|
||||||
|
}
|
||||||
|
path = '';
|
||||||
|
for (var e in paths) path += '/' + paths[e];
|
||||||
|
$.getJSON('ajax/sharing.php', {operation: 'get_gallery', token: TOKEN, path: path}, function(r) {
|
||||||
|
albumClickHandler(r);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function albumClickHandler(r) {
|
||||||
|
var element = $('div#gallery_list');
|
||||||
|
element.html('');
|
||||||
|
var album_template = '<div class="gallery_box"><div><a rel="images"><img src="ajax/sharing.php?token='+TOKEN+'&operation=get_album_thumbnail&albumname=IMGPATH"></a></div><h1></h1></div>';
|
||||||
|
|
||||||
|
for (var i in r.albums) {
|
||||||
|
var a = r.albums[i];
|
||||||
|
var local = $(album_template.replace('IMGPATH', encodeURIComponent(a)));
|
||||||
|
local.attr('title', a);
|
||||||
|
$('h1', local).html(a);
|
||||||
|
element.append(local);
|
||||||
|
}
|
||||||
|
|
||||||
|
$('div.gallery_box').each(function(i, element) {
|
||||||
|
$(element).click(function() {
|
||||||
|
paths.push($(this).attr('title'));
|
||||||
|
path = '';
|
||||||
|
for (var e in paths) path += '/' + paths[e];
|
||||||
|
$.getJSON('ajax/sharing.php', {operation: 'get_gallery', token: TOKEN, path: path}, function(r) {
|
||||||
|
var name = paths[paths.length-1];
|
||||||
|
counter++;
|
||||||
|
var d = '<span class="breadcrumbelement" onclick="javascript:returnTo('+counter+');return false;">'+name+'</span>';
|
||||||
|
d = $(d).addClass('inside');
|
||||||
|
$('#breadcrumb').append(d);
|
||||||
|
albumClickHandler(r);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var pat = '';
|
||||||
|
for (var a in paths) pat += '/'+paths[a];
|
||||||
|
var photo_template = '<div class="gallery_box"><div><a rel="images" href="*HREF*" target="_blank"><img src="ajax/sharing.php?token='+TOKEN+'&operation=get_thumbnail&img=IMGPATH"></a></div></div>';
|
||||||
|
for (var a in r.photos) {
|
||||||
|
var local = photo_template.replace('IMGPATH', encodeURIComponent(r.photos[a])).replace('*HREF*', 'ajax/sharing.php?token='+TOKEN+'&operation=get_photo&photo='+encodeURIComponent(r.photos[a]));
|
||||||
|
element.append(local);
|
||||||
|
}
|
||||||
|
}
|
|
@ -79,7 +79,7 @@ class OC_Gallery_Album {
|
||||||
$sql .= ' AND parent_path = ?';
|
$sql .= ' AND parent_path = ?';
|
||||||
$args[] = $parent;
|
$args[] = $parent;
|
||||||
}
|
}
|
||||||
$order = OC_Preferences::getValue(OC_User::getUser(), 'gallery', 'order', 'ASC');
|
$order = OC_Preferences::getValue($owner, 'gallery', 'order', 'ASC');
|
||||||
$sql .= ' ORDER BY album_name ' . $order;
|
$sql .= ' ORDER BY album_name ' . $order;
|
||||||
|
|
||||||
$stmt = OC_DB::prepare($sql);
|
$stmt = OC_DB::prepare($sql);
|
||||||
|
|
|
@ -66,8 +66,9 @@ class OC_Gallery_Photo {
|
||||||
$stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath));
|
$stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getThumbnail($image_name) {
|
public static function getThumbnail($image_name, $owner = null) {
|
||||||
$save_dir = OC_Config::getValue("datadirectory").'/'. OC_User::getUser() .'/gallery/';
|
if (!$owner) $owner = OC_User::getUser();
|
||||||
|
$save_dir = OC_Config::getValue("datadirectory").'/'. $owner .'/gallery/';
|
||||||
$save_dir .= dirname($image_name). '/';
|
$save_dir .= dirname($image_name). '/';
|
||||||
$image_path = $image_name;
|
$image_path = $image_name;
|
||||||
$thumb_file = $save_dir . basename($image_name);
|
$thumb_file = $save_dir . basename($image_name);
|
||||||
|
|
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ownCloud - gallery application
|
||||||
|
*
|
||||||
|
* @author Bartek Przybylski
|
||||||
|
* @copyright 2012 Bartek Przybylski bartek@alefzero.eu
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This library 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 AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
class OC_Gallery_Sharing {
|
||||||
|
private static function getEntries($token) {
|
||||||
|
$sql = 'SELECT * FROM *PREFIX*gallery_sharing WHERE token = ?';
|
||||||
|
$stmt = OC_DB::prepare($sql);
|
||||||
|
return $stmt->execute(array($token));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isTokenValid($token) {
|
||||||
|
$r = self::getEntries($token);
|
||||||
|
$row = $r->fetchRow();
|
||||||
|
return $row != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function isRecursive($token) {
|
||||||
|
$r = self::getEntries($token);
|
||||||
|
if ($row = $r->fetchRow()) return $row['recursive'] == 1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getTokenOwner($token) {
|
||||||
|
$r = self::getEntries($token);
|
||||||
|
if ($row = $r->fetchRow()) {
|
||||||
|
$galleryId = $row['gallery_id'];
|
||||||
|
$sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE album_id = ?';
|
||||||
|
$stmt = OC_DB::prepare($sql);
|
||||||
|
$r = $stmt->execute(array($galleryId));
|
||||||
|
if ($row = $r->fetchRow())
|
||||||
|
return $row['uid_owner'];
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPath($token) {
|
||||||
|
$r = self::getEntries($token);
|
||||||
|
if ($row = $r->fetchRow()) {
|
||||||
|
$galleryId = $row['gallery_id'];
|
||||||
|
$sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE album_id = ?';
|
||||||
|
$stmt = OC_DB::prepare($sql);
|
||||||
|
$r = $stmt->execute(array($galleryId));
|
||||||
|
if ($row = $r->fetchRow())
|
||||||
|
return $row['album_path'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function updateSharingByToken($token, $recursive) {
|
||||||
|
$stmt = OC_DB::prepare('UPDATE *PREFIX*gallery_sharing SET recursive = ? WHERE token = ?');
|
||||||
|
$stmt->execute(array($recursive, $token));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEntryByAlbumId($album_id) {
|
||||||
|
$stmt = OC_DB::prepare('SELECT * FROM *PREFIX*gallery_sharing WHERE gallery_id = ?');
|
||||||
|
return $stmt->execute(array($album_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function addShared($token, $albumId, $recursive) {
|
||||||
|
$sql = 'INSERT INTO *PREFIX*gallery_sharing (token, gallery_id, recursive) VALUES (?, ?, ?)';
|
||||||
|
$stmt = OC_DB::prepare($sql);
|
||||||
|
$stmt->execute(array($token, $albumId, $recursive));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function remove($albumId) {
|
||||||
|
$stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_sharing WHERE gallery_id = ?');
|
||||||
|
$stmt->execute(array($albumId));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ownCloud - gallery application
|
||||||
|
*
|
||||||
|
* @author Bartek Przybylski
|
||||||
|
* @copyright 2012 Bartek Przybylski bartek@alefzero.eu
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 3 of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This library 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 AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!isset($_GET['token']) || empty($_GET['token'])) {
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
require_once('../../lib/base.php');
|
||||||
|
|
||||||
|
OC_Util::checkAppEnabled('gallery');
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!doctype html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="css/sharing.css" type="text/css"/>
|
||||||
|
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
|
||||||
|
<script src="js/sharing.js" type="text/javascript"></script>
|
||||||
|
<script>
|
||||||
|
var TOKEN = '<?php echo $_GET['token']; ?>';
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="breadcrumb"><span class="breadcrumbelement" onclick="javascript:returnTo(0);return false;">Shared gallery</span></div>
|
||||||
|
<div id="gallery_list"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -14,7 +14,8 @@ $l = new OC_L10N('gallery');
|
||||||
<div id="scan">
|
<div id="scan">
|
||||||
<div id="scanprogressbar"></div>
|
<div id="scanprogressbar"></div>
|
||||||
<input type="button" class="start" value="<?php echo $l->t('Rescan');?>" onclick="javascript:scanForAlbums();" />
|
<input type="button" class="start" value="<?php echo $l->t('Rescan');?>" onclick="javascript:scanForAlbums();" />
|
||||||
<input type="button" class="stop" style="display:none" value="<?php echo $l->t('Stop');?>" onclick="javascript:Scanner.stop();" />
|
<input type="button" class="stop" style="display:none" value="<?php echo $l->t('Stop');?>" onclick="javascript:Scanner.stop();" />
|
||||||
|
<input type="button" id="g-share-button" value="<?php echo $l->t('Share'); ?>" onclick="javascript:shareGallery();" />
|
||||||
<input type="button" id="g-settings-button" value="<?php echo $l->t('Settings');?>" onclick="javascript:settings();"/>
|
<input type="button" id="g-settings-button" value="<?php echo $l->t('Settings');?>" onclick="javascript:settings();"/>
|
||||||
</div>
|
</div>
|
||||||
<div id="g-album-navigation">
|
<div id="g-album-navigation">
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* ownCloud
|
* ownCloud
|
||||||
*
|
*
|
||||||
* @author Bartek Przybylski
|
* @author Bartek Przybylski
|
||||||
* @copyright 2012 Bartek Przybylski bart.p.pl@gmail.com
|
* @copyright 2012 Bartek Przybylski bartek@alefzero.eu
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
|
@ -66,7 +66,7 @@ OCdialogs = {
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* prompt user for input with custom form
|
* prompt user for input with custom form
|
||||||
* fields should be passed in following format: [{text:'prompt text', name:'return name', type:'input type'},...]
|
* fields should be passed in following format: [{text:'prompt text', name:'return name', type:'input type', value: 'dafault value'},...]
|
||||||
* @param fields to display
|
* @param fields to display
|
||||||
* @param title dialog title
|
* @param title dialog title
|
||||||
* @param callback which will be triggered when user press OK (user answers will be passed to callback in following format: [{name:'return name', value: 'user value'},...])
|
* @param callback which will be triggered when user press OK (user answers will be passed to callback in following format: [{name:'return name', value: 'user value'},...])
|
||||||
|
@ -76,8 +76,15 @@ OCdialogs = {
|
||||||
for (var a in fields) {
|
for (var a in fields) {
|
||||||
content += '<tr><td>'+fields[a].text+'</td><td>';
|
content += '<tr><td>'+fields[a].text+'</td><td>';
|
||||||
var type=fields[a].type;
|
var type=fields[a].type;
|
||||||
if (type == 'text' || type == 'checkbox' || type == 'password')
|
if (type == 'text' || type == 'checkbox' || type == 'password') {
|
||||||
content += '<input type="'+type+'" name="'+fields[a].name+'">';
|
content += '<input type="'+type+'" name="'+fields[a].name+'"';
|
||||||
|
if (type == 'checkbox') {
|
||||||
|
if (fields[a].value != undefined && fields[a].value == true) {
|
||||||
|
content += ' checked="checked">';
|
||||||
|
} else content += '>';
|
||||||
|
} else if (type == 'text' || type == 'password' && fields[a].value)
|
||||||
|
content += ' value="'+fields[a].value+'">';
|
||||||
|
}
|
||||||
content += "</td></tr>"
|
content += "</td></tr>"
|
||||||
}
|
}
|
||||||
content += "</table>";
|
content += "</table>";
|
||||||
|
@ -112,7 +119,8 @@ OCdialogs = {
|
||||||
b[0] = {text: t('dialogs', 'Ok'), click: f};
|
b[0] = {text: t('dialogs', 'Ok'), click: f};
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$(c_id).dialog({width: 4*$(document).width()/9, height: $(d).height() + 150, modal: false, buttons: b});
|
var possible_height = ($('tr', d).size()+1)*30;
|
||||||
|
$(c_id).dialog({width: 4*$(document).width()/9, height: possible_height + 120, modal: false, buttons: b});
|
||||||
OCdialogs.dialogs_counter++;
|
OCdialogs.dialogs_counter++;
|
||||||
},
|
},
|
||||||
// dialogs buttons types
|
// dialogs buttons types
|
||||||
|
@ -127,7 +135,7 @@ OCdialogs = {
|
||||||
dialogs_counter: 0,
|
dialogs_counter: 0,
|
||||||
determineValue: function(element) {
|
determineValue: function(element) {
|
||||||
switch ($(element).attr('type')) {
|
switch ($(element).attr('type')) {
|
||||||
case 'checkbox': return $(element).attr('checked') != undefined;
|
case 'checkbox': return element.checked;
|
||||||
}
|
}
|
||||||
return $(element).val();
|
return $(element).val();
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue