Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
osticket
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
f1825c63
Commit
f1825c63
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Add new ticket thread class. (Note, Message & Response)
parent
61451f54
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class.thread.php
+222
-0
222 additions, 0 deletions
include/class.thread.php
with
222 additions
and
0 deletions
include/class.thread.php
0 → 100644
+
222
−
0
View file @
f1825c63
<?php
/*********************************************************************
class.thread.php
Ticket thread
TODO: move thread related logic here from class.ticket.php
Peter Rotich <peter@osticket.com>
Copyright (c) 2006-2012 osTicket
http://www.osticket.com
Released under the GNU General Public License WITHOUT ANY WARRANTY.
See LICENSE.TXT for details.
vim: expandtab sw=4 ts=4 sts=4:
**********************************************************************/
include_once
(
INCLUDE_DIR
.
'class.ticket.php'
);
Class
ThreadEntry
{
var
$id
;
var
$ht
;
var
$staff
;
var
$ticket
;
function
ThreadEntry
(
$id
,
$type
=
''
,
$ticketId
=
0
)
{
$this
->
load
(
$id
,
$type
,
$ticketId
);
}
function
load
(
$id
=
0
,
$type
=
''
,
$ticketId
=
0
)
{
if
(
!
$id
&&
!
(
$id
=
$this
->
getId
()))
return
false
;
$sql
=
'SELECT thread.* '
.
' ,count(DISTINCT attach.attach_id) as attachments '
.
' FROM '
.
TICKET_THREAD_TABLE
.
' thread '
.
' LEFT JOIN '
.
TICKET_ATTACHMENT_TABLE
.
' attach
ON (thread.ticket_id=attach.ticket_id
AND thread.id=attach.ref_id
AND thread.thread_type=attach.ref_type) '
.
' WHERE thread.id='
.
db_input
(
$id
);
if
(
$type
)
$sql
.
=
' AND thread.thread_type='
.
db_input
(
$type
);
if
(
$ticketId
)
$sql
.
=
' AND thread.ticket_id='
.
db_input
(
$ticketId
);
$sql
.
=
' GROUP BY thread.id '
;
if
(
!
(
$res
=
db_query
(
$sql
))
||
!
db_num_rows
(
$res
))
return
false
;
$this
->
ht
=
db_fetch_array
(
$res
);
$this
->
id
=
$this
->
ht
[
'id'
];
$this
->
staff
=
$this
->
ticket
=
null
;
return
true
;
}
function
reload
()
{
return
$this
->
load
();
}
function
getId
()
{
return
$this
->
id
;
}
function
getPid
()
{
return
$this
->
ht
[
'pid'
];
}
function
getType
()
{
return
$this
->
ht
[
'thread_type'
];
}
function
getSource
()
{
return
$this
->
ht
[
'source'
];
}
function
getPoster
()
{
return
$this
->
ht
[
'poster'
];
}
function
getTitle
()
{
return
$this
->
ht
[
'title'
];
}
function
getBody
()
{
return
$this
->
ht
[
'body'
];
}
function
getCreateDate
()
{
return
$this
->
ht
[
'created'
];
}
function
getUpdateDate
()
{
return
$this
->
ht
[
'updated'
];
}
function
getNumAttachments
()
{
return
$this
->
ht
[
'attachments'
];
}
function
getTicketId
()
{
return
$this
->
ht
[
'ticket_id'
];
}
function
getTicket
()
{
if
(
!
$this
->
ticket
&&
$this
->
getTicketId
())
$this
->
ticket
=
Ticket
::
lookup
(
$this
->
getTicketId
());
return
$this
->
ticket
;
}
function
getStaffId
()
{
return
$this
->
ht
[
'staff_id'
];
}
function
getStaff
()
{
if
(
!
$this
->
staff
&&
$this
->
getStaffId
())
$this
->
staff
=
Staff
::
lookup
(
$this
->
getStaffId
());
return
$this
->
staff
;
}
/* variables */
function
asVar
()
{
return
$this
->
getBody
();
}
function
getVar
(
$tag
)
{
global
$cfg
;
if
(
$tag
&&
is_callable
(
array
(
$this
,
'get'
.
ucfirst
(
$tag
))))
return
call_user_func
(
array
(
$this
,
'get'
.
ucfirst
(
$tag
)));
switch
(
strtolower
(
$tag
))
{
case
'create_date'
:
return
Format
::
date
(
$cfg
->
getDateTimeFormat
(),
Misc
::
db2gmtime
(
$this
->
getCreateDate
()),
$cfg
->
getTZOffset
(),
$cfg
->
observeDaylightSaving
());
break
;
case
'update_date'
:
return
Format
::
date
(
$cfg
->
getDateTimeFormat
(),
Misc
::
db2gmtime
(
$this
->
getUpdateDate
()),
$cfg
->
getTZOffset
(),
$cfg
->
observeDaylightSaving
());
break
;
}
return
false
;
}
/* static calls */
function
_lookup
(
$id
,
$type
=
''
,
$tid
=
0
)
{
return
(
$id
&&
is_numeric
(
$id
)
&&
(
$e
=
new
ThreadEntry
(
$id
,
$type
,
$tid
))
&&
$e
->
getId
()
==
$id
)
?
$e
:
null
;
}
}
/* Message - Ticket thread entry of type message */
class
Message
extends
ThreadEntry
{
function
Message
(
$id
,
$ticketId
=
0
)
{
parent
::
ThreadEntry
(
$id
,
'M'
,
$ticketId
);
}
function
getSubject
()
{
return
$this
->
getTitle
();
}
function
lookup
(
$id
,
$tid
)
{
return
parent
::
_lookup
(
$id
,
'M'
,
$tid
);
}
}
/* Response - Ticket thread entry of type response */
class
Response
extends
ThreadEntry
{
function
Response
(
$id
,
$ticketId
=
0
)
{
parent
::
ThreadEntry
(
$id
,
'R'
,
$ticketId
);
}
function
getSubject
()
{
return
$this
->
getTitle
();
}
function
getRespondent
()
{
return
$this
->
getStaff
();
}
function
lookup
(
$id
,
$tid
)
{
return
parent
::
_lookup
(
$id
,
'R'
,
$tid
);
}
}
/* Note - Ticket thread entry of type note (Internal Note) */
class
Note
extends
ThreadEntry
{
function
Note
(
$id
,
$ticketId
=
0
)
{
parent
::
ThreadEntry
(
$id
,
'N'
,
$ticketId
);
}
function
getMessage
()
{
return
$this
->
getBody
();
}
function
lookup
(
$id
,
$tid
)
{
return
parent
::
_lookup
(
$id
,
'N'
,
$tid
);
}
}
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