X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=licom.cgi;h=c26ff3f289395856983e52570b8922f4851ac8ba;hb=e519cdc67359146f3946c80e5b26c8cc83449f4e;hp=5abb2e6f09d430ff122519fa3bfb99825faaf5e0;hpb=fb2741ec9a3da3376994f3f70f8d0c17bbe70931;p=licom.git diff --git a/licom.cgi b/licom.cgi index 5abb2e6..c26ff3f 100755 --- a/licom.cgi +++ b/licom.cgi @@ -9,13 +9,14 @@ use CGI::Carp (qw(fatalsToBrowser)); use URI::Escape; use Data::Dumper; -use LiCoM::Config (qw(get_config)); -use LiCoM::Person; +use LiCoM::Config (qw(get_config set_config read_config)); +use LiCoM::Connection (); +use LiCoM::Group (); +use LiCoM::Person (); our $Debug = 0; -our $Config = {}; -our @MultiFields = (qw(address homephone cellphone officephone fax mail uri group)); +our @MultiFields = (qw(address homephone cellphone officephone fax mail uri)); our %FieldNames = ( @@ -44,27 +45,30 @@ our %Actions = save => [\&html_start, \&action_save, \&html_end], search => [\&html_start, \&action_search, \&html_end], 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 ); -$Config = get_config (); +read_config (); # make sure AuthLDAPRemoteUserIsDN is enabled. die unless ($ENV{'REMOTE_USER'}); -$Config->{'base_dn'} = $ENV{'REMOTE_USER'}; +set_config ('base_dn', $ENV{'REMOTE_USER'}); -die unless (defined ($Config->{'uri'}) and defined ($Config->{'base_dn'}) - and defined ($Config->{'bind_dn'}) and defined ($Config->{'password'})); +die unless (defined (get_config ('uri')) + and defined (get_config ('base_dn')) + and defined (get_config ('bind_dn')) + and defined (get_config ('password'))); -LiCoM::Person->connect +LiCoM::Connection->connect ( - uri => $Config->{'uri'}, - base_dn => $Config->{'base_dn'}, - bind_dn => $Config->{'bind_dn'}, - password => $Config->{'password'} + uri => get_config ('uri'), + bind_dn => get_config ('bind_dn'), + password => get_config ('password') ) or die; -our ($UserCN, $UserID) = LiCoM::Person->get_user ($Config->{'base_dn'}); +our ($UserCN, $UserID) = LiCoM::Person->get_user ($ENV{'REMOTE_USER'}); if (!$UserID and $Action ne 'save') { @@ -93,7 +97,7 @@ elsif (ref ($Actions{$Action}) eq 'ARRAY') } } -LiCoM::Person->disconnect (); +LiCoM::Connection->disconnect (); exit (0); @@ -105,83 +109,60 @@ sub action_browse $group = shift if (@_); $group ||= ''; - my @all; - if ($group) - { - @all = LiCoM::Person->search ([[group => $group]]); - } - else - { - @all = LiCoM::Person->search (); - } - if (!$group) { - my @nogroup = (); - my %groups = (); - for (@all) - { - my $person = $_; - my @g = $person->get ('group'); - - $groups{$_} = (defined ($groups{$_}) ? $groups{$_} + 1 : 1) for (@g); - - push (@nogroup, $person) if (!@g); - } - @all = @nogroup; + my @groups = LiCoM::Group->all (); print qq(\t\t

Contact Groups

\n\t\t\n\n); - } - - if ($group) - { - print qq(\t\t

Contact Group "$group"

\n); + print < + +EOF } else { - print qq(\t\t

Contacts without a group

\n); - } - - print qq(\t\t\n\n); + my $group_obj = LiCoM::Group->load ($group); + my $group_esc = uri_escape ($group_obj->name ()); + my @member_names = $group_obj->get_members (); + + print qq(\t\t

Contact Group "$group"

\n), + qq(\t\t