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
32565aa9
Commit
32565aa9
authored
10 years ago
by
Jared Hancock
Browse files
Options
Downloads
Patches
Plain Diff
Send advanced search criteria to backend
parent
36b7312e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/ajax.tickets.php
+26
-17
26 additions, 17 deletions
include/ajax.tickets.php
include/class.search.php
+8
-2
8 additions, 2 deletions
include/class.search.php
with
34 additions
and
19 deletions
include/ajax.tickets.php
+
26
−
17
View file @
32565aa9
...
@@ -101,6 +101,8 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -101,6 +101,8 @@ class TicketsAjaxAPI extends AjaxController {
global
$thisstaff
,
$cfg
,
$ost
;
global
$thisstaff
,
$cfg
,
$ost
;
$result
=
array
();
$result
=
array
();
$criteria
=
array
();
$select
=
'SELECT ticket.ticket_id'
;
$select
=
'SELECT ticket.ticket_id'
;
$from
=
' FROM '
.
TICKET_TABLE
.
' ticket
$from
=
' FROM '
.
TICKET_TABLE
.
' ticket
LEFT JOIN '
.
TICKET_STATUS_TABLE
.
' status
LEFT JOIN '
.
TICKET_STATUS_TABLE
.
' status
...
@@ -119,29 +121,38 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -119,29 +121,38 @@ class TicketsAjaxAPI extends AjaxController {
$where
.
=
' ) '
;
$where
.
=
' ) '
;
//Department
//Department
if
(
$req
[
'deptId'
])
if
(
$req
[
'deptId'
])
{
$where
.
=
' AND ticket.dept_id='
.
db_input
(
$req
[
'deptId'
]);
$where
.
=
' AND ticket.dept_id='
.
db_input
(
$req
[
'deptId'
]);
$criteria
[
'dept_id'
]
=
$req
[
'deptId'
];
}
//Help topic
//Help topic
if
(
$req
[
'topicId'
])
if
(
$req
[
'topicId'
])
{
$where
.
=
' AND ticket.topic_id='
.
db_input
(
$req
[
'topicId'
]);
$where
.
=
' AND ticket.topic_id='
.
db_input
(
$req
[
'topicId'
]);
$criteria
[
'topic_id'
]
=
$req
[
'topicId'
];
}
//Status
//Status
switch
(
strtolower
(
$req
[
'status'
]))
{
switch
(
strtolower
(
$req
[
'status'
]))
{
case
'open'
:
case
'open'
:
$where
.
=
' AND status.state="open" '
;
$where
.
=
' AND status.state="open" '
;
$criteria
[
'status'
]
=
'open'
;
break
;
break
;
case
'answered'
:
case
'answered'
:
$where
.
=
' AND status.state="open" AND ticket.isanswered=1 '
;
$where
.
=
' AND status.state="open" AND ticket.isanswered=1 '
;
$criteria
+=
array
(
'status'
=>
'open'
,
'isanswered'
=>
1
);
break
;
break
;
case
'overdue'
:
case
'overdue'
:
$where
.
=
' AND status.state="open" AND ticket.isoverdue=1 '
;
$where
.
=
' AND status.state="open" AND ticket.isoverdue=1 '
;
$criteria
+=
array
(
'status'
=>
'open'
,
'isoverdue'
=>
1
);
break
;
break
;
case
'resolved'
:
case
'resolved'
:
$where
.
=
' AND status.state="resolved" '
;
$where
.
=
' AND status.state="resolved" '
;
$criteria
+=
array
(
'status'
=>
'resolved'
,
'isoverdue'
=>
1
);
break
;
break
;
case
'closed'
:
case
'closed'
:
$where
.
=
' AND status.state="closed" '
;
$where
.
=
' AND status.state="closed" '
;
$criteria
[
'status'
]
=
'closed'
;
break
;
break
;
}
}
...
@@ -150,10 +161,14 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -150,10 +161,14 @@ class TicketsAjaxAPI extends AjaxController {
$id
=
preg_replace
(
"/[^0-9]/"
,
""
,
$req
[
'assignee'
]);
$id
=
preg_replace
(
"/[^0-9]/"
,
""
,
$req
[
'assignee'
]);
$assignee
=
$req
[
'assignee'
];
$assignee
=
$req
[
'assignee'
];
$where
.
=
' AND ( ( status.state="open" '
;
$where
.
=
' AND ( ( status.state="open" '
;
if
(
$assignee
[
0
]
==
't'
)
if
(
$assignee
[
0
]
==
't'
)
{
$where
.
=
' AND ticket.team_id='
.
db_input
(
$id
);
$where
.
=
' AND ticket.team_id='
.
db_input
(
$id
);
elseif
(
$assignee
[
0
]
==
's'
)
$criteria
[
'team_id'
]
=
$id
;
}
elseif
(
$assignee
[
0
]
==
's'
)
{
$where
.
=
' AND ticket.staff_id='
.
db_input
(
$id
);
$where
.
=
' AND ticket.staff_id='
.
db_input
(
$id
);
$criteria
[
'staff_id'
]
=
$id
;
}
elseif
(
is_numeric
(
$id
))
elseif
(
is_numeric
(
$id
))
$where
.
=
' AND ticket.staff_id='
.
db_input
(
$id
);
$where
.
=
' AND ticket.staff_id='
.
db_input
(
$id
);
...
@@ -177,28 +192,22 @@ class TicketsAjaxAPI extends AjaxController {
...
@@ -177,28 +192,22 @@ class TicketsAjaxAPI extends AjaxController {
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
.
')'
;
$criteria
[
'created__gte'
]
=
$startTime
;
}
if
(
$endTime
)
if
(
$endTime
)
{
$where
.
=
' AND ticket.created<=FROM_UNIXTIME('
.
$endTime
.
')'
;
$where
.
=
' AND ticket.created<=FROM_UNIXTIME('
.
$endTime
.
')'
;
$criteria
[
'created__lte'
]
=
$startTime
;
}
//Query
//Query
$joins
=
array
();
$joins
=
array
();
if
(
$req
[
'query'
])
{
if
(
$req
[
'query'
])
{
$queryterm
=
db_real_escape
(
$req
[
'query'
],
false
);
// Setup sets of joins and queries
// Setup sets of joins and queries
if
(
$s
=
$ost
->
searcher
)
if
(
$s
=
$ost
->
searcher
)
$ids
=
$s
->
find
(
$req
[
'query'
],
null
,
'Ticket'
);
return
$s
->
find
(
$req
[
'query'
],
$criteria
,
'Ticket'
);
if
(
!
$ids
)
return
array
();
$joins
[]
=
array
(
'from'
=>
''
,
'where'
=>
'ticket.ticket_id IN ('
.
implode
(
','
,
$ids
)
.
')'
);
}
}
// Dynamic fields
// Dynamic fields
...
...
This diff is collapsed.
Click to expand it.
include/class.search.php
+
8
−
2
View file @
32565aa9
...
@@ -291,8 +291,16 @@ class MysqlSearchBackend extends SearchBackend {
...
@@ -291,8 +291,16 @@ class MysqlSearchBackend extends SearchBackend {
case
'staff_id'
:
case
'staff_id'
:
case
'dept_id'
:
case
'dept_id'
:
case
'user_id'
:
case
'user_id'
:
case
'isanswered'
:
case
'isoverdue'
:
$where
[]
=
sprintf
(
'A1.%s = %s'
,
$name
,
db_input
(
$value
));
$where
[]
=
sprintf
(
'A1.%s = %s'
,
$name
,
db_input
(
$value
));
break
;
break
;
case
'created__gte'
:
$where
[]
=
sprintf
(
'A1.created >= %s'
,
db_input
(
$value
));
break
;
case
'created__lte'
:
$where
[]
=
sprintf
(
'A1.created <= %s'
,
db_input
(
$value
));
break
;
case
'email'
:
case
'email'
:
case
'org_id'
:
case
'org_id'
:
case
'form_id'
:
case
'form_id'
:
...
@@ -357,8 +365,6 @@ class MysqlSearchBackend extends SearchBackend {
...
@@ -357,8 +365,6 @@ class MysqlSearchBackend extends SearchBackend {
* not index in the _search table and add it to the index.
* not index in the _search table and add it to the index.
*/
*/
function
IndexOldStuff
()
{
function
IndexOldStuff
()
{
print
'Indexing old stuff!'
;
$class
=
get_class
();
$class
=
get_class
();
$auto_create
=
function
(
$db_error
)
use
(
$class
)
{
$auto_create
=
function
(
$db_error
)
use
(
$class
)
{
...
...
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