summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2011-09-22 00:40:54 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2011-09-22 00:40:54 -0400
commit7845f0a8a6e0a36303e0fb4c954ada9925b166a3 (patch)
treeffdaf84727556534b2e75afb0def1e204b17b33c
parent1b8489fdd7af9b397576773f4b657ab99ebc278d (diff)
Finally get around to implementing deleting users. (status=4)
-rw-r--r--src/controllers/Users.class.php34
-rw-r--r--src/models/Auth.class.php21
2 files changed, 32 insertions, 23 deletions
diff --git a/src/controllers/Users.class.php b/src/controllers/Users.class.php
index dc89603..d799760 100644
--- a/src/controllers/Users.class.php
+++ b/src/controllers/Users.class.php
@@ -201,17 +201,13 @@ class Users extends Controller {
$config_options = array();
global $mm;
$mm->pluginManager()->callHook('userConfig', &$config_options);
-
+
foreach ($config_options as $group=>$options) {
foreach ($options as $option) {
$this->confText($user, $option[0]);
}
}
- /*
- $this->confText($user, 'firstname');
- $this->confText($user, 'lastname');
- $this->confText($user, 'hsclass');
- */
+
// Change contact info /////////////////////////////////////////
global $CONTACT_METHODS;
foreach ($CONTACT_METHODS as $method) {
@@ -300,6 +296,10 @@ class Users extends Controller {
$editable = $editable && $logged_in_user->isAdmin();
$value = $user->isAdmin();
break;
+ case 'auth_delete':
+ $editable = $editable && $logged_in_user->isAdmin();
+ $value = false;
+ break;
default:
$value = $user->getConf($key);
if ($value===false) $value='';
@@ -325,6 +325,8 @@ class Users extends Controller {
case 'auth_admin':
$user->setAdmin($value=='true');
break;
+ case 'auth_delete':
+ if ($value=='true') $user->delete();
default:
$user->setConf($key, $value);
break;
@@ -335,14 +337,18 @@ class Users extends Controller {
return array('key'=>$key, 'name'=>$name);
}
private function getIndexAttribs() {
- $attribs = array($this->attrib('auth_user', 'Active'),
- $this->attrib('lastname','Last'),
- $this->attrib('firstname','First'),
- $this->attrib('hsclass','Class of'),
- $this->attrib('phone','Phone number'),
- $this->attrib('email','Email'),
- $this->attrib('auth_name', 'Username'),
- );
+ $attribs = array();
+ $attribs[] = $this->attrib('auth_user', 'Active');
+ if (Auth::getObj(Login::isLoggedIn())->isAdmin()) {
+ $attribs[] = $this->attrib('auth_admin', 'Admin');
+ $attribs[] = $this->attrib('auth_delete', 'Delete');
+ }
+ $attribs[] = $this->attrib('lastname','Last');
+ $attribs[] = $this->attrib('firstname','First');
+ $attribs[] = $this->attrib('hsclass','Class of');
+ $attribs[] = $this->attrib('phone','Phone number');
+ $attribs[] = $this->attrib('email','Email');
+ $attribs[] = $this->attrib('auth_name', 'Username');
return $attribs;
}
}
diff --git a/src/models/Auth.class.php b/src/models/Auth.class.php
index f2c9120..975c25f 100644
--- a/src/models/Auth.class.php
+++ b/src/models/Auth.class.php
@@ -9,19 +9,19 @@ class Auth {
public static function getObj($uid) {
if (!isset(self::$users[$uid])) {
global $mm;
- $is_group = ($mm->database()->getStatus($uid)===3);
- if ($is_group) {
- require_once('Group.class.php');
- $obj = new Group($uid);
- } else {
- require_once('User.class.php');
- $obj = new User($uid);
+ $type = $mm->database()->getStatus($uid)<3;
+ switch ($type) {
+ case 0: // unactivated user
+ case 1: // user
+ case 2: $obj = new User($uid); // admin
+ case 3: $obj = new Group($uid);
+ case 4: $obj = new Auth($uid); // deleted
}
self::$users[$uid] = $obj;
}
return self::$users[$uid];
}
-
+
protected $db = null;
protected $uid = false;
public function __construct($uid) {
@@ -39,7 +39,7 @@ class Auth {
// Row Type ////////////////////////////////////////////////////////////
/**
- * @return 0=unverified 1=user 2=admin 3=group
+ * @return 0=unverified 1=user 2=admin 3=group 4=deleted
*/
protected function getType() {
$type = $this->db->getStatus($this->uid);
@@ -75,6 +75,9 @@ class Auth {
$is_user = $this->isUser();
$this->setType($is_admin?2:($is_user?1:0));
}
+ public function delete() {
+ $this->setType(4);
+ }
// Permissions /////////////////////////////////////////////////////////
public function canRead() {