From 6f11f20992c88ff48a55929e94d9003fcc437062 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 20 Jan 2015 15:35:42 -0800 Subject: first cut at unpacking bitfields in hubloc, fixed hubloc_error and hubloc_deleted --- include/Contact.php | 28 +++++++++------------------- include/hubloc.php | 3 +-- include/notifier.php | 7 ++----- include/onedirsync.php | 2 +- include/zot.php | 32 +++++++++++++------------------- 5 files changed, 26 insertions(+), 46 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 4c80f5d6a..4a016e32f 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -272,8 +272,7 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { ); - $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s'", - intval(HUBLOC_FLAGS_DELETED), + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", dbesc($channel['channel_hash']) ); @@ -312,8 +311,7 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { intval($channel_id) ); - $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s' and hubloc_url = '%s' ", - intval(HUBLOC_FLAGS_DELETED), + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s' and hubloc_url = '%s' ", dbesc($channel['channel_hash']), dbesc(z_root()) ); @@ -322,9 +320,8 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { $hublocs = 0; - $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and not (hubloc_flags & %d)>0", - dbesc($channel['channel_hash']), - intval(HUBLOC_FLAGS_DELETED) + $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_deleted = 0", + dbesc($channel['channel_hash']) ); if($r) $hublocs = count($r); @@ -374,10 +371,8 @@ function mark_orphan_hubsxchans() { if($dirmode == DIRECTORY_MODE_NORMAL) return; - $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d)>0 + $r = q("update hubloc set hubloc_error = 1 where hubloc_error = 0 and hubloc_network = 'zot' and hubloc_connected < %s - interval %s", - intval(HUBLOC_OFFLINE), - intval(HUBLOC_OFFLINE), db_utcnow(), db_quoteinterval('36 day') ); @@ -394,9 +389,7 @@ function mark_orphan_hubsxchans() { // } - $r = q("select hubloc_id, hubloc_hash from hubloc where (hubloc_status & %d)>0 and not (hubloc_flags & %d)>0", - intval(HUBLOC_OFFLINE), - intval(HUBLOC_FLAGS_ORPHANCHECK) + $r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_error = 0 and hubloc_orphancheck = 0", ); if($r) { @@ -404,9 +397,8 @@ function mark_orphan_hubsxchans() { // see if any other hublocs are still alive for this channel - $x = q("select * from hubloc where hubloc_hash = '%s' and not (hubloc_status & %d)>0", + $x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0", dbesc($rr['hubloc_hash']), - intval(HUBLOC_OFFLINE) ); if($x) { @@ -431,8 +423,7 @@ function mark_orphan_hubsxchans() { // mark that we've checked this entry so we don't need to do it again - $y = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d", - intval(HUBLOC_FLAGS_ORPHANCHECK), + $y = q("update hubloc set hubloc_orphancheck = 1 where hubloc_id = %d", dbesc($rr['hubloc_id']) ); } @@ -501,8 +492,7 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) { // directory servers need to keep the record around for sync purposes - mark it deleted - $r = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_hash = '%s'", - intval(HUBLOC_FLAGS_DELETED), + $r = q("update hubloc set hubloc_deleted = 1 where hubloc_hash = '%s'", dbesc($xchan) ); diff --git a/include/hubloc.php b/include/hubloc.php index b5a3d47c5..92736e090 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -96,8 +96,7 @@ function remove_obsolete_hublocs() { ? intval(get_config('system','delivery_interval')) : 2 ); foreach($r as $rr) { - q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d", - intval(HUBLOC_FLAGS_DELETED), + q("update hubloc set hubloc_deleted = 1 where hubloc_id = %d", intval($rr['hubloc_id']) ); diff --git a/include/notifier.php b/include/notifier.php index 06ef7bc94..0bdc71261 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -497,11 +497,8 @@ function notifier_run($argv, $argc){ where hubloc_hash in (" . implode(',',$recipients) . ") order by hubloc_connected desc limit 1"); } else { - $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc - where hubloc_hash in (" . implode(',',$recipients) . ") and not (hubloc_flags & %d) > 0 and not (hubloc_status & %d) > 0", - intval(HUBLOC_FLAGS_DELETED), - intval(HUBLOC_OFFLINE) - ); + $r = q("select * from hubloc where hubloc_hash in (" . implode(',',$recipients) . ") + and hubloc_error = 0 and hubloc_deleted = 0"); } if(! $r) { diff --git a/include/onedirsync.php b/include/onedirsync.php index a1450e183..c94a1410f 100644 --- a/include/onedirsync.php +++ b/include/onedirsync.php @@ -55,7 +55,7 @@ function onedirsync_run($argv, $argc){ $h = q("select * from hubloc where hubloc_addr = '%s' limit 1", dbesc($r[0]['ud_addr']) ); - if(($h) && ($h[0]['hubloc_status'] & HUBLOC_OFFLINE)) { + if(($h) && (intval($h[0]['hubloc_error']))) $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date < '%s' ", intval(UPDATE_FLAGS_UPDATED), dbesc($r[0]['ud_addr']), diff --git a/include/zot.php b/include/zot.php index 384769d61..ac5127f1c 100644 --- a/include/zot.php +++ b/include/zot.php @@ -79,9 +79,8 @@ function zot_get_hublocs($hash) { /** Only search for active hublocs - e.g. those that haven't been marked deleted */ - $ret = q("select * from hubloc where hubloc_hash = '%s' and not ( hubloc_flags & %d )>0 order by hubloc_url ", - dbesc($hash), - intval(HUBLOC_FLAGS_DELETED) + $ret = q("select * from hubloc where hubloc_hash = '%s' and hubloc_deleted != 0 order by hubloc_url ", + dbesc($hash) ); return $ret; } @@ -1884,9 +1883,8 @@ function sync_locations($sender,$arr,$absolute = false) { // Should we do this? It's basically saying that the channel knows better than // the directory server if the site is alive. - if($r[0]['hubloc_status'] & HUBLOC_OFFLINE) { - q("update hubloc set hubloc_status = (hubloc_status & ~%d) where hubloc_id = %d", - intval(HUBLOC_OFFLINE), + if($r[0]['hubloc_error']) { + q("update hubloc set hubloc_error = 0 where hubloc_id = %d", intval($r[0]['hubloc_id']) ); if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { @@ -1934,10 +1932,10 @@ function sync_locations($sender,$arr,$absolute = false) { $changed = true; } } - if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED) && (! $location['deleted'])) - || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_DELETED)) && ($location['deleted']))) { - $n = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", - intval(HUBLOC_FLAGS_DELETED), + if((intval($r[0]['hubloc_deleted']) && (! $location['deleted'])) + || ((! (intval($r[0]['hubloc_deleted']))) && ($location['deleted']))) { + $n = q("update hubloc set hubloc_deleted = %d, hubloc_updated = '%s' where hubloc_id = %d", + intval($location['deleted']), dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); @@ -1994,8 +1992,7 @@ function sync_locations($sender,$arr,$absolute = false) { foreach($xisting as $x) { if(! array_key_exists('updated',$x)) { logger('sync_locations: deleting unreferenced hub location ' . $x['hubloc_url']); - $r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", - intval(HUBLOC_FLAGS_DELETED), + $r = q("update hubloc set hubloc_deleted = 1, hubloc_updated = '%s' where hubloc_id = %d", dbesc(datetime_convert()), intval($x['hubloc_id']) ); @@ -2029,7 +2026,7 @@ function zot_encode_locations($channel) { 'url_sig' => $hub['hubloc_url_sig'], 'callback' => $hub['hubloc_callback'], 'sitekey' => $hub['hubloc_sitekey'], - 'deleted' => (($hub['hubloc_flags'] & HUBLOC_FLAGS_DELETED) ? true : false) + 'deleted' => (intval($hub['hubloc_deleted']) ? true : false) ); } } @@ -2917,12 +2914,9 @@ function zot_process_message_request($data) { if($messages) { $env_recips = null; - $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host - from hubloc where hubloc_hash = '%s' and not (hubloc_flags & %d)>0 - and not (hubloc_status & %d)>0 group by hubloc_sitekey", - dbesc($sender_hash), - intval(HUBLOC_FLAGS_DELETED), - intval(HUBLOC_OFFLINE) + $r = q("select * from hubloc where hubloc_hash = '%s' and not hubloc_error and not hubloc_deleted + group by hubloc_sitekey", + dbesc($sender_hash) ); if(! $r) { logger('no hubs'); -- cgit v1.2.3 From ee3eee425c92b37fba5a7035d8e9ec0b0b563d0b Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 20 Jan 2015 16:13:18 -0800 Subject: that should take care of the bitfields in hubloc --- include/Contact.php | 10 ++++---- include/fixd.php | 33 --------------------------- include/hubloc.php | 2 +- include/identity.php | 4 ++-- include/network.php | 5 ++-- include/notifier.php | 2 +- include/onedirsync.php | 2 +- include/text.php | 6 ++--- include/zot.php | 62 ++++++++++++++++++++++---------------------------- 9 files changed, 41 insertions(+), 85 deletions(-) delete mode 100644 include/fixd.php (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index 4a016e32f..c872dc913 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -22,9 +22,8 @@ function rconnect_url($channel_id,$xchan) { if(($r) && ($r[0]['xchan_follow'])) return $r[0]['xchan_follow']; - $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d )>0 limit 1", - dbesc($xchan), - intval(HUBLOC_FLAGS_PRIMARY) + $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and hubloc_primary = 1 limit 1", + dbesc($xchan) ); if($r) @@ -389,8 +388,7 @@ function mark_orphan_hubsxchans() { // } - $r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_error = 0 and hubloc_orphancheck = 0", - ); + $r = q("select hubloc_id, hubloc_hash from hubloc where hubloc_error = 0 and hubloc_orphancheck = 0"); if($r) { foreach($r as $rr) { @@ -398,7 +396,7 @@ function mark_orphan_hubsxchans() { // see if any other hublocs are still alive for this channel $x = q("select * from hubloc where hubloc_hash = '%s' and hubloc_error = 0", - dbesc($rr['hubloc_hash']), + dbesc($rr['hubloc_hash']) ); if($x) { diff --git a/include/fixd.php b/include/fixd.php deleted file mode 100644 index bce5eb348..000000000 --- a/include/fixd.php +++ /dev/null @@ -1,33 +0,0 @@ -get_hostname()), - intval(($primary) ? HUBLOC_FLAGS_PRIMARY : 0), + intval($primary), dbesc(z_root()), dbesc(base64url_encode(rsa_sign(z_root(),$ret['channel']['channel_prvkey']))), dbesc(get_app()->get_hostname()), diff --git a/include/network.php b/include/network.php index 170b77d7d..8082d0217 100644 --- a/include/network.php +++ b/include/network.php @@ -1113,7 +1113,7 @@ function discover_by_webbie($webbie) { if(! $r) { - $r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated, hubloc_flags ) values ('%s','%s','%s','%s','%s','%s','%s','%s', %d)", + $r = q("insert into hubloc ( hubloc_guid, hubloc_hash, hubloc_addr, hubloc_network, hubloc_url, hubloc_host, hubloc_callback, hubloc_updated, hubloc_primary ) values ('%s','%s','%s','%s','%s','%s','%s','%s', 1)", dbesc($guid), dbesc($addr), dbesc($addr), @@ -1121,8 +1121,7 @@ function discover_by_webbie($webbie) { dbesc(trim($diaspora_base,'/')), dbesc($hostname), dbesc($notify), - dbescdate(datetime_convert()), - intval(HUBLOC_FLAGS_PRIMARY) + dbescdate(datetime_convert()) ); } $photos = import_profile_photo($vcard['photo'],$addr); diff --git a/include/notifier.php b/include/notifier.php index 0bdc71261..29646fb38 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -493,7 +493,7 @@ function notifier_run($argv, $argc){ // aren't the owner or author. - $r = q("select hubloc_guid, hubloc_url, hubloc_sitekey, hubloc_network, hubloc_flags, hubloc_callback, hubloc_host from hubloc + $r = q("select * from hubloc where hubloc_hash in (" . implode(',',$recipients) . ") order by hubloc_connected desc limit 1"); } else { diff --git a/include/onedirsync.php b/include/onedirsync.php index c94a1410f..e611492af 100644 --- a/include/onedirsync.php +++ b/include/onedirsync.php @@ -55,7 +55,7 @@ function onedirsync_run($argv, $argc){ $h = q("select * from hubloc where hubloc_addr = '%s' limit 1", dbesc($r[0]['ud_addr']) ); - if(($h) && (intval($h[0]['hubloc_error']))) + if(($h) && (intval($h[0]['hubloc_error']))) { $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date < '%s' ", intval(UPDATE_FLAGS_UPDATED), dbesc($r[0]['ud_addr']), diff --git a/include/text.php b/include/text.php index b6e4abf24..fcd7b422c 100644 --- a/include/text.php +++ b/include/text.php @@ -1890,13 +1890,13 @@ function xchan_query(&$items,$abook = true,$effective_uid = 0) { if(count($arr)) { if($abook) { $chans = q("select * from xchan left join hubloc on hubloc_hash = xchan_hash left join abook on abook_xchan = xchan_hash and abook_channel = %d - where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0", + where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1", intval($item['uid']) ); } else { $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash - where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0"); + where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1"); } $xchans = q("select * from xchan where xchan_hash in (" . implode(',',$arr) . ") and xchan_network in ('rss','unknown')"); if(! $chans) @@ -1924,7 +1924,7 @@ function xchan_mail_query(&$item) { if(count($arr)) { $chans = q("select xchan.*,hubloc.* from xchan left join hubloc on hubloc_hash = xchan_hash - where xchan_hash in (" . implode(',', $arr) . ") and ( hubloc_flags & " . intval(HUBLOC_FLAGS_PRIMARY) . " )>0"); + where xchan_hash in (" . implode(',', $arr) . ") and hubloc_primary = 1"); } if($chans) { $item['from'] = find_xchan_in_array($item['from_xchan'],$chans); diff --git a/include/zot.php b/include/zot.php index ac5127f1c..debd2c8a8 100644 --- a/include/zot.php +++ b/include/zot.php @@ -201,9 +201,8 @@ function zot_finger($webbie,$channel,$autofallback = true) { $r = q("select xchan.*, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash - where xchan_addr = '%s' and (hubloc_flags & %d) > 0 limit 1", - dbesc($xchan_addr), - intval(HUBLOC_FLAGS_PRIMARY) + where xchan_addr = '%s' and hubloc_primary = 1 limit 1", + dbesc($xchan_addr) ); if($r) { @@ -300,9 +299,8 @@ function zot_refresh($them,$channel = null, $force = false) { if($them['hubloc_url']) $url = $them['hubloc_url']; else { - $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) > 0 limit 1", - dbesc($them['xchan_hash']), - intval(HUBLOC_FLAGS_PRIMARY) + $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and hubloc_primary = 1 limit 1", + dbesc($them['xchan_hash']) ); if($r) $url = $r[0]['hubloc_url']; @@ -1887,9 +1885,8 @@ function sync_locations($sender,$arr,$absolute = false) { q("update hubloc set hubloc_error = 0 where hubloc_id = %d", intval($r[0]['hubloc_id']) ); - if($r[0]['hubloc_flags'] & HUBLOC_FLAGS_ORPHANCHECK) { - q("update hubloc set hubloc_flags = (hubloc_flags & ~%d) where hubloc_id = %d", - intval(HUBLOC_FLAGS_ORPHANCHECK), + if(intval($r[0]['hubloc_orphancheck'])) { + q("update hubloc set hubloc_orphancheck = 0 where hubloc_id = %d", intval($r[0]['hubloc_id']) ); } @@ -1911,15 +1908,15 @@ function sync_locations($sender,$arr,$absolute = false) { } } - if((($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) && (! $location['primary'])) - || ((! ($r[0]['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY)) && ($location['primary']))) { - $m = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_id = %d", - intval(HUBLOC_FLAGS_PRIMARY), + if((intval($r[0]['hubloc_primary']) && (! $location['primary'])) + || ((! intval($r[0]['hubloc_primary'])) && ($location['primary']))) { + $m = q("update hubloc set hubloc_primary = %d, hubloc_updated = '%s' where hubloc_id = %d", + intval($location['primary']), dbesc(datetime_convert()), intval($r[0]['hubloc_id']) ); // make sure hubloc_change_primary() has current data - $r[0]['hubloc_flags'] = $r[0]['hubloc_flags'] ^ HUBLOC_FLAGS_PRIMARY; + $r[0]['hubloc_primary'] = intval($location['primary']); hubloc_change_primary($r[0]); $what .= 'primary_hub '; $changed = true; @@ -1949,22 +1946,20 @@ function sync_locations($sender,$arr,$absolute = false) { // New hub claiming to be primary. Make it so by removing any existing primaries. if(intval($location['primary'])) { - $r = q("update hubloc set hubloc_flags = (hubloc_flags & ~%d), hubloc_updated = '%s' where hubloc_hash = '%s' and (hubloc_flags & %d )>0", - intval(HUBLOC_FLAGS_PRIMARY), + $r = q("update hubloc set hubloc_primary = 0, hubloc_updated = '%s' where hubloc_hash = '%s' and hubloc_primary = 1", dbesc(datetime_convert()), - dbesc($sender['hash']), - intval(HUBLOC_FLAGS_PRIMARY) + dbesc($sender['hash']) ); } logger('sync_locations: new hub: ' . $location['url']); - $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_network, hubloc_flags, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_updated, hubloc_connected) + $r = q("insert into hubloc ( hubloc_guid, hubloc_guid_sig, hubloc_hash, hubloc_addr, hubloc_network, hubloc_primary, hubloc_url, hubloc_url_sig, hubloc_host, hubloc_callback, hubloc_sitekey, hubloc_updated, hubloc_connected) values ( '%s','%s','%s','%s', '%s', %d ,'%s','%s','%s','%s','%s','%s','%s')", dbesc($sender['guid']), dbesc($sender['guid_sig']), dbesc($sender['hash']), dbesc($location['address']), dbesc('zot'), - intval((intval($location['primary'])) ? HUBLOC_FLAGS_PRIMARY : 0), + intval($location['primary']), dbesc($location['url']), dbesc($location['url_sig']), dbesc($location['host']), @@ -2017,18 +2012,16 @@ function zot_encode_locations($channel) { $x = zot_get_hublocs($channel['channel_hash']); if($x && count($x)) { foreach($x as $hub) { - if(! ($hub['hubloc_flags'] & HUBLOC_FLAGS_UNVERIFIED)) { - $ret[] = array( - 'host' => $hub['hubloc_host'], - 'address' => $hub['hubloc_addr'], - 'primary' => (($hub['hubloc_flags'] & HUBLOC_FLAGS_PRIMARY) ? true : false), - 'url' => $hub['hubloc_url'], - 'url_sig' => $hub['hubloc_url_sig'], - 'callback' => $hub['hubloc_callback'], - 'sitekey' => $hub['hubloc_sitekey'], - 'deleted' => (intval($hub['hubloc_deleted']) ? true : false) - ); - } + $ret[] = array( + 'host' => $hub['hubloc_host'], + 'address' => $hub['hubloc_addr'], + 'primary' => (intval($hub['hubloc_primary']) ? true : false), + 'url' => $hub['hubloc_url'], + 'url_sig' => $hub['hubloc_url_sig'], + 'callback' => $hub['hubloc_callback'], + 'sitekey' => $hub['hubloc_sitekey'], + 'deleted' => (intval($hub['hubloc_deleted']) ? true : false) + ); } } return $ret; @@ -2843,10 +2836,9 @@ function get_rpost_path($observer) { function import_author_zot($x) { $hash = make_xchan_hash($x['guid'],$x['guid_sig']); - $r = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and (hubloc_flags & %d)>0 limit 1", + $r = q("select hubloc_url from hubloc where hubloc_guid = '%s' and hubloc_guid_sig = '%s' and hubloc_primary = 1 limit 1", dbesc($x['guid']), - dbesc($x['guid_sig']), - intval(HUBLOC_FLAGS_PRIMARY) + dbesc($x['guid_sig']) ); if($r) { -- cgit v1.2.3 From 51848c619080e19cace647966a17eb9a1b42ca25 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 20 Jan 2015 19:33:19 -0800 Subject: working through the xchan table to remove bitfields, mostly complete except for updating the updater --- include/Contact.php | 16 ++++-------- include/dir_fns.php | 16 +++--------- include/group.php | 3 +-- include/hubloc.php | 10 ++++++-- include/identity.php | 8 +++--- include/socgraph.php | 12 +++------ include/text.php | 13 +++++----- include/zot.php | 70 +++++++++++++++++++--------------------------------- 8 files changed, 58 insertions(+), 90 deletions(-) (limited to 'include') diff --git a/include/Contact.php b/include/Contact.php index c872dc913..b01ac0174 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -276,8 +276,7 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { ); - $r = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s'", - intval(XCHAN_FLAGS_DELETED), + $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", dbesc($channel['channel_hash']) ); @@ -326,8 +325,7 @@ function channel_remove($channel_id, $local = true, $unset_session=true) { $hublocs = count($r); if(! $hublocs) { - $r = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s' ", - intval(XCHAN_FLAGS_DELETED), + $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s' ", dbesc($channel['channel_hash']) ); } @@ -402,9 +400,7 @@ function mark_orphan_hubsxchans() { // yes - if the xchan was marked as an orphan, undo it - $y = q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'", - intval(XCHAN_FLAGS_ORPHAN), - intval(XCHAN_FLAGS_ORPHAN), + $y = q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'", dbesc($rr['hubloc_hash']) ); @@ -413,8 +409,7 @@ function mark_orphan_hubsxchans() { // nope - mark the xchan as an orphan - $y = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s'", - intval(XCHAN_FLAGS_ORPHAN), + $y = q("update xchan set xchan_orphan = 1 where xchan_hash = '%s'", dbesc($rr['hubloc_hash']) ); } @@ -494,8 +489,7 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) { dbesc($xchan) ); - $r = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s'", - intval(XCHAN_FLAGS_DELETED), + $r = q("update xchan set xchan_deleted = 1 where xchan_hash = '%s'", dbesc($xchan) ); } diff --git a/include/dir_fns.php b/include/dir_fns.php index 6d06fddd1..86be8662c 100644 --- a/include/dir_fns.php +++ b/include/dir_fns.php @@ -295,23 +295,15 @@ function local_dir_update($uid,$force) { logger('hidden: ' . $hidden); - $r = q("select xchan_flags from xchan where xchan_hash = '%s' limit 1", + $r = q("select xchan_hidden from xchan where xchan_hash = '%s' limit 1", dbesc($p[0]['channel_hash']) ); - // Be careful - XCHAN_FLAGS_HIDDEN should evaluate to 1 - if(($r[0]['xchan_flags'] & XCHAN_FLAGS_HIDDEN) != $hidden) - $new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_HIDDEN; - else - $new_flags = $r[0]['xchan_flags']; - - if($new_flags != $r[0]['xchan_flags']) { - - $r = q("update xchan set xchan_flags = %d where xchan_hash = '%s'", - intval($new_flags), + if(intval($r[0]['xchan_hidden']) != $hidden) { + $r = q("update xchan set xchan_hidden = %d where xchan_hash = '%s'", + intval($hidden), dbesc($p[0]['channel_hash']) ); - } $address = $p[0]['channel_address'] . '@' . get_app()->get_hostname(); diff --git a/include/group.php b/include/group.php index 28cf5d80d..08361a81d 100644 --- a/include/group.php +++ b/include/group.php @@ -200,11 +200,10 @@ function group_get_members($gid) { if(intval($gid)) { $r = q("SELECT * FROM `group_member` LEFT JOIN abook ON abook_xchan = `group_member`.`xchan` left join xchan on xchan_hash = abook_xchan - WHERE `gid` = %d AND abook_channel = %d and `group_member`.`uid` = %d and not ( xchan_flags & %d )>0 and not ( abook_flags & %d )>0 and not ( abook_flags & %d )>0 ORDER BY xchan_name ASC ", + WHERE `gid` = %d AND abook_channel = %d and `group_member`.`uid` = %d and xchan_deleted = 0 and not ( abook_flags & %d )>0 and not ( abook_flags & %d )>0 ORDER BY xchan_name ASC ", intval($gid), intval(local_user()), intval(local_user()), - intval(XCHAN_FLAGS_DELETED), intval(ABOOK_FLAG_BLOCKED), intval(ABOOK_FLAG_PENDING) ); diff --git a/include/hubloc.php b/include/hubloc.php index cde166e8d..2367744ec 100644 --- a/include/hubloc.php +++ b/include/hubloc.php @@ -193,7 +193,7 @@ function xchan_store($arr) { if(! $arr['photo']) $arr['photo'] = get_default_profile_photo(); - $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_instance_url, xchan_flags, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s','%s','%s',%d,'%s') ", + $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_instance_url, xchan_hidden, xchan_orphan, xchan_censored, xchan_selfcensored, xchan_system, xchan_pubforum, xchan_deleted, xchan_name_date ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s','%s','%s','%s',%d, %d, %d, %d, %d, %d, %d, '%s') ", dbesc($arr['hash']), dbesc($arr['guid']), dbesc($arr['guid_sig']), @@ -206,7 +206,13 @@ function xchan_store($arr) { dbesc($arr['name']), dbesc($arr['network']), dbesc($arr['instance_url']), - intval($arr['flags']), + intval($arr['hidden']), + intval($arr['orphan']), + intval($arr['censored']), + intval($arr['selfcensored']), + intval($arr['system']), + intval($arr['pubforum']), + intval($arr['deleted']), dbesc(datetime_convert()) ); if(! $r) diff --git a/include/identity.php b/include/identity.php index f5a729573..e196cb247 100644 --- a/include/identity.php +++ b/include/identity.php @@ -99,7 +99,7 @@ function create_sys_channel() { 'name' => 'System', 'pageflags' => PAGE_SYSTEM, 'publish' => 0, - 'xchanflags' => XCHAN_FLAGS_SYSTEM + 'system' => 1 )); } @@ -185,7 +185,7 @@ function create_identity($arr) { $name = escape_tags($arr['name']); $pageflags = ((x($arr,'pageflags')) ? intval($arr['pageflags']) : PAGE_NORMAL); - $xchanflags = ((x($arr,'xchanflags')) ? intval($arr['xchanflags']) : XCHAN_FLAGS_NORMAL); + $system = ((x($arr,'system')) ? intval($arr['system']) : 0); $name_error = validate_channelname($arr['name']); if($name_error) { $ret['message'] = $name_error; @@ -312,7 +312,7 @@ function create_identity($arr) { $newuid = $ret['channel']['channel_id']; - $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", + $r = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_l, xchan_photo_m, xchan_photo_s, xchan_addr, xchan_url, xchan_follow, xchan_connurl, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_system ) values ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d)", dbesc($hash), dbesc($guid), dbesc($sig), @@ -328,7 +328,7 @@ function create_identity($arr) { dbesc('zot'), dbesc(datetime_convert()), dbesc(datetime_convert()), - intval($xchanflags) + intval($system) ); // Not checking return value. diff --git a/include/socgraph.php b/include/socgraph.php index 15ef480f6..466f4212d 100644 --- a/include/socgraph.php +++ b/include/socgraph.php @@ -340,14 +340,12 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) { and not xlink_link in ( select abook_xchan from abook where abook_channel = %d ) and not xlink_link in ( select xchan from xign where uid = %d ) and xlink_xchan != '' - and not ( xchan_flags & %d )>0 - and not ( xchan_flags & %d )>0 + and xchan_hidden = 0 + and xchan_deleted = 0 group by xchan_hash order by total desc limit %d offset %d ", intval($uid), intval($uid), intval($uid), - intval(XCHAN_FLAGS_HIDDEN), - intval(XCHAN_FLAGS_DELETED), intval($limit), intval($start) ); @@ -360,13 +358,11 @@ function suggestion_query($uid, $myxchan, $start = 0, $limit = 80) { where xlink_xchan = '' and not xlink_link in ( select abook_xchan from abook where abook_channel = %d ) and not xlink_link in ( select xchan from xign where uid = %d ) - and not ( xchan_flags & %d )>0 - and not ( xchan_flags & %d )>0 + and xchan_hidden = 0 + and xchan_deleted = 0 group by xchan_hash order by total desc limit %d offset %d ", intval($uid), intval($uid), - intval(XCHAN_FLAGS_HIDDEN), - intval(XCHAN_FLAGS_DELETED), intval($limit), intval($start) ); diff --git a/include/text.php b/include/text.php index fcd7b422c..720895810 100644 --- a/include/text.php +++ b/include/text.php @@ -728,20 +728,20 @@ function contact_block() { return; $is_owner = ((local_user() && local_user() == $a->profile['uid']) ? true : false); + $sql_extra = ''; $abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF; - $xchan_flags = XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED; + if(! $is_owner) { $abook_flags = $abook_flags | ABOOK_FLAG_HIDDEN; - $xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN; + $sql_extra = " and xchan_hidden = 0 "; } if((! is_array($a->profile)) || ($a->profile['hide_friends'])) return $o; - $r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and not ( abook_flags & %d )>0 and not (xchan_flags & %d)>0", + $r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and not ( abook_flags & %d )>0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra", intval($a->profile['uid']), - intval($abook_flags), - intval($xchan_flags) + intval($abook_flags) ); if(count($r)) { $total = intval($r[0]['total']); @@ -755,10 +755,9 @@ function contact_block() { } else { $randfunc = 'RAND()'; } - $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND not ( abook_flags & %d)>0 and not (xchan_flags & %d )>0 ORDER BY $randfunc LIMIT %d", + $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND not ( abook_flags & %d)>0 and xchan_orphan = 0 and xchan_deleted = 0 $sql_extra ORDER BY $randfunc LIMIT %d", intval($a->profile['uid']), intval($abook_flags|ABOOK_FLAG_ARCHIVED), - intval($xchan_flags), intval($shown) ); diff --git a/include/zot.php b/include/zot.php index debd2c8a8..9cb6c47d8 100644 --- a/include/zot.php +++ b/include/zot.php @@ -705,43 +705,36 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { $hidden = (1 - intval($arr['searchable'])); - // Be careful - XCHAN_FLAGS_HIDDEN should evaluate to 1 - if(($r[0]['xchan_flags'] & XCHAN_FLAGS_HIDDEN) != $hidden) - $new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_HIDDEN; - else - $new_flags = $r[0]['xchan_flags']; - - $adult = (($r[0]['xchan_flags'] & XCHAN_FLAGS_SELFCENSORED) ? true : false); - $adult_changed = ((intval($adult) != intval($arr['adult_content'])) ? true : false); - if($adult_changed) - $new_flags = $new_flags ^ XCHAN_FLAGS_SELFCENSORED; + $hidden_changed = $adult_changed = $deleted_changed = $pubforum_changed = 0; - $deleted = (($r[0]['xchan_flags'] & XCHAN_FLAGS_DELETED) ? true : false); - $deleted_changed = ((intval($deleted) != intval($arr['deleted'])) ? true : false); - if($deleted_changed) - $new_flags = $new_flags ^ XCHAN_FLAGS_DELETED; - - $public_forum = (($r[0]['xchan_flags'] & XCHAN_FLAGS_PUBFORUM) ? true : false); - $pubforum_changed = ((intval($public_forum) != intval($arr['public_forum'])) ? true : false); - if($pubforum_changed) - $new_flags = $r[0]['xchan_flags'] ^ XCHAN_FLAGS_PUBFORUM; + if(intval($r[0]['xchan_hidden']) != (1 - intval($arr['searchable']))) + $hidden_changed = 1; + if(intval($r[0]['xchan_selfcensored']) != intval($arr['adult_content'])) + $adult_changed = 1; + if(intval($r[0]['xchan_deleted']) != intval($arr['deleted'])) + $deleted_changed = 1; + if(intval($r[0]['xchan_pubforum']) != intval($arr['public_forum'])) + $pubforum_changed = 1; if(($r[0]['xchan_name_date'] != $arr['name_updated']) || ($r[0]['xchan_connurl'] != $arr['connections_url']) - || ($r[0]['xchan_flags'] != $new_flags) || ($r[0]['xchan_addr'] != $arr['address']) || ($r[0]['xchan_follow'] != $arr['follow_url']) || ($r[0]['xchan_connpage'] != $arr['connect_url']) - || ($r[0]['xchan_url'] != $arr['url'])) { + || ($r[0]['xchan_url'] != $arr['url']) + || $hidden_changed || adult_changed || deleted_changed || $pubforum_changed ) { $r = q("update xchan set xchan_name = '%s', xchan_name_date = '%s', xchan_connurl = '%s', xchan_follow = '%s', - xchan_connpage = '%s', xchan_flags = %d, + xchan_connpage = '%s', xchan_hidden = %d, xchan_selfcensored = %d, xchan_deleted = %d, xchan_pubforum = %d, xchan_addr = '%s', xchan_url = '%s' where xchan_hash = '%s'", dbesc(($arr['name']) ? $arr['name'] : '-'), dbesc($arr['name_updated']), dbesc($arr['connections_url']), dbesc($arr['follow_url']), dbesc($arr['connect_url']), - intval($new_flags), + intval(1 - intval($arr['searchable'])), + intval($arr['adult_content']), + intval($arr['deleted']), + intval($arr['public_forum']), dbesc($arr['address']), dbesc($arr['url']), dbesc($xchan_hash) @@ -761,20 +754,9 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { && ($arr['site']['url'] != z_root())) $arr['searchable'] = false; - $hidden = (1 - intval($arr['searchable'])); - - if($hidden) - $new_flags = XCHAN_FLAGS_HIDDEN; - else - $new_flags = 0; - if($arr['adult_content']) - $new_flags |= XCHAN_FLAGS_SELFCENSORED; - if(array_key_exists('deleted',$arr) && $arr['deleted']) - $new_flags |= XCHAN_FLAGS_DELETED; - $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype, - xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_flags) - values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d) ", + xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_selfcensored, xchan_deleted, xchan_pubforum, ) + values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d) ", dbesc($xchan_hash), dbesc($arr['guid']), dbesc($arr['guid_sig']), @@ -790,7 +772,10 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { dbesc('zot'), dbescdate($arr['photo_updated']), dbescdate($arr['name_updated']), - intval($new_flags) + intval(1 - intval($arr['searchable'])), + intval($arr['adult_content']), + intval($arr['deleted']), + intval($arr['public_forum']) ); $what .= 'new_xchan'; @@ -1433,11 +1418,11 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque if(($channel['channel_pageflags'] & PAGE_SYSTEM) && (! $arr['item_private'])) { $local_public = true; - $r = q("select xchan_flags from xchan where xchan_hash = '%s' limit 1", + $r = q("select xchan_selfcensored from xchan where xchan_hash = '%s' limit 1", dbesc($sender['hash']) ); // don't import sys channel posts from selfcensored authors - if($r && ($r[0]['xchan_flags'] & XCHAN_FLAGS_SELFCENSORED)) { + if($r && (intval($r[0]['xchan_selfcensored']))) { $local_public = false; continue; } @@ -1890,9 +1875,7 @@ function sync_locations($sender,$arr,$absolute = false) { intval($r[0]['hubloc_id']) ); } - q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'", - intval(XCHAN_FLAGS_ORPHAN), - intval(XCHAN_FLAGS_ORPHAN), + q("update xchan set xchan_orphan = 0 where xchan_orphan = 1 and xchan_hash = '%s'", dbesc($sender['hash']) ); } @@ -2078,8 +2061,7 @@ function import_directory_profile($hash,$profile,$addr,$ud_flags = UPDATE_FLAGS_ if(in_arrayi('nsfw',$clean) || in_arrayi('adult',$clean)) { - q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s'", - intval(XCHAN_FLAGS_SELFCENSORED), + q("update xchan set xchan_selfcensored = 1 where xchan_hash = '%s'", dbesc($hash) ); } -- cgit v1.2.3 From 29436081a86650e7905a79eba4fdf7dc12f1c7c9 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 Jan 2015 16:06:25 -0800 Subject: slow progress removing bitfields on item table --- include/Import/refimport.php | 8 +++-- include/activities.php | 5 ++- include/attach.php | 9 ++++-- include/bb2diaspora.php | 16 ---------- include/diaspora.php | 15 +++------ include/event.php | 54 ++++++++++++++++--------------- include/externals.php | 20 ------------ include/items.php | 27 ++++++++-------- include/notifier.php | 3 +- include/photos.php | 76 +++++++++++++++++++++++--------------------- include/zot.php | 2 +- 11 files changed, 103 insertions(+), 132 deletions(-) (limited to 'include') diff --git a/include/Import/refimport.php b/include/Import/refimport.php index 181b2b398..a7c0ef4c8 100644 --- a/include/Import/refimport.php +++ b/include/Import/refimport.php @@ -88,7 +88,10 @@ function refimport_content(&$a) { $arr['author_xchan'] = $channel['channel_hash']; $arr['owner_xchan'] = $channel['channel_hash']; $arr['app'] = REFLECT_BLOGNAME; - $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL|ITEM_THREAD_TOP; + $arr['item_origin'] = 1; + $arr['item_wall'] = 1; + $arr['item_thread_top'] = 1; + $arr['verb'] = ACTIVITY_POST; // this is an assumption @@ -256,7 +259,8 @@ function reflect_comment_store($channel,$post,$comment,$user) { $arr['edited'] = $comment['created']; $arr['author_xchan'] = $hash; $arr['owner_xchan'] = $channel['channel_hash']; - $arr['item_flags'] = ITEM_ORIGIN|ITEM_WALL; + $arr['item_origin'] = 1; + $arr['item_wall'] = 1; $arr['verb'] = ACTIVITY_POST; $arr['comment_policy'] = 'contacts'; diff --git a/include/activities.php b/include/activities.php index d770ccb23..ba12bc5d1 100644 --- a/include/activities.php +++ b/include/activities.php @@ -21,7 +21,10 @@ function profile_activity($changed, $value) { $arr['uid'] = local_user(); $arr['aid'] = $self['channel_account_id']; $arr['owner_xchan'] = $arr['author_xchan'] = $self['xchan_hash']; - $arr['item_flags'] = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_thread_top'] = 1; + $arr['verb'] = ACTIVITY_UPDATE; $arr['obj_type'] = ACTIVITY_OBJ_PROFILE; diff --git a/include/attach.php b/include/attach.php index 5ef3bea24..5a945dd66 100644 --- a/include/attach.php +++ b/include/attach.php @@ -954,7 +954,9 @@ function file_activity($channel_id, $hash, $allow_cid, $allow_gid, $deny_cid, $d $mid = item_message_id(); - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_unseen'] = 1; if($action == 'post') { //check if activity item exists @@ -975,7 +977,6 @@ function file_activity($channel_id, $hash, $allow_cid, $allow_gid, $deny_cid, $d $arr['uid'] = $channel_id; $arr['mid'] = $dmid; $arr['parent_mid'] = $dmid; - $arr['item_flags'] = $item_flags; $arr['author_xchan'] = $poster['xchan_hash']; $arr['owner_xchan'] = $poster['xchan_hash']; $arr['title'] = ''; @@ -1016,7 +1017,9 @@ function file_activity($channel_id, $hash, $allow_cid, $allow_gid, $deny_cid, $d $arr['uid'] = $channel_id; $arr['mid'] = $mid; $arr['parent_mid'] = $mid; - $arr['item_flags'] = $item_flags; + $arr['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_unseen'] = 1; $arr['author_xchan'] = $poster['xchan_hash']; $arr['owner_xchan'] = $poster['xchan_hash']; $arr['title'] = ''; diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php index 5c93ac3aa..e8f81aec4 100644 --- a/include/bb2diaspora.php +++ b/include/bb2diaspora.php @@ -271,22 +271,6 @@ function bb2diaspora_itemwallwall(&$item) { . $item['body']; } - // We have to do something similar for wall-to-wall comments. ITEM_WALL|ITEM_ORIGIN indicates that it was posted on this site. - // Regular matrix comments may have one of these bits set, but not both. - - // Update: this is getting triggered way too often and unnecessarily. Commenting out until we find a better solution. - // It's not an easy problem. For now we'll live with the mis-attributions, as wall to wall comments are much less frequent - // than wall-to-wall posts. - -// if(($item['mid'] != $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && (($item['item_flags'] & (ITEM_WALL|ITEM_ORIGIN)) == (ITEM_WALL|ITEM_ORIGIN)) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) { -// logger('bb2diaspora_itemwallwall: wall to wall comment',LOGGER_DEBUG); - // post will come across with the owner's identity. Throw a preamble onto the post to indicate the true author. -// $item['body'] = "\n\n" -// . '[img]' . $item['author']['xchan_photo_m'] . '[/img]' -// . '[url=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/url]' . "\n\n" -// . $item['body']; -// } - // $item['author'] might cause a surprise further down the line if it wasn't expected to be here. if(! $author_exists) diff --git a/include/diaspora.php b/include/diaspora.php index e494aac0f..ae405f663 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -1414,7 +1414,7 @@ function diaspora_comment($importer,$xml,$msg) { if($result && $result['success']) $message_id = $result['item_id']; - if(($parent_item['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) { + if(intval($parent_item['item_origin']) && (! $parent_author_signature)) { // if the message isn't already being relayed, notify others // the existence of parent_author_signature means the parent_author or owner // is already relaying. @@ -1996,7 +1996,7 @@ function diaspora_like($importer,$xml,$msg) { // the existence of parent_author_signature means the parent_author or owner // is already relaying. The parent_item['origin'] indicates the message was created on our system - if(($parent_item['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) + if(intval($parent_item['item_origin']) && (! $parent_author_signature)) proc_run('php','include/notifier.php','comment-import',$message_id); return; @@ -2105,19 +2105,12 @@ function diaspora_signed_retraction($importer,$xml,$msg) { $r[0]['parent'] ); if($p) { - if(($p[0]['item_flags'] & ITEM_ORIGIN) && (! $parent_author_signature)) { -// FIXME so we can relay this -// q("insert into sign (`retract_iid`,`signed_text`,`signature`,`signer`) values (%d,'%s','%s','%s') ", -// $r[0]['id'], -// dbesc($signed_data), -// dbesc($sig), -// dbesc($diaspora_handle) -// ); + if(intval($p[0]['item_origin']) && (! $parent_author_signature)) { // the existence of parent_author_signature would have meant the parent_author or owner // is already relaying. - logger('diaspora_signed_retraction: relaying relayable_retraction'); + logger('diaspora_signed_retraction: relaying relayable_retraction'); proc_run('php','include/notifier.php','drop',$r[0]['id']); } } diff --git a/include/event.php b/include/event.php index 1ed541d99..9da7a42a9 100644 --- a/include/event.php +++ b/include/event.php @@ -456,53 +456,55 @@ function event_store_item($arr,$event) { $private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0); - + + $item_wall = 0; + $item_origin = 0; + $item_thread_top = 0; if($item) { $item_arr['id'] = $item['id']; } else { $wall = (($z[0]['channel_hash'] == $event['event_xchan']) ? true : false); - - $item_flags = ITEM_THREAD_TOP; + $item_thread_top = 1; if($wall) { - $item_flags |= ITEM_WALL; - $item_flags |= ITEM_ORIGIN; + $item_wall = 1; + $item_origin = 1; } - $item_arr['item_flags'] = $item_flags; } if(! $arr['mid']) $arr['mid'] = item_message_id(); - $item_arr['aid'] = $z[0]['channel_account_id']; - $item_arr['uid'] = $arr['uid']; - $item_arr['author_xchan'] = $arr['event_xchan']; - $item_arr['mid'] = $arr['mid']; - $item_arr['parent_mid'] = $arr['mid']; + $item_arr['aid'] = $z[0]['channel_account_id']; + $item_arr['uid'] = $arr['uid']; + $item_arr['author_xchan'] = $arr['event_xchan']; + $item_arr['mid'] = $arr['mid']; + $item_arr['parent_mid'] = $arr['mid']; - $item_arr['owner_xchan'] = (($wall) ? $z[0]['channel_hash'] : $arr['event_xchan']); - $item_arr['author_xchan'] = $arr['event_xchan']; - $item_arr['title'] = $arr['summary']; - $item_arr['allow_cid'] = $arr['allow_cid']; - $item_arr['allow_gid'] = $arr['allow_gid']; - $item_arr['deny_cid'] = $arr['deny_cid']; - $item_arr['deny_gid'] = $arr['deny_gid']; - $item_arr['item_private'] = $private; - $item_arr['verb'] = ACTIVITY_POST; + $item_arr['owner_xchan'] = (($wall) ? $z[0]['channel_hash'] : $arr['event_xchan']); + $item_arr['author_xchan'] = $arr['event_xchan']; + $item_arr['title'] = $arr['summary']; + $item_arr['allow_cid'] = $arr['allow_cid']; + $item_arr['allow_gid'] = $arr['allow_gid']; + $item_arr['deny_cid'] = $arr['deny_cid']; + $item_arr['deny_gid'] = $arr['deny_gid']; + $item_arr['item_private'] = $private; + $item_arr['verb'] = ACTIVITY_POST; + $item_arr['item_wall'] = $item_wall; + $item_arr['item_origin'] = $item_origin; + $item_arr['item_thread_top'] = $item_thread_top;; if(array_key_exists('term',$arr)) $item_arr['term'] = $arr['term']; - $item_arr['resource_type'] = 'event'; - $item_arr['resource_id'] = $event['event_hash']; - - $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT; - - $item_arr['body'] = $prefix . format_event_bbcode($arr); + $item_arr['resource_type'] = 'event'; + $item_arr['resource_id'] = $event['event_hash']; + $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT; + $item_arr['body'] = $prefix . format_event_bbcode($arr); // if it's local send the permalink to the channel page. // otherwise we'll fallback to /display/$message_id diff --git a/include/externals.php b/include/externals.php index b0f853dc6..3b6d170d5 100644 --- a/include/externals.php +++ b/include/externals.php @@ -93,26 +93,6 @@ function externals_run($argv, $argc){ $results = process_delivery(array('hash' => 'undefined'), get_item_elements($message), array(array('hash' => $sys['xchan_hash'])), false, true); $total ++; -// $z = q("select id from item where mid = '%s' and uid = %d limit 1", -// dbesc($message['message_id']), -// intval($sys['channel_id']) -// ); -$z = null; - if($z) { - $flag_bits = ITEM_WALL|ITEM_ORIGIN|ITEM_UPLINK; - // preserve the source - - $r = q("update item set source_xchan = owner_xchan where id = %d", - intval($z[0]['id']) - ); - - $r = q("update item set item_flags = ( item_flags | %d ), owner_xchan = '%s' - where id = %d", - intval($flag_bits), - dbesc($sys['xchan_hash']), - intval($z[0]['id']) - ); - } } logger('externals: import_public_posts: ' . $total . ' messages imported', LOGGER_DEBUG); } diff --git a/include/items.php b/include/items.php index fb2f2586a..b2fc05f09 100755 --- a/include/items.php +++ b/include/items.php @@ -364,13 +364,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(); @@ -2917,10 +2916,7 @@ 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; } @@ -3039,7 +3035,10 @@ function start_delivery_chain($channel,$item,$item_id,$parent) { if((! $private) && $new_public_policy) $private = 1; - $flag_bits = $item['item_flags'] | ITEM_WALL|ITEM_ORIGIN; + $item_wall = 1; + $item_origin = 1; + + $flag_bits = $item['item_flags']; // unset the nocomment bit if it's there. @@ -3087,7 +3086,7 @@ function start_delivery_chain($channel,$item,$item_id,$parent) { } $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", + 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($flag_bits), dbesc($channel['channel_hash']), dbesc($channel['channel_allow_cid']), @@ -3099,6 +3098,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) ); diff --git a/include/notifier.php b/include/notifier.php index 29646fb38..241dffbd1 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -362,7 +362,7 @@ function notifier_run($argv, $argc){ $encoded_item = encode_item($target_item); - $relay_to_owner = (((! $top_level_post) && ($target_item['item_flags'] & ITEM_ORIGIN)) ? true : false); + $relay_to_owner = (((! $top_level_post) && (intval($target_item['item_origin']))) ? true : false); $uplink = false; @@ -371,7 +371,6 @@ function notifier_run($argv, $argc){ logger('notifier: relay_to_owner: ' . (($relay_to_owner) ? 'true' : 'false'), LOGGER_DATA); logger('notifier: top_level_post: ' . (($top_level_post) ? 'true' : 'false'), LOGGER_DATA); - logger('notifier: target_item_flags: ' . $target_item['item_flags'] . ' ' . (($target_item['item_flags'] & ITEM_ORIGIN ) ? 'true' : 'false'), LOGGER_DATA); // tag_deliver'd post which needs to be sent back to the original author diff --git a/include/photos.php b/include/photos.php index 2393153c6..0ac47f7ba 100644 --- a/include/photos.php +++ b/include/photos.php @@ -225,30 +225,31 @@ function photo_upload($channel, $observer, $args) { // Create item container - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_THREAD_TOP; $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); $title = ''; $mid = item_message_id(); $arr = array(); - $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_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['item_wall'] = 1; + $arr['item_origin'] = 1; + $arr['item_thread_top'] = 1; $arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid']; if ($width_x_height) @@ -431,7 +432,6 @@ 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); $title = ''; @@ -439,25 +439,27 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { $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['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_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['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]' . '[/zrl]'; diff --git a/include/zot.php b/include/zot.php index 9cb6c47d8..435592b6a 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1549,7 +1549,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque $result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); // We need this line to ensure wall-to-wall comments are relayed (by falling through to the relay bit), // and at the same time not relay any other relayable posts more than once, because to do so is very wasteful. - if(! ($r[0]['item_flags'] & ITEM_ORIGIN)) + if(! intval($r[0]['item_origin'])) continue; } } -- cgit v1.2.3 From e46eba125888704b4381aa8418495e91eeb565c8 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 Jan 2015 17:41:16 -0800 Subject: heavy lifting converting item flag bits --- include/ConversationObject.php | 2 +- include/ItemObject.php | 14 +++--- include/api.php | 17 +++---- include/conversation.php | 2 +- include/diaspora.php | 4 +- include/enotify.php | 2 +- include/identity.php | 3 +- include/items.php | 104 +++++++++++++++++------------------------ include/notifier.php | 9 ++-- include/notify.php | 7 +-- include/statistics_fns.php | 9 ++-- include/taxonomy.php | 6 ++- include/widgets.php | 4 +- include/zot.php | 7 +-- 14 files changed, 79 insertions(+), 111 deletions(-) (limited to 'include') diff --git a/include/ConversationObject.php b/include/ConversationObject.php index 7dc4c8c19..ada642482 100644 --- a/include/ConversationObject.php +++ b/include/ConversationObject.php @@ -166,7 +166,7 @@ class Conversation extends BaseObject { if(($item->get_data_value('author_xchan') === $ob_hash) || ($item->get_data_value('owner_xchan') === $ob_hash)) $item->set_commentable(true); - if($item->get_data_value('item_flags') & ITEM_NOCOMMENT) { + if(intval($item->get_data_value('item_nocomment'))) { $item->set_commentable(false); } elseif(($this->observer) && (! $item->is_commentable())) { diff --git a/include/ItemObject.php b/include/ItemObject.php index 82a321732..0bb125312 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -179,9 +179,9 @@ class Item extends BaseObject { 'do' => t("Add Star"), 'undo' => t("Remove Star"), 'toggle' => t("Toggle Star Status"), - 'classdo' => (($item['item_flags'] & ITEM_STARRED) ? "hidden" : ""), - 'classundo' => (($item['item_flags'] & ITEM_STARRED) ? "" : "hidden"), - 'isstarred' => (($item['item_flags'] & ITEM_STARRED) ? "starred icon-star" : "unstarred icon-star-empty"), + 'classdo' => (intval($item['item_starred']) ? "hidden" : ""), + 'classundo' => (intval($item['item_starred']) ? "" : "hidden"), + 'isstarred' => (intval($item['item_starred']) ? "starred icon-star" : "unstarred icon-star-empty"), 'starred' => t('starred'), ); @@ -191,9 +191,9 @@ class Item extends BaseObject { } - $verified = (($item['item_flags'] & ITEM_VERIFIED) ? t('Message signature validated') : ''); - $forged = ((($item['sig']) && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message signature incorrect') : ''); - $unverified = '' ; // (($this->is_wall_to_wall() && (! ($item['item_flags'] & ITEM_VERIFIED))) ? t('Message cannot be verified') : ''); + $verified = (intval($item['item_verified']) ? t('Message signature validated') : ''); + $forged = ((($item['sig']) && (! intval($item['item_verified']))) ? t('Message signature incorrect') : ''); + $unverified = '' ; // (($this->is_wall_to_wall() && (! intval($item['item_verified']))) ? t('Message cannot be verified') : ''); @@ -569,7 +569,7 @@ class Item extends BaseObject { if((! visible_activity($child->data)) || array_key_exists('author_blocked',$child->data)) { continue; } - if($child->data['item_flags'] & ITEM_UNSEEN) + if($child->data['item_unseen']) $total ++; } } diff --git a/include/api.php b/include/api.php index 51de412cf..579ae626f 100644 --- a/include/api.php +++ b/include/api.php @@ -336,10 +336,9 @@ require_once('include/items.php'); // count public wall messages $r = q("SELECT COUNT(`id`) as `count` FROM `item` WHERE `uid` = %d - AND ( item_flags & %d )>0 and item_restrict = 0 + AND item_wall = 1 and item_restrict = 0 AND `allow_cid`='' AND `allow_gid`='' AND `deny_cid`='' AND `deny_gid`=''", - intval($usr[0]['channel_id']), - intval(ITEM_WALL) + intval($usr[0]['channel_id']) ); $countitms = $r[0]['count']; } @@ -363,9 +362,8 @@ require_once('include/items.php'); $countfollowers = $r[0]['count']; } - $r = q("SELECT count(`id`) as `count` FROM item where ( item_flags & %d )>0 and uid = %d and item_restrict = 0", - intval($uinfo[0]['channel_id']), - intval(ITEM_STARRED) + $r = q("SELECT count(`id`) as `count` FROM item where item_starred = 1 and uid = %d and item_restrict = 0", + intval($uinfo[0]['channel_id']) ); $starred = $r[0]['count']; @@ -1004,10 +1002,7 @@ require_once('include/items.php'); // at the network timeline just mark everything seen. if (api_user() == $user_info['uid']) { - $r = q("UPDATE `item` SET item_flags = ( item_flags & ~%d ) - WHERE (item_flags & %d)>0 and uid = %d", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 and uid = %d", intval($user_info['uid']) ); } @@ -1615,7 +1610,7 @@ require_once('include/items.php'); 'in_reply_to_user_id' => $in_reply_to_user_id, 'in_reply_to_screen_name' => $in_reply_to_screen_name, 'geo' => '', - 'favorited' => (($item['item_flags'] & ITEM_STARRED) ? true : false), + 'favorited' => (intval($item['item_starred']) ? true : false), 'user' => $status_user , 'statusnet_html' => trim(prepare_text($item['body'],$item['mimetype'])), diff --git a/include/conversation.php b/include/conversation.php index 25c844fef..e81bb49e0 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -96,7 +96,7 @@ function localize_item(&$item){ if(! $item['object']) return; - if($item['item_flags'] & ITEM_THREAD_TOP) + if(intval($item['item_thread_top'])) return; $obj = json_decode_plus($item['object']); diff --git a/include/diaspora.php b/include/diaspora.php index ae405f663..4e7b968e7 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -893,8 +893,8 @@ function diaspora_post($importer,$xml,$msg) { $datarray['app'] = $app; - $datarray['item_flags'] = ITEM_UNSEEN|ITEM_THREAD_TOP; - + $datarray['item_unseen'] = 1; + $datarray['item_thread_top'] = 1; $result = item_store($datarray); return; diff --git a/include/enotify.php b/include/enotify.php index 6fc771c58..53f1ae5ef 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -157,7 +157,7 @@ function notification($params) { $item_post_type); // "your post" - if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && ($p[0]['item_flags'] & ITEM_WALL)) + if($p[0]['owner']['xchan_name'] == $p[0]['author']['xchan_name'] && intval($p[0]['item_wall'])) $dest_str = sprintf(t('%1$s, %2$s commented on [zrl=%3$s]your %4$s[/zrl]'), $recip['channel_name'], '[zrl=' . $sender['xchan_url'] . ']' . $sender['xchan_name'] . '[/zrl]', diff --git a/include/identity.php b/include/identity.php index e196cb247..ce29e71f0 100644 --- a/include/identity.php +++ b/include/identity.php @@ -589,8 +589,7 @@ function identity_basic_export($channel_id, $items = false) { // warning: this may run into memory limits on smaller systems - $r = q("select * from item where (item_flags & %d)>0 and not (item_restrict & %d)>0 and uid = %d", - intval(ITEM_WALL), + $r = q("select * from item where item_wall = 1 and not (item_restrict & %d)>0 and uid = %d", intval(ITEM_DELETED), intval($channel_id) ); diff --git a/include/items.php b/include/items.php index b2fc05f09..2478d773c 100755 --- a/include/items.php +++ b/include/items.php @@ -430,7 +430,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']; } @@ -835,11 +835,8 @@ 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; @@ -1135,7 +1132,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; @@ -1317,11 +1314,11 @@ function encode_item_flags($item) { $ret[] = 'deleted'; if($item['item_restrict'] & 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']) $ret[] = 'private'; @@ -2042,12 +2039,11 @@ function item_store($arr,$allow_exec = false) { $arr['comment_policy'] = ((x($arr,'comment_policy')) ? notags(trim($arr['comment_policy'])) : 'contacts' ); - $arr['item_flags'] = $arr['item_flags'] | ITEM_UNSEEN; - - if($arr['comment_policy'] == 'none') - $arr['item_flags'] = $arr['item_flags'] | ITEM_NOCOMMENT; - + if(! array_key_exists('item_unseen',$arr)) + $arr['item_unseen'] = 1; + 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 @@ -2073,7 +2069,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 { @@ -2121,8 +2117,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. @@ -2142,7 +2138,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 { @@ -2337,15 +2333,7 @@ function item_store_update($arr,$allow_exec = false) { // override the unseen flag with the original - if($arr['item_flags'] & ITEM_UNSEEN) - $arr['item_flags'] = $arr['item_flags'] ^ ITEM_UNSEEN; - - if($orig[0]['item_flags'] & ITEM_VERIFIED) - $orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_VERIFIED; - - if($orig[0]['item_flags'] & ITEM_OBSCURED) - $orig[0]['item_flags'] = $orig[0]['item_flags'] ^ ITEM_OBSCURED; - + $arr['item_unseen'] = $orig[0]['item_unseen']; $arr['item_flags'] = intval($arr['item_flags']) | $orig[0]['item_flags']; $arr['item_restrict'] = intval($arr['item_restrict']) | $orig[0]['item_restrict']; @@ -2371,7 +2359,7 @@ function item_store_update($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; } } @@ -2701,8 +2689,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']); @@ -2800,13 +2788,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]); } } @@ -2836,8 +2824,7 @@ 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) ); @@ -2948,10 +2935,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; @@ -3037,14 +3023,11 @@ function start_delivery_chain($channel,$item,$item_id,$parent) { $item_wall = 1; $item_origin = 1; + $item_uplink = 0; + $item_nocomment = 0; $flag_bits = $item['item_flags']; - // unset the nocomment bit if it's there. - - if($flag_bits & ITEM_NOCOMMENT) - $flag_bits = $flag_bits ^ ITEM_NOCOMMENT; - // maintain the original source, which will be the original item owner and was stored in source_xchan // when we created the delivery fork @@ -3055,7 +3038,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) ); @@ -3085,8 +3068,10 @@ function start_delivery_chain($channel,$item,$item_id,$parent) { } } - $r = q("update item set item_flags = %d, owner_xchan = '%s', allow_cid = '%s', allow_gid = '%s', + $r = q("update item set item_uplink = %d, item_nocomment = %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($flag_bits), dbesc($channel['channel_hash']), dbesc($channel['channel_allow_cid']), @@ -3868,7 +3853,7 @@ function item_expire($uid,$days) { $expire_network_only = 1; - $sql_extra = ((intval($expire_network_only)) ? " AND not (item_flags & " . intval(ITEM_WALL) . ")>0 " : ""); + $sql_extra = ((intval($expire_network_only)) ? " AND item_wall = 0 " : ""); $r = q("SELECT * FROM `item` WHERE `uid` = %d @@ -3903,7 +3888,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; } @@ -4027,7 +4012,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']); @@ -4132,7 +4117,7 @@ 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 " : "" ); $r = q("select id, created from item where item_restrict = %d and uid = %d and id = parent $wall_sql @@ -4331,19 +4316,17 @@ function zot_feed($uid,$observer_xchan,$arr) { $r = q("SELECT distinct parent, created from item WHERE uid != %d and uid in (" . stream_perms_api_uids(PERMS_PUBLIC) . ") AND item_restrict = 0 - AND (item_flags & %d)>0 + AND item_wall = 1 and item_private = 0 $sql_extra ORDER BY created ASC $limit", - intval($uid), - intval(ITEM_WALL) + intval($uid) ); } else { $r = q("SELECT distinct parent, created from item WHERE uid = %d AND item_restrict = 0 - AND (item_flags & %d)>0 + AND item_wall = 1 $sql_extra ORDER BY created ASC $limit", - intval($uid), - intval(ITEM_WALL) + intval($uid) ); } @@ -4403,12 +4386,12 @@ 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_options .= " and item_wall = 1 "; - $sql_extra = " AND item.parent IN ( SELECT parent FROM item WHERE (item_flags & " . intval(ITEM_THREAD_TOP) . ")>0 $sql_options ) "; + $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 . " "; @@ -4486,9 +4469,8 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C } 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) + $sql_extra .= sprintf(" AND parent IN (SELECT distinct parent from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ", + dbesc(protect_sprintf($uidhash)) ); } @@ -4528,7 +4510,7 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C } } - $simple_update = (($client_mode & CLIENT_MODE_UPDATE) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " )>0 " : ''); + $simple_update = (($client_mode & CLIENT_MODE_UPDATE) ? " and item.item_unseen = 1 " : ''); if($client_mode & CLIENT_MODE_LOAD) $simple_update = ''; diff --git a/include/notifier.php b/include/notifier.php index 241dffbd1..092b27498 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -206,10 +206,9 @@ function notifier_run($argv, $argc){ $normal_mode = false; $expire = true; - $items = q("SELECT * FROM item WHERE uid = %d AND ( item_flags & %d )>0 + $items = q("SELECT * FROM item WHERE uid = %d AND item_wall = 1 AND ( item_restrict & %d )>0 AND `changed` > %s - INTERVAL %s", intval($item_id), - intval(ITEM_WALL), intval(ITEM_DELETED), db_utcnow(), db_quoteinterval('10 MINUTE') ); @@ -374,7 +373,7 @@ function notifier_run($argv, $argc){ // tag_deliver'd post which needs to be sent back to the original author - if(($cmd === 'uplink') && ($parent_item['item_flags'] & ITEM_UPLINK) && (! $top_level_post)) { + if(($cmd === 'uplink') && intval($parent_item['item_uplink']) && (! $top_level_post)) { logger('notifier: uplink'); $uplink = true; } @@ -395,7 +394,7 @@ function notifier_run($argv, $argc){ // if our parent is a tag_delivery recipient, uplink to the original author causing // a delivery fork. - if(($parent_item['item_flags'] & ITEM_UPLINK) && (! $top_level_post) && ($cmd !== 'uplink')) { + if(intval($parent_item['item_uplink']) && (! $top_level_post) && ($cmd !== 'uplink')) { logger('notifier: uplinking this item'); proc_run('php','include/notifier.php','uplink',$item_id); } @@ -408,7 +407,7 @@ function notifier_run($argv, $argc){ // don't send deletions onward for other people's stuff // TODO verify this is needed - copied logic from same place in old code - if(($target_item['item_restrict'] & ITEM_DELETED) && (!($target_item['item_flags'] & ITEM_WALL))) { + if(($target_item['item_restrict'] & ITEM_DELETED) && (! intval($target_item['item_wall']))) { logger('notifier: ignoring delete notification for non-wall item'); return; } diff --git a/include/notify.php b/include/notify.php index aa96fa279..987ca8c0f 100644 --- a/include/notify.php +++ b/include/notify.php @@ -5,9 +5,6 @@ function format_notification($item) { $ret = ''; -// return array(); - - require_once('include/conversation.php'); // Call localize_item with the "brief" flag to get a one line status for activities. @@ -19,7 +16,7 @@ function format_notification($item) { $itemem_text = $item['localize']; } else { - $itemem_text = (($item['item_flags'] & ITEM_THREAD_TOP) + $itemem_text = (($item['item_thread_top']) ? t('created a new post') : sprintf( t('commented on %s\'s post'), $item['owner']['xchan_name'])); } @@ -32,7 +29,7 @@ function format_notification($item) { 'url' => $item['author']['xchan_url'], 'photo' => $item['author']['xchan_photo_s'], 'when' => relative_date($item['created']), - 'class' => (($item['item_flags'] & ITEM_UNSEEN) ? 'notify-unseen' : 'notify-seen'), + 'class' => (($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), 'message' => strip_tags(bbcode($itemem_text)) ); diff --git a/include/statistics_fns.php b/include/statistics_fns.php index 288925a2c..ce2eee5e7 100644 --- a/include/statistics_fns.php +++ b/include/statistics_fns.php @@ -23,8 +23,7 @@ function update_channels_active_halfyear_stat() { $s .= ','; $s .= intval($rr['channel_id']); } - $x = q("select uid from item where uid in ( $s ) and (item_flags & %d)>0 and created > %s - INTERVAL %s group by uid", - intval(ITEM_WALL), + $x = q("select uid from item where uid in ( $s ) and item_wall = 1 and created > %s - INTERVAL %s group by uid", db_utcnow(), db_quoteinterval('6 MONTH') ); if($x) { @@ -50,8 +49,7 @@ function update_channels_active_monthly_stat() { $s .= ','; $s .= intval($rr['channel_id']); } - $x = q("select uid from item where uid in ( $s ) and ( item_flags & %d )>0 and created > %s - INTERVAL %s group by uid", - intval(ITEM_WALL), + $x = q("select uid from item where uid in ( $s ) and item_wall = 1 and created > %s - INTERVAL %s group by uid", db_utcnow(), db_quoteinterval('1 MONTH') ); if($x) { @@ -66,8 +64,7 @@ function update_channels_active_monthly_stat() { } function update_local_posts_stat() { - $posts = q("SELECT COUNT(*) AS local_posts FROM `item` WHERE (item_flags & %d)>0 ", - intval(ITEM_WALL) ); + $posts = q("SELECT COUNT(*) AS local_posts FROM `item` WHERE item_wall = 1 "); if (is_array($posts)) { $local_posts_stat = intval($posts[0]["local_posts"]); set_config('system','local_posts_stat',$local_posts_stat); diff --git a/include/taxonomy.php b/include/taxonomy.php index be80008df..a5ccada62 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -101,8 +101,10 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $ $sql_options = ''; $count = intval($count); - if($flags) - $sql_options .= " and ((item_flags & " . intval($flags) . ") = " . intval($flags) . ") "; + if($flags) { + if($flags === 'wall') + $sql_options .= " and item_wall = 1 "; + } if($authors) { if(! is_array($authors)) diff --git a/include/widgets.php b/include/widgets.php index 9f9268055..d4888789f 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -391,7 +391,7 @@ function widget_tagcloud_wall($arr) { $limit = ((array_key_exists('limit', $arr)) ? intval($arr['limit']) : 50); if(feature_enabled($a->profile['profile_uid'], 'tagadelic')) - return wtagblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], ITEM_WALL); + return wtagblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], 'wall'); return ''; } @@ -406,7 +406,7 @@ function widget_catcloud_wall($arr) { $limit = ((array_key_exists('limit',$arr)) ? intval($arr['limit']) : 50); - return catblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], ITEM_WALL); + return catblock($a->profile['profile_uid'], $limit, $a->profile['channel_hash'], 'wall'); } diff --git a/include/zot.php b/include/zot.php index 435592b6a..07d228ea5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1436,13 +1436,10 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque // This is our own post, possibly coming from a channel clone if($arr['owner_xchan'] == $d['hash']) { - $arr['item_flags'] = $arr['item_flags'] | ITEM_WALL; + $arr['item_wall'] = 1; } else { - // clear the wall flag if it is set - if($arr['item_flags'] & ITEM_WALL) { - $arr['item_flags'] = ($arr['item_flags'] ^ ITEM_WALL); - } + $arr['item_wall'] = 0; } if((! perm_is_allowed($channel['channel_id'],$sender['hash'],$perm)) && (! $tag_delivery) && (! $local_public)) { -- cgit v1.2.3 From 6e0e3b2433fc426b758a55811f56536d58705813 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 Jan 2015 18:41:10 -0800 Subject: more expanding item flags --- include/bb2diaspora.php | 2 +- include/conversation.php | 15 +++------------ include/diaspora.php | 2 +- include/enotify.php | 2 +- include/items.php | 46 +++++++++++++++++++++++----------------------- include/text.php | 2 +- 6 files changed, 30 insertions(+), 39 deletions(-) (limited to 'include') 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); -- cgit v1.2.3 From 4c2a1e572a03e253f05f03e400af26d403cbda32 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 22 Jan 2015 21:04:54 -0800 Subject: start on item_restrict conversion --- include/diaspora.php | 12 ++++++------ include/expire.php | 3 +-- include/identity.php | 3 +-- include/items.php | 55 +++++++++++++++++++++++++++++++++------------------- include/notifier.php | 7 +++---- include/poller.php | 5 ++--- 6 files changed, 48 insertions(+), 37 deletions(-) (limited to 'include') diff --git a/include/diaspora.php b/include/diaspora.php index b9c6e5c92..317a4cbf9 100755 --- a/include/diaspora.php +++ b/include/diaspora.php @@ -206,7 +206,7 @@ function diaspora_process_outbound($arr) { if(! $contact['xchan_pubkey']) continue; - if(($target_item['item_restrict'] & ITEM_DELETED) + if(intval($target_item['item_deleted']) && (($target_item['mid'] === $target_item['parent_mid']) || $arr['followup'])) { // send both top-level retractions and relayable retractions for owner to relay diaspora_send_retraction($target_item,$arr['channel'],$contact); @@ -235,8 +235,8 @@ function diaspora_process_outbound($arr) { $contact = $arr['hub']; - if(($target_item['deleted']) - && ($target_item['mid'] === $target_item['parent_mod'])) { + if(intval($target_item['item_deleted']) + && ($target_item['mid'] === $target_item['parent_mid'])) { // top-level retraction logger('delivery: diaspora retract: ' . $loc); diaspora_send_retraction($target_item,$arr['channel'],$contact,true); @@ -2453,7 +2453,7 @@ function diaspora_send_followup($item,$owner,$contact,$public_batch = false) { $target_type = 'Post'; $positive = 'true'; - if(($item_['item_restrict'] & ITEM_DELETED)) + if(intval($item['item_deleted'])) logger('diaspora_send_followup: received deleted "like". Those should go to diaspora_send_retraction'); } else { @@ -2549,7 +2549,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { $relay_retract = false; $sql_sign_id = 'iid'; - if( $item['item_restrict'] & ITEM_DELETED) { + if( intval($item['item_deleted']) { $relay_retract = true; $target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment'); @@ -2561,7 +2561,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) { $like = true; $target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment'); -// $positive = (($item['item_restrict'] & ITEM_DELETED) ? 'false' : 'true'); +// $positive = (intval($item['item_deleted']) ? 'false' : 'true'); $positive = 'true'; $tpl = get_markup_template('diaspora_like_relay.tpl'); diff --git a/include/expire.php b/include/expire.php index a229bd4ac..b0bf55e4f 100644 --- a/include/expire.php +++ b/include/expire.php @@ -7,8 +7,7 @@ function expire_run($argv, $argc){ cli_startup(); - $r = q("select id from item where (item_restrict & %d)>0 and not (item_restrict & %d)>0 and changed < %s - INTERVAL %s", - intval(ITEM_DELETED), + $r = q("select id from item where item_deleted = 1 and not (item_restrict & %d)>0 and changed < %s - INTERVAL %s", intval(ITEM_PENDING_REMOVE), db_utcnow(), db_quoteinterval('10 DAY') ); diff --git a/include/identity.php b/include/identity.php index ce29e71f0..028df681e 100644 --- a/include/identity.php +++ b/include/identity.php @@ -589,8 +589,7 @@ function identity_basic_export($channel_id, $items = false) { // warning: this may run into memory limits on smaller systems - $r = q("select * from item where item_wall = 1 and not (item_restrict & %d)>0 and uid = %d", - intval(ITEM_DELETED), + $r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d", intval($channel_id) ); if($r) { diff --git a/include/items.php b/include/items.php index 43739b605..180600495 100755 --- a/include/items.php +++ b/include/items.php @@ -839,7 +839,7 @@ function get_item_elements($x) { $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; @@ -1310,7 +1310,7 @@ 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) $ret[] = 'hidden'; @@ -2109,7 +2109,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']; @@ -2149,7 +2149,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", @@ -3347,7 +3347,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); } @@ -3948,7 +3948,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); @@ -3979,11 +3979,17 @@ 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_restrict = ( item_restrict | %d ) WHERE id = %d", + intval(ITEM_HIDDEN), + 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 ); @@ -4047,13 +4053,23 @@ 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_restrict = ( item_restrict | %d ), + 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_deleted = 1, changed = '%s', edited = '%s' where if = %d", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($item['id']) + ); + } + break; case DROPITEM_NORMAL: @@ -4068,9 +4084,8 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL,$force = false) { ); } 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']) diff --git a/include/notifier.php b/include/notifier.php index 092b27498..6a6879ebb 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -207,9 +207,8 @@ function notifier_run($argv, $argc){ $normal_mode = false; $expire = true; $items = q("SELECT * FROM item WHERE uid = %d AND item_wall = 1 - AND ( item_restrict & %d )>0 AND `changed` > %s - INTERVAL %s", + AND item_deleted = 1 AND `changed` > %s - INTERVAL %s", intval($item_id), - intval(ITEM_DELETED), db_utcnow(), db_quoteinterval('10 MINUTE') ); $uid = $item_id; @@ -314,7 +313,7 @@ function notifier_run($argv, $argc){ $target_item = $r[0]; - if($target_item['item_restrict'] & ITEM_DELETED) + if(intval($target_item['item_deleted'])) logger('notifier: target item ITEM_DELETED', LOGGER_DEBUG); $unforwardable = ITEM_UNPUBLISHED|ITEM_DELAYED_PUBLISH|ITEM_WEBPAGE|ITEM_BUILDBLOCK|ITEM_PDL; @@ -407,7 +406,7 @@ function notifier_run($argv, $argc){ // don't send deletions onward for other people's stuff // TODO verify this is needed - copied logic from same place in old code - if(($target_item['item_restrict'] & ITEM_DELETED) && (! intval($target_item['item_wall']))) { + if(intval($target_item['item_deleted']) && (! intval($target_item['item_wall']))) { logger('notifier: ignoring delete notification for non-wall item'); return; } diff --git a/include/poller.php b/include/poller.php index 896553a43..a9647c725 100644 --- a/include/poller.php +++ b/include/poller.php @@ -53,10 +53,9 @@ function poller_run($argv, $argc){ // expire any expired items $r = q("select id from item where expires != '%s' and expires < %s - and ( item_restrict & %d ) = 0 ", + and item_deleted = 0 ", dbesc(NULL_DATE), - db_utcnow(), - intval(ITEM_DELETED) + db_utcnow() ); if($r) { require_once('include/items.php'); -- cgit v1.2.3 From e6bfe3f2c10e851ed5ba49886ec8d0a9a9de2296 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 26 Jan 2015 18:09:09 -0800 Subject: onedirsync merge --- include/onedirsync.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/onedirsync.php b/include/onedirsync.php index e611492af..215c90008 100644 --- a/include/onedirsync.php +++ b/include/onedirsync.php @@ -41,11 +41,10 @@ function onedirsync_run($argv, $argc){ intval(UPDATE_FLAGS_UPDATED) ); if($x) { - $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 and ud_date < '%s' ", + $y = q("update updates set ud_flags = ( ud_flags | %d ) where ud_addr = '%s' and ( ud_flags & %d ) = 0 ", intval(UPDATE_FLAGS_UPDATED), dbesc($r[0]['ud_addr']), - intval(UPDATE_FLAGS_UPDATED), - dbesc($x[0]['ud_date']) + intval(UPDATE_FLAGS_UPDATED) ); return; } -- cgit v1.2.3 From 0bfbe6d61d3c6250a162a29d2cdb0ec78ad02f1d Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 27 Jan 2015 19:58:43 -0800 Subject: sql typo --- include/zot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/zot.php b/include/zot.php index 18565a214..d8b9a1485 100644 --- a/include/zot.php +++ b/include/zot.php @@ -755,7 +755,7 @@ function import_xchan($arr,$ud_flags = UPDATE_FLAGS_UPDATED, $ud_arr = null) { $arr['searchable'] = false; $x = q("insert into xchan ( xchan_hash, xchan_guid, xchan_guid_sig, xchan_pubkey, xchan_photo_mimetype, - xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_selfcensored, xchan_deleted, xchan_pubforum, ) + xchan_photo_l, xchan_addr, xchan_url, xchan_connurl, xchan_follow, xchan_connpage, xchan_name, xchan_network, xchan_photo_date, xchan_name_date, xchan_hidden, xchan_selfcensored, xchan_deleted, xchan_pubforum ) values ( '%s', '%s', '%s', '%s' , '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d) ", dbesc($xchan_hash), dbesc($arr['guid']), -- cgit v1.2.3 From ff68ea608786a698ad46637ef13854ac1b1e6beb Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 29 Jan 2015 14:51:41 -0800 Subject: more message restrict conversions --- include/items.php | 27 ++++++++++++--------------- include/notifier.php | 9 ++++++--- include/photos.php | 33 ++++++++++++++++----------------- include/taxonomy.php | 2 +- include/text.php | 4 ++-- include/widgets.php | 4 ++-- include/zot.php | 10 +++++----- 7 files changed, 44 insertions(+), 45 deletions(-) (limited to 'include') diff --git a/include/items.php b/include/items.php index 916838f3f..224ad72e4 100755 --- a/include/items.php +++ b/include/items.php @@ -841,7 +841,7 @@ function get_item_elements($x) { if(array_key_exists('flags',$x) && in_array('deleted',$x['flags'])) $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 @@ -1312,7 +1312,7 @@ function encode_item_flags($item) { if(intval($item['item_deleted'])) $ret[] = 'deleted'; - if($item['item_restrict'] & ITEM_HIDDEN) + if(intval($item['item_hidden'])) $ret[] = 'hidden'; if(intval($item['item_thread_top'])) $ret[] = 'thread_parent'; @@ -1916,11 +1916,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']); } @@ -3967,8 +3967,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal // 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_restrict = ( item_restrict | %d ) WHERE id = %d", - intval(ITEM_HIDDEN), + $r = q("UPDATE item SET item_hidden = 1 WHERE id = %d", intval($item['id']) ); } @@ -4041,9 +4040,8 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL,$force = false) { case DROPITEM_PHASE1: 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']) @@ -4062,9 +4060,8 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL,$force = false) { 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']) @@ -4522,9 +4519,9 @@ function items_fetch($arr,$channel = null,$observer_hash = null,$client_mode = C $sql_extra .= item_permissions_sql($channel['channel_id']); if($arr['pages']) - $item_restrict = " AND (item_restrict & " . ITEM_WEBPAGE . ") "; + $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) { @@ -4629,11 +4626,11 @@ function update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remo $page_type = ''; - 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; diff --git a/include/notifier.php b/include/notifier.php index 6a6879ebb..79be25621 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -316,9 +316,12 @@ function notifier_run($argv, $argc){ if(intval($target_item['item_deleted'])) logger('notifier: target item ITEM_DELETED', LOGGER_DEBUG); - $unforwardable = ITEM_UNPUBLISHED|ITEM_DELAYED_PUBLISH|ITEM_WEBPAGE|ITEM_BUILDBLOCK|ITEM_PDL; - if($target_item['item_restrict'] & $unforwardable) { - logger('notifier: target item not forwardable: flags ' . $target_item['item_restrict'], LOGGER_DEBUG); + if(intval($target_item['item_type']) != ITEM_TYPE_POST) { + logger('notifier: target item not forwardable: type ' . $target_item['item_type'], LOGGER_DEBUG); + return; + } + if(intval($target_item['item_unpublished']) || intval($target_item['item_delayed_publish'])) { + logger('notifier: target item not published, so not forwardable', LOGGER_DEBUG); return; } diff --git a/include/photos.php b/include/photos.php index f52b08473..43386d626 100644 --- a/include/photos.php +++ b/include/photos.php @@ -225,7 +225,7 @@ function photo_upload($channel, $observer, $args) { // Create item container - $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); + $item_hidden = (($visible) ? 0 : 1 ); $title = ''; $mid = item_message_id(); @@ -235,8 +235,7 @@ function photo_upload($channel, $observer, $args) { $arr['uid'] = $channel_id; $arr['mid'] = $mid; $arr['parent_mid'] = $mid; - $arr['item_flags'] = $item_flags; - $arr['item_restrict'] = $item_restrict; + $arr['item_hidden'] = $item_hidden; $arr['resource_type'] = 'photo'; $arr['resource_id'] = $photo_hash; $arr['owner_xchan'] = $channel['channel_hash']; @@ -446,7 +445,7 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { // Create item container - $item_restrict = (($visible) ? ITEM_VISIBLE : ITEM_HIDDEN); + $item_hidden = (($visible) ? 0 : 1 ); $title = ''; $mid = item_message_id(); @@ -460,20 +459,20 @@ function photos_create_item($channel, $creator_hash, $photo, $visible = false) { $arr['item_wall'] = 1; $arr['item_origin'] = 1; $arr['item_thread_top'] = 1; - $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['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'] . ']' + $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo['resource_id'] . ']' . '[zmg]' . z_root() . '/photo/' . $photo['resource_id'] . '-' . $photo['scale'] . '[/zmg]' . '[/zrl]'; diff --git a/include/taxonomy.php b/include/taxonomy.php index a5ccada62..9be04e16c 100644 --- a/include/taxonomy.php +++ b/include/taxonomy.php @@ -116,7 +116,7 @@ function tagadelic($uid, $count = 0, $authors = '', $flags = 0, $restrict = 0, $ // Fetch tags $r = q("select term, count(term) as total from term left join item on term.oid = item.id where term.uid = %d and term.type = %d - and otype = %d and item_restrict = %d and item_private = 0 + and otype = %d and item_type = %d and item_private = 0 $sql_options group by term order by total desc %s", intval($uid), diff --git a/include/text.php b/include/text.php index 9a13e5e72..3258faeec 100644 --- a/include/text.php +++ b/include/text.php @@ -1549,9 +1549,9 @@ function unamp($s) { } function layout_select($channel_id, $current = '') { - $r = q("select mid,sid from item left join item_id on iid = item.id where service = 'PDL' and item.uid = item_id.uid and item_id.uid = %d and (item_restrict & %d)>0", + $r = q("select mid,sid from item left join item_id on iid = item.id where service = 'PDL' and item.uid = item_id.uid and item_id.uid = %d and item_type = %d ", intval($channel_id), - intval(ITEM_PDL) + intval(ITEM_TYPE_PDL) ); if($r) { $o = t('Select a page layout: '); diff --git a/include/widgets.php b/include/widgets.php index d4888789f..c5ccb9216 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -29,7 +29,7 @@ function widget_tagcloud($args) { $type = TERM_CATEGORY; // FIXME there exists no $authors variable - $r = tagadelic($uid, $count, $authors, $flags, ITEM_WEBPAGE, $type); + $r = tagadelic($uid, $count, $authors, $flags, ITEM_TYPE_WEBPAGE, $type); if($r) { $o = '

' . t('Categories') . '

'; @@ -688,7 +688,7 @@ function widget_item($arr) { require_once('include/security.php'); $sql_extra = item_permissions_sql($uid); - $r = q("select * from item where mid = '%s' and uid = %d and item_restrict = " . intval(ITEM_WEBPAGE) . " $sql_extra limit 1", + $r = q("select * from item where mid = '%s' and uid = %d and item_type = " . intval(ITEM_TYPE_WEBPAGE) . " $sql_extra limit 1", dbesc($arr['mid']), intval($uid) ); diff --git a/include/zot.php b/include/zot.php index 7bdde836f..2bc54e6f3 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1532,7 +1532,7 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque } } - if($arr['item_restrict'] & ITEM_DELETED) { + if(intval($arr['item_deleted'])) { // remove_community_tag is a no-op if this isn't a community tag activity remove_community_tag($sender,$arr,$channel['channel_id']); @@ -1549,14 +1549,14 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false,$reque continue; } - $r = q("select id, edited, item_restrict, item_flags, mid, parent_mid from item where mid = '%s' and uid = %d limit 1", + $r = q("select * from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), intval($channel['channel_id']) ); if($r) { // We already have this post. $item_id = $r[0]['id']; - if($r[0]['item_restrict'] & ITEM_DELETED) { + if(intval($r[0]['item_deleted'])) { // It was deleted locally. $result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); continue; @@ -1686,7 +1686,7 @@ function delete_imported_item($sender,$item,$uid) { logger('delete_imported_item invoked',LOGGER_DEBUG); - $r = q("select id, item_restrict from item where ( author_xchan = '%s' or owner_xchan = '%s' or source_xchan = '%s' ) + $r = q("select id, item_deleted 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']), @@ -1700,7 +1700,7 @@ function delete_imported_item($sender,$item,$uid) { return false; } - if($r[0]['item_restrict'] & ITEM_DELETED) { + if(intval($r[0]['item_deleted'])) { logger('delete_imported_item: item was already deleted'); return false; } -- cgit v1.2.3 From 4a243b63f7019a1e56ecf03b138cd7fc396236c2 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 29 Jan 2015 20:09:48 -0800 Subject: cleanup event form and various required indicators on inputs --- include/datetime.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index 346d03bd4..a387d84c4 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -174,7 +174,7 @@ function timesel($format, $h, $m, $id='timepicker') { * @param $maxfrom * set maximum date from picker with id $maxfrom (none by default) */ -function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '') { +function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pickdate = true, $picktime = true, $minfrom = '', $maxfrom = '',$required = false) { // Once browser support is better this could probably be replaced with native HTML5 date picker $o = ''; @@ -209,6 +209,7 @@ function datetimesel($format, $min, $max, $default, $id = 'datetimepicker', $pic $readable_format = str_replace('i','MM',$readable_format); $o .= "
"; + $o .= (($required) ? '*' : ''); $o .= '
'; $o .= ""; return $o; -- cgit v1.2.3