diff --git a/ajax/createmetademands.php b/ajax/createmetademands.php index 59a1ee00..8eae6561 100644 --- a/ajax/createmetademands.php +++ b/ajax/createmetademands.php @@ -99,6 +99,14 @@ $meta_validated = $_POST['meta_validated']; } +if (isset($PLUGIN_HOOKS['metademands'])) { + foreach ($PLUGIN_HOOKS['metademands'] as $plug => $method) { + if (Plugin::isPluginActive($plug)) { + echo PluginMetademandsMetademand::pluginPreItemAdd($plug); + } + } +} + if ($nofreetable == false) { if (isset($_POST['see_basket_summary']) && $_POST['see_basket_summary'] == 1) { $_POST['see_basket_summary'] = 0; diff --git a/inc/metademand.class.php b/inc/metademand.class.php index 7b0d11f0..9efe81e8 100644 --- a/inc/metademand.class.php +++ b/inc/metademand.class.php @@ -8932,6 +8932,28 @@ public static function getPluginUniqueDropdown($plug) } } + public static function pluginPreItemAdd($plug) + { + global $PLUGIN_HOOKS; + + $dbu = new DbUtils(); + if (isset($PLUGIN_HOOKS['metademands'][$plug])) { + $pluginclasses = $PLUGIN_HOOKS['metademands'][$plug]; + + foreach ($pluginclasses as $pluginclass) { + if (!class_exists($pluginclass)) { + continue; + } + $form[$pluginclass] = []; + $item = $dbu->getItemForItemtype($pluginclass); + if ($item && is_callable([$item, 'preItemAdd'])) { + return $item->preItemAdd(); + } + } + } + } + + public static function checkPluginUniqueItilcategory($plug, $dbu) { global $PLUGIN_HOOKS;