start on item_restrict conversion

This commit is contained in:
friendica 2015-01-22 21:04:54 -08:00
parent 6e0e3b2433
commit 4c2a1e572a
9 changed files with 53 additions and 54 deletions

View File

@ -206,7 +206,7 @@ function diaspora_process_outbound($arr) {
if(! $contact['xchan_pubkey']) if(! $contact['xchan_pubkey'])
continue; continue;
if(($target_item['item_restrict'] & ITEM_DELETED) if(intval($target_item['item_deleted'])
&& (($target_item['mid'] === $target_item['parent_mid']) || $arr['followup'])) { && (($target_item['mid'] === $target_item['parent_mid']) || $arr['followup'])) {
// send both top-level retractions and relayable retractions for owner to relay // send both top-level retractions and relayable retractions for owner to relay
diaspora_send_retraction($target_item,$arr['channel'],$contact); diaspora_send_retraction($target_item,$arr['channel'],$contact);
@ -235,8 +235,8 @@ function diaspora_process_outbound($arr) {
$contact = $arr['hub']; $contact = $arr['hub'];
if(($target_item['deleted']) if(intval($target_item['item_deleted'])
&& ($target_item['mid'] === $target_item['parent_mod'])) { && ($target_item['mid'] === $target_item['parent_mid'])) {
// top-level retraction // top-level retraction
logger('delivery: diaspora retract: ' . $loc); logger('delivery: diaspora retract: ' . $loc);
diaspora_send_retraction($target_item,$arr['channel'],$contact,true); 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'; $target_type = 'Post';
$positive = 'true'; $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'); logger('diaspora_send_followup: received deleted "like". Those should go to diaspora_send_retraction');
} }
else { else {
@ -2549,7 +2549,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$relay_retract = false; $relay_retract = false;
$sql_sign_id = 'iid'; $sql_sign_id = 'iid';
if( $item['item_restrict'] & ITEM_DELETED) { if( intval($item['item_deleted']) {
$relay_retract = true; $relay_retract = true;
$target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment'); $target_type = ( ($item['verb'] === ACTIVITY_LIKE) ? 'Like' : 'Comment');
@ -2561,7 +2561,7 @@ function diaspora_send_relay($item,$owner,$contact,$public_batch = false) {
$like = true; $like = true;
$target_type = ( $parent['mid'] === $parent['parent_mid'] ? 'Post' : 'Comment'); $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'; $positive = 'true';
$tpl = get_markup_template('diaspora_like_relay.tpl'); $tpl = get_markup_template('diaspora_like_relay.tpl');

View File

@ -7,8 +7,7 @@ function expire_run($argv, $argc){
cli_startup(); cli_startup();
$r = q("select id from item where (item_restrict & %d)>0 and not (item_restrict & %d)>0 and changed < %s - INTERVAL %s", $r = q("select id from item where item_deleted = 1 and not (item_restrict & %d)>0 and changed < %s - INTERVAL %s",
intval(ITEM_DELETED),
intval(ITEM_PENDING_REMOVE), intval(ITEM_PENDING_REMOVE),
db_utcnow(), db_quoteinterval('10 DAY') db_utcnow(), db_quoteinterval('10 DAY')
); );

View File

@ -589,8 +589,7 @@ function identity_basic_export($channel_id, $items = false) {
// warning: this may run into memory limits on smaller systems // 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", $r = q("select * from item where item_wall = 1 and item_deleted = 0 and uid = %d",
intval(ITEM_DELETED),
intval($channel_id) intval($channel_id)
); );
if($r) { if($r) {

View File

@ -839,7 +839,7 @@ function get_item_elements($x) {
$arr['item_consensus'] = 1; $arr['item_consensus'] = 1;
if(array_key_exists('flags',$x) && in_array('deleted',$x['flags'])) 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'])) if(array_key_exists('flags',$x) && in_array('hidden',$x['flags']))
$arr['item_restrict'] = ITEM_HIDDEN; $arr['item_restrict'] = ITEM_HIDDEN;
@ -1310,7 +1310,7 @@ function encode_item_flags($item) {
$ret = array(); $ret = array();
if($item['item_restrict'] & ITEM_DELETED) if(intval($item['item_deleted']))
$ret[] = 'deleted'; $ret[] = 'deleted';
if($item['item_restrict'] & ITEM_HIDDEN) if($item['item_restrict'] & ITEM_HIDDEN)
$ret[] = 'hidden'; $ret[] = 'hidden';
@ -2109,7 +2109,7 @@ function item_store($arr,$allow_exec = false) {
} }
$parent_id = $r[0]['id']; $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_cid = $r[0]['allow_cid'];
$allow_gid = $r[0]['allow_gid']; $allow_gid = $r[0]['allow_gid'];
$deny_cid = $r[0]['deny_cid']; $deny_cid = $r[0]['deny_cid'];
@ -2149,7 +2149,7 @@ function item_store($arr,$allow_exec = false) {
} }
if($parent_deleted) 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", $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) { if($r) {
$item = $r[0]; $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); logger('consume_feed: deleting item ' . $item['id'] . ' mid=' . base64url_decode($item['mid']), LOGGER_DEBUG);
drop_item($item['id'],false); drop_item($item['id'],false);
} }
@ -3948,7 +3948,7 @@ function drop_item($id,$interactive = true,$stage = DROPITEM_NORMAL,$force = fal
intval($id) 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) if(! $interactive)
return 0; return 0;
notice( t('Item not found.') . EOL); 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 // 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. // 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", $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ) WHERE id = %d",
intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), intval(ITEM_HIDDEN),
intval($item['id']) 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); $arr = array('item' => $item, 'interactive' => $interactive, 'stage' => $stage);
call_hooks('drop_item', $arr ); call_hooks('drop_item', $arr );
@ -4047,13 +4053,23 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL,$force = false) {
break; break;
case DROPITEM_PHASE1: case DROPITEM_PHASE1:
if($linked_item && ! $force) {
$r = q("UPDATE item SET item_restrict = ( item_restrict | %d ), $r = q("UPDATE item SET item_restrict = ( item_restrict | %d ),
changed = '%s', edited = '%s' WHERE id = %d", changed = '%s', edited = '%s' WHERE id = %d",
intval(($linked_item && ! $force) ? ITEM_HIDDEN : ITEM_DELETED), intval(ITEM_HIDDEN),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($item['id']) 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; break;
case DROPITEM_NORMAL: case DROPITEM_NORMAL:
@ -4068,9 +4084,8 @@ function delete_item_lowlevel($item,$stage = DROPITEM_NORMAL,$force = false) {
); );
} }
else { 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", changed = '%s', edited = '%s' WHERE id = %d",
intval(ITEM_DELETED),
dbesc(datetime_convert()), dbesc(datetime_convert()),
dbesc(datetime_convert()), dbesc(datetime_convert()),
intval($item['id']) intval($item['id'])

View File

@ -207,9 +207,8 @@ function notifier_run($argv, $argc){
$normal_mode = false; $normal_mode = false;
$expire = true; $expire = true;
$items = q("SELECT * FROM item WHERE uid = %d AND item_wall = 1 $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_id),
intval(ITEM_DELETED),
db_utcnow(), db_quoteinterval('10 MINUTE') db_utcnow(), db_quoteinterval('10 MINUTE')
); );
$uid = $item_id; $uid = $item_id;
@ -314,7 +313,7 @@ function notifier_run($argv, $argc){
$target_item = $r[0]; $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); logger('notifier: target item ITEM_DELETED', LOGGER_DEBUG);
$unforwardable = ITEM_UNPUBLISHED|ITEM_DELAYED_PUBLISH|ITEM_WEBPAGE|ITEM_BUILDBLOCK|ITEM_PDL; $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 // don't send deletions onward for other people's stuff
// TODO verify this is needed - copied logic from same place in old code // 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'); logger('notifier: ignoring delete notification for non-wall item');
return; return;
} }

View File

@ -53,10 +53,9 @@ function poller_run($argv, $argc){
// expire any expired items // expire any expired items
$r = q("select id from item where expires != '%s' and expires < %s $r = q("select id from item where expires != '%s' and expires < %s
and ( item_restrict & %d ) = 0 ", and item_deleted = 0 ",
dbesc(NULL_DATE), dbesc(NULL_DATE),
db_utcnow(), db_utcnow()
intval(ITEM_DELETED)
); );
if($r) { if($r) {
require_once('include/items.php'); require_once('include/items.php');

View File

@ -250,7 +250,7 @@ function display_content(&$a, $update = 0, $load = false) {
dbesc($item_hash) dbesc($item_hash)
); );
if($r) { if($r) {
if($r[0]['item_flags'] & ITEM_DELETED) { if(intval($r[0]['item_deleted'])) {
notice( t('Item has been removed.') . EOL ); notice( t('Item has been removed.') . EOL );
} }
else { else {

View File

@ -1047,9 +1047,8 @@ function item_check_service_class($channel_id,$iswebpage) {
if ($iswebpage) { if ($iswebpage) {
$r = q("select count(i.id) as total from item i $r = q("select count(i.id) as total from item i
right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id ) right join channel c on (i.author_xchan=c.channel_hash and i.uid=c.channel_id )
and i.parent=i.id and (i.item_restrict & %d)>0 and not (i.item_restrict & %d)>0 and i.uid= %d ", and i.parent=i.id and (i.item_restrict & %d)>0 and i.item_deleted = 0 and i.uid= %d ",
intval(ITEM_WEBPAGE), intval(ITEM_WEBPAGE),
intval(ITEM_DELETED),
intval($channel_id) intval($channel_id)
); );
} }

View File

@ -180,19 +180,8 @@ function photos_post(&$a) {
intval($page_owner_uid) intval($page_owner_uid)
); );
if(count($i)) { if(count($i)) {
q("UPDATE `item` SET item_restrict = (item_restrict | %d), `edited` = '%s', `changed` = '%s' WHERE `parent_mid` = '%s' AND `uid` = %d", drop_item($i[0]['id'],true,DROPITEM_PHASE1);
intval(ITEM_DELETED),
dbesc(datetime_convert()),
dbesc(datetime_convert()),
dbesc($i[0]['mid']),
intval($page_owner_uid)
);
$url = $a->get_baseurl(); $url = $a->get_baseurl();
$drop_id = intval($i[0]['id']);
if($i[0]['visible'])
proc_run('php',"include/notifier.php","drop","$drop_id");
} }
} }