[vhffs-dev] [1182] added allowpop and allowimap fields to vhffs_boxes

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1182
Author:   gradator
Date:     2008-04-02 23:56:40 +0200 (Wed, 02 Apr 2008)

Log Message:
-----------
added allowpop and allowimap fields to vhffs_boxes

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Services/Mail.pm
    trunk/vhffs-backend/src/pgsql/initdb.sql.in
    trunk/vhffs-compat/4.1.sql
    trunk/vhffs-doc/config/courier/authpgsqlrc


Modified: trunk/vhffs-api/src/Vhffs/Services/Mail.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mail.pm	2008-04-02 17:17:50 UTC (rev 1181)
+++ trunk/vhffs-api/src/Vhffs/Services/Mail.pm	2008-04-02 21:56:40 UTC (rev 1182)
@@ -286,6 +286,64 @@
 }
 
 
+sub set_box_allowpop
+{
+	my $self = shift;
+	my $local_part = shift;
+	my $allow = shift;
+
+	return -1 unless defined $self->{'boxes'}{$local_part};
+
+	$self->{'boxes'}{$local_part}{'allowpop'} = $allow;
+
+	my $sql = 'UPDATE vhffs_boxes SET allowpop=? WHERE domain=? AND local_part=?';
+	my $dbh = $self->{db};
+	my $sth = $dbh->prepare($sql);
+	$sth->execute($allow, $self->{domain}, $local_part) or return -1;
+
+	return 1;
+}
+
+
+sub get_box_allowpop
+{
+	my $self = shift;
+	my $local_part = shift;
+
+	return undef unless defined $self->{'boxes'}{$local_part};
+	return $self->{'boxes'}{$local_part}{'allowpop'};
+}
+
+
+sub set_box_allowimap
+{
+	my $self = shift;
+	my $local_part = shift;
+	my $allow = shift;
+
+	return -1 unless defined $self->{'boxes'}{$local_part};
+
+	$self->{'boxes'}{$local_part}{'allowimap'} = $allow;
+
+	my $sql = 'UPDATE vhffs_boxes SET allowimap=? WHERE domain=? AND local_part=?';
+	my $dbh = $self->{db};
+	my $sth = $dbh->prepare($sql);
+	$sth->execute($allow, $self->{domain}, $local_part) or return -1;
+
+	return 1;
+}
+
+
+sub get_box_allowimap
+{
+	my $self = shift;
+	my $local_part = shift;
+
+	return undef unless defined $self->{'boxes'}{$local_part};
+	return $self->{'boxes'}{$local_part}{'allowimap'};
+}
+
+
 sub set_box_status
 {
 	my $self = shift;
@@ -393,7 +451,7 @@
     $self->{boxes}{$name}{mbox_name} = $userhash;
     $self->{boxes}{$name}{state} = Vhffs::Constants::WAITING_FOR_CREATION;
 	
-    my $sql = 'INSERT INTO vhffs_boxes(domain, local_part, domain_hash, password, mbox_name, nospam, novirus, state) VALUES(?, ?, ?, ?, ?, FALSE, FALSE, ?)';
+    my $sql = 'INSERT INTO vhffs_boxes(domain, local_part, domain_hash, password, mbox_name, nospam, novirus, allowpop, allowimap, state) VALUES(?, ?, ?, ?, ?, FALSE, FALSE, TRUE, TRUE,  ?)';
     my $dbh = $self->{db};
     my $sth = $dbh->prepare($sql);
     $sth->execute($self->{domain}, $name, $domainhash, $password, $userhash, Vhffs::Constants::WAITING_FOR_CREATION) or return -3;
@@ -637,7 +695,7 @@
 sub fetch_boxes {
     my ($dbh, $domain) = @_;
     my $sql = q{SELECT domain, local_part, domain_hash, password,
-    mbox_name, nospam, novirus, state FROM vhffs_boxes
+    mbox_name, nospam, novirus, allowpop, allowimap, state FROM vhffs_boxes
     WHERE domain = ? ORDER BY local_part};
     return $dbh->selectall_hashref($sql, 'local_part', undef, $domain);
 }

Modified: trunk/vhffs-backend/src/pgsql/initdb.sql.in
===================================================================
--- trunk/vhffs-backend/src/pgsql/initdb.sql.in	2008-04-02 17:17:50 UTC (rev 1181)
+++ trunk/vhffs-backend/src/pgsql/initdb.sql.in	2008-04-02 21:56:40 UTC (rev 1182)
@@ -150,6 +150,10 @@
 	nospam boolean,
 -- Is antivirus activated?
 	novirus boolean,
+-- Allow pop login ?
+	allowpop boolean,
+-- Allow imap login ?
+	allowimap boolean,
 -- State of the box (we don't have object for this entity...)
 	state int4 NOT NULL,
 	CONSTRAINT vhffs_boxes_pkey PRIMARY KEY (domain,local_part)

Modified: trunk/vhffs-compat/4.1.sql
===================================================================
--- trunk/vhffs-compat/4.1.sql	2008-04-02 17:17:50 UTC (rev 1181)
+++ trunk/vhffs-compat/4.1.sql	2008-04-02 21:56:40 UTC (rev 1182)
@@ -8,3 +8,14 @@
 ALTER TABLE vhffs_pgsql RENAME COLUMN dbuser_new TO dbuser;
 ALTER TABLE vhffs_pgsql ALTER COLUMN dbuser SET NOT NULL;
 COMMIT;
+
+-- add allowpop and allowimap field to vhffs_boxes
+ALTER TABLE vhffs_boxes ADD COLUMN allowpop boolean;
+ALTER TABLE vhffs_boxes ALTER COLUMN allowpop SET DEFAULT true;
+UPDATE vhffs_boxes SET allowpop=true;
+ALTER TABLE vhffs_boxes ALTER COLUMN allowpop SET NOT NULL;
+
+ALTER TABLE vhffs_boxes ADD COLUMN allowimap boolean;
+ALTER TABLE vhffs_boxes ALTER COLUMN allowimap SET DEFAULT true;
+UPDATE vhffs_boxes SET allowimap=true;
+ALTER TABLE vhffs_boxes ALTER COLUMN allowimap SET NOT NULL;

Modified: trunk/vhffs-doc/config/courier/authpgsqlrc
===================================================================
--- trunk/vhffs-doc/config/courier/authpgsqlrc	2008-04-02 17:17:50 UTC (rev 1181)
+++ trunk/vhffs-doc/config/courier/authpgsqlrc	2008-04-02 21:56:40 UTC (rev 1182)
@@ -194,7 +194,7 @@
 # database scheme:
 #
 
-PGSQL_SELECT_CLAUSE	SELECT local_part||'@'||domain , password, '', 102 as uid, 104 as gid, '/data/mail/boxes/'||domain_hash||'/', mbox_name || '/Maildir', '', '', '' FROM vhffs_boxes WHERE local_part = '$(local_part)' AND domain='$(domain)'
+PGSQL_SELECT_CLAUSE	SELECT local_part||'@'||domain , password, '', 102 as uid, 104 as gid, '/data/mail/boxes/'||domain_hash||'/', mbox_name || '/Maildir', '', '', '' FROM vhffs_boxes WHERE local_part = '$(local_part)' AND domain='$(domain)' AND ( ( '$(service)' LIKE 'pop%' AND allowpop=true ) OR ( '$(service)' LIKE 'imap%' AND allowimap=true ) ) AND state=6
 
 
 ##NAME: PGSQL_ENUMERATE_CLAUSE:0
@@ -227,7 +227,6 @@
 # $(newpass_crypt) contains its crypted form
 #
 PGSQL_CHPASS_CLAUSE	UPDATE	vhffs_boxes				\
-			SET	clearpw='$(newpass)',			\
-				password='$(newpass_crypt)'		\
+			SET	password='$(newpass_crypt)'		\
 			WHERE	local_part='$(local_part)'		\
 			AND	domain_name='$(domain)'


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/