aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2019-06-26 21:54:50 -0700
committerzotlabs <mike@macgirvin.com>2019-06-26 21:54:50 -0700
commitd83ce0863abaf448b64c550999e070376fd71b71 (patch)
treea0f0b45249487bd471bcf0545dfbb23f7b871623 /include
parentcf844cb27c02c3aae636eb1aa1587b1d5e3e81a0 (diff)
parent5ccef18d4e5b7901f78a11e0124c16e1c484e3bf (diff)
downloadvolse-hubzilla-d83ce0863abaf448b64c550999e070376fd71b71.tar.gz
volse-hubzilla-d83ce0863abaf448b64c550999e070376fd71b71.tar.bz2
volse-hubzilla-d83ce0863abaf448b64c550999e070376fd71b71.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'include')
-rw-r--r--include/api_zot.php4
-rw-r--r--include/attach.php7
-rw-r--r--include/channel.php4
-rw-r--r--include/features.php14
-rw-r--r--include/import.php2
-rwxr-xr-xinclude/items.php113
-rw-r--r--include/message.php5
-rw-r--r--include/zid.php2
-rw-r--r--include/zot.php36
9 files changed, 96 insertions, 91 deletions
diff --git a/include/api_zot.php b/include/api_zot.php
index b332aea71..287720484 100644
--- a/include/api_zot.php
+++ b/include/api_zot.php
@@ -6,8 +6,8 @@
api_register_func('api/export/basic','api_export_basic', true);
api_register_func('api/red/channel/export/basic','api_export_basic', true);
api_register_func('api/z/1.0/channel/export/basic','api_export_basic', true);
- api_register_func('api/red/item/export/page','api_item_export_page', true);
- api_register_func('api/z/1.0/item/export/page','api_item_export_page', true);
+ api_register_func('api/red/item/export_page','api_item_export_page', true);
+ api_register_func('api/z/1.0/item/export_page','api_item_export_page', true);
api_register_func('api/red/channel/list','api_channel_list', true);
api_register_func('api/z/1.0/channel/list','api_channel_list', true);
api_register_func('api/red/channel/stream','api_channel_stream', true);
diff --git a/include/attach.php b/include/attach.php
index f169e0669..80efe0838 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -1514,12 +1514,15 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
function attach_drop_photo($channel_id,$resource) {
- $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d",
+ $x = q("select id, item_hidden from item where resource_id = '%s' and resource_type = 'photo' and uid = %d and item_deleted = 0",
dbesc($resource),
intval($channel_id)
);
+
if($x) {
- drop_item($x[0]['id'],false,(($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1),true);
+ $stage = (($x[0]['item_hidden']) ? DROPITEM_NORMAL : DROPITEM_PHASE1);
+ $interactive = (($x[0]['item_hidden']) ? false : true);
+ drop_item($x[0]['id'], $interactive, $stage);
}
$r = q("SELECT content FROM photo WHERE resource_id = '%s' AND uid = %d AND os_storage = 1",
diff --git a/include/channel.php b/include/channel.php
index e4b6df47b..0280cd1cd 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -1161,7 +1161,7 @@ function channel_export_items_date($channel_id, $start, $finish) {
$ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()];
}
- $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created <= '%s' and resource_type = '' order by created",
+ $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and created >= '%s' and created <= '%s' and resource_type != 'photo' order by created",
intval(ITEM_TYPE_POST),
intval($channel_id),
dbesc($start),
@@ -1223,7 +1223,7 @@ function channel_export_items_page($channel_id, $start, $finish, $page = 0, $lim
$ret['relocate'] = [ 'channel_address' => $ch['channel_address'], 'url' => z_root()];
}
- $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and resource_type = '' and created >= '%s' and created <= '%s' order by created limit %d offset %d",
+ $r = q("select * from item where ( item_wall = 1 or item_type != %d ) and item_deleted = 0 and uid = %d and resource_type != 'photo' and created >= '%s' and created <= '%s' order by created limit %d offset %d",
intval(ITEM_TYPE_POST),
intval($channel_id),
dbesc($start),
diff --git a/include/features.php b/include/features.php
index 9528d3418..87df0c50d 100644
--- a/include/features.php
+++ b/include/features.php
@@ -280,20 +280,6 @@ function get_features($filtered = true, $level = (-1)) {
],
- 'events' => [
-
- t('Events'),
-
- [
- 'events_cal_first_day',
- t('Start calendar week on Monday'),
- t('Default is Sunday'),
- false,
- get_config('feature_lock','events_cal_first_day')
- ]
-
- ],
-
'manage' => [
t('Manage'),
diff --git a/include/import.php b/include/import.php
index 1843c9741..1d3b7c035 100644
--- a/include/import.php
+++ b/include/import.php
@@ -1392,7 +1392,7 @@ function sync_files($channel, $files) {
$p['content'] = (($p['content'])? base64_decode($p['content']) : '');
}
- if (intval($p['imgscale']) && ((intval($p['os_storage'])) || (! $p['content']))) {
+ if(intval($p['imgscale'])) {
$time = datetime_convert();
diff --git a/include/items.php b/include/items.php
index 26a74fd86..4fc659926 100755
--- a/include/items.php
+++ b/include/items.php
@@ -1457,6 +1457,7 @@ function encode_mail($item,$extended = false) {
$x['to'] = encode_item_xchan($item['to']);
$x['raw'] = $item['mail_raw'];
$x['mimetype'] = $item['mail_mimetype'];
+ $x['sig'] = $item['sig'];
if($item['attach'])
$x['attach'] = json_decode($item['attach'],true);
@@ -1516,6 +1517,9 @@ function get_mail_elements($x) {
$arr['expires'] = datetime_convert('UTC','UTC',$x['expires']);
$arr['mail_flags'] = 0;
+
+ if(array_key_exists('sig',$x))
+ $arr['sig'] = $x['sig'];
if($x['flags'] && is_array($x['flags'])) {
if(in_array('recalled',$x['flags'])) {
@@ -2008,7 +2012,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
// find the item we just created
$r = q("SELECT * FROM item WHERE mid = '%s' AND uid = %d and revision = %d ORDER BY id ASC ",
- $arr['mid'], // already dbesc'd
+ dbesc($arr['mid']),
intval($arr['uid']),
intval($arr['revision'])
);
@@ -2029,7 +2033,7 @@ function item_store($arr, $allow_exec = false, $deliver = true) {
if(count($r) > 1) {
logger('item_store: duplicated post occurred. Removing duplicates.');
q("DELETE FROM item WHERE mid = '%s' AND uid = %d AND id != %d ",
- $arr['mid'],
+ dbesc($arr['mid']),
intval($arr['uid']),
intval($current_post)
);
@@ -3664,7 +3668,7 @@ function retain_item($id) {
);
}
-function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force = false) {
+function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL) {
$uid = 0;
if(! local_channel() && ! remote_channel())
@@ -3672,7 +3676,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
if(count($items)) {
foreach($items as $item) {
- $owner = drop_item($item,$interactive,$stage,$force);
+ $owner = drop_item($item,$interactive,$stage);
if($owner && ! $uid)
$uid = $owner;
}
@@ -3695,12 +3699,7 @@ function drop_items($items,$interactive = false,$stage = DROPITEM_NORMAL,$force
// $stage = 1 => set deleted flag on the item and perform intial notifications
// $stage = 2 => perform low level delete at a later stage
-function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = false) {
-
- // These resource types have linked items that should only be removed at the same time
- // as the linked resource; if we encounter one set it to item_hidden rather than item_deleted.
-
- $linked_resource_types = [ 'photo' ];
+function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL) {
// locate item to be deleted
@@ -3712,13 +3711,11 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
if(! $interactive)
return 0;
notice( t('Item not found.') . EOL);
- goaway(z_root() . '/' . $_SESSION['return_url']);
+ //goaway(z_root() . '/' . $_SESSION['return_url']);
}
$item = $r[0];
- $linked_item = (($item['resource_id'] && $item['resource_type'] && in_array($item['resource_type'], $linked_resource_types)) ? true : false);
-
$ok_to_delete = false;
// system deletion
@@ -3744,16 +3741,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
// set the deleted flag immediately on this item just in case the
// hook calls a remote process which loops. We'll delete it properly in a second.
- if(($linked_item) && (! $force)) {
- $r = q("UPDATE item SET item_hidden = 1 WHERE id = %d",
- intval($item['id'])
- );
- }
- else {
- $r = q("UPDATE item SET item_deleted = 1 WHERE id = %d",
- intval($item['id'])
- );
- }
+ $r = q("UPDATE item SET item_deleted = 1 WHERE id = %d",
+ intval($item['id'])
+ );
$arr = [
'item' => $item,
@@ -3793,14 +3783,13 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1)) {
Master::Summon([ 'Notifier','drop',$notify_id ]);
}
-
- goaway(z_root() . '/' . $_SESSION['return_url']);
+ //goaway(z_root() . '/' . $_SESSION['return_url']);
}
else {
if(! $interactive)
return 0;
notice( t('Permission denied.') . EOL);
- goaway(z_root() . '/' . $_SESSION['return_url']);
+ //goaway(z_root() . '/' . $_SESSION['return_url']);
}
}
@@ -3815,11 +3804,9 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
* @param boolean $force
* @return boolean
*/
-function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
-
- $linked_item = (($item['resource_id']) ? true : false);
+function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL) {
- logger('item: ' . $item['id'] . ' stage: ' . $stage . ' force: ' . $force, LOGGER_DATA);
+ logger('item: ' . $item['id'] . ' stage: ' . $stage, LOGGER_DATA);
switch($stage) {
case DROPITEM_PHASE2:
@@ -3832,42 +3819,50 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
break;
case DROPITEM_PHASE1:
- if($linked_item && ! $force) {
- $r = q("UPDATE item SET item_hidden = 1,
- changed = '%s', edited = '%s' WHERE id = %d",
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($item['id'])
- );
- }
- else {
- $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d",
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($item['id'])
- );
- }
-
+ $r = q("UPDATE item set item_deleted = 1, changed = '%s', edited = '%s' where id = %d",
+ dbesc(datetime_convert()),
+ dbesc(datetime_convert()),
+ intval($item['id'])
+ );
break;
case DROPITEM_NORMAL:
default:
- if($linked_item && ! $force) {
- $r = q("UPDATE item SET item_hidden = 1,
- changed = '%s', edited = '%s' WHERE id = %d",
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($item['id'])
- );
- }
- else {
- $r = q("DELETE FROM item WHERE id = %d",
- intval($item['id'])
- );
- }
+ $r = q("DELETE FROM item WHERE id = %d",
+ intval($item['id'])
+ );
break;
}
+ // immediately remove local linked resources
+
+ if($item['resource_type'] === 'event') {
+ $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ dbesc($item['resource_id']),
+ intval($item['uid'])
+ );
+
+ $sync_data = $r[0];
+
+ $x = q("delete from event where event_hash = '%s' and uid = %d",
+ dbesc($item['resource_id']),
+ intval($item['uid'])
+ );
+
+ if($x) {
+ $sync_data['event_deleted'] = 1;
+ build_sync_packet($item['uid'], ['event' => [$sync_data]]);
+ }
+ }
+
+ if($item['resource_type'] === 'photo') {
+ attach_delete($item['uid'], $item['resource_id'], true );
+ $channel = channelx_by_n($item['uid']);
+ $sync_data = attach_export_data($channel, $item['resource_id'], true);
+ if($sync_data)
+ build_sync_packet($item['uid'], ['file' => [$sync_data]]);
+ }
+
// immediately remove any undesired profile likes.
q("delete from likes where iid = %d and channel_id = %d",
diff --git a/include/message.php b/include/message.php
index 2486beb83..7d05b9ab7 100644
--- a/include/message.php
+++ b/include/message.php
@@ -19,7 +19,7 @@ function mail_prepare_binary($item) {
// send a private message
-function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false) {
+function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $replyto = '', $expires = NULL_DATE, $mimetype = 'text/bbcode', $raw = false, $sig = '') {
$ret = array('success' => false);
$is_reply = false;
@@ -175,8 +175,7 @@ function send_message($uid = 0, $recipient = '', $body = '', $subject = '', $rep
$subject = str_rot47(base64url_encode($subject));
if(($body )&& (! $raw))
$body = str_rot47(base64url_encode($body));
-
- $sig = ''; // placeholder
+
$mimetype = ''; //placeholder
$r = q("INSERT INTO mail ( account_id, conv_guid, mail_obscured, channel_id, from_xchan, to_xchan, mail_mimetype, title, body, sig, attach, mid, parent_mid, created, expires, mail_isreply, mail_raw )
diff --git a/include/zid.php b/include/zid.php
index ed79de76a..27ef0cefa 100644
--- a/include/zid.php
+++ b/include/zid.php
@@ -13,7 +13,7 @@ function is_matrix_url($url) {
if(array_key_exists($m['host'],$remembered))
return $remembered[$m['host']];
- $r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network = 'zot' limit 1",
+ $r = q("select hubloc_url from hubloc where hubloc_host = '%s' and hubloc_network in ('zot', 'zot6') limit 1",
dbesc($m['host'])
);
if($r) {
diff --git a/include/zot.php b/include/zot.php
index e9374f0cc..53c3d4d86 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -2240,7 +2240,7 @@ function delete_imported_item($sender, $item, $uid, $relay) {
$item_found = false;
$post_id = 0;
- $r = q("select id, author_xchan, owner_xchan, source_xchan, item_deleted from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
+ $r = q("select * from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' )
and mid = '%s' and uid = %d limit 1",
dbesc($sender['hash']),
dbesc($sender['hash']),
@@ -2250,10 +2250,13 @@ function delete_imported_item($sender, $item, $uid, $relay) {
);
if($r) {
- if($r[0]['author_xchan'] === $sender['hash'] || $r[0]['owner_xchan'] === $sender['hash'] || $r[0]['source_xchan'] === $sender['hash'])
+
+ $stored = $r[0];
+
+ if($stored['author_xchan'] === $sender['hash'] || $stored['owner_xchan'] === $sender['hash'] || $stored['source_xchan'] === $sender['hash'])
$ownership_valid = true;
- $post_id = $r[0]['id'];
+ $post_id = $stored['id'];
$item_found = true;
}
else {
@@ -2277,10 +2280,29 @@ function delete_imported_item($sender, $item, $uid, $relay) {
return false;
}
+ if ($stored['resource_type'] === 'event') {
+ $i = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
+ dbesc($stored['resource_id']),
+ intval($uid)
+ );
+ if ($i) {
+ if ($i[0]['event_xchan'] === $sender['hash']) {
+ q("delete from event where event_hash = '%s' and uid = %d",
+ dbesc($stored['resource_id']),
+ intval($uid)
+ );
+ }
+ else {
+ logger('delete linked event: not owner');
+ return;
+ }
+ }
+ }
+
require_once('include/items.php');
if($item_found) {
- if(intval($r[0]['item_deleted'])) {
+ if(intval($stored['item_deleted'])) {
logger('delete_imported_item: item was already deleted');
if(! $relay)
return false;
@@ -2292,10 +2314,10 @@ function delete_imported_item($sender, $item, $uid, $relay) {
// back, and we aren't going to (or shouldn't at any rate) delete it again in the future - so losing
// this information from the metadata should have no other discernible impact.
- if (($r[0]['id'] != $r[0]['parent']) && intval($r[0]['item_origin'])) {
+ if (($stored['id'] != $stored['parent']) && intval($stored['item_origin'])) {
q("update item set item_origin = 0 where id = %d and uid = %d",
- intval($r[0]['id']),
- intval($r[0]['uid'])
+ intval($stored['id']),
+ intval($stored['uid'])
);
}
}