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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
3d7752ca
Commit
3d7752ca
authored
14 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Qual: Simplify canvas code
parent
a918f3bf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
htdocs/core/class/canvas.class.php
+18
-27
18 additions, 27 deletions
htdocs/core/class/canvas.class.php
htdocs/societe/class/societe.class.php
+6
-5
6 additions, 5 deletions
htdocs/societe/class/societe.class.php
htdocs/societe/soc.php
+2
-0
2 additions, 0 deletions
htdocs/societe/soc.php
with
26 additions
and
32 deletions
htdocs/core/class/canvas.class.php
+
18
−
27
View file @
3d7752ca
...
@@ -72,42 +72,33 @@ class Canvas
...
@@ -72,42 +72,33 @@ class Canvas
/**
/**
* Initialize properties like ->control, ->control->object, ->template_dir
* Initialize properties: ->targetmodule, ->card, ->canvas
* @param module Name of target module (thirdparty, ...)
* and MVC properties: ->control (Controller), ->control->object (Model), ->template_dir (View)
* @param card Type of card (ex: card, info, ...)
* @param module Name of target module (thirdparty, contact, ...)
* @param canvas Name of canvas (ex: mycanvas@mymodule)
* @param card Type of card (ex: card, info, contactcard, ...)
* @param canvas Name of canvas (ex: mycanvas, default, or mycanvas@myexternalmodule)
*/
*/
function
getCanvas
(
$module
,
$card
,
$canvas
)
function
getCanvas
(
$module
,
$card
,
$canvas
)
{
{
global
$conf
,
$langs
;
global
$conf
,
$langs
;
$error
=
''
;
$error
=
''
;
$this
->
card
=
$card
;
// Define this->canvas, this->targetmodule, this->aliasmodule, targetmodule, childmodule
// Set properties with value specific to dolibarr core: this->targetmodule, this->card, this->canvas
$this
->
targetmodule
=
$module
;
$this
->
card
=
$card
;
$this
->
canvas
=
$canvas
;
$this
->
canvas
=
$canvas
;
$this
->
targetmodule
=
$this
->
aliasmodule
=
$module
;
$dirmodule
=
$module
;
// Correct values if canvas is into an external module
if
(
preg_match
(
'/^([^@]+)@([^@]+)$/i'
,
$canvas
,
$regs
))
if
(
preg_match
(
'/^([^@]+)@([^@]+)$/i'
,
$canvas
,
$regs
))
{
{
$this
->
canvas
=
$regs
[
1
];
$this
->
canvas
=
$regs
[
1
];
$
this
->
alias
module
=
$regs
[
2
];
$
dir
module
=
$regs
[
2
];
}
}
$targetmodule
=
$this
->
targetmodule
;
$childmodule
=
$this
->
aliasmodule
;
// For compatibility
// For compatibility
if
(
$targetmodule
==
'thirdparty'
)
{
$targetmodule
=
'societe'
;
}
if
(
$dirmodule
==
'thirdparty'
)
{
$dirmodule
=
'societe'
;
}
if
(
$childmodule
==
'thirdparty'
)
{
$childmodule
=
'societe'
;
$this
->
aliasmodule
=
'societe'
;
}
if
(
$targetmodule
==
'contact'
)
{
$targetmodule
=
'societe'
;
}
if
(
$childmodule
==
'contact'
)
{
$childmodule
=
'societe'
;
}
/*print 'canvas='.$this->canvas.'<br>';
print 'childmodule='.$childmodule.' targetmodule='.$targetmodule.'<br>';
print 'this->aliasmodule='.$this->aliasmodule.' this->targetmodule='.$this->targetmodule.'<br>';
print 'childmodule='.$conf->$childmodule->enabled.' targetmodule='.$conf->$targetmodule->enabled.'<br>';*/
if
(
!
$conf
->
$childmodule
->
enabled
||
!
$conf
->
$targetmodule
->
enabled
)
accessforbidden
();
$controlclassfile
=
dol_buildpath
(
'/'
.
$
this
->
alias
module
.
'/canvas/'
.
$this
->
canvas
.
'/actions_'
.
$this
->
card
.
'_'
.
$this
->
canvas
.
'.class.php'
);
$controlclassfile
=
dol_buildpath
(
'/'
.
$
dir
module
.
'/canvas/'
.
$this
->
canvas
.
'/actions_'
.
$this
->
card
.
'_'
.
$this
->
canvas
.
'.class.php'
);
if
(
file_exists
(
$controlclassfile
))
if
(
file_exists
(
$controlclassfile
))
{
{
// Include actions class (controller)
// Include actions class (controller)
...
@@ -119,7 +110,7 @@ class Canvas
...
@@ -119,7 +110,7 @@ class Canvas
}
}
// TODO Dao should be declared and used by controller or templates when required only
// TODO Dao should be declared and used by controller or templates when required only
$modelclassfile
=
dol_buildpath
(
'/'
.
$
this
->
alias
module
.
'/canvas/'
.
$this
->
canvas
.
'/dao_'
.
$this
->
targetmodule
.
'_'
.
$this
->
canvas
.
'.class.php'
);
$modelclassfile
=
dol_buildpath
(
'/'
.
$
dir
module
.
'/canvas/'
.
$this
->
canvas
.
'/dao_'
.
$this
->
targetmodule
.
'_'
.
$this
->
canvas
.
'.class.php'
);
if
(
file_exists
(
$modelclassfile
))
if
(
file_exists
(
$modelclassfile
))
{
{
// Include dataservice class (model)
// Include dataservice class (model)
...
@@ -132,16 +123,16 @@ class Canvas
...
@@ -132,16 +123,16 @@ class Canvas
// Include specific library
// Include specific library
// TODO Specific libraries must be included by files that need them only, so by actions and/or dao files.
// TODO Specific libraries must be included by files that need them only, so by actions and/or dao files.
$libfile
=
dol_buildpath
(
'/'
.
$
this
->
alias
module
.
'/lib/'
.
$
this
->
alias
module
.
'.lib.php'
);
$libfile
=
dol_buildpath
(
'/'
.
$
dir
module
.
'/lib/'
.
$
dir
module
.
'.lib.php'
);
if
(
file_exists
(
$libfile
))
require_once
(
$libfile
);
if
(
file_exists
(
$libfile
))
require_once
(
$libfile
);
// Template dir
// Template dir
$this
->
template_dir
=
dol_buildpath
(
'/'
.
$
this
->
alias
module
.
'/canvas/'
.
$this
->
canvas
.
'/tpl/'
);
$this
->
template_dir
=
dol_buildpath
(
'/'
.
$
dir
module
.
'/canvas/'
.
$this
->
canvas
.
'/tpl/'
);
if
(
!
is_dir
(
$this
->
template_dir
))
if
(
!
is_dir
(
$this
->
template_dir
))
{
{
$this
->
template_dir
=
''
;
$this
->
template_dir
=
''
;
}
}
//print '/'.$
this->alias
module.'/canvas/'.$this->canvas.'/tpl/';
//print '/'.$
dir
module.'/canvas/'.$this->canvas.'/tpl/';
//print 'template_dir='.$this->template_dir.'<br>';
//print 'template_dir='.$this->template_dir.'<br>';
return
1
;
return
1
;
...
...
This diff is collapsed.
Click to expand it.
htdocs/societe/class/societe.class.php
+
6
−
5
View file @
3d7752ca
...
@@ -173,9 +173,12 @@ class Societe extends CommonObject
...
@@ -173,9 +173,12 @@ class Societe extends CommonObject
global
$langs
,
$conf
;
global
$langs
,
$conf
;
// Clean parameters
// Clean parameters
if
(
empty
(
$this
->
status
))
$this
->
status
=
0
;
$this
->
name
=
$this
->
name
?
trim
(
$this
->
name
)
:
trim
(
$this
->
nom
);
$this
->
name
=
$this
->
name
?
trim
(
$this
->
name
)
:
trim
(
$this
->
nom
);
if
(
!
empty
(
$conf
->
global
->
MAIN_FIRST_TO_UPPER
))
$this
->
name
=
ucwords
(
$this
->
name
);
if
(
!
empty
(
$conf
->
global
->
MAIN_FIRST_TO_UPPER
))
$this
->
name
=
ucwords
(
$this
->
name
);
$this
->
nom
=
$this
->
name
;
// For backward compatibility
$this
->
nom
=
$this
->
name
;
// For backward compatibility
if
(
empty
(
$this
->
client
))
$this
->
client
=
0
;
if
(
empty
(
$this
->
fournisseur
))
$this
->
fournisseur
=
0
;
dol_syslog
(
"Societe::create "
.
$this
->
name
);
dol_syslog
(
"Societe::create "
.
$this
->
name
);
...
@@ -186,8 +189,8 @@ class Societe extends CommonObject
...
@@ -186,8 +189,8 @@ class Societe extends CommonObject
$this
->
error
=
$langs
->
trans
(
"ErrorBadEMail"
,
$this
->
email
);
$this
->
error
=
$langs
->
trans
(
"ErrorBadEMail"
,
$this
->
email
);
return
-
1
;
return
-
1
;
}
}
if
(
empty
(
$this
->
client
))
$this
->
client
=
0
;
if
(
empty
(
$this
->
fournisseur
))
$this
->
fournisseur
=
0
;
$now
=
dol_now
()
;
$this
->
db
->
begin
();
$this
->
db
->
begin
();
...
@@ -195,8 +198,6 @@ class Societe extends CommonObject
...
@@ -195,8 +198,6 @@ class Societe extends CommonObject
if
(
$this
->
code_client
==
-
1
)
$this
->
get_codeclient
(
$this
->
prefix_comm
,
0
);
if
(
$this
->
code_client
==
-
1
)
$this
->
get_codeclient
(
$this
->
prefix_comm
,
0
);
if
(
$this
->
code_fournisseur
==
-
1
)
$this
->
get_codefournisseur
(
$this
->
prefix_comm
,
1
);
if
(
$this
->
code_fournisseur
==
-
1
)
$this
->
get_codefournisseur
(
$this
->
prefix_comm
,
1
);
$now
=
dol_now
();
// Check more parameters
// Check more parameters
$result
=
$this
->
verify
();
$result
=
$this
->
verify
();
...
...
This diff is collapsed.
Click to expand it.
htdocs/societe/soc.php
+
2
−
0
View file @
3d7752ca
...
@@ -56,6 +56,8 @@ $soc = new Societe($db);
...
@@ -56,6 +56,8 @@ $soc = new Societe($db);
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
if
(
!
empty
(
$socid
))
$soc
->
getCanvas
(
$socid
);
if
(
!
empty
(
$socid
))
$soc
->
getCanvas
(
$socid
);
$canvas
=
(
!
empty
(
$soc
->
canvas
)
?
$soc
->
canvas
:
GETPOST
(
"canvas"
));
$canvas
=
(
!
empty
(
$soc
->
canvas
)
?
$soc
->
canvas
:
GETPOST
(
"canvas"
));
if
(
!
empty
(
$canvas
))
if
(
!
empty
(
$canvas
))
{
{
require_once
(
DOL_DOCUMENT_ROOT
.
"/core/class/canvas.class.php"
);
require_once
(
DOL_DOCUMENT_ROOT
.
"/core/class/canvas.class.php"
);
...
...
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