Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
docker
osticket
Commits
23e2aca9
Commit
23e2aca9
authored
11 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add collaborator(s) utils to ticket class
parent
bedd46e3
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.ticket.php
+78
-1
78 additions, 1 deletion
include/class.ticket.php
with
78 additions
and
1 deletion
include/class.ticket.php
+
78
−
1
View file @
23e2aca9
...
@@ -32,6 +32,8 @@ include_once(INCLUDE_DIR.'class.sla.php');
...
@@ -32,6 +32,8 @@ include_once(INCLUDE_DIR.'class.sla.php');
include_once
(
INCLUDE_DIR
.
'class.canned.php'
);
include_once
(
INCLUDE_DIR
.
'class.canned.php'
);
require_once
(
INCLUDE_DIR
.
'class.dynamic_forms.php'
);
require_once
(
INCLUDE_DIR
.
'class.dynamic_forms.php'
);
require_once
(
INCLUDE_DIR
.
'class.user.php'
);
require_once
(
INCLUDE_DIR
.
'class.user.php'
);
require_once
(
INCLUDE_DIR
.
'class.collaborator.php'
);
class
Ticket
{
class
Ticket
{
...
@@ -64,7 +66,7 @@ class Ticket {
...
@@ -64,7 +66,7 @@ class Ticket {
$sql
=
'SELECT ticket.*, lock_id, dept_name '
$sql
=
'SELECT ticket.*, lock_id, dept_name '
.
' ,IF(sla.id IS NULL, NULL, DATE_ADD(ticket.created, INTERVAL sla.grace_period HOUR)) as sla_duedate '
.
' ,IF(sla.id IS NULL, NULL, DATE_ADD(ticket.created, INTERVAL sla.grace_period HOUR)) as sla_duedate '
.
' ,count(attach.attach_id) as attachments '
.
' ,count(attach.attach_id) as attachments
, count(collab.id) as collaborators
'
.
' FROM '
.
TICKET_TABLE
.
' ticket '
.
' FROM '
.
TICKET_TABLE
.
' ticket '
.
' LEFT JOIN '
.
DEPT_TABLE
.
' dept ON (ticket.dept_id=dept.dept_id) '
.
' LEFT JOIN '
.
DEPT_TABLE
.
' dept ON (ticket.dept_id=dept.dept_id) '
.
' LEFT JOIN '
.
SLA_TABLE
.
' sla ON (ticket.sla_id=sla.id AND sla.isactive=1) '
.
' LEFT JOIN '
.
SLA_TABLE
.
' sla ON (ticket.sla_id=sla.id AND sla.isactive=1) '
...
@@ -72,6 +74,8 @@ class Ticket {
...
@@ -72,6 +74,8 @@ class Ticket {
.
'ticket.ticket_id=tlock.ticket_id AND tlock.expire>NOW()) '
.
'ticket.ticket_id=tlock.ticket_id AND tlock.expire>NOW()) '
.
' LEFT JOIN '
.
TICKET_ATTACHMENT_TABLE
.
' attach ON ('
.
' LEFT JOIN '
.
TICKET_ATTACHMENT_TABLE
.
' attach ON ('
.
'ticket.ticket_id=attach.ticket_id) '
.
'ticket.ticket_id=attach.ticket_id) '
.
' LEFT JOIN '
.
TICKET_COLLABORATOR_TABLE
.
' collab ON ('
.
'ticket.ticket_id=collab.ticket_id) '
.
' WHERE ticket.ticket_id='
.
db_input
(
$id
)
.
' WHERE ticket.ticket_id='
.
db_input
(
$id
)
.
' GROUP BY ticket.ticket_id'
;
.
' GROUP BY ticket.ticket_id'
;
...
@@ -98,6 +102,7 @@ class Ticket {
...
@@ -98,6 +102,7 @@ class Ticket {
$this
->
stats
=
null
;
$this
->
stats
=
null
;
$this
->
topic
=
null
;
$this
->
topic
=
null
;
$this
->
thread
=
null
;
$this
->
thread
=
null
;
$this
->
collaborators
=
null
;
//REQUIRED: Preload thread obj - checked on lookup!
//REQUIRED: Preload thread obj - checked on lookup!
$this
->
getThread
();
$this
->
getThread
();
...
@@ -567,7 +572,79 @@ class Ticket {
...
@@ -567,7 +572,79 @@ class Ticket {
return
$this
->
getThread
()
->
getEntries
(
$type
,
$order
);
return
$this
->
getThread
()
->
getEntries
(
$type
,
$order
);
}
}
//Collaborators
function
getNumCollaborators
()
{
return
$this
->
ht
[
'collaborators'
];
}
function
getActiveCollaborators
()
{
return
$this
->
getCollaborators
(
array
(
'isactive'
=>
1
));
}
function
getCollaborators
(
$criteria
=
array
())
{
if
(
$criteria
)
return
Collaborator
::
forTicket
(
$this
->
getId
(),
$criteria
);
if
(
!
$this
->
collaborators
&&
$this
->
getNumCollaborators
())
$this
->
collaborators
=
Collaborator
::
forTicket
(
$this
->
getId
());
return
$this
->
collaborators
;
}
function
addCollaborator
(
$user
,
&
$errors
)
{
if
(
!
$user
)
return
null
;
$vars
=
array
(
'ticketId'
=>
$this
->
getId
(),
'userId'
=>
$user
->
getId
());
if
(
!
(
$c
=
Collaborator
::
add
(
$vars
,
$errors
)))
return
null
;
$this
->
ht
[
'collaborators'
]
+=
1
;
$this
->
collaborators
=
null
;
return
$c
;
}
//XXX: Ugly for now
function
updateCollaborators
(
$vars
,
&
$errors
)
{
//Deletes
if
(
$vars
[
'del'
]
&&
(
$ids
=
array_filter
(
$vars
[
'del'
])))
{
$sql
=
'DELETE FROM '
.
TICKET_COLLABORATOR_TABLE
.
' WHERE ticket_id='
.
db_input
(
$this
->
getId
())
.
' AND id IN('
.
implode
(
','
,
db_input
(
$ids
))
.
')'
;
if
(
db_query
(
$sql
))
$this
->
ht
[
'collaborators'
]
-=
db_affected_rows
();
}
//statuses
$cids
=
null
;
if
(
$vars
[
'cid'
]
&&
(
$cids
=
array_filter
(
$vars
[
'cid'
])))
{
$sql
=
'UPDATE '
.
TICKET_COLLABORATOR_TABLE
.
' SET updated=NOW(), isactive=1 '
.
' WHERE ticket_id='
.
db_input
(
$this
->
getId
())
.
' AND id IN('
.
implode
(
','
,
db_input
(
$cids
))
.
')'
;
db_query
(
$sql
);
}
$sql
=
'UPDATE '
.
TICKET_COLLABORATOR_TABLE
.
' SET updated=NOW(), isactive=0 '
.
' WHERE ticket_id='
.
db_input
(
$this
->
getId
());
if
(
$cids
)
$sql
.
=
' AND id NOT IN('
.
implode
(
','
,
db_input
(
$cids
))
.
')'
;
db_query
(
$sql
);
$this
->
collaborators
=
null
;
return
true
;
}
/* -------------------- Setters --------------------- */
/* -------------------- Setters --------------------- */
function
setLastMsgId
(
$msgid
)
{
function
setLastMsgId
(
$msgid
)
{
...
...
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