Skip to content

Commit dc8167e

Browse files
committed
tform actions updated
1 parent 5f97596 commit dc8167e

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

interface/lib/classes/tform_actions.inc.php

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,8 @@ function onLoad() {
5353

5454
// Load table definition from file
5555
$app->tform->loadFormDef($tform_def_file);
56-
57-
// loading plugins
58-
$next_tab = $app->tform->getNextTab();
59-
if(is_array($app->tform->formDef["tabs"][$next_tab]["plugins"])) {
60-
$app->load('plugin_base');
61-
foreach($app->tform->formDef["tabs"][$next_tab]["plugins"] as $plugin_name => $plugin_settings) {
62-
$plugin_class = $plugin_settings["class"];
63-
$app->load($plugin_class);
64-
$this->plugins[$plugin_name] = new $plugin_class;
65-
$this->plugins[$plugin_name]->setOptions($plugin_name,$plugin_settings['options']);
66-
$this->plugins[$plugin_name]->onLoad();
67-
}
68-
}
69-
70-
// Importing ID
56+
57+
// Importing ID
7158
$this->id = intval($_REQUEST["id"]);
7259

7360
if(count($_POST) > 1) {
@@ -108,6 +95,10 @@ function onUpdate() {
10895
$app->db->query($sql);
10996
if($app->db->errorMessage != '') die($app->db->errorMessage);
11097
}
98+
99+
// loading plugins
100+
$next_tab = $app->tform->getCurrentTab();
101+
$this->loadPlugins($next_tab);
111102

112103
// Call plugin
113104
foreach($this->plugins as $plugin) {
@@ -148,7 +139,11 @@ function onInsert() {
148139
$app->db->query($sql);
149140
if($app->db->errorMessage != '') die($app->db->errorMessage);
150141
$this->id = $app->db->insertID();
151-
142+
143+
// loading plugins
144+
$next_tab = $app->tform->getCurrentTab();
145+
$this->loadPlugins($next_tab);
146+
152147
// Call plugin
153148
foreach($this->plugins as $plugin) {
154149
$plugin->onInsert();
@@ -241,7 +236,12 @@ function onDelete() {
241236
}
242237

243238
$app->db->query("DELETE FROM ".$liste["table"]." WHERE ".$liste["table_idx"]." = ".$this->id);
244-
239+
240+
// loading plugins
241+
$next_tab = $app->tform->getCurrentTab();
242+
$this->loadPlugins($next_tab);
243+
244+
245245
// Call plugin
246246
foreach($this->plugins as $plugin) {
247247
$plugin->onInsert();
@@ -283,6 +283,10 @@ function onShow() {
283283

284284
// Setting default values
285285
$app->tpl_defaults();
286+
287+
// loading plugins
288+
//$next_tab = $app->tform->getNextTab();
289+
$this->loadPlugins($this->active_tab);
286290

287291
// Calling the Plugin onShow Events and set the data in the
288292
// plugins placeholder in the template
@@ -346,6 +350,20 @@ function onShowEnd() {
346350
// Template parsen
347351
$app->tpl->pparse();
348352
}
353+
354+
function loadPlugins($next_tab) {
355+
global $app;
356+
if(is_array($app->tform->formDef["tabs"][$next_tab]["plugins"])) {
357+
$app->load('plugin_base');
358+
foreach($app->tform->formDef["tabs"][$next_tab]["plugins"] as $plugin_name => $plugin_settings) {
359+
$plugin_class = $plugin_settings["class"];
360+
$app->load($plugin_class);
361+
$this->plugins[$plugin_name] = new $plugin_class;
362+
$this->plugins[$plugin_name]->setOptions($plugin_name,$plugin_settings['options']);
363+
$this->plugins[$plugin_name]->onLoad();
364+
}
365+
}
366+
}
349367

350368

351369
}

0 commit comments

Comments
 (0)