removeme sort of works for a single channel - lots of loose ends to deal with but it's a start

This commit is contained in:
friendica 2013-11-12 18:27:36 -08:00
parent 061b438f97
commit b26989bb65
6 changed files with 64 additions and 38 deletions

View file

@ -1632,8 +1632,10 @@ function profile_load(&$a, $nickname, $profile = '') {
if(! $r) {
$r = q("SELECT profile.uid AS profile_uid, profile.*, channel.* FROM profile
LEFT JOIN channel ON profile.uid = channel.channel_id
WHERE channel.channel_address = '%s' AND profile.is_default = 1 LIMIT 1",
dbesc($nickname)
WHERE channel.channel_address = '%s' and not ( channel_pageflags & %d )
AND profile.is_default = 1 LIMIT 1",
dbesc($nickname),
intval(PAGE_REMOVED)
);
}

View file

@ -199,6 +199,7 @@ function channel_remove($channel_id, $local = true) {
return;
$a = get_app();
logger('Removing channel: ' . $channel_id);
logger('channel_remove: local only: ' . intval($local));
$r = q("select * from channel where channel_id = %d limit 1", intval($channel_id));
if(! $r) {
@ -209,12 +210,8 @@ function channel_remove($channel_id, $local = true) {
$channel = $r[0];
call_hooks('channel_remove',$r[0]);
if(! $local) {
// FIXME notify the directory
// FIXME notify all contacts
if(! $local) {
$r = q("update channel set channel_deleted = '%s', channel_pageflags = (channel_pageflags | %d), channel_r_stream = 0, channel_r_profile = 0,
channel_r_photos = 0, channel_r_abook = 0, channel_w_stream = 0, channel_w_wall = 0, channel_w_tagwall = 0,
@ -254,6 +251,12 @@ function channel_remove($channel_id, $local = true) {
q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($channel_id));
q("DELETE FROM `spam` WHERE `uid` = %d", intval($channel_id));
q("delete from abook where abook_xchan = '%s' and abook_flags & %d limit 1",
dbesc($channel['channel_hash']),
dbesc(ABOOK_FLAG_SELF)
);
$r = q("update channel set channel_deleted = '%s', channel_pageflags = (channel_pageflags | %d) where channel_id = %d limit 1",
dbesc(datetime_convert()),
intval(PAGE_REMOVED),
@ -291,10 +294,8 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
}
else {
// this is somewhat destructive
// FIXME
// We don't want to be quite as destructive on directories, which will need to mirror the action
// and we also don't want to completely destroy an xchan that has moved to a new primary location
$dirmode = intval(get_config('system','directory_mode'));
$r = q("delete from photo where xchan = '%s'",
dbesc($xchan)
@ -323,22 +324,35 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) {
dbesc($xchan)
);
$r = q("delete from abook where abook_xchan = '%s'",
dbesc($xchan)
);
// This could get sticky with directories
// $r = q("delete from xchan where xchan_hash = '%s' limit 1",
// dbesc($xchan)
// );
// $r = q("delete from hubloc where hubloc_hash = '%s'",
// dbesc($xchan)
// );
// $r = q("delete from abook where abook_xchan = '%s'",
// dbesc($xchan)
// );
// $r = q("delete from xtag where xtag_hash = '%s'",
// dbesc($xchan)
// );
if($dirmode === false || $dirmode == DIRECTORY_MODE_NORMAL) {
$r = q("delete from xchan where xchan_hash = '%s' limit 1",
dbesc($xchan)
);
$r = q("delete from hubloc where hubloc_hash = '%s'",
dbesc($xchan)
);
}
else {
// 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),
dbesc($xchan)
);
$r = q("update xchan set xchan_flags = xchan_flags | %d where xchan_hash = '%s'",
intval(XCHAN_FLAGS_DELETED),
dbesc($xchan)
);
}
}
}

View file

@ -121,9 +121,10 @@ function dirsearch_content(&$a) {
else {
$qlimit = " LIMIT " . intval($startrec) . " , " . intval($perpage);
if($return_total) {
$r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d) and not ( xchan_flags & %d ) $safesql ",
$r = q("SELECT COUNT(xchan_hash) AS `total` FROM xchan left join xprof on xchan_hash = xprof_hash where $logic $sql_extra and not ( xchan_flags & %d) and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) $safesql ",
intval(XCHAN_FLAGS_HIDDEN),
intval(XCHAN_FLAGS_ORPHAN)
intval(XCHAN_FLAGS_ORPHAN),
intval(XCHAN_FLAGS_DELETED)
);
if($r) {
$ret['total_items'] = $r[0]['total'];
@ -161,9 +162,10 @@ function dirsearch_content(&$a) {
}
else {
$r = q("SELECT xchan.*, xprof.* from xchan left join xprof on xchan_hash = xprof_hash where ( $logic $sql_extra ) and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) $safesql $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 ) and not ( xchan_flags & %d ) and not ( xchan_flags & %d ) $safesql $order $qlimit ",
intval(XCHAN_FLAGS_HIDDEN),
intval(XCHAN_FLAGS_ORPHAN)
intval(XCHAN_FLAGS_ORPHAN),
intval(XCHAN_FLAGS_DELETED)
);
}

View file

@ -36,8 +36,9 @@ function manage_content(&$a) {
$channels = null;
if(local_user()) {
$r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d order by channel_name ",
intval(get_account_id())
$r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel.channel_account_id = %d and not ( channel_pageflags & %d ) order by channel_name ",
intval(get_account_id()),
intval(PAGE_REMOVED)
);
$selected_channel = null;

View file

@ -17,13 +17,17 @@ function removeme_post(&$a) {
if($_POST['verify'] !== $_SESSION['remove_account_verify'])
return;
$encrypted = hash('whirlpool',trim($_POST['qxz_password']));
if((strlen($a->user['password'])) && ($encrypted === $a->user['password'])) {
require_once('include/Contact.php');
user_remove($a->user['uid']);
// NOTREACHED
}
$account = $a->get_account();
if(! account_verify_password($account['account_email'],$_POST['qxz_password']))
return;
require_once('include/Contact.php');
$global_remove = intval($_POST['global']);
channel_remove(local_user(),1 - $global_remove);
}
@ -42,9 +46,10 @@ function removeme_content(&$a) {
$o .= replace_macros($tpl, array(
'$basedir' => $a->get_baseurl(),
'$hash' => $hash,
'$title' => t('Remove My Account'),
'$desc' => t('This will completely remove your account. Once this has been done it is not recoverable.'),
'$title' => t('Remove This Channel'),
'$desc' => t('This will completely remove this channel from the network. Once this has been done it is not recoverable.'),
'$passwd' => t('Please enter your password for verification:'),
'$global' => array('global', t('Remove this channel and all its clones from the network'), false, t('By default only the instance of the channel located on this hub will be removed from the network')),
'$submit' => t('Remove My Account')
));

View file

@ -13,6 +13,8 @@
</div>
<div id="remove-account-pass-end"></div>
{{include file="field_checkbox.tpl" field=$global}}
<input type="submit" name="submit" value="{{$submit}}" />
</form>