verify => [\&html_start, \&action_verify, \&html_end],
delete => [\&html_start, \&action_ask_del, \&html_end],
expunge => [\&html_start, \&action_do_del, \&html_end],
- vcard => \&action_vcard
+ vcard => \&action_vcard,
+ edit_group => [\&html_start, \&action_edit_group, \&html_end],
+ save_group => [\&html_start, \&action_save_group, \&html_end]
);
read_config ();
if (!defined ($Actions{$Action}))
{
- die;
+ die ("No such action: $Action");
}
if (ref ($Actions{$Action}) eq 'CODE')
{
my @groups = LiCoM::Group->all ();
- print qq(\t\t<h2>Contact Groups</h2>\n\t\t<ul class="groups">\n);
+ print qq(\t\t<h2>Contact groups</h2>\n\t\t<ul class="groups">\n);
for (@groups)
{
my $group = $_;
my @members = $group->get_members ();
my $members = scalar (@members);
my $group_name = $group->name ();
- my $group_esc = uri_escape ($group_name);
+ my $group_uri = uri_escape ($group_name);
my $desc = $group->description ();
- print qq#\t\t\t<li><a href="$MySelf?action=browse&group=$group_esc">#,
+ print qq#\t\t\t<li><a href="$MySelf?action=browse&group=$group_uri">#,
encode_entities ($group_name),
qq#</a> ($members Member#, ($members == 1 ? ')' : 's)');
print qq(<br />\n\t\t\t\t<span class="description">),
}
else
{
- my $group_obj = LiCoM::Group->load ($group);
- my $group_esc = uri_escape ($group_obj->name ());
+ my $group_obj = LiCoM::Group->load ($group);
+ my $group_uri = uri_escape ($group_obj->name ());
+ my $group_html = encode_entities ($group_obj->name ());
my @member_names = $group_obj->get_members ();
+ my $desc = $group_obj->description ();
+ my $desc_html = encode_entities ($desc || '');
- print qq(\t\t<h2>Contact Group "$group"</h2>\n),
- qq(\t\t<ul class="results">\n);
+ print qq(\t\t<h2>Contact group "$group_html"</h2>\n);
+ print qq(\t\t<div>$desc_html</div>\n) if ($desc);
+ print qq(\t\t<ul class="results">\n);
for (sort (@member_names))
{
my $cn = $_;
- my $cn_esc = uri_escape ($cn);
+ my $cn_uri = uri_escape ($cn);
+ my $cn_html = encode_entities ($cn);
- print qq(\t\t\t<li><a href="$MySelf?action=detail&cn=$cn_esc">$cn</a></li>\n);
+ print qq(\t\t\t<li><a href="$MySelf?action=detail&cn=$cn_uri">$cn_html</a></li>\n);
}
print <<EOF;
</ul>
<div class="menu">
- [<a href="$MySelf?action=list&group=$group_esc">List</a>]
+ [<a href="$MySelf?action=list&group=$group_uri">List</a>]
[<a href="$MySelf?action=browse">Back</a>]
- [Edit]
+ [<a href="$MySelf?action=edit_group&group=$group_uri">Edit</a>]
</div>
EOF
}
action_browse ();
}
+sub action_edit_group
+{
+ my $group_name = param ('group') or die;
+
+ my $group_name_html = encode_entities ($group_name);
+
+ my $group_obj = LiCoM::Group->load ($group_name);
+
+ if (!$group_obj)
+ {
+ print qq(\t<div class="error">Group "$group_name_html" does not exist or could not be loaded.</div>\n);
+ return;
+ }
+
+ $group_name_html = encode_entities ($group_obj->name ());
+
+ my $desc_html = encode_entities ($group_obj->description () || '');
+
+ print <<HTML;
+ <h2>Edit contact group "$group_name_html"</h2>
+ <form action="$MySelf" method="post">
+ <input type="hidden" name="action" value="save_group" />
+ <input type="hidden" name="group" value="$group_name_html" />
+ <table>
+ <tr>
+ <th>Group Name</th>
+ <td>$group_name_html</td>
+ </tr>
+ <tr>
+ <th>Description</th>
+ <td><input type="text" name="description" value="$desc_html" /></td>
+ </tr>
+ <tr>
+ <th colspan="2"><input type="submit" name="button" value="Save" /></th>
+ </tr>
+ </table>
+ </form>
+HTML
+}
+
+sub action_save_group
+{
+ my $group_name = param ('group') or die;
+
+ my $group_name_html = encode_entities ($group_name);
+
+ my $group_obj = LiCoM::Group->load ($group_name);
+
+ if (!$group_obj)
+ {
+ print qq(\t<div class="error">Group "$group_name_html" does not exist or could not be loaded.</div>\n);
+ return;
+ }
+
+ my $desc = param ('description');
+ $group_obj->description ($desc);
+
+ action_browse ();
+ return;
+}
+
sub html_start
{
my $title = shift;