diff --git a/.env b/.env index 6ec8976..2b87a06 100644 --- a/.env +++ b/.env @@ -14,6 +14,9 @@ migrations.enabled = true aauth.dbProfile = 'tests' aauth.loginRemember = '-1 day' +aauth.dbSoftDeleteUsers = true +aauth.dbSoftDeleteGroups = true +aauth.dbSoftDeletePerms = true #-------------------------------------------------------------------- # APP diff --git a/app/Config/Aauth.php b/app/Config/Aauth.php index 2708eaa..391ea6d 100644 --- a/app/Config/Aauth.php +++ b/app/Config/Aauth.php @@ -341,6 +341,24 @@ class Aauth extends BaseConfig | | The table which contains permissions for groups | (default: 'aauth_perm_to_group') + | + | 'dbSoftDeleteUsers' + | + | Enables soft delete for Users + | If this is enabled, it simply set a flag when rows are deleted. + | (default: false) + | + | 'dbSoftDeleteGroups' + | + | Enables soft delete for Groups + | If this is enabled, it simply set a flag when rows are deleted. + | (default: false) + | + | 'dbSoftDeletePerms' + | + | Enables soft delete for Perms + | If this is enabled, it simply set a flag when rows are deleted. + | (default: false) */ public $dbProfile = 'default'; public $dbTableUsers = 'aauth_users'; @@ -353,4 +371,7 @@ class Aauth extends BaseConfig public $dbTablePerms = 'aauth_perms'; public $dbTablePermToUser = 'aauth_perm_to_user'; public $dbTablePermToGroup = 'aauth_perm_to_group'; + public $dbSoftDeleteUsers = true; + public $dbSoftDeleteGroups = true; + public $dbSoftDeletePerms = true; } diff --git a/app/Models/Aauth/GroupModel.php b/app/Models/Aauth/GroupModel.php index c72826e..3cc3ebb 100644 --- a/app/Models/Aauth/GroupModel.php +++ b/app/Models/Aauth/GroupModel.php @@ -29,15 +29,6 @@ use Config\Aauth as AauthConfig; */ class GroupModel extends Model { - /** - * If this model should use "softDeletes" and - * simply set a flag when rows are deleted, or - * do hard deletes. - * - * @var boolean - */ - protected $useSoftDeletes = true; - /** * If true, will set created_at, and updated_at * values during insert and update routines. @@ -60,12 +51,19 @@ class GroupModel extends Model /** * Constructor */ - public function __construct() + public function __construct($db = null, $validation = null, $config = null) { parent::__construct(); - $this->config = new AauthConfig(); - $this->table = $this->config->dbTableGroups; - $this->DBGroup = $this->config->dbProfile; + + if (is_null($config)) + { + $config = new AauthConfig(); + } + + $this->config = $config; + $this->table = $this->config->dbTableGroups; + $this->DBGroup = $this->config->dbProfile; + $this->tempUseSoftDeletes = $this->config->dbSoftDeleteGroups; $this->validationRules['name'] = 'required|is_unique[' . $this->table . '.name,id,{id}]'; diff --git a/app/Models/Aauth/PermModel.php b/app/Models/Aauth/PermModel.php index 10f3dee..a8f85c0 100644 --- a/app/Models/Aauth/PermModel.php +++ b/app/Models/Aauth/PermModel.php @@ -29,15 +29,6 @@ use Config\Aauth as AauthConfig; */ class PermModel extends Model { - /** - * If this model should use "softDeletes" and - * simply set a flag when rows are deleted, or - * do hard deletes. - * - * @var boolean - */ - protected $useSoftDeletes = true; - /** * If true, will set created_at, and updated_at * values during insert and update routines. @@ -60,12 +51,19 @@ class PermModel extends Model /** * Constructor */ - public function __construct() + public function __construct($db = null, $validation = null, $config = null) { parent::__construct(); - $this->config = new AauthConfig(); - $this->table = $this->config->dbTablePerms; - $this->DBGroup = $this->config->dbProfile; + + if (is_null($config)) + { + $config = new AauthConfig(); + } + + $this->config = $config; + $this->table = $this->config->dbTablePerms; + $this->DBGroup = $this->config->dbProfile; + $this->tempUseSoftDeletes = $this->config->dbSoftDeletePerms; $this->validationRules['name'] = 'required|is_unique[' . $this->table . '.name,id,{id}]'; diff --git a/app/Models/Aauth/UserModel.php b/app/Models/Aauth/UserModel.php index d01d3d2..a4bc588 100644 --- a/app/Models/Aauth/UserModel.php +++ b/app/Models/Aauth/UserModel.php @@ -29,15 +29,6 @@ use Config\Aauth as AauthConfig; */ class UserModel extends Model { - /** - * If this model should use "softDeletes" and - * simply set a flag when rows are deleted, or - * do hard deletes. - * - * @var boolean - */ - protected $useSoftDeletes = true; - /** * If true, will set created_at, and updated_at * values during insert and update routines. @@ -94,9 +85,10 @@ class UserModel extends Model $config = new AauthConfig(); } - $this->config = $config; - $this->table = $this->config->dbTableUsers; - $this->DBGroup = $this->config->dbProfile; + $this->config = $config; + $this->table = $this->config->dbTableUsers; + $this->DBGroup = $this->config->dbProfile; + $this->tempUseSoftDeletes = $this->config->dbSoftDeleteGroups; $this->validationRules['email'] = 'required|valid_email|is_unique[' . $this->table . '.email]'; $this->validationRules['password'] = 'required|min_length[' . $this->config->passwordMin . ']|max_length[' . $this->config->passwordMax . ']';