From b3d1b8332f39259efe258a1d0ddb054dabf82823 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 11 Jan 2013 14:40:44 -0800 Subject: use correct param for connect link --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index e52b5c9cf..14332c417 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -16,7 +16,7 @@ function vcard_from_xchan($xchan) { return replace_macros(get_markup_template('xchan_vcard.tpl'),array( '$name' => $xchan['xchan_name'], '$photo' => $xchan['xchan_photo_l'], - '$url' => $xchan['xchan_addr'], + '$follow' => $xchan['xchan_addr'], '$connect' => $connect )); } -- cgit v1.2.3 From f63997f61877bf03b9c85cbfaa00b8300c8cb770 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 23 Jan 2013 16:06:01 -0800 Subject: plug potential hole in magic auth, add link to chanview to view in dedicated window --- include/Contact.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 14332c417..a2303803c 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,7 +1,7 @@ $xchan['xchan_name'], '$photo' => $xchan['xchan_photo_l'], '$follow' => $xchan['xchan_addr'], - '$connect' => $connect + '$connect' => $connect, + '$newwin' => (($mode === 'chanview') ? t('New window') : ''), + '$newtit' => t('Open the selected location in a different window or browser tab'), + '$url' => $url, )); } -- cgit v1.2.3 From d8fe7e011513855d9bd0178638bfebd70145b8a5 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 25 Jan 2013 05:00:18 -0800 Subject: more api functions to help pull business logic out of controller code, in this case the often used functions to fetch all contacts or fetch the self contact --- include/Contact.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index a2303803c..972911c0f 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,6 +1,24 @@ Date: Fri, 25 Jan 2013 05:12:16 -0800 Subject: api for abook entries --- include/Contact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 972911c0f..9bb047060 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,9 +1,9 @@ Date: Fri, 25 Jan 2013 16:18:35 -0800 Subject: 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 --- include/Contact.php | 48 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 14 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 9bb047060..be4bd9212 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -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", - intval($id) - ); - if((! count($r)) || (! intval($r[0]['uid']))) - return; + if((! $channel_id) || (! $abook_id)) + return false; - $archive = get_pconfig($r[0]['uid'], 'system','archive_removed_contacts'); + $archive = get_pconfig($channel_id, 'system','archive_removed_contacts'); if($archive) { - q("update contact set `archive` = 1, `network` = 'none', `writable` = 0 where id = %d limit 1", - intval($id) + q("update abook set abook_flags = abook_flags | %d where abook_id = %d and abook_channel = %d limit 1", + intval(ABOOK_FLAG_ARCHIVE), + intval($abook_id), + intval($channel_id) ); - return; + return true; } - q("DELETE FROM `contact` WHERE `id` = %d LIMIT 1", - intval($id) + $r = q("select * from abook where abook_id = %d and abook_channel = %d limit 1", + 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 ", intval($id) ); @@ -160,7 +178,9 @@ function contact_remove($id) { q("DELETE FROM `queue` WHERE `cid` = %d ", intval($id) ); +*/ + return true; } -- cgit v1.2.3 From 91126d8dd33bdfa86ab1013561833b0c3c224a14 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 26 Jan 2013 02:24:07 -0800 Subject: more photo backend stuff --- include/Contact.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index be4bd9212..2ace23f01 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -19,6 +19,13 @@ function abook_self($channel_id) { return(($r) ? $r[0] : array()); } +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) + ); +} + + function vcard_from_xchan($xchan, $observer = null, $mode = '') { $connect = false; -- cgit v1.2.3 From a21e6cffa184d78b6214a0306e2d2a7bbfc8ddb1 Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 16 Feb 2013 15:51:55 -0800 Subject: start on channel_remove(), add some generic channel queries to the API layers --- include/Contact.php | 85 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 53 insertions(+), 32 deletions(-) (limited to 'include/Contact.php') 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()); } + } -- cgit v1.2.3 From 65912ec0bfb112fd3dca4a8823bb834a1b1c80fc Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 18 Feb 2013 15:15:55 -0800 Subject: moving on --- include/Contact.php | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 7febe310d..36f4cbcf7 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -153,6 +153,66 @@ function channel_remove($channel_id) { } +function remove_all_xchan_resources($xchan, $channel_id = 0) { + + if(intval($channel_id)) { + + + + } + 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 + + $r = q("delete from photo where xchan = '%s'", + dbesc($xchan) + ); + $r = q("select resource_id, resource_type, uid, id from item where ( author_xchan = '%s' or owner_xchan = '%s' ) ", + dbesc($xchan), + dbesc($xchan) + ); + if($r) { + foreach($r as $rr) { + drop_item($rr,false); + } + } + $r = q("delete from event where event_xchan = '%s'", + dbesc($xchan) + ); + $r = q("delete from group_member where xchan = '%s'", + dbesc($xchan) + ); + $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' )", + dbesc($xchan), + dbesc($xchan) + ); + $r = q("delete from xlink where ( xlink_xchan = '%s' or xlink_link = '%s' )", + dbesc($xchan), + dbesc($xchan) + ); + + + $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) + ); + + } +} + + + function contact_remove($channel_id, $abook_id) { -- cgit v1.2.3 From ea3940c4b0b8232e2de0771811b9f90ade9ee45f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 25 Feb 2013 17:09:40 -0800 Subject: start formatting for Doxygen --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 36f4cbcf7..6978b45bc 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,4 +1,4 @@ - Date: Wed, 6 Mar 2013 00:21:02 -0800 Subject: randprof sorta working --- include/Contact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 6978b45bc..a49cc335f 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -397,8 +397,8 @@ function contact_photo_menu($contact) { function random_profile() { - $r = q("select xchan_url from xchan where xchan_network = 'zot' order by rand() limit 1"); - if($r && count($r)) + $r = q("select xchan_url from xchan where 1 order by rand() limit 1"); + if($r) return $r[0]['xchan_url']; return ''; } -- cgit v1.2.3 From 868a1877d289c886a7a081aa1bcea2f0cee7b51e Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 19 Apr 2013 04:47:49 -0700 Subject: sql error on contact removal --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index a49cc335f..b2d459ca4 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -247,7 +247,7 @@ function contact_remove($channel_id, $abook_id) { intval($channel_id) ); - q("delete from abook where abook_id = %d and channel_id = %d limit 1", + q("delete from abook where abook_id = %d and abook_channel = %d limit 1", intval($abook['abook_id']), intval($channel_id) ); -- cgit v1.2.3 From 156cf592eeeaf1ef2fe446655b1f28debab7814c Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 26 Jun 2013 14:28:11 -0700 Subject: more nomadic clone sync --- include/Contact.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index b2d459ca4..245682454 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -76,6 +76,9 @@ function abook_toggle_flag($abook,$flag) { intval($abook['abook_id']), intval($abook['abook_channel']) ); + $a = get_app(); + if($a->data['abook']) + $a->data['abook']['abook_flags'] = $a->data['abook']['abook_flags'] ^ $flag; return $r; } -- cgit v1.2.3 From 4c30cddbfc105c0ea60f30594b760633e654cb0c Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 16 Jul 2013 22:48:05 -0700 Subject: provide a controlling user for theme settings, not necessarily local_user() - can't test on my test site so moving into production and I'll debug it there. --- include/Contact.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 245682454..466d7f606 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -43,6 +43,8 @@ function channelx_by_n($id) { function vcard_from_xchan($xchan, $observer = null, $mode = '') { + $a = get_app(); + $connect = false; if(local_user()) { $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", @@ -53,6 +55,9 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { $connect = t('Connect'); } + if(array_key_exists('channel_id',$xchan)) + $a->profile_uid = $xchan['channel_id']; + $url = (($observer) ? z_root() . '/magic?f=&dest=' . $xchan['xchan_url'] . '&addr=' . $xchan['xchan_addr'] : $xchan['xchan_url'] -- cgit v1.2.3 From 68d907803a4521d9f0c0b69c4e875864f9058a8d Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 4 Aug 2013 17:17:00 -0700 Subject: basic *account* removal, but the channel removal which it calls still needs (lots of) work. Oh and the intro table is no longer used and won't be - so it's gone. --- include/Contact.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 466d7f606..109c345c1 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -115,6 +115,49 @@ function user_remove($uid) { } +function account_remove($account_id) { + + if(! intval($account_id)) { + logger('account_remove: no account.'); + return false; + } + + // Don't let anybody nuke the only admin account. + + $r = q("select account_id from account where (account_roles & %d)", + intval(ACCOUNT_ROLE_ADMIN) + ); + + if($r !== false && count($r) == 1 && $r[0]['account_id'] == $account_id) { + logger("Unable to remove the only remaining admin account"); + return false; + } + + $r = q("select * from account where account_id = %d limit 1", + intval($account_id) + ); + + if(! $r) { + logger('account_remove: No account with id: ' . $account_id); + return false; + } + + $x = q("select channel_id from channel where channel_account_id = %d", + intval($account_id) + ); + if($x) { + foreach($x as $xx) { + channel_remove($xx['channel_id']); + } + } + + $r = q("delete from account where account_id = %d limit 1", + intval($account_id) + ); + + return $r; + +} function channel_remove($channel_id) { -- cgit v1.2.3 From ad36ccdbc802bbf4d8bcce8754ae3a1ca63bcbfc Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 4 Aug 2013 19:09:53 -0700 Subject: progress on unfriending --- include/Contact.php | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 109c345c1..7e6c65ac1 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -263,8 +263,6 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) { } - - function contact_remove($channel_id, $abook_id) { if((! $channel_id) || (! $abook_id)) @@ -293,31 +291,37 @@ function contact_remove($channel_id, $abook_id) { if($abook['abook_flags'] & ABOOK_FLAG_SELF) return false; - q("delete from item where author_xchan = '%s' and uid = %d", + + $r = q("select * from item where author_xchan = '%s' and uid = %d", dbesc($abook['abook_xchan']), intval($channel_id) ); + if($r) { + foreach($r as $rr) { + drop_item($rr,false); + } + } q("delete from abook where abook_id = %d and abook_channel = %d limit 1", intval($abook['abook_id']), intval($channel_id) ); -/* -// FIXME - q("DELETE FROM `photo` WHERE `contact-id` = %d ", - intval($id) - ); - q("DELETE FROM `mail` WHERE `contact-id` = %d ", - intval($id) + $r = q("delete from event where event_xchan = '%s' and uid = %d", + dbesc($abook['abook_xchan']), + intval($channel_id) ); - q("DELETE FROM `event` WHERE `cid` = %d ", - intval($id) + + $r = q("delete from group_member where xchan = '%s' and uid = %d", + dbesc($abook['abook_xchan']), + intval($channel_id) ); - q("DELETE FROM `queue` WHERE `cid` = %d ", - intval($id) + + $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' ) and uid = %d ", + dbesc($abook['abook_xchan']), + dbesc($abook['abook_xchan']), + intval($channel_id) ); -*/ return true; } -- cgit v1.2.3 From c965ed2bb620d12873fdf13aea13d18f12dba063 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 5 Aug 2013 17:32:33 -0700 Subject: enotify: localize things we know how to translate --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 7e6c65ac1..b9ad1e4cb 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -317,7 +317,7 @@ function contact_remove($channel_id, $abook_id) { intval($channel_id) ); - $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' ) and uid = %d ", + $r = q("delete from mail where ( from_xchan = '%s' or to_xchan = '%s' ) and channel_id = %d ", dbesc($abook['abook_xchan']), dbesc($abook['abook_xchan']), intval($channel_id) -- cgit v1.2.3 From b9a8b73392afc6e460073ac6305da24623de5b49 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 13 Aug 2013 02:06:05 -0700 Subject: untested patch for issue #58 - will require theming if it works --- include/Contact.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index b9ad1e4cb..6b0ffe4f7 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -1,6 +1,24 @@ Date: Tue, 13 Aug 2013 02:29:10 -0700 Subject: debugging issue #58 - seems to work but needs (more) theming --- include/Contact.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 6b0ffe4f7..992ed27e2 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -3,20 +3,27 @@ function rconnect_url($channel_id,$xchan) { + if(! $xchan) return ''; - $r = q("select abook_id from abook where abook_channel_id = %d and abook_xchan = '%s' limit 1", + + $r = q("select abook_id from abook where abook_channel = %d and abook_xchan = '%s' limit 1", intval($channel_id), dbesc($xchan) ); + if($r) return ''; - $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and (hubloc_flags & HUBLOC_FLAGS_PRIMARY) limit 1", - dbesc($xchan) + + $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) limit 1", + dbesc($xchan), + intval(HUBLOC_FLAGS_PRIMARY) ); + if($r) return $r[0]['hubloc_url']; return ''; + } function abook_connections($channel_id, $sql_conditions = '') { -- cgit v1.2.3 From 764e0201ce8259c84a3b6ce643a52effe9dc8a59 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 15 Aug 2013 17:43:19 -0700 Subject: don't include archived contacts in public posts, unless specifically requested --- include/Contact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 992ed27e2..bf536ccd5 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -295,8 +295,8 @@ function contact_remove($channel_id, $abook_id) { $archive = get_pconfig($channel_id, 'system','archive_removed_contacts'); if($archive) { - q("update abook set abook_flags = abook_flags | %d where abook_id = %d and abook_channel = %d limit 1", - intval(ABOOK_FLAG_ARCHIVE), + q("update abook set abook_flags = ( abook_flags | %d ) where abook_id = %d and abook_channel = %d limit 1", + intval(ABOOK_FLAG_ARCHIVED), intval($abook_id), intval($channel_id) ); -- cgit v1.2.3 From 925b046794b77345c1321a3c74e4561d5c10ec95 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 21 Aug 2013 22:10:08 -0700 Subject: premium/restricted channel connections implemented, configure at yoursite/channel/nickname - this basically redirects "follow" requests to a premium channel's sell page if it has one configured. You can still click through and create a connection request (introduction), but this provides a means for the channel owner to state their terms. If you don't abide by the terms, you will likely be blocked or the channel deleted. This facility is extensible in a number of ways. --- include/Contact.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index bf536ccd5..46d356f3f 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -15,13 +15,20 @@ function rconnect_url($channel_id,$xchan) { if($r) return ''; + $r = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($xchan) + ); + + if(($r) && ($r[0]['xchan_follow'])) + return $r[0]['xchan_follow']; + $r = q("select hubloc_url from hubloc where hubloc_hash = '%s' and ( hubloc_flags & %d ) limit 1", dbesc($xchan), intval(HUBLOC_FLAGS_PRIMARY) ); if($r) - return $r[0]['hubloc_url']; + return $r[0]['hubloc_url'] . '/follow?f=&url=%s'; return ''; } -- cgit v1.2.3 From ff2ada207a7c90f095d1fad1513440eb08d3840a Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 17 Sep 2013 20:50:09 -0700 Subject: Pieces we'll need to tie together chanman and account/channel deletion and directory sync. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. Please do not mess with any of this. OK? Understood? --- include/Contact.php | 59 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 44 insertions(+), 15 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 46d356f3f..b9e879bcf 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -147,7 +147,9 @@ function user_remove($uid) { } -function account_remove($account_id) { +function account_remove($account_id,$local = true) { + + logger('account_remove: ' . $account_id); if(! intval($account_id)) { logger('account_remove: no account.'); @@ -179,7 +181,7 @@ function account_remove($account_id) { ); if($x) { foreach($x as $xx) { - channel_remove($xx['channel_id']); + channel_remove($xx['channel_id'],$local); } } @@ -191,7 +193,7 @@ function account_remove($account_id) { } -function channel_remove($channel_id) { +function channel_remove($channel_id, $local = true) { if(! $channel_id) return; @@ -199,13 +201,38 @@ function channel_remove($channel_id) { logger('Removing channel: ' . $channel_id); $r = q("select * from channel where channel_id = %d limit 1", intval($channel_id)); + if(! $r) { + logger('channel_remove: channel not found: ' . $channel_id); + return; + } + + $channel = $r[0]; call_hooks('channel_remove',$r[0]); + if(! $local) { + // FIXME notify the directory // FIXME notify all contacts + $r = q("update channel set 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, + channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0, + channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0 where channel_id = %d limit 1", + intval(PAGE_REMOVED), + intval($channel_id) + ); + + $r = q("update hubloc set hubloc_flags = hubloc_flags | %d where hubloc_hash = '%s'", + intval(HUBLOC_FLAGS_DELETED), + dbesc($channel['channel_hash']) + ); + + proc_run('php','include/notifier.php','purge_all',$channel_id); + + + } q("DELETE FROM `group` WHERE `uid` = %d", intval($channel_id)); q("DELETE FROM `group_member` WHERE `uid` = %d", intval($channel_id)); @@ -278,18 +305,20 @@ function remove_all_xchan_resources($xchan, $channel_id = 0) { ); - $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) - ); +// 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) +// ); } } -- cgit v1.2.3 From dffce63662c54db7ebb61786d39db6a900d1381f Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 30 Sep 2013 21:49:26 -0700 Subject: implement republish permission for use in sourced channels --- include/Contact.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index b9e879bcf..46c84aab6 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -219,7 +219,8 @@ function channel_remove($channel_id, $local = true) { $r = q("update channel set 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, channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0, - channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0 where channel_id = %d limit 1", + channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0, channel_a_republish = 0 + where channel_id = %d limit 1", intval(PAGE_REMOVED), intval($channel_id) ); -- cgit v1.2.3 From 5b3adf7755f7bd648c97969ec8b0183797bb2722 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 5 Nov 2013 17:43:32 -0800 Subject: more work on channel removal - it might sort of work now but I'm expecting lots of issues. Hence there is still no code in chanman to start the process rolling and make it happen. Will need a barrage of test cases. --- include/Contact.php | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 46c84aab6..de4ac6ff7 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -216,11 +216,12 @@ function channel_remove($channel_id, $local = true) { // FIXME notify all contacts - $r = q("update channel set channel_pageflags = (channel_pageflags | %d), channel_r_stream = 0, channel_r_profile = 0, + $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, channel_w_comment = 0, channel_w_mail = 0, channel_w_photos = 0, channel_w_chat = 0, channel_a_delegate = 0, channel_r_storage = 0, channel_w_storage = 0, channel_r_pages = 0, channel_w_pages = 0, channel_a_republish = 0 where channel_id = %d limit 1", + dbesc(datetime_convert()), intval(PAGE_REMOVED), intval($channel_id) ); @@ -230,6 +231,11 @@ function channel_remove($channel_id, $local = true) { dbesc($channel['channel_hash']) ); + $r = q("update xchan set xchan_flags = xchan_flags | %d where xchan_hash = '%s'", + intval(XCHAN_FLAGS_DELETED), + dbesc($channel['channel_hash']) + ); + proc_run('php','include/notifier.php','purge_all',$channel_id); @@ -248,13 +254,25 @@ 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)); - // 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", + $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), intval($channel_id) ); + $r = q("update hubloc set hubloc_flags = hubloc_flags | %d where hubloc_hash = '%s' and hubloc_url = '%s' ", + intval(HUBLOC_FLAGS_DELETED), + dbesc($channel['channel_hash']), + dbesc(z_root()) + ); + + $r = q("update xchan set xchan_flags = xchan_flags | %d where xchan_hash = '%s' ", + intval(XCHAN_FLAGS_DELETED), + dbesc($channel['channel_hash']) + ); + + + proc_run('php','include/directory.php',$channel_id); if($channel_id == local_user()) { unset($_SESSION['authenticated']); -- cgit v1.2.3 From b26989bb65615f7827047f87b3c4490f45b1f3e1 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 12 Nov 2013 18:27:36 -0800 Subject: removeme sort of works for a single channel - lots of loose ends to deal with but it's a start --- include/Contact.php | 58 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 22 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index de4ac6ff7..fcc5019e7 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -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) + ); + } } } -- cgit v1.2.3 From d9f67876dce5da9ed056726f792e087d142699cb Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 2 Dec 2013 15:15:02 -0800 Subject: refactor magic-auth --- include/Contact.php | 79 ----------------------------------------------------- 1 file changed, 79 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index fcc5019e7..5725e06f0 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -489,62 +489,6 @@ function unmark_for_death($contact) { ); }} -if(! function_exists('contact_photo_menu')){ -function contact_photo_menu($contact) { - - $a = get_app(); - - $contact_url=""; - $pm_url=""; - $status_link=""; - $photos_link=""; - $posts_link=""; - $poke_link=""; - - $sparkle = false; - if($contact['xchan_network'] === NETWORK_ZOT) { - $sparkle = true; - $profile_link = $a->get_baseurl() . '/magic?f=&id=' . $contact['abook_id']; - } - else - $profile_link = $contact['xchan_url']; - - if($sparkle) { - $status_link = $profile_link . "&url=status"; - $photos_link = $profile_link . "&url=photos"; - $profile_link = $profile_link . "&url=profile"; - $pm_url = $a->get_baseurl() . '/message/new/' . $contact['xchan_hash']; - } - - $poke_link = $a->get_baseurl() . '/poke/?f=&c=' . $contact['abook_id']; - $contact_url = $a->get_baseurl() . '/connections/' . $contact['abook_id']; - $posts_link = $a->get_baseurl() . '/network/?cid=' . $contact['abook_id']; - - $menu = Array( - t("Poke") => $poke_link, - t("View Status") => $status_link, - t("View Profile") => $profile_link, - t("View Photos") => $photos_link, - t("Network Posts") => $posts_link, - t("Edit Contact") => $contact_url, - t("Send PM") => $pm_url, - ); - - - $args = array('contact' => $contact, 'menu' => &$menu); - - call_hooks('contact_photo_menu', $args); - - $o = ""; - foreach($menu as $k=>$v){ - if ($v!="") { - $o .= "
  • $k
  • \n"; - } - } - return $o; -}} - - function random_profile() { $r = q("select xchan_url from xchan where 1 order by rand() limit 1"); if($r) @@ -553,26 +497,3 @@ function random_profile() { } -function contacts_not_grouped($uid,$start = 0,$count = 0) { - - if(! $count) { - $r = q("select count(*) as total from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) ", - intval($uid), - intval($uid) - ); - - return $r; - - - } - - $r = q("select * from contact where uid = %d and self = 0 and id not in (select distinct(`contact-id`) from group_member where uid = %d) and blocked = 0 and pending = 0 limit %d, %d", - intval($uid), - intval($uid), - intval($start), - intval($count) - ); - - return $r; -} - -- cgit v1.2.3 From 0215043826c2c036c3a2c88fa6e42089138c7c52 Mon Sep 17 00:00:00 2001 From: friendica Date: Fri, 13 Dec 2013 13:30:33 -0800 Subject: prepare for Comanchification of mod_photos --- include/Contact.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 5725e06f0..20dd04d17 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -77,6 +77,19 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { $a = get_app(); + if(! $xchan) { + if($a->profile['channel_hash']) + $r = q("select * from xchan where xchan_hash = '%s' limit 1", + dbesc($a->profile['channel_hash']) + ); + if($r) + $xchan = $r[0]; + } + + if(! $xchan) + return; + +// FIXME - show connect button to observer if appropriate $connect = false; if(local_user()) { $r = q("select * from abook where abook_xchan = '%s' and abook_channel = %d limit 1", -- cgit v1.2.3 From 825492407e3e064b6cd806b3ed7d484d2cc9f50e Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 19 Dec 2013 02:35:45 -0800 Subject: more comanche --- include/Contact.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 20dd04d17..59605e463 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -78,12 +78,16 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { $a = get_app(); if(! $xchan) { - if($a->profile['channel_hash']) + if($a->poi) { + $xchan = $a->poi; + } + elseif($a->profile['channel_hash']) { $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($a->profile['channel_hash']) ); if($r) $xchan = $r[0]; + } } if(! $xchan) -- cgit v1.2.3 From 1a42580ad44f768ba8d4eb0669f3b8be03670e04 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Dec 2013 18:37:39 -0800 Subject: remove a couple of mysql reserved words from being used as table or row names. For this round we're getting 'group' and 'desc'. Warning: potentially destabilising as this touches a lot of code. --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 59605e463..fd450033c 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -255,7 +255,7 @@ function channel_remove($channel_id, $local = true) { } - q("DELETE FROM `group` WHERE `uid` = %d", intval($channel_id)); + q("DELETE FROM `groups` 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)); -- cgit v1.2.3 From 655b6445d5f3354b0af3b9ee22b33be828499d41 Mon Sep 17 00:00:00 2001 From: friendica Date: Tue, 11 Feb 2014 19:51:43 -0800 Subject: use profile photo on vcard before reverting to xchan photo --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index fd450033c..2dab62fd8 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -114,7 +114,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { return replace_macros(get_markup_template('xchan_vcard.tpl'),array( '$name' => $xchan['xchan_name'], - '$photo' => $xchan['xchan_photo_l'], + '$photo' => ((array_key_exists('photo',$a->profile)) ? $a->profile['photo'] : $xchan['xchan_photo_l']), '$follow' => $xchan['xchan_addr'], '$connect' => $connect, '$newwin' => (($mode === 'chanview') ? t('New window') : ''), -- cgit v1.2.3 From 4944070e79d4914ba0503e6e90c194cbd766dc38 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Feb 2014 02:30:37 -0800 Subject: vsprintf error on update --- include/Contact.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 2dab62fd8..09f7925cb 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -81,7 +81,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { if($a->poi) { $xchan = $a->poi; } - elseif($a->profile['channel_hash']) { + elseif(is_array($a->profile) && $a->profile['channel_hash']) { $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($a->profile['channel_hash']) ); @@ -114,7 +114,7 @@ function vcard_from_xchan($xchan, $observer = null, $mode = '') { return replace_macros(get_markup_template('xchan_vcard.tpl'),array( '$name' => $xchan['xchan_name'], - '$photo' => ((array_key_exists('photo',$a->profile)) ? $a->profile['photo'] : $xchan['xchan_photo_l']), + '$photo' => ((is_array($a->profile) && array_key_exists('photo',$a->profile)) ? $a->profile['photo'] : $xchan['xchan_photo_l']), '$follow' => $xchan['xchan_addr'], '$connect' => $connect, '$newwin' => (($mode === 'chanview') ? t('New window') : ''), -- cgit v1.2.3 From e12f6f1bd93bb42bf0fe9fc9d9a1ff08cd162a0d Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Feb 2014 17:20:24 -0800 Subject: small changes to a couple of lookup functions which we need to use a bit more --- include/Contact.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 09f7925cb..9883c598d 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -52,24 +52,27 @@ 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' and not ( channel_pageflags & %d ) LIMIT 1", + $r = 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) ); + return(($r) ? $r[0] : false); } 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", + $r = 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) ); + return(($r) ? $r[0] : false); } 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", + $r = 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) ); + return(($r) ? $r[0] : false); } -- cgit v1.2.3 From 9f54a8f96b7664c82ab9228608970a7ce6bd41a9 Mon Sep 17 00:00:00 2001 From: sasiflo Date: Sun, 6 Apr 2014 00:34:52 +0200 Subject: Hope I have repaired the channel admin page. Channel blocking and deleting was copied from user actions. This was not done to an end. Hope what I do is enough to enable channel blocking and deleting the correct way. On deletion all entities that belong to the channel are deleted. But the channel itself is just marked as deleted. Do not really understand why it is done this way. --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 9883c598d..540e1169d 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -263,7 +263,7 @@ function channel_remove($channel_id, $local = true) { 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 `mail` WHERE `channel_id` = %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)); -- cgit v1.2.3 From 9fa929fab5c4c547951a0b42e7d56a94aea17564 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 25 May 2014 23:00:06 -0700 Subject: filter randprof results to avoid channels that are known to be deceased. --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 540e1169d..0cd4be72c 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -510,7 +510,7 @@ function unmark_for_death($contact) { }} function random_profile() { - $r = q("select xchan_url from xchan where 1 order by rand() limit 1"); + $r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > UTC_TIMESTAMP() - interval 30 day order by rand() limit 1"); if($r) return $r[0]['xchan_url']; return ''; -- cgit v1.2.3 From 2a6d7b6a079a565afc0200fe160cb2402ed7c0a3 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 28 May 2014 21:42:46 -0700 Subject: cleanup dead directory entries. This was a real b#tch, so keep your eye out for issues - which you shouldn't see until next weekend when this is scheduled to run. We're only setting flags, so if anything goes wrong we should be able to recover without too much pain. --- include/Contact.php | 84 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 66 insertions(+), 18 deletions(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 0cd4be72c..6e12652a5 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -141,24 +141,6 @@ function abook_toggle_flag($abook,$flag) { } - - - - - - - - - - - - - - - - - - // Included here for completeness, but this is a very dangerous operation. // It is the caller's responsibility to confirm the requestor's intent and // authorisation to do this. @@ -305,6 +287,72 @@ function channel_remove($channel_id, $local = true) { } +/** + * mark any hubs "offline" that haven't been heard from in more than 30 days + * Allow them to redeem themselves if they come back later. + * Then go through all those that are newly marked and see if any other hubs + * are attached to the controlling xchan that are still alive. + * If not, they're dead (although they could come back some day). + */ + + +function mark_orphan_hubsxchans() { + + $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d) + and hubloc_connected < utc_timestamp() - interval 30 day", + intval(HUBLOC_OFFLINE), + intval(HUBLOC_OFFLINE) + ); + + $r = q("select hubloc_id, hubloc_hash from hubloc where (hubloc_status & %d) and not (hubloc_flags & %d)", + intval(HUBLOC_OFFLINE), + intval(HUBLOC_FLAGS_ORPHANCHECK) + ); + + if($r) { + foreach($r as $rr) { + + // see if any other hublocs are still alive for this channel + + $x = q("select * from hubloc where hubloc_hash = '%s' and not (hubloc_status & %d)", + dbesc($rr['hubloc_hash']), + intval(HUBLOC_OFFLINE) + ); + if($x) { + + // yes - if the xchan was marked as an orphan, undo it + + $y = q("update xchan set xchan_flags = (xchan_flags ^ %d) where (xchan_flags & %d) and xchan_hash = '%s' limit 1", + intval(XCHAN_FLAGS_ORPHAN), + intval(XCHAN_FLAGS_ORPHAN), + dbesc($rr['hubloc_hash']) + ); + + } + else { + + // nope - mark the xchan as an orphan + + $y = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s' limit 1", + intval(XCHAN_FLAGS_ORPHAN), + dbesc($rr['hubloc_hash']) + ); + } + + // mark that we've checked this entry so we don't need to do it again + + $y = q("update hubloc set hubloc_flags = (hubloc_flags | %d) where hubloc_id = %d limit 1", + intval(HUBLOC_FLAGS_ORPHANCHECK), + dbesc($rr['hubloc_id']) + ); + } + } + +} + + + + function remove_all_xchan_resources($xchan, $channel_id = 0) { if(intval($channel_id)) { -- cgit v1.2.3 From 1a58777daa0ab9394f38737a806a7a185ebceeb0 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 29 May 2014 00:55:34 -0700 Subject: this is an important bit - only mark dead hubs on directory servers. They shouldn't matter anywhere else. --- include/Contact.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index 6e12652a5..b4583c358 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -298,6 +298,10 @@ function channel_remove($channel_id, $local = true) { function mark_orphan_hubsxchans() { + $dirmode = intval(get_config('system','directory_mode')); + if($dirmode == DIRECTORY_MODE_NORMAL) + return; + $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d) and hubloc_connected < utc_timestamp() - interval 30 day", intval(HUBLOC_OFFLINE), -- cgit v1.2.3 From a84d2d0731c2b4014744f130c1af45de0dde764d Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 1 Jun 2014 17:22:04 -0700 Subject: add a few days of slop to the orphan finder to account for any lags in dir syncing. --- include/Contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index b4583c358..ffee5096a 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -303,7 +303,7 @@ function mark_orphan_hubsxchans() { return; $r = q("update hubloc set hubloc_status = (hubloc_status | %d) where not (hubloc_status & %d) - and hubloc_connected < utc_timestamp() - interval 30 day", + and hubloc_connected < utc_timestamp() - interval 36 day", intval(HUBLOC_OFFLINE), intval(HUBLOC_OFFLINE) ); -- cgit v1.2.3 From 88bb3c9ddb3bd1cd13ba91efb6124c214ebbe861 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 18 Jun 2014 18:29:04 -0700 Subject: reset timestamps when unarchiving a connection --- include/Contact.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include/Contact.php') diff --git a/include/Contact.php b/include/Contact.php index ffee5096a..787612c83 100644 --- a/include/Contact.php +++ b/include/Contact.php @@ -133,6 +133,19 @@ function abook_toggle_flag($abook,$flag) { intval($abook['abook_id']), intval($abook['abook_channel']) ); + + // if unsetting the archive bit, update the timestamps so we'll try to connect for an additional 30 days. + + if(($flag === ABOOK_FLAG_ARCHIVED) && ($abook['abook_flags'] & ABOOK_FLAG_ARCHIVED)) { + $r = q("update abook set abook_connected = '%s', abook_updated = '%s' + where abook_id = %d and abook_channel = %d limit 1", + dbesc(datetime_convert()), + dbesc(datetime_convert()), + intval($abook['abook_id']), + intval($abook['abook_channel']) + ); + } + $a = get_app(); if($a->data['abook']) $a->data['abook']['abook_flags'] = $a->data['abook']['abook_flags'] ^ $flag; -- cgit v1.2.3