~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to web/cgi/alpine/select2.tcl

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2007-02-17 13:17:42 UTC
  • Revision ID: james.westby@ubuntu.com-20070217131742-99x5c6cpg1pbkdhw
Tags: upstream-0.82+dfsg
ImportĀ upstreamĀ versionĀ 0.82+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!./tclsh
 
2
# $Id: select2.tcl 391 2007-01-25 03:53:59Z mikes@u.washington.edu $
 
3
# ========================================================================
 
4
# Copyright 2006 University of Washington
 
5
#
 
6
# Licensed under the Apache License, Version 2.0 (the "License");
 
7
# you may not use this file except in compliance with the License.
 
8
# You may obtain a copy of the License at
 
9
#
 
10
#     http://www.apache.org/licenses/LICENSE-2.0
 
11
#
 
12
# ========================================================================
 
13
 
 
14
#  select.tcl
 
15
#
 
16
#  Purpose:  CGI script to generate html form used to gather info
 
17
#            for message searching selection
 
18
 
 
19
#  Input:
 
20
set select_vars {
 
21
}
 
22
 
 
23
#  Output:
 
24
#
 
25
#       HTML/CSS data representing form for text select input
 
26
 
 
27
# coerce uid to zero since there's not method in WPL yet to initiate
 
28
# a search from a particular message.
 
29
set uid 0
 
30
 
 
31
 
 
32
# inherit global config
 
33
source ./alpine.tcl
 
34
source cmdfunc.tcl
 
35
 
 
36
WPEval $select_vars {
 
37
  if {$uid} {
 
38
    if {[catch {WPCmd PEMessage $uid number} thisnum]} {
 
39
      set uid 0
 
40
    }
 
41
  } else {
 
42
    set thisnum ""
 
43
  }
 
44
 
 
45
 
 
46
  cgi_http_head {
 
47
    WPStdHttpHdrs
 
48
  }
 
49
 
 
50
  cgi_html {
 
51
    cgi_head {
 
52
      WPStdHtmlHdr "Select By Text"
 
53
      WPStyleSheets
 
54
    }
 
55
 
 
56
    cgi_body BGCOLOR="$_wp(bordercolor)" {
 
57
 
 
58
      catch {WPCmd PEInfo set wp_index_script fr_select.tcl}
 
59
      catch {WPCmd PEInfo set help_context select}
 
60
 
 
61
      cgi_form $_wp(appdir)/wp method=get name=auth target=body {
 
62
        cgi_text "page=index" type=hidden notab
 
63
        cgi_text "doselect=1" type=hidden notab
 
64
        cgi_table border=0 cellspacing=0 cellpadding=2 width="100%" height="100%" {
 
65
          cgi_table_row {
 
66
            cgi_table_data align=center valign=top class=dialog {
 
67
              cgi_table width="80%" {
 
68
                cgi_table_row {
 
69
                  cgi_table_data {
 
70
                    cgi_center {
 
71
                      cgi_puts "[cgi_nl][cgi_nl]This page provides a way to search for specific messsages within the currently open folder, [cgi_bold [WPCmd PEMailbox mailboxname]].  Simply fill in the criteria below and click the assoicated [cgi_italic Search] button. All messages matching the criteria will be marked with a check in the box next to their line in the Message List.[cgi_nl][cgi_nl]"
 
72
                      cgi_puts "Click [cgi_italic Cancel] to return to the Message List without searching.[cgi_nl]"
 
73
                    }
 
74
                  }
 
75
                }
 
76
 
 
77
                if {[WPCmd PEMailbox selected]} {
 
78
                  cgi_table_row class=dialog {
 
79
                    cgi_table_data colspan=2 align=center valign=middle class=dialog {
 
80
                      cgi_put [cgi_font face=tahoma,verdana,geneva "Since some messages are already marked, choose whether criteria specified here should "]
 
81
                      cgi_select result {
 
82
                        cgi_option "search all messages in '[WPCmd PEMailbox mailboxname]'" value=broad selected
 
83
                        cgi_option "search within marked messages only." value=narrow
 
84
                        cgi_option "discard previous marks and search anew." value=new
 
85
                      }
 
86
 
 
87
                      cgi_br
 
88
                      cgi_br
 
89
                    }
 
90
                  }
 
91
                } else {
 
92
                  cgi_text result=broad type=hidden notab
 
93
                }
 
94
 
 
95
                cgi_table_row class=dialog {
 
96
                  cgi_table_data {
 
97
                    cgi_table width=100% border=2 cellpadding=8 {
 
98
                      cgi_table_row {
 
99
                        cgi_table_data bgcolor=#CC9900 {
 
100
                          cgi_radio_button by=text
 
101
                        }
 
102
 
 
103
                        cgi_table_data valign=top align=center nowrap class=dialog {
 
104
                          cgi_put [cgi_bold "Search for Text in Message Headers or Body"]
 
105
                          cgi_br
 
106
                          cgi_br
 
107
                          cgi_put "Select messages with text "
 
108
                          cgi_select textcase {
 
109
                            cgi_option "in" value=ton
 
110
                            cgi_option "NOT in" value=not
 
111
                          }
 
112
 
 
113
                          cgi_br
 
114
                          cgi_br
 
115
 
 
116
                          cgi_put [cgi_font face=tahoma,verdana,geneva "the message's "]
 
117
                          if {$uid} {
 
118
                            set fromaddr [WPCmd PEMessage $uid fromaddr]
 
119
                            set deftext $fromaddr
 
120
                          } else {
 
121
                            set deftext ""
 
122
                          }
 
123
 
 
124
                          set fields {
 
125
                            {Subject: field} subj ""
 
126
                            {From: field} from selected
 
127
                            {To: field} to ""
 
128
                            {Cc: field} cc ""
 
129
                            {recipient fields} recip ""
 
130
                            {participant fields} partic ""
 
131
                            {text, anywhere} any ""
 
132
                          }
 
133
 
 
134
                          cgi_select field {
 
135
                            foreach {x y z} $fields {
 
136
                              cgi_option $x value=$y $z
 
137
                            }
 
138
                          }
 
139
 
 
140
                          cgi_br
 
141
                          cgi_br
 
142
                          cgi_put [cgi_font face=tahoma,verdana,geneva "matching "]
 
143
                          cgi_text text=$deftext size=20 maxlength=256
 
144
 
 
145
                          if {$uid} {
 
146
                            set ft [WPJSQuote $fromaddr]
 
147
                            set tt [WPJSQuote [WPCmd PEMessage $uid toaddr]]
 
148
                            set st [WPJSQuote [WPCmd PEMessage $uid subject]]
 
149
                            if {[string length $ft] || [string length $tt] || [string length $st]} {
 
150
                              cgi_put "[cgi_nl]Using "
 
151
                              cgi_select defs {
 
152
                                cgi_option "- Nothing -" ""
 
153
                                if {[string length $ft]} {
 
154
                                  cgi_option "From Address" value=$ft selected
 
155
                                }
 
156
                                if {[string length $tt]} {
 
157
                                  cgi_option "To Address" value=$tt
 
158
                                }
 
159
                                if {[string length $st]} {
 
160
                                  cgi_option "Subject Text" value=$st
 
161
                                }
 
162
                              }
 
163
                              cgi_put " of message ${thisnum}"
 
164
                            }
 
165
                          }
 
166
                        }
 
167
                      }
 
168
 
 
169
                      cgi_table_row class=dialog {
 
170
                        cgi_table_data bgcolor=#CC9900 {
 
171
                          cgi_radio_button by=date
 
172
                        }
 
173
 
 
174
                        cgi_table_data valign=top align=center class=dialog {
 
175
                          cgi_put [cgi_bold "Search for Messages by Date"]
 
176
                          cgi_br
 
177
                          cgi_br
 
178
                          cgi_put "Messages dated "
 
179
 
 
180
                          cgi_select datecase {
 
181
                            foreach i {On Since Before} {
 
182
                              cgi_option $i value=[string tolower $i]
 
183
                            }
 
184
                          }
 
185
 
 
186
                          cgi_br
 
187
                          cgi_br
 
188
 
 
189
                          cgi_select datemon {
 
190
                            if {$uid} {
 
191
                              set today [string tolower [WPCmd PEMessage $uid date month]]
 
192
                            } else {
 
193
                              set today [string tolower [clock format [clock seconds] -format %b]]
 
194
                            }
 
195
 
 
196
                            set months {
 
197
                              January jan
 
198
                              February feb
 
199
                              March mar
 
200
                              April Apr
 
201
                              May may
 
202
                              June jun
 
203
                              July jul
 
204
                              August aug
 
205
                              September sep
 
206
                              October oct
 
207
                              November nov
 
208
                              December dec
 
209
                            }
 
210
 
 
211
                            foreach {x y} $months {
 
212
                              if {$y == $today} {
 
213
                                cgi_option $x value=$y selected
 
214
                              } else {
 
215
                                cgi_option $x value=$y
 
216
                              }
 
217
                            }
 
218
                          }
 
219
 
 
220
                          cgi_select dateday {
 
221
                            if {$uid} {
 
222
                              set today [WPCmd PEMessage $uid date day]
 
223
                            } else {
 
224
                              set today [clock format [clock seconds] -format %d]
 
225
                            }
 
226
 
 
227
                            for {set i 1} {$i <= 31} {incr i} {
 
228
                              set v [format "%.2d" $i]
 
229
                              if {$v == $today} {
 
230
                                cgi_option $i value=$v selected
 
231
                              } else {
 
232
                                cgi_option $i value=$v
 
233
                              }
 
234
                            }
 
235
                          }
 
236
 
 
237
                          cgi_put ",[cgi_nbspace]"
 
238
                          cgi_select dateyear {
 
239
                            if {$uid} {
 
240
                              set now [WPCmd PEMessage $uid date year]
 
241
                            } else {
 
242
                              set now [clock format [clock seconds] -format "%Y"]
 
243
                            }
 
244
 
 
245
                            cgi_option $now value=$now selected
 
246
                            for {set n [expr $now - 1]} {$n >= 1970} {incr n -1} {
 
247
                              cgi_option $n value=$n
 
248
                            }
 
249
                          }
 
250
                        }
 
251
                      }
 
252
 
 
253
                      cgi_table_row class=dialog {
 
254
                        cgi_table_data bgcolor=#CC9900 {
 
255
                          cgi_radio_button by=status
 
256
                        }
 
257
 
 
258
                        cgi_table_data class=dialog align=center {
 
259
                          cgi_put [cgi_bold "Search for Messages with Certain Flag Settings"]
 
260
                          cgi_br
 
261
                          cgi_br
 
262
                          cgi_puts [cgi_font face=tahoma,verdana,geneva "Messages "]
 
263
                          cgi_select statcase {
 
264
                            cgi_option "flagged" value=ton
 
265
                            cgi_option "NOT flagged" value=not
 
266
                          }
 
267
 
 
268
                          cgi_puts [cgi_font face=tahoma,verdana,geneva " :"]
 
269
 
 
270
                          cgi_table {
 
271
                            set statuses {
 
272
                              Important imp
 
273
                              New new
 
274
                              Answered ans
 
275
                              Deleted del
 
276
                            }
 
277
 
 
278
                            foreach {x y} $statuses {
 
279
                              cgi_table_row {
 
280
                                cgi_table_data align=right width="42%" {
 
281
                                  cgi_radio_button flag=$y
 
282
                                }
 
283
 
 
284
                                cgi_table_data align=left {
 
285
                                  cgi_put $x
 
286
                                }
 
287
                              }
 
288
                            }
 
289
                          }
 
290
                        }
 
291
                      }
 
292
                    }
 
293
                  }
 
294
                }
 
295
 
 
296
                cgi_table_row class=dialog {
 
297
                  cgi_table_data valign=top align=center nowrap class=dialog {
 
298
                    cgi_br
 
299
                    cgi_submit_button ok=Search
 
300
                    cgi_submit_button cancel=Cancel
 
301
                  }
 
302
                }
 
303
 
 
304
                cgi_table_row class=dialog {
 
305
                  cgi_table_data colspan=2 valign=top align=center class=dialog {
 
306
                    cgi_br
 
307
                    cgi_br
 
308
                    cgi_puts [cgi_nl][cgi_nl][cgi_font size=-1 "Note, if the number of messages in this folder is larger than the number of lines in the Message List, then some matching messages may not be visible without paging/scrolling."]
 
309
                  }
 
310
                }
 
311
              }
 
312
            }
 
313
          }
 
314
        }
 
315
      }
 
316
    }
 
317
  }
 
318
}