diff --git a/htdocs/public/api/index.php b/htdocs/public/api/index.php index 709b4436337da7abdcc29d61292d2c835e2750a4..832ab4e6c6950be8e877848dc08fe276cb389cf8 100644 --- a/htdocs/public/api/index.php +++ b/htdocs/public/api/index.php @@ -88,19 +88,29 @@ foreach ($modulesdir as $dir) /* * If exists, load the API class for enable module * - * Search a file api_<object>.class.php into /htdocs/<module>/class directory + * Search files named api_<object>.class.php into /htdocs/<module>/class directory * * @todo : take care of externals module! - * @todo : use getElementProperties() function + * @todo : use getElementProperties() function ? */ - $file = DOL_DOCUMENT_ROOT.'/'.$part."/class/api_".$obj.".class.php"; - - $classname = ucwords($obj).'Api'; - if (file_exists($file)) + $dir_part = DOL_DOCUMENT_ROOT.'/'.$part.'/class/'; + + $handle_part=@opendir(dol_osencode($dir_part)); + if (is_resource($handle_part)) { - require_once $file; - $api->r->addAPIClass($classname,''); + while (($file_searched = readdir($handle_part))!==false) + { + if (is_readable($dir_part.$file_searched) && preg_match("/^(api_.*)\.class\.php$/i",$file_searched,$reg)) + { + $classname=$reg[1]; + $classname = str_replace('Api_','',ucwords($reg[1])).'Api'; + require_once $dir_part.$file_searched; + if(class_exists($classname)) + $api->r->addAPIClass($classname,''); + } + } } + } } } diff --git a/htdocs/societe/class/api_thirdparty.class.php b/htdocs/societe/class/api_thirdparty.class.php index d21bee80c418642733ccd47344713c408e51620a..8fcc8b539d46b347a7791ef2fb249e2126c75c62 100644 --- a/htdocs/societe/class/api_thirdparty.class.php +++ b/htdocs/societe/class/api_thirdparty.class.php @@ -90,7 +90,9 @@ class ThirdpartyApi extends DolibarrApi { } /** - * Fetch a list of thirdparties + * List thirdparties + * + * Get a list of thirdparties * * @url GET /thirdparties/ *