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
340fb4e6
Commit
340fb4e6
authored
11 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Reactor how template group and email are fetched.
parent
6fd12376
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
+84
-125
84 additions, 125 deletions
include/class.ticket.php
with
84 additions
and
125 deletions
include/class.ticket.php
+
84
−
125
View file @
340fb4e6
...
@@ -385,9 +385,11 @@ class Ticket {
...
@@ -385,9 +385,11 @@ class Ticket {
}
}
function
getDept
()
{
function
getDept
()
{
global
$cfg
;
if
(
!
$this
->
dept
&&
$this
->
getDeptId
())
if
(
!
$this
->
dept
)
$this
->
dept
=
Dept
::
lookup
(
$this
->
getDeptId
());
if
(
!
(
$this
->
dept
=
Dept
::
lookup
(
$this
->
getDeptId
())))
$this
->
dept
=
$cfg
->
getDefaultDept
();
return
$this
->
dept
;
return
$this
->
dept
;
}
}
...
@@ -832,22 +834,20 @@ class Ticket {
...
@@ -832,22 +834,20 @@ class Ticket {
/* ------ SEND OUT NEW TICKET AUTORESP && ALERTS ----------*/
/* ------ SEND OUT NEW TICKET AUTORESP && ALERTS ----------*/
$this
->
reload
();
//get the new goodies.
$this
->
reload
();
//get the new goodies.
$dept
=
$this
->
getDept
();
if
(
!
$cfg
||
!
(
$dept
=
$this
->
getDept
())
if
(
!
$dept
||
!
(
$tpl
=
$dept
->
getTemplate
()))
||
!
(
$tpl
=
$dept
->
getTemplate
())
$tpl
=
$cfg
->
getDefaultTemplate
();
||
!
(
$email
=
$dept
->
getAutoRespEmail
()))
{
return
false
;
//bail out...missing stuff.
if
(
!
$tpl
)
return
false
;
//bail out...missing stuff.
}
if
(
!
$dept
||
!
(
$email
=
$dept
->
getAutoRespEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
$options
=
array
(
$options
=
array
(
'inreplyto'
=>
$message
->
getEmailMessageId
(),
'inreplyto'
=>
$message
->
getEmailMessageId
(),
'references'
=>
$message
->
getEmailReferences
());
'references'
=>
$message
->
getEmailReferences
());
//Send auto response - if enabled.
//Send auto response - if enabled.
if
(
$autorespond
&&
$email
&&
$cfg
->
autoRespONNewTicket
()
if
(
$autorespond
&&
$cfg
->
autoRespONNewTicket
()
&&
$dept
->
autoRespONNewTicket
()
&&
$dept
->
autoRespONNewTicket
()
&&
(
$msg
=
$tpl
->
getAutoRespMsgTemplate
()))
{
&&
(
$msg
=
$tpl
->
getAutoRespMsgTemplate
()))
{
...
@@ -863,12 +863,10 @@ class Ticket {
...
@@ -863,12 +863,10 @@ class Ticket {
null
,
$options
);
null
,
$options
);
}
}
if
(
!
(
$email
=
$cfg
->
getAlertEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
//Send alert to out sleepy & idle staff.
//Send alert to out sleepy & idle staff.
if
(
$alertstaff
&&
$email
if
(
$alertstaff
&&
$cfg
->
alertONNewTicket
()
&&
$cfg
->
alertONNewTicket
()
&&
(
$email
=
$cfg
->
getAlertEmail
())
&&
(
$msg
=
$tpl
->
getNewTicketAlertMsgTemplate
()))
{
&&
(
$msg
=
$tpl
->
getNewTicketAlertMsgTemplate
()))
{
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
array
(
'message'
=>
$message
));
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
array
(
'message'
=>
$message
));
...
@@ -912,18 +910,14 @@ class Ticket {
...
@@ -912,18 +910,14 @@ class Ticket {
$msg
=
sprintf
(
'Max open tickets (%d) reached for %s '
,
$cfg
->
getMaxOpenTickets
(),
$this
->
getEmail
());
$msg
=
sprintf
(
'Max open tickets (%d) reached for %s '
,
$cfg
->
getMaxOpenTickets
(),
$this
->
getEmail
());
$ost
->
logWarning
(
'Max. Open Tickets Limit ('
.
$this
->
getEmail
()
.
')'
,
$msg
);
$ost
->
logWarning
(
'Max. Open Tickets Limit ('
.
$this
->
getEmail
()
.
')'
,
$msg
);
if
(
!
$sendNotice
||
!
$cfg
->
sendOverLimitNotice
())
return
true
;
if
(
!
$sendNotice
||
!
$cfg
->
sendOverLimitNotice
())
return
true
;
//Send notice to user.
//Send notice to user.
$dept
=
$this
->
getDept
();
if
((
$dept
=
$this
->
getDept
())
&&
(
$tpl
=
$dept
->
getTemplate
())
if
(
!
$dept
||
!
(
$tpl
=
$dept
->
getTemplate
()))
&&
(
$msg
=
$tpl
->
getOverlimitMsgTemplate
())
$tpl
=
$cfg
->
getDefaultTemplate
();
&&
(
$email
=
$dept
->
getAutoRespEmail
()))
{
if
(
!
$dept
||
!
(
$email
=
$dept
->
getAutoRespEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
if
(
$tpl
&&
(
$msg
=
$tpl
->
getOverlimitMsgTemplate
())
&&
$email
)
{
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
array
(
'signature'
=>
(
$dept
&&
$dept
->
isPublic
())
?
$dept
->
getSignature
()
:
''
));
array
(
'signature'
=>
(
$dept
&&
$dept
->
isPublic
())
?
$dept
->
getSignature
()
:
''
));
...
@@ -971,18 +965,14 @@ class Ticket {
...
@@ -971,18 +965,14 @@ class Ticket {
if
(
!
$autorespond
||
!
$cfg
->
autoRespONNewMessage
())
return
;
//no autoresp or alerts.
if
(
!
$autorespond
||
!
$cfg
->
autoRespONNewMessage
())
return
;
//no autoresp or alerts.
$this
->
reload
();
$this
->
reload
();
$dept
=
$this
->
getDept
();
$email
=
$dept
->
getAutoRespEmail
();
if
(
!
$dept
||
!
(
$tpl
=
$dept
->
getTemplate
()))
$tpl
=
$cfg
->
getDefaultTemplate
();
if
(
!
$dept
||
!
(
$email
=
$dept
->
getAutoRespEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
//If enabled...send confirmation to user. ( New Message AutoResponse)
//If enabled...send confirmation to user. ( New Message AutoResponse)
if
(
$email
&&
$tpl
&&
(
$msg
=
$tpl
->
getNewMessageAutorepMsgTemplate
()))
{
if
(
$email
&&
(
$tpl
=
$dept
->
getTemplate
())
&&
(
$msg
=
$tpl
->
getNewMessageAutorepMsgTemplate
()))
{
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
array
(
'signature'
=>
(
$dept
&&
$dept
->
isPublic
())
?
$dept
->
getSignature
()
:
''
));
array
(
'signature'
=>
(
$dept
&&
$dept
->
isPublic
())
?
$dept
->
getSignature
()
:
''
));
...
@@ -1022,14 +1012,10 @@ class Ticket {
...
@@ -1022,14 +1012,10 @@ class Ticket {
if
(
!
$alert
||
!
$cfg
->
alertONAssignment
())
return
true
;
//No alerts!
if
(
!
$alert
||
!
$cfg
->
alertONAssignment
())
return
true
;
//No alerts!
$dept
=
$this
->
getDept
();
$dept
=
$this
->
getDept
();
if
(
!
$dept
//Get template.
||
!
(
$tpl
=
$dept
->
getTemplate
())
if
(
!
$dept
||
!
(
$tpl
=
$dept
->
getTemplate
()))
||
!
(
$email
=
$cfg
->
getAlertEmail
()))
$tpl
=
$cfg
->
getDefaultTemplate
();
return
true
;
//Email to use!
if
(
!
(
$email
=
$cfg
->
getAlertEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
//recipients
//recipients
$recipients
=
array
();
$recipients
=
array
();
...
@@ -1044,7 +1030,7 @@ class Ticket {
...
@@ -1044,7 +1030,7 @@ class Ticket {
}
}
//Get the message template
//Get the message template
if
(
$email
&&
$recipients
&&
$tpl
&&
(
$msg
=
$tpl
->
getAssignedAlertMsgTemplate
()))
{
if
(
$recipients
&&
(
$msg
=
$tpl
->
getAssignedAlertMsgTemplate
()))
{
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
array
(
'comments'
=>
$comments
,
array
(
'comments'
=>
$comments
,
...
@@ -1076,20 +1062,15 @@ class Ticket {
...
@@ -1076,20 +1062,15 @@ class Ticket {
$whine
=
false
;
$whine
=
false
;
//check if we need to send alerts.
//check if we need to send alerts.
if
(
!
$whine
||
!
$cfg
->
alertONOverdueTicket
())
if
(
!
$whine
||
!
$cfg
->
alertONOverdueTicket
()
||
!
(
$dept
=
$this
->
getDept
()))
return
true
;
return
true
;
$dept
=
$this
->
getDept
();
//Get department-defined or default template.
if
(
!
$dept
||
!
(
$tpl
=
$dept
->
getTemplate
()))
$tpl
=
$cfg
->
getDefaultTemplate
();
//Email to use!
if
(
!
(
$email
=
$cfg
->
getAlertEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
//Get the message template
//Get the message template
if
(
$tpl
&&
(
$msg
=
$tpl
->
getOverdueAlertMsgTemplate
())
&&
$email
)
{
if
((
$tpl
=
$dept
->
getTemplate
())
&&
(
$msg
=
$tpl
->
getOverdueAlertMsgTemplate
())
&&
(
$email
=
$cfg
->
getAlertEmail
()))
{
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
array
(
'comments'
=>
$comments
));
array
(
'comments'
=>
$comments
));
...
@@ -1282,19 +1263,12 @@ class Ticket {
...
@@ -1282,19 +1263,12 @@ class Ticket {
$this
->
logEvent
(
'transferred'
);
$this
->
logEvent
(
'transferred'
);
//Send out alerts if enabled AND requested
//Send out alerts if enabled AND requested
if
(
!
$alert
||
!
$cfg
->
alertONTransfer
()
||
!
(
$dept
=
$this
->
getDept
()))
return
true
;
//no alerts!!
if
(
!
$alert
||
!
$cfg
->
alertONTransfer
()
||
!
(
$dept
=
$this
->
getDept
()))
return
true
;
//no alerts!!
//Get template.
if
((
$email
=
$cfg
->
getAlertEmail
())
if
(
!
(
$tpl
=
$dept
->
getTemplate
()))
&&
(
$tpl
=
$dept
->
getTemplate
())
$tpl
=
$cfg
->
getDefaultTemplate
();
&&
(
$msg
=
$tpl
->
getTransferAlertMsgTemplate
()))
{
//Email to use!
if
(
!
(
$email
=
$cfg
->
getAlertEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
//Get the message template
if
(
$tpl
&&
(
$msg
=
$tpl
->
getTransferAlertMsgTemplate
())
&&
$email
)
{
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
array
(
'comments'
=>
$comments
,
'staff'
=>
$thisstaff
));
array
(
'comments'
=>
$comments
,
'staff'
=>
$thisstaff
));
...
@@ -1442,17 +1416,22 @@ class Ticket {
...
@@ -1442,17 +1416,22 @@ class Ticket {
$dept
=
$this
->
getDept
();
$dept
=
$this
->
getDept
();
if
(
!
$dept
||
!
(
$tpl
=
$dept
->
getTemplate
()))
$tpl
=
$cfg
->
getDefaultTemplate
();
if
(
!
(
$email
=
$cfg
->
getAlertEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
$variables
=
array
(
'message'
=>
$message
,
'poster'
=>
(
$vars
[
'poster'
]
?
$vars
[
'poster'
]
:
$this
->
getName
())
);
$options
=
array
(
'inreplyto'
=>
$message
->
getEmailMessageId
(),
'references'
=>
$message
->
getEmailReferences
());
//If enabled...send alert to staff (New Message Alert)
//If enabled...send alert to staff (New Message Alert)
if
(
$cfg
->
alertONNewMessage
()
&&
$tpl
&&
$email
&&
(
$msg
=
$tpl
->
getNewMessageAlertMsgTemplate
()))
{
if
(
$cfg
->
alertONNewMessage
()
&&
(
$email
=
$cfg
->
getAlertEmail
())
&&
(
$tpl
=
$dept
->
getTemplate
())
&&
(
$msg
=
$tpl
->
getNewMessageAlertMsgTemplate
()))
{
$attachments
=
$message
->
getAttachments
();
$attachments
=
$message
->
getAttachments
();
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
array
(
'message'
=>
$message
)
);
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
$variables
);
//Build list of recipients and fire the alerts.
//Build list of recipients and fire the alerts.
$recipients
=
array
();
$recipients
=
array
();
...
@@ -1470,9 +1449,6 @@ class Ticket {
...
@@ -1470,9 +1449,6 @@ class Ticket {
$recipients
[]
=
$manager
;
$recipients
[]
=
$manager
;
$sentlist
=
array
();
//I know it sucks...but..it works.
$sentlist
=
array
();
//I know it sucks...but..it works.
$options
=
array
(
'inreplyto'
=>
$message
->
getEmailMessageId
(),
'references'
=>
$message
->
getEmailReferences
());
foreach
(
$recipients
as
$k
=>
$staff
)
{
foreach
(
$recipients
as
$k
=>
$staff
)
{
if
(
!
$staff
||
!
$staff
->
getEmail
()
||
!
$staff
->
isAvailable
()
||
in_array
(
$staff
->
getEmail
(),
$sentlist
))
continue
;
if
(
!
$staff
||
!
$staff
->
getEmail
()
||
!
$staff
->
isAvailable
()
||
in_array
(
$staff
->
getEmail
(),
$sentlist
))
continue
;
$alert
=
str_replace
(
'%{recipient}'
,
$staff
->
getFirstName
(),
$msg
[
'body'
]);
$alert
=
str_replace
(
'%{recipient}'
,
$staff
->
getFirstName
(),
$msg
[
'body'
]);
...
@@ -1510,13 +1486,9 @@ class Ticket {
...
@@ -1510,13 +1486,9 @@ class Ticket {
$dept
=
$this
->
getDept
();
$dept
=
$this
->
getDept
();
if
(
!
(
$tpl
=
$dept
->
getTemplate
()))
if
((
$email
=
$dept
->
getEmail
())
$tpl
=
$cfg
->
getDefaultTemplate
();
&&
(
$tpl
=
$dept
->
getTemplate
())
&&
(
$msg
=
$tpl
->
getAutoReplyMsgTemplate
()))
{
if
(
!
$dept
||
!
(
$email
=
$dept
->
getEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
if
(
$tpl
&&
(
$msg
=
$tpl
->
getAutoReplyMsgTemplate
())
&&
$email
)
{
if
(
$dept
&&
$dept
->
isPublic
())
if
(
$dept
&&
$dept
->
isPublic
())
$signature
=
$dept
->
getSignature
();
$signature
=
$dept
->
getSignature
();
...
@@ -1561,41 +1533,37 @@ class Ticket {
...
@@ -1561,41 +1533,37 @@ class Ticket {
$this
->
setStatus
(
$vars
[
'reply_ticket_status'
]);
$this
->
setStatus
(
$vars
[
'reply_ticket_status'
]);
$this
->
onResponse
();
//do house cleaning..
$this
->
onResponse
();
//do house cleaning..
$this
->
reload
();
/* email the user?? - if disabled - the bail out */
/* email the user?? - if disabled - the bail out */
if
(
!
$alert
)
return
$response
;
if
(
!
$alert
)
return
$response
;
$dept
=
$this
->
getDept
();
$dept
=
$this
->
getDept
();
if
(
!
(
$tpl
=
$dept
->
getTemplate
()))
if
(
$thisstaff
&&
$vars
[
'signature'
]
==
'mine'
)
$tpl
=
$cfg
->
getDefaultTemplate
();
$signature
=
$thisstaff
->
getSignature
();
elseif
(
$vars
[
'signature'
]
==
'dept'
&&
$dept
&&
$dept
->
isPublic
())
if
(
!
$dept
||
!
(
$email
=
$dept
->
getEmail
()))
$signature
=
$dept
->
getSignature
();
$email
=
$cfg
->
getDefaultEmail
();
else
$signature
=
''
;
if
(
$tpl
&&
(
$msg
=
$tpl
->
getReplyMsgTemplate
())
&&
$email
)
{
if
(
$thisstaff
&&
$vars
[
'signature'
]
==
'mine'
)
$variables
=
array
(
$signature
=
$thisstaff
->
getSignature
();
'response'
=>
$response
,
elseif
(
$vars
[
'signature'
]
==
'dept'
&&
$dept
&&
$dept
->
isPublic
())
'signature'
=>
$signature
,
$signature
=
$dept
->
getSignature
();
'staff'
=>
$thisstaff
,
else
'poster'
=>
$thisstaff
);
$signature
=
''
;
$options
=
array
(
'inreplyto'
=>
$response
->
getEmailMessageId
(),
'references'
=>
$response
->
getEmailReferences
());
//Set attachments if emailing.
if
((
$email
=
$dept
->
getEmail
())
$attachments
=
$cfg
->
emailAttachments
()
?
$response
->
getAttachments
()
:
array
();
&&
(
$tpl
=
$dept
->
getTemplate
())
&&
(
$msg
=
$tpl
->
getReplyMsgTemplate
()))
{
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
$msg
=
$this
->
replaceVars
(
$msg
->
asArray
(),
$variables
);
array
(
'response'
=>
$response
,
'signature'
=>
$signature
,
'staff'
=>
$thisstaff
));
if
(
$cfg
->
stripQuotedReply
()
&&
(
$tag
=
$cfg
->
getReplySeparator
()))
if
(
$cfg
->
stripQuotedReply
()
&&
(
$tag
=
$cfg
->
getReplySeparator
()))
$msg
[
'body'
]
=
"<p style=
\"
display:none
\"
>
$tag
<p>"
.
$msg
[
'body'
];
$msg
[
'body'
]
=
"<p style=
\"
display:none
\"
>
$tag
<p>"
.
$msg
[
'body'
];
$attachments
=
$cfg
->
emailAttachments
()
?
$response
->
getAttachments
()
:
array
();
$options
=
array
(
'inreplyto'
=>
$response
->
getEmailMessageId
(),
'references'
=>
$response
->
getEmailReferences
());
//TODO: setup 5 param (options... e.g mid trackable on replies)
$email
->
send
(
$this
->
getEmail
(),
$msg
[
'subj'
],
$msg
[
'body'
],
$attachments
,
$email
->
send
(
$this
->
getEmail
(),
$msg
[
'subj'
],
$msg
[
'body'
],
$attachments
,
$options
);
$options
);
}
}
...
@@ -1673,14 +1641,9 @@ class Ticket {
...
@@ -1673,14 +1641,9 @@ class Ticket {
if
(
!
$alert
||
!
$cfg
->
alertONNewNote
()
||
!
(
$dept
=
$this
->
getDept
()))
if
(
!
$alert
||
!
$cfg
->
alertONNewNote
()
||
!
(
$dept
=
$this
->
getDept
()))
return
$note
;
return
$note
;
if
(
!
(
$tpl
=
$dept
->
getTemplate
()))
if
((
$email
=
$cfg
->
getAlertEmail
())
$tpl
=
$cfg
->
getDefaultTemplate
();
&&
(
$tpl
=
$dept
->
getTemplate
())
&&
(
$msg
=
$tpl
->
getNoteAlertMsgTemplate
()))
{
if
(
!
(
$email
=
$cfg
->
getAlertEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
if
(
$tpl
&&
(
$msg
=
$tpl
->
getNoteAlertMsgTemplate
())
&&
$email
)
{
$attachments
=
$note
->
getAttachments
();
$attachments
=
$note
->
getAttachments
();
...
@@ -2278,19 +2241,15 @@ class Ticket {
...
@@ -2278,19 +2241,15 @@ class Ticket {
$ticket
->
reload
();
$ticket
->
reload
();
if
(
!
$cfg
->
notifyONNewStaffTicket
()
||
!
isset
(
$vars
[
'alertuser'
]))
if
(
!
$cfg
->
notifyONNewStaffTicket
()
||
!
isset
(
$vars
[
'alertuser'
])
||
!
(
$dept
=
$ticket
->
getDept
()))
return
$ticket
;
//No alerts.
return
$ticket
;
//No alerts.
//Send Notice to user --- if requested AND enabled!!
//Send Notice to user --- if requested AND enabled!!
if
((
$tpl
=
$dept
->
getTemplate
())
$dept
=
$ticket
->
getDept
();
&&
(
$msg
=
$tpl
->
getNewTicketNoticeMsgTemplate
())
if
(
!
$dept
||
!
(
$tpl
=
$dept
->
getTemplate
()))
&&
(
$email
=
$dept
->
getEmail
()))
{
$tpl
=
$cfg
->
getDefaultTemplate
();
if
(
!
$dept
||
!
(
$email
=
$dept
->
getEmail
()))
$email
=
$cfg
->
getDefaultEmail
();
if
(
$tpl
&&
(
$msg
=
$tpl
->
getNewTicketNoticeMsgTemplate
())
&&
$email
)
{
$message
=
$vars
[
'message'
];
$message
=
$vars
[
'message'
];
if
(
$response
)
{
if
(
$response
)
{
...
...
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