From a641c81d92c6f511fb744d63e6df1e81fba7adbc Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 7 Nov 2019 17:05:30 +0100 Subject: [PATCH 1/3] FIX socialnetworks API if module not active --- htdocs/api/class/api_setup.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index b32eea1f57f..2e52c6af32f 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1095,7 +1095,11 @@ class Setup extends DolibarrApi */ public function getListOfsocialNetworks($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { - $list = array(); + if (empty($conf->global->MAIN_MODULE_SOCIALNETWORKS)) { + throw new RestException(400, 'API not available: this dictionary is not enabled by setup'); + } + + $list = array(); //TODO link with multicurrency module $sql = "SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_socialnetworks as t"; From a3878d82e9d1be9edfd110109d2d2eca28719651 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 7 Nov 2019 16:06:58 +0000 Subject: [PATCH 2/3] Fixing style errors. --- htdocs/api/class/api_setup.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index 2e52c6af32f..a74f8e8ec79 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1098,7 +1098,7 @@ class Setup extends DolibarrApi if (empty($conf->global->MAIN_MODULE_SOCIALNETWORKS)) { throw new RestException(400, 'API not available: this dictionary is not enabled by setup'); } - + $list = array(); //TODO link with multicurrency module $sql = "SELECT t.rowid, t.entity, t.code, t.label, t.url, t.icon, t.active"; From 4145d7c8259b5d323d6b3c249b61dcbd2634745b Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Thu, 7 Nov 2019 17:18:39 +0100 Subject: [PATCH 3/3] Update api_setup.class.php --- htdocs/api/class/api_setup.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/api/class/api_setup.class.php b/htdocs/api/class/api_setup.class.php index a74f8e8ec79..a264288c111 100644 --- a/htdocs/api/class/api_setup.class.php +++ b/htdocs/api/class/api_setup.class.php @@ -1095,7 +1095,9 @@ class Setup extends DolibarrApi */ public function getListOfsocialNetworks($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '') { - if (empty($conf->global->MAIN_MODULE_SOCIALNETWORKS)) { + global $conf; + + if (empty($conf->socialnetworks->enabled)) { throw new RestException(400, 'API not available: this dictionary is not enabled by setup'); }