- updated to the new pikotools api (child spaces were removed)

some plugins need to be fixed yet: ticket, gallery, group, menu
- added current user to default models as "user"
- renamed in User: super_user -> is_super_user, env -> admin_env, pass_hash_salted -> is_pass_hash_salted
- now Users class has a WinixModel as a base class
  some plugin calls have to be fixed yet
- added UserWrapper model with a pointer to User class
- removed from ItemContent: methods for accessing 'meta' and 'admin_meta', now ezc can iterate through Space classes
- fixed in env winix function: if there is "changeuser" parameter then we should only switch the user (not save anything)
This commit is contained in:
2021-06-27 23:31:50 +02:00
parent 472490c239
commit 1d18b7fa12
59 changed files with 1419 additions and 1607 deletions

View File

@@ -53,22 +53,28 @@ User::User()
void User::fields()
{
field(L"id", id, morm::FT::no_insertable | morm::FT::no_updatable | morm::FT::primary_key);
field(L"login", name); // IMPROVEME set the same name, either 'login' or 'name'
field(L"super_user", super_user); // IMPROVEME rename to is_super_user
field(L"login", login);
field(L"is_super_user", is_super_user);
field(L"has_pass", has_pass);
field(L"pass_type", pass_type);
field(L"password", L"", password);
field(L"pass_encrypted", L"", pass_encrypted, morm::FT::binary);
field(L"pass_hash_salted", pass_hash_salted); // IMPROVEME rename to pass_is_hash_salted or is_pass_hash_salted
field(L"is_pass_hash_salted", is_pass_hash_salted);
field(L"email", email);
field(L"notify", notify);
field(L"env", env);
field(L"aenv", aenv); // IMPROVEME rename to admin_env
field(L"admin_env", admin_env);
field(L"status", status);
field(L"locale_id", locale_id);
field(L"time_zone_id", time_zone_id);
field(L"", L"id_is", &User::id_is);
field(L"", L"is_guest", &User::is_guest);
field(L"", L"is_env_object", &User::is_env_object);
field(L"", L"is_admin_env_object", &User::is_admin_env_object);
}
@@ -95,20 +101,20 @@ void User::after_insert()
void User::Clear()
{
id = -1;
name.clear();
super_user = false;
login.clear();
is_super_user = false;
groups.clear();
email.clear();
notify = 0;
env.clear();
aenv.clear();
admin_env.clear();
status = WINIX_ACCOUNT_BLOCKED;
locale_id = 0;
time_zone_id = 0;
has_pass = false;
pass_type = 0;
pass_hash_salted = false;
is_pass_hash_salted = false;
clear_passwords();
}
@@ -143,6 +149,7 @@ bool User::do_migration(int & current_table_version)
bool ok = true;
ok = ok && morm::Model::do_migration(current_table_version, 1, this, &User::do_migration_to_1);
ok = ok && morm::Model::do_migration(current_table_version, 2, this, &User::do_migration_to_2);
return ok;
}
@@ -160,11 +167,11 @@ bool User::do_migration_to_1()
email character varying(255),
notify integer,
pass_type integer,
pass_hash_salted boolean,
is_pass_hash_salted boolean,
pass_encrypted bytea,
super_user boolean,
is_super_user boolean,
env text,
aenv text,
admin_env text,
status integer,
locale_id integer,
time_zone_id integer,
@@ -177,18 +184,57 @@ bool User::do_migration_to_1()
}
bool User::do_migration_to_2()
{
const char * str[] = {
"alter table core.user rename column aenv to admin_env",
"alter table core.user rename column super_user to is_super_user",
"alter table core.user rename column pass_hash_salted to is_pass_hash_salted",
};
size_t len = sizeof(str) / sizeof(const char*);
return db_query(str, len);
}
void User::display_name(EzcEnv & env)
{
std::wstring * dname = aenv.get_wstr(L"display_name");
std::wstring * dname = admin_env.get_wstr(L"display_name");
if( dname && !IsWhite(*dname, true) )
env.out << *dname;
else
env.out << name;
env.out << login;
}
void User::id_is(EzcEnv & env)
{
if( !env.par.empty() )
{
long par_user_id = pt::Tol(env.par.c_str());
env.res = id == par_user_id;
}
}
bool User::is_guest()
{
return id == -1;
}
bool User::is_env_object()
{
return env.is_object();
}
bool User::is_admin_env_object()
{
return admin_env.is_object();
}
} // namespace Winix