aboutsummaryrefslogtreecommitdiffstats
path: root/include/photos.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/photos.php')
-rw-r--r--include/photos.php109
1 files changed, 65 insertions, 44 deletions
diff --git a/include/photos.php b/include/photos.php
index ca8c53679..867571f8f 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -55,7 +55,18 @@ 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']) {
+ $os_storage = 0;
+
+ if($args['os_path'] && $args['getimagesize']) {
+ $imagedata = @file_get_contents($args['os_path']);
+ $filename = $args['filename'];
+ $filesize = strlen($imagedata);
+ // this is going to be deleted if it exists
+ $src = '/tmp/deletemenow';
+ $type = $args['getimagesize']['mime'];
+ $os_storage = 1;
+ }
+ elseif ($args['data']) {
// allow an import from a binary string representing the image.
// This bypasses the upload step and max size limit checking
@@ -156,9 +167,10 @@ function photo_upload($channel, $observer, $args) {
$errors = false;
$p = array('aid' => $account_id, 'uid' => $channel_id, 'xchan' => $visitor, 'resource_id' => $photo_hash,
- 'filename' => $filename, 'album' => $album, 'scale' => 0, 'photo_flags' => PHOTO_NORMAL,
+ 'filename' => $filename, 'album' => $album, 'scale' => 0, 'photo_usage' => PHOTO_NORMAL,
'allow_cid' => $str_contact_allow, 'allow_gid' => $str_group_allow,
- 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny
+ 'deny_cid' => $str_contact_deny, 'deny_gid' => $str_group_deny,
+ 'os_storage' => $os_storage, 'os_path' => $args['os_path']
);
if($args['created'])
$p['created'] = $args['created'];
@@ -173,6 +185,10 @@ function photo_upload($channel, $observer, $args) {
if(! $r1)
$errors = true;
+
+ unset($p['os_storage']);
+ unset($p['os_path']);
+
if(($width > 640 || $height > 640) && (! $errors)) {
$ph->scaleImage(640);
$p['scale'] = 1;
@@ -210,6 +226,9 @@ function photo_upload($channel, $observer, $args) {
// Create item container
+
+ $item_hidden = (($visible) ? 0 : 1 );
+
$lat = $lon = null;
if($exif && $exif['GPS']) {
@@ -219,8 +238,6 @@ function photo_upload($channel, $observer, $args) {
}
}
- $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP;
- $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN);
$title = '';
$mid = item_message_id();
@@ -229,22 +246,24 @@ function photo_upload($channel, $observer, $args) {
if($lat && $lon)
$arr['coord'] = $lat . ' ' . $lon;
- $arr['aid'] = $account_id;
- $arr['uid'] = $channel_id;
- $arr['mid'] = $mid;
- $arr['parent_mid'] = $mid;
- $arr['item_flags'] = $item_flags;
- $arr['item_restrict'] = $item_restrict;
- $arr['resource_type'] = 'photo';
- $arr['resource_id'] = $photo_hash;
- $arr['owner_xchan'] = $channel['channel_hash'];
- $arr['author_xchan'] = $observer['xchan_hash'];
- $arr['title'] = $title;
- $arr['allow_cid'] = $str_contact_allow;
- $arr['allow_gid'] = $str_group_allow;
- $arr['deny_cid'] = $str_contact_deny;
- $arr['deny_gid'] = $str_group_deny;
- $arr['verb'] = ACTIVITY_POST;
+ $arr['aid'] = $account_id;
+ $arr['uid'] = $channel_id;
+ $arr['mid'] = $mid;
+ $arr['parent_mid'] = $mid;
+ $arr['item_hidden'] = $item_hidden;
+ $arr['resource_type'] = 'photo';
+ $arr['resource_id'] = $photo_hash;
+ $arr['owner_xchan'] = $channel['channel_hash'];
+ $arr['author_xchan'] = $observer['xchan_hash'];
+ $arr['title'] = $title;
+ $arr['allow_cid'] = $str_contact_allow;
+ $arr['allow_gid'] = $str_group_allow;
+ $arr['deny_cid'] = $str_contact_deny;
+ $arr['deny_gid'] = $str_group_deny;
+ $arr['verb'] = ACTIVITY_POST;
+ $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_thread_top'] = 1;
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
@@ -310,7 +329,7 @@ function photos_albums_list($channel, $observer) {
$sql_extra = permissions_sql($channel_id);
- $albums = q("SELECT count( distinct resource_id ) as total, album from photo where uid = %d and ( photo_flags = %d or photo_flags = %d ) $sql_extra group by album order by max(created) desc",
+ $albums = q("SELECT count( distinct resource_id ) as total, album from photo where uid = %d and photo_usage IN ( %d, %d ) $sql_extra group by album order by max(created) desc",
intval($channel_id),
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
@@ -390,7 +409,7 @@ function photos_list_photos($channel, $observer, $album = '') {
$ret = array('success' => false);
- $r = q("select resource_id, created, edited, title, description, album, filename, type, height, width, size, scale, profile, photo_flags, allow_cid, allow_gid, deny_cid, deny_gid from photo where uid = %d and ( photo_flags = %d or photo_flags = %d ) $sql_extra ",
+ $r = q("select resource_id, created, edited, title, description, album, filename, type, height, width, size, scale, photo_usage, allow_cid, allow_gid, deny_cid, deny_gid from photo where uid = %d and photo_usage in ( %d, %d ) $sql_extra ",
intval($channel_id),
intval(PHOTO_NORMAL),
intval(PHOTO_PROFILE)
@@ -488,32 +507,34 @@ 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_hidden = (($visible) ? 0 : 1 );
$mid = item_message_id();
$arr = array();
- $arr['aid'] = $channel['channel_account_id'];
- $arr['uid'] = $channel['channel_id'];
- $arr['mid'] = $mid;
- $arr['parent_mid'] = $mid;
- $arr['item_flags'] = $item_flags;
- $arr['item_restrict'] = $item_restrict;
- $arr['resource_type'] = 'photo';
- $arr['resource_id'] = $photo['resource_id'];
- $arr['owner_xchan'] = $channel['channel_hash'];
- $arr['author_xchan'] = $creator_hash;
-
- $arr['allow_cid'] = $photo['allow_cid'];
- $arr['allow_gid'] = $photo['allow_gid'];
- $arr['deny_cid'] = $photo['deny_cid'];
- $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'] . ']'
+ $arr['aid'] = $channel['channel_account_id'];
+ $arr['uid'] = $channel['channel_id'];
+ $arr['mid'] = $mid;
+ $arr['parent_mid'] = $mid;
+ $arr['item_wall'] = 1;
+ $arr['item_origin'] = 1;
+ $arr['item_thread_top'] = 1;
+ $arr['item_hidden'] = $item_hidden;
+ $arr['resource_type'] = 'photo';
+ $arr['resource_id'] = $photo['resource_id'];
+ $arr['owner_xchan'] = $channel['channel_hash'];
+ $arr['author_xchan'] = $creator_hash;
+
+ $arr['allow_cid'] = $photo['allow_cid'];
+ $arr['allow_gid'] = $photo['allow_gid'];
+ $arr['deny_cid'] = $photo['deny_cid'];
+ $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]';