Mercurial > hgrepos > hgweb.cgi > after5
annotate after5.rb @ 68:db1502243712 draft
Do not hover mail addresses of users for non-administrator list.
author | HIROSE Yuuji <yuuji@gentei.org> |
---|---|
date | Thu, 28 Jun 2012 09:43:29 +0900 |
parents | a421c2fefc32 |
children | bdb7e40c2d4f |
rev | line source |
---|---|
17 | 1 #!/usr/local/bin/ruby19 |
16 | 2 # -*- coding: euc-jp -*- |
0 | 3 # |
4 # Associative Scheduling Table - after5 | |
22
8803e5d52611
Show guidance when wrong password entered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
18
diff
changeset
|
5 # (C)2003, 2004, 2006, 2008, 2012 by HIROSE Yuuji [yuuji<at>gentei.org] |
26 | 6 # $Id: after5.rb,v 1.19 2012/04/01 11:52:25 yuuji Exp yuuji $ |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
7 # Last modified Thu Jun 28 09:42:37 2012 on firestorm |
0 | 8 # See http://www.gentei.org/~yuuji/software/after5/ |
9 # このスクリプトはEUCで保存してください。 | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
10 $hgid = <<_HGID_.split[1..-2].join(" ") |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
11 $HGid$ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
12 _HGID_ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
13 $myurl = "http://www.gentei.org/~yuuji/software/after5/" |
0 | 14 |
15 require 'kconv' | |
17 | 16 require 'nkf' |
0 | 17 |
18 $charset = 'EUC-JP' | |
19 | |
20 class HTMLout | |
21 def contenttype(type = "text/html", charset = $charset) | |
22 sprintf "Content-type: %s; charset=%s\n\n", type, charset | |
23 end | |
24 def initialize(title = "Document") | |
25 @title = title | |
26 @eltstack = [] | |
27 end | |
28 def resetstack() | |
29 @eltstack = [] | |
30 end | |
31 def head(title = @title, css = "style.css") | |
32 sprintf <<__EOS__, title, css | |
33 <html> | |
34 <head> | |
35 <title>%s</title> | |
36 <link rel="stylesheet" type="text/css" href="%s"> | |
37 </head> | |
38 __EOS__ | |
39 end | |
40 | |
41 def startelement(elt, attrs = {}, nl = true) | |
42 attr = "" | |
43 if attrs.is_a?(Hash) | |
44 for k in attrs.keys | |
45 attr += " %s=\"%s\"" % [k, attrs[k]] | |
46 end | |
47 end | |
48 @eltstack.push(elt) | |
49 sprintf "<%s%s>%s", elt, attr, nl ? "\n" : "" | |
50 end | |
51 def endelement(elt = nil, nl = true) | |
52 if elt | |
53 x = elt | |
54 @eltstack.pop | |
55 else | |
56 x = @eltstack.pop | |
57 end | |
58 sprintf "</%s>%s", x, nl ? "\n" : "" | |
59 end | |
60 def element(elt, attrs = nil, nl = nil) | |
61 attr = "" | |
62 lf = nl ? "\n" : "" | |
63 if attrs.is_a?(Hash) | |
64 for k in attrs.keys | |
65 attr += " %s=\"%s\"" % [k, attrs[k]] | |
66 end | |
67 end | |
68 body = yield | |
69 sprintf "<%s%s>%s%s%s</%s>%s", elt, attr, lf, body, lf, elt, lf | |
70 end | |
71 def elementln(elt, attr=nil) | |
72 body = yield | |
73 element(elt, attr, true){body} | |
74 end | |
75 def a(href, anchor = nil, attrs = {}) | |
76 attr = attrs | |
77 attr['href'] = href | |
78 element("a", attr){ | |
79 anchor or href | |
80 } | |
81 end | |
82 def p(msg, attrs=nil) | |
83 element("p", attrs){msg} | |
84 end | |
85 def text(name, value='', size=nil, maxlength=nil) | |
86 sprintf "<input type=\"text\" name=\"%s\" value=\"%s\"%s%s>", | |
87 name, value, | |
88 size ? " size=\"%s\""%size.to_s : '', | |
89 maxlength ? " maxlength=\"%s\""%maxlength.to_s : '' | |
90 end | |
91 def hidden(name, value='') | |
92 sprintf "<input type=\"hidden\" name=\"%s\" value=\"%s\">", name, value | |
93 end | |
94 def radio(name, value, text='', checked=nil) | |
95 sprintf "<input type=\"radio\" name=\"%s\" value=\"%s\"%s>%s", | |
96 name, value, checked ? " checked" : "", text | |
97 end | |
98 def checkbox(name, value, text='', checked=nil) | |
99 sprintf "<input type=\"checkbox\" name=\"%s\" value=\"%s\"%s>%s", | |
100 name, value, checked ? " checked" : "", text | |
101 end | |
102 def submit(name, value, text='') | |
103 sprintf "<input type=\"submit\" name=\"%s\" value=\"%s\">%s\n", | |
104 name, value, text | |
105 end | |
106 def reset(name, value, text='') | |
107 sprintf "<input type=\"reset\" name=\"%s\" value=\"%s\">\n", | |
108 name, value, text | |
109 end | |
110 def submit_reset(name) | |
111 submit(name, "GO")+reset(name, "Reset") | |
112 end | |
113 | |
2 | 114 def select(name, range, selected=nil) |
115 #start = (b<e ? b : e) | |
116 #last = (b>e ? b : e) | |
117 c=0 | |
0 | 118 "<select name=\"#{name}\">\n" + \ |
2 | 119 range.collect{|i| |
3 | 120 value = (i.is_a?(Array) ? i[1] : i).to_s |
121 sprintf "<option%s%s>%s%s</option>", | |
122 (selected.to_s==value.to_s) ? " selected" : "", | |
123 i.is_a?(Array) ? " value=\"%s\"" % value : '', | |
124 i.is_a?(Array) ? i[0] : i.to_s, | |
2 | 125 (c+=1)%6==0 ? "\n" : '' |
0 | 126 }.join + \ |
127 "\n</select>\n" | |
128 end | |
129 end | |
14 | 130 class TEXTout |
131 def isBlock(elt) | |
132 /\b(tr|[udo]l|p|div)\b/i =~ elt | |
133 end | |
134 def isEOC(elt) | |
135 /\bt[dh]\b/i =~ elt | |
136 end | |
137 def eoelem(elt) | |
138 r = "" | |
139 r << "\n" if isBlock(elt) | |
140 r << " " if isEOC(elt) | |
141 r | |
142 end | |
143 def contenttype(type = "text/plain", charset = $charset) | |
144 ### sprintf "Content-type: %s; charset=%s\n\n", type, charset | |
145 "" | |
146 end | |
147 def initialize(title = "Document") | |
148 @title = title | |
149 @eltstack = [] | |
150 end | |
151 def resetstack() | |
152 @eltstack = [] | |
153 end | |
154 def head(title = @title, css = "style.css") | |
155 sprintf <<__EOS__, title, css | |
156 ===== [[[ %s ]]] ===== | |
157 __EOS__ | |
158 end | |
159 | |
160 def startelement(elt, attrs = {}, nl = true) | |
161 attr = "" | |
162 x = sprintf "%s", " "*@eltstack.length | |
163 @eltstack.push(elt) | |
164 x | |
165 end | |
166 def endelement(elt = nil, nl = true) | |
167 if elt | |
168 x = elt | |
169 @eltstack.pop | |
170 else | |
171 x = @eltstack.pop | |
172 end | |
173 eoelem(x) | |
174 end | |
175 def element(elt, attrs = nil, nl = nil) | |
176 attr = "" | |
177 lf = nl ? "\n" : "" | |
178 body = yield | |
179 #sprintf "<%s%s>%s%s%s</%s>%s", elt, attr, lf, body, lf, elt, lf | |
180 sprintf "%s%s", body, eoelem(elt) | |
181 end | |
182 def elementln(elt, attr=nil) | |
183 body = yield | |
184 sprintf "%s\n", body | |
185 end | |
186 def a(href, anchor = nil, attrs = {}) | |
187 attr = attrs | |
188 attr['href'] = href | |
189 # sprintf "%s\n", href | |
190 anchor | |
191 end | |
192 def p(msg, attrs=nil) | |
193 element("p", attrs){msg} | |
194 end | |
195 def text(name, value='', size=nil, maxlength=nil) | |
196 "" | |
197 end | |
198 def hidden(name, value='') | |
199 "" | |
200 end | |
201 def radio(name, value, text='', checked=nil) | |
202 "" | |
203 end | |
204 def checkbox(name, value, text='', checked=nil) | |
205 "" | |
206 end | |
207 def submit(name, value, text='') | |
208 "" | |
209 end | |
210 def reset(name, value, text='') | |
211 "" | |
212 end | |
213 def submit_reset(name) | |
214 "" | |
215 end | |
216 def select(name, range, selected=nil) | |
217 "" | |
218 end | |
219 end | |
0 | 220 |
221 class PasswdMgr | |
222 def initialize(name, mode=0640) | |
223 require 'dbm' | |
224 @pdb = DBM.open(name, mode) | |
225 end | |
226 def checkpasswd(user, passwd) | |
227 if @pdb[user] then | |
228 @pdb[user] == passwd.crypt(@pdb[user]) | |
229 end | |
230 end | |
231 def setpasswd(user, passwd) | |
232 salt = [rand(64),rand(64)].pack("C*").tr("\x00-\x3f","A-Za-z0-9./") | |
233 @pdb[user] = passwd.crypt(salt) | |
234 end | |
235 def userexist?(user) | |
236 @pdb[user] ? true : false | |
237 end | |
238 def getpasswd(user) | |
239 @pdb[user] | |
240 end | |
241 def delete(user) | |
242 @pdb.delete(user) | |
243 end | |
244 def close() | |
245 @pdb.close() | |
246 end | |
247 def newpasswd(length) | |
61
502103680ea2
Call srand() without parameter.
HIROSE Yuuji <yuuji@gentei.org>
parents:
60
diff
changeset
|
248 srand() |
0 | 249 left = "qazxswedcvfrtgb12345" |
250 right = "yhnmjuik.lop;/67890-" | |
251 array = [left, right] | |
252 (1..length).collect{|i| | |
253 a = array[i%array.length] | |
254 a[rand(a.length), 1] | |
255 }.join('') | |
256 end | |
257 def users() | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
258 @pdb.keys.collect{|u| u.toeuc} # toeuc is for 1.9 :( |
0 | 259 end |
260 private :newpasswd | |
261 def setnewpasswd(user, length=8) | |
262 newp = newpasswd(length) | |
263 setpasswd(user, newp) | |
264 newp | |
265 end | |
266 end | |
267 | |
268 class ScheduleDir | |
269 def initialize(dir = "s") | |
270 @dir = dir | |
271 @schedulefile = "sched" | |
272 @usermapdir = File.join(@dir, "usermap") | |
273 @usermap = mkusermap() | |
274 @groupmapdir = File.join(@dir, "groupmap") | |
275 @groupmap = mkgroupmap() | |
276 @crondir = File.join(@dir, "crondir") | |
277 | |
278 end | |
279 def mkusermap() | |
280 map = {} | |
281 unless test(?d, @usermapdir) | |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
282 mkdir_p(@usermapdir, 0750) |
0 | 283 end |
284 Dir.foreach(@usermapdir){|u| | |
285 next if /^\./ =~ u | |
286 newu = '' | |
287 u.split('').each{|c| # for security wrapping | |
12 | 288 newu << c[0].chr if %r,[-A-Z0-9/+_.@],i =~ c |
0 | 289 } |
290 u = newu | |
291 map[u] = {} | |
17 | 292 d = File.join(@usermapdir, u).untaint |
0 | 293 next unless test(?d, d) |
294 Dir.foreach(d){|attr| | |
295 next if /^\./ =~ attr | |
12 | 296 attr.untaint if /^[A-Z_][-A-Z_0-9]*$/i =~ attr |
17 | 297 file = File.join(@usermapdir, u, attr).untaint |
0 | 298 next unless test(?s, file) && test(?r, file) |
17 | 299 map[u][attr] = IO.readlines(file).join.toeuc.strip |
0 | 300 } |
301 } | |
302 map | |
303 end | |
304 def putuserattr(user, attr, text) | |
305 # if text==nil, remove it | |
306 d = File.join(@usermapdir, user) | |
307 Dir.mkdir(d) unless test(?d, d) | |
308 file = File.join(d, attr) | |
309 begin | |
2 | 310 unless @usermap[user] |
311 @usermap[user] = {} | |
312 mkdir_p(d) unless test(?d, d) | |
313 end | |
0 | 314 @usermap[user][attr] = text |
315 if text==nil | |
316 File.unlink(file) | |
317 else | |
318 open(file, "w"){|w| w.puts @usermap[user][attr]} | |
319 end | |
320 rescue | |
321 return nil | |
322 end | |
323 return {attr => text} | |
324 end | |
325 def getuserattr(user, attr) | |
326 # Should we distinguish between attribute is nil and "" ? | |
327 if @usermap.has_key?(user) && @usermap[user][attr].is_a?(String) && | |
328 @usermap[user][attr] > '' | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
329 return @usermap[user][attr].untaint |
0 | 330 else |
331 return nil | |
332 end | |
333 end | |
334 | |
335 def nickname(user) | |
336 if @usermap.has_key?(user) && @usermap[user]['name'].is_a?(String) && | |
337 @usermap[user]['name'] > '' | |
338 return @usermap[user]['name'] | |
339 else | |
340 return user.sub(/@.*/, '') | |
341 end | |
342 end | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
343 def mailaddress(user, grp = nil) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
344 grp ? mail4grp(user, grp) : \ |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
345 (getuserattr(user, 'email') || user) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
346 end |
0 | 347 def setnickname(user, nickname) |
348 putuserattr(user, 'name', nickname) | |
349 end | |
350 | |
351 # | |
352 # make group map | |
353 def collectmembers(gname) | |
354 @visitedgroup=[] unless @visitedgroup | |
355 return [] unless @visitedgroup.grep(gname).empty? | |
356 @visitedgroup.push(gname) | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
357 mdir = File.join(@groupmapdir, gname, 'members').untaint |
0 | 358 return [] unless test(?d, mdir) |
359 members = [] | |
360 Dir.foreach(mdir){|item| | |
361 next if /^\./ =~ item | |
362 item.untaint | |
363 next unless test(?f, File.join(mdir, item)) | |
364 if /.+@.+/ =~ item | |
365 members << item | |
366 else | |
367 members += collectmembers(item) | |
368 end | |
369 } | |
370 @visitedgroup.pop | |
371 members | |
372 end | |
373 def mkgroupmap() | |
374 map = {} | |
375 return map unless test(?d, @groupmapdir) | |
376 @visitedgroup = [] | |
377 Dir.foreach(@groupmapdir){|g| | |
378 next if /^\./ =~ g | |
379 newg = '' | |
380 next unless /^[-a-z0-9_.]+$/i =~ g | |
381 #g.untaint ## untaintじゃだめだ。map{g} のkeyがtaintedになっちゃうよ | |
382 gg = '' # for security wrapping | |
383 g.split('').each{|c| gg << c[0].chr if c != '`'} | |
384 g = gg | |
385 map[gg] = {} | |
17 | 386 d = File.join(@groupmapdir, g).untaint |
0 | 387 next unless test(?d, d) |
388 # get group name | |
17 | 389 gnf = File.join(d, 'name').untaint |
0 | 390 if test(?r, gnf) && test(?s, gnf) |
17 | 391 n = IO.readlines(gnf)[0].to_s.toeuc.strip |
0 | 392 map[g]['name'] = if n > '' then n else g end |
393 else | |
394 map[g]['name'] = g | |
395 end | |
396 # get administrators | |
397 # | |
17 | 398 gad = File.join(d, 'admin').untaint |
0 | 399 map[g]['admin'] = [] |
400 if test(?d, gad) | |
401 Dir.foreach(gad){|a| | |
402 # administrator should be a person (not group) | |
403 next unless /@/ =~ a | |
404 map[g]['admin'] << a | |
405 } | |
406 end | |
407 # collect members | |
408 #map[g]['members'] = collectmembers(g) | |
17 | 409 memd = File.join(d, 'members').untaint |
0 | 410 map[g]['members'] = [] |
411 if test(?d, memd) | |
412 Dir.foreach(memd){|a| | |
413 next if /^\./ =~ a | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
414 map[g]['members'] << a.untaint |
0 | 415 } |
416 end | |
47 | 417 # get other attributes |
418 Dir.foreach(d) {|attr| | |
419 next if /^\./ =~ attr | |
420 next unless /^[-_a-z]+$/i =~ attr | |
421 next if attr == "name" # already collected | |
422 attr.untaint | |
423 file = File.join(d, attr) #.untaint | |
424 next if test(?d, file) | |
425 next unless test(?s, file) && test(?r, file) | |
426 map[g][attr] = IO.readlines(file).join.toeuc.strip | |
427 } | |
0 | 428 } |
429 map | |
430 end | |
47 | 431 def putgroupattr(group, attr, value) |
432 d = File.join(@groupmapdir, group).untaint | |
433 Dir.mkdir(d) unless test(?d, d) | |
434 file = File.join(d, attr) | |
435 begin | |
436 unless @groupmap[group] | |
437 @groupmap[group] = {} | |
438 end | |
439 @groupmap[group][attr] = value | |
440 if value == nil | |
441 File.unlink(file) | |
442 else | |
443 open(file, "w"){|w| w.puts @groupmap[group][attr]} | |
444 end | |
445 rescue | |
446 return nil | |
447 end | |
448 return {attr => value} | |
449 end | |
450 def getgroupattr(group, attr) | |
451 if @groupmap.has_key?(group) && @groupmap[group][attr].is_a?(String) && | |
452 @groupmap[group][attr] > '' | |
453 return @groupmap[group][attr].untaint | |
454 else | |
455 return nil | |
456 end | |
457 end | |
0 | 458 def groupmap() |
459 @groupmap | |
460 end | |
461 def groups() | |
462 @groupmap.keys | |
463 end | |
2 | 464 def addgroup(group, users, remove=nil, role='members') |
465 grp = groups.grep(group)[0] # group may be tainted, using kept name | |
466 return nil unless grp | |
0 | 467 for u in users |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
468 m = nil |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
469 u, m = u if u.is_a?(Array) # ["user", "mailto"] |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
470 m = nil if mailaddress(u)==m || /@/ !~ m |
0 | 471 next unless account_exists(u) |
17 | 472 mdir = File.join(@groupmapdir, grp, role).untaint |
473 file = File.join(mdir, u).untaint | |
0 | 474 if remove |
475 @groupmap[grp][role].delete(u) | |
476 File.unlink(file) if test(?e, file) | |
477 else | |
478 @groupmap[grp][role] << u | |
479 @groupmap[grp][role].uniq | |
480 Dir.mkdir(file) unless test(?d, mdir) | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
481 open(file, "w"){|x|x.puts m if m} |
0 | 482 end |
483 end | |
484 grp | |
485 end | |
486 def setgroupname(grp, name) | |
487 return nil unless @groupmap[grp] | |
17 | 488 mdir = File.join(@groupmapdir, grp).untaint |
489 nfile = File.join(mdir, 'name').untaint | |
0 | 490 @groupmap[grp]['name'] = name |
491 if grp == name | |
492 # remove the name file because it is default name | |
493 File.unlink(nfile) if test(?e, nfile) | |
494 else | |
495 Dir.mkdir(mdir) unless test(?d, mdir) | |
496 open(nfile, "w"){|n| n.puts name.to_s.strip} | |
497 end | |
498 name | |
499 end | |
500 def creategroup(grp, grpname="", admin=[]) | |
2 | 501 grpptnOK = /^[-A-Z0-9._:!$%,]+$/i |
502 return nil unless grpptnOK =~ grp | |
503 gg = '' | |
504 grp.split('').each{|c| gg << c[0].chr if c =~ grpptnOK} | |
505 grp = gg | |
0 | 506 gdir = File.join(@groupmapdir, grp) |
507 mkdir_p(gdir) # Should not care errors here | |
508 Dir.mkdir(File.join(gdir, "admin")) | |
509 Dir.mkdir(File.join(gdir, "members")) | |
510 @groupmap[grp] = {} | |
511 if grpname == '' | |
512 @groupmap[grp]['name'] = grp | |
513 else | |
514 setgroupname(grp, grpname) | |
515 end | |
516 @groupmap[grp]['members'] = [] | |
517 @groupmap[grp]['admin'] = [] | |
518 addgroup(grp, admin) | |
519 addgroup(grp, admin, nil, 'admin') | |
520 return @groupmap[grp] | |
521 end | |
522 def createuser(user, email = nil) | |
523 return nil unless /@/ =~ user | |
524 return nil if %r@[\/()\;|,$\%^!\#&\'\"]@ =~ user | |
525 email = email || user | |
526 @usermap[user] = {} | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
527 dir = File.join(@usermapdir, user).untaint |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
528 test(?d, dir) || Dir.mkdir(dir) |
0 | 529 putuserattr(user, 'email', email) |
530 end | |
531 def deleteuser(user) | |
532 return nil unless @usermap[user] | |
533 begin | |
534 @usermap[user] # return value | |
535 ensure | |
536 @usermap.delete(user) | |
537 rm_rf(File.join(@usermapdir, user)) | |
538 rm_rf(File.join(@groupmapdir, "*/members/#{user}")) | |
539 rm_rf(File.join(@crondir, "[1-9]*-*-*/#{user}")) | |
540 rm_rf(File.join(@dir, "[1-9]*/[0-9][0-9]/[0-9][0-9]/[0-9]???/#{user}")) | |
541 end | |
542 end | |
543 def destroygroup(grp) | |
544 return nil unless @groupmap[grp] | |
545 begin | |
546 @groupmap[grp] # return value | |
547 ensure | |
548 @groupmap.delete(grp) | |
549 rm_rf(File.join(@groupmapdir, grp)) | |
550 rm_rf(File.join(@groupmapdir, "*/members/#{grp}")) | |
551 rm_rf(File.join(@crondir, "[1-9]*-*-*/#{grp}")) | |
552 rm_rf(File.join(@dir, "[1-9]*/[0-9][0-9]/[0-9][0-9]/[0-9]???/#{grp}")) | |
553 end | |
554 end | |
555 def rm_rf(path) | |
6 | 556 path.untaint |
0 | 557 if (list = Dir.glob(path))[0] |
558 for p in list | |
2 | 559 p.untaint |
0 | 560 system "/bin/rm -rf \"#{p}\"" |
561 end | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
562 cleanup_files(list) |
0 | 563 end |
564 end | |
565 def account_exists(instance) | |
566 if /@/ =~ instance | |
567 true | |
568 else | |
569 ! @groupmap.select{|k, v| k==instance}.empty? | |
570 end | |
571 end | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
572 def mail4grp(usr, group) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
573 file = File.expand_path((group+"/members/"+usr).untaint, @groupmapdir) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
574 if test(?s, file.untaint) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
575 open(file, "r"){|f|f.gets.chomp}.untaint |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
576 else |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
577 mailaddress(usr) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
578 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
579 end |
0 | 580 def ismember(user, grouporuser) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
581 return user if user==grouporuser |
0 | 582 if @groupmap[grouporuser] |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
583 @groupmap[grouporuser]['members'].grep(user)[0] && |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
584 mail4grp(user, grouporuser) |
0 | 585 end |
586 end | |
2 | 587 def isuser(user) |
588 @usermap[user] && @usermap.keys.grep(user)[0] | |
589 end | |
0 | 590 def isgroup(grp) |
591 @groupmap[grp] | |
592 end | |
593 def isadmin(user, group) | |
594 @groupmap[group] and @groupmap[group]['admin'].grep(user)[0] | |
595 end | |
596 def members(grp) | |
597 @groupmap[grp] and ####################@groupmap[grp]['members'] | |
598 collectmembers(grp) | |
599 end | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
600 def membernames(grp) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
601 members(grp).collect{|u| nickname(u)} |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
602 end |
0 | 603 def admins(grp) |
604 @groupmap[grp] and @groupmap[grp]['admin'] | |
605 end | |
606 def groupname(grp) | |
607 @groupmap[grp] && @groupmap[grp]['name'] | |
608 end | |
2 | 609 def name2group(name) |
610 @groupmap.find{|g, v| v.is_a?(Hash) && v['name']==name} | |
611 end | |
612 def day_all(d, user=nil, personalonly = nil) | |
0 | 613 y, m, d = d.scan(%r,(\d\d\d\d+)/(\d+)/(\d+),)[0] |
614 #daydir = File.join(@dir, "%04d"%y.to_i, "%02d"%m.to_i, "%02d"%d.to_i) | |
615 daydir = File.join("s", "%04d"%y.to_i, "%02d"%m.to_i, "%02d"%d.to_i) | |
616 sched = {} | |
617 return sched unless test(?d, daydir) | |
618 Dir.foreach(daydir) {|time| | |
619 next if /^\./ =~ time | |
620 next unless /^\d\d\d\d$/ =~ time | |
621 time.untaint | |
622 t = File.join(daydir, time) | |
623 next unless test(?d, t) | |
624 sched[time] = {} | |
625 Dir.foreach(t){|who| | |
626 next if /^\./ =~ who | |
627 | |
628 visible = false | |
629 #next unless /@/ =~ who # user must be as user@do.ma.in | |
630 next unless account_exists(who) | |
7 | 631 ## next if personalonly && who != user #2004/1/16 |
0 | 632 who.untaint |
633 dir = File.join(t, who) | |
634 next unless test(?d, dir) && test(?x, dir) | |
635 pub = File.join(dir, 'pub') | |
7 | 636 if test(?f, pub) && test(?r, pub) && test(?s, pub) && |
637 !personalonly # unneccessary if personal mode | |
0 | 638 if IO.readlines(pub)[0].to_i > 0 |
639 visible = true | |
640 end | |
641 end | |
642 | |
643 | |
644 if ismember(user, who) || visible | |
645 sched[time][who] = {} | |
646 file = File.join(dir, @schedulefile) | |
647 if test(?s, file) && test(?r, file) && test(?s, file) | |
17 | 648 sched[time][who]['sched'] = IO.readlines(file).join.toeuc.chomp! |
6 | 649 sched[time][who]['regtime'] = File.stat(file).mtime |
0 | 650 end |
651 sched[time][who]['pub'] = visible | |
652 end | |
653 } #|who| | |
654 sched.delete(time) if sched[time].empty? | |
655 } | |
656 sched | |
657 end | |
658 | |
659 def scheduledir(user, y, m, d, time) | |
660 sprintf("%s/%04d/%02d/%02d/%04d/%s", | |
44 | 661 @dir, y.to_i, m.to_i, d.to_i, time.to_i, user).untaint |
0 | 662 end |
663 def schedulefile(user, y, m, d, time) | |
664 File.join(scheduledir(user, y, m, d, time), @schedulefile) | |
665 end | |
666 def mkdir_p(path, mode=0777) | |
667 # Do not mkdir `path' for | |
668 # absolute paths | |
669 # those paths which contains `../' | |
670 # for the sake of security reason | |
671 return false if %r,\.\./|^/, =~ path | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
672 path = path.untaint |
0 | 673 p = 0 |
674 i=0 | |
675 while p=path.index("/", p) | |
676 dir = path[0..p].chop | |
677 p += 1 | |
678 break if i > 10 # overprotecting | |
679 next if test(?d, dir) | |
680 Dir.mkdir(dir, mode) | |
681 i += 1 | |
682 end | |
683 Dir.mkdir(path, mode) unless test(?d, path) | |
684 end | |
685 | |
686 # | |
687 # register schedule for user | |
688 # | |
689 def register(user, year, month, day, time, text, replace=nil) | |
690 # return code: 0 = succesfull new registration | |
691 # 1 = succesfull appending registration | |
692 dir = scheduledir(user, year, month, day, time) | |
693 file = schedulefile(user, year, month, day, time) | |
694 ret = 0 | |
695 um = File.umask(027) | |
696 begin | |
697 if !replace && test(?s, file) | |
698 ret = 1 | |
699 else | |
700 mkdir_p(dir, 0777) | |
701 end | |
702 ensure | |
703 File.umask(um) | |
704 end | |
705 open(file, replace ? "w" : "a"){|out|out.print text} | |
706 return ret | |
707 end | |
708 def getschedule(user, year, month, day, time) | |
709 file = schedulefile(user, year, month, day, time) | |
710 if test(?r, file) && test(?s, file) | |
17 | 711 return IO.readlines(file).join.toeuc |
0 | 712 end |
713 return nil | |
714 end | |
715 def remove(user, year, month, day, time) | |
716 file = schedulefile(user, year, month, day, time) | |
717 dir = File.dirname(file) | |
718 if test(?r, file) && test(?s, file) | |
719 File.unlink(file) | |
720 end | |
721 for f in Dir.glob(File.join(dir, "*")) | |
722 f.untaint | |
723 File.unlink(f) | |
724 end | |
725 Dir.rmdir(dir) if test(?d, dir) | |
726 begin | |
727 Dir.rmdir(File.dirname(dir)) | |
728 rescue | |
729 end | |
730 end | |
731 # | |
732 # register file | |
733 # | |
734 def putfile(user, year, month, day, time, file, contents) | |
735 scback = @schedulefile | |
736 begin | |
737 @schedulefile = File.basename(file) | |
738 register(user, year, month, day, time, contents, true) | |
739 ensure | |
740 @schedulefile = scback | |
741 end | |
742 end | |
743 def getfile(user, year, month, day, time, file) | |
744 scback = @schedulefile | |
745 begin | |
746 @schedulefile = File.basename(file) | |
747 getschedule(user, year, month, day, time) | |
748 ensure | |
749 @schedulefile = scback | |
750 end | |
751 end | |
752 def removefile(user, year, month, day, time, file) | |
753 dir = scheduledir(user, year, month, day, time) | |
754 file = File.join(dir, file) | |
755 if test(?e, file) | |
756 File.unlink(file) | |
757 end | |
758 end | |
759 # | |
760 # registration to crondir | |
761 # | |
762 def cronlink_file(nt_time, user, y, m, d, time) | |
763 subdir = nt_time.strftime("%Y-%m-%d-%H%M/#{user}") | |
764 cdir = File.join(@crondir, subdir) | |
765 File.join(cdir, sprintf("%04d-%02d-%02d-%04d", y, m, d, time)) | |
766 end | |
767 def register_crondir(nt_time, user, y, m, d, time) | |
768 linkfile = cronlink_file(nt_time, user, y, m, d, time) | |
769 mkdir_p(File.dirname(linkfile)) | |
770 scfile = schedulefile(user, y, m, d, time) | |
771 if test(?s, scfile) | |
772 sclink = File.join("../../..", scfile.sub!(Regexp.quote(@dir+'/'), '')) | |
773 File.symlink(sclink, linkfile) unless test(?e, linkfile) | |
774 return linkfile | |
775 end | |
776 return false | |
777 end | |
778 def remove_crondir(nt_time, user, y, m, d, time) | |
779 linkfile = cronlink_file(nt_time, user, y, m, d, time) | |
780 scfile = schedulefile(user, y, m, d, time) | |
781 if test(?e, linkfile) | |
782 File.unlink(linkfile) | |
783 begin | |
784 dir = linkfile | |
785 2.times {|x| | |
786 dir = File.dirname(dir) | |
787 if Dir.open(dir).collect.length <= 2 # is empty dir | |
788 Dir.rmdir(dir) | |
789 else | |
790 break | |
791 end | |
792 } | |
793 rescue | |
794 end | |
795 return linkfile | |
796 end | |
797 return false | |
798 end | |
799 | |
800 # | |
801 # return the Hash of crondir {user => files} | |
802 def notify_list(asof) | |
803 slack = 5*60 | |
804 gomifiles = [] | |
805 ntl = {} | |
806 return ntl unless test(?d, @crondir) | |
807 Dir.foreach(@crondir){|datedir| | |
2 | 808 next unless /(\d\d\d\d+)-(\d+)-(\d+)-(\d\d\d\d)/ =~ datedir |
10 | 809 ##datedir = sprintf("%04d-%02d-%02d-%04d", |
810 ## $1.to_i, $2.to_i, $3.to_i, $4.to_i) | |
811 datedir.untaint | |
0 | 812 dd = File.join(@crondir, datedir) |
813 next unless test(?d, dd) | |
814 y, m, d, hm = $1.to_i, $2.to_i, $3.to_i, $4.to_i | |
815 hh = hm/100 % 60 | |
816 mm = (hm%100) % 60 | |
817 t = Time.mktime(y, m, d, hh, mm) | |
818 next if t-slack > asof | |
819 # | |
820 # collect them | |
821 Dir.foreach(dd){|user| | |
2 | 822 # next unless /@/ =~ user || isgroup(user) |
823 next if /^\./ =~ user | |
824 if isgroup(user) | |
825 user = @groupmap.keys.grep(user)[0] | |
826 else | |
827 user = @usermap.keys.grep(user)[0] | |
828 end | |
829 next unless user | |
0 | 830 ud = File.join(dd, user) |
831 next unless test(?d, ud) | |
832 ntl[user] = {} | |
833 Dir.foreach(ud){|date| | |
834 next if /^\./ =~ date | |
835 unless /(\d\d\d\d+)-(\d+)-(\d+)-(\d\d\d\d)/ =~ date | |
836 gomifiles << File.join(ud, date) | |
837 next | |
838 end | |
13 | 839 #date = sprintf("%04d-%02d-%02d-%04d", |
840 # $1.to_i, $2.to_i, $3.to_i, $4.to_i) | |
841 date.untaint | |
0 | 842 f = File.join(ud, date) |
843 if test(?s, f) | |
844 ntl[user][date] = {} | |
845 ntl[user][date]['file'] = f | |
33 | 846 ntl[user][date]['text'] = |
847 IO.readlines(f).collect{|l| l.toeuc} # ...why? :-( | |
0 | 848 else |
849 File.unlink(f) # symlink points to nonexistent file | |
850 end | |
851 } | |
852 if ntl[user].empty? | |
853 # if ud does not contain valid cron symlinks, | |
854 # ud had been left badly. Remove it. | |
855 ntl.delete(user) | |
856 cleanup_files(gomifiles) | |
857 end | |
858 } | |
859 } | |
860 ntl | |
861 end | |
862 # | |
863 # cleanup file and directories | |
864 def cleanup_crondir(time) | |
865 Dir.foreach(@crnondir){|datedir| | |
866 dd = File.join(@crondir, datedir) | |
867 next unless test(?d, dd) | |
868 next unless /(\d\d\d\d+)-(\d+)-(\d+)-(\d\d\d\d)/ =~ dd | |
869 y, m, d, hm = $1.to_i, $2.to_i, $3.to_i, $4.to_i | |
870 hh = hm/100 % 60 | |
871 mm = (hm%100) % 60 | |
872 t = Time.mktime(y, m, d, hh, mm) | |
873 if t < time | |
874 system "rm -rf #{dd}" | |
875 end | |
876 } | |
877 end | |
878 # | |
879 # remove files in FILES, and remove parent directory if possible | |
880 def cleanup_files(files) | |
881 sentinel = File.stat(@dir).ino | |
16 | 882 me = $0.dup.untaint |
883 scriptsuid = File.stat(me).uid | |
0 | 884 for f in files |
2 | 885 if $SAFE > 0 |
886 f.untaint | |
887 if test(?e, f) && File.stat(f).uid != scriptsuid | |
888 f.taint | |
889 end | |
890 end | |
891 printf "Removing %s\n", f if $DEBUG | |
0 | 892 File.unlink(f) if test(?e, f) |
893 d = f | |
894 loop { | |
895 d = File.dirname(d) | |
896 break if d.length < 2 | |
897 break if File.stat(d).ino == sentinel | |
898 begin | |
899 puts "rmdir #{d}" if $DEBUG | |
900 Dir.rmdir(d) | |
901 rescue | |
902 break | |
903 end | |
904 } | |
905 end | |
906 end | |
907 end | |
908 | |
909 class StringIO<IO | |
910 def initialize() | |
911 @str="" | |
912 end | |
913 def foo=(str) | |
914 @str = str | |
915 end | |
2 | 916 def append(str) |
917 @str = str+@str | |
918 end | |
0 | 919 def print(str) |
920 @str << str | |
921 end | |
922 def puts(str) | |
923 @str << str+"\n" | |
924 end | |
925 def printf(*args) | |
926 @str << sprintf(*args) | |
927 end | |
928 def write(bytes) | |
929 print(bytes) | |
930 end | |
931 def gets() | |
932 return nil if @str == '' | |
933 p = @str.index(?\n) | |
934 if p | |
935 r = @str[0..p] | |
936 @str=@str[p+1..-1] | |
937 else | |
938 r = @str | |
939 end | |
940 return r | |
941 end | |
942 def readline() | |
943 this.gets() | |
944 end | |
945 def readlines() | |
946 r = @str | |
947 @str='' | |
948 r | |
949 end | |
950 | |
951 def p(*obj) | |
952 STDOUT.p(*obj) | |
953 end | |
954 end | |
955 | |
956 class CMDTimeout < Exception | |
957 def initialize() | |
958 @pw = IO.pipe | |
959 @pr = IO.pipe | |
960 @pe = IO.pipe | |
961 @timeout = false | |
962 end | |
963 def start(cmd, timeout, mixstderr=false) | |
964 if @pid=fork | |
965 @pw[0].close | |
966 @pr[1].close | |
967 @pe[1].close | |
968 # puts "parent!" | |
969 if @tk=fork | |
970 # main | |
971 else | |
972 @pw[1].close | |
973 @pr[0].close | |
974 @pe[0].close | |
975 trap(:INT){exit 0} | |
976 sleep timeout | |
977 begin | |
978 @timeout = true | |
979 STDERR.puts "TIMEOUT" | |
980 Process.kill :INT, @pid | |
981 rescue | |
982 #puts "Already done" | |
983 end | |
984 exit 0 | |
985 end | |
986 else | |
987 # Running this block with pid=@pid | |
988 trap(:INT){@timeout = true; exit 0} | |
989 @pw[1].close | |
990 STDIN.reopen(@pw[0]) | |
991 @pw[0].close | |
992 | |
993 @pr[0].close | |
994 STDOUT.reopen(@pr[1]) | |
995 if mixstderr | |
996 STDERR.reopen(@pr[1]) | |
997 else | |
998 STDERR.reopen(@pe[1]) | |
999 end | |
1000 @pr[1].close | |
1001 @pe[0].close | |
1002 @pe[1].close | |
1003 | |
15 | 1004 exec(*cmd) |
0 | 1005 exit 0 |
1006 end | |
1007 return [@pw[1], @pr[0], @pe[0]] | |
1008 end | |
1009 def wait() | |
1010 Process.waitpid(@pid, nil) | |
1011 end | |
1012 def close() | |
1013 @pr.each{|p| p.close unless p.closed?} | |
1014 @pw.each{|p| p.close unless p.closed?} | |
1015 @pe.each{|p| p.close unless p.closed?} | |
1016 begin | |
1017 Process.kill :INT, @tk | |
1018 rescue | |
1019 end | |
1020 end | |
1021 def timeout() | |
1022 @timeout | |
1023 end | |
1024 end | |
1025 | |
1026 class Holiday | |
1027 def initialize(dir = ".") | |
1028 @@dir = dir | |
1029 defined?(@@holiday) || setupHoliday | |
1030 end | |
1031 def setupHoliday(file = "holiday") | |
1032 @@holiday = {} | |
1033 return unless test(?f, file) && test(?s, file) | |
1034 IO.foreach(file){|line| | |
17 | 1035 line = line.toeuc.strip |
0 | 1036 next if /^#/ =~ line |
1037 date, what = line.scan(/(\S+)\s+(.*)/)[0] | |
1038 if %r,(\d+)/(\d+)/(\d+), =~ date | |
1039 cdate = sprintf("%d/%d/%d", $1.to_i, $2.to_i, $3.to_i) | |
1040 @@holiday[cdate] || @@holiday[cdate] = [] | |
1041 @@holiday[cdate] << what | |
1042 elsif %r,(\d+)/(\d+), =~ date | |
1043 cdate = sprintf("%d/%d", $1.to_i, $2.to_i) | |
1044 @@holiday[cdate] || @@holiday[cdate] = [] | |
1045 @@holiday[cdate] << what | |
1046 elsif %r,(\d+)/(\w+), =~ date | |
1047 cdate = sprintf("%d/%s", $1.to_i, $2.downcase) | |
1048 @@holiday[cdate] || @@holiday[cdate] = [] | |
1049 @@holiday[cdate] << what | |
1050 end | |
1051 } | |
1052 end | |
1053 def isHoliday(y, m, d, wday=nil) | |
1054 y, m, d = y.to_i, m.to_i, d.to_i | |
1055 wname = %w[sun mon tue wed thu fri sat] | |
35 | 1056 wday = wname[wday || Time.mktime(y, m, d).wday] |
0 | 1057 holiday = @@holiday[sprintf("%d/%d/%d", y, m, d)] || |
1058 @@holiday[sprintf("%d/%d", m, d)] | |
1059 unless holiday | |
1060 nthweek = (d-1)/7+1 | |
1061 holiday = @@holiday[sprintf("%d/w%d%s", m, nthweek, wday)] | |
1062 end | |
35 | 1063 if !holiday && wday == "mon" && d > 0 # d<1 when column is before 1th |
1064 # holiday in lieu | |
1065 yesterday = Time.mktime(y, m, d)-3600*24 | |
1066 holiday = ["振替休日"] if | |
1067 isHoliday(yesterday.year, yesterday.mon, yesterday.day) | |
1068 end | |
0 | 1069 holiday |
1070 end | |
1071 def holidays() | |
1072 @@holiday | |
1073 end | |
1074 end | |
1075 | |
1076 class After5 | |
1077 def initialize() | |
1078 @me = File.expand_path($0) | |
1079 @mydir, @myname = File.dirname(@me), File.basename(@me) | |
1 | 1080 @mybase = @myname.sub(/\.\w+$/, '') |
0 | 1081 @mydir.untaint |
1 | 1082 @mybase.untaint |
0 | 1083 Dir.chdir @mydir |
1 | 1084 @myname='a5.cgi' if test(?f, "a5.cgi") |
0 | 1085 @conf = nil |
1086 @schedulearea = {'rows'=>'4', 'cols'=>'60', 'name'=>'schedule'} | |
1087 @oldagent = (%r,Mozilla/4, =~ ENV['HTTP_USER_AGENT']) | |
2 | 1088 @lang = 0 |
14 | 1089 @mailmode = nil |
57
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
1090 @mailadmdelimiter = "/" |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1091 @mailadmsuffix = @mailadmdelimiter + "adm" |
7 | 1092 @saveprefsregexp = /^(display(mode|days)$|nt|headline)/ |
0 | 1093 @opt = { |
1094 'conf' => @mybase+".cf", | |
1095 'css' => @mybase+".css", | |
13 | 1096 'logfile' => 's/'+@mybase+".log", |
0 | 1097 "sendmail" => "/usr/sbin/sendmail", |
1098 'hostcmd' => '/usr/bin/host', | |
1099 'nslookup' => '/usr/sbin/nsookup', | |
1100 'bg' => 'ivory', | |
8 | 1101 'name' => nil, |
0 | 1102 'at_bsd' => '%H:%M %b %d %Y', |
1103 'at_solaris' => '%H:%M %b %d,%Y', | |
1104 'schedir' => 's', | |
1105 'tdskip' => '<br>', | |
1106 'forgot' => 'wasureta', | |
1107 'size' => @oldagent ? '15' : '40', | |
1108 'morning' => '6', | |
1109 'night' => '22', | |
1110 'alldaydir' => '3000', | |
1111 'pswdlen' => 4, | |
6 | 1112 'pswddb' => 's/a5pswd', |
2 | 1113 'lang' => 'j', |
6 | 1114 'notifymail' => true, |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1115 'mailbracket' => '[%n-ML]', |
0 | 1116 } |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1117 @subjtags = [['[GroupID:#]', "[%i:%c]"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1118 ['[GroupID:#####]', "[%i:%5c]"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1119 ['[GroupName:#]', "[%n:%c]"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1120 ['[GroupName:#####]', "[%n:%5c]"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1121 ['(GroupID:#)', "(%i:%c)"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1122 ['(GroupID:#####)', "(%i:%5c)"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1123 ['(GroupName:#)', "(%n:%c)"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1124 ['(GroupName:#####)', "(%n:%5c)"]] |
0 | 1125 ##@job = "today" |
3 | 1126 @wnames = %w[sun mon tue wed thu fri sat] |
0 | 1127 @job = "login" |
1128 @sc = ScheduleDir.new | |
1129 @O = StringIO.new | |
1130 @H = HTMLout.new() | |
1131 @umback = File.umask | |
1132 @author = 'yuuji@gentei.org' | |
1133 @after5url = 'http://www.gentei.org/~yuuji/software/after5/' | |
1134 File.umask(007) | |
1135 end | |
1136 def doit() | |
1137 @params = getarg() | |
1138 @cookie = getcookie() | |
3 | 1139 importcookie() |
2 | 1140 @lang = (/^j/i =~ @opt['lang'] ? 0 : 1) |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1141 @ntlist = [ # this shoud be set after @lang |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1142 ['nt10m', "10"+msg('minutes', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1143 ['nt30m', "30"+msg('minutes', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1144 ['nt60m', "60"+msg('minutes', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1145 ['nttoday', msg('theday')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1146 ['nt1d', "1"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1147 ['nt2d', "2"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1148 ['nt3d', "3"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1149 ['nt7d', "7"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1150 ['nt30d', "30"+msg('days', 'before')], |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1151 ] |
0 | 1152 p @cookie if $DEBUG |
1153 p @params if $DEBUG | |
1154 | |
3 | 1155 ### @params['displaymode'] = @params['displaymode'] || @cookie['displaymode'] |
2 | 1156 personal = /personal/i =~ @params['displaymode'] |
1157 bodyclass = if personal then {'class'=>'personal'} end | |
0 | 1158 |
1159 ## x = {"align"=>'center'} | |
1160 ## @H.element("p", x, "hoge", nil) | |
1161 ## @H.element("p", nil, "buha", nil) | |
1162 | |
3 | 1163 if nil |
0 | 1164 if !@params['passwd'] && @cookie['passwd'] |
1165 @params['passwd'] = @cookie['passwd'] | |
1166 end | |
1167 if !@params['user'] && @cookie['user'] | |
1168 @params['user'] = @cookie['user'] | |
1169 end | |
3 | 1170 end |
0 | 1171 @params['user'] = safecopy(@params['user']) |
2 | 1172 |
15 | 1173 ######eval @job |
8 | 1174 a5name = if @opt['name'] && @opt['name'] > '' |
1175 sprintf("(%s)", @opt['name']) | |
1176 else | |
1177 "" | |
1178 end | |
2 | 1179 @O.append(@H.contenttype() + |
8 | 1180 @H.head(a5name+"After 5"+@job.sub(/\s*/, ' '), @opt['css'])) |
2 | 1181 @O.print @H.startelement("body", bodyclass, true) |
15 | 1182 # @job should be here because its output shoud go after <body>. |
1183 eval @job | |
0 | 1184 @O.print @H.endelement(nil, true) # body |
14 | 1185 @O.print @H.endelement("html", true) # html |
0 | 1186 setcookie() |
1187 | |
1188 print @O.readlines | |
1189 end | |
1190 def msg(*keyword) | |
1191 unless defined?(@msg) | |
1192 @msg = { | |
3 | 1193 'title' => ['みんなの予定表 <img src="after5.png" alt="「アフター5」">', 'Schedule table for us all <img src="after5.png" alt="After 5">'], |
0 | 1194 'login' => ['ログイン', 'Login'], |
1195 'loginfirst' => ['最初にログインすべし', 'Login first'], | |
1196 'autherror' => ['認証エラーがあったと管理者に伝えてくれっす', | |
1197 'Unexpected authentication error. Please tell this to the administrator'], | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1198 'yourmail' => ['あなたのメイルアドレス', 'Your email address'], |
0 | 1199 'passwd' => ['パスワード<br>(初回時は空欄)', |
1200 'Passowrd<br>Left blank, first time'], | |
1201 'error' => ['エラー:', 'Error: '], | |
1202 'mailerror' => ['メイルアドレスが違います', 'Invalid email address'], | |
1203 'pswderror' => ['パスワードが違います', 'Password incorrect'], | |
22
8803e5d52611
Show guidance when wrong password entered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
18
diff
changeset
|
1204 'forgotguide' => ['忘れた場合は %s と入力するよろし', |
8803e5d52611
Show guidance when wrong password entered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
18
diff
changeset
|
1205 "Put \`%s' when you forgot password."], |
8 | 1206 'fmtdaysschedule'=> ['%s〜の予定', 'Schedule from %s'], |
18 | 1207 'schedtable' => ['予定表', 'Schedule Table'], |
0 | 1208 'noplan' => ['登録されている予定はありません', 'No plans'], |
1209 'allday' => ['全日', 'whole day'], | |
1210 'addsched' => ['新規予定項目の登録', 'Register new schedule'], | |
1211 'defthisday' => ['デフォルトの日付はこの日になってま', ''], | |
1212 '24hour' => ['24時間制4桁でね<br>(0000〜2359)<br>%sは時刻指定なし', 'in 24-hour<br>(0000-2359)<br>%s for whole day'], | |
14 | 1213 '24hourtxt' => ['24時間制4桁でね(0000〜2359), %sは時刻指定なし', 'in 24-hour(0000-2359), %s for whole day'], |
0 | 1214 'reqnotify' => ['通知メイルいるけ?', 'Previous notification'], |
1215 'rightnow' => ['登録時にすぐ', 'Right now on registration'], | |
1216 'immediatenote' => ['に以下の予定を登録しました', | |
1217 ", Your schedule has been registered as follows;"], | |
1218 'registerer_is' => ['登録名義: ', 'Register as '], | |
1219 'registerer' => ['登録者: ', 'registerer: '], | |
1220 'about' => ['約', 'about'], | |
1221 'minutes' => ['分', 'minutes'], | |
1222 'hours' => ['時間', 'hour(s)'], | |
1223 'days' => ['日', 'day(s)'], | |
2 | 1224 'daystodisplay' => ['日分表示', 'days to display'], |
0 | 1225 'before' => ['前', 'before'], |
2 | 1226 'precedingday' => ['前日', 'Preceding day'], |
0 | 1227 'theday' => ['当日朝', "the day's morning"], |
1228 'night' => ['(夜)', '(night)'], | |
63
e2aa6180c2c6
Show the number of group member in groupman().
HIROSE Yuuji <yuuji@gentei.org>
parents:
62
diff
changeset
|
1229 'publicok' => ['アカウント保持者全員<br>に見せてもええね?', |
e2aa6180c2c6
Show the number of group member in groupman().
HIROSE Yuuji <yuuji@gentei.org>
parents:
62
diff
changeset
|
1230 'visible to anyone who has account of this board?'], |
0 | 1231 'public' => ['公', 'pub'], |
1232 'nonpublic' => ['非', 'sec'], | |
2 | 1233 'through' => ['〜', '=>'], |
0 | 1234 'yes' => ['はいな', 'yes'], |
29
e7a01e561e28
Message 'no' should contain only 'no'.
HIROSE Yuuji <yuuji@gentei.org>
parents:
28
diff
changeset
|
1235 'no' => ['やだ', 'nope'], |
2 | 1236 'wnames' => [%w[日 月 火 水 木 金 土], |
1237 %w[sun mon tue wed thu fri sat]], | |
1238 'whichday' => ['<small>(まとめ登録の場合)</small><br>期間中のどの日に?', | |
1239 '<small>(On multiple registration)</small><br>Which days in the term?'], | |
1240 'singleday' => ['一日分だけ登録', '1day regist'], | |
1241 'everyday' => ['毎日', 'everyday'], | |
0 | 1242 'invaliddate' => ['日付指定が変みたい', 'Invalid time string'], |
1243 'past' => ['それはもう過去の話ね', 'It had Pasted'], | |
1244 'putsomething' => ['何か書こうや', 'Write some message please'], | |
1245 'appended' => ['既存の予定に追加しました', 'Appended'], | |
1246 'append' => ['追加', 'append'], | |
1247 'join' => ['参加', 'join'], | |
1248 'regist' => ['登録', 'register'], | |
1249 'remove' => ['削除', 'remove'], | |
14 | 1250 'move' => ['移動', 'move'], |
1251 'newdate' => ['移動先時刻', 'New date'], | |
0 | 1252 'deletion' => ['完全消去', 'deletion'], |
1253 'deletionwarn' => ['OK押したら即消去。確認とらないぞ', | |
1254 'Hitting OK immediately delets this group, be carefully!'], | |
1255 'deluser' => ['%s ユーザ消してええかの?', "Delete the user `%s'"], | |
1256 'delgroup' => ['%s グループ消してええかの?', "Delete the group `%s'"], | |
1257 'really?' => ['ほんまにええけ?', 'Really?'], | |
1258 'chicken' => ['ふっ、腰抜けめ', 'Hey, chicken boy'], | |
1259 'modify' => ['修正', 'modify'], | |
1260 'done' => ['完了', 'done'], | |
1261 'success' => ['成功', 'success'], | |
1262 'failure' => ['失敗', 'failure'], | |
1263 'tomonthlist' => ['%s の一覧', 'all %s table'], | |
1264 'notifysubj' => @mybase+"'s reminder for your plan", | |
1265 'introduce' => ['はいこんにちは、'+@mybase+'ですよ〜。', | |
1266 "Hi, this is #{@mybase}'s notification."], | |
1267 'notifymail' => ['こんな予定がありまっせ。', | |
1268 "You have some eschedule below;"], | |
1269 'notification' => ['の通知', 'notification'], | |
1270 'newaccount' => ["新しいアカウントを作りました。\n"+ | |
1271 "パスワードは %s さん宛に送信しておきました。\n", | |
1272 "You got new account for #{@mybase}\n" + | |
1273 "Password was sent to %s.\nThank you.\n"], | |
1274 'accessfrom' => ["%s からのアクセスによる送信\n", | |
1275 "This mail was sent by the access from %s\n"], | |
1276 'newpassword' => ["%s さんのパスワードは %s です。\n", | |
1277 "The password of %s is %s\n"], | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1278 'mischief' => ["身に覚えのない場合はMLへの代理登録の可能性があります。 |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1279 上記URLが見慣れたものならばアクセスしてみるか、 |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1280 このURLの管理人(%s さん)に問い合わせてみて下さい。 |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1281 それらも心当たりのない場合はいたずらです。対処しますので管理人まで御連絡下さい。", |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1282 'If you have no idea of the reason for getting this message, '+ |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1283 'it may be a invitation of mailing list from your friend. |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1284 Please try to access URL above if it is familiar one or |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1285 contact to the administrator of the site(is %s). |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1286 If you have completely no clue for this invitation, |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1287 it might be a mischief by someone else. Please notice the fact |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1288 to the administrator. Thank you.'], |
0 | 1289 'user' => ['ユーザ', 'user'], |
1290 'group' => ['グループ', 'group'], | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1291 'mladdress' => ['公開MLアドレス(%s以外にしたい場合設定する)', |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1292 "Public ML address(if you set to diffrent address than `%s')"], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1293 'fromhack' => ['ML配送時のFrom:を常にMLのアドレスにする |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1294 (From:にしか返さないケータイ参加者が多いときにオススメ)', |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1295 'Set From: address of all ML messages to ML address, which is convenient |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1296 to keep responses from cellular phones surely to ML address. Most cellular |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1297 phones tend to return only from: address.'], |
66 | 1298 'inviteonly' => ['管理者のみ加入操作可能', |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1299 'Only administrators can add new members.'], |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1300 'invite-error' => ['%s への加入はグループ管理者のみが操作できます。', |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
1301 "Only administrator of this group(`%s') can add you."], |
0 | 1302 'personal' => ['個人で', 'personal'], |
17 | 1303 'registas' => ['グループ予定として登録?', 'Register as group?'], |
1304 'headsched' => ['下の枠内に予定を記入: 1行以内で短めに。 | |
1305 長くなるときは2行目以降に詳細を。', | |
1306 'Put shortest sentence as possible within 1 line. | |
1307 Or, put short subject in the first line, details in latter lines.'], | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1308 'joinquit' => ['入退会', 'joining/quiting'], |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1309 'operation' => ['操作', 'operation'], |
0 | 1310 'of' => ['の', "'s"], |
47 | 1311 'id' => ['ID(英単語かローマ字の分かりやすい1単語半角空白なしで)', 'ID(without spaces)'], |
0 | 1312 'name' => ['名前', 'name'], |
1313 'anystring' => ['(日本語OK)', '(any length, any characters)'], | |
1314 'setto' => ['を設定 → ', 'set to '], | |
2 | 1315 'dupname' => ['あー、%sってグループ名は既にあるん素。別のにして.', |
1316 "Group name `%s' already exists, choose another name."], | |
0 | 1317 'management' => ['管理', 'management'], |
1318 'administrator' => ['管理者', 'Administrator'], | |
1319 'newgroup' => ['新規グループ作成', 'Create new group'], | |
1320 'adminop' => ['管理<br>操作', "Administrative<br>operation"], | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1321 'sendall' => ['一斉送信', "write to members"], |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1322 'sendall_err' => ["%s ファイルで mailprefix と maildomain を定義しとかないと送れまへん。 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1323 例: mailprefix=yuuji-after5 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1324 maildomain=gentei.org |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1325 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1326 さらに、.qmail-$mailprefix-default も以下のように用意しておこね。 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1327 | ./#{@myname} -list", |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1328 "You should define `mailprefix' and `maildomain' in %s file before |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1329 sending message to all. |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1330 (ex.) mailprefix=yuuji-after5 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1331 maildomain=gentei.org |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1332 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1333 And then prepare .qmail-$mailprefix-default file as below. |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1334 | ./#{@myname} -list"], |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1335 'sendall_head' => ['「%s」宛のメイル送信', "Send message to `%s'"], |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1336 'sendall_note' => ['メンバーへの連絡だけでなく、グループ非加入者がこれから加入する旨の通知などにも有用。', |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1337 "Send this message to all of group."], |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1338 'sendall_done' => ['送信完了', "sending message done"], |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1339 'body' => ['本文', 'Body'], |
0 | 1340 'member' => ['メンバー', 'Member'], |
2 | 1341 'personalmode' => ['自分のだけ表示モード', 'Display Personal Only'], |
1342 'normalmode' => ['全員分表示モード', "Display Everyone's"], | |
3 | 1343 'display' => ['予定表示行: ', 'Display schedule of: '], |
1344 'nameonly' => ['名前のみ', 'Name Only'], | |
1345 'head5char' => ['先頭5文字', 'Head 5 chars'], | |
1346 'headline' => ['先頭1行', 'Headline only'], | |
1347 'whole' => ['長くても全部', 'Whole text'], | |
6 | 1348 'hldays' => ['最新X日分強調', 'Hilight Recent X-days'], |
0 | 1349 'addedtogroup' => ['をグループに追加 →', 'added to the group:'], |
1350 'removedfromgp' => ['をグループから削除:', 'removed from the group:'], | |
1351 'soleadmin' => ['%s は %s の唯一の管理者なのでやめられないのだ', | |
1352 "%s is sole administrator of %s. Cannot retire."], | |
1353 'recursewarn' => ['個人では加入してないが、別の加入グループがこのグループに入っているので実質参加していることになっている。', | |
1354 'Though this member does not join to this group, it is assumed to be joining this group because other group where one joins is joined to this group.'], | |
1355 'regaddress' => ['登録アカウント名', 'Account id'], | |
1356 'existent' => ['既にあるんすよ → ', 'Already exists: '], | |
1357 'mailaddress' => ['通知送付先アドレス', 'Notification email address'], | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1358 'multipleok' => ['<br>(スペースで区切って複数指定可)', |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1359 '<br>(Two or more addresses are OK by delimiting with space.)'], |
0 | 1360 'weburl' => ['ゲストブックとかURL<br><small>(予定への反応を書いて欲しい場所)</small>', 'Your guest book URL'], |
1361 'usermodwarn' => ['いちいち yes/no とか確認取らないから押したら最後、気いつけて。', | |
1362 'This is the final decision. Make sure and sure.'], | |
1363 'joinmyself' => ['自分自身が既存のグループに対して入る(IN)か出る(OUT)かを決めるのがここ。自分管理のグループに誰かを足すなら「管理操作」、新たにグループを作るなら', | |
1364 'In this page, you can decide put yourself IN or OUT of the existing groups. If you want to manage the member of your own group, go to'], | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1365 'aboutgroup' => ['グループ %s の操作', "Operations on group `%s'"], |
0 | 1366 'groupwarn' => ['自分が参加してないグループAに、自分が参加しているグループBが含まれている場合、グループAにも加入していると見なされるので気をつけよう。管理者はグループのニックネームを変えられるよ。', |
1367 'Though you are not member of group A, you are treated as a member of A, if you join to the group B, which is a member of A. Think the nesting of groups carefully, please. Group administrator can change the group nickname.'], | |
1368 'wholemembers' => ['グループ内グループを考慮した上で、現在グループ %s への通知は以下のメンバーに送られる。', | |
1369 "Consiering the groups registered in another group, notification to the group `%s' is send to members as follows."], | |
1370 'noadmingroup' => ['管理できるグループはないっす', | |
1371 "'There's no groups under your administration."], | |
1372 'nickname' => ['ニックネーム', 'nickname'], | |
1373 'shortnameplz' => ['表が崩れるほど長すぎるニックネームは嫌われるよ。短めにね。', | |
1374 'Because nickname is displayed many times in table, shorter name is prefered.'], | |
1375 'nicknamenote' => ['ニックネームを消去するとデフォルト名になりんす.', | |
1376 'Default name is displayed if you remove nickname.'], | |
1377 'nothingtodo' => ['って何もやることあらへんかったで', | |
14 | 1378 'Nothing to do for this transaction.'], |
1379 'schedlist' => [' and %d days Schedule list', | |
1380 'から%d日間の予定一覧'], | |
1381 'nothing' => ['なんもないす', 'Nothing'], | |
1382 'sessionpswd' => ['セッションパスワード(これはいじらないでね)', | |
1383 'Session Password(Do not modify this)'], | |
1384 'date' => ['日付', 'Date'], | |
1385 'time' => ['時刻指定', 'Time'], | |
1386 'publicp' => ['公開=yes、非公開=no', 'Public?'], | |
1387 'neednotify' => ['通知メイル(要らないのは消してね)', | |
1388 'Leave lines for notification timing'], | |
1389 'schedulehere' => ['以下登録内容', 'Your Schedule below'] | |
0 | 1390 } |
1391 end | |
1392 keyword.collect{|k| | |
1393 if @msg[k].is_a?(Array) | |
2 | 1394 @msg[k][@lang] |
0 | 1395 elsif @msg[k].is_a?(String) |
1396 @msg[k] | |
1397 else | |
1398 '' | |
1399 end | |
2 | 1400 }.join(['', ' '][@lang]) |
0 | 1401 end |
1402 | |
3 | 1403 def importcookie() |
7 | 1404 @cookie.keys.grep(@saveprefsregexp){|v| |
3 | 1405 @params[v] = @params[v] || @cookie[v] |
1406 } | |
7 | 1407 for v in %w[user passwd] |
1408 @params[v] = @params[v] || @cookie[v] | |
1409 end | |
3 | 1410 end |
0 | 1411 def setcookie() |
7 | 1412 a = {} |
1413 a['user'] = @params['user'] if @params['user'] | |
1414 a['passwd'] = @params['passwd'] if @params['passwd'] | |
1415 ac = gencookie("value", a, 3600*6*1) | |
1416 printf "Set-Cookie: %s\n", ac if ac | |
0 | 1417 p = {} |
7 | 1418 @params.keys.grep(@saveprefsregexp){|v| |
6 | 1419 p[v] = @params[v].to_s.strip if @params[v] && @params[v] > '' |
0 | 1420 } |
7 | 1421 c = gencookie("prefs", p, 3600*24*7) |
1422 str = [ac, c].select{|x|x}.join("; ") | |
1423 # printf "Set-Cookie: %s\n", str if str>'' | |
0 | 1424 printf "Set-Cookie: %s\n", c if c |
1425 end | |
1426 | |
1427 def encode(string) # borrowed from cgi.rb | |
1428 string.gsub(/([^ a-zA-Z0-9_.-]+)/n) do | |
1429 '%' + $1.unpack('H2' * $1.size).join('%').upcase | |
1430 end.tr(' ', '+') | |
1431 end | |
14 | 1432 def purify(string) |
1433 string.gsub(/[\040-\177]/) {encode($&)} | |
1434 end | |
0 | 1435 def decode!(string) |
1436 string.gsub!(/\+/, ' ') | |
1437 string.gsub!(/%(..)/){[$1.hex].pack("c")} | |
1438 end | |
14 | 1439 def decode(string) |
17 | 1440 string.gsub(/\+/, ' ').gsub(/%(..)/){[$1.hex].pack("c")} |
14 | 1441 end |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1442 def escape(string) |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1443 string.gsub(/&/n, '&').gsub(/\"/n, '"'). |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1444 gsub(/>/n, '>').gsub(/</n, '<') |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1445 end |
0 | 1446 |
7 | 1447 def gencookie(name, a, expire) |
0 | 1448 x = a.collect{|k, v| |
1449 sprintf("%s=%s", k, encode(v)) if v | |
1450 } | |
1451 x.delete(nil) | |
1452 return nil if x.empty? | |
1453 str = x.join('&') | |
1454 ex = (Time.new+expire).to_s | |
7 | 1455 sprintf "%s=%s; expires=%s", name, encode(str), ex |
0 | 1456 end |
1457 | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1458 def login(altaction = nil) |
0 | 1459 @O.print @H.elementln("h1", nil){msg('title')} |
1460 @O.print @H.elementln("h2", nil){msg('login')} | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1461 format = {'method'=>'POST', |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1462 'action'=> @myname+"?" +(altaction || "-today")} |
0 | 1463 @O.print @H.elementln("form", format){ |
1464 @H.elementln("table", nil){ | |
1465 @H.elementln("tr", nil){ | |
1466 @H.element("td", nil){msg('yourmail')} + \ | |
1467 @H.element("td", nil){ | |
1468 sprintf '<input type="text" size="%s" name="user">', @opt['size'] | |
1469 } | |
1470 } + \ | |
1471 @H.elementln("tr", nil){ | |
1472 @H.element("td", nil){msg('passwd')} + \ | |
1473 @H.element("td", nil){ | |
1474 sprintf '<input type="password" size="%s" name="passwd">', @opt['size'] | |
1475 } | |
1476 } | |
1477 } + '<input type="submit" value="LOGIN">' | |
1478 } | |
1479 @O.print footer2() | |
1480 end | |
1481 def open_pm() | |
1482 begin | |
1483 PasswdMgr.new(@opt['pswddb']) | |
1484 rescue | |
1485 STDERR.printf "Cannot open pswd file [%s]\n", @opt['pswddb'] | |
1486 STDERR.printf "euid=#{Process.euid}, uid=#{Process.uid}\n", @opt['pswddb'] | |
1487 nil | |
1488 end | |
1489 end | |
1490 def outputError(*msg) | |
1491 @O.print @H.p(msg('error')+sprintf(*msg)) | |
1492 end | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1493 def mailaddress(user, grp=nil) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1494 @sc.mailaddress(user, grp) |
0 | 1495 end |
1496 def webpage(user) | |
1497 @sc.getuserattr(user, "webpage") | |
1498 end | |
14 | 1499 def checkauth_mail() |
1500 return true # temporary | |
1501 end | |
0 | 1502 def checkauth() |
14 | 1503 if @mailmode && @params['sessionpw'] |
1504 return checkauth_mail | |
1505 end | |
1506 auth = catch(:auth) { | |
0 | 1507 unless @params['user'] |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1508 #outputError(@H.a(@myname, msg('loginfirst'))) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1509 login(@oldargv.join('+')) |
0 | 1510 throw :auth, nil |
1511 end | |
1512 unless pm=open_pm() | |
1513 outputError(msg('autherror')) | |
1514 throw :auth, nil | |
1515 end | |
1516 user, passwd = @params['user'], @params['passwd'] | |
1517 email = mailaddress(user) | |
1518 if !checkmail(user) | |
1519 outputError(msg('mailerror')) | |
1520 throw :auth, nil | |
1521 end | |
1522 if pm.userexist?(user) | |
1523 if pm.checkpasswd(user, passwd) | |
1524 throw :auth, true | |
1525 elsif passwd == @opt['forgot'] | |
1526 newp = pm.setnewpasswd(user, @opt['pswdlen']) | |
1527 sendMail(email, "#{@mybase} password", | |
1528 "(#{ENV['REMOTE_ADDR']} からのアクセスによる送信)\n" + | |
7 | 1529 @opt['url'] + "\n" + |
0 | 1530 "#{@mybase} 用の #{user} さんのパスワードは\n" + |
1531 (newp || "未定義") + "\nです。\n") | |
1532 @O.print @H.p("#{email} 宛に送信しておきました") | |
1533 throw :auth, nil | |
1534 else | |
1535 outputError(msg('pswderror')) | |
22
8803e5d52611
Show guidance when wrong password entered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
18
diff
changeset
|
1536 @O.print @H.p(sprintf(msg('forgotguide'), @opt['forgot'])) |
0 | 1537 throw :auth, nil |
1538 end | |
7 | 1539 elsif passwd == '' |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1540 # Create new user from Web-UI |
0 | 1541 newp = pm.setnewpasswd(user, @opt['pswdlen']) |
1542 @sc.createuser(user, user) | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1543 putLog("New user [#{user}] created\n") |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1544 sendMail(@opt['maintainer'], "After5 New User", |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1545 sprintf("URL=%s\nREMOTE_ADDR=%s\nuser=%s", |
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1546 @opt['url'], ENV['REMOTE_ADDR'], user)) |
0 | 1547 sendMail(email, "#{@mybase} new account", |
1548 sprintf(msg('accessfrom'), ENV['REMOTE_ADDR']) + | |
7 | 1549 sprintf(@opt['url']) + "\n" + |
0 | 1550 sprintf(msg('newpassword'), user, newp) + |
1551 sprintf(msg('mischief'))) | |
1552 @O.print @H.p(sprintf(msg('newaccount'), user)) | |
1553 @O.print @H.p(@H.a(@myname, msg('login'))) | |
1554 throw :auth, nil | |
7 | 1555 else |
1556 outputError(msg('pswderror')) | |
1557 throw :auth, nil | |
0 | 1558 end |
1559 } | |
1560 if auth | |
1561 return true | |
1562 else | |
1563 return false | |
1564 end | |
1565 end | |
1566 def safecopy(string) | |
1567 return nil unless string | |
1568 if $SAFE > 0 | |
1569 cpy='' | |
1570 string.split('').each{|c| | |
1571 cpy << c[0].chr if c[0] != ?` # ` | |
1572 } | |
28 | 1573 cpy.untaint |
0 | 1574 else |
1575 string | |
28 | 1576 end |
0 | 1577 end |
1578 def checkmail(mail) | |
1579 account, domain = mail.scan(/(.*)@(.*)/)[0] | |
1580 return false unless account != nil && domain != nil | |
17 | 1581 return false unless /^[-0-9a-z_.]+$/oi =~ domain.toeuc |
0 | 1582 domain = safecopy(domain) |
1583 require 'socket' | |
1584 begin | |
1585 TCPSocket.gethostbyname(domain) | |
1586 return true | |
1587 rescue | |
1588 if test(?x, @opt["hostcmd"]) | |
1589 open("| #{@opt['hostcmd']} -t mx #{domain}.", "r") {|ns| | |
1590 #p ns.readlines.grep(/\d,\s*mail exchanger/) | |
1591 return ! ns.readlines.grep(/is handled .*(by |=)\d+/).empty? | |
1592 } | |
1593 elsif test(?x, @opt["nslookup"]) | |
1594 open("| #{@opt['nslookup']} -type=mx #{domain}.", "r") {|ns| | |
1595 #p ns.readlines.grep(/\d,\s*mail exchanger/) | |
1596 return ! ns.readlines.grep(/\d,\s*mail exchanger/).empty? | |
1597 } | |
1598 end | |
1599 return false | |
1600 end | |
1601 end # checkmail | |
1602 | |
1603 # Logging | |
1604 # | |
1605 def putLog(msg) | |
1606 msg += "\n" unless /\n/ =~ msg | |
1607 open(@opt["logfile"], "a+") {|lp| | |
1608 lp.print Time.now.to_s + " " + msg | |
1609 } | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1610 msg |
0 | 1611 end |
1612 | |
1613 def sendnotify(whom, subj, body) | |
1614 users = users() | |
1615 if grepgroup(whom) | |
1616 recipients = @sc.members(whom) | |
1617 else | |
1618 recipients=[whom] | |
1619 end | |
1620 for u in recipients | |
1621 if users.grep(u)[0] | |
1622 sendMail(mailaddress(u), subj, body) | |
1623 end | |
1624 end | |
1625 end | |
1626 | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1627 def dospool(dir, outhandle) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1628 seq=1 |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1629 seqfile=File.expand_path("seq", dir).untaint |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1630 spooldir=File.expand_path("spool", dir).untaint |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1631 test(?d, spooldir) or Dir.mkdir(spooldir) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1632 if test(?s, seqfile) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1633 seq=open(seqfile, "r"){|s|s.gets.to_i} |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1634 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1635 seq+=1 while test(?s, (newfile=sprintf("%s/%d", spooldir, seq))) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1636 open(newfile, "w") do |spoolfile| |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1637 countdone = nil |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1638 while line=STDIN.gets |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1639 if !countdone && /^X-ML-Name: / =~ line |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1640 line += sprintf("X-Mail-Count: %d\n", seq) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1641 coutndone=true |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1642 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1643 spoolfile.print line |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1644 outhandle.print line |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1645 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1646 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1647 open(seqfile, "w"){|s| s.puts seq.to_s} # update `seq' file |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1648 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1649 def mlseq(dir) |
65
3e91dd66deb6
Return 1 if /seq file is not there.
HIROSE Yuuji <yuuji@gentei.org>
parents:
64
diff
changeset
|
1650 test(?s, (seqfile = dir+"/seq")) ? |
3e91dd66deb6
Return 1 if /seq file is not there.
HIROSE Yuuji <yuuji@gentei.org>
parents:
64
diff
changeset
|
1651 open(seqfile, "r"){|s|s.gets.to_i+1} |
3e91dd66deb6
Return 1 if /seq file is not there.
HIROSE Yuuji <yuuji@gentei.org>
parents:
64
diff
changeset
|
1652 : 1 |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1653 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1654 def sendMail(to, subject, body, from=nil, rcptto=nil, header={}, |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1655 thru=nil, spoolto=false) |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1656 body = NKF.nkf("-j", body) unless thru |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1657 subject = NKF.nkf("-jM", subject.strip) |
0 | 1658 to = safecopy(to) # cleanup tainted address |
1659 subject.gsub!(/\n/, '') | |
1660 begin | |
1661 if (m=open("|-", "w")) | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1662 header.each do |h, v| |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1663 m.printf("%s: %s\n", h.strip, v.strip) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1664 end |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1665 unless thru |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1666 m.print "To: #{to}\n" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1667 from and m.print "From: #{from}\n" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1668 m.print "Subject: #{subject}\n" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1669 m.puts "Mime-Version: 1.0 |
0 | 1670 Content-Transfer-Encoding: 7bit |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1671 Content-Type: Text/Plain; charset=iso-2022-jp" |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
1672 m.puts "Date: #{Time.now.strftime("%a, %d %Y %T %z")}" |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1673 m.print "\n" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1674 end |
0 | 1675 m.print body, "\n" |
1676 m.close | |
1677 else | |
1678 # exec(@attr['mail'], "-s", subject, to) | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
1679 recipient = rcptto || to.split(/,\s*|\s+/) |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1680 #p recipient |
56 | 1681 File.umask(027) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1682 if spoolto && spoolto.is_a?(String) && |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1683 proc { |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1684 require 'fileutils' |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1685 begin |
67
a421c2fefc32
Fix the argument for FileUtils.mkdir_p()
HIROSE Yuuji <yuuji@gentei.org>
parents:
66
diff
changeset
|
1686 test(?d, spoolto) or FileUtils.mkdir_p(spoolto, :mode => 0750) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1687 test(?w, spoolto) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1688 rescue |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1689 nil |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1690 end}.call && |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1691 (tee=open("|-", "w")) # popen should be done in if-condition |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1692 dospool(spoolto, tee) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1693 else |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1694 if ENV['MAILCMD'] |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1695 #exec("qmail-inject", "yuuji@gentei.org", "yuuji@koeki-u.ac.jp") |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1696 open("/tmp/body", "w") {|w| w.print STDIN.readlines.join |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1697 w.puts "---" |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1698 w.puts recipient.join(",\n") |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1699 } |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1700 exit 0 |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1701 else |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1702 #recipient.unshift "-f"+header['return-path'] if header['return-path'] |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1703 exec(ENV['MAILCMD'] || @opt['sendmail'], *recipient) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
1704 end |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
1705 end |
0 | 1706 exit 0; |
1707 end | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
1708 putLog("Sent '#{subject.toeuc}' to #{to}\n") |
0 | 1709 return true |
1710 rescue | |
1711 putLog("FAILED! - Sent '#{subject}' to #{to}\n") | |
1712 return nil | |
1713 end | |
1714 end # sendMail | |
1715 | |
1716 def today() | |
1717 today = Time.now | |
1718 showtable(today) | |
1719 end | |
1720 def isleap?(y) | |
1721 if y%400 == 0 | |
1722 true | |
1723 elsif y%100 == 0 || y%4 != 0 | |
1724 false | |
1725 else | |
1726 true | |
1727 end | |
1728 end | |
1729 def daysofmonth(year, month) | |
1730 dl = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] | |
1731 if month != 2 || !isleap?(year) | |
1732 dl[month-1] | |
1733 else | |
1734 29 | |
1735 end | |
1736 end | |
1737 # | |
1738 # Return the Time object at the last day of last month | |
1739 def lastmonth(today) | |
1740 Time.at(Time.mktime(today.year, today.month)-3600*24) | |
1741 end | |
1742 # | |
1743 # Return the Time object at the first day of next month | |
1744 def nextmonth(today) | |
1745 y, m = today.year, today.month | |
1746 Time.at(Time.mktime(y, m, daysofmonth(y, m))+3600*24) | |
1747 end | |
1748 | |
1749 def month(month) | |
1750 y, m = month.scan(%r,(\d\d\d\d+)/(\d+),)[0] | |
1751 if y && m | |
1752 showtable(Time.mktime(y, m, 1)) | |
1753 else | |
1754 outputError "%s %s", msg('invaliddate'), month | |
1755 return nil | |
1756 end | |
1757 end | |
1758 def footer1() | |
1759 "<br>" + \ | |
1760 @H.element("p"){ | |
1761 me = @myname+"?-"; delim = " / " | |
1762 @H.a(me+'userman', msg('user', 'management')) + delim + \ | |
2 | 1763 @H.a(me+'groupman', msg('group', 'management')) + delim + \ |
1764 if /personal/i =~ @params['displaymode'] | |
1765 @H.a(me+'today_n', msg('normalmode')) | |
1766 else | |
1767 @H.a(me+'today_p', msg('personalmode')) | |
1768 end | |
0 | 1769 } |
1770 end | |
1771 | |
1772 def footer2() | |
1773 "<hr>" + \ | |
1774 @H.element("code") { | |
1775 "This " + \ | |
1776 @H.a(@after5url, "After5") + \ | |
1777 " board is maintained by " + \ | |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
1778 @opt['maintainer'].gsub(".", "<span>.</span>"). |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
1779 sub('@', "@") + \ |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
1780 '<span style="display: none;">.cut.here</span>' + \ |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
1781 "." |
0 | 1782 } |
1783 end | |
1784 def footer() | |
1785 footer1+footer2 | |
1786 end | |
1787 def nickname(userORgroup) | |
1788 if grepgroup(userORgroup) | |
1789 @sc.groupname(userORgroup) | |
1790 else | |
1791 @sc.nickname(userORgroup) | |
1792 end | |
1793 end | |
1794 # | |
1795 # show specified month's calendar | |
1796 def showtable(day) | |
1797 if !checkauth | |
1798 return nil | |
1799 end | |
17 | 1800 |
0 | 1801 month = day.month.to_s |
1802 first = Time.mktime(day.year, day.month, 1) | |
1803 last = daysofmonth(day.year, day.month) | |
1804 wday1 = first.wday | |
1805 start = 1-wday1 | |
3 | 1806 wname = @wnames |
0 | 1807 today = Time.now |
8 | 1808 todayy = today.year |
0 | 1809 todaym = today.month |
1810 todayd = today.day | |
1811 tdclass = {} | |
1812 tdclass["width"] = "64px" if @oldagent # workaround for NN4 | |
2 | 1813 personal = /personal/ =~ @params['displaymode'] |
3 | 1814 headline = @params['headline'] |
6 | 1815 headlinehl = @params['headlinehl'] |
1816 hldays = headlinehl.to_i * 3600*24 | |
1817 recent = {'class'=>'recent'} | |
3 | 1818 monthstr = sprintf "%d/%d", day.year, day.month |
1819 | |
0 | 1820 holiday = Holiday.new |
1821 # create dayofweek header | |
3 | 1822 @O.print @H.elementln("h1", nil){monthstr} |
2 | 1823 # which mode? |
1824 @O.print @H.p(msg(personal ? 'personalmode' : 'normalmode')) | |
1825 # | |
1826 # display table | |
0 | 1827 @O.print @H.startelement("table", {'border'=>"1", 'class'=>'main'}) |
1828 | |
1829 # day of week | |
1830 @O.print @H.startelement("tr") | |
1831 for w in wname | |
1832 @O.print @H.element("th", {'class'=>w}){w.capitalize} | |
1833 end | |
1834 @O.print "\n"+@H.endelement(nil, true) | |
1835 | |
1836 # create day table | |
1837 column = start | |
1838 ## p day, last | |
1839 while column <= last | |
1840 @O.print @H.elementln("tr", nil){ | |
1841 (column..column+6).collect{|d| | |
8 | 1842 todayp = (day.year==todayy && day.month==todaym && d==todayd) |
0 | 1843 wd=d-column |
1844 hd = holiday.isHoliday(day.year, day.month, d, wd) | |
1845 tdclass['class'] = (hd ? 'holiday' : wname[wd]) | |
1846 @H.element("td", tdclass){ | |
13 | 1847 if d>0 |
1848 thisday = first+(d-1)*3600*24 | |
1849 #date = "%d/%d/%d"%[day.year, day.month, d] | |
1850 date = "%d/%d/%d"%[thisday.year, thisday.month, thisday.day] | |
0 | 1851 @H.element("p", {'class'=>todayp ? 'todayline' : 'dayline'}){ |
13 | 1852 ##@H.a(@myname+"?-show+"+date, "%4d"%d) |
1853 @H.a(@myname+"?-show+"+date, "%4d"%thisday.day) | |
0 | 1854 } + \ |
1855 # isHoliday? | |
1856 if hd | |
1857 @H.element("small"){hd.join("<br>")} | |
1858 end.to_s + \ | |
1859 @H.element("p", {'class'=>'topic'}){ | |
2 | 1860 s = @sc.day_all(date, @params['user'], personal) |
0 | 1861 if !s.empty? |
1862 s.keys.sort.collect{|time| | |
1863 s[time].keys.sort.collect{|who| | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
1864 text = escape(s[time][who]['sched']) |
6 | 1865 topic = sprintf "%s%s", |
3 | 1866 time == @opt['alldaydir'] ? '' : time+":", |
2 | 1867 if personal |
9 | 1868 (@params['user'] == who ? "" : nickname(who)+"=") + |
7 | 1869 text ## .split("\n") ##[0] |
2 | 1870 else |
5 | 1871 nickname(who) + \ |
3 | 1872 if headline == 'whole' |
5 | 1873 '=' + text |
3 | 1874 elsif headline == 'head5char' |
5 | 1875 '=' + text.gsub(/\n/, '').sub(/(.{5}).*/, '\1') |
3 | 1876 elsif headline == 'headline' |
5 | 1877 '=' + text.split("\n")[0] |
3 | 1878 end.to_s |
2 | 1879 end |
6 | 1880 if hldays > 0 && |
1881 (today - s[time][who]['regtime']) < hldays | |
1882 topic = @H.element("span", recent){topic} | |
1883 end | |
1884 topic | |
3 | 1885 }.join("<br>") |
1886 }.join("<br>\n") | |
0 | 1887 else |
1888 @opt['tdskip'] | |
1889 end | |
1890 } | |
1891 else | |
1892 @opt['tdskip'] | |
1893 end | |
1894 } | |
1895 }.join | |
1896 } | |
1897 column += 7 | |
1898 end | |
1899 | |
1900 # month-link | |
1901 @O.print @H.elementln("tr", {'class'=>'monthlink'}){ | |
1902 lm1 = lastmonth(day) | |
1903 lm2 = lastmonth(lm1) | |
1904 lm3 = lastmonth(lm2) | |
1905 nm1 = nextmonth(day) | |
1906 nm2 = nextmonth(nm1) | |
1907 nm3 = nextmonth(nm2) | |
1908 [lm3, lm2, lm1, nil, nm1, nm2, nm3].collect{|t| | |
1909 @H.element("td"){ | |
1910 if t.is_a?(Time) | |
1911 ym = sprintf("%d/%d", t.year, t.month) | |
1912 @H.a(sprintf("%s?-month+%s", @myname, ym), ym) | |
1913 else | |
1914 sprintf "%d/%d", day.year, day.month | |
1915 end | |
1916 } | |
1917 }.join("\n") | |
1918 } | |
1919 @O.print "\n"+@H.endelement(nil, true) | |
1920 | |
1921 @O.print "showtable" if @params['user'] == @author | |
3 | 1922 @O.print @H.elementln("form", {'action'=>@myname+"?-month+#{monthstr}", 'method'=>'POST'}){ |
1923 choice = [ | |
1924 [msg('nameonly'), 'name'], | |
1925 [msg('head5char'), 'head5char'], | |
1926 [msg('headline'), 'headline'], | |
1927 [msg('whole'), 'whole']] | |
1928 msg('display') + \ | |
6 | 1929 @H.select('headline', choice, headline) + "/" + \ |
1930 msg('hldays') + \ | |
1931 @H.select('headlinehl', 0..30, headlinehl) + \ | |
3 | 1932 @H.submit("GO", "GO") |
1933 } | |
0 | 1934 @O.print footer |
1935 ##schedule.day_all("2003/12/22") | |
1936 # @O.print @H.endelement() | |
1937 end | |
1938 | |
1939 # | |
1940 # Put carrying values | |
1941 def hiddenvalues() | |
2 | 1942 h = %w[user displaymode].collect{|v| |
0 | 1943 if @params[v] |
1944 sprintf "<input type=\"hidden\" name=\"%s\" value=\"%s\">\n", | |
1945 v, @params[v] | |
1946 end | |
1947 } | |
1948 h.delete(nil) | |
1949 h.join | |
1950 end | |
2 | 1951 def date2ymd(date) |
1952 %r,(\d\d\d\d+)/(\d\d?)/(\d\d?), =~ date and | |
1953 [$1.to_i, $2.to_i, $3.to_i] | |
1954 end | |
0 | 1955 # |
1956 # Return the string of table | |
2 | 1957 def dayTableString(user, datestr, range, personal = nil) |
1958 #s = @sc.day_all(date, user, personal) | |
1959 #return '' if s.empty? | |
0 | 1960 r = '' |
2 | 1961 header = @H.startelement("table", {'border'=>'1'}, true) |
1962 | |
1963 day = Time.mktime(*date2ymd(datestr)) | |
1964 i = -1 | |
1965 while (i+=1) < range | |
1966 d = Time.at(day+i*3600*24) | |
1967 date = sprintf("%04d/%02d/%02d", d.year, d.month, d.day) | |
3 | 1968 datewn = @H.element("span", {'class'=>@wnames[d.wday]}){ |
1969 sprintf("%s(%s)", date, @msg['wnames'][@lang][d.wday]) | |
1970 } | |
2 | 1971 s = @sc.day_all(date, user, personal) |
1972 next if s.empty? | |
1973 | |
1974 r << @H.element("tr", nil){ | |
1975 @H.element("th", {'class'=>'time'}){'TIME'} + \ | |
3 | 1976 @H.element("th", nil){'Who - '+datewn+' - What'} |
2 | 1977 } |
6 | 1978 for time in s.keys.sort |
2 | 1979 tstr = case time |
1980 when @opt['alldaydir'] | |
1981 msg('allday') | |
1982 else | |
1983 sprintf "%02d:%02d", time.to_i/100, time.to_i%100 | |
1984 end | |
1985 r << @H.startelement("tr", nil, true) | |
1986 r << @H.element("th", {'class'=>'time'}){tstr} | |
1987 r << @H.element("td"){ | |
1988 @H.elementln("table"){ | |
1989 s[time].keys.collect{|who| | |
1990 editable = (user==who || @sc.ismember(user, who)) | |
1991 groupp = grepgroup(who) | |
1992 @H.element("tr"){ | |
1993 @H.element("td", {'class'=>groupp ? 'group' : 'who'}){ | |
1994 if !groupp && webpage(who) | |
1995 @H.a(webpage(who), nickname(who)) | |
1996 else | |
1997 nickname(who) | |
1998 end | |
1999 } + \ | |
2000 @H.element("td"){ | |
2001 if editable | |
2002 s[time][who]['pub'] ? msg('public') : | |
2003 msg('nonpublic') | |
2004 else | |
2005 @opt['tdskip'] | |
2006 end | |
2007 } + \ | |
2008 @H.element("td"){ | |
2009 if editable | |
2010 @H.a(@myname+"?-modify+#{date}/#{time}/#{who}", | |
2011 msg('modify')) | |
2012 else | |
2013 @opt['tdskip'] | |
2014 end | |
2015 } + \ | |
2016 @H.element("td"){ | |
2017 if editable | |
2018 @H.a(@myname+"?-remove+#{date}/#{time}/#{who}", | |
2019 msg('remove')) | |
2020 else | |
2021 @opt['tdskip'] | |
2022 end | |
2023 } + \ | |
14 | 2024 @H.element("td"){ |
2025 if editable | |
2026 @H.a(@myname+"?-move+#{date}/#{time}/#{who}", | |
2027 msg('move')) | |
2028 else | |
2029 @opt['tdskip'] | |
2030 end | |
2031 } + \ | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2032 @H.element("td"){escape(s[time][who]['sched'])} |
2 | 2033 } |
2034 }.join("\n") | |
2035 } | |
0 | 2036 } |
2 | 2037 r << @H.endelement() |
2038 end | |
0 | 2039 end |
2 | 2040 footer = @H.endelement() |
2041 if r > '' | |
2042 header + r + footer | |
2043 else | |
2044 '' | |
2045 end | |
0 | 2046 end |
14 | 2047 def dayTextString(user, datestr, range, personal = nil) |
2048 r = '' | |
2049 cols = 20 | |
2050 header = "-" * cols + "\n" | |
2051 | |
2052 day = Time.mktime(*date2ymd(datestr)) | |
2053 i = -1 | |
2054 while (i+=1) < range | |
2055 d = Time.at(day+i*3600*24) | |
2056 date = sprintf("%04d/%02d/%02d", d.year, d.month, d.day) | |
2057 datewn = sprintf("%s(%s)", date, @msg['wnames'][@lang][d.wday]) | |
2058 s = @sc.day_all(date, user, personal) | |
2059 next if s.empty? | |
2060 | |
2061 r << sprintf("TIME Who %s - What\n", datewn) | |
2062 | |
2063 for time in s.keys.sort | |
2064 tstr = case time | |
2065 when @opt['alldaydir'] | |
2066 msg('allday') | |
2067 else | |
2068 sprintf "%02d:%02d", time.to_i/100, time.to_i%100 | |
2069 end | |
2070 r << s[time].keys.collect{|who| | |
2071 editable = (user==who || @sc.ismember(user, who)) | |
2072 groupp = grepgroup(who) | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2073 sprintf("%-5s %-10s %s", |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2074 tstr, nickname(who), escape(s[time][who]['sched'])) |
14 | 2075 }.join("\n") + "\n" |
2076 end | |
2077 r << "-" * cols + "\n" | |
2078 end | |
2079 footer = "That's all\n" | |
2080 if r > '' | |
2081 header + r + footer | |
2082 else | |
2083 '' | |
2084 end | |
2085 | |
2086 end | |
0 | 2087 # |
2 | 2088 # new form |
2089 def displayRegistForm(date, multiple = true) | |
0 | 2090 # |
2091 # Link button to add new plan | |
2092 #now = Time.now+3600*24 | |
2 | 2093 thisyear, thismonth, thisday = date.scan(%r,(\d\d\d\d+)/(\d+)/(\d+),)[0] |
2094 user = @params['user'] | |
0 | 2095 now = Time.mktime(thisyear, thismonth, thisday.to_i, Time.now.hour) |
2096 y, m, d, h, min = now.year, now.month, now.day, now.hour, now.min | |
2 | 2097 nextweek = Time.at(now+3600*24*7) |
2098 ey, em, ed = nextweek.year, nextweek.month, nextweek.day | |
2099 rcsp = (multiple ? {'colspan'=>'2'} : nil) | |
2100 wnames = @msg['wnames'][@lang] | |
2101 wnames << @msg['everyday'][@lang] | |
2102 | |
0 | 2103 @O.print @H.element('h2', nil, true){msg('addsched')} |
2104 @O.print @H.element('p', nil){msg('defthisday')} | |
2 | 2105 |
0 | 2106 @O.print @H.element("form", {'action'=>@myname+"?-addsched", 'method'=>'POST'}){ |
2 | 2107 border1 = {'border'=>'1'} |
2108 border1c = {'border'=>'1', 'class'=>'c'} | |
2109 mygroup = @sc.groups().select{|g|@sc.ismember(user, g)} | |
0 | 2110 @H.elementln('table', border1){ |
2111 @H.elementln('tr'){ | |
2112 @H.element('th'){'Name'} + \ | |
2 | 2113 @H.element('td', rcsp){ |
0 | 2114 hiddenvalues() + @sc.nickname(user) |
2115 } | |
2116 } + \ | |
2117 @H.elementln('tr'){ | |
2118 @H.element('th'){'Year'} + \ | |
2 | 2119 @H.element('td'){@H.select("year", y..y+5, y)} + \ |
2120 if multiple | |
2121 @H.element('td'){ | |
2122 d1 = msg('singleday') | |
2123 msg('through')+@H.select("endyear", [d1]+(y..y+5).to_a, d1) | |
2124 } | |
2125 end | |
0 | 2126 } + \ |
2127 @H.elementln('tr'){ | |
2128 @H.element('th'){'Month'} + \ | |
2 | 2129 @H.element('td'){@H.select("month", 1..12, m)} + \ |
2130 if multiple | |
2131 @H.element('td'){ | |
2132 msg('through')+@H.select("endmonth", 1..12, em) | |
2133 } | |
2134 end | |
0 | 2135 } + \ |
2136 @H.elementln('tr'){ | |
2137 @H.element('th'){'Day'} + \ | |
2 | 2138 @H.element('td'){@H.select("day", 1..31, d)} + \ |
2139 if multiple | |
2140 @H.element('td'){ | |
2141 msg('through')+@H.select("endday", 1..31, ed) | |
2142 } | |
2143 end | |
0 | 2144 } + \ |
2 | 2145 if multiple |
2146 @H.elementln('tr'){ | |
2147 @H.element('th'){ | |
2148 msg('whichday') | |
2149 } + \ | |
2150 @H.element('td', rcsp){ | |
2151 @H.elementln('table', border1c){ | |
2152 @H.element('tr'){ | |
2153 i=-1 | |
2154 wnames.collect{|w| | |
2155 @H.element('td'){ | |
2156 i+=1 | |
2157 @H.radio('whichday', i.to_s, '', i==wnames.length-1) | |
2158 } | |
2159 }.join("\n") | |
2160 } + \ | |
2161 @H.element('tr'){ | |
2162 i=-1 | |
2163 wnames.collect{|w| | |
2164 @H.element('td'){w} | |
2165 }.join | |
2166 } | |
2167 } | |
2168 } | |
2169 } | |
2170 end + \ | |
0 | 2171 @H.elementln('tr'){ |
2172 @H.element('th'){'Time<br>'+ \ | |
2173 sprintf(msg('24hour'), @opt['alldaydir'])} + \ | |
2 | 2174 @H.element('td', rcsp){ |
0 | 2175 '<input type=text name="time" value="3000" size=8 maxlength="4">' |
2176 } | |
2177 } + \ | |
2178 @H.elementln('tr'){ | |
2179 @H.element('th'){msg('publicok')} + \ | |
2 | 2180 @H.element('td', rcsp){ |
0 | 2181 @H.radio('pub', 'yes', msg('yes')+'<br>', true) + \ |
2182 @H.radio('pub', 'no', msg('no')) | |
2183 } | |
2184 } | |
2185 ## table | |
2186 } + \ | |
2187 @H.elementln("p"){ # put notify mail checkbox | |
2188 msg('reqnotify') + '<br>' + \ | |
2189 @ntlist.collect{|n, v| | |
8 | 2190 # Actual variables of notifylist for submitting is "sub_"+n |
2191 @H.checkbox("sub_"+n, 'yes', v, @params[n]) | |
0 | 2192 }.join("\n") + \ |
2193 " " + @H.checkbox('rightnow', 'yes', msg('rightnow'), true) + \ | |
2194 "\n" | |
2195 } + \ | |
2196 if mygroup[0] | |
2197 @H.elementln("p"){ # put "register as" | |
2198 msg('registas') + "<br>\n" + \ | |
2199 mygroup.collect{|g| | |
2200 @H.radio('registas', g, @sc.groupname(g)) | |
2201 }.join(' ') + "\n/ " + \ | |
2202 @H.radio('registas', 'no', msg('personal')) | |
2203 } | |
2204 end.to_s + "\n" + \ | |
2 | 2205 @H.radio('editmode', 'remove', 'Delete?') + " / " + \ |
2206 @H.radio('editmode', 'modify', 'Overwrite?') + " / " + \ | |
2207 @H.radio('editmode', 'append', 'Append?', true) + "<br>\n" + \ | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2208 @H.element("p"){msg('headsched') + "<br>\n" + \ |
17 | 2209 @H.element("textarea", @schedulearea){}} + # textarea |
0 | 2210 @H.submit_reset("GO") |
2211 } #form | |
2 | 2212 end |
2213 # | |
2214 # show the schedule list of specified date | |
2215 # | |
2216 def show(date) | |
2217 if !checkauth | |
2218 return nil | |
2219 end | |
2220 user = safecopy(@params['user']) | |
2221 personal = (/personal/i =~ @params['displaymode']) | |
2222 @params['displaydays'] = @params['displaydays'] || @cookie['displaydays'] | |
3 | 2223 days = @params['displaydays'].to_i |
18 | 2224 days = (days > 0 ? days : 3) |
2 | 2225 |
2226 # str = @sc.day_all(date, user, personal) | |
2227 outstr = dayTableString(user, date, days, personal) | |
2228 | |
2229 @O.print @H.element("h1", nil){ | |
2230 sprintf msg('fmtdaysschedule'), date | |
2231 } | |
18 | 2232 @O.print @H.element("h2"){msg('schedtable')} |
2 | 2233 ## @O.print @H.p() |
2234 @O.print @H.elementln("form", {'action'=>@myname+"?-show+#{date}", 'method'=>'POST'}){ | |
2235 @H.elementln("p"){ | |
6 | 2236 msg(personal ? 'personalmode' : 'normalmode') + "<br>" + \ |
2 | 2237 @H.select("displaydays", 1..30, days) + msg('daystodisplay') + \ |
2238 @H.submit("GO", "GO") | |
2239 } | |
2240 } | |
2241 if outstr > '' | |
2242 @O.print outstr | |
2243 else | |
2244 @O.print @H.p(msg('noplan')) | |
2245 end #is_empty? | |
2246 thisyear, thismonth, thisday = date.scan(%r,(\d\d\d\d+)/(\d+)/(\d+),)[0] | |
2247 mstr = sprintf "%04d/%02d", thisyear.to_i, thismonth.to_i | |
2248 @O.print @H.a(@myname+"?-month+"+mstr, | |
2249 sprintf(msg('tomonthlist'), mstr)) | |
2250 | |
2251 | |
2252 # | |
2253 # Display registration form | |
2254 displayRegistForm(date) | |
0 | 2255 @O.print "show" if user == @author |
2256 end | |
2257 | |
2258 # | |
2259 # call process | |
2260 def call_process(cmd, input=nil, timeout=10) | |
2261 prc = CMDTimeout.new | |
2262 fds = prc.start(cmd, timeout, true) | |
2263 if input | |
2264 Thread.start { | |
2265 fds[0].sync = true | |
2266 fds[0].print.input | |
2267 fds[0] | |
2268 } | |
2269 end | |
2270 begin | |
2271 fds[1].readlines | |
2272 ensure | |
2273 prc.close() | |
2274 end | |
2275 end | |
2276 # | |
2277 # notification registerer | |
2278 def notify_time(year, month, day, time, symbol) | |
2279 if (t = time.to_i) > 2359 | |
2280 hh = mm = 0 | |
2281 else | |
2282 hh, mm = t/100, t%100 | |
2283 end | |
2284 base = Time.mktime(year.to_i, month.to_i, day.to_i, hh, mm) | |
2285 if /nt(\d+)([mh])$/ =~ symbol | |
2286 return nil if t > 2359 | |
2287 num, unit = $1.to_i, $2.downcase | |
2288 rate = {'h'=>3600, 'm'=>60}[unit] || 3600 | |
2289 return Time.at(base-rate*num) | |
2290 elsif /nt(\d+)d/ =~ symbol | |
2291 seconds = $1.to_i*3600*24 | |
14 | 2292 tday= Time.at(base-seconds) |
2293 target = [tday.year, tday.month, tday.day, @opt['night'].to_i] | |
2294 targetnight = Time.mktime(*target) | |
0 | 2295 elsif "nttoday" == symbol |
2296 Time.mktime(year.to_i, month.to_i, day.to_i, @opt['morning']) | |
2297 end | |
2298 end | |
2299 def reg_notify(user, year, month, day, time, text, cancelall = nil) | |
6 | 2300 return nil unless @opt['notifymail'] |
0 | 2301 threshold = 5*60 # Omit notifycation within 30min future |
2302 | |
2303 y, m, d, t, = year.to_i, month.to_i, day.to_i, time.to_i | |
2304 if t > 2359 | |
2305 hh = mm = 0 | |
2306 else | |
2307 hh = t/100 | |
2308 mm = t%100 | |
2309 end | |
2310 now = Time.now | |
2311 | |
2312 filearg = [user, year, month, day, t] | |
2313 @ntlist.each{|k, v| | |
8 | 2314 # @params[k]s are always defined in cookies, so we use @params["sub_"+k] |
2315 @params[k] = @params["sub_"+k] | |
0 | 2316 nt_time = notify_time(year, month, day, t, k) |
2317 if !nt_time | |
2318 # do nothing for allday schedule's notification before some minutes | |
2319 elsif cancelall || nt_time < now+threshold || | |
2320 /yes|on|true|1/ !~ @params[k] || !@params[k] | |
2321 # cancel | |
2322 uf = @sc.remove_crondir(nt_time, user, year, month, day, t) | |
2323 @sc.removefile(*(filearg+[k])) | |
2324 else | |
2325 # register | |
2326 lf = @sc.register_crondir(nt_time, user, year, month, day, t) | |
2327 @sc.putfile(*(filearg+[k, lf])) | |
2328 end | |
2329 } | |
2330 end | |
2331 def cancel_notify(user, year, month, day, time) | |
2332 reg_notify(user, year, month, day, time, 'dummy', true) | |
2333 end | |
2 | 2334 |
2335 def commit_schedule(who, y, m, d, timedir, text, repl, pub) | |
2336 | |
2337 end | |
2338 | |
14 | 2339 def regulate_time(y, m, d, tm) |
2340 if tm > 2399 | |
2341 sh, smin = 23, 59 | |
2342 timedir=@opt['alldaydir'] | |
2343 tmstr = msg('allday') | |
2344 else | |
2345 sh = (tm/100).to_i | |
2346 smin = (tm%100).to_i | |
2347 timedir = sprintf("%04d", tm) | |
2348 tmstr = sprintf("%d:%02d", sh, smin) | |
2349 end | |
2350 time = nil | |
2351 begin | |
2352 time = Time.mktime(y, m, d, sh, smin) | |
2353 rescue | |
2354 outputError "%s<br>\nyear=%s<br>month=%s<br>day=%s<br>time=%s\n", | |
2355 msg('invaliddate'), | |
2356 @params['year'], @params['month'], @params['day'], @params['time'] | |
2357 return nil | |
2358 end | |
2359 [time, timedir, tmstr] | |
2360 end | |
2361 | |
0 | 2362 # |
2363 # add or remove a schedule | |
2364 # | |
2365 def add_remove(remove = nil) | |
2366 if !checkauth | |
2367 return nil | |
2368 end | |
2369 user = registerer = @params['user'] | |
2370 as = @params['registas'] | |
2371 if as && as > '' && /^no$/ !~ as && @sc.ismember(user, as) | |
3 | 2372 if (gr=grepgroup(as)) |
2373 registerer = gr | |
2374 end | |
0 | 2375 end |
2376 now = Time.now | |
2 | 2377 #y, m, d, h, min = now.year, now.month, now.day, now.hour, now.min |
0 | 2378 |
2379 $KCODE='e' if $DEBUG | |
2380 @O.print @params.inspect if $DEBUG | |
2381 # | |
2382 # Check the validity of specified time | |
2383 sy = @params['year'].to_i | |
2384 sm = @params['month'].to_i | |
2385 sd = @params['day'].to_i | |
2386 tm = @params['time'].to_i | |
14 | 2387 |
2388 time, timedir, tmstr = regulate_time(sy, sm, sd, tm) | |
2 | 2389 |
2390 # | |
2391 # Check continuous schedule registration | |
2392 wwday = @params['whichday'].to_i | |
2393 if @params['endyear'] && @params['endmonth'] && @params['endday'] && | |
2394 (ey=@params['endyear'].to_i) > 0 && | |
2395 (em=@params['endmonth'].to_i) > 0 && | |
2396 (ed=@params['endday'].to_i) > 0 | |
2397 daylist = [] | |
2398 endtime = Time.mktime(ey, em, ed, 23, 59) | |
2399 ti = time | |
2400 begin | |
2401 if wwday==7 || wwday==ti.wday | |
2402 daylist << [ti.year, ti.month, ti.day] | |
2403 end | |
9 | 2404 end while (ti=Time.at(ti+3600*24)) <= endtime |
2 | 2405 else |
2406 daylist = [[sy, sm, sd]] | |
2407 end | |
2408 | |
2409 if !remove && !(@params['schedule'] && @params['schedule'].strip > '') | |
0 | 2410 outputError msg('putsomething') |
2411 return nil | |
2412 end | |
2413 | |
2 | 2414 |
2415 for y, m, d in daylist | |
2416 # do remove or addition | |
2417 if remove | |
2418 cancel_notify(registerer, y, m, d, timedir) | |
2419 begin | |
2420 @sc.remove(registerer, y, m, d, timedir) | |
2421 #########@O.print @H.p(msg('remove')+msg('done')) | |
2422 rescue | |
2423 outputError("Failed"+$!) | |
2424 end | |
2425 else | |
2426 if time < now | |
2427 outputError(msg('past')) | |
2428 return nil | |
2429 end | |
2430 begin | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2431 |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2432 (text = @params['schedule'].toeuc.strip.gsub(/\r+\n/, $/)) << "\n" |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2433 # text = purify(text) |
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2434 STDERR.print text |
2 | 2435 replace = (/modify/i =~ @params['editmode']) |
2436 rc = @sc.register(registerer, y, m, d, timedir, text, replace) | |
2437 if @params['pub'] && /yes/ =~ @params['pub'] | |
2438 @sc.putfile(registerer, y, m, d, timedir, 'pub', "1\n") | |
2439 else | |
2440 @sc.removefile(registerer, y, m, d, timedir, 'pub') | |
2441 end | |
2442 ######## @O.print @H.p(msg('appended')) if rc == 1 | |
2443 rescue | |
2444 outputError("Failed"+$!) | |
2445 end | |
17 | 2446 text = @sc.getschedule(registerer, y, m, d, timedir) |
2 | 2447 reg_notify(registerer, y, m, d, timedir, text) |
2448 | |
0 | 2449 end |
2 | 2450 |
2451 end | |
2452 | |
2453 if !remove && @params['rightnow'] && /yes/i =~ @params['rightnow'] | |
2454 header = sprintf("%s\n%s/%s/%s%s %s %s\n%s%s%s\n%s\n", | |
2455 @opt['url'], | |
2456 sy, sm, sd, | |
2457 if daylist.length > 1 | |
2458 "-%s/%s/%s" % daylist[-1] | |
2459 end, | |
2460 tmstr, msg('immediatenote'), | |
2461 msg('registerer_is'), nickname(registerer), | |
2462 if user!=registerer | |
2463 sprintf(" (%s%s)", | |
2464 msg('registerer'), nickname(user)) | |
2465 else | |
2466 "" | |
2467 end, | |
2468 "-"*70) | |
2469 sendnotify(registerer, "Registration completed", header+text) | |
0 | 2470 end |
14 | 2471 unless @mailmode |
2472 show(sprintf("%04d/%02d/%02d", sy, sm, sd)) | |
2473 @O.print "add_remove" if user == @author | |
2474 end | |
0 | 2475 end |
2476 | |
2477 # add | |
2478 def addsched() | |
14 | 2479 if "move" == @params['editmode'] |
2480 add_remove(:remove) | |
2481 for p in %w(year month day time) do | |
2482 @params[p] = @params["new"+p] | |
2483 end | |
2484 end | |
2485 add_remove(/^remove/i =~ @params['editmode']) | |
0 | 2486 end |
2487 | |
2488 # | |
2489 # Display remove or modify screen | |
14 | 2490 def remove_modify(datetime, editmode) |
0 | 2491 if !checkauth |
2492 return nil | |
2493 end | |
2494 | |
2495 user = @params['user'] | |
2496 y, m, d, time, dummy, as = | |
2497 datetime.scan(%r,(\d\d\d\d+)/(\d+)/(\d+)/(\d+)(/(.+))?,)[0] | |
2498 # datetime always contains trailing slash generated by parsedate | |
2499 # but if the trailing part is a user(not a group), it is removed | |
2500 # because it filtered out by grepgroup() function | |
2501 if ! (y && m && d && time) | |
2502 outputError "Invalid time specification" | |
2503 return nil | |
2504 elsif as && as > '' | |
2505 unless @sc.ismember(user, as) | |
2506 outputError "You have no permission to edit group %s's schedule", as | |
2507 return nil | |
2508 end | |
2509 user = as | |
2510 end | |
2511 unless text=@sc.getschedule(user, y, m, d, time) | |
2512 outputError "%s %s", datetime, msg('noplan') | |
2513 return nil | |
2514 end | |
32
d23a2b3c456b
Save schedule text `as is' in a file and escape them for browser.
HIROSE Yuuji <yuuji@gentei.org>
parents:
31
diff
changeset
|
2515 ## text = decode(text) |
0 | 2516 @O.print @H.elementln("h1"){ |
14 | 2517 sprintf "%s %s", datetime, msg(editmode) |
0 | 2518 } |
2519 @O.print @H.elementln("form", {'action'=>@myname+"?-addsched", 'method'=>'POST'}){ | |
2520 pubp=(@sc.getfile(user, y, m, d, time, 'pub').to_i > 0) | |
2521 if as | |
2522 @H.hidden("registas", as) | |
2523 end.to_s + \ | |
2524 "<input type=\"hidden\" name=\"year\" value=\"%04d\">\n" % y.to_i + \ | |
2525 "<input type=\"hidden\" name=\"month\" value=\"%02d\">\n" % m.to_i + \ | |
2526 "<input type=\"hidden\" name=\"day\" value=\"%02d\">\n" % d.to_i + \ | |
2527 "<input type=\"hidden\" name=\"time\" value=\"%04d\">\n" % time.to_i + \ | |
14 | 2528 if editmode=="move" |
2529 @H.elementln("table") { | |
2530 @H.elementln("tr", {"colspan" => "2"}) {msg('newdate')} + \ | |
2531 @H.elementln("tr") { | |
2532 @H.element("th"){"Year"} + \ | |
2533 @H.element("td"){@H.select("newyear", y.to_i..y.to_i+5, y)} | |
2534 } + \ | |
2535 @H.elementln("tr") { | |
2536 @H.element("th"){"Month"} + \ | |
2537 @H.element("td"){@H.select("newmonth", 1..12, m)} | |
2538 } + \ | |
2539 @H.elementln("tr") { | |
2540 @H.element("th"){"Day"} + \ | |
2541 @H.element("td"){@H.select("newday", 1..31, d)} | |
2542 } + \ | |
2543 @H.elementln("tr") { | |
2544 @H.element("th"){"Time"} + \ | |
2545 @H.element("td"){ | |
2546 "<input type=text name=\"newtime\" value=\"#{time}\" " + \ | |
2547 "size=\"8\" maxlength=\"4\">" | |
2548 } | |
2549 } | |
2550 } | |
2551 end.to_s + \ | |
2552 @H.elementln("div", {"style" => | |
2553 "visibility: " + | |
2554 (editmode=="move" ? "hidden" : "show") + "\""}) { | |
2555 msg('reqnotify') + "<br>\n" + \ | |
2556 @ntlist.collect{|nt, v| | |
2557 cronp = @sc.getfile(user, y, m, d, time, nt) | |
2558 sprintf "<input type=\"checkbox\" name=\"%s\"%s>%s \n", | |
2559 nt, (cronp ? " checked" : ""), v | |
2560 }.join + "<br>" | |
2561 } + \ | |
0 | 2562 @H.element("textarea", @schedulearea) {text} + "<br>" + \ |
2563 @H.radio("editmode", "append", msg('append')) + ' / ' + \ | |
14 | 2564 @H.radio("editmode", "modify", msg('modify'), editmode=="modify")+' / '+\ |
2565 @H.radio("editmode", "remove", msg('remove'), editmode=="remove")+' / '+\ | |
2566 @H.radio("editmode", "move", msg('move'), editmode=="move") + ' / ' + \ | |
0 | 2567 "<br>\n" + \ |
2568 msg('publicok') + \ | |
2569 @H.radio("pub", "yes", msg('yes'), pubp) + \ | |
2570 @H.radio("pub", "no", msg('no'), !pubp) + \ | |
2571 '<br>' + \ | |
2572 @H.submit_reset("GO") | |
2573 } | |
2574 @O.print "remove_modify" if user == @author | |
2575 end | |
2576 def remove(datetime) | |
14 | 2577 remove_modify(datetime, "remove") |
0 | 2578 end |
2579 def modify(datetime) | |
14 | 2580 remove_modify(datetime, "modify") |
2581 end | |
2582 def move(datetime) | |
2583 remove_modify(datetime, "move") | |
0 | 2584 end |
2585 | |
2586 def prohibitviahttp() | |
2587 %w[REMOTE_ADDR REMOTE_HOST SERVER_NAME].each{|v| | |
2588 if ENV[v] | |
2589 print "Content-type: text/plain\n\n" | |
2590 print "Do not call this via CGI" | |
2591 exit 0 | |
2592 end | |
2593 } | |
2594 end | |
2595 # | |
2596 # notify: call via cron | |
2597 def notify() | |
2598 prohibitviahttp() | |
2599 unless @opt['maintainer'] | |
2600 STDERR.printf "Set maintainer(email-address) in %s\n", @opt['conf'] | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2601 STDERR.print "(ex.) maintainer=yuuji@gentei.org\n" |
0 | 2602 exit 0 |
2603 end | |
2604 Dir.chdir @mydir | |
2605 line = "-"*25 | |
2606 indent = " " | |
2607 now = Time.now | |
2608 p "notifylist", @sc.notify_list(now) if $DEBUG | |
2609 @sc.notify_list(now).each{|u, datehash| | |
2610 dellist = [] | |
2611 content = datehash.sort.collect{|date, filehash| | |
2612 next unless /(\d\d\d\d+)-(\d+)-(\d+)-(\d\d\d\d)/ =~ date | |
2613 y, m, d, t = $1.to_i, $2.to_i, $3.to_i, $4.to_i | |
11 | 2614 ddiff=(Time.mktime(y, m, d) \ |
2615 - Time.mktime(now.year, now.month, now.day))/3600/24 | |
0 | 2616 if t > 2359 |
2617 hhmm = msg('allday') | |
11 | 2618 if ddiff > 1 |
2619 comment = "%d%s" % [ddiff, msg('days', 'before')] | |
2620 else | |
2621 comment = msg(now.hour > 18 ? 'precedingday' : 'theday') | |
2622 end | |
0 | 2623 else |
2624 hhmm = sprintf "%02d:%02d", t/100, t%100 | |
2 | 2625 diff = Time.mktime(y, m, d, t/100, t%100) - now |
0 | 2626 if diff < 7200 |
2627 comment = "%d%s" % [diff/60, msg('minutes', 'before')] | |
11 | 2628 elsif (ddiff == 0) |
0 | 2629 comment = "%s%d%s" % |
2630 [msg('about'), diff/3600, msg('hours', 'before')] | |
2631 else | |
2632 comment = "%d%s" % [ddiff, msg('days', 'before')] | |
2633 end | |
2634 end | |
2635 dellist << filehash['file'] | |
2636 sprintf("%s[[[%d/%d/%d %s]]]%s\n", line, y, m, d, hhmm, line) + \ | |
2637 sprintf("(%s %s)\n", comment, msg('notification')) + \ | |
31
aceb533dfa32
Schedule file is already decoded. No need to decode again.
HIROSE Yuuji <yuuji@gentei.org>
parents:
30
diff
changeset
|
2638 indent+filehash['text'].join(indent) + "\n\n" |
0 | 2639 } |
2640 # content.delete(nil) | |
2641 if content | |
2642 if $DEBUG | |
2643 print content | |
2644 else | |
2645 content.unshift(msg('introduce')+"\n"+msg('notifymail')+"\n") | |
2646 content.unshift(@opt['url'].to_s+"\n") | |
2647 if sendnotify(u, msg('notifysubj'), content.join) | |
2648 # send mail completed | |
2649 begin | |
2650 @sc.cleanup_files(dellist) | |
2651 rescue | |
2652 end | |
2653 end | |
2654 end | |
2655 end | |
2656 } | |
2657 if !(list=@sc.notify_list(now)).empty? | |
2658 subj = @mybase+": Undeleted old cron files detected" | |
2659 files = list.collect{|who, whash| | |
2660 whash.sort.collect{|date, fhash| fhash['file']}.join("\n") | |
2661 }.join("\n") | |
2662 sendMail(@opt['maintainer'], subj, | |
2663 "This is `#{@mybase}' in #{@mydir}\n" + | |
2664 "You'd better check and remove these files.\n\n"+files) | |
2665 end | |
2666 | |
2667 exit 0 | |
2668 end | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2669 # ML functions |
47 | 2670 def parseaddress(spec) # from catchup.rb |
2671 # Return [email, comment] | |
2672 # nil if comment does not exitst. | |
2673 if /(.*)\s*<(.*)>/ =~ spec then | |
2674 [$2, $1.strip] | |
2675 elsif /(.*)\s*\((.*)\)/ =~ spec then | |
2676 [$1.strip, $2] | |
2677 else | |
2678 [spec.strip, nil] | |
2679 end | |
2680 end | |
2681 def rewritefrom(email, comment, newseed) # from catchup.rb | |
2682 # no need to setcomment here because if comment set, it's enough | |
2683 comment.sub!(/(\"?)(.*)\1/, '\2') | |
2684 comment += "/" if comment>"" | |
2685 return comment.gsub(/([^\x00-\x7f]+)/){NKF.nkf('-jM', $1)} + | |
2686 email.sub("@", "=")+" <"+newseed+">" | |
2687 # end | |
2688 end | |
2689 | |
2690 def tagify_subj(body, tag, removeregexp, fromhack = nil) | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2691 # This method should be generic for other headers than `Subject'? |
40 | 2692 hold = [] |
2693 ret = [] | |
2694 skip = false | |
2695 while line = body.shift | |
2696 case line.toeuc | |
2697 when /^$/ | |
2698 hold << "\n" | |
2699 break | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2700 ## when /^(subject|from): /i |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2701 when /^(\S+): /i # if new header comes |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2702 if /^subject:/i =~ hold[0] # check previous header in hold space |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2703 sj = hold.join.toeuc.sub("Subject: ", "").gsub(tag, "").strip |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2704 sj.gsub!(removeregexp, "") |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2705 sj = sj.sub(/^(re: *)+/i, "Re: ").gsub("\n", "") |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2706 hold = ["Subject: "+NKF.nkf('-jM', tag+" "+sj).strip+"\n"] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2707 elsif /^from/i =~ hold[0] && fromhack.is_a?(String) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2708 from = hold.join.toeuc.sub(/From: */i, "").strip |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2709 email, comment = parseaddress(from) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2710 hold = ["From: "+rewritefrom(email, comment, fromhack)+"\n"] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2711 end |
40 | 2712 ret += hold |
2713 hold = [line] | |
2714 when /^\s/ # continued line | |
2715 hold << line | |
2716 end | |
2717 end | |
2718 ret + hold + body | |
2719 end | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2720 def defaultmladdress(name) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2721 prefix = (@opt['mailprefix'] || "") |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2722 dash = prefix > '' ? "-" : "" |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2723 sprintf("%s%s%s@%s", prefix, dash, name, @opt['maildomain']) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2724 end |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2725 def list() |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2726 # For debug: |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2727 # LOCAL=1 DEFAULT=name ./after5.rb -list |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2728 # $DEFAULT is ML name |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2729 viamail = ENV['LOCAL'] && ENV['DEFAULT'] # called via mail |
57
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2730 from = toadmin = nil |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2731 unless @opt['mailprefix'] && @opt['maildomain'] |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2732 if viamail |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2733 STDERR.print msg('sendall_err') % [@opt['conf']] |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2734 exit 0 |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2735 else |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2736 @O.print @H.elementln("pre"){msg('sendall_err') % [@opt['conf']]} |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2737 return true |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2738 end |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2739 end |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2740 if viamail then |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2741 prohibitviahttp() |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2742 name = ENV['DEFAULT'] |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
2743 if Regexp.new("(.*)("+Regexp.quote(@mailadmsuffix)+")") =~ name |
58 | 2744 # To: GROUP/adm*@domain |
57
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2745 # -> Forward to group administrator(s) |
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2746 name, toadmin = $1, $2 |
58 | 2747 sendMail("dummy", 'dummy', # Original To: and Subject: go through |
57
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2748 STDIN.readlines.join, nil, @sc.admins(name), |
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2749 {"Return-path" => @opt['maintainer']}, :thru) |
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2750 exit 0 |
d089cb42619d
ML's return-path changed from maintainer to group owners.
HIROSE Yuuji <yuuji@gentei.org>
parents:
56
diff
changeset
|
2751 end |
56 | 2752 unless grepgroup(name) |
2753 sendMail(@opt['maintainer'], "no group", | |
2754 sprintf("Invalid group address: %s(%s@%s)\nSent by %s\n" + | |
2755 "URL: %s\n------------\n", | |
2756 name, ENV['LOCAL'], ENV['HOST'], ENV['SENDER'], | |
2757 @opt['url']) + | |
2758 "> "+STDIN.readlines.join("> ")) | |
2759 exit 0 # should exit 0 in mail mode | |
2760 end | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2761 else # via http |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2762 return nil unless checkauth |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2763 name = @params['name'].untaint |
56 | 2764 unless grepgroup(name) |
2765 @O.print @H.p("No such group: #{name}") | |
2766 return true | |
2767 end | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2768 nick = @sc.nickname(@params['user']) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2769 from = sprintf("%s <%s>", nick, @params['user']) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2770 body = @params['body'].gsub("\r", "").untaint |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2771 end |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2772 bracket = @sc.getgroupattr(name, 'subjtag') || @params['mailbracket'] |
47 | 2773 fromhack = @sc.getgroupattr(name, 'fromhack') |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2774 mldir = "ml/"+name |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2775 to = @sc.getgroupattr(name, 'mladdress') || defaultmladdress(name) |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
2776 returnpath = to.sub("@", @mailadmsuffix+"-@") |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2777 subj = @params['subject'] || "Message from "+@myname |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2778 sjtag = bracket.gsub("%n", nickname(name)). |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2779 gsub("%i", name). |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2780 gsub(/%(\d*)c/){("%0"+$1+"d") % [mlseq(mldir)]} |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2781 tagpt = Regexp.quote(bracket). # compute bracket pattern |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2782 gsub("%n", Regexp.quote(nickname(name))). |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2783 gsub("%i", Regexp.quote(name)). |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2784 gsub(/%(\d*)c/, '\d+') |
47 | 2785 tagre = Regexp.new(tagpt) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2786 subj = sjtag.strip+" "+subj.gsub(Regexp.new(tagpt), "") |
40 | 2787 if viamail then |
47 | 2788 body = tagify_subj(STDIN.readlines, sjtag, tagre, |
2789 fromhack ? to : nil).join | |
2790 elsif fromhack | |
2791 from = rewritefrom(@params['user'], nick, to) | |
40 | 2792 end |
38
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2793 header = { |
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2794 "Reply-to" => to, |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2795 "X-ML-Driver" => ($hgid || @myname), |
38
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2796 "X-ML-Driver-URI" => $myurl, |
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2797 "X-ML-Name" => name, |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
2798 "X-ML-URI" => sprintf("%s?-groupman+%s", @opt['url'], name), |
58 | 2799 "Return-path" => returnpath} |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2800 Dir.chdir @mydir |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2801 rcpts = if grepgroup(name) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2802 @sc.members(name) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2803 else |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2804 [name] |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
2805 end.collect {|u| mailaddress(u, name).split(/,\s*|\s+/)}.flatten |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2806 # p rcpts |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2807 # p to |
58 | 2808 ENV["QMAILINJECT"] = "r" # for ML mode, use verp |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2809 sendMail(to, subj, body, from, rcpts, |
38
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2810 header, |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2811 ENV['SENDER'], |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
2812 @opt['mlspooling'] ? mldir : nil) |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2813 if !viamail then |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2814 @O.print @H.elementln("h1"){msg('sendall_done')} |
38
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2815 @O.print @H.p(sprintf(msg('sendall_head'), |
39da23b2edb9
Prepend bracket tag to subject.
HIROSE Yuuji <yuuji@gentei.org>
parents:
37
diff
changeset
|
2816 nickname(name))+" "+msg('done')) |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2817 link2home() |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2818 @O.print footer() |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2819 return true |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2820 end |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2821 exit 0 |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2822 end |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2823 def listdraft(name) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2824 return nil unless checkauth |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2825 return nil unless name |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2826 unless @opt['mailprefix'] && @opt['maildomain'] |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2827 @O.print @H.elementln("pre"){msg('sendall_err') % [@opt['conf']]} |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2828 return true |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2829 end |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
2830 |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2831 user=@params['user'] |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2832 nickname = @sc.nickname(user) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2833 @O.print @H.elementln("h1") { |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2834 @mybase+' '+msg('sendall').sub("<br>", " ") |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2835 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2836 @O.print @H.elementln("h2") { |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2837 sprintf(msg('sendall_head'), nickname(name)) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2838 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2839 @O.print @H.p(sprintf("(%s: %s)", msg('member'), |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2840 @sc.membernames(name).join(", "))) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2841 @O.print \ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2842 @H.elementln("form", {'action' => @myname+'?-list', 'method'=>"POST"}) { |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2843 @H.elementln("table"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2844 @H.elementln("tr"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2845 @H.element("td"){"Subject"} + \ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2846 @H.element("td"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2847 @H.text("subject", "", 40, 128) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2848 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2849 } + \ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2850 @H.elementln("tr"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2851 @H.element("td"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2852 msg('body') |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2853 } + \ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2854 @H.element("td"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2855 @H.element("textarea", @schedulearea.merge({"name"=>"body"})){} |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2856 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2857 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2858 } + # </table> |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2859 @H.hidden("name", name) + |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2860 @H.submit("send", "SEND") + |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2861 @H.reset("clear", "Clear") |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2862 } |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2863 @O.print @H.p(msg('sendall_note')) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
2864 end |
0 | 2865 |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2866 # put Link to home |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2867 def link2home() |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2868 @O.print @H.p("-> " + @H.a(@myname+"?-today", "Home")) |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2869 end |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
2870 |
0 | 2871 # |
2872 # user management | |
2873 def userman() | |
2874 if !checkauth | |
2875 return nil | |
2876 end | |
2877 user=@params['user'] | |
2878 nickname = @sc.nickname(user) | |
2879 tdclass = {} | |
2880 tdclass["width"] = "80px" if @oldagent # workaround for NN4 | |
2881 | |
2882 @O.print @H.elementln("h1"){ | |
2883 @mybase+' '+msg('user', 'management') | |
2884 } | |
2885 @O.print @H.p(@sc.mkusermap.inspect) if $DEBUG | |
2886 @O.print @H.p(msg('usermodwarn')) | |
2887 @O.print \ | |
2888 @H.elementln("form", {'action'=>@myname+"?-usermod", 'method'=>'POST'}){ | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
2889 @H.elementln("table", {"class" => "border"}){ |
0 | 2890 @H.elementln("tr"){ |
2891 @H.element("td", tdclass) {msg('regaddress')} + \ | |
2892 @H.element("td") { | |
2893 @H.element("code"){user} | |
2894 } | |
2895 } + \ | |
2896 @H.elementln("tr"){ | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
2897 @H.element("td", tdclass) {msg('mailaddress', 'multipleok')} + \ |
0 | 2898 @H.element("td") { |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
2899 @H.text("newmail", mailaddress(user), @opt['size'], 180) |
0 | 2900 } |
2901 } + \ | |
2902 @H.elementln("tr"){ | |
2903 @H.element("td", tdclass) {msg('weburl')} + \ | |
2904 @H.element("td") { | |
2905 @H.text("webpage", webpage(user), @opt['size'], 80) | |
2906 } | |
2907 } + \ | |
2908 @H.elementln("tr"){ | |
2909 @H.element("td") {msg('nickname')} + \ | |
2910 @H.element("td") { | |
2911 @H.text("nickname", nickname, @opt['size'], 10) | |
2912 } | |
2913 } | |
2914 } + \ | |
50
0b104c49457a
Multiple email addresses can be acceptable
HIROSE Yuuji <yuuji@gentei.org>
parents:
48
diff
changeset
|
2915 @H.elementln("p"){msg('shortnameplz')} + \ |
0 | 2916 '<br>' + \ |
2917 @H.submit_reset("GO") | |
2918 } # form | |
2919 | |
2920 # | |
2921 # Next section, REMOVE USER! | |
2922 @O.print @H.elementln("h2"){ | |
2923 sprintf "%s %s %s", msg('user'), user, msg('deletion') | |
2924 } | |
2925 @O.print @H.p(msg('deletionwarn'))+"\n" | |
2926 @O.print @H.elementln("form", {'action'=>@myname+"?-delusersub+#{user}", 'method'=>'POST'}){ | |
2927 @H.hidden("user", user) + "\n" + \ | |
2928 @H.elementln("table"){ | |
2929 @H.elementln("tr"){ | |
2930 @H.elementln("td"){ | |
2931 sprintf msg('deluser'), user | |
2932 } + \ | |
2933 @H.elementln("td"){ | |
2934 @H.radio("delete", "yes", msg('yes')) + ' ' + \ | |
2935 @H.radio("delete", "no", msg('no'), true) | |
2936 } | |
2937 } + \ | |
2938 @H.elementln("tr"){ | |
2939 @H.elementln("td"){ | |
2940 sprintf msg('really?'), user | |
2941 } + \ | |
2942 @H.elementln("td"){ | |
2943 @H.radio("delete2", "yes", msg('yes')) + ' ' + \ | |
2944 @H.radio("delete2", "no", msg('no'), true) | |
2945 } | |
2946 } | |
2947 } + \ | |
2948 "<br>\n" + @H.submit_reset("GO") | |
2949 } | |
2950 | |
2951 | |
2952 end | |
2953 def usermod() | |
2954 if !checkauth | |
2955 return nil | |
2956 end | |
2957 @O.print @H.elementln("h1"){ | |
2958 msg('user', 'management')+" "+msg('done') | |
2959 } | |
2960 user=@params['user'] | |
2961 email = mailaddress(user) | |
2962 newmail = @params['newmail'] | |
2963 nickname = @sc.nickname(user) | |
2964 newnn = @params['nickname'].to_s.strip | |
2965 webpage = webpage(user) | |
2966 newweb = @params['webpage'] | |
2967 if email != newmail | |
2968 # change user's address | |
2969 if newmail == user | |
2970 newvalue = nil | |
2971 elsif checkmail(newmail) | |
2972 newvalue = newmail | |
2973 else | |
2974 @O.print @H.elementln("pre"){"Invalid mail address"} | |
2975 end | |
2976 @O.print @H.elementln("pre"){ | |
2977 if @sc.putuserattr(user, 'email', newvalue) | |
2978 sprintf "new mail address=\"%s\"", mailaddress(user) | |
2979 else | |
2980 sprintf "Setting new mail address to \"%s\" failed", newvalue | |
2981 end | |
2982 } | |
2983 end | |
2984 if nickname != newnn | |
2985 if @sc.setnickname(user, newnn) | |
2986 @O.print @H.p(msg('success')) | |
2987 @O.print @H.elementln("pre"){ | |
2988 sprintf "user=\"%s\"\nnickname=\"%s\"", user, @sc.nickname(user) | |
2989 } | |
2990 @O.print @H.p(msg('nicknamenote')) if newnn == '' | |
2991 else | |
2992 @O.print @H.p(msg('failure')) | |
2993 end | |
2994 end | |
2995 if newweb > '' && webpage != newweb | |
2996 if @sc.putuserattr(user, "webpage", newweb) | |
2997 @O.print @H.p(msg('success')) | |
2998 @O.print @H.elementln("pre"){ | |
2999 sprintf "user=\"%s\"\nwebpage=\"%s\"", user, webpage(user) | |
3000 } | |
3001 else | |
3002 @O.print @H.p("Update webpage"+msg('failure')) | |
3003 end | |
3004 end | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
3005 link2home |
0 | 3006 end |
3007 # | |
3008 # Display form of group management | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3009 def groupman(grp = nil) |
0 | 3010 if !checkauth |
3011 return nil | |
3012 end | |
3013 user=@params['user'] | |
3014 nickname = @sc.nickname(user) | |
3015 tdclass = {} | |
3016 tdclass["width"] = "80px" if @oldagent # workaround for NN4 | |
3017 admclass = {'class'=>'admin'} | |
3018 grmap = @sc.groupmap | |
3019 | |
3020 @O.print @H.elementln("h1"){ | |
3021 @mybase+' '+msg('group', 'management') | |
3022 } | |
3023 $KCODE='e' if $DEBUG | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3024 if grp && group = grepgroup(grp) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3025 @O.print @H.elementln("h2"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3026 sprintf(msg('aboutgroup'), group) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3027 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3028 grmap = {group => grmap[group]} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3029 end |
0 | 3030 @O.print grmap.inspect if $DEBUG |
3031 @O.print @H.p(msg('joinmyself')+ | |
3032 @H.a(@myname+"?-newgroup", msg('newgroup'))) | |
3033 @O.print @H.p(msg('usermodwarn')) | |
3034 @O.print \ | |
3035 @H.elementln("form", {'action'=>@myname+"?-groupmod", 'method'=>'POST'}){ | |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3036 @H.elementln("table", {'class'=>'border'}){ |
47 | 3037 grmap.sort.collect{|g, ghash| |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3038 memberp = @sc.ismember(user, g) |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3039 adminp = @sc.isadmin(user, g) |
0 | 3040 @H.elementln("tr"){ |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3041 @H.element("td", adminp ? admclass : nil){ |
63
e2aa6180c2c6
Show the number of group member in groupman().
HIROSE Yuuji <yuuji@gentei.org>
parents:
62
diff
changeset
|
3042 g + "<br>("+@sc.members(g).length.to_s+")" |
0 | 3043 } + \ |
3044 @H.element("td"){ | |
3045 @H.element("div", {'class'=>'c'}) { | |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3046 if adminp |
0 | 3047 @H.a(@myname+"?-admgroup+#{g}", msg('adminop')) |
3048 else | |
3049 '--' | |
3050 end | |
3051 } | |
3052 } + \ | |
3053 @H.element("td"){ | |
3054 if ghash['admin'].grep(user)[0] | |
67
a421c2fefc32
Fix the argument for FileUtils.mkdir_p()
HIROSE Yuuji <yuuji@gentei.org>
parents:
66
diff
changeset
|
3055 @H.text("groupname-#{g}", ghash['name'], nil, 12) |
0 | 3056 else |
3057 ghash['name'] | |
3058 end + '<br>' + \ | |
66 | 3059 # If this group is inviteonly and the user is not a member, |
67
a421c2fefc32
Fix the argument for FileUtils.mkdir_p()
HIROSE Yuuji <yuuji@gentei.org>
parents:
66
diff
changeset
|
3060 # one cannot join. |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3061 if memberp && adminp || !@sc.getgroupattr(g, 'inviteonly') |
66 | 3062 @H.radio("groupadd-#{g}", "yes", "IN", memberp) + " / " + \ |
3063 @H.radio("groupadd-#{g}", "no", "OUT", !memberp) | |
3064 else | |
3065 @H.element("small"){"("+msg('inviteonly')+")"} | |
3066 end | |
0 | 3067 } + \ |
3068 @H.element("td"){ | |
47 | 3069 @H.element("div", {'class'=>'memlist5'}){ |
3070 memlist = ghash['members'] | |
3071 if memberp # move this user to the beginning of list | |
3072 memlist.delete(user) | |
3073 memlist.unshift(user) | |
3074 end | |
3075 memlist.collect{|u| | |
68
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3076 (adminp \ |
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3077 ? @H.element("abbr", "title"=>mailaddress(u)) { |
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3078 @sc.nickname(u) |
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3079 } |
db1502243712
Do not hover mail addresses of users for non-administrator list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
67
diff
changeset
|
3080 : @sc.nickname(u)) + \ |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3081 ((u == user) ? ("("+@H.text("mail4-#{g}", memberp, 30, 180)+")") : "") |
47 | 3082 }.join(", ") |
3083 } | |
3084 } + \ | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3085 @H.element("td"){ |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3086 @H.a(@myname+"?-listdraft+#{g}", msg('sendall')) |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3087 } |
0 | 3088 } |
27 | 3089 }.join("\n") |
0 | 3090 } + \ |
3091 '' + \ | |
3092 @H.p(msg('groupwarn', 'shortnameplz')) + \ | |
3093 @H.submit_reset("GO") | |
3094 } # form | |
3095 end | |
2 | 3096 def groupnamesString() |
3097 @H.elementln("p", {'class'=>'listup'}){ | |
3098 @sc.groups().collect{|g|@sc.groupname(g)}.join(", ") | |
3099 } | |
3100 end | |
0 | 3101 def groupmod() |
3102 if !checkauth | |
3103 return nil | |
3104 end | |
3105 @O.print @H.elementln("h1"){ | |
3106 msg('group', 'management')+" "+msg('done') | |
3107 } | |
3108 user=@params['user'] | |
3109 @O.print @params.inspect if $DEBUG | |
3110 | |
3111 for grp in @sc.groups() | |
3112 # | |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3113 # As a member, participate or retire |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3114 |
0 | 3115 key = "groupadd-#{grp}" |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3116 memberp = @sc.ismember(user, grp) |
0 | 3117 removep = (/no/i =~ @params[key]) |
3118 if @params[key] | |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3119 # |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3120 # Check the group is invitation-only mode. |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3121 if !removep && !memberp && !@sc.isadmin(user, grp) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3122 @O.print @H.elementln("p") { |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3123 sprintf(msg('invite-error'), grp) + "<br>\n" + \ |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3124 @sc.admins(grp).join(", ") |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3125 } |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3126 sendMail(defaultmladdress(grp).sub("@", @mailadmsuffix+"@"), |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3127 "Group paticipation attempt to #{grp}", |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3128 putLog("User `%s' tried to join `%s' from %s" % |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3129 [user, grp, ENV['REMOTE_ADDR']]), |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3130 nil, |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3131 @sc.admins(grp)) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3132 next |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3133 end |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3134 # |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3135 # OK to join/retire |
0 | 3136 if (!removep) ^ memberp |
3137 @sc.addgroup(grp, [user], removep) | |
3138 @O.print @H.elementln("p"){ | |
3139 sprintf "%s [%s] %s %s", msg('user'), user, | |
3140 removep ? msg('removedfromgp') : msg('addedtogroup'), grp | |
3141 } | |
3142 end | |
3143 end | |
3144 # | |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3145 # As a member, change group-specific mailto address. |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3146 key = "mail4-#{grp}" |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3147 if memberp && @params[key] && memberp != @params[key] |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3148 @sc.addgroup(grp, [[user, @params[key]]]) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3149 newmemp = @sc.ismember(user, grp) |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3150 @O.print @H.elementln("p") { |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3151 sprintf("%s `%s' %s => %s%s", |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3152 msg('group'), grp, msg('mailaddress'), @params[key], |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3153 @params[key]==mailaddress(user) ? "(same)" : "") |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3154 } |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3155 end |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3156 # |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3157 # as an owner, change the name of group |
0 | 3158 if @sc.isadmin(user, grp) && |
3159 (newname = @params["groupname-#{grp}"]) && | |
3160 @sc.groupname(grp) != newname | |
2 | 3161 @O.printf "@sc.name2group=%s<br>\n", @sc.name2group(newname) |
3162 if dupl=@sc.name2group(newname) | |
3163 @O.print @H.p(sprintf(msg('dupname'), newname)) | |
3164 @O.print groupnamesString() | |
3165 | |
3166 else | |
3167 @sc.setgroupname(grp, newname) | |
3168 @O.print @H.elementln("p"){ | |
3169 sprintf "%s %s%s %s", | |
3170 msg('group'), grp, msg('of', 'name', 'setto'), newname | |
3171 } | |
3172 end | |
0 | 3173 end |
3174 end | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
3175 link2home |
0 | 3176 end |
3177 def users() | |
3178 unless pm=open_pm() | |
3179 outputError(msg('autherror')) | |
3180 return nil | |
3181 end | |
3182 pm.users | |
3183 end | |
3184 def grepgroup(gname) | |
3185 gr = @sc.groups.grep(gname)[0] | |
3186 end | |
3187 def admgroup(group = nil) | |
3188 # if group==nil, create new | |
3189 if !checkauth | |
3190 return nil | |
3191 end | |
3192 @O.print @H.elementln("h1"){ | |
3193 msg('group', 'management') | |
3194 } | |
3195 user=@params['user'] | |
3196 | |
3197 # Check the existent group's validity | |
3198 if group | |
3199 unless (gr=grepgroup(group)) | |
3200 @O.print @H.p("No such group #{group}") | |
3201 return nil | |
3202 end | |
3203 group = gr | |
3204 unless @sc.isadmin(user, group) | |
3205 @O.print @H.p("You are not administrator of #{group}.") | |
3206 return nil | |
3207 end | |
3208 @O.print @H.elementln("h2"){ | |
3209 msg('group')+" #{group}" + | |
3210 if group != @sc.groupname(group) | |
3211 " (#{@sc.groupname(group)})" | |
3212 end.to_s | |
3213 } | |
3214 actionmethod={'action'=>@myname+"?-admgroupsub", 'method'=>'POST'} | |
3215 else | |
3216 # New group creation | |
3217 @O.print @H.elementln("h2"){ | |
3218 msg('newgroup') | |
3219 } | |
3220 actionmethod={'action'=>@myname+"?-newgroupsub", 'method'=>'POST'} | |
3221 end | |
3222 | |
43 | 3223 userlist = ([user] + users()).uniq.sort |
0 | 3224 myselfclass = {'class'=>'admin'} |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3225 yesclass = {'class' => 'yes'} |
0 | 3226 colspan2 = {'colspan'=>'2'} |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3227 colspan3 = {'colspan'=>'3'} |
0 | 3228 warnclass = {'class'=>'warn'} |
3229 warnp = nil | |
3230 | |
3231 @O.print @H.elementln("form", actionmethod){ | |
3232 @H.hidden('group', group) + "\n" + \ | |
3233 if group | |
64
2445a87742d0
Gather the current group-member at the beginning of the user list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
63
diff
changeset
|
3234 # Non symmetric job: Move the current users above. |
2445a87742d0
Gather the current group-member at the beginning of the user list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
63
diff
changeset
|
3235 gmemlist = userlist.select{|u| @sc.ismember(u, group)} |
2445a87742d0
Gather the current group-member at the beginning of the user list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
63
diff
changeset
|
3236 userlist = (gmemlist + userlist).uniq |
2445a87742d0
Gather the current group-member at the beginning of the user list.
HIROSE Yuuji <yuuji@gentei.org>
parents:
63
diff
changeset
|
3237 # In this context, should return simply "". |
0 | 3238 "" |
3239 else | |
3240 # new group creation | |
3241 grps = @sc.groups() | |
3242 i=1 | |
3243 defname = "group%03d"%i | |
3244 while grps.grep(defname)[0] | |
3245 defname = "group%03d"%(i+=1) | |
3246 end | |
3247 @H.element("pre"){ | |
3248 msg('group', 'of', 'id')+"\n"+@H.text("group", defname) + "\n" + \ | |
3249 msg('group', 'of', 'name', 'anystring')+"\n"+ \ | |
3250 @H.text("gname", '') + "\n" | |
3251 } | |
3252 end + \ | |
47 | 3253 @H.elementln("div", {'class'=>'memlist'}){ |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3254 @H.elementln("table", {'border'=>'1'}){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3255 @H.elementln("tr") { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3256 @H.elementln("th", colspan3) { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3257 msg('member', 'of', 'joinquit', 'operation')} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3258 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3259 @H.elementln("tr"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3260 @H.element("th"){msg('join')} + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3261 @H.element("th"){msg('administrator')} + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3262 @H.element("th"){msg('member')} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3263 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3264 userlist.collect{|u| |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3265 recursememp = nil |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3266 if group |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3267 memberp = (@sc.ismember(u, group) && true) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3268 adminp = (@sc.isadmin(u, group) && true) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3269 if !memberp && @sc.members(group).grep(u)[0] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3270 recursememp = true |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3271 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3272 else |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3273 memberp = adminp = (u == user) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3274 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3275 @H.elementln("tr", (u==user ? myselfclass : nil)){ |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3276 @H.element("td", memberp && yesclass){ |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3277 yes = memberp ? 'YES' : 'yes' |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3278 @H.radio('mem-'+u, 'yes', yes+' / ', memberp) + \ |
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3279 @H.radio('mem-'+u, 'no', 'no', !memberp) |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3280 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3281 @H.element("td"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3282 @H.radio('adm-'+u, 'yes', 'Admin / ', adminp) + \ |
55
9a82edb295ca
Adjust umask. Max width of email entry, enlarged.
HIROSE Yuuji <yuuji@gentei.org>
parents:
50
diff
changeset
|
3283 @H.radio('adm-'+u, 'no', 'no', !adminp) |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3284 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3285 @H.element("td"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3286 @H.element("abbr", "title"=>mailaddress(u)) { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3287 @sc.nickname(u) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3288 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3289 if recursememp |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3290 warnp = true |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3291 @H.element("span", warnclass){"(*)"} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3292 end.to_s |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3293 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3294 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3295 }.join + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3296 # group names |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3297 @H.elementln("tr") { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3298 @H.elementln("th", colspan3) { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3299 msg('group', 'of', 'joinquit', 'operation')} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3300 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3301 @H.elementln("tr"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3302 @H.element("th", colspan2){msg('join')} + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3303 @H.element("th"){msg('group')} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3304 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3305 @sc.groups().sort.collect{|g| |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3306 next if group == g |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3307 memberp = @sc.ismember(g, group) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3308 @H.element("tr"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3309 @H.element("td", colspan2){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3310 @H.radio('mem-'+g, 'yes', 'YES / ', memberp) + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3311 @H.radio('mem-'+g, 'no', 'NO', !memberp) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3312 } + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3313 @H.element("td"){ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3314 if @sc.isadmin(user, g) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3315 @H.a(@myname+"?-admgroup+#{g}", @sc.groupname(g)) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3316 else |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3317 @sc.groupname(g) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3318 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3319 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3320 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3321 }.join |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3322 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3323 } + \ |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3324 ["fromhack", "inviteonly"].collect do |param| |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3325 @H.checkbox(param, "yes", msg(param), |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3326 @sc.getgroupattr(group, param)) + "<br>\n" |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3327 end.join + \ |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3328 (group ? @H.elementln("p") { |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3329 sprintf(msg('mladdress'), defaultmladdress(group)) + \ |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3330 @H.text("mladdress", @sc.getgroupattr(group, 'mladdress'), |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3331 @opt['size'], 80) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3332 } : "") + \ |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3333 @H.elementln('p') { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3334 n = -1 |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3335 curtag = @sc.getgroupattr(group, 'subjtag') |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3336 values = @subjtags.collect {|x| |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3337 sprintf(' <option value="%d"%s>%s</option>', n+=1, |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3338 curtag==@subjtags[n][1] ? ' selected' : "", |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3339 x[0]) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3340 }.join("\n") |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3341 "Subject tag: " + \ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3342 <<-_EOF_ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3343 <select name="subjtag"> |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3344 <option value="">DEFAULT</option> |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3345 #{values} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3346 </select> |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3347 _EOF_ |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3348 } + \ |
0 | 3349 @H.submit_reset("GO") |
3350 } # form | |
3351 @O.print @H.p(@H.element("span", warnclass){"(*)"}+ | |
3352 msg('recursewarn')) if warnp | |
2 | 3353 if group && (members = @sc.members(group))[0] |
0 | 3354 @O.print @H.p(sprintf(msg('wholemembers'), group)) |
3355 @O.print @H.elementln("p", {'class'=>'listup'}){ | |
2 | 3356 members.collect{|u|@sc.nickname(u)}.join(", ")} |
0 | 3357 end |
3358 | |
3359 # | |
3360 # Next section, REMOVE GROUP! | |
3361 return nil unless group | |
3362 @O.print @H.elementln("h2"){ | |
3363 sprintf "%s %s %s", msg('group'), group, msg('deletion') | |
3364 } | |
3365 @O.print @H.p(msg('deletionwarn'))+"\n" | |
3366 @O.print @H.elementln("form", {'action'=>@myname+"?-delgroupsub+#{group}", 'method'=>'POST'}){ | |
3367 @H.hidden("group", group) + "\n" + \ | |
3368 @H.elementln("table"){ | |
3369 @H.elementln("tr"){ | |
3370 @H.elementln("td"){ | |
3371 sprintf msg('delgroup'), group | |
3372 } + \ | |
3373 @H.elementln("td"){ | |
3374 @H.radio("delete", "yes", msg('yes')) + ' ' + \ | |
3375 @H.radio("delete", "no", msg('no'), true) | |
3376 } | |
3377 } + \ | |
3378 @H.elementln("tr"){ | |
3379 @H.elementln("td"){ | |
3380 sprintf msg('really?'), group | |
3381 } + \ | |
3382 @H.elementln("td"){ | |
3383 @H.radio("delete2", "yes", msg('yes')) + ' ' + \ | |
3384 @H.radio("delete2", "no", msg('no'), true) | |
3385 } | |
3386 } | |
3387 } + \ | |
3388 "<br>\n" + @H.submit_reset("GO") | |
3389 } | |
3390 | |
3391 @O.print footer() | |
3392 end | |
3393 def newgroup() | |
3394 admgroup(nil) | |
3395 end | |
3396 | |
3397 def delgroupsub(group) | |
3398 if !checkauth | |
3399 return nil | |
3400 end | |
3401 user = @params['user'] | |
3402 if group != @params['group'] | |
3403 @O.print @H.p("Group mismatch") | |
3404 return nil | |
3405 end | |
3406 unless (gr=grepgroup(group)) | |
3407 @O.print @H.p("No such group #{group}") | |
3408 return nil | |
3409 end | |
3410 group = gr | |
3411 unless @sc.isadmin(user, group) | |
3412 @O.print @H.p("You are not administrator of #{group}.") | |
3413 return nil | |
3414 end | |
3415 unless @params['delete'] && /yes/i =~ @params['delete'] \ | |
3416 && @params['delete2'] && /yes/i =~ @params['delete2'] | |
3417 @O.print @H.p(msg('chicken')) | |
3418 return nil | |
3419 end | |
3420 @O.print @H.elementln("h1"){ | |
3421 msg('group')+" #{group} "+msg('deletion') | |
3422 } | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3423 resmsg = @sc.destroygroup(group) ? msg("done") : msg("failure") |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3424 @O.print @H.p(resmsg) |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3425 putLog("Delete group '#{group}' #{resmsg}\n") |
0 | 3426 |
3427 @O.print footer() | |
3428 end | |
3429 | |
3430 def deleteuser(user) | |
3431 @sc.deleteuser(user) && | |
3432 begin | |
3433 pm = open_pm | |
3434 pm.delete(user) | |
3435 pm.close() | |
3436 true | |
3437 rescue | |
3438 nil | |
3439 end | |
3440 end | |
3441 def delusersub(user) | |
3442 if !checkauth | |
3443 return nil | |
3444 end | |
3445 user = @params['user'] | |
3446 if user != @params['user'] | |
3447 @O.print @H.p("User mismatch") | |
3448 return nil | |
3449 end | |
3450 unless (us=users().grep(user)[0]) | |
3451 @O.print @H.p("No such user #{user}") | |
3452 return nil | |
3453 end | |
3454 user = us | |
3455 unless @params['delete'] && /yes/i =~ @params['delete'] \ | |
3456 && @params['delete2'] && /yes/i =~ @params['delete2'] | |
3457 @O.print @H.p(msg('chicken')) | |
3458 return nil | |
3459 end | |
3460 @O.print @H.elementln("h1"){ | |
3461 msg('user')+" #{user} "+msg('deletion') | |
3462 } | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3463 resmsg = deleteuser(user) ? msg("done") : msg("failure") |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3464 @O.print @H.p(resmsg) |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3465 putLog("Delete user '#{user}' #{resmsg}\n") |
0 | 3466 |
7 | 3467 @O.print @H.p(@H.a(@myname, msg('login'))) |
0 | 3468 end |
3469 | |
3470 def admgroupsub() | |
3471 if !checkauth | |
3472 return nil | |
3473 end | |
3474 user = @params['user'] | |
3475 group = @params['group'] | |
3476 unless (gr=grepgroup(group)) | |
3477 @O.print @H.element("pre"){"No such group #{group.inspect}"} | |
3478 return nil | |
3479 end | |
3480 unless @sc.isadmin(user, group) | |
3481 @O.print @H.p("You are not administrator of #{group}.") | |
3482 return nil | |
3483 end | |
3484 gorup = gr | |
3485 @O.print @H.elementln("h1"){ | |
3486 msg('group', 'management', 'done') | |
3487 } | |
3488 @O.print @H.elementln("h2"){ | |
3489 msg('group')+" #{group}" + | |
3490 if group != @sc.groupname(group) | |
3491 " (#{@sc.groupname(group)})" | |
3492 end.to_s | |
3493 } | |
3494 somethingdone = nil | |
3495 for u in users() | |
2 | 3496 u = @sc.isuser(u) # users() value is considered tainted. |
3497 next unless u # Use registered value in @sc. | |
0 | 3498 for var, kind in { |
3499 "mem"=>['members', 'member'], 'adm'=>['admin', 'administrator']} | |
3500 memv = "#{var}-#{u}" | |
3501 if @params[memv] | |
3502 joinp = ((/^yes/i =~ @params[memv]) && true) | |
3503 membp = if var=='mem' | |
3504 @sc.ismember(u, group) | |
3505 else # admin | |
3506 @sc.isadmin(u, group) | |
3507 end && true | |
3508 if var=='adm' && @sc.admins(group).length == 1 && membp && !joinp | |
3509 @O.print @H.p(sprintf(msg('soleadmin'), u, group)) | |
3510 elsif joinp ^ membp | |
3511 somethingdone = true | |
3512 @sc.addgroup(group, [u], !joinp, kind[0]) | |
3513 @O.print @H.elementln("p"){ | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3514 putLog(sprintf "%s [%s](%s) %s %s", msg('user'), u, |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3515 msg(kind[1]), |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3516 joinp ? msg('addedtogroup'): msg('removedfromgp'), group) |
0 | 3517 } |
3518 end | |
3519 end | |
3520 end | |
3521 end # users() | |
3522 | |
3523 # add or remove for group in groups | |
3524 for g in @sc.groups() | |
3525 next if g == group | |
3526 memv = "mem-#{g}" | |
3527 if @params[memv] | |
3528 joinp = ((/^yes/i =~ @params[memv]) && true) | |
3529 membp = (@sc.ismember(g, group) && true) | |
3530 if joinp ^ membp | |
3531 somethingdone = true | |
3532 @sc.addgroup(group, [g], !joinp) | |
3533 @O.print @H.elementln("p"){ | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3534 putLog(sprintf("%s [%s] %s %s", |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3535 msg('group'), g, |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3536 joinp ? |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3537 msg('addedtogroup') |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3538 : msg('removedfromgp'), group)) |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3539 } |
0 | 3540 end |
3541 end | |
3542 end # groups | |
47 | 3543 # Change parameter(s) |
3544 # To be more generic... | |
62
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3545 ["fromhack", "inviteonly"].each {|param| |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3546 parsetp = (@params[param] && /^yes/i =~ @params[param]) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3547 cursetp = (@sc.getgroupattr(group, param)!=nil) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3548 if cursetp ^ parsetp |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3549 @sc.putgroupattr(group, param, @params[param]) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3550 @O.print @H.elementln("p") { |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3551 putLog(sprintf("group: %s[%s] -> %s", |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3552 group, param, @params[param].inspect)) |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3553 } |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3554 somethingdone = true |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3555 end |
2d33f85c3d9f
Introduce invitation-only mode for groups.
HIROSE Yuuji <yuuji@gentei.org>
parents:
61
diff
changeset
|
3556 } |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3557 # mladdress |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3558 newmladdress = @params['mladdress'] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3559 newmladdress = nil if newmladdress == "" |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3560 curmladdress = @sc.getgroupattr(group, 'mladdress') |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3561 if newmladdress != curmladdress |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3562 defmladdress = defaultmladdress(group) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3563 @sc.putgroupattr(group, 'mladdress', newmladdress) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3564 @O.print @H.elementln("p") { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3565 putLog(sprintf("group: %s[mladdress] <%s> -> <%s>", |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3566 group, |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3567 curmladdress || defmladdress, |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3568 newmladdress || defmladdress)) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3569 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3570 somethingdone = true |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3571 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3572 # Subject tag bracket |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3573 newtag = @params['subjtag'] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3574 if newtag == '' |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3575 newtag = nil |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3576 else |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3577 newtag = @subjtags[newtag.to_i % @subjtags.length][1] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3578 end |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3579 @sc.putgroupattr(group, 'subjtag', newtag) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3580 if newtag && newtag > "" |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3581 @O.print @H.elementln("p") { |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3582 putLog(sprintf("group: %s[subjtag] set to '%s'", group, newtag)) |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3583 } |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3584 somethingdone = true |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3585 end |
0 | 3586 unless somethingdone |
3587 # @O.print @H.p(msg('nothingtodo')) | |
3588 end | |
36
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
3589 # @O.print footer() |
e67737e49a5d
add a5userman.html multiplenotify.html
HIROSE Yuuji <yuuji@gentei.org>
parents:
35
diff
changeset
|
3590 link2home |
0 | 3591 end |
3592 def newgroupsub() | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3593 return nil unless checkauth |
0 | 3594 user = @params['user'] |
3595 newgroup = @params['group'] | |
3596 newgname = @params['gname'] | |
3597 | |
3598 | |
3599 if @sc.groups.grep(newgroup)[0] | |
3600 @O.print @H.p(msg('existent')+newgroup) | |
3601 return nil | |
3602 end | |
2 | 3603 if dupl=@sc.name2group(newgname) |
3604 @O.print @H.p(sprintf(msg('dupname'), newgname)) | |
3605 @O.print groupnamesString() | |
3606 return nil | |
3607 end | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3608 @sc.creategroup(newgroup, newgname, [user]) && |
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3609 putLog("New group '#{newgroup}'(#{newgname}) created\n") |
47 | 3610 admgroupsub() |
0 | 3611 end |
3612 | |
14 | 3613 # |
3614 # Methods Related to viaMail functions | |
3615 def gen_sessionpswd() | |
3616 | |
3617 end | |
3618 def viamail_registform() | |
3619 c = "# " | |
3620 nl = "\n" | |
3621 user = @params['user'] | |
3622 msg('addsched') + "-" * 20 + nl*2 + \ | |
3623 c + msg('user') + nl + \ | |
3624 "user=" + user + nl*2 + \ | |
3625 c + msg('sessionpswd') + nl + \ | |
3626 "sp=hoge" + nl*2 + \ | |
3627 c + msg('date') + nl + \ | |
3628 "date="+Time.now.strftime("%Y/%m/%d") + nl*2 + \ | |
3629 c + msg('time') + sprintf(msg('24hourtxt'), @opt['alldaydir']) + nl + \ | |
3630 "time=3000"+nl*2 + \ | |
3631 c + msg('publicp') + nl + \ | |
3632 "public=yes" + nl*2 + \ | |
3633 c + msg('neednotify') + nl + \ | |
3634 "nt10m=yes (%s) | |
3635 nttoday=yes (%s) | |
3636 nt1d=yes (%s) | |
3637 nt7d=yes (%s)" % ["10"+msg('minutes')+msg('before'), | |
3638 msg('theday'), msg('precedingday'), | |
3639 "7"+msg('days')+msg('before')] + nl*2 + \ | |
3640 | |
3641 c + msg('schedulehere') | |
3642 end | |
3643 def viamail_footer() | |
3644 viamail_registform() | |
3645 end | |
3646 def show_by_text(date, days) | |
3647 user = @params['user'] | |
3648 personal = true | |
3649 sched = dayTextString(user, date, days, personal) | |
3650 # @O.print outstr | |
3651 | |
3652 sendMail(mailaddress(user), | |
3653 "After5 Schedule", | |
3654 @opt['url'] + "\n" + \ | |
3655 Time.now.strftime("%Y/%m/%d") + \ | |
3656 sprintf(msg('schedlist'), days) + "\n\n" + \ | |
3657 if sched > '' | |
3658 sched | |
3659 else | |
3660 msg('noplan')+"\n" | |
3661 end + \ | |
3662 viamail_footer | |
3663 ) | |
3664 | |
3665 end | |
3666 def parseHeader | |
3667 contline=nil | |
3668 header=Hash.new | |
3669 text=Array.new | |
3670 | |
3671 field=nil | |
3672 # header | |
3673 while line=STDIN.gets | |
3674 text << line | |
3675 break if /^$/ =~ line | |
3676 | |
3677 if /^\s+/ =~ line | |
3678 if field | |
3679 header[field][-1] << line | |
3680 end | |
3681 else | |
3682 if /^([^:]+):\s*(.*)/ =~ line | |
3683 field=$1.downcase | |
3684 header[field] or header[field] = [] | |
3685 header[field] << $2 | |
3686 end | |
3687 end | |
3688 end | |
3689 header | |
3690 end | |
3691 def mail_regsched() | |
3692 @params = Hash.new # Reset | |
3693 | |
3694 reqparams = %w[user sp date time public] | |
3695 otherparams = %w[nt10m nttoday nt1d nt7d] | |
3696 setall = lambda{ | |
3697 reqparams.each{|key| return false unless @params.has_key?(key)} | |
3698 return true | |
3699 } | |
3700 stack = "" | |
3701 while line=gets # !setall.call && line=gets | |
3702 if /^(\S+)=(.*)/ =~ line | |
3703 next unless reqparams.index($1) || otherparams.index($1) | |
3704 @params[$1] = $2 | |
3705 #if reqparams.index($1) | |
3706 STDERR.print "Set #{$1} to #{$2}\n" | |
3707 #end | |
3708 buf = "" | |
3709 elsif /^\s*\#|^$/ =~ line | |
3710 # skip comments | |
3711 else | |
3712 buf += line | |
3713 end | |
3714 end | |
3715 unless setall.call | |
3716 STDERR.print "Insufficient variables\n" | |
3717 exit 1 | |
3718 end | |
3719 p buf | |
3720 | |
3721 y, m, d = date2ymd(@params["date"]) | |
3722 @params["year"] = y | |
3723 @params["month"] = m | |
3724 @params["day"] = d | |
3725 @params["schedule"] = buf | |
3726 @params["editmode"] = "modify" | |
3727 @params["sessionpw"] = @params["sp"] | |
3728 p @params | |
3729 add_remove() | |
3730 end | |
3731 def mail_getsched() | |
3732 user = nil | |
3733 while bline=gets | |
3734 if /(\S+@\S+)/ =~ bline | |
3735 break if user=@sc.isuser($1) | |
3736 end | |
3737 end | |
3738 unless user | |
3739 sendMail(@opt['maintainer'], "viaMail Request Error", | |
3740 "This is `#{@mybase}' in #{@mydir}\n" + | |
3741 "Invalid schedule request from #{ENV['SENDER']}.\n\n") | |
3742 exit 1 | |
3743 end | |
3744 today = Time.now.strftime("%Y/%m/%d") | |
3745 days = 7 | |
3746 if bline=gets | |
3747 if /\d+/ =~ bline | |
3748 days = bline.to_i | |
3749 end | |
3750 end | |
3751 # Send user to schedules of today and near future | |
3752 @params['user'] = user | |
3753 show_by_text(today, days) | |
3754 end | |
3755 def doMail() | |
3756 days = 7 | |
3757 # Confirm `via Mail' | |
3758 prohibitviahttp() | |
3759 @H = TEXTout.new | |
3760 unless ENV['RECIPIENT'] && ENV['SENDER'] | |
3761 STDERR.print "Call me via qmail\n" | |
3762 exit 1 | |
3763 end | |
3764 @mailmode = true | |
3765 header = parseHeader # is this necessary? | |
3766 if /regist/ =~ ENV["EXT"] | |
3767 mail_regsched() | |
3768 else | |
3769 mail_getsched() | |
3770 end | |
3771 end | |
3772 | |
3773 # | |
3774 # Password related Methos | |
0 | 3775 def setpasswd(user) |
3776 prohibitviahttp() | |
3777 pm = open_pm() | |
3778 exit 1 unless pm | |
3779 if pm.userexist?(user) then | |
3780 begin | |
3781 system "stty -echo" | |
3782 STDERR.print "New passwd: " | |
3783 p1 = STDIN.gets | |
3784 STDERR.print "\nAgain: " | |
3785 p2 = STDIN.gets | |
3786 ensure | |
3787 system "stty echo" | |
3788 end | |
3789 if (p1 == p2) then | |
3790 pm.setpasswd(user, p1.chop!) | |
3791 end | |
3792 STDERR.print "New password for #{user} set successfully\n" | |
3793 else | |
3794 STDERR.print "User #{user} not found\n" | |
3795 end | |
3796 pm.close() | |
3797 exit 0 | |
3798 end | |
3799 def adduser(user) | |
3800 prohibitviahttp() | |
3801 pm = open_pm() | |
3802 exit 1 unless pm | |
60 | 3803 if pm.userexist?(user) && !ENV['PWRESET'] |
59
595ff0134cd9
Skip creation of user which is already registered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
58
diff
changeset
|
3804 printf("User %s already exists. Skip.\n", user) |
60 | 3805 printf("If you reset passwd to new one, PWRESET=1 #{$0} ...\n") |
59
595ff0134cd9
Skip creation of user which is already registered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
58
diff
changeset
|
3806 exit 1 |
595ff0134cd9
Skip creation of user which is already registered.
HIROSE Yuuji <yuuji@gentei.org>
parents:
58
diff
changeset
|
3807 end |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3808 email = nil |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3809 if /(.*@.*)=(.*@.*)/ =~ user |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3810 user, email = $1, $2 |
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3811 end |
0 | 3812 newpwd = pm.setnewpasswd(user, 4) |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3813 @sc.createuser(user, email) |
0 | 3814 print "#{user}'s password is #{newpwd}\n" |
3815 pm.close() | |
3816 exit 0 | |
3817 end | |
3818 def deluser(user) | |
3819 prohibitviahttp() | |
3820 pm = open_pm() | |
3821 exit 1 unless pm | |
3822 pm.delete(user) | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3823 @sc.deleteuser(user) |
0 | 3824 pm.close() |
3825 exit 0 | |
3826 end | |
3827 | |
3828 # read configuratoin file | |
3829 def readconf(conf) | |
3830 cf = "after5.cf" #conf # || @opt['conf'] | |
3831 cf = File.join(@mydir, cf) unless test(?s, cf) | |
3832 cf = File.join(ENV["HOME"], cf) unless test(?s, cf) | |
3833 return unless test(?s, cf) | |
3834 begin | |
3835 IO.foreach(cf){|line| | |
26 | 3836 line = line.toeuc |
0 | 3837 next if /^\s *#/ =~ line |
3838 line.chop! | |
3839 line.sub!(/^\s*#.*/, '') | |
3840 next if /^$/ =~ line | |
3841 case line | |
3842 # title, type = line.split(/\t+/) | |
3843 when /^([a-z]+)=(.*)/oi | |
3844 key, value = $1, $2 | |
3845 case value | |
6 | 3846 when /^(no|none|null|nil|false|0|off)$/io |
0 | 3847 @opt[key] = nil |
3848 else | |
45
1b16890d61d6
ML: digited subject, ML-specific email addresses, spooling
HIROSE Yuuji <yuuji@gentei.org>
parents:
44
diff
changeset
|
3849 @opt[key] = value.untaint |
0 | 3850 end |
3851 print "#{key} set to #{value}\n" if $DEBUG | |
3852 end | |
3853 } | |
3854 rescue | |
26 | 3855 STDERR.printf("Configuration file %s not readable\n", cf) |
0 | 3856 end |
3857 end | |
3858 | |
3859 def parsedate(string) | |
3860 if %r,^(\d\d\d\d+)/(\d+)/(\d+)/(\d+)/([^/]+)$, =~ string | |
3861 sprintf "%04d/%02d/%02d/%04d/%s", $1.to_i, $2.to_i, $3.to_i, $4.to_i, | |
3862 grepgroup($5) | |
3863 elsif %r,^(\d\d\d\d+)/(\d+)/(\d+)/(\d+), =~ string | |
3864 sprintf "%04d/%02d/%02d/%04d", $1.to_i, $2.to_i, $3.to_i, $4.to_i | |
3865 elsif %r,^(\d\d\d\d+)/(\d+)/(\d+), =~ string | |
3866 sprintf "%04d/%02d/%02d", $1.to_i, $2.to_i, $3.to_i | |
3867 elsif %r,^(\d\d\d\d+)/(\d+), =~ string | |
3868 sprintf "%04d/%02d", $1.to_i, $2.to_i | |
3869 elsif %r,^(\d\d\d\d+)/(\d+), =~ string | |
3870 sprintf "%04d", $1.to_i | |
3871 end | |
3872 end | |
3873 | |
3874 def getarg() | |
3875 argument = {} | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3876 @oldargv = ARGV.dup |
0 | 3877 |
3878 while /^-/ =~ ARGV[0] | |
3879 case ARGV[0] | |
3880 when '-f' | |
3881 conf = ARGV[1] | |
3882 ARGV.shift | |
3883 when "-d" | |
3884 $DEBUG = true | |
3885 when "-install" | |
14 | 3886 when "-stream" |
3887 # ARGV.shift | |
3888 # @job = 'show_by_text "2005/1/18"' | |
3889 @job = 'doMail' | |
0 | 3890 when "-addsched" |
3891 @job = "addsched" | |
3892 when "-today" | |
3893 @job = "today" | |
2 | 3894 when "-today_p" |
3895 argument['displaymode'] = 'personal' | |
3896 @job = "today" | |
3897 when "-today_n" | |
3898 argument['displaymode'] = 'normal' | |
3899 @job = "today" | |
0 | 3900 when "-remove" |
3901 ARGV.shift | |
3902 @job = 'remove "'+parsedate(ARGV[0])+'"' | |
14 | 3903 when "-move" |
3904 ARGV.shift | |
3905 @job = 'move "'+parsedate(ARGV[0])+'"' | |
0 | 3906 when "-modify" |
3907 ARGV.shift | |
3908 @job = 'modify "'+parsedate(ARGV[0])+'"' | |
3909 when "-month" | |
3910 ARGV.shift | |
3911 @job = 'month "'+parsedate(ARGV[0])+'"' | |
3912 when "-show" | |
3913 ARGV.shift | |
3914 # @job = "show '"+ARGV[0]+"'" | |
3915 @job = "show '"+parsedate(ARGV[0])+"'" | |
3916 when "-login" | |
3917 @job = "login" | |
3918 when "-userman" | |
3919 @job = "userman" | |
3920 when "-usermod" | |
3921 @job = "usermod" | |
3922 when "-groupinout" | |
3923 @job = "groupinout" | |
3924 when "-groupsubmit" | |
3925 @job = "groupsubmit" | |
3926 when "-groupman" | |
48
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3927 ARGV.shift |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3928 x=ARGV[0] |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3929 @prc = proc {groupman(x)} |
05de5274c110
Another ml-address can be set.
HIROSE Yuuji <yuuji@gentei.org>
parents:
47
diff
changeset
|
3930 @job = "@prc.call" |
0 | 3931 when "-groupmod" |
3932 @job = "groupmod" | |
3933 when "-notify" | |
3934 @job = 'notify' # + exit | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3935 when "-list" |
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3936 @job = 'list' # + exit |
0 | 3937 when "-newgroup" |
3938 @job = 'newgroup' | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3939 when /^-(admgroup|listdraft)$/ |
0 | 3940 ARGV.shift |
3941 gr = safecopy(grepgroup(ARGV[0])) | |
3942 ##gr.untaint | |
37
1515ea889ea1
First implementation of ML feature.
HIROSE Yuuji <yuuji@gentei.org>
parents:
36
diff
changeset
|
3943 @job = safecopy($1)+' "'+gr+'"' |
0 | 3944 when "-admgroupsub" |
3945 @job = 'admgroupsub' | |
3946 when "-newgroupsub" | |
3947 @job = 'newgroupsub' | |
3948 when "-delusersub" | |
3949 ARGV.shift | |
6 | 3950 usr = safecopy(users().grep(ARGV[0])[0]) |
0 | 3951 @job = 'delusersub "'+usr+'"' |
3952 when "-delgroupsub" | |
3953 ARGV.shift | |
42
07ef43ac4f15
Some ruby-1.9 workarounds and enhancement to logging and messaging.
HIROSE Yuuji <yuuji@gentei.org>
parents:
41
diff
changeset
|
3954 gr = safecopy(grepgroup(ARGV[0])) |
0 | 3955 @job = 'delgroupsub "'+gr+'"' |
3956 when /-(setpasswd|deluser|adduser)$/ | |
3957 ARGV.shift | |
3958 @job = $1+ " '#{ARGV[0]}'" # + exit | |
3959 when "" | |
3960 end | |
3961 ARGV.shift | |
3962 end | |
3963 | |
3964 readconf(@conf) | |
3965 | |
3966 query = '' | |
3967 method = ENV["REQUEST_METHOD"] | |
3968 if /POST/i =~ method then | |
3969 length = ENV["CONTENT_LENGTH"].to_i | |
3970 query = STDIN.read(length) | |
3971 elsif /GET/i =~ method then | |
3972 query = ENV["QUERY_STRING"] | |
3973 else # executed from command line | |
3974 query = ARGV.join("&") | |
3975 end | |
3976 | |
3977 for unit in query.split(/\&/) | |
3978 if /^([a-z][-_0-9@%a-z.]*)=(.*)/i =~ unit | |
3979 key, value = $1, $2 | |
3980 #value.gsub!(/%(..)/){[$1.hex].pack("c")} # これでURLデコードが一発 | |
3981 decode!(value) | |
3982 decode!(key) | |
3983 value = Kconv::toeuc(value) # EUCに変換 | |
3984 printf "[%s] = %s\n", key, value if $DEBUG | |
3985 argument[key] = value | |
3986 end | |
3987 end | |
3988 argument | |
3989 end | |
3990 def getcookie() | |
3991 cookie = {} | |
7 | 3992 return cookie unless ENV['HTTP_COOKIE'] |
3993 #if /value=(.*)/ =~ ENV['HTTP_COOKIE'] | |
3994 for cv in ENV['HTTP_COOKIE'].split(/[\; ]+/).grep(/(value|prefs)=(.*)/) | |
0 | 3995 # value=$1.gsub!(/%(..)/){[$1.hex].pack("c")} |
7 | 3996 next unless /\w+=(.*)/ =~ cv |
0 | 3997 value=decode!($1) |
7 | 3998 next unless value |
0 | 3999 for line in value.split("&") |
4000 if /(\w+)=(.*)/ =~ line | |
4001 key, value = $1, $2 | |
4002 #value.gsub!(/%(..)/){[$1.hex].pack("c")} # これでURLデコードが一発 | |
4003 decode!(value) | |
4004 value = Kconv::toeuc(value) # EUCに変換 | |
4005 printf "cookie[%s] = %s\n", key, value if $DEBUG | |
4006 cookie[key] = value | |
4007 end | |
4008 end | |
4009 end | |
4010 cookie | |
4011 end | |
4012 end | |
4013 | |
17 | 4014 $KCODE='e' if RUBY_VERSION < "1.9" |
0 | 4015 After5.new.doit |
4016 | |
4017 if __FILE__ == $0 | |
4018 end | |
4019 | |
4020 | |
4021 # Local variables: | |
4022 # buffer-file-coding-system: euc-jp | |
4023 # End: |