From 0d1159d8622c784fab783846567cb38a94dca5a3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 6 Jun 2012 22:59:26 +0200 Subject: [PATCH] Fix: problem with external module --- htdocs/core/ajax/loadinplace.php | 11 +++++++++-- htdocs/core/ajax/saveinplace.php | 18 +++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/htdocs/core/ajax/loadinplace.php b/htdocs/core/ajax/loadinplace.php index 152ba07288d..55d9adb70f3 100644 --- a/htdocs/core/ajax/loadinplace.php +++ b/htdocs/core/ajax/loadinplace.php @@ -87,8 +87,15 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ } else if (! empty($ext_element)) { - dol_include_once('/'.$ext_element.'/class/actions_'.$ext_element.'.class.php'); - $classname = 'Actions'.ucfirst($ext_element); + $module = $subelement = $ext_element; + if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) + { + $module = $regs[1]; + $subelement = $regs[2]; + } + + dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php'); + $classname = 'Actions'.ucfirst($subelement); $object = new $classname($db); $ret = $object->$methodname(); if ($ret > 0) echo json_encode($object->$cachename); diff --git a/htdocs/core/ajax/saveinplace.php b/htdocs/core/ajax/saveinplace.php index 9af6a83e54a..50541facffa 100644 --- a/htdocs/core/ajax/saveinplace.php +++ b/htdocs/core/ajax/saveinplace.php @@ -51,6 +51,7 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ $field = substr($field, 8); // remove prefix val_ $type = GETPOST('type','alpha',2); $value = ($type == 'ckeditor' ? GETPOST('value','',2) : GETPOST('value','alpha',2)); + $loadmethod = GETPOST('loadmethod','alpha',2); $savemethod = GETPOST('savemethod','alpha',2); $savemethodname = (! empty($savemethod) ? $savemethod : 'setValueFrom'); @@ -104,9 +105,9 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ } else if ($type == 'select') { - $loadmethodname = 'load_cache_'.GETPOST('loadmethod','alpha'); - $loadcachename = 'cache_'.GETPOST('loadmethod','alpha'); - $loadviewname = 'view_'.GETPOST('loadmethod','alpha'); + $loadmethodname = 'load_cache_'.$loadmethod; + $loadcachename = 'cache_'.$loadmethod; + $loadviewname = 'view_'.$loadmethod; $form = new Form($db); if (method_exists($form, $loadmethodname)) @@ -131,8 +132,15 @@ if (! empty($field) && ! empty($element) && ! empty($table_element) && ! empty($ } else { - dol_include_once('/'.$ext_element.'/class/actions_'.$ext_element.'.class.php'); - $classname = 'Actions'.ucfirst($ext_element); + $module = $subelement = $ext_element; + if (preg_match('/^([^_]+)_([^_]+)/i',$ext_element,$regs)) + { + $module = $regs[1]; + $subelement = $regs[2]; + } + + dol_include_once('/'.$module.'/class/actions_'.$subelement.'.class.php'); + $classname = 'Actions'.ucfirst($subelement); $object = new $classname($db); $ret = $object->$loadmethodname(); if ($ret > 0)