forked from Dolibarr/dolibarr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
815d815
commit 0d23eae
Showing
26 changed files
with
4,181 additions
and
511 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
* Copyright (C) 2012-2015 Marcos García <[email protected]> | ||
* Copyright (C) 2012-2015 Raphaël Doursenaud <[email protected]> | ||
* Copyright (C) 2012 Cedric Salvador <[email protected]> | ||
* Copyright (C) 2015-2022 Alexandre Spangaro <[email protected]> | ||
* Copyright (C) 2015-2021 Alexandre Spangaro <[email protected]> | ||
* Copyright (C) 2016 Bahfir abbes <[email protected]> | ||
* Copyright (C) 2017 ATM Consulting <[email protected]> | ||
* Copyright (C) 2017-2019 Nicolas ZABOURI <[email protected]> | ||
|
@@ -83,11 +83,6 @@ abstract class CommonObject | |
*/ | ||
public $element; | ||
|
||
/** | ||
* @var string Name to use for 'features' parameter to check module permissions with restrictedArea(). Undefined means same value than $element. | ||
*/ | ||
public $element_for_permission; | ||
|
||
/** | ||
* @var string Name of table without prefix where object is stored | ||
*/ | ||
|
@@ -2931,20 +2926,15 @@ public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line | |
return -1; | ||
} | ||
|
||
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position' | ||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) { | ||
$fieldposition = 'position'; | ||
} | ||
|
||
// Count number of lines to reorder (according to choice $renum) | ||
$nl = 0; | ||
$sql = "SELECT count(rowid) FROM ".$this->db->prefix().$this->table_element_line; | ||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); | ||
if (!$renum) { | ||
$sql .= " AND " . $fieldposition . " = 0"; | ||
$sql .= ' AND rang = 0'; | ||
} | ||
if ($renum) { | ||
$sql .= " AND " . $fieldposition . " <> 0"; | ||
$sql .= ' AND rang <> 0'; | ||
} | ||
|
||
dol_syslog(get_class($this)."::line_order", LOG_DEBUG); | ||
|
@@ -2965,7 +2955,7 @@ public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line | |
if ($fk_parent_line) { | ||
$sql .= ' AND fk_parent_line IS NULL'; | ||
} | ||
$sql .= " ORDER BY " . $fieldposition . " ASC, rowid " . $rowidorder; | ||
$sql .= " ORDER BY rang ASC, rowid ".$rowidorder; | ||
|
||
dol_syslog(get_class($this)."::line_order search all parent lines", LOG_DEBUG); | ||
$resql = $this->db->query($sql); | ||
|
@@ -3006,17 +2996,12 @@ public function line_order($renum = false, $rowidorder = 'ASC', $fk_parent_line | |
*/ | ||
public function getChildrenOfLine($id, $includealltree = 0) | ||
{ | ||
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position' | ||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) { | ||
$fieldposition = 'position'; | ||
} | ||
|
||
$rows = array(); | ||
|
||
$sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line; | ||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); | ||
$sql .= ' AND fk_parent_line = '.((int) $id); | ||
$sql .= " ORDER BY " . $fieldposition . " ASC"; | ||
$sql .= ' ORDER BY rang ASC'; | ||
|
||
dol_syslog(get_class($this)."::getChildrenOfLine search children lines for line ".$id, LOG_DEBUG); | ||
$resql = $this->db->query($sql); | ||
|
@@ -3087,7 +3072,7 @@ public function updateRangOfLine($rowid, $rang) | |
{ | ||
global $hookmanager; | ||
$fieldposition = 'rang'; // @todo Rename 'rang' into 'position' | ||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) { | ||
if (in_array($this->table_element_line, array('bom_bomline', 'ecm_files', 'emailcollector_emailcollectoraction'))) { | ||
$fieldposition = 'position'; | ||
} | ||
|
||
|
@@ -3133,13 +3118,13 @@ public function updateLineUp($rowid, $rang) | |
{ | ||
if ($rang > 1) { | ||
$fieldposition = 'rang'; | ||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) { | ||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) { | ||
$fieldposition = 'position'; | ||
} | ||
|
||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang); | ||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); | ||
$sql .= " AND " . $fieldposition . " = " . ((int) ($rang - 1)); | ||
$sql .= ' AND rang = '.((int) ($rang - 1)); | ||
if ($this->db->query($sql)) { | ||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang - 1)); | ||
$sql .= ' WHERE rowid = '.((int) $rowid); | ||
|
@@ -3164,13 +3149,13 @@ public function updateLineDown($rowid, $rang, $max) | |
{ | ||
if ($rang < $max) { | ||
$fieldposition = 'rang'; | ||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) { | ||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction'))) { | ||
$fieldposition = 'position'; | ||
} | ||
|
||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) $rang); | ||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); | ||
$sql .= " AND " . $fieldposition . " = " . ((int) ($rang + 1)); | ||
$sql .= ' AND rang = '.((int) ($rang + 1)); | ||
if ($this->db->query($sql)) { | ||
$sql = "UPDATE ".$this->db->prefix().$this->table_element_line." SET ".$fieldposition." = ".((int) ($rang + 1)); | ||
$sql .= ' WHERE rowid = '.((int) $rowid); | ||
|
@@ -3191,12 +3176,7 @@ public function updateLineDown($rowid, $rang, $max) | |
*/ | ||
public function getRangOfLine($rowid) | ||
{ | ||
$fieldposition = 'rang'; | ||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) { | ||
$fieldposition = 'position'; | ||
} | ||
|
||
$sql = "SELECT " . $fieldposition . " FROM ".$this->db->prefix().$this->table_element_line; | ||
$sql = "SELECT rang FROM ".$this->db->prefix().$this->table_element_line; | ||
$sql .= " WHERE rowid = ".((int) $rowid); | ||
|
||
dol_syslog(get_class($this)."::getRangOfLine", LOG_DEBUG); | ||
|
@@ -3215,14 +3195,9 @@ public function getRangOfLine($rowid) | |
*/ | ||
public function getIdOfLine($rang) | ||
{ | ||
$fieldposition = 'rang'; | ||
if (in_array($this->table_element_line, array('ecm_files', 'emailcollector_emailcollectoraction', 'product_attribute_value'))) { | ||
$fieldposition = 'position'; | ||
} | ||
|
||
$sql = "SELECT rowid FROM ".$this->db->prefix().$this->table_element_line; | ||
$sql .= " WHERE ".$this->fk_element." = ".((int) $this->id); | ||
$sql .= " AND " . $fieldposition . " = ".((int) $rang); | ||
$sql .= " AND rang = ".((int) $rang); | ||
$resql = $this->db->query($sql); | ||
if ($resql) { | ||
$row = $this->db->fetch_row($resql); | ||
|
@@ -3241,7 +3216,7 @@ public function line_max($fk_parent_line = 0) | |
{ | ||
// phpcs:enable | ||
$positionfield = 'rang'; | ||
if (in_array($this->table_element, array('bom_bom', 'product_attribute'))) { | ||
if ($this->table_element == 'bom_bom') { | ||
$positionfield = 'position'; | ||
} | ||
|
||
|
@@ -3695,7 +3670,7 @@ public function add_object_linked($origin = null, $origin_id = null, $f_user = n | |
|
||
// Elements of the core modules which have `$module` property but may to which we don't want to prefix module part to the element name for finding the linked object in llx_element_element. | ||
// It's because an entry for this element may be exist in llx_element_element before this modification (version <=14.2) and ave named only with their element name in fk_source or fk_target. | ||
$coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization', 'asset'); | ||
$coremodule = array('knowledgemanagement', 'partnership', 'workstation', 'ticket', 'recruitment', 'eventorganization'); | ||
// Add module part to target type if object has $module property and isn't in core modules. | ||
$targettype = ((!empty($this->module) && ! in_array($this->module, $coremodule)) ? $this->module.'_' : '').$this->element; | ||
|
||
|
@@ -5330,7 +5305,8 @@ protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $h | |
$sav_charset_output = $outputlangs->charset_output; | ||
|
||
if (in_array(get_class($this), array('Adherent'))) { | ||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, 'tmp_cards', $moreparams); | ||
$arrayofrecords = array(); // The write_file of templates of adherent class need this var | ||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams); | ||
} else { | ||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); | ||
} | ||
|
@@ -5713,12 +5689,12 @@ public function setValuesForExtraLanguages($onlykey = '') | |
|
||
$enabled = 1; | ||
if (isset($this->fields[$key]['enabled'])) { | ||
$enabled = dol_eval($this->fields[$key]['enabled'], 1, 1, '1'); | ||
$enabled = dol_eval($this->fields[$key]['enabled'], 1); | ||
} | ||
/*$perms = 1; | ||
if (isset($this->fields[$key]['perms'])) | ||
{ | ||
$perms = dol_eval($this->fields[$key]['perms'], 1, 1, '1'); | ||
$perms = dol_eval($this->fields[$key]['perms'], 1); | ||
}*/ | ||
if (empty($enabled)) { | ||
continue; | ||
|
@@ -5728,11 +5704,11 @@ public function setValuesForExtraLanguages($onlykey = '') | |
if (in_array($key_type, array('date'))) { | ||
// Clean parameters | ||
// TODO GMT date in memory must be GMT so we should add gm=true in parameters | ||
$value_key = dol_mktime(0, 0, 0, GETPOST($postfieldkey."month", 'int'), GETPOST($postfieldkey."day", 'int'), GETPOST($postfieldkey."year", 'int')); | ||
$value_key = dol_mktime(0, 0, 0, $_POST[$postfieldkey."month"], $_POST[$postfieldkey."day"], $_POST[$postfieldkey."year"]); | ||
} elseif (in_array($key_type, array('datetime'))) { | ||
// Clean parameters | ||
// TODO GMT date in memory must be GMT so we should add gm=true in parameters | ||
$value_key = dol_mktime(GETPOST($postfieldkey."hour", 'int'), GETPOST($postfieldkey."min", 'int'), 0, GETPOST($postfieldkey."month", 'int'), GETPOST($postfieldkey."day", 'int'), GETPOST($postfieldkey."year", 'int')); | ||
$value_key = dol_mktime($_POST[$postfieldkey."hour"], $_POST[$postfieldkey."min"], 0, $_POST[$postfieldkey."month"], $_POST[$postfieldkey."day"], $_POST[$postfieldkey."year"]); | ||
} elseif (in_array($key_type, array('checkbox', 'chkbxlst'))) { | ||
$value_arr = GETPOST($postfieldkey, 'array'); // check if an array | ||
if (!empty($value_arr)) { | ||
|
@@ -5874,7 +5850,7 @@ public function fetch_optionals($rowid = null, $optionsArray = null) | |
if (!empty($extrafields) && !empty($extrafields->attributes[$this->table_element]['computed'][$key])) { | ||
//var_dump($conf->disable_compute); | ||
if (empty($conf->disable_compute)) { | ||
$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0, ''); | ||
$this->array_options["options_".$key] = dol_eval($extrafields->attributes[$this->table_element]['computed'][$key], 1, 0); | ||
} | ||
} | ||
} | ||
|
@@ -5955,6 +5931,7 @@ public function insertExtraFields($trigger = '', $userused = null) | |
|
||
$error = 0; | ||
|
||
|
||
if (!empty($this->array_options)) { | ||
// Check parameters | ||
$langs->load('admin'); | ||
|
@@ -6005,7 +5982,7 @@ public function insertExtraFields($trigger = '', $userused = null) | |
|
||
if (!empty($attrfieldcomputed)) { | ||
if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { | ||
$value = dol_eval($attrfieldcomputed, 1, 0, ''); | ||
$value = dol_eval($attrfieldcomputed, 1, 0); | ||
dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG); | ||
$new_array_options[$key] = $value; | ||
} else { | ||
|
@@ -6372,7 +6349,7 @@ public function updateExtraField($key, $trigger = null, $userused = null) | |
|
||
if (!empty($attrfieldcomputed)) { | ||
if (!empty($conf->global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { | ||
$value = dol_eval($attrfieldcomputed, 1, 0, ''); | ||
$value = dol_eval($attrfieldcomputed, 1, 0); | ||
dol_syslog($langs->trans("Extrafieldcomputed")." sur ".$attributeLabel."(".$value.")", LOG_DEBUG); | ||
$this->array_options["options_".$key] = $value; | ||
} else { | ||
|
@@ -6668,7 +6645,7 @@ public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = | |
|
||
// Add validation state class | ||
if (!empty($validationClass)) { | ||
$morecss.= $validationClass; | ||
$morecss.= ' '.$validationClass; | ||
} | ||
|
||
if (in_array($type, array('date'))) { | ||
|
@@ -7087,8 +7064,6 @@ public function showInputField($val, $key, $value, $moreparam = '', $keysuffix = | |
$paramforthenewlink = ''; | ||
$paramforthenewlink .= (GETPOSTISSET('action') ? '&action='.GETPOST('action', 'aZ09') : ''); | ||
$paramforthenewlink .= (GETPOSTISSET('id') ? '&id='.GETPOST('id', 'int') : ''); | ||
$paramforthenewlink .= (GETPOSTISSET('origin') ? '&origin='.GETPOST('origin', 'aZ09') : ''); | ||
$paramforthenewlink .= (GETPOSTISSET('originid') ? '&originid='.GETPOST('originid', 'int') : ''); | ||
$paramforthenewlink .= '&fk_'.strtolower($class).'=--IDFORBACKTOPAGE--'; | ||
// TODO Add Javascript code to add input fields already filled into $paramforthenewlink so we won't loose them when going back to main page | ||
$out .= '<a class="butActionNew" title="'.$langs->trans("New").'" href="'.$url_path.'?action=create&backtopage='.urlencode($_SERVER['PHP_SELF'].($paramforthenewlink ? '?'.$paramforthenewlink : '')).'"><span class="fa fa-plus-circle valignmiddle"></span></a>'; | ||
|
@@ -7173,7 +7148,7 @@ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix | |
$objectid = $this->id; // Not used ??? | ||
$label = empty($val['label']) ? '' : $val['label']; | ||
$type = empty($val['type']) ? '' : $val['type']; | ||
$type = empty($val['type']) ? '' : $val['ty²pe']; | ||
$size = empty($val['css']) ? '' : $val['css']; | ||
$reg = array(); | ||
|
||
|
@@ -7228,7 +7203,7 @@ public function showOutputField($val, $key, $value, $moreparam = '', $keysuffix | |
if ($computed) { | ||
// Make the eval of compute string | ||
//var_dump($computed); | ||
$value = dol_eval($computed, 1, 0, ''); | ||
$value = dol_eval($computed, 1, 0); | ||
} | ||
|
||
if (empty($morecss)) { | ||
|
@@ -7739,7 +7714,7 @@ public function showOptionals($extrafields, $mode = 'view', $params = null, $key | |
if (empty($reshook)) { | ||
if (key_exists('label', $extrafields->attributes[$this->table_element]) && is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0) { | ||
$out .= "\n"; | ||
$out .= '<!-- commonobject:showOptionals --> '; | ||
$out .= '<!-- showOptionals --> '; | ||
$out .= "\n"; | ||
|
||
$extrafields_collapse_num = ''; | ||
|
@@ -7753,20 +7728,20 @@ public function showOptionals($extrafields, $mode = 'view', $params = null, $key | |
// Test on 'enabled' ('enabled' is different than 'list' = 'visibility') | ||
$enabled = 1; | ||
if ($enabled && isset($extrafields->attributes[$this->table_element]['enabled'][$key])) { | ||
$enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1, 1, '1'); | ||
$enabled = dol_eval($extrafields->attributes[$this->table_element]['enabled'][$key], 1); | ||
} | ||
if (empty($enabled)) { | ||
continue; | ||
} | ||
|
||
$visibility = 1; | ||
if ($visibility && isset($extrafields->attributes[$this->table_element]['list'][$key])) { | ||
$visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1, 1, '1'); | ||
$visibility = dol_eval($extrafields->attributes[$this->table_element]['list'][$key], 1); | ||
} | ||
|
||
$perms = 1; | ||
if ($perms && isset($extrafields->attributes[$this->table_element]['perms'][$key])) { | ||
$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1, 1, '1'); | ||
$perms = dol_eval($extrafields->attributes[$this->table_element]['perms'][$key], 1); | ||
} | ||
|
||
if (($mode == 'create') && abs($visibility) != 1 && abs($visibility) != 3) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
function ipInRange($ip, $range) { | ||
if (strpos($range, '/') == false) { | ||
$range .= '/32'; | ||
} | ||
// $range is in IP/CIDR format eg | ||
list($range, $netmask) = explode('/', $range, 2); | ||
$range_decimal = ip2long($range); | ||
$ip_decimal = ip2long($ip); | ||
$wildcard_decimal = pow(2, (32 - $netmask)) - 1; | ||
$netmask_decimal = ~ $wildcard_decimal; | ||
return (($ip_decimal & $netmask_decimal) == ($range_decimal & $netmask_decimal)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.