[vhffs-dev] [989] Add state field to vhffs_boxes, API is done, Panel too, but not yet for robots |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 989
Author: gradator
Date: 2007-10-14 22:08:36 +0000 (Sun, 14 Oct 2007)
Log Message:
-----------
Add state field to vhffs_boxes, API is done, Panel too, but not yet for robots
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Services/Mail.pm
trunk/vhffs-backend/conf/vhffs.conf.dist.in
trunk/vhffs-backend/src/pgsql/initdb.sql.in
trunk/vhffs-compat/4.0.sql.in
trunk/vhffs-panel/mail/prefs.pl
trunk/vhffs-panel/templates/mail/prefs_boxes.tmpl
Modified: trunk/vhffs-api/src/Vhffs/Services/Mail.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mail.pm 2007-10-14 20:13:28 UTC (rev 988)
+++ trunk/vhffs-api/src/Vhffs/Services/Mail.pm 2007-10-14 22:08:36 UTC (rev 989)
@@ -273,6 +273,24 @@
return 1;
}
+sub set_box_status
+{
+ my $self = shift;
+ my $local_part = shift;
+ my $state = shift;
+
+ return -1 unless defined $self->{'boxes'}{$local_part};
+
+ $self->{'boxes'}{$local_part}{'state'} = $state;
+
+ my $sql = 'UPDATE vhffs_boxes SET state=? WHERE domain=? AND local_part=?';
+ my $dbh = $self->{db};
+ my $sth = $dbh->prepare($sql);
+ $sth->execute($state, $self->{domain}, $local_part) or return -1;
+
+ return 1;
+}
+
=pod
=head2 addforward
@@ -337,11 +355,12 @@
$self->{boxes}{$name}{novirus} = 0;
$self->{boxes}{$name}{nospam} = 0;
$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) VALUES(?, ?, ?, ?, ?, FALSE, FALSE)';
+ my $sql = 'INSERT INTO vhffs_boxes(domain, local_part, domain_hash, password, mbox_name, nospam, novirus, state) VALUES(?, ?, ?, ?, ?, FALSE, FALSE, ?)';
my $dbh = $self->{db};
my $sth = $dbh->prepare($sql);
- $sth->execute($self->{domain}, $name, $domainhash, $password, $userhash) or return -3;
+ $sth->execute($self->{domain}, $name, $domainhash, $password, $userhash, Vhffs::Constants::WAITING_FOR_CREATION) or return -3;
return 1;
}
@@ -425,7 +444,7 @@
return crypt( $clear , $salt );
}
-# Returns an hashref with all bosex
+# Returns an hashref with all boxes
# The key of this hash is the local_part of each mailbox
sub get_boxes
{
@@ -568,7 +587,7 @@
sub fetch_boxes {
my ($dbh, $domain) = @_;
my $sql = q{SELECT domain, local_part, domain_hash, password,
- mbox_name, nospam, novirus FROM vhffs_boxes
+ mbox_name, nospam, novirus, state FROM vhffs_boxes
WHERE domain = ? ORDER BY local_part};
return $dbh->selectall_hashref($sql, 'local_part', undef, $domain);
}
Modified: trunk/vhffs-backend/conf/vhffs.conf.dist.in
===================================================================
--- trunk/vhffs-backend/conf/vhffs.conf.dist.in 2007-10-14 20:13:28 UTC (rev 988)
+++ trunk/vhffs-backend/conf/vhffs.conf.dist.in 2007-10-14 22:08:36 UTC (rev 989)
@@ -353,11 +353,11 @@
# URL to the documentation (optional)
url_doc = http://help.myhoster.net/mail
- # kind of catchall addresses allowed (none|domain|open)
- # none: no catchall allowed
- # domain: only on the concerned domain
- # open: any address
- allowed_catchall = domain
+ # kind of catchall addresses allowed (none|domain|open)
+ # none: no catchall allowed
+ # domain: only on the concerned domain
+ # open: any address
+ allowed_catchall = domain
</mail>
# The mailuser service allows a user to get a mail account on a default domain
Modified: trunk/vhffs-backend/src/pgsql/initdb.sql.in
===================================================================
--- trunk/vhffs-backend/src/pgsql/initdb.sql.in 2007-10-14 20:13:28 UTC (rev 988)
+++ trunk/vhffs-backend/src/pgsql/initdb.sql.in 2007-10-14 22:08:36 UTC (rev 989)
@@ -102,6 +102,7 @@
password varchar NOT NULL,
nospam boolean,
novirus boolean,
+ state int4 NOT NULL,
CONSTRAINT vhffs_boxes_pkey PRIMARY KEY (domain,local_part)
) WITH OIDS;
@@ -298,6 +299,8 @@
CREATE INDEX idx_vhffs_mailings_state ON vhffs_mailings(state);
-- state is used in vhffs_user_group in where clauses
CREATE INDEX idx_vhffs_user_group_state ON vhffs_user_group(state);
+-- state is used in vhffs_boxes in where clauses
+CREATE INDEX idx_vhffs_boxes_state ON vhffs_boxes(state);
-- vhffs_cvs.public may be used in where clause to display public cvs
CREATE INDEX idx_vhffs_cvs_public ON vhffs_cvs(public);
-- vhffs_svn.public may be used in where clause to display public svn
Modified: trunk/vhffs-compat/4.0.sql.in
===================================================================
--- trunk/vhffs-compat/4.0.sql.in 2007-10-14 20:13:28 UTC (rev 988)
+++ trunk/vhffs-compat/4.0.sql.in 2007-10-14 22:08:36 UTC (rev 989)
@@ -382,3 +382,8 @@
-- drop useless columns on vhffs_ml
ALTER TABLE vhffs_ml DROP COLUMN admin;
+
+-- add state column to vhffs_boxes
+ALTER TABLE vhffs_boxes ADD COLUMN state int4;
+UPDATE vhffs_boxes SET state=6;
+ALTER TABLE vhffs_boxes ALTER state SET NOT NULL;
Modified: trunk/vhffs-panel/mail/prefs.pl
===================================================================
--- trunk/vhffs-panel/mail/prefs.pl 2007-10-14 20:13:28 UTC (rev 988)
+++ trunk/vhffs-panel/mail/prefs.pl 2007-10-14 22:08:36 UTC (rev 989)
@@ -159,6 +159,10 @@
my $output = "";
my @boxes = sort { $a->{local_part} cmp $b->{local_part} } (values %{$mail->get_boxes});
+ foreach my $bo ( @boxes ) {
+ $bo->{active} = ($bo->{state} == Vhffs::Constants::ACTIVATED);
+ $bo->{statestr} = Vhffs::Functions::status_string_from_status_id($bo->{state});
+ }
$template->param( BOXES => ( \@boxes ) );
$template->param( ANTIVIRUS_FEATURE => ($mail_config->{'use_novirus'} eq 'yes' ) );
@@ -270,7 +274,7 @@
my $box = $cgi->param('localpart');
if(!defined $box) {
$panel->add_error( gettext('CGI error') );
- } elsif($mail->delbox($box) < 0) {
+ } elsif($mail->set_box_status($box, Vhffs::Constants::TO_DELETE) < 0) {
$panel->add_error( sprintf(gettext('Unable to delete box %s'), $box) );
} else {
$panel->add_info( sprintf(gettext('Box %s deleted'), $box) );
Modified: trunk/vhffs-panel/templates/mail/prefs_boxes.tmpl
===================================================================
--- trunk/vhffs-panel/templates/mail/prefs_boxes.tmpl 2007-10-14 20:13:28 UTC (rev 988)
+++ trunk/vhffs-panel/templates/mail/prefs_boxes.tmpl 2007-10-14 22:08:36 UTC (rev 989)
@@ -1,6 +1,6 @@
<TMPL_LOOP NAME="BOXES">
<fieldset>
-<legend><TMPL_VAR NAME="LOCAL_PART">@<TMPL_VAR NAME="DOMAIN"></legend>
+<legend><TMPL_VAR NAME="LOCAL_PART">@<TMPL_VAR NAME="DOMAIN"> <tmpl_unless name="ACTIVE"> — <tmpl_var name="STATESTR"></tmpl_unless> </legend>
<form method="post" action="prefs.pl">
<p><TMPL_I18N KEY="Change Password">: <input type="password" name="box_password" value=""/></p>
<tmpl_if name="antispam_feature">