aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2015-01-22 18:41:10 -0800
committerfriendica <info@friendica.com>2015-01-22 18:41:10 -0800
commit6e0e3b2433fc426b758a55811f56536d58705813 (patch)
treea8d8fb7c63216cea94765e93be935f2b9d2fe227 /include
parente46eba125888704b4381aa8418495e91eeb565c8 (diff)
downloadvolse-hubzilla-6e0e3b2433fc426b758a55811f56536d58705813.tar.gz
volse-hubzilla-6e0e3b2433fc426b758a55811f56536d58705813.tar.bz2
volse-hubzilla-6e0e3b2433fc426b758a55811f56536d58705813.zip
more expanding item flags
Diffstat (limited to 'include')
-rw-r--r--include/bb2diaspora.php2
-rw-r--r--include/conversation.php15
-rwxr-xr-xinclude/diaspora.php2
-rw-r--r--include/enotify.php2
-rwxr-xr-xinclude/items.php46
-rw-r--r--include/text.php2
6 files changed, 30 insertions, 39 deletions
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index e8f81aec4..5b675128f 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -304,7 +304,7 @@ function bb2diaspora_itembody($item,$force_update = false) {
$newitem = $item;
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
$b = json_decode($item['body'],true);
// if called from diaspora_process_outbound, this decoding has already been done.
diff --git a/include/conversation.php b/include/conversation.php
index e81bb49e0..5a9e4a59e 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -357,21 +357,12 @@ function localize_item(&$item){
}
}
*/
- // add sparkle links to appropriate permalinks
-
-// $x = stristr($item['plink'],'/display/');
-// if($x) {
-// $sparkle = false;
-// $y = best_link_url($item,$sparkle,true);
- // if($sparkle)
-// $item['plink'] = $y . '?f=&url=' . $item['plink'];
-// }
// if item body was obscured and we changed it, re-obscure it
// FIXME - we need a better filter than just the string 'data'; try and
// match the fact that it's json encoded
- if(($item['item_flags'] & ITEM_OBSCURED)
+ if(intval($item['item_obscured'])
&& strlen($item['body']) && (! strpos($item['body'],'data'))) {
$item['body'] = json_encode(crypto_encapsulate($item['body'],get_config('system','pubkey')));
}
@@ -655,8 +646,8 @@ function conversation(&$a, $items, $mode, $update, $page_mode = 'traditional', $
$likebuttons = false;
$shareable = false;
- $verified = (($item['item_flags'] & ITEM_VERIFIED) ? t('Message signature validated') : '');
- $forged = ((($item['sig']) && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message signature incorrect') : '');
+ $verified = (intval($item['item_verified']) ? t('Message signature validated') : '');
+ $forged = ((($item['sig']) && (! intval($item['item_verified']))) ? t('Message signature incorrect') : '');
$unverified = '';
diff --git a/include/diaspora.php b/include/diaspora.php
index 4e7b968e7..b9c6e5c92 100755
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -157,7 +157,7 @@ function diaspora_process_outbound($arr) {
$target_item = $arr['target_item'];
- if($target_item && array_key_exists('item_flags',$target_item) && ($target_item['item_flags'] & ITEM_OBSCURED)) {
+ if($target_item && array_key_exists('item_obscured',$target_item) && intval($target_item['item_obscured'])) {
$key = get_config('system','prvkey');
if($target_item['title'])
$target_item['title'] = crypto_unencapsulate(json_decode($target_item['title'],true),$key);
diff --git a/include/enotify.php b/include/enotify.php
index 53f1ae5ef..34552cc36 100644
--- a/include/enotify.php
+++ b/include/enotify.php
@@ -65,7 +65,7 @@ function notification($params) {
localize_item($i);
$title = $i['title'];
$body = $i['body'];
- $private = (($i['item_private']) || ($i['item_flags'] & ITEM_OBSCURED));
+ $private = (($i['item_private']) || intval($i['item_obscured']));
}
else {
$title = $params['item']['title'];
diff --git a/include/items.php b/include/items.php
index 2478d773c..43739b605 100755
--- a/include/items.php
+++ b/include/items.php
@@ -396,13 +396,13 @@ 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;
+ $arr['item_obscured'] = 1;
if($arr['title'])
$arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
if($arr['body'])
@@ -870,7 +870,7 @@ 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.');
}
@@ -883,7 +883,7 @@ function get_item_elements($x) {
if(intval($arr['item_private'])) {
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
+ $arr['item_obscured'] = 1;
if($arr['title'])
$arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
if($arr['body'])
@@ -1066,7 +1066,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'])
@@ -1475,7 +1475,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
@@ -1956,7 +1956,7 @@ function item_store($arr,$allow_exec = false) {
// 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
@@ -1967,7 +1967,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;
}
}
@@ -1985,7 +1985,7 @@ function item_store($arr,$allow_exec = false) {
}
if($arr['item_private']) {
$key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
+ $arr['item_obscured'] = 1;
if($arr['title'])
$arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
if($arr['body'])
@@ -2349,7 +2349,7 @@ 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
@@ -2377,7 +2377,7 @@ function item_store_update($arr,$allow_exec = false) {
}
if($arr['item_private']) {
$key = get_config('system','pubkey');
- $arr['item_flags'] = $arr['item_flags'] | ITEM_OBSCURED;
+ $arr['item_obscured'] = 1;
if($arr['title'])
$arr['title'] = json_encode(crypto_encapsulate($arr['title'],$key));
if($arr['body'])
@@ -2834,7 +2834,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);
@@ -2981,7 +2981,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);
}
@@ -3025,6 +3025,7 @@ function start_delivery_chain($channel,$item,$item_id,$parent) {
$item_origin = 1;
$item_uplink = 0;
$item_nocomment = 0;
+ $item_obscured = 0;
$flag_bits = $item['item_flags'];
@@ -3048,30 +3049,31 @@ function start_delivery_chain($channel,$item,$item_id,$parent) {
$body = $item['body'];
if($private) {
- if(!($flag_bits & ITEM_OBSCURED)) {
+ if(! intval($item['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));
+ $item_obscured = 1;
}
}
else {
- if($flag_bits & ITEM_OBSCURED) {
+ if(intval($item['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_uplink = %d, item_nocomment = %d, item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s',
+ $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']),
@@ -3860,11 +3862,10 @@ function item_expire($uid,$days) {
AND `created` < %s - INTERVAL %s
AND `id` = `parent`
$sql_extra
- AND NOT ( item_flags & %d )>0
+ AND item_retained = 0
AND (item_restrict = 0 ) ",
intval($uid),
- db_utcnow(), db_quoteinterval(intval($days).' DAY'),
- intval(ITEM_RETAINED)
+ db_utcnow(), db_quoteinterval(intval($days).' DAY')
);
if(! $r)
@@ -3901,8 +3902,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)
);
}
diff --git a/include/text.php b/include/text.php
index 720895810..101d6ca2e 100644
--- a/include/text.php
+++ b/include/text.php
@@ -1152,7 +1152,7 @@ function link_compare($a,$b) {
function unobscure(&$item) {
- if(array_key_exists('item_flags',$item) && ($item['item_flags'] & ITEM_OBSCURED)) {
+ if(array_key_exists('item_obscured',$item) && intval($item['item_obscured'])) {
$key = get_config('system','prvkey');
if($item['title'])
$item['title'] = crypto_unencapsulate(json_decode_plus($item['title']),$key);