start on item_restrict conversion
This commit is contained in:
parent
6e0e3b2433
commit
4c2a1e572a
@ -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');
|
||||
|
@ -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')
|
||||
);
|
||||
|
@ -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) {
|
||||
|
@ -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'])
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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');
|
||||
|
@ -250,7 +250,7 @@ function display_content(&$a, $update = 0, $load = false) {
|
||||
dbesc($item_hash)
|
||||
);
|
||||
if($r) {
|
||||
if($r[0]['item_flags'] & ITEM_DELETED) {
|
||||
if(intval($r[0]['item_deleted'])) {
|
||||
notice( t('Item has been removed.') . EOL );
|
||||
}
|
||||
else {
|
||||
|
@ -1047,11 +1047,10 @@ function item_check_service_class($channel_id,$iswebpage) {
|
||||
if ($iswebpage) {
|
||||
$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 )
|
||||
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_DELETED),
|
||||
intval($channel_id)
|
||||
);
|
||||
intval($channel_id)
|
||||
);
|
||||
}
|
||||
else {
|
||||
$r = q("select count(i.id) as total from item i
|
||||
|
@ -180,19 +180,8 @@ function photos_post(&$a) {
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
if(count($i)) {
|
||||
q("UPDATE `item` SET item_restrict = (item_restrict | %d), `edited` = '%s', `changed` = '%s' WHERE `parent_mid` = '%s' AND `uid` = %d",
|
||||
intval(ITEM_DELETED),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc(datetime_convert()),
|
||||
dbesc($i[0]['mid']),
|
||||
intval($page_owner_uid)
|
||||
);
|
||||
|
||||
drop_item($i[0]['id'],true,DROPITEM_PHASE1);
|
||||
$url = $a->get_baseurl();
|
||||
$drop_id = intval($i[0]['id']);
|
||||
|
||||
if($i[0]['visible'])
|
||||
proc_run('php',"include/notifier.php","drop","$drop_id");
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user