/** * Config object for `Users_Feature`. * Copyright 2022 Anton Tarasenko *------------------------------------------------------------------------------ * This file is part of Acedia. * * Acedia is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3 of the License, or * (at your option) any later version. * * Acedia is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Acedia. If not, see . */ class Users extends FeatureConfig perobjectconfig config(AcediaUsers); var public config bool useDatabase; var public config string databaseLink; var public config array localUserGroup; protected function HashTable ToData() { local int i; local HashTable data; local ArrayList userGroupList; data = __().collections.EmptyHashTable(); data.SetBool(P("useDatabase"), useDatabase, false); data.SetString(P("databaseLink"), databaseLink); userGroupList = _.collections.EmptyArrayList(); for (i = 0; i < localUserGroup.length; i += 1) { userGroupList.AddString(localUserGroup[i]); } data.SetItem(P("userGroups"), userGroupList); userGroupList.FreeSelf(); return data; } protected function FromData(HashTable source) { local int i; local ArrayList userGroupList; if (source == none) { return; } useDatabase = source.GetBool(P("useDatabase")); databaseLink = source.GetString( P("databaseLink"), "[local]database:/users"); userGroupList = source.GetArrayList(P("userGroups")); localUserGroup.length = 0; if (userGroupList == none) { return; } for (i = 0; i < userGroupList.GetLength(); i += 1) { localUserGroup[localUserGroup.length] = userGroupList.GetString(i); } userGroupList.FreeSelf(); } protected function DefaultIt() { useDatabase = false; databaseLink = "[local]database:/users"; localUserGroup.length = 0; localUserGroup[0] = "admin"; localUserGroup[1] = "moderator"; localUserGroup[2] = "trusted"; } defaultproperties { configName = "AcediaUsers" useDatabase = false databaseLink = "[local]database:/users" localUserGroup(0) = "admin" localUserGroup(1) = "moderator" localUserGroup(2) = "trusted" }