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
ae8fea26
Commit
ae8fea26
authored
11 years ago
by
Cédric Salvador
Committed by
Raphaël Doursenaud
11 years ago
Browse files
Options
Downloads
Patches
Plain Diff
new attributes
parent
e8e37526
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
htdocs/install/mysql/tables/llx_links.sql
+3
-1
3 additions, 1 deletion
htdocs/install/mysql/tables/llx_links.sql
htdocs/link/class/link.class.php
+29
-10
29 additions, 10 deletions
htdocs/link/class/link.class.php
with
32 additions
and
11 deletions
htdocs/install/mysql/tables/llx_links.sql
+
3
−
1
View file @
ae8fea26
...
...
@@ -24,5 +24,7 @@ create table llx_links
entity
INTEGER
DEFAULT
1
NOT
NULL
,
-- multi company id
datea
DATETIME
NOT
NULL
,
-- date start
url
VARCHAR
(
255
)
NOT
NULL
,
-- link url
label
VARCHAR
(
255
)
NOT
NULL
-- link label
label
VARCHAR
(
255
)
NOT
NULL
,
-- link label
objecttype
VARCHAR
(
255
)
NOT
NULL
,
-- object type in Dolibarr
objectid
INTEGER
NOT
NULL
)
ENGINE
=
innodb
;
This diff is collapsed.
Click to expand it.
htdocs/link/class/link.class.php
+
29
−
10
View file @
ae8fea26
...
...
@@ -36,6 +36,8 @@ class Link extends CommonObject
public
$datea
;
public
$url
;
public
$label
;
public
$objecttype
;
public
$objectid
;
/**
* Constructor
...
...
@@ -83,10 +85,12 @@ class Link extends CommonObject
$this
->
db
->
begin
();
$sql
=
"INSERT INTO "
.
MAIN_DB_PREFIX
.
"links (entity, datea, url, label)"
;
$sql
=
"INSERT INTO "
.
MAIN_DB_PREFIX
.
"links (entity, datea, url, label
, objecttype, objectid
)"
;
$sql
.
=
" VALUES ('"
.
$conf
->
entity
.
"', '"
.
$this
->
db
->
idate
(
$this
->
datea
)
.
"'"
;
$sql
.
=
", '"
.
$this
->
db
->
escape
(
$this
->
url
)
.
"'"
;
$sql
.
=
", '"
.
$this
->
db
->
escape
(
$this
->
label
)
.
"')"
;
$sql
.
=
", '"
.
$this
->
db
->
escape
(
$this
->
label
)
.
"'"
;
$sql
.
=
", '"
.
$this
->
objecttype
.
"'"
;
$sql
.
=
", "
.
$this
->
objectid
.
")"
;
dol_syslog
(
get_class
(
$this
)
.
"::create sql="
.
$sql
);
$result
=
$this
->
db
->
query
(
$sql
);
...
...
@@ -174,8 +178,10 @@ class Link extends CommonObject
$sql
=
"UPDATE "
.
MAIN_DB_PREFIX
.
"links SET "
;
$sql
.
=
"entity = '"
.
$conf
->
entity
.
"'"
;
$sql
.
=
", datea = '"
.
$this
->
db
->
idate
(
dol_now
())
.
"'"
;
$sql
.
=
", url = '"
.
$this
->
db
->
escape
(
$this
->
url
)
.
"'"
;
$sql
.
=
", label = '"
.
$this
->
db
->
escape
(
$this
->
label
)
.
"'"
;
$sql
.
=
", url = '"
.
$this
->
db
->
escape
(
$this
->
url
)
.
"'"
;
$sql
.
=
", label = '"
.
$this
->
db
->
escape
(
$this
->
label
)
.
"'"
;
$sql
.
=
", objecttype = '"
.
$this
->
objecttype
.
"'"
;
$sql
.
=
", objectid = "
.
$this
->
objectid
;
$sql
.
=
" WHERE rowid = '"
.
$this
->
id
.
"'"
;
...
...
@@ -220,19 +226,30 @@ class Link extends CommonObject
/**
* Loads all links from database
* @return array of Link objects
* @param $links array of Link objects to fill
* @param $objecttype type of the associated object in dolibarr
* @param $objectid id of the associated object in dolibarr
* @return 1 if ok, 0 if no records, -1 if error
*
* */
public
function
fetchAll
()
public
function
fetchAll
(
&
$links
,
$objecttype
,
$objectid
,
$sortfield
=
null
,
$sortorder
=
null
)
{
$sql
=
"SELECT rowid, entity, datea, url, label FROM "
.
MAIN_DB_PREFIX
.
"links"
;
global
$conf
;
$sql
=
"SELECT rowid, entity, datea, url, label , objecttype, objectid FROM "
.
MAIN_DB_PREFIX
.
"links"
;
$sql
.
=
" WHERE objecttype = '"
.
$objecttype
.
"' AND objectid = "
.
$objectid
;
if
(
$conf
->
entity
!=
0
)
$sql
.
=
" AND entity = "
.
$conf
->
entity
;
if
(
$sortfield
)
{
if
(
empty
(
$sortorder
))
{
$sortorder
=
"ASC"
;
}
$sql
.
=
" ORDER BY "
.
$sortfield
.
" "
.
$sortorder
;
}
$resql
=
$this
->
db
->
query
(
$sql
);
dol_syslog
(
get_class
(
$this
)
.
"::fetchAll "
.
$sql
,
LOG_DEBUG
);
if
(
$resql
)
{
$num
=
$this
->
db
->
num_rows
(
$resql
);
dol_syslog
(
get_class
(
$this
)
.
"::fetchAll "
.
$num
.
"records"
,
LOG_DEBUG
);
if
(
$num
>
0
)
{
$links
=
array
();
while
(
$obj
=
$this
->
db
->
fetch_object
(
$resql
))
{
$link
=
new
Link
(
$db
);
$link
->
id
=
$obj
->
rowid
;
...
...
@@ -242,7 +259,7 @@ class Link extends CommonObject
$link
->
label
=
$obj
->
label
;
$links
[]
=
$link
;
}
return
$links
;
return
1
;
}
else
{
return
0
;
}
...
...
@@ -260,11 +277,13 @@ class Link extends CommonObject
* */
public
function
fetch
(
$rowid
=
null
)
{
global
$conf
;
if
(
empty
(
$rowid
))
{
$rowid
=
$this
->
id
;
}
$sql
=
"SELECT rowid, entity, datea, url, label FROM "
.
MAIN_DB_PREFIX
.
"links"
;
$sql
=
"SELECT rowid, entity, datea, url, label
, objecttype, objectid
FROM "
.
MAIN_DB_PREFIX
.
"links"
;
$sql
.
=
" WHERE rowid = "
.
$rowid
;
if
(
$conf
->
entity
!=
0
)
$sql
.
=
" AND entity = "
.
$conf
->
entity
;
$resql
=
$this
->
db
->
query
(
$sql
);
dol_syslog
(
get_class
(
$this
)
.
"::fetch "
.
$sql
,
LOG_DEBUG
);
if
(
$resql
)
{
...
...
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