aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-08-26 22:13:20 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-08-26 22:13:20 -0700
commit9cebd249871389bb756cb4d73e6719200120e413 (patch)
tree153df78defa07c2820b9866330c89170821b1c06 /include
parent54c88dfae91da709eeb959b5ad8b2eb034ac0041 (diff)
downloadvolse-hubzilla-9cebd249871389bb756cb4d73e6719200120e413.tar.gz
volse-hubzilla-9cebd249871389bb756cb4d73e6719200120e413.tar.bz2
volse-hubzilla-9cebd249871389bb756cb4d73e6719200120e413.zip
change attach_store to allow a predefined item to accompany a photo
Diffstat (limited to 'include')
-rw-r--r--include/attach.php2
-rw-r--r--include/photos.php124
2 files changed, 82 insertions, 44 deletions
diff --git a/include/attach.php b/include/attach.php
index a23f0f81a..620c7620c 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -758,6 +758,8 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$args['created'] = $created;
$args['edited'] = $edited;
+ if($arr['item'])
+ $args['item'] = $arr['item'];
$p = photo_upload($channel,$observer,$args);
if($p['success']) {
diff --git a/include/photos.php b/include/photos.php
index dc7df2d0d..4f5e1d077 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -270,62 +270,98 @@ function photo_upload($channel, $observer, $args) {
}
}
- $title = '';
- $mid = item_message_id();
+ if($args['item']) {
+ foreach($args['item'] as $i) {
- $arr = array();
+ $item = get_item_elements($i);
+ $force = false;
- if($lat && $lon)
- $arr['coord'] = $lat . ' ' . $lon;
-
- $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;
+ if($item['mid'] === $item['parent_mid']) {
- $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
+ $item['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
+ . $tag . z_root() . "/photo/{$photo_hash}-{$smallest}.".$ph->getExt() . '[/zmg]'
+ . '[/zrl]';
+ $item['sig'] = '';
+ $force = true;
- // 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');
- if($larger) {
- $tag = '[zmg]';
- if($r2)
- $smallest = 1;
- else
- $smallest = 0;
+ }
+ $r = q("select id, edited from item where mid = '%s' and uid = %d limit 1",
+ dbesc($item['mid']),
+ intval($channel['channel_id'])
+ );
+ if($r) {
+ if(($item['edited'] > $r[0]['edited']) || $force) {
+ $item['id'] = $r[0]['id'];
+ $item['uid'] = $channel['channel_id'];
+ item_store_update($item);
+ continue;
+ }
+ }
+ else {
+ $item['aid'] = $channel['channel_account_id'];
+ $item['uid'] = $channel['channel_id'];
+ $item_result = item_store($item);
+ }
+ }
}
else {
- if ($width_x_height)
- $tag = '[zmg=' . $width_x_height. ']';
- else
+ $title = '';
+ $mid = item_message_id();
+
+ $arr = array();
+
+ if($lat && $lon)
+ $arr['coord'] = $lat . ' ' . $lon;
+
+ $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'];
+
+ // We should also put a width_x_height on large photos. Left as an exercise for
+ // devs looking for simple stuff to fix.
+
+ $larger = feature_enabled($channel['channel_id'], 'large_photos');
+ if($larger) {
$tag = '[zmg]';
- }
+ if($r2)
+ $smallest = 1;
+ else
+ $smallest = 0;
+ }
+ else {
+ if ($width_x_height)
+ $tag = '[zmg=' . $width_x_height. ']';
+ else
+ $tag = '[zmg]';
+ }
- $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
+ $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'];
+ $result = item_store($arr);
+ $item_id = $result['item_id'];
- if($visible)
- proc_run('php', "include/notifier.php", 'wall-new', $item_id);
+ if($visible)
+ proc_run('php', "include/notifier.php", 'wall-new', $item_id);
+ }
$ret['success'] = true;
$ret['item'] = $arr;