Skip to content

Commit

Permalink
Merge branch '20.0' of [email protected]:Dolibarr/dolibarr.git into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Jun 28, 2024
2 parents 8aeebe6 + e9487a2 commit b574fe4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 29 deletions.
2 changes: 1 addition & 1 deletion htdocs/admin/barcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
print '</td>';
print '<td class="nowrap">'.$modBarCode->getExample($langs)."</td>\n";

if (getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM') && $conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") {
if (getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM') == "$file") {
print '<td class="center"><a class="reposition" href="'.$_SERVER['PHP_SELF'].'?action=setbarcodeproductoff&token='.newToken().'&amp;value='.urlencode($file).'">';
print img_picto($langs->trans("Activated"), 'switch_on');
print '</a></td>';
Expand Down
2 changes: 1 addition & 1 deletion htdocs/barcode/codeinit.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@
if (preg_match('/^mod_barcode_product_.*php$/', $file)) {
$file = substr($file, 0, dol_strlen($file) - 4);

if ($file == $conf->global->BARCODE_PRODUCT_ADDON_NUM) {
if ($file == getDolGlobalString('BARCODE_PRODUCT_ADDON_NUM')) {
try {
dol_include_once($dirroot.$file.'.php');
} catch (Exception $e) {
Expand Down
8 changes: 4 additions & 4 deletions htdocs/core/class/html.formwebsite.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,12 @@ public function selectTypeOfContainer($htmlname, $selected = '', $useempty = 0,
$lasttypecontainer = '';
while ($i < $num) {
$obj = $this->db->fetch_object($result);
if (in_array($obj->typecontainer, array('library', 'service'))) {
/*if (!getDolGlobalString('WEBSITE_ADD_PAGE_TYPE_PHPLIB')) {
/*if (in_array($obj->typecontainer, array('library', 'service'))) {
if (!getDolGlobalString('WEBSITE_ADD_PAGE_TYPE_PHPLIB')) {
$i++;
continue;
}*/
}
}
}*/
if ($obj->typecontainer != $lasttypecontainer) {
$out .= '<option value="0" disabled>--- ';
$transcodecontainer = ucfirst($obj->typecontainer);
Expand Down
6 changes: 3 additions & 3 deletions htdocs/core/lib/website2.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -727,13 +727,13 @@ function checkPHPCode(&$phpfullcodestringold, &$phpfullcodestring)
break;
}
}
// Deny dynamic functions '${a}(' or '$a[b](' - So we refuse '}(' and ']('
// Deny dynamic functions '${a}(' or '$a[b](' or '$a->b(' => So we refuse '}(' and ']('
if (preg_match('/[}\]]\(/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", ']('), null, 'errors');
}
// Deny dynamic functions $xxx(
if (preg_match('/\$[a-z0-9_]+\(/ims', $phpfullcodestring)) {
// Deny dynamic functions '$xxx(' or '$a->b('
if (preg_match('/\$[a-z0-9_\-\>\/\*]+\(/ims', $phpfullcodestring)) {
$error++;
setEventMessages($langs->trans("DynamicPHPCodeContainsAForbiddenInstruction", '$...('), null, 'errors');
}
Expand Down
12 changes: 6 additions & 6 deletions htdocs/product/class/product.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ class Product extends CommonObject
public $accountancy_code_buy_export;

/**
* @var string|int Main Barcode value, -1 for auto code
* @var string|int Main Barcode value, -1 or 'auto' for auto code
*/
public $barcode;

Expand Down Expand Up @@ -687,11 +687,11 @@ public function check()
}

/**
* Insert product into database
* Insert product into database
*
* @param User $user User making insert
* @param int $notrigger Disable triggers
* @return int Id of product/service if OK, < 0 if KO
* @param User $user User making insert
* @param int $notrigger Disable triggers
* @return int Id of product/service if OK, < 0 if KO
*/
public function create($user, $notrigger = 0)
{
Expand Down Expand Up @@ -826,7 +826,7 @@ public function create($user, $notrigger = 0)
$this->db->begin();

// For automatic creation during create action (not used by Dolibarr GUI, can be used by scripts)
if ($this->barcode == -1) {
if ($this->barcode == '-1' || $this->barcode == 'auto') {
$this->barcode = $this->get_barcode($this, $this->barcode_type_code);
}

Expand Down
24 changes: 10 additions & 14 deletions htdocs/workstation/class/api_workstations.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
require_once DOL_DOCUMENT_ROOT.'/workstation/class/workstation.class.php';

/**
* \file class/api_workstations.class.php
* \file htdocs/workstation/class/api_workstations.class.php
* \ingroup workstation
* \brief File for API management of Workstations.
*/
Expand Down Expand Up @@ -68,7 +68,7 @@ public function __construct()
*/
public function get($id)
{
return $this->_fetch($id, '', '', '', $includestockdata, $includesubproducts, $includeparentid, false, $includetrans);
return $this->_fetch($id);
}

/**
Expand All @@ -88,7 +88,7 @@ public function get($id)
*/
public function getByRef($ref)
{
return $this->_fetch('', $ref);
return $this->_fetch(0, $ref);
}

/**
Expand All @@ -101,8 +101,8 @@ public function getByRef($ref)
* @param int $limit Limit for list
* @param int $page Page number
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.tobuy:=:0) and (t.tosell:=:1)"
* @param string $properties Restrict the data returned to theses properties. Ignored if empty. Comma separated list of properties names
* @return array Array of product objects
* @param string $properties Restrict the data returned to these properties. Ignored if empty. Comma separated list of properties names
* @return array Array of workstation objects
*/
public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $page = 0, $sqlfilters = '', $properties = '')
{
Expand All @@ -128,7 +128,7 @@ public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $p
}
}

//this query will return total products with the filters given
// this query will return total products with the filters given
$sqlTotals = str_replace('SELECT t.rowid, t.ref', 'SELECT count(t.rowid) as total', $sql);

$sql .= $this->db->order($sortfield, $sortorder);
Expand All @@ -148,13 +148,9 @@ public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $p
$i = 0;
while ($i < $min) {
$obj = $this->db->fetch_object($result);
if (!$ids_only) {
$workstation_static = new Workstation($this->db);
if ($workstation_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($workstation_static), $properties);
}
} else {
$obj_ret[] = $obj->rowid;
$workstation_static = new Workstation($this->db);
if ($workstation_static->fetch($obj->rowid)) {
$obj_ret[] = $this->_filterObjectProperties($this->_cleanObjectDatas($workstation_static), $properties);
}
$i++;
}
Expand All @@ -163,7 +159,7 @@ public function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 100, $p
}

//if $pagination_data is true the response will contain element data with all values and element pagination with pagination data(total,page,limit)
if ($pagination_data) {
if ($page > 0) {
$totalsResult = $this->db->query($sqlTotals);
$total = $this->db->fetch_object($totalsResult)->total;

Expand Down

0 comments on commit b574fe4

Please sign in to comment.