-
Notifications
You must be signed in to change notification settings - Fork 7
/
search.cfm
330 lines (311 loc) · 14.5 KB
/
search.cfm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
<cfsetting enablecfoutputonly="true">
<cfprocessingdirective pageencoding="utf-8">
<cfparam name="url.p" default="">
<cfparam name="url.f" default="">
<cfparam name="form.search" default="">
<cfif StructKeyExists(url,"s")>
<cfset form.search = url.s>
</cfif>
<cfif compare(url.p,'')>
<cfset project = application.project.get(projectID=url.p)>
<cfelse>
<cfset project = QueryNew("projectID,name,svnurl")>
</cfif>
<cfif compare(form.search,'')>
<cfif not compare(url.p,'')>
<cfset projects = application.search.projects(form.search,session.user.admin)>
<cfquery name="distinct_projects" dbtype="query">
select distinct projectid from projects
</cfquery>
<cfset dist_proj_list = quotedValueList(distinct_projects.projectID)>
<cfelse>
<cfset projects.recordCount = 0>
<cfset dist_proj_list = "'#url.p#'">
</cfif>
<cfset messages = application.search.messages(form.search,url.p,session.user.admin)>
<cfset comments = application.search.comments(form.search,url.p,session.user.admin)>
<cfset files = application.search.files(form.search,url.p,session.user.admin)>
<cfset mstones = application.search.milestones(form.search,url.p,session.user.admin)>
<cfset todos = application.search.todos(form.search,url.p,session.user.admin)>
<cfset issues = application.search.issues(form.search,url.p,session.user.admin)>
<cfset screenshots = application.search.screenshots(form.search,url.p,session.user.admin)>
<cfif not session.user.admin>
<cfset uprojects = session.user.projects>
<!--- messages with user permissions --->
<cfquery name="messages_withperms" dbtype="query">
select messageID, categoryID, milestoneID, title, message, stamp, messages.name, category,
messages.projectID, projName, msg_view
from messages, uprojects
where uprojects.projectid = messages.projectid
</cfquery>
<cfset messages = messages_withperms>
<!--- comments with user permissions --->
<cfquery name="comments_withperms" dbtype="query">
select commentID, itemID, type, commentText, stamp, messageID, comments.title, issueID, issue,
userID, firstName, lastName, avatar, comments.projectID, projName,
file_comment, issue_comment, msg_comment, mstone_comment, todo_comment
from comments, uprojects
where uprojects.projectid = comments.projectid
</cfquery>
<cfset comments = comments_withperms>
<!--- files with user permissions --->
<cfquery name="files_withperms" dbtype="query">
select fileid, title, categoryID, files.description, filename, serverfilename, filetype,
filesize, uploaded, uploadedBy, firstName, lastName, category, files.projectID,
projName, file_view
from files, uprojects
where uprojects.projectid = files.projectid
</cfquery>
<cfset files = files_withperms>
<!--- milestones with user permissions --->
<cfquery name="mstones_withperms" dbtype="query">
select milestoneid, mstones.name, mstones.description, dueDate, completed, mstones.projectID,
projName, mstone_view
from mstones, uprojects
where uprojects.projectid = mstones.projectid
</cfquery>
<cfset mstones = mstones_withperms>
<!--- todos with user permissions --->
<cfquery name="todos_withperms" dbtype="query">
select todoID, todolistID, task, todos.userID, rank, due, completed,
todos.title, todos.description, todos.projectID, projName, todolist_view
from todos, uprojects
where uprojects.projectid = todos.projectid
</cfquery>
<cfset todos = todos_withperms>
<!--- issues with user permissions --->
<cfquery name="issues_withperms" dbtype="query">
select issueID, shortID, issue, detail, type, severity, issues.status, created, createdBy,
assignedTo, updated, updatedBy, issues.projectID, projName, issue_view
from issues, uprojects
where uprojects.projectid = issues.projectid
</cfquery>
<cfset issues = issues_withperms>
<!--- screenshots with user permissions --->
<cfquery name="screenshots_withperms" dbtype="query">
select fileID, issueID, screenshots.title, screenshots.description, filename, serverfilename, filetype,
screenshots.projectID, projName, issue_view
from screenshots, uprojects
where uprojects.projectid = screenshots.projectid
</cfquery>
<cfset screenshots = screenshots_withperms>
</cfif>
</cfif>
<!--- Loads header/footer --->
<cfmodule template="tags/layout.cfm" templatename="main" title="#application.settings.app_title# » Search" project="#project.name#" projectid="#url.p#" svnurl="#project.svnurl#">
<cfsavecontent variable="js">
<cfoutput>
<script type='text/javascript'>
$(document).ready(function(){
$('##searchbox').focus();
});
</script>
</cfoutput>
</cfsavecontent>
<cfhtmlhead text="#js#">
<cfoutput>
<div id="container">
<!--- left column --->
<div class="left">
<div class="main">
<div class="header headernomb">
<h2>Search <cfif compare(url.p,'')>the "#project.name#" project<span class="norm sm"> or <a href="#cgi.script_name#">across all projects</a></span><cfelse>across all projects</cfif></h2>
<form action="#cgi.script_name#?#cgi.query_string#" method="post" id="search">
<input type="text" name="search" value="#form.search#" id="searchbox" />
<input type="submit" value="Search" class="button" />
</form>
</div>
<cfif compare(form.search,'')>
<div class="subheader">
Show <a href="#cgi.script_name#?s=#URLEncodedFormat(form.search)#"<cfif not compare(url.f,'')> class="b"</cfif>>All (#comments.recordCount+files.recordCount+issues.recordCount+messages.recordCount+mstones.recordCount+todos.recordCount#)</a>
or
<cfif not compare(url.p,'')>
<a href="#cgi.script_name#?s=#URLEncodedFormat(form.search)#&f=project">Projects (#projects.recordCount#)</a>,
</cfif>
<a href="#cgi.script_name#?p=#url.p#&s=#URLEncodedFormat(form.search)#&f=msgs"<cfif not compare(url.f,'msgs')> class="b"</cfif>>Messages (#messages.recordCount#)</a>,
<a href="#cgi.script_name#?p=#url.p#&s=#URLEncodedFormat(form.search)#&f=comments"<cfif not compare(url.f,'comments')> class="b"</cfif>>Comments (#comments.recordCount#)</a>,
<a href="#cgi.script_name#?p=#url.p#&s=#URLEncodedFormat(form.search)#&f=todos"<cfif not compare(url.f,'todos')> class="b"</cfif>>To-Dos (#todos.recordCount#)</a>,
<a href="#cgi.script_name#?p=#url.p#&s=#URLEncodedFormat(form.search)#&f=files"<cfif not compare(url.f,'files')> class="b"</cfif>>Files (#files.recordCount#)</a>,
<a href="#cgi.script_name#?p=#url.p#&s=#URLEncodedFormat(form.search)#&f=mstones"<cfif not compare(url.f,'mstones')> class="b"</cfif>>Milestones (#mstones.recordCount#)</a>,
<a href="#cgi.script_name#?p=#url.p#&s=#URLEncodedFormat(form.search)#&f=issues"<cfif not compare(url.f,'issues')> class="b"</cfif>>Issues (#issues.recordCount#)</a>,
<a href="#cgi.script_name#?p=#url.p#&s=#URLEncodedFormat(form.search)#&f=screen"<cfif not compare(url.f,'screen')> class="b"</cfif>>Screenshots (#screenshots.recordCount#)</a>
</div>
</cfif>
<div class="content">
<div class="wrapper">
<cfset row = 1>
<cfif compare(form.search,'')>
<cfif not compare(url.p,'')>
<cfif not compare(url.f,'') or not compare(url.f,'project')>
<cfset proj_list = "">
<cfloop query="projects">
<cfif not listFind(proj_list,projectID)>
<div class="searchresult<cfif row mod 2 eq 0> odd</cfif>">
<div class="catbox project">Project</div>
<h4><a href="project.cfm?p=#projectID#">#name#</a></h4>
<cfif compare(description,'')><p>#left(description,200)#<cfif len(description) gt 200>...</cfif></p></cfif>
</div>
<cfset row = row + 1>
<cfset proj_list = listAppend(proj_list,projectID)>
</cfif>
</cfloop>
</cfif>
</cfif>
<cfif not compare(url.f,'') or not compare(url.f,'msgs')>
<cfloop query="messages">
<cfif session.user.admin or msg_view>
<div class="searchresult<cfif row mod 2 eq 0> odd</cfif>">
<div class="catbox message">Message</div>
<h4>
<cfif not compare(url.p,'')>
<a href="project.cfm?p=#projectID#">#projName#</a> :
</cfif>
<a href="message.cfm?p=#projectID#&m=#messageID#">#title#</a>
</h4>
<cfif compare(message,'')><p>#left(message,200)#<cfif len(message) gt 200>...</cfif></p></cfif>
</div>
<cfset row = row + 1>
</cfif>
</cfloop>
</cfif>
<cfif not compare(url.f,'') or not compare(url.f,'comments')>
<cfloop query="comments">
<cfif session.user.admin or (
(not compare(type,'file') and file_comment) or
(not compare(type,'issue') and issue_comment) or
(not compare(type,'msg') and msg_comment) or
(not compare(type,'mstone') and mstone_comment) or
(not compare(type,'todo') and todo_comment)
)>
<div class="searchresult<cfif row mod 2 eq 0> odd</cfif>">
<div class="catbox comm">Comment</div>
<h4>on
<cfif not compare(url.p,'')>
<a href="project.cfm?p=#projectID#">#projName#</a> :
</cfif>
<cfif compare(messageID,'')>
<a href="message.cfm?p=#projectID#&m=#messageID#">#title#</a>
<cfelseif compare(issueID,'')>
<a href="issue.cfm?p=#projectID#&i=#issueID#">#issue#</a>
</cfif>
</h4>
<cfif compare(commentText,'')><p>#left(commentText,200)#<cfif len(commentText) gt 200>...</cfif></p></cfif>
</div>
<cfset row = row + 1>
</cfif>
</cfloop>
</cfif>
<cfif not compare(url.f,'') or not compare(url.f,'todos')>
<cfloop query="todos">
<cfif session.user.admin or todolist_view>
<div class="searchresult<cfif row mod 2 eq 0> odd</cfif>">
<div class="catbox todolist">To-Dos</div>
<h4>
<cfif not compare(url.p,'')>
<a href="project.cfm?p=#projectID#">#projName#</a> :
</cfif>
<a href="todos.cfm?p=#projectID#">#title#</a> : <a href="todos.cfm?p=#projectID#">#task#</a>
</h4>
</div>
<cfset row = row + 1>
</cfif>
</cfloop>
</cfif>
<cfif not compare(url.f,'') or not compare(url.f,'files')>
<cfloop query="files">
<cfif session.user.admin or file_view>
<div class="searchresult<cfif row mod 2 eq 0> odd</cfif>">
<div class="catbox file">File</div>
<h4>
<cfif not compare(url.p,'')>
<a href="project.cfm?p=#projectID#">#projName#</a> :
</cfif>
<a href="files.cfm?p=#projectID#">#title#</a>
</h4>
<cfif compare(description,'')><p>#left(description,200)#<cfif len(description) gt 200>...</cfif></p></cfif>
</div>
<cfset row = row + 1>
</cfif>
</cfloop>
</cfif>
<cfif not compare(url.f,'') or not compare(url.f,'mstones')>
<cfloop query="mstones">
<cfif session.user.admin or mstone_view>
<div class="searchresult<cfif row mod 2 eq 0> odd</cfif>">
<div class="catbox milestone">Milestone</div>
<h4>
<cfif not compare(url.p,'')>
<a href="project.cfm?p=#projectID#">#projName#</a> :
</cfif>
<a href="milestone.cfm?p=#projectID#">#name#</a>
</h4>
<cfif compare(description,'')><p>#left(description,200)#<cfif len(description) gt 200>...</cfif></p></cfif>
</div>
<cfset row = row + 1>
</cfif>
</cfloop>
</cfif>
<cfif not compare(url.f,'') or not compare(url.f,'issues')>
<cfloop query="issues">
<cfif session.user.admin or issue_view>
<div class="searchresult<cfif row mod 2 eq 0> odd</cfif>">
<div class="catbox issue">Issue</div>
<h4>
<cfif not compare(url.p,'')>
<a href="project.cfm?p=#projectID#">#projName#</a> :
</cfif>
<a href="issue.cfm?p=#projectID#&i=#issueID#">#issue#</a>
</h4>
<cfif compare(detail,'')><p>#left(detail,200)#<cfif len(detail) gt 200>...</cfif></p></cfif>
</div>
<cfset row = row + 1>
</cfif>
</cfloop>
</cfif>
<cfif not compare(url.f,'') or not compare(url.f,'screen')>
<cfloop query="screenshots">
<cfif session.user.admin or issue_view>
<div class="searchresult<cfif row mod 2 eq 0> odd</cfif>">
<div class="catbox screenshot">Screenshot</div>
<h4>
<cfif not compare(url.p,'')>
<a href="project.cfm?p=#projectID#">#projName#</a> :
</cfif>
<a href="issue.cfm?p=#projectID#&i=#issueID#">#title#</a>
</h4>
<cfif compare(description,'')><p>#left(description,200)#<cfif len(description) gt 200>...</cfif></p></cfif>
</div>
<cfset row = row + 1>
</cfif>
</cfloop>
</cfif>
<cfelse>
<p class="g">
<cfif compare(url.p,'')>
Enter your search term above to search the "#project.name#" project.<br />
You might also want to <a href="#cgi.script_name#">search all projects</a>.
<cfelse>
Enter your search term above to search across all projects.
</cfif>
</p>
</cfif>
</div>
</div>
</div>
<div class="bottom"> </div>
<div class="footer">
<cfinclude template="#application.settings.mapping#/footer.cfm">
</div>
</div>
<!--- right column --->
<div class="right">
<cfif not compare(url.p,'') and compare(application.settings.company_logo,'')>
<img src="#application.settings.userFilesMapping#/company/#application.settings.company_logo#" border="0" alt="#application.settings.company_name#" /><br />
<cfelseif compare(url.p,'') and compare(project.logo_img,'')>
<img src="#application.settings.userFilesMapping#/projects/#project.logo_img#" border="0" alt="#project.name#" class="projlogo" />
</cfif>
</div>
</div>
</cfoutput>
</cfmodule>
<cfsetting enablecfoutputonly="false">