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
16c48d52
Commit
16c48d52
authored
12 years ago
by
Peter Rotich
Browse files
Options
Downloads
Patches
Plain Diff
Drop unused/uninitialized var - groupby
parent
d0bef5e0
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/ajax.tickets.php
+29
-29
29 additions, 29 deletions
include/ajax.tickets.php
with
29 additions
and
29 deletions
include/ajax.tickets.php
+
29
−
29
View file @
16c48d52
...
@@ -19,7 +19,7 @@ if(!defined('INCLUDE_DIR')) die('403');
...
@@ -19,7 +19,7 @@ if(!defined('INCLUDE_DIR')) die('403');
include_once
(
INCLUDE_DIR
.
'class.ticket.php'
);
include_once
(
INCLUDE_DIR
.
'class.ticket.php'
);
class
TicketsAjaxAPI
extends
AjaxController
{
class
TicketsAjaxAPI
extends
AjaxController
{
function
lookup
()
{
function
lookup
()
{
global
$thisstaff
;
global
$thisstaff
;
...
@@ -33,12 +33,12 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -33,12 +33,12 @@ class TicketsAjaxAPI extends AjaxController {
$sql
=
'SELECT DISTINCT ticketID, email'
$sql
=
'SELECT DISTINCT ticketID, email'
.
' FROM '
.
TICKET_TABLE
.
' FROM '
.
TICKET_TABLE
.
' WHERE ticketID LIKE \''
.
db_input
(
$_REQUEST
[
'q'
],
false
)
.
'%\''
;
.
' WHERE ticketID LIKE \''
.
db_input
(
$_REQUEST
[
'q'
],
false
)
.
'%\''
;
$sql
.
=
' AND ( staff_id='
.
db_input
(
$thisstaff
->
getId
());
$sql
.
=
' AND ( staff_id='
.
db_input
(
$thisstaff
->
getId
());
if
((
$teams
=
$thisstaff
->
getTeams
())
&&
count
(
array_filter
(
$teams
)))
if
((
$teams
=
$thisstaff
->
getTeams
())
&&
count
(
array_filter
(
$teams
)))
$sql
.
=
' OR team_id IN('
.
implode
(
','
,
db_input
(
array_filter
(
$teams
)))
.
')'
;
$sql
.
=
' OR team_id IN('
.
implode
(
','
,
db_input
(
array_filter
(
$teams
)))
.
')'
;
if
(
!
$thisstaff
->
showAssignedOnly
()
&&
(
$depts
=
$thisstaff
->
getDepts
()))
if
(
!
$thisstaff
->
showAssignedOnly
()
&&
(
$depts
=
$thisstaff
->
getDepts
()))
$sql
.
=
' OR dept_id IN ('
.
implode
(
','
,
db_input
(
$depts
))
.
')'
;
$sql
.
=
' OR dept_id IN ('
.
implode
(
','
,
db_input
(
$depts
))
.
')'
;
...
@@ -63,7 +63,7 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -63,7 +63,7 @@ class TicketsAjaxAPI extends AjaxController {
$sql
=
'SELECT email, count(ticket_id) as tickets '
$sql
=
'SELECT email, count(ticket_id) as tickets '
.
' FROM '
.
TICKET_TABLE
.
' FROM '
.
TICKET_TABLE
.
' WHERE email LIKE \'%'
.
db_input
(
strtolower
(
$_REQUEST
[
'q'
]),
false
)
.
'%\' '
;
.
' WHERE email LIKE \'%'
.
db_input
(
strtolower
(
$_REQUEST
[
'q'
]),
false
)
.
'%\' '
;
$sql
.
=
' AND ( staff_id='
.
db_input
(
$thisstaff
->
getId
());
$sql
.
=
' AND ( staff_id='
.
db_input
(
$thisstaff
->
getId
());
if
((
$teams
=
$thisstaff
->
getTeams
())
&&
count
(
array_filter
(
$teams
)))
if
((
$teams
=
$thisstaff
->
getTeams
())
&&
count
(
array_filter
(
$teams
)))
...
@@ -71,11 +71,11 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -71,11 +71,11 @@ class TicketsAjaxAPI extends AjaxController {
if
(
!
$thisstaff
->
showAssignedOnly
()
&&
(
$depts
=
$thisstaff
->
getDepts
()))
if
(
!
$thisstaff
->
showAssignedOnly
()
&&
(
$depts
=
$thisstaff
->
getDepts
()))
$sql
.
=
' OR dept_id IN ('
.
implode
(
','
,
db_input
(
$depts
))
.
')'
;
$sql
.
=
' OR dept_id IN ('
.
implode
(
','
,
db_input
(
$depts
))
.
')'
;
$sql
.
=
' ) '
$sql
.
=
' ) '
.
' GROUP BY email '
.
' GROUP BY email '
.
' ORDER BY created LIMIT '
.
$limit
;
.
' ORDER BY created LIMIT '
.
$limit
;
if
((
$res
=
db_query
(
$sql
))
&&
db_num_rows
(
$res
))
{
if
((
$res
=
db_query
(
$sql
))
&&
db_num_rows
(
$res
))
{
while
(
list
(
$email
,
$count
)
=
db_fetch_row
(
$res
))
while
(
list
(
$email
,
$count
)
=
db_fetch_row
(
$res
))
$tickets
[]
=
array
(
'email'
=>
$email
,
'value'
=>
$email
,
'info'
=>
"
$email
(
$count
)"
);
$tickets
[]
=
array
(
'email'
=>
$email
,
'value'
=>
$email
,
'info'
=>
"
$email
(
$count
)"
);
...
@@ -86,7 +86,7 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -86,7 +86,7 @@ class TicketsAjaxAPI extends AjaxController {
function
search
()
{
function
search
()
{
global
$thisstaff
,
$cfg
;
global
$thisstaff
,
$cfg
;
$result
=
array
();
$result
=
array
();
$select
=
'SELECT count( DISTINCT ticket.ticket_id) as tickets '
;
$select
=
'SELECT count( DISTINCT ticket.ticket_id) as tickets '
;
$from
=
' FROM '
.
TICKET_TABLE
.
' ticket '
;
$from
=
' FROM '
.
TICKET_TABLE
.
' ticket '
;
...
@@ -127,7 +127,7 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -127,7 +127,7 @@ class TicketsAjaxAPI extends AjaxController {
break
;
break
;
}
}
//Assignee
//Assignee
if
(
isset
(
$_REQUEST
[
'assignee'
])
&&
strcasecmp
(
$_REQUEST
[
'status'
],
'closed'
))
{
if
(
isset
(
$_REQUEST
[
'assignee'
])
&&
strcasecmp
(
$_REQUEST
[
'status'
],
'closed'
))
{
$id
=
preg_replace
(
"/[^0-9]/"
,
""
,
$_REQUEST
[
'assignee'
]);
$id
=
preg_replace
(
"/[^0-9]/"
,
""
,
$_REQUEST
[
'assignee'
]);
$assignee
=
$_REQUEST
[
'assignee'
];
$assignee
=
$_REQUEST
[
'assignee'
];
...
@@ -147,16 +147,16 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -147,16 +147,16 @@ class TicketsAjaxAPI extends AjaxController {
$where
.
=
' OR ticket.status="closed" '
;
$where
.
=
' OR ticket.status="closed" '
;
$where
.
=
' ) '
;
$where
.
=
' ) '
;
}
elseif
(
$_REQUEST
[
'staffId'
])
{
}
elseif
(
$_REQUEST
[
'staffId'
])
{
$where
.
=
' AND (ticket.staff_id='
.
db_input
(
$_REQUEST
[
'staffId'
])
.
' AND ticket.status="closed") '
;
$where
.
=
' AND (ticket.staff_id='
.
db_input
(
$_REQUEST
[
'staffId'
])
.
' AND ticket.status="closed") '
;
}
}
//dates
//dates
$startTime
=
(
$_REQUEST
[
'startDate'
]
&&
(
strlen
(
$_REQUEST
[
'startDate'
])
>=
8
))
?
strtotime
(
$_REQUEST
[
'startDate'
])
:
0
;
$startTime
=
(
$_REQUEST
[
'startDate'
]
&&
(
strlen
(
$_REQUEST
[
'startDate'
])
>=
8
))
?
strtotime
(
$_REQUEST
[
'startDate'
])
:
0
;
$endTime
=
(
$_REQUEST
[
'endDate'
]
&&
(
strlen
(
$_REQUEST
[
'endDate'
])
>=
8
))
?
strtotime
(
$_REQUEST
[
'endDate'
])
:
0
;
$endTime
=
(
$_REQUEST
[
'endDate'
]
&&
(
strlen
(
$_REQUEST
[
'endDate'
])
>=
8
))
?
strtotime
(
$_REQUEST
[
'endDate'
])
:
0
;
if
(
(
$startTime
&&
$startTime
>
time
())
or
(
$startTime
>
$endTime
&&
$endTime
>
0
))
if
(
(
$startTime
&&
$startTime
>
time
())
or
(
$startTime
>
$endTime
&&
$endTime
>
0
))
$startTime
=
$endTime
=
0
;
$startTime
=
$endTime
=
0
;
if
(
$startTime
)
if
(
$startTime
)
$where
.
=
' AND ticket.created>=FROM_UNIXTIME('
.
$startTime
.
')'
;
$where
.
=
' AND ticket.created>=FROM_UNIXTIME('
.
$startTime
.
')'
;
...
@@ -166,17 +166,17 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -166,17 +166,17 @@ class TicketsAjaxAPI extends AjaxController {
//Query
//Query
if
(
$_REQUEST
[
'query'
])
{
if
(
$_REQUEST
[
'query'
])
{
$queryterm
=
db_real_escape
(
$_REQUEST
[
'query'
],
false
);
$queryterm
=
db_real_escape
(
$_REQUEST
[
'query'
],
false
);
$from
.
=
' LEFT JOIN '
.
TICKET_THREAD_TABLE
.
' thread ON (ticket.ticket_id=thread.ticket_id )'
;
$from
.
=
' LEFT JOIN '
.
TICKET_THREAD_TABLE
.
' thread ON (ticket.ticket_id=thread.ticket_id )'
;
$where
.
=
" AND ( ticket.email LIKE '%
$queryterm
%'"
$where
.
=
" AND ( ticket.email LIKE '%
$queryterm
%'"
.
" OR ticket.name LIKE '%
$queryterm
%'"
.
" OR ticket.name LIKE '%
$queryterm
%'"
.
" OR ticket.subject LIKE '%
$queryterm
%'"
.
" OR ticket.subject LIKE '%
$queryterm
%'"
.
" OR thread.title LIKE '%
$queryterm
%'"
.
" OR thread.title LIKE '%
$queryterm
%'"
.
" OR thread.body LIKE '%
$queryterm
%'"
.
" OR thread.body LIKE '%
$queryterm
%'"
.
' )'
;
.
' )'
;
}
}
$sql
=
"
$select
$from
$where
$groupby
"
;
$sql
=
"
$select
$from
$where
"
;
if
((
$tickets
=
db_result
(
db_query
(
$sql
))))
{
if
((
$tickets
=
db_result
(
db_query
(
$sql
))))
{
$result
[
'success'
]
=
sprintf
(
"Search criteria matched %s - <a href='tickets.php?%s'>view</a>"
,
$result
[
'success'
]
=
sprintf
(
"Search criteria matched %s - <a href='tickets.php?%s'>view</a>"
,
(
$tickets
>
1
?
"
$tickets
tickets"
:
"
$tickets
ticket"
),
(
$tickets
>
1
?
"
$tickets
tickets"
:
"
$tickets
ticket"
),
...
@@ -184,26 +184,26 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -184,26 +184,26 @@ class TicketsAjaxAPI extends AjaxController {
}
else
{
}
else
{
$result
[
'fail'
]
=
'No tickets found matching your search criteria.'
;
$result
[
'fail'
]
=
'No tickets found matching your search criteria.'
;
}
}
return
$this
->
json_encode
(
$result
);
return
$this
->
json_encode
(
$result
);
}
}
function
acquireLock
(
$tid
)
{
function
acquireLock
(
$tid
)
{
global
$cfg
,
$thisstaff
;
global
$cfg
,
$thisstaff
;
if
(
!
$tid
or
!
is_numeric
(
$tid
)
or
!
$thisstaff
or
!
$cfg
or
!
$cfg
->
getLockTime
())
if
(
!
$tid
or
!
is_numeric
(
$tid
)
or
!
$thisstaff
or
!
$cfg
or
!
$cfg
->
getLockTime
())
return
0
;
return
0
;
if
(
!
(
$ticket
=
Ticket
::
lookup
(
$tid
))
||
!
$ticket
->
checkStaffAccess
(
$thisstaff
))
if
(
!
(
$ticket
=
Ticket
::
lookup
(
$tid
))
||
!
$ticket
->
checkStaffAccess
(
$thisstaff
))
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
false
,
'msg'
=>
'Lock denied!'
));
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
false
,
'msg'
=>
'Lock denied!'
));
//is the ticket already locked?
//is the ticket already locked?
if
(
$ticket
->
isLocked
()
&&
(
$lock
=
$ticket
->
getLock
())
&&
!
$lock
->
isExpired
())
{
if
(
$ticket
->
isLocked
()
&&
(
$lock
=
$ticket
->
getLock
())
&&
!
$lock
->
isExpired
())
{
/*Note: Ticket->acquireLock does the same logic...but we need it here since we need to know who owns the lock up front*/
/*Note: Ticket->acquireLock does the same logic...but we need it here since we need to know who owns the lock up front*/
//Ticket is locked by someone else.??
//Ticket is locked by someone else.??
if
(
$lock
->
getStaffId
()
!=
$thisstaff
->
getId
())
if
(
$lock
->
getStaffId
()
!=
$thisstaff
->
getId
())
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
false
,
'msg'
=>
'Unable to acquire lock.'
));
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
false
,
'msg'
=>
'Unable to acquire lock.'
));
//Ticket already locked by staff...try renewing it.
//Ticket already locked by staff...try renewing it.
$lock
->
renew
();
//New clock baby!
$lock
->
renew
();
//New clock baby!
}
elseif
(
!
(
$lock
=
$ticket
->
acquireLock
(
$thisstaff
->
getId
(),
$cfg
->
getLockTime
())))
{
}
elseif
(
!
(
$lock
=
$ticket
->
acquireLock
(
$thisstaff
->
getId
(),
$cfg
->
getLockTime
())))
{
...
@@ -220,17 +220,17 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -220,17 +220,17 @@ class TicketsAjaxAPI extends AjaxController {
if
(
!
$id
or
!
is_numeric
(
$id
)
or
!
$thisstaff
)
if
(
!
$id
or
!
is_numeric
(
$id
)
or
!
$thisstaff
)
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
true
));
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
true
));
$lock
=
TicketLock
::
lookup
(
$id
);
$lock
=
TicketLock
::
lookup
(
$id
);
if
(
!
$lock
||
!
$lock
->
getStaffId
()
||
$lock
->
isExpired
())
//Said lock doesn't exist or is is expired
if
(
!
$lock
||
!
$lock
->
getStaffId
()
||
$lock
->
isExpired
())
//Said lock doesn't exist or is is expired
return
self
::
acquireLock
(
$tid
);
//acquire the lock
return
self
::
acquireLock
(
$tid
);
//acquire the lock
if
(
$lock
->
getStaffId
()
!=
$thisstaff
->
getId
())
//user doesn't own the lock anymore??? sorry...try to next time.
if
(
$lock
->
getStaffId
()
!=
$thisstaff
->
getId
())
//user doesn't own the lock anymore??? sorry...try to next time.
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
false
));
//Give up...
return
$this
->
json_encode
(
array
(
'id'
=>
0
,
'retry'
=>
false
));
//Give up...
//Renew the lock.
//Renew the lock.
$lock
->
renew
();
//Failure here is not an issue since the lock is not expired yet.. client need to check time!
$lock
->
renew
();
//Failure here is not an issue since the lock is not expired yet.. client need to check time!
return
$this
->
json_encode
(
array
(
'id'
=>
$lock
->
getId
(),
'time'
=>
$lock
->
getTime
()));
return
$this
->
json_encode
(
array
(
'id'
=>
$lock
->
getId
(),
'time'
=>
$lock
->
getTime
()));
}
}
...
@@ -238,12 +238,12 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -238,12 +238,12 @@ class TicketsAjaxAPI extends AjaxController {
global
$thisstaff
;
global
$thisstaff
;
if
(
$id
&&
is_numeric
(
$id
)){
//Lock Id provided!
if
(
$id
&&
is_numeric
(
$id
)){
//Lock Id provided!
$lock
=
TicketLock
::
lookup
(
$id
,
$tid
);
$lock
=
TicketLock
::
lookup
(
$id
,
$tid
);
//Already gone?
//Already gone?
if
(
!
$lock
||
!
$lock
->
getStaffId
()
||
$lock
->
isExpired
())
//Said lock doesn't exist or is is expired
if
(
!
$lock
||
!
$lock
->
getStaffId
()
||
$lock
->
isExpired
())
//Said lock doesn't exist or is is expired
return
1
;
return
1
;
//make sure the user actually owns the lock before releasing it.
//make sure the user actually owns the lock before releasing it.
return
(
$lock
->
getStaffId
()
==
$thisstaff
->
getId
()
&&
$lock
->
release
())
?
1
:
0
;
return
(
$lock
->
getStaffId
()
==
$thisstaff
->
getId
()
&&
$lock
->
release
())
?
1
:
0
;
...
@@ -269,7 +269,7 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -269,7 +269,7 @@ class TicketsAjaxAPI extends AjaxController {
$warn
.
=
' <span class="Icon lockedTicket">Ticket is locked by '
.
$lock
->
getStaffName
()
.
'</span>'
;
$warn
.
=
' <span class="Icon lockedTicket">Ticket is locked by '
.
$lock
->
getStaffName
()
.
'</span>'
;
elseif
(
$ticket
->
isOverdue
())
elseif
(
$ticket
->
isOverdue
())
$warn
.
=
' <span class="Icon overdueTicket">Marked overdue!</span>'
;
$warn
.
=
' <span class="Icon overdueTicket">Marked overdue!</span>'
;
ob_start
();
ob_start
();
echo
sprintf
(
echo
sprintf
(
'<div style="width:500px; padding: 2px 2px 0 5px;">
'<div style="width:500px; padding: 2px 2px 0 5px;">
...
@@ -353,7 +353,7 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -353,7 +353,7 @@ class TicketsAjaxAPI extends AjaxController {
$options
[]
=
array
(
'action'
=>
'Thread ('
.
$ticket
->
getThreadCount
()
.
')'
,
'url'
=>
"tickets.php?id=
$tid
"
);
$options
[]
=
array
(
'action'
=>
'Thread ('
.
$ticket
->
getThreadCount
()
.
')'
,
'url'
=>
"tickets.php?id=
$tid
"
);
if
(
$ticket
->
getNumNotes
())
if
(
$ticket
->
getNumNotes
())
$options
[]
=
array
(
'action'
=>
'Notes ('
.
$ticket
->
getNumNotes
()
.
')'
,
'url'
=>
"tickets.php?id=
$tid
#notes"
);
$options
[]
=
array
(
'action'
=>
'Notes ('
.
$ticket
->
getNumNotes
()
.
')'
,
'url'
=>
"tickets.php?id=
$tid
#notes"
);
if
(
$ticket
->
isOpen
())
if
(
$ticket
->
isOpen
())
$options
[]
=
array
(
'action'
=>
'Reply'
,
'url'
=>
"tickets.php?id=
$tid
#reply"
);
$options
[]
=
array
(
'action'
=>
'Reply'
,
'url'
=>
"tickets.php?id=
$tid
#reply"
);
...
...
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