From 0d601563d02d7e9b7414586486f1623a93cf958b Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Wed, 4 Mar 2015 00:03:19 +0100 Subject: Some cleanups and documentation. Fixed some wrong variable names. Initialized some variables before using them. Removed some checks for STATUSNET_PRIVACY_COMPATIBILITY in include/security.php as it does not seem to be defined anywhere. --- include/photos.php | 75 +++++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 29 deletions(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index ee94bac60..794ff7748 100644 --- a/include/photos.php +++ b/include/photos.php @@ -53,7 +53,7 @@ function photo_upload($channel, $observer, $args) { $visible = 1; else $visible = 0; - + if(intval($args['not_visible']) || $args['not_visible'] === 'true') $visible = 0; @@ -98,7 +98,6 @@ function photo_upload($channel, $observer, $args) { logger('photo_upload: received file: ' . $filename . ' as ' . $src . ' ('. $type . ') ' . $filesize . ' bytes', LOGGER_DEBUG); - $maximagesize = get_config('system','maximagesize'); if(($maximagesize) && ($filesize > $maximagesize)) { @@ -133,7 +132,6 @@ function photo_upload($channel, $observer, $args) { call_hooks('photo_post_end',$ret); return $ret; } - $ph = photo_factory($imagedata, $type); @@ -185,7 +183,7 @@ function photo_upload($channel, $observer, $args) { $r1 = $ph->save($p); if(! $r1) $errors = true; - + if(($width > 640 || $height > 640) && (! $errors)) { $ph->scaleImage(640); $p['scale'] = 1; @@ -204,7 +202,6 @@ function photo_upload($channel, $observer, $args) { $errors = true; } - if($errors) { q("delete from photo where resource_id = '%s' and uid = %d", dbesc($photo_hash), @@ -220,16 +217,15 @@ function photo_upload($channel, $observer, $args) { $width_x_height = $ph->getWidth() . 'x' . $ph->getHeight(); - $basename = basename($filename); $mid = item_message_id(); // Create item container $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; - $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); + $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); $title = ''; $mid = item_message_id(); - + $arr = array(); $arr['aid'] = $account_id; @@ -254,7 +250,7 @@ function photo_upload($channel, $observer, $args) { // We should also put a width_x_height on large photos. Left as an exercise for // devs looking fo simple stuff to fix. - $larger = feature_enabled($channel['channel_id'],'large_photos'); + $larger = feature_enabled($channel['channel_id'], 'large_photos'); if($larger) { $tag = '[zmg]'; if($r2) @@ -273,7 +269,7 @@ function photo_upload($channel, $observer, $args) { $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' . $tag . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]' . '[/zrl]'; - + $result = item_store($arr); $item_id = $result['item_id']; @@ -291,15 +287,23 @@ function photo_upload($channel, $observer, $args) { return $ret; } - - - -function photos_albums_list($channel,$observer) { +/** + * @brief Returns a list with all photo albums observer is allowed to see. + * + * Returns an associative array with all albums where observer has permissions. + * + * @param array $channel + * @param array $observer + * @return bool|array false if no view_photos permission or an array + * * success (bool) + * * albums (array) + */ +function photos_albums_list($channel, $observer) { $channel_id = $channel['channel_id']; $observer_xchan = (($observer) ? $observer['xchan_hash'] : ''); - if(! perm_is_allowed($channel_id,$observer_xchan,'view_photos')) + if(! perm_is_allowed($channel_id, $observer_xchan, 'view_photos')) return false; // FIXME - create a permissions SQL which works on arbitrary observers and channels, regardless of login or web status @@ -310,7 +314,6 @@ function photos_albums_list($channel,$observer) { intval($channel_id), intval(PHOTO_NORMAL), intval(PHOTO_PROFILE) - ); // add various encodings to the array so we can just loop through and pick them out in a template @@ -330,8 +333,8 @@ function photos_albums_list($channel,$observer) { $ret['albums'][] = $entry; } } - return $ret; + return $ret; } function photos_album_widget($channelx,$observer,$albums = null) { @@ -395,17 +398,32 @@ function photos_list_photos($channel,$observer,$album = '') { return $ret; } - - -function photos_album_exists($channel_id,$album) { - $r = q("SELECT id from photo where album = '%s' and uid = %d limit 1", +/** + * @brief Check if given photo album exists in channel. + * + * @param int $channel_id id of the channel + * @param string $album name of the album + * @return boolean + */ +function photos_album_exists($channel_id, $album) { + $r = q("SELECT id FROM photo WHERE album = '%s' AND uid = %d limit 1", dbesc($album), intval($channel_id) ); + return (($r) ? true : false); } -function photos_album_rename($channel_id,$oldname,$newname) { +/** + * @brief Renames a photo album in a channel. + * + * @todo Do we need to check if new album name already exists? + * @param int $channel_id id of the channel + * @param string $oldname The name of the album to rename + * @param string $newname The new name of the album + * @return bool|array + */ +function photos_album_rename($channel_id, $oldname, $newname) { return q("UPDATE photo SET album = '%s' WHERE album = '%s' AND uid = %d", dbesc($newname), dbesc($oldname), @@ -437,8 +455,8 @@ function photos_album_get_db_idstr($channel_id,$album,$remote_xchan = '') { $str = implode(',',$arr); return $str; } - return false; + return false; } function photos_create_item($channel, $creator_hash, $photo, $visible = false) { @@ -446,11 +464,10 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { // Create item container $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; - $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); + $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); - $title = ''; $mid = item_message_id(); - + $arr = array(); $arr['aid'] = $channel['channel_account_id']; @@ -470,13 +487,13 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { $arr['deny_gid'] = $photo['deny_gid']; $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid']; - + $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]' . '[/zrl]'; - + $result = item_store($arr); $item_id = $result['item_id']; - return $item_id; + return $item_id; } -- cgit v1.2.3 From 76eb0a7e5606d61153b199094482c4c55685a035 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 4 Mar 2015 18:55:17 -0800 Subject: Deprecate the "wall uploads" photo album. Photo uploads (from any source) with no album specified will go now into an album based on YYYY-MM. --- include/photos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 794ff7748..cd753ffea 100644 --- a/include/photos.php +++ b/include/photos.php @@ -31,7 +31,7 @@ function photo_upload($channel, $observer, $args) { if($newalbum) $album = $newalbum; else - $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y'); + $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y-m'); } /** -- cgit v1.2.3 From 5b35f1e6c4fbf0fd941c6d292b9c9b5847b64d0b Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 10 Mar 2015 15:43:15 -0700 Subject: Change logic of "don't create a status post for this photo upload" and turn it into a bona-fide on/off toggle. This takes up one more vertical line, but we have it to spare, and the single button (while concise visually) provided no feedback of the current state, or indicate whether a second click toggled it. Some addons use this setting so addons will need to be pulled when this is pulled in order to remain in sync. --- include/photos.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index cd753ffea..4841e649d 100644 --- a/include/photos.php +++ b/include/photos.php @@ -54,8 +54,8 @@ function photo_upload($channel, $observer, $args) { else $visible = 0; - if(intval($args['not_visible']) || $args['not_visible'] === 'true') - $visible = 0; + if(intval($args['visible']) || $args['visible'] === 'true') + $visible = 1; $str_group_allow = perms2str(((is_array($args['group_allow'])) ? $args['group_allow'] : explode(',',$args['group_allow']))); $str_contact_allow = perms2str(((is_array($args['contact_allow'])) ? $args['contact_allow'] : explode(',',$args['contact_allow']))); -- cgit v1.2.3 From 0014cf4ff232328c3e3d0993eb8e9893a7c16f54 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 11 Mar 2015 00:21:57 -0700 Subject: skip trying to come up with an intelligent way to decide what photos should get a status post - leave it manual. --- include/photos.php | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 4841e649d..c2f5ed4ba 100644 --- a/include/photos.php +++ b/include/photos.php @@ -34,29 +34,11 @@ function photo_upload($channel, $observer, $args) { $album = datetime_convert('UTC',date_default_timezone_get(),'now', 'Y-m'); } - /** - * - * We create a wall item for every photo, but we don't want to - * overwhelm the data stream with a hundred newly uploaded photos. - * So we will make the first photo uploaded to this album in the last several hours - * visible by default, the rest will become visible over time when and if - * they acquire comments, likes, dislikes, and/or tags - * - */ - - $r = q("SELECT * FROM photo WHERE album = '%s' AND uid = %d AND created > %s - INTERVAL %s ", - dbesc($album), - intval($channel_id), - db_utcnow(), db_quoteinterval('3 HOUR') - ); - if((! $r) || ($album == t('Profile Photos'))) + if(intval($args['visible']) || $args['visible'] === 'true') $visible = 1; else $visible = 0; - if(intval($args['visible']) || $args['visible'] === 'true') - $visible = 1; - $str_group_allow = perms2str(((is_array($args['group_allow'])) ? $args['group_allow'] : explode(',',$args['group_allow']))); $str_contact_allow = perms2str(((is_array($args['contact_allow'])) ? $args['contact_allow'] : explode(',',$args['contact_allow']))); $str_group_deny = perms2str(((is_array($args['group_deny'])) ? $args['group_deny'] : explode(',',$args['group_deny']))); -- cgit v1.2.3 From 7c194c37b891f122740de52d154db0af612e0074 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Mar 2015 20:08:05 -0700 Subject: started to add the ability to geotag photos (default will be disabled) but my phone isn't outputting the GPS tags even after being explicitly enabled so I'll have to wait until I've got a device that I can reliably test against. --- include/photos.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index c2f5ed4ba..4b7809fc1 100644 --- a/include/photos.php +++ b/include/photos.php @@ -125,7 +125,9 @@ function photo_upload($channel, $observer, $args) { return $ret; } - $ph->orient($src); + $exif = $ph->orient($src); + + @unlink($src); $max_length = get_config('system','max_image_length'); -- cgit v1.2.3 From bc22df9057198018f9cc490d0e3e013692f52b90 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Mar 2015 22:06:03 -0700 Subject: display a map for photos if allowed. Note: there is a bug in that if the map div starts with display:none one needs to reload the frame or zoom in or they end up at minimum resolution. Still trying to sort this out. --- include/photos.php | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 4b7809fc1..4785e47c4 100644 --- a/include/photos.php +++ b/include/photos.php @@ -205,6 +205,17 @@ function photo_upload($channel, $observer, $args) { // Create item container + $lat = $lon = null; + + if($exif && $exif['GPS']) { + if(get_pconfig($channel_id,'system','allow_photo_location')) { + $lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPSLatitudeRef']); + $lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPSLongitudeRef']); + } + } + + + $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); $title = ''; @@ -212,6 +223,9 @@ function photo_upload($channel, $observer, $args) { $arr = array(); + if($lat && $lon) + $arr['coord'] = $lat . ' ' . $lon; + $arr['aid'] = $account_id; $arr['uid'] = $channel_id; $arr['mid'] = $mid; @@ -481,3 +495,30 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { return $item_id; } + + +function getGps($exifCoord, $hemi) { + + $degrees = count($exifCoord) > 0 ? gps2Num($exifCoord[0]) : 0; + $minutes = count($exifCoord) > 1 ? gps2Num($exifCoord[1]) : 0; + $seconds = count($exifCoord) > 2 ? gps2Num($exifCoord[2]) : 0; + + $flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1; + + return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600))); + +} + +function gps2Num($coordPart) { + + $parts = explode('/', $coordPart); + + if (count($parts) <= 0) + return 0; + + if (count($parts) == 1) + return $parts[0]; + + return floatval($parts[0]) / floatval($parts[1]); +} + -- cgit v1.2.3 From fab8209ebd4a052f8af5918de8603fd21a4bc7a6 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Mar 2015 00:33:43 -0700 Subject: turn photo location mapping into a feature --- include/photos.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 4785e47c4..4d3f4c755 100644 --- a/include/photos.php +++ b/include/photos.php @@ -208,7 +208,7 @@ function photo_upload($channel, $observer, $args) { $lat = $lon = null; if($exif && $exif['GPS']) { - if(get_pconfig($channel_id,'system','allow_photo_location')) { + if(feature_enabled($channel_id,'photo_location')) { $lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPSLatitudeRef']); $lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPSLongitudeRef']); } -- cgit v1.2.3 From 6b3afb5eecca2964222e8dc09ddfae86e802c2f4 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Mar 2015 00:53:24 -0700 Subject: get the correct hemisphere for geotagged photos --- include/photos.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index 4d3f4c755..c4d5a33aa 100644 --- a/include/photos.php +++ b/include/photos.php @@ -209,8 +209,8 @@ function photo_upload($channel, $observer, $args) { if($exif && $exif['GPS']) { if(feature_enabled($channel_id,'photo_location')) { - $lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPSLatitudeRef']); - $lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPSLongitudeRef']); + $lat = getGps($exif['GPS']['GPSLatitude'], $exif['GPS']['GPSLatitudeRef']); + $lon = getGps($exif['GPS']['GPSLongitude'], $exif['GPS']['GPSLongitudeRef']); } } -- cgit v1.2.3 From d0361582b0b620064aff90bf88f01d1072b308fe Mon Sep 17 00:00:00 2001 From: Klaus Weidenbach Date: Sun, 22 Mar 2015 00:06:08 +0100 Subject: Correcting reported Doxygen syntax warnings. Fixed wrong Doxygen syntax and add some of the available FIXME to Doxygen documentation. Updated Doxygen configuration to add also all capital letter tags. Adding some more Doxygen documentation. --- include/photos.php | 117 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 71 insertions(+), 46 deletions(-) (limited to 'include/photos.php') diff --git a/include/photos.php b/include/photos.php index c4d5a33aa..1672e310a 100644 --- a/include/photos.php +++ b/include/photos.php @@ -1,10 +1,21 @@ - false); @@ -18,12 +29,12 @@ function photo_upload($channel, $observer, $args) { call_hooks('photo_upload_begin', $args); - /** + /* * Determine the album to use */ - $album = $args['album']; - $newalbum = $args['newalbum']; + $album = $args['album']; + $newalbum = $args['newalbum']; logger('photo_upload: album= ' . $album . ' newalbum= ' . $newalbum , LOGGER_DEBUG); @@ -44,8 +55,7 @@ function photo_upload($channel, $observer, $args) { $str_group_deny = perms2str(((is_array($args['group_deny'])) ? $args['group_deny'] : explode(',',$args['group_deny']))); $str_contact_deny = perms2str(((is_array($args['contact_deny'])) ? $args['contact_deny'] : explode(',',$args['contact_deny']))); - - if($args['data']) { + if ($args['data']) { // allow an import from a binary string representing the image. // This bypasses the upload step and max size limit checking @@ -56,23 +66,21 @@ function photo_upload($channel, $observer, $args) { // this is going to be deleted if it exists $src = '/tmp/deletemenow'; $type = $args['type']; - } - else { + } else { $f = array('src' => '', 'filename' => '', 'filesize' => 0, 'type' => ''); call_hooks('photo_upload_file',$f); - if(x($f,'src') && x($f,'filesize')) { + if (x($f,'src') && x($f,'filesize')) { $src = $f['src']; $filename = $f['filename']; $filesize = $f['filesize']; $type = $f['type']; - } - else { - $src = $_FILES['userfile']['tmp_name']; - $filename = basename($_FILES['userfile']['name']); - $filesize = intval($_FILES['userfile']['size']); - $type = $_FILES['userfile']['type']; + } else { + $src = $_FILES['userfile']['tmp_name']; + $filename = basename($_FILES['userfile']['name']); + $filesize = intval($_FILES['userfile']['size']); + $type = $_FILES['userfile']['type']; } if (! $type) @@ -82,14 +90,14 @@ function photo_upload($channel, $observer, $args) { $maximagesize = get_config('system','maximagesize'); - if(($maximagesize) && ($filesize > $maximagesize)) { + if (($maximagesize) && ($filesize > $maximagesize)) { $ret['message'] = sprintf ( t('Image exceeds website size limit of %lu bytes'), $maximagesize); @unlink($src); call_hooks('photo_upload_end',$ret); return $ret; } - if(! $filesize) { + if (! $filesize) { $ret['message'] = t('Image file is empty.'); @unlink($src); call_hooks('photo_post_end',$ret); @@ -101,14 +109,13 @@ function photo_upload($channel, $observer, $args) { $imagedata = @file_get_contents($src); } - $r = q("select sum(size) as total from photo where aid = %d and scale = 0 ", intval($account_id) ); $limit = service_class_fetch($channel_id,'photo_upload_limit'); - if(($r) && ($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) { + if (($r) && ($limit !== false) && (($r[0]['total'] + strlen($imagedata)) > $limit)) { $ret['message'] = upgrade_message(); @unlink($src); call_hooks('photo_post_end',$ret); @@ -117,7 +124,7 @@ function photo_upload($channel, $observer, $args) { $ph = photo_factory($imagedata, $type); - if(! $ph->is_valid()) { + if (! $ph->is_valid()) { $ret['message'] = t('Unable to process image'); logger('photo_upload: unable to process image'); @unlink($src); @@ -127,13 +134,12 @@ function photo_upload($channel, $observer, $args) { $exif = $ph->orient($src); - @unlink($src); $max_length = get_config('system','max_image_length'); - if(! $max_length) + if (! $max_length) $max_length = MAX_IMAGE_LENGTH; - if($max_length > 0) + if ($max_length > 0) $ph->scaleImage($max_length); $width = $ph->getWidth(); @@ -144,7 +150,7 @@ function photo_upload($channel, $observer, $args) { $photo_hash = (($args['resource_id']) ? $args['resource_id'] : photo_new_resource()); $visitor = ''; - if($channel['channel_hash'] !== $observer['xchan_hash']) + if ($channel['channel_hash'] !== $observer['xchan_hash']) $visitor = $observer['xchan_hash']; $errors = false; @@ -163,7 +169,6 @@ function photo_upload($channel, $observer, $args) { if($args['description']) $p['description'] = $args['description']; - $r1 = $ph->save($p); if(! $r1) $errors = true; @@ -214,8 +219,6 @@ function photo_upload($channel, $observer, $args) { } } - - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); $title = ''; @@ -263,10 +266,9 @@ function photo_upload($channel, $observer, $args) { $tag = '[zmg]'; } - - $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' - . $tag . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]' - . '[/zrl]'; + $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']' + . $tag . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]' + . '[/zrl]'; $result = item_store($arr); $item_id = $result['item_id']; @@ -304,7 +306,7 @@ function photos_albums_list($channel, $observer) { if(! perm_is_allowed($channel_id, $observer_xchan, 'view_photos')) return false; - // FIXME - create a permissions SQL which works on arbitrary observers and channels, regardless of login or web status + /** @FIXME create a permissions SQL which works on arbitrary observers and channels, regardless of login or web status */ $sql_extra = permissions_sql($channel_id); @@ -327,7 +329,8 @@ function photos_albums_list($channel, $observer) { 'total' => $album['total'], 'url' => z_root() . '/photos/' . $channel['channel_address'] . '/album/' . bin2hex($album['album']), 'urlencode' => urlencode($album['album']), - 'bin2hex' => bin2hex($album['album'])); + 'bin2hex' => bin2hex($album['album']) + ); $ret['albums'][] = $entry; } } @@ -360,11 +363,19 @@ function photos_album_widget($channelx,$observer,$albums = null) { ? t('Upload New Photos') : '') )); } + return $o; } - -function photos_list_photos($channel,$observer,$album = '') { +/** + * @brief + * + * @param array $channel + * @param array $observer + * @param string $album default empty + * @return boolean|array + */ +function photos_list_photos($channel, $observer, $album = '') { $channel_id = $channel['channel_id']; $observer_xchan = (($observer) ? $observer['xchan_hash'] : ''); @@ -384,7 +395,7 @@ function photos_list_photos($channel,$observer,$album = '') { intval(PHOTO_NORMAL), intval(PHOTO_PROFILE) ); - + if($r) { for($x = 0; $x < count($r); $x ++) { $r[$x]['src'] = z_root() . '/photo/' . $r[$x]['resource_id'] . '-' . $r[$x]['scale']; @@ -416,6 +427,7 @@ function photos_album_exists($channel_id, $album) { * @brief Renames a photo album in a channel. * * @todo Do we need to check if new album name already exists? + * * @param int $channel_id id of the channel * @param string $oldname The name of the album to rename * @param string $newname The new name of the album @@ -429,25 +441,31 @@ function photos_album_rename($channel_id, $oldname, $newname) { ); } +/** + * @brief + * + * @param int $channel_id + * @param string $album + * @param string $remote_xchan + * @return string|boolean + */ +function photos_album_get_db_idstr($channel_id, $album, $remote_xchan = '') { -function photos_album_get_db_idstr($channel_id,$album,$remote_xchan = '') { - - if($remote_xchan) { + if ($remote_xchan) { $r = q("SELECT distinct resource_id as from photo where xchan = '%s' and uid = %d and album = '%s' ", dbesc($remote_xchan), intval($channel_id), dbesc($album) ); - } - else { + } else { $r = q("SELECT distinct resource_id from photo where uid = %d and album = '%s' ", intval($channel_id), dbesc($album) ); } - if($r) { + if ($r) { $arr = array(); - foreach($r as $rr) { + foreach ($r as $rr) { $arr[] = "'" . dbesc($rr['resource_id']) . "'" ; } $str = implode(',',$arr); @@ -457,6 +475,15 @@ function photos_album_get_db_idstr($channel_id,$album,$remote_xchan = '') { return false; } +/** + * @brief Creates a new photo item. + * + * @param array $channel + * @param string $creator_hash + * @param array $photo + * @param boolean $visible default false + * @return int item_id + */ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { // Create item container @@ -506,7 +533,6 @@ function getGps($exifCoord, $hemi) { $flip = ($hemi == 'W' or $hemi == 'S') ? -1 : 1; return floatval($flip * ($degrees + ($minutes / 60) + ($seconds / 3600))); - } function gps2Num($coordPart) { @@ -521,4 +547,3 @@ function gps2Num($coordPart) { return floatval($parts[0]) / floatval($parts[1]); } - -- cgit v1.2.3