Open ximex opened 7 years ago
Also thought about this longer time ago. The question was for me how to realize a plugin manager. It should be easy for people with less knowledge. Just copy the plugin to folder an Admidio detects the new Plugin and handles install/uninstall in the system settings. The plugin will be added to the component table and store plugins config variables also .... therefor the plugins must follow a strict structure for its variables to be taken to the prederences. E.g. it must provide an config.xml wirh all parameters. \<Author>, \<Pluginname>, \<Version> ... Also all config parameters: \<param> , \<type>, \<defaultValue> ... The parameters table should be stored by our backup script .... Just as idea ... Sounds great for me
Updated my implementation above.
Possible "default config" with overriding this: (This is my idea for a future Admidio config (v4.0); not a plugin; but it shows my idea)
$defaultConfig = array(
'database' => array(
'type' => 'mysql', // "mysql", "pgsql"
'host' => 'localhost',
'port' => null,
'username' => null,
'password' => null,
'database' => 'admidio',
'tablePrefix' => 'adm'
),
'passwordOptions' => array(
'hashAlgorithm' => 'DEFAULT', // "DEFAULT", "BCRYPT", "SHA512"
'minLength' => 8,
'minComplexity' => 1, // 0, 1, 2, 3, 4 => zxcvbn
'generateLength' => 16,
'generateChars' => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
),
'security' => array(
'authForUpdate' => true,
'forceHTTPS' => false,
'secureProxy' => null
),
'timezone' => 'Europe/Berlin', // TODO: null?
'organization' => null, // TODO: necessary?
'debug' => false,
'logging' => array(
'level' => 'WARNING',
'maxFiles' => 0,
'path' => null
)
);
$config = array_replace($defaultConfig, $newConfig);
Other idea for saving a custom config in the database is to use "namespaced keys" like:
key | value | type |
---|---|---|
database.type | mysql | string |
database.host | localhost | string |
plugins.login_form.password.minlength | 8 | int |
plugins.xyz.list | 1,3,6,9 | int[] |
... | .... |
So it is possible to map this entries to an config array for above like:
$newConfig = array(
'database' => array(
'type' => 'mysql',
'host' => 'localhost'
),
'plugins' => array(
'login_form' => array(
'password' => array(
'minlength' => 8
)
),
'xyz' => array(
'list' => array(1, 3, 6, 9)
)
)
);
The problem with the value type could be solved with another type column in the database with: bool, int, float, string, bool[], int[], float[], string[]
Please give feedback
Personally I would prefer the second way, but it definitly depends on our requirements how the Plugin Manager should look like. The first way with overwriting the default config is still ok, if the plugins are customized handish in the config files. In my point of view we should drop this and make it more easier handling in the admin preferencens GUI. The modules are already customizable there. Also installed plugins should be moved to this tool. Therefor the plugins must follow a strict architectural guideline and must provide an idoc file with all elemantary data and config of parameters. Doing so, the paramaeters must be handled in the database ( 2. way). This would be managed by an installer/uninstaller. The GUI makes it costumizable on Admidio surface. No needs to use editors the config files anymore. This would be a proper way in my point of view. Maybe we should create a new Project on Git and discuss and work step by step? May be it is a good idea to create an UML of the planned Software architecture of the planned Manager ...
For a better handling we should define how a plugin should look like. I have coded some first ideas. But i think we shouldn't make all static. And we need a better config handling
PluginManager.php
iPlugin.php
AbstractPlugin.php
LoginFormPlugin.php