Adds option to add more field paths or rule paths to both module or plugin forms.

This commit is contained in:
2022-02-04 12:50:24 +02:00
parent e8b0bf8ede
commit 2ce36117d4
8 changed files with 259 additions and 36 deletions

View File

@ -9389,6 +9389,8 @@ class Get
$module->form_files = array();
$module->fieldsets_label = array();
$module->fieldsets_paths = array();
$module->add_rule_path = array();
$module->add_field_path = array();
// set global fields rule to default component path
$module->fields_rules_paths = 1;
// set the fields data
@ -9463,6 +9465,30 @@ class Get
// set where to path is pointing
$module->fieldsets_paths[$unique]
= $form['fields_rules_paths'];
// check for extra rule paths
if (isset($form['addrulepath'])
&& ComponentbuilderHelper::checkArray($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (ComponentbuilderHelper::checkString($add_rule_path['path']))
{
$module->add_rule_path[$unique][] = $add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ComponentbuilderHelper::checkArray($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (ComponentbuilderHelper::checkString($add_field_path['path']))
{
$module->add_field_path[$unique][] = $add_field_path['path'];
}
}
}
// add the label if set to lang
if (isset($form['label'])
&& ComponentbuilderHelper::checkString(
@ -10297,6 +10323,8 @@ class Get
$plugin->form_files = array();
$plugin->fieldsets_label = array();
$plugin->fieldsets_paths = array();
$plugin->add_rule_path = array();
$plugin->add_field_path = array();
// set global fields rule to default component path
$plugin->fields_rules_paths = 1;
// set the fields data
@ -10380,6 +10408,30 @@ class Get
$plugin->fieldsets_label[$unique]
= $this->setLang($form['label']);
}
// check for extra rule paths
if (isset($form['addrulepath'])
&& ComponentbuilderHelper::checkArray($form['addrulepath']))
{
foreach ($form['addrulepath'] as $add_rule_path)
{
if (ComponentbuilderHelper::checkString($add_rule_path['path']))
{
$plugin->add_rule_path[$unique][] = $add_rule_path['path'];
}
}
}
// check for extra field paths
if (isset($form['addfieldpath'])
&& ComponentbuilderHelper::checkArray($form['addfieldpath']))
{
foreach ($form['addfieldpath'] as $add_field_path)
{
if (ComponentbuilderHelper::checkString($add_field_path['path']))
{
$plugin->add_field_path[$unique][] = $add_field_path['path'];
}
}
}
// build the fields
$form['fields'] = array_map(
function ($field) use ($key, $unique) {

View File

@ -28572,31 +28572,57 @@ function vdm_dkim() {
&& $module->fieldsets_paths[$field_name . $fieldset]
== 2)
{
$xml .= PHP_EOL . $this->_t(1) . '<!--'
. $this->setLine(__LINE__) . ' default paths of '
. $fieldset . ' fieldset points to the module -->';
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '"';
if ($module->target == 2)
{
$xml .= PHP_EOL . $this->_t(2)
. 'addrulepath="/administrator/modules/'
. $module->file_name
. '/rules"';
$xml .= PHP_EOL . $this->_t(2)
. 'addfieldpath="/administrator/modules/'
. $module->file_name
. '/fields"';
$module->add_rule_path[$field_name . $fieldset][] =
'/administrator/modules/'
. $module->file_name . '/rules';
$module->add_field_path[$field_name . $fieldset][] =
'/administrator/modules/'
. $module->file_name . '/fields';
}
else
{
$xml .= PHP_EOL . $this->_t(2)
. 'addrulepath="/modules/' . $module->file_name
. '/rules"';
$xml .= PHP_EOL . $this->_t(2)
. 'addfieldpath="/modules/' . $module->file_name
. '/fields"';
$module->add_rule_path[$field_name . $fieldset][] =
'/modules/' . $module->file_name
. '/rules';
$module->add_field_path[$field_name . $fieldset][] =
'/modules/' . $module->file_name
. '/fields';
}
}
// add path to module rules and custom fields
if (isset($module->add_rule_path[$field_name . $fieldset])
|| isset($module->add_field_path[$field_name . $fieldset]))
{
$xml .= PHP_EOL . $this->_t(1) . '<!--'
. $this->setLine(__LINE__) . ' default paths of '
. $fieldset . ' fieldset points to the module -->';
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '"';
if (isset($module->add_rule_path[$field_name . $fieldset]))
{
foreach ($module->add_rule_path[$field_name . $fieldset] as $path)
{
$xml .= PHP_EOL . $this->_t(2)
. 'addrulepath="' . $path . '"';
}
}
if (isset($module->add_field_path[$field_name . $fieldset]))
{
foreach ($module->add_field_path[$field_name . $fieldset] as $path)
{
$xml .= PHP_EOL . $this->_t(2)
. 'addfieldpath="' . $path . '"';
}
}
$xml .= PHP_EOL . $this->_t(1) . '>';
}
else
@ -28931,26 +28957,51 @@ function vdm_dkim() {
$label = $plugin->fieldsets_label[$field_name
. $fieldset];
}
// add path to plugin rules and custom fields
if (isset($plugin->fieldsets_paths[$field_name . $fieldset])
&& $plugin->fieldsets_paths[$field_name . $fieldset]
== 2)
{
$plugin->add_rule_path[$field_name . $fieldset][] =
'/plugins/' . strtolower($plugin->group
) . '/' . strtolower($plugin->code_name)
. '/rules';
$plugin->add_field_path[$field_name . $fieldset][] =
'/plugins/' . strtolower($plugin->group
) . '/' . strtolower($plugin->code_name)
. '/fields';
}
// add path to plugin rules and custom fields
if (isset($plugin->add_rule_path[$field_name . $fieldset])
|| isset($plugin->add_field_path[$field_name . $fieldset]))
{
$xml .= PHP_EOL . $this->_t(1) . '<!--'
. $this->setLine(__LINE__) . ' default paths of '
. $fieldset . ' fieldset points to the plugin -->';
$xml .= PHP_EOL . $this->_t(1) . '<fieldset name="'
. $fieldset . '" label="' . $label . '"';
$xml .= PHP_EOL . $this->_t(2)
. 'addrulepath="/plugins/' . strtolower(
$plugin->group
) . '/' . strtolower($plugin->code_name)
. '/rules"';
$xml .= PHP_EOL . $this->_t(2)
. 'addfieldpath="/plugins/' . strtolower(
$plugin->group
) . '/' . strtolower($plugin->code_name)
. '/fields"';
if (isset($plugin->add_rule_path[$field_name . $fieldset]))
{
foreach ($plugin->add_rule_path[$field_name . $fieldset] as $path)
{
$xml .= PHP_EOL . $this->_t(2)
. 'addrulepath="' . $path . '"';
}
}
if (isset($plugin->add_field_path[$field_name . $fieldset]))
{
foreach ($plugin->add_field_path[$field_name . $fieldset] as $path)
{
$xml .= PHP_EOL . $this->_t(2)
. 'addfieldpath="' . $path . '"';
}
}
$xml .= PHP_EOL . $this->_t(1) . '>';
}
else