diff --git a/ChangeLog b/ChangeLog index aa600bdacef..d80f8781ba1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -19,7 +19,8 @@ Following changes may create regressions for some external modules, but were nec __PROPALREF__, ...) * The substition key __SIGNATURE__ was renamed into __USER_SIGNATURE__ to standardize naming conventions. * Substitution keys with syntax %XXX% were renamed into __XXX__ to match others. -* Some REST API to access the dictionary (country, town, ...) were moved into a common API. +* Some REST API to access setup features, like dictionaries (country, town, extrafields, ...) were moved into a + common API "/setup". * Page bank/index.php and bank/bankentries.php were renamed into bank/list.php and bank/bankentries_list.php to follow page naming conventions (so default filter/sort order features can also work). * The trigger ORDER_SUPPLIER_STATUS_ONPROCESS was renamed into ORDER_SUPPLIER_STATUS_ORDERED diff --git a/htdocs/api/class/api_dictionary.class.php b/htdocs/api/class/api_setup.class.php similarity index 98% rename from htdocs/api/class/api_dictionary.class.php rename to htdocs/api/class/api_setup.class.php index d551f3d866f..ab11c1e2e2f 100644 --- a/htdocs/api/class/api_dictionary.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/ccountry.class.php'; * @access protected * @class DolibarrApiAccess {@requires user,external} */ -class Dictionary extends DolibarrApi +class Setup extends DolibarrApi { private $translations = null; @@ -53,7 +53,7 @@ class Dictionary extends DolibarrApi * @param int $active Payment type is active or not {@min 0} {@max 1} * @param string $sqlfilters SQL criteria to filter with. Syntax example "(t.code:=:'CHQ')" * - * @url GET payment/types + * @url GET dictionary/payment_types * * @return array [List of payment types] * @@ -122,7 +122,7 @@ class Dictionary extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return List of countries * - * @url GET countries + * @url GET dictionary/countries * * @throws RestException */ @@ -188,7 +188,7 @@ class Dictionary extends DolibarrApi * @param string $lang Code of the language the name of the * country must be translated to * - * @url GET countries/{id} + * @url GET dictionary/countries/{id} * * @throws RestException */ @@ -212,7 +212,7 @@ class Dictionary extends DolibarrApi * Clean sensible object datas * * @param object $object Object to clean - * @return array Array of cleaned object properties + * @return array Array of cleaned object properties */ function _cleanObjectDatas($object) { @@ -263,7 +263,7 @@ class Dictionary extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return List of events types * - * @url GET events + * @url GET dictionary/event_types * * @throws RestException */ @@ -402,7 +402,7 @@ class Dictionary extends DolibarrApi * @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.code:like:'A%') and (t.active:>=:0)" * @return List of towns * - * @url GET towns + * @url GET dictionary/towns * * @throws RestException */ @@ -463,7 +463,7 @@ class Dictionary extends DolibarrApi * @param int $active Payment term is active or not {@min 0} {@max 1} * @param string $sqlfilters SQL criteria to filter. Syntax example "(t.code:=:'CHQ')" * - * @url GET payment/terms + * @url GET dictionary/payment_terms * * @return array List of payment terms * diff --git a/htdocs/api/class/api_status.class.php b/htdocs/api/class/api_status.class.php index 2ac8da018d6..ea61731b51a 100644 --- a/htdocs/api/class/api_status.class.php +++ b/htdocs/api/class/api_status.class.php @@ -21,7 +21,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php'; /** * API that gives the status of the Dolibarr instance. * - * @access protected + * @access protected * @class DolibarrApiAccess {@requires user,external} */ class Status @@ -30,10 +30,13 @@ class Status * Get status (Dolibarr version) */ function index() { + global $conf; + return array( 'success' => array( 'code' => 200, - 'dolibarr_version' => DOL_VERSION + 'dolibarr_version' => DOL_VERSION, + 'access_locked' => (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)?'0':$conf->global->MAIN_ONLY_LOGIN_ALLOWED) ) ); } diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 7ba73df91df..0806cabed4d 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2198,10 +2198,7 @@ function getModuleDirForApiClass($module) if ($module == 'contracts') { $moduledirforclass = 'contrat'; } - elseif (in_array($module, array('login', 'access', 'status', 'documents'))) { - $moduledirforclass = 'api'; - } - elseif (preg_match('/^dictionary/', $module)) { + elseif (in_array($module, array('login', 'setup', 'access', 'status', 'documents'))) { $moduledirforclass = 'api'; } elseif ($module == 'contact' || $module == 'contacts' || $module == 'customer' || $module == 'thirdparty' || $module == 'thirdparties') {