aboutsummaryrefslogtreecommitdiffstats
path: root/include/Contact.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-08-04 17:17:00 -0700
committerfriendica <info@friendica.com>2013-08-04 17:17:00 -0700
commit68d907803a4521d9f0c0b69c4e875864f9058a8d (patch)
treecebbd9d749974b87eb92c8fe5f468bb23c161eef /include/Contact.php
parent1b7b53f4093a6a2b277f2b85b0962adbf1fa759e (diff)
downloadvolse-hubzilla-68d907803a4521d9f0c0b69c4e875864f9058a8d.tar.gz
volse-hubzilla-68d907803a4521d9f0c0b69c4e875864f9058a8d.tar.bz2
volse-hubzilla-68d907803a4521d9f0c0b69c4e875864f9058a8d.zip
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.
Diffstat (limited to 'include/Contact.php')
-rw-r--r--include/Contact.php43
1 files changed, 43 insertions, 0 deletions
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) {