[vhffs-dev] [809] renaming Vhffs::Panel::Mailinglist to Vhffs::Panel::MailingList ( part two) |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 809
Author: gradator
Date: 2007-08-29 23:46:25 +0000 (Wed, 29 Aug 2007)
Log Message:
-----------
renaming Vhffs::Panel::Mailinglist to Vhffs::Panel::MailingList (part two)
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Makefile.am
Added Paths:
-----------
trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm
Removed Paths:
-------------
trunk/vhffs-api/src/Vhffs/Panel/Mailinglist.pm
Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am 2007-08-29 23:45:26 UTC (rev 808)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am 2007-08-29 23:46:25 UTC (rev 809)
@@ -34,7 +34,7 @@
Panel/Group.pm \
Panel/Handler.pm \
Panel/Mail.pm \
- Panel/Mailinglist.pm \
+ Panel/MailingList.pm \
Panel/Main.pm \
Panel/Menu.pm \
Panel/Mysql.pm \
Copied: trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm (from rev 808, trunk/vhffs-api/src/Vhffs/Panel/Mailinglist.pm)
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Panel/MailingList.pm 2007-08-29 23:46:25 UTC (rev 809)
@@ -0,0 +1,138 @@
+#!%PERL%
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+
+package Vhffs::Panel::MailingList;
+
+use DBI;
+use POSIX qw(locale_h);
+use HTML::Template;
+use locale;
+use Locale::gettext;
+use CGI;
+use CGI::Session;
+use strict;
+use Vhffs::User;
+use Vhffs::Main;
+use Vhffs::Panel::Main;
+use Vhffs::Services::MailingList;
+
+sub search
+{
+ my ($main, $name) = @_;
+ my $sql;
+ my @params;
+ my $mls = [];
+
+ if( defined $name ) {
+ $sql = 'SELECT l.local_part, l.domain, g.groupname, l.object_id AS oid, o.state FROM vhffs_ml l INNER JOIN vhffs_object o ON o.object_id = l.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE l.local_part LIKE ? OR l.domain LIKE ?';
+ push(@params, '%'.$name.'%');
+ push(@params, '%'.$name.'%');
+ } else {
+ $sql = 'SELECT l.local_part, l.domain, g.groupname, l.object_id AS oid, o.state FROM vhffs_ml l INNER JOIN vhffs_object o ON o.object_id = l.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid';
+ }
+ my $dbh = $main->get_db_object();
+ my $sth = $dbh->prepare($sql) or return undef;
+
+ return undef unless($sth->execute(@params));
+
+ while(my $m = $sth->fetchrow_hashref('NAME_lc')) {
+ $m->{state} = Vhffs::Functions::status_string_from_status_id($m->{state});
+ push(@$mls, $m);
+ }
+ return $mls;
+}
+
+=pod
+
+=head2 getall_per_group
+
+ $ml = Vhffs::Panel::MailingList::getall_per_group($vhffs, $gid);
+
+Returns an array of hashrefs (oid, displayname, active, state (localized string)) of all mailing lists owned by
+a given group.
+
+=cut
+
+
+sub getall_per_group
+{
+ my ( $main, $gid ) = @_;
+
+ my $dbh = $main->get_db_object;
+ my $sql = 'SELECT l.object_id AS oid, l.local_part || \'@\' || l.domain AS displayname, o.state FROM vhffs_ml l INNER JOIN vhffs_object o ON l.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY l.local_part, l.domain';
+ my $sth = $dbh->prepare($sql) or return -1;
+ $sth->execute($gid) or return -2;
+ my $mls = [];
+ while(my $l = $sth->fetchrow_hashref) {
+ $l->{active} = ($l->{state} == Vhffs::Constants::ACTIVATED);
+ $l->{state} = Vhffs::Functions::status_string_from_status_id($l->{state});
+ push @$mls, $l;
+ }
+ return $mls;
+}
+
+=pod
+
+=head2 getall_mdomains_per_group
+
+ $domains = Vhffs::Panel::MailingList::getall_mdomains_per_group($vhffs, $gid);
+
+Returns an array of hashref (domain) of all active mail domains for
+a given group.
+
+=cut
+
+sub getall_mdomains_per_group($$) {
+ my ($main, $gid) = @_;
+
+ my $dbh = $main->get_db_object;
+ my $sql = q{ SELECT m.domain FROM vhffs_mxdomain m INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE o.owner_gid = ? AND o.state = ? ORDER BY m.domain };
+ return ($dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED) );
+}
+
+sub create_list
+{
+ my ($main, $lpart, $domain, $description, $user, $group) = @_;
+
+ return undef unless( defined $user );
+ return undef unless( defined $group );
+
+ my $list = Vhffs::Services::MailingList::create( $main , $lpart , $domain, $user->get_mail, $description, $user, $group );
+ return undef unless( defined $list );
+
+ return undef if ( Vhffs::Acl::add_acl( $user , $list , Vhffs::Constants::ACL_DELETE , $main ) < 0 );
+ return undef if( Vhffs::Acl::add_acl( $group , $list , Vhffs::Constants::ACL_VIEW , $main ) < 0 );
+
+ return $list;
+}
+
+1;
Deleted: trunk/vhffs-api/src/Vhffs/Panel/Mailinglist.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Mailinglist.pm 2007-08-29 23:45:26 UTC (rev 808)
+++ trunk/vhffs-api/src/Vhffs/Panel/Mailinglist.pm 2007-08-29 23:46:25 UTC (rev 809)
@@ -1,138 +0,0 @@
-#!%PERL%
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#3. Neither the name of vhffs nor the names of its contributors
-# may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-
-package Vhffs::Panel::MailingList;
-
-use DBI;
-use POSIX qw(locale_h);
-use HTML::Template;
-use locale;
-use Locale::gettext;
-use CGI;
-use CGI::Session;
-use strict;
-use Vhffs::User;
-use Vhffs::Main;
-use Vhffs::Panel::Main;
-use Vhffs::Services::MailingList;
-
-sub search
-{
- my ($main, $name) = @_;
- my $sql;
- my @params;
- my $mls = [];
-
- if( defined $name ) {
- $sql = 'SELECT l.local_part, l.domain, g.groupname, l.object_id AS oid, o.state FROM vhffs_ml l INNER JOIN vhffs_object o ON o.object_id = l.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid WHERE l.local_part LIKE ? OR l.domain LIKE ?';
- push(@params, '%'.$name.'%');
- push(@params, '%'.$name.'%');
- } else {
- $sql = 'SELECT l.local_part, l.domain, g.groupname, l.object_id AS oid, o.state FROM vhffs_ml l INNER JOIN vhffs_object o ON o.object_id = l.object_id INNER JOIN vhffs_groups g ON g.gid = o.owner_gid';
- }
- my $dbh = $main->get_db_object();
- my $sth = $dbh->prepare($sql) or return undef;
-
- return undef unless($sth->execute(@params));
-
- while(my $m = $sth->fetchrow_hashref('NAME_lc')) {
- $m->{state} = Vhffs::Functions::status_string_from_status_id($m->{state});
- push(@$mls, $m);
- }
- return $mls;
-}
-
-=pod
-
-=head2 getall_per_group
-
- $ml = Vhffs::Panel::MailingList::getall_per_group($vhffs, $gid);
-
-Returns an array of hashrefs (oid, displayname, active, state (localized string)) of all mailing lists owned by
-a given group.
-
-=cut
-
-
-sub getall_per_group
-{
- my ( $main, $gid ) = @_;
-
- my $dbh = $main->get_db_object;
- my $sql = 'SELECT l.object_id AS oid, l.local_part || \'@\' || l.domain AS displayname, o.state FROM vhffs_ml l INNER JOIN vhffs_object o ON l.object_id = o.object_id WHERE o.owner_gid = ? ORDER BY l.local_part, l.domain';
- my $sth = $dbh->prepare($sql) or return -1;
- $sth->execute($gid) or return -2;
- my $mls = [];
- while(my $l = $sth->fetchrow_hashref) {
- $l->{active} = ($l->{state} == Vhffs::Constants::ACTIVATED);
- $l->{state} = Vhffs::Functions::status_string_from_status_id($l->{state});
- push @$mls, $l;
- }
- return $mls;
-}
-
-=pod
-
-=head2 getall_mdomains_per_group
-
- $domains = Vhffs::Panel::MailingList::getall_mdomains_per_group($vhffs, $gid);
-
-Returns an array of hashref (domain) of all active mail domains for
-a given group.
-
-=cut
-
-sub getall_mdomains_per_group($$) {
- my ($main, $gid) = @_;
-
- my $dbh = $main->get_db_object;
- my $sql = q{ SELECT m.domain FROM vhffs_mxdomain m INNER JOIN vhffs_object o ON o.object_id = m.object_id WHERE o.owner_gid = ? AND o.state = ? ORDER BY m.domain };
- return ($dbh->selectall_arrayref($sql, { Slice => {} }, $gid, Vhffs::Constants::ACTIVATED) );
-}
-
-sub create_list
-{
- my ($main, $lpart, $domain, $description, $user, $group) = @_;
-
- return undef unless( defined $user );
- return undef unless( defined $group );
-
- my $list = Vhffs::Services::MailingList::create( $main , $lpart , $domain, $user->get_mail, $description, $user, $group );
- return undef unless( defined $list );
-
- return undef if ( Vhffs::Acl::add_acl( $user , $list , Vhffs::Constants::ACL_DELETE , $main ) < 0 );
- return undef if( Vhffs::Acl::add_acl( $group , $list , Vhffs::Constants::ACL_VIEW , $main ) < 0 );
-
- return $list;
-}
-
-1;