X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=licom.cgi;h=cd0269060ba760153c82b332078d8fd86fcdd44c;hb=561ad6221dd53bd1c4295073e67a6ad41b0cbf7b;hp=4af14ad7b37a84e185cf24b420d28fc7502891fd;hpb=0b46496344123e462825844a676997b77823b365;p=licom.git diff --git a/licom.cgi b/licom.cgi index 4af14ad..cd02690 100755 --- a/licom.cgi +++ b/licom.cgi @@ -1,5 +1,21 @@ #!/usr/bin/perl +# LiCoM - Lightweight contact manager +# Copyright (c) 2005-2006 Florian octo Forster +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; only version 2 of the License is applicable. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; if not, write to the Free Software # Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + use strict; use warnings; use lib (qw(lib)); @@ -7,14 +23,16 @@ use lib (qw(lib)); use CGI (':cgi'); use CGI::Carp (qw(fatalsToBrowser)); use URI::Escape; -use Data::Dumper; +use HTML::Entities (qw(encode_entities)); -use 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 = ( @@ -43,24 +61,32 @@ our %Actions = save => [\&html_start, \&action_save, \&html_end], search => [\&html_start, \&action_search, \&html_end], verify => [\&html_start, \&action_verify, \&html_end], - vcard => \&action_vcard + delete => [\&html_start, \&action_ask_del, \&html_end], + expunge => [\&html_start, \&action_do_del, \&html_end], + vcard => \&action_vcard, + edit_group => [\&html_start, \&action_edit_group, \&html_end], + save_group => [\&html_start, \&action_save_group, \&html_end] ); 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 (get_config ('uri')) + and defined (get_config ('base_dn')) + and defined (get_config ('bind_dn')) + and defined (get_config ('password'))); -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) = Person->get_user ($Config{'base_dn'}); +our ($UserCN, $UserID) = LiCoM::Person->get_user ($ENV{'REMOTE_USER'}); if (!$UserID and $Action ne 'save') { @@ -74,7 +100,7 @@ if (!$UserCN) if (!defined ($Actions{$Action})) { - die; + die ("No such action: $Action"); } if (ref ($Actions{$Action}) eq 'CODE') @@ -89,9 +115,7 @@ elsif (ref ($Actions{$Action}) eq 'ARRAY') } } -#print qq#
Authenticated as ($UserCN, $UserID, #, $Config{'base_dn'}, qq#)
\n#; - -Person->disconnect (); +LiCoM::Connection->disconnect (); exit (0); @@ -103,94 +127,112 @@ sub action_browse $group = shift if (@_); $group ||= ''; - my @all; - if ($group) - { - @all = Person->search ([[group => $group]]); - } - else - { - @all = Person->search (); - } - if (!$group) { - my %groups = (); - for (@all) - { - my $person = $_; - my @g = $person->get ('group'); + my @groups = LiCoM::Group->all (); - $groups{$_} = (defined ($groups{$_}) ? $groups{$_} + 1 : 1) for (@g); - } - - print qq(\t\t

Contact Groups

\n\t\t