diff --git a/4dev/database/function/set_date.sql b/4dev/database/function/set_date.sql index 408688a1..13a51743 100644 --- a/4dev/database/function/set_date.sql +++ b/4dev/database/function/set_date.sql @@ -5,9 +5,9 @@ RETURNS TRIGGER AS $$ BEGIN IF TG_OP = 'INSERT' THEN - NEW.date_created := 'now'; + NEW.date_created := clock_timestamp(); ELSIF TG_OP = 'UPDATE' THEN - NEW.date_updated := 'now'; + NEW.date_updated := clock_timestamp(); END IF; RETURN NEW; END; diff --git a/4dev/database/function/set_edit_generic.sql b/4dev/database/function/set_edit_generic.sql index 4ec68683..be7519b9 100644 --- a/4dev/database/function/set_edit_generic.sql +++ b/4dev/database/function/set_edit_generic.sql @@ -7,11 +7,11 @@ DECLARE random_length INT = 25; -- that should be long enough BEGIN IF TG_OP = 'INSERT' THEN - NEW.date_created := 'now'; + NEW.date_created := clock_timestamp(); NEW.cuid := random_string(random_length); NEW.cuuid := gen_random_uuid(); ELSIF TG_OP = 'UPDATE' THEN - NEW.date_updated := 'now'; + NEW.date_updated := clock_timestamp(); END IF; RETURN NEW; END; diff --git a/4dev/database/function/set_generic_uid.sql b/4dev/database/function/set_generic_uid.sql index 71c27275..8ad24467 100644 --- a/4dev/database/function/set_generic_uid.sql +++ b/4dev/database/function/set_generic_uid.sql @@ -8,12 +8,12 @@ DECLARE random_length INT = 32; -- long for massive data BEGIN IF TG_OP = 'INSERT' THEN - NEW.date_created := 'now'; + NEW.date_created := clock_timestamp(); IF NEW.uid IS NULL THEN NEW.uid := random_string(random_length); END IF; ELSIF TG_OP = 'UPDATE' THEN - NEW.date_updated := 'now'; + NEW.date_updated := clock_timestamp(); END IF; RETURN NEW; END; diff --git a/4dev/database/function/update_function.sql b/4dev/database/function/update_function.sql deleted file mode 100644 index 80a3dccf..00000000 --- a/4dev/database/function/update_function.sql +++ /dev/null @@ -1,19 +0,0 @@ --- adds the created or updated date tags - --- OLD, DEPRECATED, use set_generic.sql - --- CREATE OR REPLACE FUNCTION set_generic() --- RETURNS TRIGGER AS --- $$ --- BEGIN --- IF TG_OP = 'INSERT' THEN --- NEW.date_created := clock_timestamp(); --- NEW.user_created := current_user; --- ELSIF TG_OP = 'UPDATE' THEN --- NEW.date_updated := clock_timestamp(); --- NEW.user_updated := current_user; --- END IF; --- RETURN NEW; --- END; --- $$ --- LANGUAGE 'plpgsql'; diff --git a/4dev/tests/ACL/database/CoreLibsACLLogin_database_create_data.sql b/4dev/tests/ACL/database/CoreLibsACLLogin_database_create_data.sql index e1d1a0cb..7caaf1c3 100644 --- a/4dev/tests/ACL/database/CoreLibsACLLogin_database_create_data.sql +++ b/4dev/tests/ACL/database/CoreLibsACLLogin_database_create_data.sql @@ -30,11 +30,11 @@ DECLARE random_length INT = 12; -- that should be long enough BEGIN IF TG_OP = 'INSERT' THEN - NEW.date_created := 'now'; + NEW.date_created := clock_timestamp(); NEW.cuid := random_string(random_length); NEW.cuuid := gen_random_uuid(); ELSIF TG_OP = 'UPDATE' THEN - NEW.date_updated := 'now'; + NEW.date_updated := clock_timestamp(); END IF; RETURN NEW; END; diff --git a/www/lib/CoreLibs/ACL/Login.php b/www/lib/CoreLibs/ACL/Login.php index 6fb11dd4..365f5e69 100644 --- a/www/lib/CoreLibs/ACL/Login.php +++ b/www/lib/CoreLibs/ACL/Login.php @@ -217,26 +217,6 @@ class Login 'path' => '', ]; - // lock status bitmap (smallint, 256) - /** @var int enabled flag */ - public const ENABLED = 1; - /** @var int deleted flag */ - public const DELETED = 2; - /** @var int locked flag */ - public const LOCKED = 4; - /** @var int banned/suspened flag [not implemented] */ - public const BANNED = 8; - /** @var int password reset in progress [not implemented] */ - public const RESET = 16; - /** @var int confirm/paending, eg waiting for confirm of email [not implemented] */ - public const CONFIRM = 32; - /** @var int strict, on error lock */ - public const STRICT = 64; - /** @var int proected, cannot delete */ - public const PROTECTED = 128; - /** @var int master admin flag */ - public const ADMIN = 256; - /** @var int resync interval time in minutes */ private const DEFAULT_AUTH_RESYNC_INTERVAL = 5 * 60; /** @var int the session max garbage collection life time */ diff --git a/www/lib/CoreLibs/ACL/LoginUserStatus.php b/www/lib/CoreLibs/ACL/LoginUserStatus.php new file mode 100644 index 00000000..fb791abb --- /dev/null +++ b/www/lib/CoreLibs/ACL/LoginUserStatus.php @@ -0,0 +1,68 @@ + + */ + public static function getMap() + { + return array_flip((new \ReflectionClass(static::class))->getConstants()); + } + + /** + * Returns the descriptive role names + * + * @return string[] + */ + public static function getNames() + { + + return array_keys((new \ReflectionClass(static::class))->getConstants()); + } + + /** + * Returns the numerical role values + * + * @return int[] + */ + public static function getValues() + { + return array_values((new \ReflectionClass(static::class))->getConstants()); + } +} + +// __END__