aboutsummaryrefslogtreecommitdiffstats
path: root/include/photos.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-05-29 19:47:01 -0700
committerfriendica <info@friendica.com>2013-05-29 19:47:01 -0700
commitfadf2c3ea6e363b96f5aa60d163489fe3886b2c3 (patch)
tree50a92ee66dfeeff5c16a1dcca6289b5695b800ba /include/photos.php
parentcd9ea115f85fd5bc4d55cec06a480cc21d721e15 (diff)
downloadvolse-hubzilla-fadf2c3ea6e363b96f5aa60d163489fe3886b2c3.tar.gz
volse-hubzilla-fadf2c3ea6e363b96f5aa60d163489fe3886b2c3.tar.bz2
volse-hubzilla-fadf2c3ea6e363b96f5aa60d163489fe3886b2c3.zip
add photos and albums enumeration to Red API (will allow us to export either all our photos or individual albums using a script)
Diffstat (limited to 'include/photos.php')
-rw-r--r--include/photos.php39
1 files changed, 36 insertions, 3 deletions
diff --git a/include/photos.php b/include/photos.php
index 137123882..5568a4257 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -250,13 +250,16 @@ function photos_albums_list($channel,$observer) {
// add various encodings to the array so we can just loop through and pick them out in a template
+ $ret = array('success' => false);
+
if($albums) {
+ $ret['success'] = true;
foreach($albums as $k => $album) {
- $albums[$k]['urlencode'] = urlencode($album['album']);
- $albums[$k]['bin2hex'] = bin2hex($album['album']);
+ $entry = array('text' => $album['album'], 'urlencode' => urlencode($album['album']),'bin2hex' => bin2hex($album['album']));
+ $ret[] = $entry;
}
}
- return $albums;
+ return $ret;
}
@@ -280,6 +283,36 @@ function photos_album_widget($channelx,$observer,$albums = null) {
return $o;
}
+
+function photos_list_photos($channel,$observer,$album = '') {
+
+ $channel_id = $channel['channel_id'];
+ $observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
+
+ if(! perm_is_allowed($channel_id,$observer_xchan,'view_photos'))
+ return false;
+
+ $sql_extra = permissions_sql($channel_id);
+
+ if($album)
+ $sql_extra .= " and album = '" . protect_sprintf(dbesc($album)) . "' ";
+
+ $ret = array('success' => false);
+
+ $r = q("select resource_id, created, edited, title, `desc`, album, filename, `type`, height, width, `size`, `scale`, profile, allow_cid, allow_gid, deny_cid, deny_gid from photo where uid = %d $sql_extra ",
+ intval($channel_id)
+ );
+
+ if($r) {
+ $ret['success'] = true;
+ $ret['photos'] = $r;
+ }
+
+ return $ret;
+}
+
+
+
function photos_album_exists($channel_id,$album) {
$r = q("SELECT id from photo where album = '%s' and uid = %d limit 1",
dbesc($album),