diff options
author | friendica <info@friendica.com> | 2015-01-22 21:04:54 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-01-22 21:04:54 -0800 |
commit | 4c2a1e572a03e253f05f03e400af26d403cbda32 (patch) | |
tree | edf7afa0bb97dfb9c8ea598a28c3e6281a65ec90 /include | |
parent | 6e0e3b2433fc426b758a55811f56536d58705813 (diff) | |
download | volse-hubzilla-4c2a1e572a03e253f05f03e400af26d403cbda32.tar.gz volse-hubzilla-4c2a1e572a03e253f05f03e400af26d403cbda32.tar.bz2 volse-hubzilla-4c2a1e572a03e253f05f03e400af26d403cbda32.zip |
start on item_restrict conversion
Diffstat (limited to 'include')
-rwxr-xr-x | include/diaspora.php | 12 | ||||
-rw-r--r-- | include/expire.php | 3 | ||||
-rw-r--r-- | include/identity.php | 3 | ||||
-rwxr-xr-x | include/items.php | 55 | ||||
-rw-r--r-- | include/notifier.php | 7 | ||||
-rw-r--r-- | include/poller.php | 5 |
6 files changed, 48 insertions, 37 deletions
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'); |