aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-02-16 15:51:55 -0800
committerfriendica <info@friendica.com>2013-02-16 15:51:55 -0800
commita21e6cffa184d78b6214a0306e2d2a7bbfc8ddb1 (patch)
tree1448f88c5be38411f91c0f32cef2b7443706fdfb
parent663f09e01bab8e20390691d81cac541d4fd3289a (diff)
downloadvolse-hubzilla-a21e6cffa184d78b6214a0306e2d2a7bbfc8ddb1.tar.gz
volse-hubzilla-a21e6cffa184d78b6214a0306e2d2a7bbfc8ddb1.tar.bz2
volse-hubzilla-a21e6cffa184d78b6214a0306e2d2a7bbfc8ddb1.zip
start on channel_remove(), add some generic channel queries to the API layers
-rw-r--r--boot.php2
-rw-r--r--include/Contact.php85
-rw-r--r--include/follow.php2
-rw-r--r--include/security.php5
-rw-r--r--version.inc2
5 files changed, 60 insertions, 36 deletions
diff --git a/boot.php b/boot.php
index e62676e4f..3b7409b1a 100644
--- a/boot.php
+++ b/boot.php
@@ -147,6 +147,8 @@ define ( 'PAGE_HIDDEN', 0x0001 );
define ( 'PAGE_AUTOCONNECT', 0x0002 );
define ( 'PAGE_APPLICATION', 0x0004 );
+define ( 'PAGE_REMOVED', 0x8000 );
+
//define ( 'PAGE_FREELOVE', 3 );
//define ( 'PAGE_BLOG', 4 );
//define ( 'PAGE_PRVGROUP', 5 );
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'];
diff --git a/version.inc b/version.inc
index e66c9883d..abe9cf720 100644
--- a/version.inc
+++ b/version.inc
@@ -1 +1 @@
-2013-02-15.225
+2013-02-16.226