@@ -503,11 +518,11 @@ EOF
EOF
if ($UserID)
{
- print qq(\t\t\t\t | \n);
+ print qq(\t\t\t\t | \n);
}
else
{
- print qq(\t\t\t\t$firstname | \n);
+ print qq(\t\t\t\t$firstname_html | \n);
}
print "\t\t\t\n";
@@ -593,7 +608,7 @@ EOF
sub action_save
{
- my $cn = $UserID ? param ('cn') : $UserCN;
+ my $cn = $UserID ? param_utf8 ('cn') : $UserCN;
if (verify_fields ())
{
@@ -609,7 +624,7 @@ sub action_save
die unless ($UserID);
- my $button = lc (param ('button'));
+ my $button = lc (param_utf8 ('button'));
$button ||= 'save';
if ($button eq 'cancel')
@@ -618,15 +633,15 @@ sub action_save
return;
}
- if (!param ('lastname') or !param ('firstname'))
+ if (!param_utf8 ('lastname') or !param_utf8 ('firstname'))
{
print qq(\tYou have to give both, first and lastname, to identify this record.
\n);
action_edit (cn => '');
return;
}
- my $lastname = param ('lastname');
- my $firstname = param ('firstname');
+ my $lastname = param_utf8 ('lastname');
+ my $firstname = param_utf8 ('firstname');
my $contacts = get_contacts ();
@@ -640,7 +655,7 @@ sub action_save
$cn = $person->name ();
- for (param ('group'))
+ for (param_utf8 ('group'))
{
my $group_name = $_;
my $group = LiCoM::Group->load ($group_name);
@@ -656,10 +671,10 @@ sub action_save
}
}
- if (param ('newgroup'))
+ if (param_utf8 ('newgroup'))
{
# FIXME add error handling
- my $group_name = param ('newgroup');
+ my $group_name = param_utf8 ('newgroup');
LiCoM::Group->create ($group_name, '', $cn);
}
@@ -675,12 +690,12 @@ sub action_save
sub action_update
{
- my $cn = $UserID ? param ('cn') : $UserCN;
- my $person = LiCoM::Person->load ($cn);
+ my $cn = $UserID ? param_utf8 ('cn') : $UserCN;
- die unless ($person);
+ my $person = LiCoM::Person->load ($cn);
+ die ("Unable to load CN `$cn'") unless ($person);
- my $button = lc (param ('button'));
+ my $button = lc (param_utf8 ('button'));
$button ||= 'save';
if ($UserID and $button eq 'cancel')
@@ -691,17 +706,39 @@ sub action_update
if ($UserID)
{
- my $lastname = param ('lastname');
- my $firstname = param ('firstname');
+ my $lastname = param_utf8 ('lastname');
+ my $firstname = param_utf8 ('firstname');
+
+ my $old_cn = $person->name ();
+
+ print <
+ \$lastname = $lastname
+ \$firstname = $firstname
+ \$old_cn = $old_cn
+
+HTML
$person->lastname ($lastname) if ($lastname and $lastname ne $person->lastname ());
$person->firstname ($firstname) if ($firstname and $firstname ne $person->firstname ());
$cn = $person->name ();
- # FIXME Fix groups:
- # Each group is one entry of type (objectClass=groupOfNames)
- # with one or more `member' attributes. These attributes are
- # the `dn' (distinguished name) of the member entries.
+
+ # Change the cn's saved in the groups
+ if ($old_cn ne $cn)
+ {
+ my @groups = LiCoM::Group->load_by_member ($old_cn);
+ for (@groups)
+ {
+ # ->del_members automatically deleted the
+ # group, if no more members exist. So this
+ # order is important.
+ print "\$cn = " . encode_entities ($cn) . "; "
+ . "\$old_cn = " . encode_entities ($old_cn) . ";
\n";
+ $_->add_members ($cn);
+ $_->del_members ($old_cn);
+ }
+ } # if ($old_cn ne $cn)
}
my $contacts = get_contacts ();
@@ -723,36 +760,49 @@ sub action_update
}
}
- my %changed_groups = map { $_ => 1 } (param ('group'));
- my @current_groups = LiCoM::Group->load_by_member ($cn);
-
- for (@current_groups)
+ # only `authorized' users may see and change groups
+ if ($UserID)
{
- my $group_obj = $_;
- my $group_name = $group_obj->name ();
+ my %changed_groups = map { $_ => 1 } (param_utf8 ('group'));
+ my @current_groups = LiCoM::Group->load_by_member ($cn);
- if (!defined ($changed_groups{$group_name}))
+ for (@current_groups)
{
- $group_obj->del_members ($cn);
+ my $group_obj = $_;
+ my $group_name = $group_obj->name ();
+
+ if (!defined ($changed_groups{$group_name}))
+ {
+ $group_obj->del_members ($cn);
+ }
+ else
+ {
+ delete ($changed_groups{$group_name});
+ }
}
- else
+ for (keys %changed_groups)
{
- delete ($changed_groups{$group_name});
+ my $group_name = $_;
+ my $group_obj = LiCoM::Group->load ($group_name) or die;
+
+ $group_obj->add_members ($cn);
}
- }
- for (keys %changed_groups)
- {
- my $group_name = $_;
- my $group_obj = LiCoM::Group->load ($group_name) or die;
- $group_obj->add_members ($cn);
+ if (param_utf8 ('newgroup'))
+ {
+ # FIXME add error handling
+ my $group_name = param_utf8 ('newgroup');
+ LiCoM::Group->create ($group_name, '', $cn);
+ }
}
- if (param ('newgroup'))
+ if (!$UserID)
{
- # FIXME add error handling
- my $group_name = param ('newgroup');
- LiCoM::Group->create ($group_name, '', $cn);
+ print <Your changes have been saved.
+ Thank you very much for taking the time to keep this record up to date.
+
+HTML
}
if ($button eq 'apply' or !$UserID)
@@ -767,7 +817,7 @@ sub action_update
sub action_vcard
{
- my $cn = param ('cn');
+ my $cn = param_utf8 ('cn');
$cn = shift if (@_);
die unless ($cn);
@@ -787,7 +837,7 @@ sub action_vcard
my $sn = $person->lastname ();
my $gn = $person->firstname ();
- my $cn_esc = uri_escape ($cn);
+ my $cn_esc = uri_escape_utf8 ($cn);
print <get ('mail');
if (!$owner_mail)
{
- my $cn_uri = uri_escape ($UserCN);
+ my $cn_uri = uri_escape_utf8 ($UserCN);
print qq(\t\tYou have no email set in your own profile.
Edit it now!
\n);
return (0);
}
@@ -933,13 +983,13 @@ EOM
sub action_ask_del
{
- my $cn = param ('cn');
+ my $cn = param_utf8 ('cn');
$cn or die;
my $person = LiCoM::Person->load ($cn);
$person or die;
- my $cn_uri = uri_escape ($cn);
+ my $cn_uri = uri_escape_utf8 ($cn);
my $cn_html = encode_entities ($cn);
print <load ($group_name);
+
+ if (!$group_obj)
+ {
+ print qq(\tGroup "$group_name_html" does not exist or could not be loaded.
\n);
+ return;
+ }
+
+ $group_name_html = encode_entities ($group_obj->name ());
+
+ my $desc_html = encode_entities ($group_obj->description () || '');
+
+ print <Edit contact group "$group_name_html"
+
+HTML
+}
+
+sub action_save_group
+{
+ my $group_name = param_utf8 ('group') or die;
+
+ my $group_name_html = encode_entities ($group_name);
+
+ my $group_obj = LiCoM::Group->load ($group_name);
+
+ if (!$group_obj)
+ {
+ print qq(\tGroup "$group_name_html" does not exist or could not be loaded.
\n);
+ return;
+ }
+
+ my $desc = param_utf8 ('description');
+ $group_obj->description ($desc);
+
+ action_browse ();
+ return;
+}
+
sub html_start
{
my $title = shift;
@@ -1103,6 +1214,7 @@ Content-Type: text/html; charset=UTF-8
table.list
{
width: 100%;
+ border: 2px solid #d0d0d0;
}
table.list td
@@ -1113,18 +1225,23 @@ Content-Type: text/html; charset=UTF-8
td
{
color: black;
- background-color: #cccccc;
+ background-color: #e8e8e8;
vertical-align: top;
}
th
{
color: black;
- background-color: #999999;
+ background-color: #d0d0d0;
padding: 0.3ex;
text-align: left;
vertical-align: top;
}
+
+ ul.groups li
+ {
+ margin-top: 0.5ex;
+ }
}
\@media print
@@ -1198,20 +1315,20 @@ EOF
if ($UserID)
{
- my $search = param ('search') || '';
+ my $search = param_utf8 ('search') || '';
$search = encode_entities ($search);
print <