Enable/Disable users
This commit is contained in:
@@ -40,6 +40,18 @@ class User extends Base
|
||||
return $this->db->table(self::TABLE)->eq('id', $user_id)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the user is active
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id User id
|
||||
* @return boolean
|
||||
*/
|
||||
public function isActive($user_id)
|
||||
{
|
||||
return $this->db->table(self::TABLE)->eq('id', $user_id)->eq('is_active', 1)->exists();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get query to fetch all users
|
||||
*
|
||||
@@ -193,9 +205,9 @@ class User extends Base
|
||||
* @param boolean $prepend Prepend "All users"
|
||||
* @return array
|
||||
*/
|
||||
public function getList($prepend = false)
|
||||
public function getActiveUsersList($prepend = false)
|
||||
{
|
||||
$users = $this->db->table(self::TABLE)->columns('id', 'username', 'name')->findAll();
|
||||
$users = $this->db->table(self::TABLE)->eq('is_active', 1)->columns('id', 'username', 'name')->findAll();
|
||||
$listing = $this->prepareList($users);
|
||||
|
||||
if ($prepend) {
|
||||
@@ -280,6 +292,30 @@ class User extends Base
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable a specific user
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function disable($user_id)
|
||||
{
|
||||
return $this->db->table(self::TABLE)->eq('id', $user_id)->update(array('is_active' => 0));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable a specific user
|
||||
*
|
||||
* @access public
|
||||
* @param integer $user_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function enable($user_id)
|
||||
{
|
||||
return $this->db->table(self::TABLE)->eq('id', $user_id)->update(array('is_active' => 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a specific user
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user