| 8 |
require Message::CGI::Carp; |
require Message::CGI::Carp; |
| 9 |
|
|
| 10 |
require 'users.pl'; |
require 'users.pl'; |
| 11 |
|
require 'texts.pl'; |
| 12 |
|
|
| 13 |
|
our $subject_prefix; |
| 14 |
|
|
| 15 |
require Message::CGI::HTTP; |
require Message::CGI::HTTP; |
| 16 |
require Encode; |
require Encode; |
| 19 |
return Encode::decode ('utf-8', $_[1]); |
return Encode::decode ('utf-8', $_[1]); |
| 20 |
}; |
}; |
| 21 |
|
|
| 22 |
|
our $Lang = 'ja' |
| 23 |
|
if $cgi->get_meta_variable ('HTTP_ACCEPT_LANGUAGE') =~ /\bja\b/; ## TODO: ... |
| 24 |
|
|
| 25 |
require Message::DOM::DOMImplementation; |
require Message::DOM::DOMImplementation; |
| 26 |
my $dom = Message::DOM::DOMImplementation->new; |
my $dom = Message::DOM::DOMImplementation->new; |
| 27 |
|
|
| 45 |
|
|
| 46 |
my $e_user_id = htescape ($user_id); |
my $e_user_id = htescape ($user_id); |
| 47 |
|
|
| 48 |
print qq[Content-Type: text/html; charset=utf-8 |
print q[Content-Type: text/html; charset=utf-8 |
| 49 |
|
|
| 50 |
<!DOCTYPE HTML> |
<!DOCTYPE HTML> |
| 51 |
<html lang=en> |
<html lang=en class=account-user-info> |
| 52 |
<title>User $e_user_id</title> |
<title>]; |
| 53 |
<link rel=stylesheet href="/www/style/html/xhtml"> |
print_text ('User %s', sub { print $e_user_id }); |
| 54 |
<h1>User $e_user_id</h1> |
print q[</title> |
| 55 |
]; |
<link rel=stylesheet href="/admin/style/common"> |
| 56 |
|
<h1>]; |
| 57 |
|
print_text ('User %s', sub { print $e_user_id }); |
| 58 |
|
print q[</h1>]; |
| 59 |
|
|
| 60 |
my @joined; |
my @joined; |
| 61 |
my @requested; |
my @requested; |
| 82 |
} |
} |
| 83 |
} |
} |
| 84 |
|
|
| 85 |
print qq[<section id=groups><h2>Groups</h2>]; |
print q[<section id=groups><h2>]; |
| 86 |
|
print_text ('Groups'); |
| 87 |
|
print q[</h2>]; |
| 88 |
|
|
| 89 |
if (@joined) { |
if (@joined) { |
| 90 |
print_list_section |
print_list_section |
| 98 |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
| 99 |
print q[">] . htescape ($group_id), q[</a> ]; |
print q[">] . htescape ($group_id), q[</a> ]; |
| 100 |
print q[<input type=hidden name=action value=leave>]; |
print q[<input type=hidden name=action value=leave>]; |
| 101 |
print q[<input type=submit value="Leave this group"></form>]; |
print q[<input type=submit value="]; |
| 102 |
|
print_text ('Leave this group'); |
| 103 |
|
print q["></form>]; |
| 104 |
}); |
}); |
| 105 |
} |
} |
| 106 |
|
|
| 116 |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
| 117 |
print q[">] . htescape ($group_id), q[</a> ]; |
print q[">] . htescape ($group_id), q[</a> ]; |
| 118 |
print q[<input type=hidden name=action value=leave>]; |
print q[<input type=hidden name=action value=leave>]; |
| 119 |
print q[<input type=submit value="Cancel the request"></form>]; |
print q[<input type=submit value="]; |
| 120 |
|
print_text ('Cancel the request'); |
| 121 |
|
print q["></form>]; |
| 122 |
}); |
}); |
| 123 |
} |
} |
| 124 |
|
|
| 134 |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
| 135 |
print q[">] . htescape ($group_id), q[</a> ]; |
print q[">] . htescape ($group_id), q[</a> ]; |
| 136 |
print q[<input type=hidden name=action value=join>]; |
print q[<input type=hidden name=action value=join>]; |
| 137 |
print q[<input type=submit value="Join this group"></form>]; |
print q[<input type=submit value="]; |
| 138 |
|
print_text ('Join this group'); |
| 139 |
|
print q["></form>]; |
| 140 |
}); |
}); |
| 141 |
} |
} |
| 142 |
|
|
| 151 |
print q[" accept-charset=utf-8 method=post>]; |
print q[" accept-charset=utf-8 method=post>]; |
| 152 |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
| 153 |
print q[">] . htescape ($group_id), q[</a>]; |
print q[">] . htescape ($group_id), q[</a>]; |
| 154 |
print q[<input type=hidden name=action value=join>]; |
print q[<input type=hidden name=action value=join> ]; |
| 155 |
print q[<input type=submit value="Join this group"></form>]; |
print q[<input type=submit value="]; |
| 156 |
|
print_text ('Join this group'); |
| 157 |
|
print q["></form>]; |
| 158 |
}); |
}); |
| 159 |
} |
} |
| 160 |
|
|
| 170 |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
print q[<a href="../../groups/].htescape ($group_id) . '/'; |
| 171 |
print q[">] . htescape ($group_id), q[</a> ]; |
print q[">] . htescape ($group_id), q[</a> ]; |
| 172 |
print q[<input type=hidden name=action value=join>]; |
print q[<input type=hidden name=action value=join>]; |
| 173 |
print q[<input type=submit value="Join this group"></form>]; |
print q[<input type=submit value="]; |
| 174 |
|
print_text ('Join this group'); |
| 175 |
|
print q["></form>]; |
| 176 |
}); |
}); |
| 177 |
} |
} |
| 178 |
|
|
| 179 |
print q[</section><section id=props><h2>Properties</h2> |
print q[</section><section id=props><h2>]; |
| 180 |
|
print_text ('Properties'); |
| 181 |
<p><em>Though these properties are only accessible to administrators, |
print q[</h2><p><em>]; |
| 182 |
you are advised not to expose any confidential data.</em>]; |
print_text (q[Don't expose any confidential data.]); |
| 183 |
|
print q[</em>]; |
| 184 |
|
|
| 185 |
print_prop_list ($ac, $user_prop, |
print_prop_list ($ac, $user_prop, |
| 186 |
{ |
{ |
| 200 |
}, |
}, |
| 201 |
); |
); |
| 202 |
|
|
| 203 |
print qq[</section><section id=password> |
print qq[</section><section id=password><h2>]; |
| 204 |
<h2>Password</h2> |
print_text ('Password'); |
| 205 |
|
print q[</h2> |
| 206 |
|
|
| 207 |
<form action=password method=post accept-charset=utf-8> |
<form action=password method=post accept-charset=utf-8> |
| 208 |
|
|
| 209 |
<p>You can change the password. |
<p>]; |
| 210 |
|
print_text ('You can change the password.'); |
| 211 |
|
|
| 212 |
<p><strong>New password</strong>: <input type=password name=user-pass |
print q[<p><strong>]; |
| 213 |
size=10 required pattern=".{4,}" title="Type 4 characters at minimum"> |
print_text ('New password'); |
| 214 |
|
print q[</strong>: <input type=password name=user-pass |
| 215 |
<p><strong>New password</strong> (type again): <input type=password |
size=10 required pattern=".{4,}"> (]; |
| 216 |
|
print_text ('Type 4 characters at minimum'); |
| 217 |
|
print q[) <p><strong>]; |
| 218 |
|
print_text ('New password'); |
| 219 |
|
print q[</strong> (]; |
| 220 |
|
print_text ('type again'); |
| 221 |
|
print q[): <input type=password |
| 222 |
name=user-pass2 size=10 required pattern=".{4,}"> |
name=user-pass2 size=10 required pattern=".{4,}"> |
| 223 |
|
|
| 224 |
<p><input type=submit value=Change> |
<p><input type=submit value="]; |
| 225 |
|
print_text ('Change'); |
| 226 |
|
print q["> |
| 227 |
|
|
| 228 |
</form> |
</form> |
| 229 |
</section> |
</section> |
| 230 |
|
|
| 231 |
<section id=disable-account><h2>Disable account</h2> |
<section id=disable-account><h2>]; |
| 232 |
|
print_text ('Disable account'); |
| 233 |
|
print q[</h2> |
| 234 |
|
|
| 235 |
<form action=disabled method=post accept-charset=utf-8> |
<form action=disabled method=post accept-charset=utf-8> |
| 236 |
|
|
| 237 |
<p><label><input type=checkbox name=action value=enable |
<p><label><input type=checkbox name=action value=enable ]; |
| 238 |
@{[$user_prop->{disabled} ? '' : 'checked']}> Enable this |
print 'checked' unless $user_prop->{disabled}; |
| 239 |
account.</label> |
print q[> ]; |
| 240 |
|
print_text ('Enable this account'); |
| 241 |
<p><strong>Caution!</strong> Once you disable your own account, you |
print q[</label> |
| 242 |
cannot enable your account by yourself. |
|
| 243 |
|
<p><strong>]; |
| 244 |
<p><input type=submit value=Change> |
print_text ('Caution!'); |
| 245 |
|
print q[</strong> ]; |
| 246 |
|
print_text ('Once you disable your own account, you cannot enable your account by yourself.'); |
| 247 |
|
|
| 248 |
</form> |
print q[<p><input type=submit value="]; |
| 249 |
|
print_text ('Change'); |
| 250 |
</section>]; |
|
| 251 |
|
print q["></form></section>]; |
| 252 |
|
|
| 253 |
exit; |
exit; |
| 254 |
} |
} |
| 294 |
} |
} |
| 295 |
} else { |
} else { |
| 296 |
my $e_group_id = htescape ($group_id); |
my $e_group_id = htescape ($group_id); |
| 297 |
print qq[Content-Type: text/html; charset=utf-8 |
print q[Content-Type: text/html; charset=utf-8 |
| 298 |
|
|
| 299 |
<!DOCTYPE HTML> |
<!DOCTYPE HTML> |
| 300 |
<html lang=en> |
<html lang=en class=account-group-misc> |
| 301 |
<title>Joining the group $e_group_id</title> |
<title>]; |
| 302 |
<link rel=stylesheet href="/www/style/html/xhtml"> |
print_text ('Joining the group %s', sub { print $e_group_id }); |
| 303 |
<h1>Joining the group $e_group_id</h1> |
print q[</title> |
| 304 |
|
<link rel=stylesheet href="/admin/style/common"> |
| 305 |
|
<h1>]; |
| 306 |
|
print_text ('Joining the group %s', sub { print $e_group_id }); |
| 307 |
|
print q[</h1> |
| 308 |
|
|
| 309 |
<dl> |
<dl> |
| 310 |
<dt>Description |
<dt>]; |
| 311 |
<dd>@{[$group_prop->{desc}]} |
print_text ('Description'); |
| 312 |
|
print qq[<dd>@{[$group_prop->{desc}]} |
| 313 |
</dl> |
</dl> |
| 314 |
|
|
| 315 |
<form action="@{[htescape ($cgi->request_uri)]}" accept-charset=utf-8 method=post> |
<form action="@{[htescape ($cgi->request_uri)]}" accept-charset=utf-8 method=post> |
| 316 |
<input type=hidden name=action value=join> |
<input type=hidden name=action value=join> |
| 317 |
|
|
| 318 |
<p>Do you really want to join this group? |
<p>]; |
| 319 |
<input type=submit name=agreed value=yes> |
print_text ('Do you really want to join this group?'); |
| 320 |
<input type=button value=no onclick="history.back ()"> |
print q[ <input type=submit name=agreed value="]; |
| 321 |
|
print_text ('Yes'); |
| 322 |
</form>]; |
print q["> <input type=button value="]; |
| 323 |
|
print_text ('No'); |
| 324 |
|
print q[" onclick="history.back ()"></form>]; |
| 325 |
exit; |
exit; |
| 326 |
} |
} |
| 327 |
} elsif ($action eq 'leave') { |
} elsif ($action eq 'leave') { |
| 345 |
} |
} |
| 346 |
|
|
| 347 |
set_user_prop ($user_id, $user_prop); |
set_user_prop ($user_id, $user_prop); |
| 348 |
|
send_mail ("$subject_prefix $group_id membership action", |
| 349 |
|
"Group: $group_id\nUser: $user_id\nAction: $action\nStatus: $status\n"); |
| 350 |
regenerate_htpasswd_and_htgroup (); |
regenerate_htpasswd_and_htgroup (); |
| 351 |
commit (); |
commit (); |
| 352 |
|
|
| 353 |
redirect (303, $status, './'); |
redirect (303, $status, './#groups'); |
| 354 |
exit; |
exit; |
| 355 |
} |
} |
| 356 |
} |
} |
| 390 |
} |
} |
| 391 |
|
|
| 392 |
set_user_prop ($user_id, $user_prop); |
set_user_prop ($user_id, $user_prop); |
| 393 |
|
send_mail ("$subject_prefix $user_id disabledness action", |
| 394 |
|
"User: $user_id\nNew value: @{[$user_prop->{disabled} ? 'disabled' : 'enabled']}\n"); |
| 395 |
regenerate_htpasswd_and_htgroup (); |
regenerate_htpasswd_and_htgroup (); |
| 396 |
commit (); |
commit (); |
| 397 |
|
|
| 441 |
|
|
| 442 |
my $e_group_id = htescape ($group_id); |
my $e_group_id = htescape ($group_id); |
| 443 |
|
|
| 444 |
print qq[Content-Type: text/html; charset=utf-8 |
print q[Content-Type: text/html; charset=utf-8 |
| 445 |
|
|
| 446 |
<!DOCTYPE HTML> |
<!DOCTYPE HTML> |
| 447 |
<html lang=en> |
<html lang=en class=account-group-info> |
| 448 |
<title>Group $e_group_id</title> |
<title>]; |
| 449 |
<link rel=stylesheet href="/www/style/html/xhtml"> |
print_text ('Group %s', sub { print $e_group_id }); |
| 450 |
<h1>Group $e_group_id</h1>]; |
print q[</title> |
| 451 |
|
<link rel=stylesheet href="/admin/style/common">]; |
| 452 |
print q[<section id=props><h2>Properties</h2>]; |
if (defined $group_prop->{favicon_url}) { |
| 453 |
|
print q[<link rel=icon href="], htescape ($group_prop->{favicon_url}); |
| 454 |
|
print q[">]; |
| 455 |
|
} |
| 456 |
|
print q[<h1>]; |
| 457 |
|
if (defined $group_prop->{favicon_url}) { |
| 458 |
|
print q[<img src="], htescape ($group_prop->{favicon_url}); |
| 459 |
|
print q[" alt="">]; |
| 460 |
|
} |
| 461 |
|
print_text ('Group %s', sub { print $e_group_id }); |
| 462 |
|
print q[</h1>]; |
| 463 |
|
|
| 464 |
|
print q[<section id=props><h2>]; |
| 465 |
|
print_text ('Properties'); |
| 466 |
|
print q[</h2>]; |
| 467 |
|
|
| 468 |
print_prop_list ($ac, $group_prop, |
print_prop_list ($ac, $group_prop, |
| 469 |
{ |
{ |
| 477 |
label => 'Administrative group', |
label => 'Administrative group', |
| 478 |
field_type => 'text', |
field_type => 'text', |
| 479 |
}, |
}, |
| 480 |
|
{ |
| 481 |
|
name => 'favicon_url', |
| 482 |
|
label => 'Group icon URL', |
| 483 |
|
field_type => 'url', |
| 484 |
|
}, |
| 485 |
); |
); |
| 486 |
|
|
| 487 |
print q[</section><section id=members><h2>Members</h2>]; |
print q[</section><section id=members><h2>]; |
| 488 |
|
print_text ('Members'); |
| 489 |
|
print q[</h2>]; |
| 490 |
|
|
| 491 |
if ($ac->{read_group_member_list}) { |
if ($ac->{read_group_member_list}) { |
| 492 |
my @members; |
my @members; |
| 512 |
print_item => sub { |
print_item => sub { |
| 513 |
my $user_id = shift; |
my $user_id = shift; |
| 514 |
print q[<form action="user.] . htescape ($user_id); |
print q[<form action="user.] . htescape ($user_id); |
| 515 |
print q[" accept-charset=utf-8 method=post>]; |
print q[" accept-charset=utf-8 method=post>]; |
| 516 |
print qq[<a href="../../users/@{[htescape ($user_id)]}/">]; |
print qq[<a href="../../users/@{[htescape ($user_id)]}/">]; |
| 517 |
print '' . htescape ($user_id) . q[</a> ]; |
print '' . htescape ($user_id) . q[</a> ]; |
| 518 |
print q[<input type=hidden name=action value=unapprove>]; |
print q[<input type=hidden name=action value=unapprove>]; |
| 519 |
print q[<input type=submit value="Kick"></form>]; |
print q[<input type=submit value="]; |
| 520 |
|
print_text ('Kick'); |
| 521 |
|
print q["></form>]; |
| 522 |
}); |
}); |
| 523 |
} |
} |
| 524 |
|
|
| 534 |
print qq[<a href="../../users/@{[htescape ($user_id)]}/">]; |
print qq[<a href="../../users/@{[htescape ($user_id)]}/">]; |
| 535 |
print '' . htescape ($user_id) . q[</a> ]; |
print '' . htescape ($user_id) . q[</a> ]; |
| 536 |
print q[<input type=hidden name=action value=approve>]; |
print q[<input type=hidden name=action value=approve>]; |
| 537 |
print q[<input type=submit value=Approve></form>]; |
print q[<input type=submit value="]; |
| 538 |
|
print_text ('Approve'); |
| 539 |
|
print q["></form>]; |
| 540 |
}); |
}); |
| 541 |
} |
} |
| 542 |
|
|
| 552 |
print qq[<a href="../../users/@{[htescape ($user_id)]}/">]; |
print qq[<a href="../../users/@{[htescape ($user_id)]}/">]; |
| 553 |
print '' . htescape ($user_id), q[</a> ]; |
print '' . htescape ($user_id), q[</a> ]; |
| 554 |
print q[<input type=hidden name=action value=unapprove>]; |
print q[<input type=hidden name=action value=unapprove>]; |
| 555 |
print q[<input type=submit value="Cancel invitation"></form>]; |
print q[<input type=submit value="]; |
| 556 |
|
print_text ('Cancel invitation'); |
| 557 |
|
print q["></form>]; |
| 558 |
}); |
}); |
| 559 |
} |
} |
| 560 |
} |
} |
| 561 |
|
|
| 562 |
my $join_condition = $group_prop->{join_condition}; |
my $join_condition = $group_prop->{join_condition}; |
| 563 |
my $disabled = $ac->{write} ? '' : 'disabled'; |
my $disabled = $ac->{write} ? '' : 'disabled'; |
| 564 |
print qq[<section id=member-approval> |
print qq[<section id=member-approval><h3>]; |
| 565 |
<h3>Member approval policy</h3> |
print_text ('Member approval policy'); |
| 566 |
|
print qq[</h3> |
| 567 |
|
|
| 568 |
<form action=join-condition method=post accept-charset=utf-8> |
<form action=join-condition method=post accept-charset=utf-8> |
| 569 |
|
|
| 570 |
<p><label><input type=radio name=condition value=invitation $disabled |
<p><label><input type=radio name=condition value=invitation $disabled |
| 571 |
@{[$join_condition->{invitation} ? 'checked' : '']}> A user who is |
@{[$join_condition->{invitation} ? 'checked' : '']}> ]; |
| 572 |
invited by an administrator of the group can join the group.</label> |
print_text ('A user who is invited by an administrator of the group can join the group.'); |
| 573 |
|
print qq[</label> |
| 574 |
|
|
| 575 |
<p><label><input type=radio name=condition value=approval $disabled |
<p><label><input type=radio name=condition value=approval $disabled |
| 576 |
@{[(not $join_condition->{invitation} and $join_condition->{approval}) |
@{[(not $join_condition->{invitation} and $join_condition->{approval}) |
| 577 |
? 'checked' : '']}> A user who is invited or approved by an |
? 'checked' : '']}> ]; |
| 578 |
administrator of the group can join the group.</label> |
print_text ('A user who is invited or approved by an administrator of the group can join the group.'); |
| 579 |
|
print qq[</label> |
| 580 |
|
|
| 581 |
<p><label><input type=radio name=condition value=anyone $disabled |
<p><label><input type=radio name=condition value=anyone $disabled |
| 582 |
@{[(not $join_condition->{invitation} and not |
@{[(not $join_condition->{invitation} and not |
| 583 |
$join_condition->{approval}) ? 'checked' : '']}> Any user can join |
$join_condition->{approval}) ? 'checked' : '']}> ]; |
| 584 |
the group.</label> |
print_text ('Any user can join the group.'); |
| 585 |
|
print q[</label>]; |
| 586 |
@{[$disabled ? '' : '<p><input type=submit value=Change>']} |
unless ($disabled) { |
| 587 |
|
print q[<p><input type=submit value="]; |
| 588 |
</form> |
print_text ('Change'); |
| 589 |
|
print q[">]; |
| 590 |
</section>]; |
} |
| 591 |
|
print q[</form></section>]; |
| 592 |
|
|
| 593 |
if ($ac->{write}) { |
if ($ac->{write}) { |
| 594 |
print q[<section id=member-invitation> |
print q[<section id=member-invitation><h3>]; |
| 595 |
<h3>Invite a user</h3> |
print_text ('Invite a user'); |
| 596 |
|
print q[</h3> |
| 597 |
|
|
| 598 |
<form action=invite-user accept-charset=utf-8 method=post> |
<form action=invite-user accept-charset=utf-8 method=post> |
| 599 |
|
|
| 600 |
<p><strong>User id</strong>: <input type=text name=user-id |
<p><strong>]; |
| 601 |
|
print_text ('User id'); |
| 602 |
|
print q[</strong>: <input type=text name=user-id |
| 603 |
maxlength=20 size=10 required pattern="[0-9a-z-]{4,20}"> |
maxlength=20 size=10 required pattern="[0-9a-z-]{4,20}"> |
| 604 |
|
|
| 605 |
<p><input type=submit value=Invite> |
<p><input type=submit value="]; |
| 606 |
|
print_text ('Invite'); |
| 607 |
</form> |
print q["></form></section>]; |
|
|
|
|
</section>]; |
|
| 608 |
} |
} |
| 609 |
|
|
| 610 |
print q[</section>]; |
print q[</section>]; |
| 650 |
|
|
| 651 |
my $prop_name = $cgi->get_parameter ('name'); |
my $prop_name = $cgi->get_parameter ('name'); |
| 652 |
if (defined $prop_name and |
if (defined $prop_name and |
| 653 |
{desc => 1, admin_group => 1}->{$prop_name}) { |
{desc => 1, admin_group => 1, |
| 654 |
|
favicon_url => 1}->{$prop_name}) { |
| 655 |
$group_prop->{$prop_name} = $cgi->get_parameter ('value'); |
$group_prop->{$prop_name} = $cgi->get_parameter ('value'); |
| 656 |
|
|
| 657 |
set_group_prop ($group_id, $group_prop); |
set_group_prop ($group_id, $group_prop); |
| 720 |
} |
} |
| 721 |
|
|
| 722 |
set_user_prop ($user_id, $user_prop); |
set_user_prop ($user_id, $user_prop); |
| 723 |
|
send_mail ("$subject_prefix $group_id membership action", |
| 724 |
|
"Group: $group_id\nUser: $user_id\nAction: $action\nStatus: $status\n"); |
| 725 |
regenerate_htpasswd_and_htgroup (); |
regenerate_htpasswd_and_htgroup (); |
| 726 |
commit (); |
commit (); |
| 727 |
|
|
| 728 |
print "Status: 204 $status\n\n"; |
#print "Status: 204 $status\n\n"; |
| 729 |
|
redirect (303, $status, './#members'); |
| 730 |
exit; |
exit; |
| 731 |
} |
} |
| 732 |
} |
} |
| 741 |
my $group_id = $cgi->get_parameter ('group-id'); |
my $group_id = $cgi->get_parameter ('group-id'); |
| 742 |
|
|
| 743 |
if ($group_id !~ /\A[0-9a-z-]{4,20}\z/) { |
if ($group_id !~ /\A[0-9a-z-]{4,20}\z/) { |
| 744 |
print_error (400, qq[Group id "$group_id" is invalid; use characters [0-9a-z-]{4,20}]); |
print_error (400, |
| 745 |
|
q[Group id %s is invalid; use characters [0-9a-z-]{4,20}], |
| 746 |
|
$group_id); |
| 747 |
exit; |
exit; |
| 748 |
} |
} |
| 749 |
|
|
| 750 |
if (get_group_prop ($group_id)) { |
if (get_group_prop ($group_id)) { |
| 751 |
print_error (400, qq[Group id "$group_id" is already used]); |
print_error (400, q[Group id %s is already used], $group_id); |
| 752 |
exit; |
exit; |
| 753 |
} |
} |
| 754 |
|
|
| 755 |
my $group_prop = {id => $group_id}; |
my $group_prop = {id => $group_id}; |
| 756 |
set_group_prop ($group_id, $group_prop); |
set_group_prop ($group_id, $group_prop); |
| 757 |
|
|
| 758 |
|
send_mail ("$subject_prefix Group $group_id created", |
| 759 |
|
"Group: $group_id\nStatus: Group registered\n"); |
| 760 |
commit (); |
commit (); |
| 761 |
|
|
| 762 |
my $group_url = get_absolute_url ('groups/' . $group_id . '/'); |
my $group_url = get_absolute_url ('groups/' . $group_id . '/'); |
| 766 |
Content-Type: text/html; charset=utf-8 |
Content-Type: text/html; charset=utf-8 |
| 767 |
|
|
| 768 |
<!DOCTYPE HTML> |
<!DOCTYPE HTML> |
| 769 |
<html lang=en> |
<html lang=en class=account-group-misc> |
| 770 |
<title>Group "@{[htescape ($group_id)]}" registered</title> |
<title>]; |
| 771 |
<link rel=stylesheet href="/www/style/html/xhtml"> |
print_text ('Group %s registered', sub { print '', htescape ($group_id) }); |
| 772 |
<h1>Group "@{[htescape ($group_id)]}" registered</h1> |
print q[</title> |
| 773 |
<p>The new group is created successfully. |
<link rel=stylesheet href="/admin/style/common"> |
| 774 |
<p>See <a href="@{[htescape ($group_url)]}">the group information page</a>.]; |
<h1>]; |
| 775 |
|
print_text ('Group %s registered', sub { print '', htescape ($group_id) }); |
| 776 |
|
print q[</h1><p>]; |
| 777 |
|
print_text ('The new group is created successfully.'); |
| 778 |
|
print q[<p>]; |
| 779 |
|
print_text ('See %s.', sub { |
| 780 |
|
print qq[<a href="@{[htescape ($group_url)]}">]; |
| 781 |
|
print_text ('the group information page'); |
| 782 |
|
print qq[</a>]; |
| 783 |
|
}); |
| 784 |
exit; |
exit; |
| 785 |
} else { |
} else { |
| 786 |
binmode STDOUT, ":encoding(utf-8)"; |
binmode STDOUT, ":encoding(utf-8)"; |
| 787 |
print qq[Content-Type: text/html; charset=utf-8 |
print q[Content-Type: text/html; charset=utf-8 |
| 788 |
|
|
| 789 |
<!DOCTYPE HTML> |
<!DOCTYPE HTML> |
| 790 |
<html lang=en> |
<html lang=en class=account-group-misc> |
| 791 |
<title>Create a new group</title> |
<title>]; |
| 792 |
<link rel=stylesheet href="/www/style/html/xhtml"> |
print_text ('Create a new group'); |
| 793 |
<h1>Create a new group</h1> |
print q[</title> |
| 794 |
|
<link rel=stylesheet href="/admin/style/common"> |
| 795 |
|
<h1>]; |
| 796 |
|
print_text ('Create a new group'); |
| 797 |
|
print q[</h1> |
| 798 |
|
|
| 799 |
<form action=new-group accept-charset=utf-8 method=post> |
<form action=new-group accept-charset=utf-8 method=post> |
| 800 |
|
|
| 801 |
<p><strong>Group id</strong>: <input type=text name=group-id |
<p><strong>]; |
| 802 |
maxlength=20 size=10 required pattern="[0-9a-z-]{4,20}" |
print_text ('Group id'); |
| 803 |
title="Use a string of characters 'a'..'z', '0'..'9', and '-' with length 4..10 (inclusive)"> |
print q[</strong>: <input type=text name=group-id |
| 804 |
|
maxlength=20 size=10 required pattern="[0-9a-z-]{4,20}"> (]; |
| 805 |
<p><input type=submit value=Create> |
print_text ('Use [0-9a-z-]{4,20}.'); |
| 806 |
|
print q[) <p><input type=submit value="]; |
| 807 |
</form>]; |
print_text ('Create'); |
| 808 |
|
print q["></form>]; |
| 809 |
exit; |
exit; |
| 810 |
} |
} |
| 811 |
} elsif (@path == 1 and $path[0] eq '') { |
} elsif (@path == 1 and $path[0] eq '') { |
| 827 |
$opt{level} ||= 3; |
$opt{level} ||= 3; |
| 828 |
|
|
| 829 |
print q[<section id="] . htescape ($opt{id}); |
print q[<section id="] . htescape ($opt{id}); |
| 830 |
print q["><h] . $opt{level} . q[>] . htescape ($opt{title}); |
print q["><h] . $opt{level} . q[>]; |
| 831 |
|
print_text ($opt{title}); |
| 832 |
print q[</h] . $opt{level} . q[><ul>]; |
print q[</h] . $opt{level} . q[><ul>]; |
| 833 |
for my $item (sort {$a cmp $b} @{$opt{items}}) { |
for my $item (sort {$a cmp $b} @{$opt{items}}) { |
| 834 |
print q[<li>]; |
print q[<li>]; |
| 843 |
|
|
| 844 |
for my $prop (@_) { |
for my $prop (@_) { |
| 845 |
if ($prop->{public}) { |
if ($prop->{public}) { |
| 846 |
print q[<p><strong>], htescape ($prop->{label}), q[</strong>: ]; |
print q[<p><strong>]; |
| 847 |
|
print_text ($prop->{label}); |
| 848 |
|
print q[</strong>: ]; |
| 849 |
print $prop_hash->{$prop->{name}}; |
print $prop_hash->{$prop->{name}}; |
| 850 |
} |
} |
| 851 |
|
|
| 853 |
print q[<form action="prop" accept-charset=utf-8 method=post>]; |
print q[<form action="prop" accept-charset=utf-8 method=post>]; |
| 854 |
print q[<input type=hidden name=name value="], htescape ($prop->{name}), q[">]; |
print q[<input type=hidden name=name value="], htescape ($prop->{name}), q[">]; |
| 855 |
if ($prop->{field_type} eq 'textarea') { |
if ($prop->{field_type} eq 'textarea') { |
| 856 |
print q[<p><label><strong>], htescape ($prop->{label}); |
print q[<p><label><strong>]; |
| 857 |
|
print_text ($prop->{label}); |
| 858 |
print q[</strong>: <br><textarea name="value"]; |
print q[</strong>: <br><textarea name="value"]; |
| 859 |
print q[>], htescape ($prop_hash->{$prop->{name}} // ''); |
print q[>], htescape ($prop_hash->{$prop->{name}} // ''); |
| 860 |
print q[</textarea></label>]; |
print q[</textarea></label>]; |
| 861 |
print q[<p><input type=submit value=Save>]; |
print q[<p><input type=submit value="]; |
| 862 |
|
print_text ('Save'); |
| 863 |
|
print q[">]; |
| 864 |
} else { |
} else { |
| 865 |
print q[<p><label><strong>], htescape ($prop->{label}); |
print q[<p><label><strong>]; |
| 866 |
|
print_text ($prop->{label}); |
| 867 |
print q[</strong>: <input type="] . $prop->{field_type}; |
print q[</strong>: <input type="] . $prop->{field_type}; |
| 868 |
print q[" name="value" ]; |
print q[" name="value" ]; |
| 869 |
print q[value="], htescape ($prop_hash->{$prop->{name}} // ''); |
print q[value="], htescape ($prop_hash->{$prop->{name}} // ''); |
| 870 |
print q["></label> ]; |
print q["></label> ]; |
| 871 |
print q[<input type=submit value=Save>]; |
print q[<input type=submit value="]; |
| 872 |
|
print_text ('Save'); |
| 873 |
|
print q[">]; |
| 874 |
} |
} |
| 875 |
print q[</form>]; |
print q[</form>]; |
| 876 |
} |
} |
| 936 |
sub forbidden () { |
sub forbidden () { |
| 937 |
my $user = $cgi->remote_user; |
my $user = $cgi->remote_user; |
| 938 |
if (defined $user) { |
if (defined $user) { |
| 939 |
print_error (403, q[Forbidden (you've logged in as ] . $user . ')'); |
print_error (403, q[Forbidden (you've logged in as %s)], $user); |
| 940 |
} else { |
} else { |
| 941 |
print_error (403, 'Forbidden'); |
print_error (403, 'Forbidden'); |
| 942 |
} |
} |