Skip to content

Commit 2481306

Browse files
committed
Create two new events in the remote lib to allow loading custom plugin fields.
1 parent 461a5bc commit 2481306

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

interface/lib/classes/remoting_lib.inc.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,22 @@ class remoting_lib extends tform_base {
8282
//* Load the form definition from file. - special version for remoting
8383
// module parameter is only for compatibility with base class
8484
function loadFormDef($file, $module = '') {
85-
global $app, $conf;
85+
global $app;
8686

8787
include $file;
8888

89+
// Search for module name by path because $_SESSION['s']['module']['name']
90+
// isn't set in a remote call.
91+
$module_path = array_reverse(explode('/', $file));
92+
$module_name = isset($module_path[2]) && $module_path[1] == 'form' && preg_match("/^[a-z]{2,20}$/i", $module_path[2]) ? $module_path[2] : '';
93+
94+
// Allow plugins to be loaded
95+
if ($module_name) {
96+
$app->plugin->raiseEvent($module_name.':'.$form['name'] . ':on_remote_before_formdef', $this);
97+
}
98+
8999
$this->formDef = $form;
100+
90101
unset($this->formDef['tabs']);
91102

92103
//* Copy all fields from all tabs into one form definition
@@ -97,6 +108,11 @@ function loadFormDef($file, $module = '') {
97108
}
98109
unset($form);
99110

111+
// Allow plugins to be loaded
112+
if ($module_name) {
113+
$app->plugin->raiseEvent($module_name.':'.$this->formDef['name'] . ':on_remote_after_formdef', $this);
114+
}
115+
100116
$this->dateformat = 'Y-m-d'; //$app->lng('conf_format_dateshort');
101117
$this->datetimeformat = 'Y-m-d H:i:s'; //$app->lng('conf_format_datetime');
102118

@@ -203,14 +219,14 @@ function encode($record, $tab = '', $dbencode = true) {
203219
function getSQL($record, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '', $dummy = '') {
204220

205221
global $app;
206-
222+
207223
// early usage. make sure _primary_id is sanitized if present.
208224
if ( isset($record['_primary_id']) && is_numeric($record['_primary_id'])) {
209225
$_primary_id = intval($record['_primary_id']);
210226
if ($_primary_id > 0)
211227
$this->primary_id_override = $_primary_id;
212228
}
213-
229+
214230
if(!is_array($this->formDef)) $app->error("Form definition not found.");
215231
$this->dataRecord = $record;
216232

0 commit comments

Comments
 (0)