Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
90fdc29d
Commit
90fdc29d
authored
10 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix restore compatibility
parent
c5269eb0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
htdocs/core/class/extrafields.class.php
+24
-8
24 additions, 8 deletions
htdocs/core/class/extrafields.class.php
with
24 additions
and
8 deletions
htdocs/core/class/extrafields.class.php
+
24
−
8
View file @
90fdc29d
...
...
@@ -100,7 +100,7 @@ class ExtraFields
* @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
* @param int $pos Position of attribute
* @param int $size Size/length of attribute
* @param string $elementtype Element type ('member', 'product', '
compan
y', ...)
* @param string $elementtype Element type ('member', 'product', '
thirdpart
y', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param string $default_value Defaulted value
...
...
@@ -113,6 +113,8 @@ class ExtraFields
if
(
empty
(
$attrname
))
return
-
1
;
if
(
empty
(
$label
))
return
-
1
;
if
(
$elementtype
==
'thirdparty'
)
$elementtype
=
'societe'
;
// Create field into database except for separator type which is not stored in database
if
(
$type
!=
'separate'
)
{
...
...
@@ -145,7 +147,7 @@ class ExtraFields
* @param string $attrname code of attribute
* @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour')
* @param int $length Size/length of attribute
* @param string $elementtype Element type ('member', 'product', '
compan
y', 'contact', ...)
* @param string $elementtype Element type ('member', 'product', '
thirdpart
y', 'contact', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param string $default_value Default value for field
...
...
@@ -155,6 +157,8 @@ class ExtraFields
*/
private
function
create
(
$attrname
,
$type
=
'varchar'
,
$length
=
255
,
$elementtype
=
'member'
,
$unique
=
0
,
$required
=
0
,
$default_value
=
''
,
$param
=
''
)
{
if
(
$elementtype
==
'thirdparty'
)
$elementtype
=
'societe'
;
$table
=
$elementtype
.
'_extrafields'
;
if
(
!
empty
(
$attrname
)
&&
preg_match
(
"/^\w[a-zA-Z0-9_]*$/"
,
$attrname
)
&&
!
is_numeric
(
$attrname
))
...
...
@@ -216,7 +220,7 @@ class ExtraFields
* @param int $type Type of attribute ('int', 'text', 'varchar', 'date', 'datehour', 'float')
* @param int $pos Position of attribute
* @param int $size Size/length of attribute
* @param string $elementtype Element type ('member', 'product', '
compan
y', ...)
* @param string $elementtype Element type ('member', 'product', '
thirdpart
y', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param array||string $param Params for field (ex for select list : array('options' => array(value'=>'label of option')) )
...
...
@@ -227,6 +231,8 @@ class ExtraFields
{
global
$conf
;
if
(
$elementtype
==
'thirdparty'
)
$elementtype
=
'societe'
;
// Clean parameters
if
(
empty
(
$pos
))
$pos
=
0
;
...
...
@@ -277,11 +283,13 @@ class ExtraFields
* Delete an optional attribute
*
* @param string $attrname Code of attribute to delete
* @param string $elementtype Element type ('member', 'product', '
compan
y', 'contact', ...)
* @param string $elementtype Element type ('member', 'product', '
thirdpart
y', 'contact', ...)
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
*/
function
delete
(
$attrname
,
$elementtype
=
'member'
)
{
if
(
$elementtype
==
'thirdparty'
)
$elementtype
=
'societe'
;
$table
=
$elementtype
.
'_extrafields'
;
if
(
!
empty
(
$attrname
)
&&
preg_match
(
"/^\w[a-zA-Z0-9-_]*$/"
,
$attrname
))
...
...
@@ -307,13 +315,15 @@ class ExtraFields
* Delete description of an optional attribute
*
* @param string $attrname Code of attribute to delete
* @param string $elementtype Element type ('member', 'product', '
compan
y', ...)
* @param string $elementtype Element type ('member', 'product', '
thirdpart
y', ...)
* @return int < 0 if KO, 0 if nothing is done, 1 if OK
*/
private
function
delete_label
(
$attrname
,
$elementtype
=
'member'
)
{
global
$conf
;
if
(
$elementtype
==
'thirdparty'
)
$elementtype
=
'societe'
;
if
(
isset
(
$attrname
)
&&
$attrname
!=
''
&&
preg_match
(
"/^\w[a-zA-Z0-9-_]*$/"
,
$attrname
))
{
$sql
=
"DELETE FROM "
.
MAIN_DB_PREFIX
.
"extrafields"
;
...
...
@@ -347,7 +357,7 @@ class ExtraFields
* @param string $label Label of attribute
* @param string $type Type of attribute
* @param int $length Length of attribute
* @param string $elementtype Element type ('member', 'product', '
compan
y', 'contact', ...)
* @param string $elementtype Element type ('member', 'product', '
thirdpart
y', 'contact', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param int $pos Position of attribute
...
...
@@ -357,6 +367,8 @@ class ExtraFields
*/
function
update
(
$attrname
,
$label
,
$type
,
$length
,
$elementtype
,
$unique
=
0
,
$required
=
0
,
$pos
=
0
,
$param
=
''
,
$alwayseditable
=
0
)
{
if
(
$elementtype
==
'thirdparty'
)
$elementtype
=
'societe'
;
$table
=
$elementtype
.
'_extrafields'
;
if
(
isset
(
$attrname
)
&&
$attrname
!=
''
&&
preg_match
(
"/^\w[a-zA-Z0-9-_]*$/"
,
$attrname
))
...
...
@@ -433,7 +445,7 @@ class ExtraFields
* @param string $label Label of attribute
* @param string $type Type of attribute
* @param int $size Length of attribute
* @param string $elementtype Element type ('member', 'product', '
compan
y', ...)
* @param string $elementtype Element type ('member', 'product', '
thirdpart
y', ...)
* @param int $unique Is field unique or not
* @param int $required Is field required or not
* @param int $pos Position of attribute
...
...
@@ -446,6 +458,8 @@ class ExtraFields
global
$conf
;
dol_syslog
(
get_class
(
$this
)
.
"::update_label "
.
$attrname
.
", "
.
$label
.
", "
.
$type
.
", "
.
$size
.
", "
.
$elementtype
.
", "
.
$unique
.
", "
.
$required
);
if
(
$elementtype
==
'thirdparty'
)
$elementtype
=
'societe'
;
if
(
isset
(
$attrname
)
&&
$attrname
!=
''
&&
preg_match
(
"/^\w[a-zA-Z0-9-_]*$/"
,
$attrname
))
{
$this
->
db
->
begin
();
...
...
@@ -513,7 +527,7 @@ class ExtraFields
/**
* Load array this->attribute_xxx like attribute_label, attribute_type, ...
*
* @param string $elementtype Type of element ('adherent', 'commande',
societe
', 'facture', 'propal', 'product', ...)
* @param string $elementtype Type of element ('adherent', 'commande',
thirdparty
', 'facture', 'propal', 'product', ...)
* @param boolean $forceload Force load of extra fields whatever is option MAIN_EXTRAFIELDS_DISABLED
* @return array Array of attributes for all extra fields
*/
...
...
@@ -521,6 +535,8 @@ class ExtraFields
{
global
$conf
;
if
(
$elementtype
==
'thirdparty'
)
$elementtype
=
'societe'
;
$array_name_label
=
array
();
// For avoid conflicts with external modules
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment