Fix use the getUrl function instead of hard coded curl
This commit is contained in:
parent
0ee93fb00c
commit
95cf36c43b
@ -37,6 +37,7 @@ $action=GETPOST('action','aZ09');
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (preg_match('/set_(.*)/',$action,$reg))
|
||||
{
|
||||
$code=$reg[1];
|
||||
@ -82,7 +83,7 @@ print load_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'title_setup')
|
||||
|
||||
$head=categoriesadmin_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'setup', $langs->trans("Categories"), 0, 'category');
|
||||
dol_fiche_head($head, 'setup', $langs->trans("Categories"), -1, 'category');
|
||||
|
||||
|
||||
print '<table class="noborder" width="100%">';
|
||||
|
||||
@ -68,7 +68,7 @@ print load_fiche_titre($langs->trans("CategoriesSetup"),$linkback,'title_setup')
|
||||
|
||||
$head = categoriesadmin_prepare_head();
|
||||
|
||||
dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), 0, 'category');
|
||||
dol_fiche_head($head, 'attributes_categories', $langs->trans("Categories"), -1, 'category');
|
||||
|
||||
require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
|
||||
|
||||
|
||||
@ -247,12 +247,18 @@ ComposedProduct=Sub-product
|
||||
MinSupplierPrice=Minimum supplier price
|
||||
MinCustomerPrice=Minimum customer price
|
||||
DynamicPriceConfiguration=Dynamic price configuration
|
||||
DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value.
|
||||
DynamicPriceDesc=On product card, with this module enabled, you should be able to set mathematic functions to calculate Customer or Supplier prices. Such function can use all mathematic operators, some constants and variables. You can set here the variables you want to be able to use and if the variable need an automatic update, the external URL to use to ask Dolibarr to update automaticaly the value.
|
||||
AddVariable=Add Variable
|
||||
AddUpdater=Add Updater
|
||||
GlobalVariables=Global variables
|
||||
VariableToUpdate=Variable to update
|
||||
GlobalVariableUpdaters=Global variable updaters
|
||||
GlobalVariableUpdaterType0=JSON data
|
||||
GlobalVariableUpdaterHelp0=Parses JSON data from specified URL, VALUE specifies the location of relevant value,
|
||||
GlobalVariableUpdaterHelpFormat0=Format for request {"URL": "http://example.com/urlofjson", "VALUE": "array1,array2,targetvalue"}
|
||||
GlobalVariableUpdaterType1=WebService data
|
||||
GlobalVariableUpdaterHelp1=Parses WebService data from specified URL, NS specifies the namespace, VALUE specifies the location of relevant value, DATA should contain the data to send and METHOD is the calling WS method
|
||||
GlobalVariableUpdaterHelpFormat1=Format for request is {"URL": "http://example.com/urlofws", "VALUE": "array,targetvalue", "NS": "http://example.com/urlofns", "METHOD": "myWSMethod", "DATA": {"your": "data", "to": "send"}}
|
||||
UpdateInterval=Update interval (minutes)
|
||||
LastUpdated=Latest update
|
||||
CorrectlyUpdated=Correctly updated
|
||||
|
||||
@ -54,9 +54,11 @@ if ($action == 'edit_updater') {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if (!empty($action) && empty($cancel)) {
|
||||
//Global variable actions
|
||||
if ($action == 'create_variable' || $action == 'edit_variable') {
|
||||
|
||||
@ -464,24 +464,18 @@ class PriceGlobalVariableUpdater
|
||||
}
|
||||
$result = "";
|
||||
if ($this->type == 0) {
|
||||
//CURL client
|
||||
$handle = curl_init();
|
||||
curl_setopt_array($handle, array(
|
||||
CURLOPT_URL => $url,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_TIMEOUT => 5,
|
||||
CURLOPT_POST => false,
|
||||
CURLOPT_HEADER => false,
|
||||
));
|
||||
// Call JSON request
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/geturl.lib.php';
|
||||
$tmpresult=getURLContent($url);
|
||||
$code=$tmpresult['http_code'];
|
||||
$result=$tmpresult['content'];
|
||||
|
||||
$result = curl_exec($handle);
|
||||
$code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
|
||||
if (!isset($result)) {
|
||||
$this->error = $langs->trans("ErrorGlobalVariableUpdater0", "empty response");
|
||||
return -1;
|
||||
}
|
||||
if ($code !== 200) {
|
||||
$this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code);
|
||||
$this->error = $langs->trans("ErrorGlobalVariableUpdater0", $code.' '.$tmpresult['curl_error_msg']);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user