aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xboot.php2
-rw-r--r--include/Contact.php43
-rw-r--r--install/database.sql22
-rw-r--r--install/update.php9
4 files changed, 52 insertions, 24 deletions
diff --git a/boot.php b/boot.php
index 3af47afe8..de1c640a6 100755
--- a/boot.php
+++ b/boot.php
@@ -43,7 +43,7 @@ require_once('include/taxonomy.php');
define ( 'RED_PLATFORM', 'Red Matrix' );
define ( 'RED_VERSION', trim(file_get_contents('version.inc')) . 'R');
define ( 'ZOT_REVISION', 1 );
-define ( 'DB_UPDATE_VERSION', 1057 );
+define ( 'DB_UPDATE_VERSION', 1058 );
define ( 'EOL', '<br />' . "\r\n" );
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
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) {
diff --git a/install/database.sql b/install/database.sql
index 0c4b868d2..cd1c72ac6 100644
--- a/install/database.sql
+++ b/install/database.sql
@@ -386,28 +386,6 @@ CREATE TABLE IF NOT EXISTS `hubloc` (
KEY `hubloc_connected` (`hubloc_connected`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-CREATE TABLE IF NOT EXISTS `intro` (
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `uid` int(10) unsigned NOT NULL,
- `fid` int(11) NOT NULL DEFAULT '0',
- `contact-id` int(11) NOT NULL,
- `knowyou` tinyint(1) NOT NULL,
- `duplex` tinyint(1) NOT NULL DEFAULT '0',
- `note` text NOT NULL,
- `hash` char(255) NOT NULL,
- `datetime` datetime NOT NULL,
- `blocked` tinyint(1) NOT NULL DEFAULT '1',
- `ignore` tinyint(1) NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`),
- KEY `uid` (`uid`),
- KEY `fid` (`fid`),
- KEY `hash` (`hash`),
- KEY `datetime` (`datetime`),
- KEY `blocked` (`blocked`),
- KEY `ignore` (`ignore`),
- KEY `contact-id` (`contact-id`)
-) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-
CREATE TABLE IF NOT EXISTS `issue` (
`issue_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`issue_created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
diff --git a/install/update.php b/install/update.php
index f953e3f09..c09bc9d64 100644
--- a/install/update.php
+++ b/install/update.php
@@ -1,6 +1,6 @@
<?php
-define( 'UPDATE_VERSION' , 1057 );
+define( 'UPDATE_VERSION' , 1058 );
/**
*
@@ -663,3 +663,10 @@ ADD INDEX ( `xchan_instance_url` ) ");
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
+
+function update_r1057() {
+ $r = q("drop table intro");
+ if($r)
+ return UPDATE_SUCCESS;
+ return UPDATE_FAILED;
+}