diff options
Diffstat (limited to 'models')
| -rw-r--r-- | models/user.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/models/user.php b/models/user.php index 9b76f37..1f58e7c 100644 --- a/models/user.php +++ b/models/user.php @@ -57,4 +57,30 @@ class User extends Table { include $VIEWS_DIR . '/img/user-star.svg'; } } + + private static $AnonUID = 1; + + function delete() { + // Applicable to Anon user + if ($this->Password === '') { + throw new Exception('Not deleting system account!'); + } + + Table::_update( + 'Webpages', + 'RequesterUID = "' . self::$AnonUID . '"', + "RequesterUID = \"$this->UID\"" + ); + + Table::_update( + 'ArchiveLists', + 'AuthorUID = "' . self::$AnonUID . '"', + "AuthorUID = \"$this->UID\"" + ); + + Table::_delete( + 'Users', + "UID = \"$this->UID\"" + ); + } } |
