aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Contact.php85
-rw-r--r--include/follow.php2
-rw-r--r--include/security.php5
3 files changed, 57 insertions, 35 deletions
diff --git a/include/Contact.php b/include/Contact.php
index 2ace23f01..7febe310d 100644
--- a/include/Contact.php
+++ b/include/Contact.php
@@ -20,8 +20,23 @@ function abook_self($channel_id) {
}
function channelx_by_nick($nick) {
- return q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' LIMIT 1",
- dbesc($nick)
+ return q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_address = '%s' and not ( channel_pageflags & %d ) LIMIT 1",
+ dbesc($nick),
+ intval(PAGE_REMOVED)
+ );
+}
+
+function channelx_by_hash($hash) {
+ return q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_hash = '%s' and not ( channel_pageflags & %d ) LIMIT 1",
+ dbesc($hash),
+ intval(PAGE_REMOVED)
+ );
+}
+
+function channelx_by_n($id) {
+ return q("SELECT * FROM channel left join xchan on channel_hash = xchan_hash WHERE channel_id = %d and not ( channel_pageflags & %d ) LIMIT 1",
+ dbesc($id),
+ intval(PAGE_REMOVED)
);
}
@@ -89,47 +104,53 @@ function abook_toggle_flag($abook,$flag) {
// authorisation to do this.
function user_remove($uid) {
- if(! $uid)
+
+}
+
+
+function channel_remove($channel_id) {
+
+ if(! $channel_id)
return;
$a = get_app();
- logger('Removing user: ' . $uid);
-
- $r = q("select * from user where uid = %d limit 1", intval($uid));
+ logger('Removing channel: ' . $channel_id);
- call_hooks('remove_user',$r[0]);
+ $r = q("select * from channel where channel_id = %d limit 1", intval($channel_id));
- // save username (actually the nickname as it is guaranteed
- // unique), so it cannot be re-registered in the future.
+ call_hooks('channel_remove',$r[0]);
- q("insert into userd ( username ) values ( '%s' )",
- $r[0]['nickname']
+ // FIXME notify the directory
+
+ // FIXME notify all contacts
+
+
+ q("DELETE FROM `group` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `group_member` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `event` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `item` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `item_id` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `mail` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `notify` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `photo` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `attach` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `profile` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($channel_id));
+ q("DELETE FROM `spam` WHERE `uid` = %d", intval($channel_id));
+
+ // We also need a timestamp in the channel DB so we know when to remove the entry.
+
+ $r = q("update channel set channel_pageflags = (channel_pageflags | %d) where channel_id = %d limit 1",
+ intval(PAGE_REMOVED),
+ intval($channel_id)
);
- q("DELETE FROM `contact` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `gcign` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `group` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `group_member` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `intro` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `event` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `item` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `item_id` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `mail` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `mailacct` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `manage` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `notify` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `photo` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `attach` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `profile` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `profile_check` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `pconfig` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `search` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `spam` WHERE `uid` = %d", intval($uid));
- q("DELETE FROM `user` WHERE `uid` = %d", intval($uid));
- if($uid == local_user()) {
+
+ if($channel_id == local_user()) {
unset($_SESSION['authenticated']);
unset($_SESSION['uid']);
goaway($a->get_baseurl());
}
+
}
diff --git a/include/follow.php b/include/follow.php
index cf77c40ea..a094a979f 100644
--- a/include/follow.php
+++ b/include/follow.php
@@ -114,7 +114,7 @@ function new_contact($uid,$url,$channel,$interactive = false) {
$hash = $a->observer['xchan_hash'];
}
else {
- $r = q("select * from channel where uid = %d limit 1",
+ $r = q("select * from channel where channel_id = %d limit 1",
intval($uid)
);
if(! $r) {
diff --git a/include/security.php b/include/security.php
index 8477ea6de..e691939fb 100644
--- a/include/security.php
+++ b/include/security.php
@@ -138,9 +138,10 @@ function change_channel($change_channel) {
$ret = false;
if($change_channel) {
- $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_account_id = %d limit 1",
+ $r = q("select channel.*, xchan.* from channel left join xchan on channel.channel_hash = xchan.xchan_hash where channel_id = %d and channel_account_id = %d and not ( channel_pageflags & %d) limit 1",
intval($change_channel),
- intval(get_account_id())
+ intval(get_account_id()),
+ intval(PAGE_REMOVED)
);
if($r) {
$hash = $r[0]['channel_hash'];