line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::OptimalQuery::SavedSearches; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
573
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
3
|
no warnings qw( uninitialized ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
6
|
1
|
|
|
1
|
|
3
|
use CGI qw( escapeHTML ); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
7
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub process_request { |
9
|
0
|
|
|
0
|
0
|
|
my ($q,$dbh,$userid,$selfurl) = @_; |
10
|
|
|
|
|
|
|
|
11
|
0
|
0
|
|
|
|
|
if ($q->param('load') =~ /^(\d+)$/) { |
|
|
0
|
|
|
|
|
|
12
|
0
|
|
|
|
|
|
my $id = $1; |
13
|
0
|
|
|
|
|
|
my $oracleReadLen; |
14
|
0
|
0
|
|
|
|
|
if ($$dbh{Driver}{Name} eq 'Oracle') { |
15
|
0
|
|
|
|
|
|
($oracleReadLen) = $dbh->selectrow_array("SELECT max(dbms_lob.getlength(params)) FROM oq_saved_search WHERE user_id = ?", undef, $userid); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
local $dbh->{LongReadLen} = $oracleReadLen |
18
|
0
|
0
|
0
|
|
|
|
if $oracleReadLen && $oracleReadLen > $dbh->{LongReadLen}; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare("SELECT uri, params FROM oq_saved_search WHERE id=? AND user_id = ?"); |
21
|
0
|
|
|
|
|
|
$sth->execute($id, $userid); |
22
|
0
|
|
|
|
|
|
my ($uri, $params) = $sth->fetchrow_array(); |
23
|
|
|
|
|
|
|
|
24
|
0
|
0
|
|
|
|
|
if (! $uri) { |
25
|
0
|
|
|
|
|
|
print CGI::header("text/plain"), "saved search not found"; |
26
|
0
|
|
|
|
|
|
return undef; |
27
|
|
|
|
|
|
|
} else { |
28
|
0
|
|
|
|
|
|
my $stateArgs = ''; |
29
|
0
|
0
|
|
|
|
|
if ($params ne '') { |
30
|
0
|
|
|
|
|
|
$params = eval '{'.$params.'}'; |
31
|
0
|
|
|
|
|
|
$$params{module} = 'InteractiveQuery2'; |
32
|
0
|
0
|
|
|
|
|
if (ref($params) eq 'HASH') { |
33
|
0
|
|
|
|
|
|
delete $$params{show}; |
34
|
0
|
|
|
|
|
|
delete $$params{rows_page}; |
35
|
0
|
|
|
|
|
|
delete $$params{page}; |
36
|
0
|
|
|
|
|
|
delete $$params{hiddenFilter}; |
37
|
0
|
|
|
|
|
|
delete $$params{filter}; |
38
|
0
|
|
|
|
|
|
delete $$params{queryDescr}; |
39
|
0
|
|
|
|
|
|
delete $$params{sort}; |
40
|
0
|
|
|
|
|
|
while (my ($k,$v) = each %$params) { |
41
|
0
|
|
|
|
|
|
$stateArgs .= "&$k="; |
42
|
0
|
0
|
|
|
|
|
$stateArgs .= (ref($v) eq 'ARRAY') ? CGI::escape($$v[0]) : CGI::escape($v); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
} |
46
|
0
|
|
|
|
|
|
print CGI::redirect("$uri?OQLoadSavedSearch=".$id.$stateArgs); |
47
|
0
|
|
|
|
|
|
return undef; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
elsif ($q->param('delete') =~ /^(\d+)$/) { |
52
|
0
|
|
|
|
|
|
my $id = $1; |
53
|
0
|
|
|
|
|
|
$dbh->do("DELETE FROM oq_saved_search WHERE id=? AND user_id=?", undef, $id, $userid); |
54
|
0
|
|
|
|
|
|
print CGI::header('text/plain'), "OK"; |
55
|
0
|
|
|
|
|
|
return undef; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
else { |
59
|
0
|
|
|
|
|
|
print CGI::header('text/plain'), get_html($q,$dbh,$userid,$selfurl); |
60
|
0
|
|
|
|
|
|
return undef; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return undef; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub get_html { |
67
|
0
|
|
|
0
|
0
|
|
my ($q,$dbh,$userid,$selfurl) = @_; |
68
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare( |
69
|
|
|
|
|
|
|
"SELECT id, oq_title, user_title |
70
|
|
|
|
|
|
|
FROM oq_saved_search |
71
|
|
|
|
|
|
|
WHERE user_id=? |
72
|
|
|
|
|
|
|
ORDER BY oq_title, user_title"); |
73
|
0
|
|
|
|
|
|
$sth->execute($userid); |
74
|
0
|
|
|
|
|
|
my $last_oq_title = ''; |
75
|
0
|
|
|
|
|
|
my $buf = ''; |
76
|
0
|
|
|
|
|
|
while (my ($id, $oq_title, $user_title) = $sth->fetchrow_array()) { |
77
|
0
|
0
|
|
|
|
|
if ($last_oq_title ne $oq_title) { |
78
|
0
|
0
|
|
|
|
|
$buf .= '' if $last_oq_title; |
79
|
0
|
|
|
|
|
|
$last_oq_title = $oq_title; |
80
|
0
|
|
|
|
|
|
$buf .= "".escapeHTML($oq_title)." |
81
|
|
|
|
|
|
|
} |
82
|
0
|
|
|
|
|
|
$buf .= " |
83
|
|
|
|
|
|
|
".escapeHTML($user_title)." |
84
|
|
|
|
|
|
|
delete |
85
|
|
|
|
|
|
|
"; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
0
|
|
|
|
|
$buf .= '' if $last_oq_title; |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
if ($buf) { |
90
|
0
|
|
|
|
|
|
$buf = ' '.$buf.' |
91
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
'; |
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
|
|
|
return $buf; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
1; |