Skip to content

Commit

Permalink
Fix: problem with external module
Browse files Browse the repository at this point in the history
  • Loading branch information
hregis committed Jun 6, 2012
1 parent 54dd024 commit 0d1159d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
11 changes: 9 additions & 2 deletions htdocs/core/ajax/loadinplace.php
Expand Up @@ -87,8 +87,15 @@
}
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);
Expand Down
18 changes: 13 additions & 5 deletions htdocs/core/ajax/saveinplace.php
Expand Up @@ -51,6 +51,7 @@
$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');

Expand Down Expand Up @@ -104,9 +105,9 @@
}
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))
Expand All @@ -131,8 +132,15 @@
}
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)
Expand Down

0 comments on commit 0d1159d

Please sign in to comment.