make contact_remove sort of work so I can actually get rid of Oliver's and Michael J's dead contacts and not poll them every ten minutes forever

This commit is contained in:
friendica 2013-01-25 16:18:35 -08:00
parent 318d75a86a
commit c96eb6dc97
6 changed files with 43 additions and 23 deletions

View File

@ -126,28 +126,46 @@ function user_remove($uid) {
} }
function contact_remove($id) { function contact_remove($channel_id, $abook_id) {
$r = q("select uid from contact where id = %d limit 1", if((! $channel_id) || (! $abook_id))
intval($id) return false;
);
if((! count($r)) || (! intval($r[0]['uid'])))
return;
$archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts'); $archive = get_pconfig($channel_id, 'system','archive_removed_contacts');
if($archive) { if($archive) {
q("update contact set `archive` = 1, `network` = 'none', `writable` = 0 where id = %d limit 1", q("update abook set abook_flags = abook_flags | %d where abook_id = %d and abook_channel = %d limit 1",
intval($id) intval(ABOOK_FLAG_ARCHIVE),
intval($abook_id),
intval($channel_id)
); );
return; return true;
} }
q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1", $r = q("select * from abook where abook_id = %d and abook_channel = %d limit 1",
intval($id) intval($abook_id),
intval($channel_id)
); );
q("DELETE FROM `item` WHERE `contact-id` = %d ",
intval($id) if(! $r)
return false;
$abook = $r[0];
if($abook['abook_flags'] & ABOOK_FLAG_SELF)
return false;
q("delete from item where author_xchan = '%s' and uid = %d",
dbesc($abook['abook_xchan']),
intval($channel_id)
); );
q("delete from abook where abook_id = %d and channel_id = %d limit 1",
intval($abook['abook_id']),
intval($channel_id)
);
/*
// FIXME
q("DELETE FROM `photo` WHERE `contact-id` = %d ", q("DELETE FROM `photo` WHERE `contact-id` = %d ",
intval($id) intval($id)
); );
@ -160,7 +178,9 @@ function contact_remove($id) {
q("DELETE FROM `queue` WHERE `cid` = %d ", q("DELETE FROM `queue` WHERE `cid` = %d ",
intval($id) intval($id)
); );
*/
return true;
} }

View File

@ -63,7 +63,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
info( t('Logged out.') . EOL); info( t('Logged out.') . EOL);
goaway(z_root()); goaway(z_root());
} }
dbg(1);
if(x($_SESSION,'visitor_id') && (! x($_SESSION,'uid'))) { if(x($_SESSION,'visitor_id') && (! x($_SESSION,'uid'))) {
$r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash where hubloc_hash = '%s' limit 1", $r = q("select * from hubloc left join xchan on xchan_hash = hubloc_hash where hubloc_hash = '%s' limit 1",
dbesc($_SESSION['visitor_id']) dbesc($_SESSION['visitor_id'])
@ -77,7 +77,7 @@ dbg(1);
} }
$a->set_groups(init_groups_visitor($_SESSION['visitor_id'])); $a->set_groups(init_groups_visitor($_SESSION['visitor_id']));
} }
dbg(0);
if(x($_SESSION,'uid') || x($_SESSION,'account_id')) { if(x($_SESSION,'uid') || x($_SESSION,'account_id')) {
// already logged in user returning // already logged in user returning

View File

@ -3631,7 +3631,7 @@ function lose_follower($importer,$contact,$datarray,$item) {
); );
} }
else { else {
contact_remove($contact['id']); // contact_remove($contact['id']);
} }
} }
@ -3644,7 +3644,7 @@ function lose_sharer($importer,$contact,$datarray,$item) {
); );
} }
else { else {
contact_remove($contact['id']); // contact_remove($contact['id']);
} }
} }

View File

@ -223,7 +223,7 @@ function connections_content(&$a) {
// FIXME // FIXME
// terminate_friendship($a->get_channel(),$orig_record[0]); // terminate_friendship($a->get_channel(),$orig_record[0]);
contact_remove($orig_record[0]['abook_id']); contact_remove(local_user(), $orig_record[0]['abook_id']);
info( t('Contact has been removed.') . EOL ); info( t('Contact has been removed.') . EOL );
if(x($_SESSION,'return_url')) if(x($_SESSION,'return_url'))
goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']); goaway($a->get_baseurl(true) . '/' . $_SESSION['return_url']);

View File

@ -71,7 +71,7 @@ function dirsearch_content(&$a) {
// By default we return one page (default 80 items maximum) and do not count total entries // By default we return one page (default 80 items maximum) and do not count total entries
$logic = ((strlen($sql_extra)) ? 0 : 1); $logic = ((strlen($sql_extra)) ? 0 : 1);
dbg(1);
if($limit) if($limit)
$qlimit = " LIMIT $limit "; $qlimit = " LIMIT $limit ";
else { else {
@ -91,7 +91,7 @@ dbg(1);
$r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d ) $order $qlimit ", $r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d ) $order $qlimit ",
intval(XCHAN_FLAGS_HIDDEN) intval(XCHAN_FLAGS_HIDDEN)
); );
dbg(0);
$ret['page'] = $page + 1; $ret['page'] = $page + 1;
$ret['records'] = count($r); $ret['records'] = count($r);

View File

@ -620,7 +620,7 @@ function network_content(&$a, $update = 0, $load = false) {
if($load) { if($load) {
// Fetch a page full of parent items for this page // Fetch a page full of parent items for this page
dbg(1);
$r = q("SELECT item.id AS item_id FROM item $r = q("SELECT item.id AS item_id FROM item
left join abook on item.author_xchan = abook.abook_xchan left join abook on item.author_xchan = abook.abook_xchan
WHERE item.uid = %d AND item.item_restrict = 0 WHERE item.uid = %d AND item.item_restrict = 0
@ -631,7 +631,7 @@ dbg(1);
intval(local_user()), intval(local_user()),
intval(ABOOK_FLAG_BLOCKED) intval(ABOOK_FLAG_BLOCKED)
); );
dbg(0);
} }
else { else {
// update // update