aboutsummaryrefslogtreecommitdiffstats
path: root/include/items.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/items.php')
-rwxr-xr-xinclude/items.php533
1 files changed, 285 insertions, 248 deletions
diff --git a/include/items.php b/include/items.php
index 0dc6d6ed6..23561ef46 100755
--- a/include/items.php
+++ b/include/items.php
@@ -192,20 +192,30 @@ function comments_are_now_closed($item) {
return false;
}
+function item_normal() {
+ return " and item.item_hidden = 0 and item.item_type = 0 and item.item_deleted = 0
+ and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
+ and item.item_blocked = 0 ";
+}
+
/**
* @brief
*
* This is a compatibility function primarily for plugins, because
- * in future hubzilla (and later) DB schemas the definition of a
- * normal item gets a bit more complicated.
+ * in earlier DB schemas this was a much simpler single integer compare
*
*/
function is_item_normal($item) {
- return((intval($item['item_restrict'])) ? false : true);
-}
+ if(intval($item['item_hidden']) || intval($item['item_type']) || intval($item['item_deleted'])
+ || intval($item['item_unpublished']) || intval($item['item_delayed']) || intval($item['item_pending_remove'])
+ || intval($item['item_blocked']))
+ return false;
+ return true;
+
+}
/**
* @brief
@@ -396,12 +406,12 @@ function post_activity_item($arr) {
if((($arr['parent']) && $arr['parent'] != $arr['id']) || (($arr['parent_mid']) && $arr['parent_mid'] != $arr['mid']))
$is_comment = true;
- if(! x($arr,'item_flags')) {
- if($is_comment)
- $arr['item_flags'] = ITEM_ORIGIN;
- else
- $arr['item_flags'] = ITEM_ORIGIN | ITEM_WALL | ITEM_THREAD_TOP;
- }
+ if(! array_key_exists('item_origin',$arr))
+ $arr['item_origin'] = 1;
+ if(! array_key_exists('item_wall',$arr) && (! $is_comment))
+ $arr['item_wall'] = 1;
+ if(! array_key_exists('item_thread_top',$arr) && (! $is_comment))
+ $arr['item_thread_top'] = 1;
$channel = get_app()->get_channel();
$observer = get_app()->get_observer();
@@ -428,17 +438,9 @@ function post_activity_item($arr) {
if($channel) {
if($channel['channel_hash'] === $arr['author_xchan']) {
$arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
- $arr['item_flags'] = $arr['item_flags'] | ITEM_VERIFIED;
+ $arr['item_verified'] = 1;
}
}
-
- logger('Encrypting local storage');
- $key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
}
$arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : item_message_id());
@@ -460,7 +462,7 @@ function post_activity_item($arr) {
$arr['comment_policy'] = map_scope($channel['channel_w_comment']);
- if ((! $arr['plink']) && ($arr['item_flags'] & ITEM_THREAD_TOP)) {
+ if ((! $arr['plink']) && (intval($arr['item_thread_top']))) {
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
}
@@ -866,7 +868,7 @@ function get_item_elements($x) {
$arr['sig'] = (($x['signature']) ? htmlspecialchars($x['signature'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['diaspora_meta'] = (($x['diaspora_signature']) ? json_encode(crypto_encapsulate($x['diaspora_signature'],$key)) : '');
+ $arr['diaspora_meta'] = (($x['diaspora_signature']) ? json_encode($x['diaspora_signature']) : '');
$arr['object'] = activity_sanitise($x['object']);
$arr['target'] = activity_sanitise($x['target']);
@@ -878,11 +880,12 @@ function get_item_elements($x) {
$arr['item_flags'] = 0;
if(array_key_exists('flags',$x) && in_array('consensus',$x['flags']))
- $arr['item_flags'] |= ITEM_CONSENSUS;
+ $arr['item_consensus'] = 1;
+
if(array_key_exists('flags',$x) && in_array('deleted',$x['flags']))
- $arr['item_restrict'] |= ITEM_DELETED;
+ $arr['item_deleted'] = 1;
if(array_key_exists('flags',$x) && in_array('hidden',$x['flags']))
- $arr['item_restrict'] |= ITEM_HIDDEN;
+ $arr['item_hidden'] = 1;
// Here's the deal - the site might be down or whatever but if there's a new person you've never
// seen before sending stuff to your stream, we MUST be able to look them up and import their data from their
@@ -910,27 +913,13 @@ function get_item_elements($x) {
dbesc($arr['author_xchan'])
);
if($r && rsa_verify($x['body'],base64url_decode($arr['sig']),$r[0]['xchan_pubkey']))
- $arr['item_flags'] |= ITEM_VERIFIED;
+ $arr['item_verified'] = 1;
else
logger('get_item_elements: message verification failed.');
}
-
- // if it's a private post, encrypt it in the DB.
- // We have to do that here because we need to cleanse the input and prevent bad stuff from getting in,
- // and we need plaintext to do that.
-
-
- if(intval($arr['item_private'])) {
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
- }
-
-
if(array_key_exists('revision',$x)) {
+
// extended export encoding
$arr['revision'] = $x['revision'];
@@ -942,9 +931,30 @@ function get_item_elements($x) {
$arr['postopts'] = $x['postopts'];
$arr['resource_id'] = $x['resource_id'];
$arr['resource_type'] = $x['resource_type'];
- $arr['item_restrict'] = $x['item_restrict'];
- $arr['item_flags'] = $x['item_flags'];
$arr['attach'] = $x['attach'];
+ $arr['item_origin'] = $x['item_origin'];
+ $arr['item_unseen'] = $x['item_unseen'];
+ $arr['item_starred'] = $x['item_starred'];
+ $arr['item_uplink'] = $x['item_uplink'];
+ $arr['item_consensus'] = $x['item_consensus'];
+ $arr['item_wall'] = $x['item_wall'];
+ $arr['item_thread_top'] = $x['item_thread_top'];
+ $arr['item_notshown'] = $x['item_notshown'];
+ $arr['item_nsfw'] = $x['item_nsfw'];
+ $arr['item_relay'] = $x['item_relay'];
+ $arr['item_mentionsme'] = $x['item_mentionsme'];
+ $arr['item_nocomment'] = $x['item_nocomment'];
+ $arr['item_obscured'] = $x['item_obscured'];
+ $arr['item_verified'] = $x['item_verified'];
+ $arr['item_retained'] = $x['item_retained'];
+ $arr['item_rss'] = $x['item_rss'];
+ $arr['item_deleted'] = $x['item_deleted'];
+ $arr['item_type'] = $x['item_type'];
+ $arr['item_hidden'] = $x['item_hidden'];
+ $arr['item_unpublished'] = $x['item_unpublished'];
+ $arr['item_delayed'] = $x['item_delayed'];
+ $arr['item_pending_remove'] = $x['item_pending_remove'];
+ $arr['item_blocked'] = $x['item_blocked'];
}
return $arr;
@@ -1127,7 +1137,7 @@ function encode_item($item,$mirror = false) {
$key = get_config('system','prvkey');
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
if($item['title'])
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
if($item['body'])
@@ -1150,9 +1160,31 @@ function encode_item($item,$mirror = false) {
$x['postopts'] = $item['postopts'];
$x['resource_id'] = $item['resource_id'];
$x['resource_type'] = $item['resource_type'];
- $x['item_restrict'] = $item['item_restrict'];
- $x['item_flags'] = $item['item_flags'];
$x['attach'] = $item['attach'];
+ $x['item_origin'] = $item['item_origin'];
+ $x['item_unseen'] = $item['item_unseen'];
+ $x['item_starred'] = $item['item_starred'];
+ $x['item_uplink'] = $item['item_uplink'];
+ $x['item_consensus'] = $item['item_consensus'];
+ $x['item_wall'] = $item['item_wall'];
+ $x['item_thread_top'] = $item['item_thread_top'];
+ $x['item_notshown'] = $item['item_notshown'];
+ $x['item_nsfw'] = $item['item_nsfw'];
+ $x['item_relay'] = $item['item_relay'];
+ $x['item_mentionsme'] = $item['item_mentionsme'];
+ $x['item_nocomment'] = $item['item_nocomment'];
+ $x['item_obscured'] = $item['item_obscured'];
+ $x['item_verified'] = $item['item_verified'];
+ $x['item_retained'] = $item['item_retained'];
+ $x['item_rss'] = $item['item_rss'];
+ $x['item_deleted'] = $item['item_deleted'];
+ $x['item_type'] = $item['item_type'];
+ $x['item_hidden'] = $item['item_hidden'];
+ $x['item_unpublished'] = $item['item_unpublished'];
+ $x['item_delayed'] = $item['item_delayed'];
+ $x['item_pending_remove'] = $item['item_pending_remove'];
+ $x['item_blocked'] = $item['item_blocked'];
+
}
@@ -1193,7 +1225,7 @@ function encode_item($item,$mirror = false) {
$x['public_scope'] = $scope;
- if($item['item_flags'] & ITEM_NOCOMMENT)
+ if($item['item_nocomment'])
$x['comment_scope'] = 'none';
else
$x['comment_scope'] = $c_scope;
@@ -1201,9 +1233,15 @@ function encode_item($item,$mirror = false) {
if($item['term'])
$x['tags'] = encode_item_terms($item['term']);
- if($item['diaspora_meta'])
- $x['diaspora_signature'] = crypto_unencapsulate(json_decode($item['diaspora_meta'],true),$key);
-
+ if($item['diaspora_meta']) {
+ $z = json_decode($item['diaspora_meta'],true);
+ if($z) {
+ if(array_key_exists('iv',$z))
+ $x['diaspora_signature'] = crypto_unencapsulate($z,$key);
+ else
+ $x['diaspora_signature'] = $z;
+ }
+ }
logger('encode_item: ' . print_r($x,true), LOGGER_DATA);
return $x;
@@ -1416,17 +1454,17 @@ function encode_item_flags($item) {
$ret = array();
- if($item['item_restrict'] & ITEM_DELETED)
+ if(intval($item['item_deleted']))
$ret[] = 'deleted';
- if($item['item_restrict'] & ITEM_HIDDEN)
+ if(intval($item['item_hidden']))
$ret[] = 'hidden';
- if($item['item_flags'] & ITEM_THREAD_TOP)
+ if(intval($item['item_thread_top']))
$ret[] = 'thread_parent';
- if($item['item_flags'] & ITEM_NSFW)
+ if(intval($item['item_nsfw']))
$ret[] = 'nsfw';
- if($item['item_flags'] & ITEM_CONSENSUS)
+ if(intval($item['item_consensus']))
$ret[] = 'consensus';
- if($item['item_private'])
+ if(intval($item['item_private']))
$ret[] = 'private';
return $ret;
@@ -1438,11 +1476,10 @@ function encode_mail($item) {
$x['encoding'] = 'zot';
if(array_key_exists('mail_flags',$item) && ($item['mail_flags'] & MAIL_OBSCURED)) {
- $key = get_config('system','prvkey');
if($item['title'])
- $item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);
+ $item['title'] = base64url_decode(str_rot47($item['title']));
if($item['body'])
- $item['body'] = crypto_unencapsulate(json_decode_plus($item['body']),$key);
+ $item['body'] = base64url_decode(str_rot47($item['body']));
}
$x['message_id'] = $item['mid'];
@@ -1494,13 +1531,15 @@ function get_mail_elements($x) {
$key = get_config('system','pubkey');
$arr['mail_flags'] |= MAIL_OBSCURED;
- $arr['body'] = htmlspecialchars($arr['body'],ENT_COMPAT,'UTF-8',false);
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
- $arr['title'] = htmlspecialchars($arr['title'],ENT_COMPAT,'UTF-8',false);
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
+ if($arr['body']) {
+ $arr['body'] = str_rot47(base64url_encode($arr['body']));
+ $arr['body'] = htmlspecialchars($arr['body'],ENT_COMPAT,'UTF-8',false);
+ }
+ if($arr['title']) {
+ $arr['title'] = str_rot47(base64url_encode($arr['title']));
+ $arr['title'] = htmlspecialchars($arr['title'],ENT_COMPAT,'UTF-8',false);
+ }
if($arr['created'] > datetime_convert())
$arr['created'] = datetime_convert();
@@ -1582,7 +1621,7 @@ function get_atom_elements($feed, $item, &$author) {
$res['title'] = unxmlify($item->get_title());
$res['body'] = unxmlify($item->get_content());
$res['plink'] = unxmlify($item->get_link(0));
- $res['item_flags'] = ITEM_RSS;
+ $res['item_rss'] = 1;
// removing the content of the title if its identically to the body
@@ -2022,11 +2061,11 @@ function item_store($arr, $allow_exec = false) {
// If a page layout is provided, ensure it exists and belongs to us.
if(array_key_exists('layout_mid',$arr) && $arr['layout_mid']) {
- $l = q("select item_restrict from item where mid = '%s' and uid = %d limit 1",
+ $l = q("select item_type from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['layout_mid']),
intval($arr['uid'])
);
- if((! $l) || (! ($l[0]['item_restrict'] & ITEM_PDL)))
+ if((! $l) || (! ($l[0]['item_type'] != ITEM_TYPE_PDL)))
unset($arr['layout_mid']);
}
@@ -2055,12 +2094,13 @@ function item_store($arr, $allow_exec = false) {
$arr['deny_cid'] = ((x($arr,'deny_cid')) ? trim($arr['deny_cid']) : '');
$arr['deny_gid'] = ((x($arr,'deny_gid')) ? trim($arr['deny_gid']) : '');
$arr['item_private'] = ((x($arr,'item_private')) ? intval($arr['item_private']) : 0 );
- $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : 0 );
+ $arr['item_wall'] = ((x($arr,'item_wall')) ? intval($arr['item_wall']) : 0 );
+ $arr['item_type'] = ((x($arr,'item_type')) ? intval($arr['item_type']) : 0 );
// only detect language if we have text content, and if the post is private but not yet
// obscured, make it so.
- if(! ($arr['item_flags'] & ITEM_OBSCURED)) {
+ if((! array_key_exists('item_obscured',$arr)) || $arr['item_obscured'] == 0) {
$arr['lang'] = detect_language($arr['body']);
// apply the input filter here - if it is obscured it has been filtered already
@@ -2070,7 +2110,7 @@ function item_store($arr, $allow_exec = false) {
$channel = get_app()->get_channel();
if($channel['channel_hash'] === $arr['author_xchan']) {
$arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
- $arr['item_flags'] |= ITEM_VERIFIED;
+ $arr['item_verified'] = 1;
}
}
@@ -2086,14 +2126,6 @@ function item_store($arr, $allow_exec = false) {
}
$arr = $translate['item'];
}
- if($arr['item_private']) {
- $key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
- }
}
if((x($arr,'object')) && is_array($arr['object'])) {
@@ -2135,16 +2167,16 @@ function item_store($arr, $allow_exec = false) {
$arr['plink'] = ((x($arr,'plink')) ? notags(trim($arr['plink'])) : '');
$arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : '');
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : '');
- $arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : 0 );
$arr['public_policy'] = ((x($arr,'public_policy')) ? notags(trim($arr['public_policy'])) : '' );
$arr['comment_policy'] = ((x($arr,'comment_policy')) ? notags(trim($arr['comment_policy'])) : 'contacts' );
+
+ if(! array_key_exists('item_unseen',$arr))
+ $arr['item_unseen'] = 1;
- $arr['item_unseen'] = ((array_key_exists('item_unseen',$arr)) ? intval($arr['item_unseen']) : 1);
-
- if($arr['comment_policy'] == 'none')
- $arr['item_flags'] = $arr['item_flags'] | ITEM_NOCOMMENT;
+ if((! array_key_exists('item_nocomment',$arr)) && ($arr['comment_policy'] == 'none'))
+ $arr['item_nocomment'] = 1;
// handle time travelers
// Allow a bit of fudge in case somebody just has a slightly slow/fast clock
@@ -2152,7 +2184,7 @@ function item_store($arr, $allow_exec = false) {
$d1 = new DateTime('now +10 minutes', new DateTimeZone('UTC'));
$d2 = new DateTime($arr['created'] . '+00:00');
if($d2 > $d1)
- $arr['item_restrict'] = $arr['item_restrict'] | ITEM_DELAYED_PUBLISH;
+ $arr['item_delayed'] = 1;
$arr['llink'] = z_root() . '/display/' . $arr['mid'];
@@ -2168,7 +2200,7 @@ function item_store($arr, $allow_exec = false) {
$deny_gid = $arr['deny_gid'];
$public_policy = $arr['public_policy'];
$comments_closed = $arr['comments_closed'];
- $arr['item_flags'] = $arr['item_flags'] | ITEM_THREAD_TOP;
+ $arr['item_thread_top'] = 1;
}
else {
@@ -2218,7 +2250,7 @@ function item_store($arr, $allow_exec = false) {
}
$parent_id = $r[0]['id'];
- $parent_deleted = $r[0]['item_restrict'] & ITEM_DELETED;
+ $parent_deleted = $r[0]['item_deleted'];
$allow_cid = $r[0]['allow_cid'];
$allow_gid = $r[0]['allow_gid'];
$deny_cid = $r[0]['deny_cid'];
@@ -2226,8 +2258,8 @@ function item_store($arr, $allow_exec = false) {
$public_policy = $r[0]['public_policy'];
$comments_closed = $r[0]['comments_closed'];
- if($r[0]['item_flags'] & ITEM_WALL)
- $arr['item_flags'] = $arr['item_flags'] | ITEM_WALL;
+ if(intval($r[0]['item_wall']))
+ $arr['item_wall'] = 1;
// An uplinked comment might arrive with a downstream owner.
// Fix it.
@@ -2246,7 +2278,7 @@ function item_store($arr, $allow_exec = false) {
// The original author commented, but as this is a comment, the permissions
// weren't fixed up so it will still show the comment as private unless we fix it here.
- if((intval($r[0]['item_flags']) & ITEM_UPLINK) && (! $r[0]['item_private']))
+ if(intval($r[0]['item_uplink']) && (! $r[0]['item_private']))
$arr['item_private'] = 0;
}
else {
@@ -2257,7 +2289,7 @@ function item_store($arr, $allow_exec = false) {
}
if($parent_deleted)
- $arr['item_restrict'] = $arr['item_restrict'] | ITEM_DELETED;
+ $arr['item_deleted'] = 1;
$r = q("SELECT `id` FROM `item` WHERE `mid` = '%s' AND `uid` = %d LIMIT 1",
dbesc($arr['mid']),
@@ -2369,10 +2401,9 @@ function item_store($arr, $allow_exec = false) {
// update the commented timestamp on the parent
- $z = q("select max(created) as commented from item where parent_mid = '%s' and uid = %d and not ( item_restrict & %d )>0 ",
+ $z = q("select max(created) as commented from item where parent_mid = '%s' and uid = %d and item_delayed = 0 ",
dbesc($arr['parent_mid']),
- intval($arr['uid']),
- intval(ITEM_DELAYED_PUBLISH)
+ intval($arr['uid'])
);
q("UPDATE item set commented = '%s', changed = '%s' WHERE id = %d",
@@ -2387,7 +2418,7 @@ function item_store($arr, $allow_exec = false) {
// so that we have an item in the DB that's marked deleted and won't store a fresh post
// that isn't aware that we were already told to delete it.
- if(! ($arr['item_restrict'] & ITEM_DELETED)) {
+ if(! intval($arr['item_deleted'])) {
send_status_notifications($current_post,$arr);
tag_deliver($arr['uid'],$current_post);
}
@@ -2434,17 +2465,8 @@ function item_store_update($arr,$allow_exec = false) {
// override the unseen flag with the original
- if(intval($arr['item_flags']))
- $arr['item_unseen'] = 0;
-
- if($orig[0]['item_flags'] & ITEM_VERIFIED)
- $orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_VERIFIED;
+ $arr['item_unseen'] = $orig[0]['item_unseen'];
- if($orig[0]['item_flags'] & ITEM_OBSCURED)
- $orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_OBSCURED;
-
- $arr['item_flags'] = intval($arr['item_flags']) | $orig[0]['item_flags'];
- $arr['item_restrict'] = intval($arr['item_restrict']) | $orig[0]['item_restrict'];
if(array_key_exists('edit',$arr))
unset($arr['edit']);
@@ -2457,19 +2479,19 @@ function item_store_update($arr,$allow_exec = false) {
return $ret;
}
- if(! ($arr['item_flags'] & ITEM_OBSCURED)) {
+ if((! array_key_exists('item_obscured', $arr)) || $arr['item_obscured'] == 0) {
$arr['lang'] = detect_language($arr['body']);
- // apply the input filter here - if it is obscured it has been filtered already
- $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']);
-
- if(local_channel() && (! $arr['sig'])) {
- $channel = get_app()->get_channel();
- if($channel['channel_hash'] === $arr['author_xchan']) {
- $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
- $arr['item_flags'] |= ITEM_VERIFIED;
- }
- }
+ // apply the input filter here - if it is obscured it has been filtered already
+ $arr['body'] = z_input_filter($arr['uid'],$arr['body'],$arr['mimetype']);
+
+ if(local_channel() && (! $arr['sig'])) {
+ $channel = get_app()->get_channel();
+ if($channel['channel_hash'] === $arr['author_xchan']) {
+ $arr['sig'] = base64url_encode(rsa_sign($arr['body'],$channel['channel_prvkey']));
+ $arr['item_verified'] = 1;
+ }
+ }
$allowed_languages = get_pconfig($arr['uid'],'system','allowed_languages');
@@ -2483,14 +2505,6 @@ function item_store_update($arr,$allow_exec = false) {
}
$arr = $translate['item'];
}
- if($arr['item_private']) {
- $key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
- if($arr['title'])
- $arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
- if($arr['body'])
- $arr['body'] = json_encode(crypto_encapsulate($arr['body'],$key));
- }
}
if((x($arr,'object')) && is_array($arr['object'])) {
@@ -2550,11 +2564,35 @@ function item_store_update($arr,$allow_exec = false) {
$arr['title'] = ((array_key_exists('title',$arr) && strlen($arr['title'])) ? trim($arr['title']) : '');
$arr['body'] = ((array_key_exists('body',$arr) && strlen($arr['body'])) ? trim($arr['body']) : '');
+ $arr['html'] = ((array_key_exists('html',$arr) && strlen($arr['html'])) ? trim($arr['html']) : '');
+
+ $arr['attach'] = ((array_key_exists('attach',$arr)) ? notags(trim($arr['attach'])) : $orig[0]['attach']);
+ $arr['app'] = ((array_key_exists('app',$arr)) ? notags(trim($arr['app'])) : $orig[0]['app']);
+
+ $arr['item_origin'] = ((array_key_exists('item_origin',$arr)) ? intval($arr['item_origin']) : $orig[0]['item_origin'] );
+ $arr['item_unseen'] = ((array_key_exists('item_unseen',$arr)) ? intval($arr['item_unseen']) : $orig[0]['item_unseen'] );
+ $arr['item_starred'] = ((array_key_exists('item_starred',$arr)) ? intval($arr['item_starred']) : $orig[0]['item_starred'] );
+ $arr['item_uplink'] = ((array_key_exists('item_uplink',$arr)) ? intval($arr['item_uplink']) : $orig[0]['item_uplink'] );
+ $arr['item_consensus'] = ((array_key_exists('item_consensus',$arr)) ? intval($arr['item_consensus']) : $orig[0]['item_consensus'] );
+ $arr['item_wall'] = ((array_key_exists('item_wall',$arr)) ? intval($arr['item_wall']) : $orig[0]['item_wall'] );
+ $arr['item_thread_top'] = ((array_key_exists('item_thread_top',$arr)) ? intval($arr['item_thread_top']) : $orig[0]['item_thread_top'] );
+ $arr['item_notshown'] = ((array_key_exists('item_notshown',$arr)) ? intval($arr['item_notshown']) : $orig[0]['item_notshown'] );
+ $arr['item_nsfw'] = ((array_key_exists('item_nsfw',$arr)) ? intval($arr['item_nsfw']) : $orig[0]['item_nsfw'] );
+ $arr['item_relay'] = ((array_key_exists('item_relay',$arr)) ? intval($arr['item_relay']) : $orig[0]['item_relay'] );
+ $arr['item_mentionsme'] = ((array_key_exists('item_mentionsme',$arr)) ? intval($arr['item_mentionsme']) : $orig[0]['item_mentionsme'] );
+ $arr['item_nocomment'] = ((array_key_exists('item_nocomment',$arr)) ? intval($arr['item_nocomment']) : $orig[0]['item_nocomment'] );
+ $arr['item_obscured'] = ((array_key_exists('item_obscured',$arr)) ? intval($arr['item_obscured']) : $orig[0]['item_obscured'] );
+ $arr['item_verified'] = ((array_key_exists('item_verified',$arr)) ? intval($arr['item_verified']) : $orig[0]['item_verified'] );
+ $arr['item_retained'] = ((array_key_exists('item_retained',$arr)) ? intval($arr['item_retained']) : $orig[0]['item_retained'] );
+ $arr['item_rss'] = ((array_key_exists('item_rss',$arr)) ? intval($arr['item_rss']) : $orig[0]['item_rss'] );
+ $arr['item_deleted'] = ((array_key_exists('item_deleted',$arr)) ? intval($arr['item_deleted']) : $orig[0]['item_deleted'] );
+ $arr['item_type'] = ((array_key_exists('item_type',$arr)) ? intval($arr['item_type']) : $orig[0]['item_type'] );
+ $arr['item_hidden'] = ((array_key_exists('item_hidden',$arr)) ? intval($arr['item_hidden']) : $orig[0]['item_hidden'] );
+ $arr['item_unpublished'] = ((array_key_exists('item_unpublished',$arr)) ? intval($arr['item_unpublished']) : $orig[0]['item_unpublished'] );
+ $arr['item_delayed'] = ((array_key_exists('item_delayed',$arr)) ? intval($arr['item_delayed']) : $orig[0]['item_delayed'] );
+ $arr['item_pending_remove'] = ((array_key_exists('item_pending_remove',$arr)) ? intval($arr['item_pending_remove']) : $orig[0]['item_pending_remove'] );
+ $arr['item_blocked'] = ((array_key_exists('item_blocked',$arr)) ? intval($arr['item_blocked']) : $orig[0]['item_blocked'] );
- $arr['attach'] = ((x($arr,'attach')) ? notags(trim($arr['attach'])) : $orig[0]['attach']);
- $arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : $orig[0]['app']);
-// $arr['item_restrict'] = ((x($arr,'item_restrict')) ? intval($arr['item_restrict']) : $orig[0]['item_restrict'] );
-// $arr['item_flags'] = ((x($arr,'item_flags')) ? intval($arr['item_flags']) : $orig[0]['item_flags'] );
$arr['sig'] = ((x($arr,'sig')) ? $arr['sig'] : '');
$arr['layout_mid'] = ((array_key_exists('layout_mid',$arr)) ? dbesc($arr['layout_mid']) : $orig[0]['layout_mid'] );
@@ -2664,11 +2702,10 @@ function store_diaspora_comment_sig($datarray, $channel, $parent_item, $post_id,
$x = array('signer' => $diaspora_handle, 'body' => $signed_body, 'signed_text' => $signed_text, 'signature' => base64_encode($authorsig));
- $key = get_config('system','pubkey');
- $y = crypto_encapsulate(json_encode($x),$key);
+ $y = json_encode($x);
$r = q("update item set diaspora_meta = '%s' where id = %d",
- dbesc(json_encode($y)),
+ dbesc($y),
intval($post_id)
);
@@ -2793,8 +2830,8 @@ function tag_deliver($uid, $item_id) {
$item = $i[0];
- if(($item['source_xchan']) && ($item['item_flags'] & ITEM_UPLINK)
- && ($item['item_flags'] & ITEM_THREAD_TOP) && ($item['edited'] != $item['created'])) {
+ if(($item['source_xchan']) && intval($item['item_uplink'])
+ && intval($item['item_thread_top']) && ($item['edited'] != $item['created'])) {
// this is an update (edit) to a post which was already processed by us and has a second delivery chain
// Just start the second delivery chain to deliver the updated post
proc_run('php','include/notifier.php','tgroup',$item['id']);
@@ -2816,7 +2853,7 @@ function tag_deliver($uid, $item_id) {
if($obj['id'] !== $u[0]['channel_hash'])
$poke_notify = false;
}
- if($item['item_restrict'] & ITEM_DELETED)
+ if(intval($item['item_deleted']))
$poke_notify = false;
$verb = urldecode(substr($item['verb'],strpos($item['verb'],'#')+1));
@@ -2893,13 +2930,13 @@ function tag_deliver($uid, $item_id) {
// This might be a followup (e.g. comment) by the original post author to a tagged forum
// If so setup a second delivery chain
- if( ! ($item['item_flags'] & ITEM_THREAD_TOP)) {
+ if( ! intval($item['item_thread_top'])) {
$x = q("select * from item where id = parent and parent = %d and uid = %d limit 1",
intval($item['parent']),
intval($uid)
);
- if(($x) && ($x[0]['item_flags'] & ITEM_UPLINK)) {
+ if(($x) && intval($x[0]['item_uplink'])) {
start_delivery_chain($u[0],$item,$item_id,$x[0]);
}
}
@@ -2927,9 +2964,8 @@ function tag_deliver($uid, $item_id) {
if($mention) {
logger('tag_deliver: mention found for ' . $u[0]['channel_name']);
-
- $r = q("update item set item_flags = ( item_flags | %d ) where id = %d",
- intval(ITEM_MENTIONSME),
+
+ $r = q("update item set item_mentionsme = 1 where id = %d",
intval($item_id)
);
@@ -2939,7 +2975,7 @@ function tag_deliver($uid, $item_id) {
$body = '';
- if($item['item_flags'] & ITEM_OBSCURED) {
+ if(intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
if($item['body'])
$body = crypto_unencapsulate(json_decode_plus($item['body']),$key);
@@ -3023,10 +3059,8 @@ function tag_deliver($uid, $item_id) {
// prevent delivery looping - only proceed
// if the message originated elsewhere and is a top-level post
- if(($item['item_flags'] & ITEM_WALL)
- || ($item['item_flags'] & ITEM_ORIGIN)
- || (!($item['item_flags'] & ITEM_THREAD_TOP))
- || ($item['id'] != $item['parent'])) {
+
+ if(intval($item['item_wall']) || intval($item['item_origin']) || (! intval($item['item_thread_top'])) || ($item['id'] != $item['parent'])) {
logger('tag_deliver: item was local or a comment. rejected.');
return;
}
@@ -3051,10 +3085,9 @@ function tgroup_check($uid,$item) {
// or is a followup and we have already accepted the top level post as an uplink
if($item['mid'] != $item['parent_mid']) {
- $r = q("select id from item where mid = '%s' and uid = %d and ( item_flags & %d )>0 limit 1",
+ $r = q("select id from item where mid = '%s' and uid = %d and item_uplink = 1 limit 1",
dbesc($item['parent_mid']),
- intval($uid),
- intval(ITEM_UPLINK)
+ intval($uid)
);
if($r)
return true;
@@ -3100,7 +3133,7 @@ function tgroup_check($uid,$item) {
$body = $item['body'];
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED) && $body) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured']) && $body) {
$key = get_config('system','prvkey');
$body = crypto_unencapsulate(json_decode($body,true),$key);
}
@@ -3163,20 +3196,14 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
if((! $private) && $new_public_policy)
$private = 1;
- $flag_bits = $item['item_flags'] | ITEM_WALL;
-
- // The message didn't necessarily originate on this site, (we'll honour it if it did),
- // but the parent post of this thread will be reset as a local post, as it is the top of
- // this delivery chain and is coming from this site, regardless of where the original
- // originated.
-
- if(! $parent)
- $flag_bits = $flag_bits | ITEM_ORIGIN;
- // unset the nocomment bit if it's there.
+ $item_wall = 1;
+ $item_origin = 1;
+ $item_uplink = 0;
+ $item_nocomment = 0;
+ $item_obscured = 0;
- if($flag_bits & ITEM_NOCOMMENT)
- $flag_bits = $flag_bits ^ ITEM_NOCOMMENT;
+ $flag_bits = $item['item_flags'];
// maintain the original source, which will be the original item owner and was stored in source_xchan
// when we created the delivery fork
@@ -3188,7 +3215,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
);
}
else {
- $flag_bits = $flag_bits | ITEM_UPLINK;
+ $item_uplink = 1;
$r = q("update item set source_xchan = owner_xchan where id = %d",
intval($item_id)
);
@@ -3197,29 +3224,22 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
$title = $item['title'];
$body = $item['body'];
- if($private) {
- if(!($flag_bits & ITEM_OBSCURED)) {
- $key = get_config('system','pubkey');
- $flag_bits = $flag_bits|ITEM_OBSCURED;
- if($title)
- $title = json_encode(crypto_encapsulate($title,$key));
- if($body)
- $body = json_encode(crypto_encapsulate($body,$key));
- }
- }
- else {
+ if(! $private) {
if($flag_bits & ITEM_OBSCURED) {
$key = get_config('system','prvkey');
- $flag_bits = $flag_bits ^ ITEM_OBSCURED;
if($title)
$title = crypto_unencapsulate(json_decode($title,true),$key);
if($body)
$body = crypto_unencapsulate(json_decode($body,true),$key);
+ $item_obscured = 0;
}
}
- $r = q("update item set item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
- deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s' where id = %d",
+ $r = q("update item set item_uplink = %d, item_nocomment = %d, item_obscured = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
+ deny_cid = '%s', deny_gid = '%s', item_private = %d, public_policy = '%s', comment_policy = '%s', title = '%s', body = '%s', item_wall = %d, item_origin = %d where id = %d",
+ intval($item_uplink),
+ intval($item_nocomment),
+ intval($item_obscured),
intval($flag_bits),
dbesc($channel['channel_hash']),
dbesc($channel['channel_allow_cid']),
@@ -3231,6 +3251,8 @@ function start_delivery_chain($channel, $item, $item_id, $parent) {
dbesc(map_scope($channel['channel_w_comment'])),
dbesc($title),
dbesc($body),
+ intval($item_wall),
+ $intval($item_origin),
intval($item_id)
);
@@ -3477,7 +3499,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
if($r) {
$item = $r[0];
- if(! ($item['item_restrict'] & ITEM_DELETED)) {
+ if(! intval($item['item_deleted'])) {
logger('consume_feed: deleting item ' . $item['id'] . ' mid=' . base64url_decode($item['mid']), LOGGER_DEBUG);
drop_item($item['id'],false);
}
@@ -3972,22 +3994,23 @@ function item_expire($uid,$days) {
$expire_network_only = 1;
+ $sql_extra = ((intval($expire_network_only)) ? " AND item_wall = 0 " : "");
+
$expire_limit = get_config('system','expire_limit');
if(! intval($expire_limit))
$expire_limit = 5000;
- $sql_extra = ((intval($expire_network_only)) ? " AND (item_flags & " . intval(ITEM_WALL) . ") = 0 " : "");
+ $item_normal = item_normal();
$r = q("SELECT * FROM `item`
WHERE `uid` = %d
AND `created` < %s - INTERVAL %s
AND `id` = `parent`
$sql_extra
- AND ( item_flags & %d ) = 0
- AND ( item_restrict = 0 ) LIMIT $expire_limit ",
+ AND item_retained = 0
+ $item_normal LIMIT $expire_limit ",
intval($uid),
- db_utcnow(), db_quoteinterval(intval($days).' DAY'),
- intval(ITEM_RETAINED)
+ db_utcnow(), db_quoteinterval(intval($days).' DAY')
);
if(! $r)
@@ -4011,7 +4034,7 @@ function item_expire($uid,$days) {
retain_item($item['id']);
continue;
}
- if($item['item_flags'] & ITEM_STARRED) {
+ if(intval($item['item_starred'])) {
retain_item($item['id']);
continue;
}
@@ -4023,8 +4046,7 @@ function item_expire($uid,$days) {
}
function retain_item($id) {
- $r = q("update item set item_flags = (item_flags | %d ) where id = %d",
- intval(ITEM_RETAINED),
+ $r = q("update item set item_retained = 1 where id = %d",
intval($id)
);
}
@@ -4069,7 +4091,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
intval($id)
);
- if((! $r) || (($r[0]['item_restrict'] & ITEM_DELETED) && ($stage === DROPITEM_NORMAL))) {
+ if((! $r) || (intval($r[0]['item_deleted']) && ($stage === DROPITEM_NORMAL))) {
if(! $interactive)
return 0;
notice( t('Item not found.') . EOL);
@@ -4105,10 +4127,16 @@ 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.
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ) WHERE id = %d",
- intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED),
- intval($item['id'])
- );
+ 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'])
+ );
+ }
$arr = array('item' => $item, 'interactive' => $interactive, 'stage' => $stage);
call_hooks('drop_item', $arr );
@@ -4137,7 +4165,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
// We'll rely on the undocumented behaviour that DROPITEM_PHASE1 is (hopefully) only
// set if we know we're going to send delete notifications out to others.
- if((($item['item_flags'] & ITEM_WALL) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1))
+ if((intval($item['item_wall']) && ($stage != DROPITEM_PHASE2)) || ($stage == DROPITEM_PHASE1))
proc_run('php','include/notifier.php','drop',$notify_id);
goaway($a->get_baseurl() . '/' . $_SESSION['return_url']);
@@ -4169,9 +4197,8 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
switch($stage) {
case DROPITEM_PHASE2:
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '',
+ $r = q("UPDATE item SET item_pending_remove = 1, body = '', title = '',
changed = '%s', edited = '%s' WHERE id = %d",
- intval(ITEM_PENDING_REMOVE),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
@@ -4179,30 +4206,37 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
break;
case DROPITEM_PHASE1:
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ),
- changed = '%s', edited = '%s' WHERE id = %d",
- intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED),
- dbesc(datetime_convert()),
- dbesc(datetime_convert()),
- intval($item['id'])
- );
+ 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 if = %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_restrict = ( item_restrict | %d ),
+ $r = q("UPDATE item SET item_hidden = 1,
changed = '%s', edited = '%s' WHERE id = %d",
- intval(ITEM_HIDDEN),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
);
}
else {
- $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), body = '', title = '',
+ $r = q("UPDATE item SET item_deleted = 1, body = '', title = '',
changed = '%s', edited = '%s' WHERE id = %d",
- intval(ITEM_DELETED),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
intval($item['id'])
@@ -4247,10 +4281,11 @@ function delete_item_lowlevel($item, $stage = DROPITEM_NORMAL, $force = false) {
function first_post_date($uid,$wall = false) {
- $wall_sql = (($wall) ? sprintf(" and (item_flags & %d)>0 ", ITEM_WALL) : "" );
+ $wall_sql = (($wall) ? " and item_wall = 1 " : "" );
+ $item_normal = item_normal();
$r = q("select id, created from item
- where item_restrict = %d and uid = %d and id = parent $wall_sql
+ where uid = %d and id = parent $item_normal $wall_sql
order by created asc limit 1",
intval(ITEM_VISIBLE),
intval($uid)
@@ -4451,23 +4486,23 @@ function zot_feed($uid,$observer_hash,$arr) {
return array();
}
+ $item_normal = item_normal();
+
if(is_sys_channel($uid)) {
$r = q("SELECT parent, created, postopts from item
WHERE uid != %d
- AND item_private = 0 AND item_restrict = 0 AND uid in (" . stream_perms_api_uids(PERMS_PUBLIC,10,1) . ")
- AND (item_flags & %d) > 0
- $sql_extra GROUP BY parent ORDER BY created ASC $limit",
- intval($uid),
- intval(ITEM_WALL)
+ and uid in (" . stream_perms_api_uids(PERMS_PUBLIC,10,1) . ") $item_normal
+ AND item_wall = 1
+ and item_private = 0 $sql_extra GROUP BY parent ORDER BY created ASC $limit",
+ intval($uid)
);
}
else {
$r = q("SELECT parent, created, postopts from item
- WHERE uid = %d AND item_restrict = 0
- AND (item_flags & %d) > 0
+ WHERE uid = %d $item_normal
+ AND item_wall = 1
$sql_extra GROUP BY parent ORDER BY created ASC $limit",
- intval($uid),
- intval(ITEM_WALL)
+ intval($uid)
);
}
@@ -4480,10 +4515,10 @@ function zot_feed($uid,$observer_hash,$arr) {
$parents_str = ids_to_querystr($r,'parent');
$sys_query = ((is_sys_channel($uid)) ? $sql_extra : '');
+ $item_normal = item_normal();
$items = q("SELECT `item`.*, `item`.`id` AS `item_id` FROM `item`
- WHERE `item`.`item_restrict` = 0
- AND `item`.`parent` IN ( %s ) $sys_query ",
+ WHERE `item`.`parent` IN ( %s ) $item_normal $sys_query ",
dbesc($parents_str)
);
}
@@ -4521,6 +4556,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
$def_acl = '';
$item_uids = ' true ';
+ $item_normal = item_normal();
+
if ($arr['uid']) $uid= $arr['uid'];
@@ -4531,13 +4568,13 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
}
if($arr['star'])
- $sql_options .= " and (item_flags & " . intval(ITEM_STARRED) . ")>0 ";
+ $sql_options .= " and item_starred = 1 ";
if($arr['wall'])
- $sql_options .= " and (item_flags & " . intval(ITEM_WALL) . ")>0 ";
-
- $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE (item_flags & " . intval(ITEM_THREAD_TOP) . ")>0 $sql_options ) ";
-
+ $sql_options .= " and item_wall = 1 ";
+
+ $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE item_thread_top = 1 $sql_options ) ";
+
if($arr['since_id'])
$sql_extra .= " and item.id > " . $since_id . " ";
@@ -4567,7 +4604,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
return $result;
}
- $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent and item_restrict = 0 ) ";
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str)) or allow_gid like '" . protect_sprintf('%<' . dbesc($r[0]['hash']) . '>%') . "' ) and id = parent $item_normal ) ";
$x = group_rec_byhash($uid,$r[0]['hash']);
$result['headline'] = sprintf( t('Collection: %s'),$x['name']);
@@ -4579,7 +4616,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
intval(local_channel())
);
if ($r) {
- $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval($arr['uid']) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) and item_restrict = 0 ) ";
+ $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval($arr['uid']) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' ) $item_normal ) ";
$result['headline'] = sprintf( t('Connection: %s'),$r[0]['xchan_name']);
} else {
$result['message'] = t('Connection not found.');
@@ -4600,24 +4637,24 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
}
if($arr['search']) {
- if(strpos($arr['search'],'#') === 0)
- $sql_extra .= term_query('item',substr($arr['search'],1),TERM_HASHTAG);
- else
- $sql_extra .= sprintf(" AND item.body like '%s' ",
- dbesc(protect_sprintf('%' . $arr['search'] . '%'))
- );
- }
- if (strlen($arr['file'])) {
- $sql_extra .= term_query('item',$arr['files'],TERM_FILE);
- }
+ if(strpos($arr['search'],'#') === 0)
+ $sql_extra .= term_query('item',substr($arr['search'],1),TERM_HASHTAG);
+ else
+ $sql_extra .= sprintf(" AND item.body like '%s' ",
+ dbesc(protect_sprintf('%' . $arr['search'] . '%'))
+ );
+ }
- if ($arr['conv'] && $channel) {
- $sql_extra .= sprintf(" AND parent IN (SELECT distinct parent from item where ( author_xchan like '%s' or ( item_flags & %d )>0)) ",
- dbesc(protect_sprintf($uidhash)),
- intval(ITEM_MENTIONSME)
- );
- }
+ if(strlen($arr['file'])) {
+ $sql_extra .= term_query('item',$arr['files'],TERM_FILE);
+ }
+
+ if($arr['conv'] && $channel) {
+ $sql_extra .= sprintf(" AND parent IN (SELECT distinct parent from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ",
+ dbesc(protect_sprintf($uidhash))
+ );
+ }
if (($client_mode & CLIENT_MODE_UPDATE) && (! ($client_mode & CLIENT_MODE_LOAD))) {
// only setup pagination on initial page view
@@ -4652,19 +4689,19 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C
}
}
- $simple_update = (($client_mode & CLIENT_MODE_UPDATE) ? " and ( item.item_unseen = 1 ) " : '');
- if ($client_mode & CLIENT_MODE_LOAD)
- $simple_update = '';
+ $simple_update = (($client_mode & CLIENT_MODE_UPDATE) ? " and item.item_unseen = 1 " : '');
+ if($client_mode & CLIENT_MODE_LOAD)
+ $simple_update = '';
//$start = dba_timer();
require_once('include/security.php');
$sql_extra .= item_permissions_sql($channel['channel_id'],$observer_hash);
- if ($arr['pages'])
- $item_restrict = " AND (item_restrict & " . ITEM_WEBPAGE . ") ";
+ if($arr['pages'])
+ $item_restrict = " AND item_type = " . ITEM_TYPE_WEBPAGE . " ";
else
- $item_restrict = " AND item_restrict = 0 ";
+ $item_restrict = " AND item_type = 0 ";
if ($arr['nouveau'] && ($client_mode & CLIENT_MODE_LOAD) && $channel) {
// "New Item View" - show all items unthreaded in reverse created date order
@@ -4768,11 +4805,11 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo
if(! $post_id)
return;
- if($webpage & ITEM_WEBPAGE)
+ if($webpage == ITEM_TYPE_WEBPAGE)
$page_type = 'WEBPAGE';
- elseif($webpage & ITEM_BUILDBLOCK)
+ elseif($webpage == ITEM_TYPE_BLOCK)
$page_type = 'BUILDBLOCK';
- elseif($webpage & ITEM_PDL)
+ elseif($webpage == ITEM_TYPE_PDL)
$page_type = 'PDL';
elseif($namespace && $remote_id) {
$page_type = $namespace;
@@ -4981,4 +5018,4 @@ function asencode_person($p) {
);
return $ret;
-} \ No newline at end of file
+}