[vhffs-dev] [991] Misc modifications about vhffs_boxes state, exim configuration check if the boxis activated, panel doesn' t allow modification of a non activated box

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


Revision: 991
Author:   gradator
Date:     2007-10-15 20:40:26 +0000 (Mon, 15 Oct 2007)

Log Message:
-----------
Misc modifications about vhffs_boxes state, exim configuration check if the boxis activated, panel doesn't allow modification of a non activated box

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Services/Mail.pm
    trunk/vhffs-backend/src/mirror/mx2-mirror.pl
    trunk/vhffs-doc/config/exim4-mx1/exim4.conf
    trunk/vhffs-doc/config/exim4-mx2/exim4.conf
    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-15 20:00:00 UTC (rev 990)
+++ trunk/vhffs-api/src/Vhffs/Services/Mail.pm	2007-10-15 20:40:26 UTC (rev 991)
@@ -273,6 +273,7 @@
 	return 1;
 }
 
+
 sub set_box_status
 {
 	my $self = shift;
@@ -291,6 +292,17 @@
 	return 1;
 }
 
+
+sub get_box_status
+{
+	my $self = shift;
+	my $local_part = shift;
+
+	return undef unless defined $self->{'boxes'}{$local_part};
+	return $self->{'boxes'}{$local_part}{'state'};
+}
+
+
 sub get_box_dir
 {
 	my $self = shift;

Modified: trunk/vhffs-backend/src/mirror/mx2-mirror.pl
===================================================================
--- trunk/vhffs-backend/src/mirror/mx2-mirror.pl	2007-10-15 20:00:00 UTC (rev 990)
+++ trunk/vhffs-backend/src/mirror/mx2-mirror.pl	2007-10-15 20:40:26 UTC (rev 991)
@@ -104,7 +104,7 @@
 # is active or not.
 $msth = $master_dbh->prepare(q{SELECT bf.domain,  bf.local_part
     FROM (SELECT domain AS domain, local_part AS local_part
-        FROM vhffs_boxes b
+        FROM vhffs_boxes b WHERE state = 6
         UNION 
         SELECT domain AS domain, local_part AS local_part
         FROM vhffs_forward f) AS bf

Modified: trunk/vhffs-doc/config/exim4-mx1/exim4.conf
===================================================================
--- trunk/vhffs-doc/config/exim4-mx1/exim4.conf	2007-10-15 20:00:00 UTC (rev 990)
+++ trunk/vhffs-doc/config/exim4-mx1/exim4.conf	2007-10-15 20:40:26 UTC (rev 991)
@@ -1,7 +1,7 @@
 hide pgsql_servers = PGHOST/PGDB/PGUSER/PGPASS
 MAIL_HOME=/data/mail/boxes
 PGSQL_LOCAL_DOMAINS = ${lookup pgsql{SELECT domain FROM vhffs_mxdomain WHERE domain = '$domain'}}
-PGSQL_VIRTUAL_LOCAL_DOMAINS = ${lookup pgsql{select vhffs_boxes.domain from vhffs_boxes, vhffs_mxdomain where local_part = '$local_part' and vhffs_boxes.domain = vhffs_mxdomain.domain and vhffs_mxdomain.domain = '$domain'}}
+PGSQL_VIRTUAL_LOCAL_DOMAINS = ${lookup pgsql{select vhffs_boxes.domain from vhffs_boxes, vhffs_mxdomain where local_part = '$local_part' and vhffs_boxes.domain = vhffs_mxdomain.domain and vhffs_mxdomain.domain = '$domain' and vhffs_boxes.state = 6}}
 PGSQL_VIRTUAL_LOCAL_DIR = MAIL_HOME/${lookup pgsql{select boxes_path from vhffs_mxdomain where domain = '$domain'}{$value}fail}/${lookup pgsql{select mbox_name from vhffs_boxes where domain = '$domain' and local_part = '$local_part'}{$value}fail}/Maildir
 PGSQL_VIRTUAL_FORWARD_DATA = ${lookup pgsql{select remote_name from vhffs_forward, vhffs_mxdomain where local_part = '$local_part' and vhffs_forward.domain = vhffs_mxdomain.domain and vhffs_mxdomain.domain = '$domain'}}
 PGSQL_ML_EXIST = ${lookup pgsql{select domain from vhffs_ml where local_part='$local_part' and domain='$domain'}}

Modified: trunk/vhffs-doc/config/exim4-mx2/exim4.conf
===================================================================
--- trunk/vhffs-doc/config/exim4-mx2/exim4.conf	2007-10-15 20:00:00 UTC (rev 990)
+++ trunk/vhffs-doc/config/exim4-mx2/exim4.conf	2007-10-15 20:40:26 UTC (rev 991)
@@ -1,7 +1,7 @@
 hide pgsql_servers = PGHOST/PGDB/PGUSER/PGPASS
 PGSQL_RELAY_DOMAIN = ${lookup pgsql{SELECT domain FROM vhffs_mxdomain WHERE domain = '$domain'}}
 # Use this query if your MX2 directly uses VHFFS database
-PGSQL_RELAY_CHECKLOCALPART = ${lookup pgsql{SELECT d.domain FROM vhffs_mxdomain d WHERE d.domain = '$domain' AND (d.catchall != '' OR EXISTS (SELECT domain FROM vhffs_boxes WHERE domain = '$domain' AND local_part = '$local_part') OR EXISTS (SELECT domain FROM vhffs_forward WHERE domain = '$domain' AND local_part = '$local_part') OR EXISTS (SELECT domain FROM vhffs_ml WHERE domain = '$domain' AND (local_part = '$local_part' OR local_part || '-request' = '$local_part')))}}
+PGSQL_RELAY_CHECKLOCALPART = ${lookup pgsql{SELECT d.domain FROM vhffs_mxdomain d WHERE d.domain = '$domain' AND (d.catchall != '' OR EXISTS (SELECT domain FROM vhffs_boxes WHERE domain = '$domain' AND local_part = '$local_part' AND state = 6) OR EXISTS (SELECT domain FROM vhffs_forward WHERE domain = '$domain' AND local_part = '$local_part') OR EXISTS (SELECT domain FROM vhffs_ml WHERE domain = '$domain' AND (local_part = '$local_part' OR local_part || '-request' = '$local_part')))}}
 # Use this query if your MX has a mirrored VHFFS db (using mirror-mx2.pl)
 # PGSQL_RELAY_CHECKLOCALPART = ${lookup pgsql{SELECT d.domain FROM vhffs_mxdomain d WHERE d.domain = '$domain' AND (d.catchall != '' OR EXISTS (SELECT domain FROM vhffs_addresses WHERE domain = '$domain' AND local_part = '$local_part'))}}
 

Modified: trunk/vhffs-panel/mail/prefs.pl
===================================================================
--- trunk/vhffs-panel/mail/prefs.pl	2007-10-15 20:00:00 UTC (rev 990)
+++ trunk/vhffs-panel/mail/prefs.pl	2007-10-15 20:40:26 UTC (rev 991)
@@ -228,10 +228,10 @@
 
 sub update_box {
     # User wants to update information about a box
-    if(!$user->can_modify($mail)) {
+    my $box = $cgi->param('localpart');
+    unless( $user->can_modify($mail) && $mail->get_box_status( $box ) == Vhffs::Constants::ACTIVATED ) {
         $panel->add_error( gettext('You are not allowed to modify this object') );
     } else {
-        my $box = $cgi->param('localpart');
         my $passwd = $cgi->param('box_password');
         my $use_antispam = $cgi->param('use_antispam');
         my $use_antivirus = $cgi->param('use_antivirus');
@@ -268,10 +268,10 @@
 
 sub delete_box {
     # User wants to delete a box
-    if(!$user->can_modify($mail)) {
+    my $box = $cgi->param('localpart');
+    unless( $user->can_modify($mail) && $mail->get_box_status( $box ) == Vhffs::Constants::ACTIVATED ) {
         $panel->add_error( gettext('You are not allowed to modify this object') );
     } else {
-        my $box = $cgi->param('localpart');
         if(!defined $box) {
             $panel->add_error( gettext('CGI error') );
         } elsif($mail->set_box_status($box, Vhffs::Constants::TO_DELETE) < 0) {

Modified: trunk/vhffs-panel/templates/mail/prefs_boxes.tmpl
===================================================================
--- trunk/vhffs-panel/templates/mail/prefs_boxes.tmpl	2007-10-15 20:00:00 UTC (rev 990)
+++ trunk/vhffs-panel/templates/mail/prefs_boxes.tmpl	2007-10-15 20:40:26 UTC (rev 991)
@@ -1,6 +1,7 @@
 <TMPL_LOOP NAME="BOXES">
 <fieldset>
-<legend><TMPL_VAR NAME="LOCAL_PART">@<TMPL_VAR NAME="DOMAIN"> <tmpl_unless name="ACTIVE">&nbsp;&mdash;&nbsp;<tmpl_var name="STATESTR"></tmpl_unless> </legend>
+<legend><TMPL_VAR NAME="LOCAL_PART">@<TMPL_VAR NAME="DOMAIN"></legend>
+	<tmpl_if name="ACTIVE">
 		<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">
@@ -17,5 +18,8 @@
 			<input type="hidden" name="localpart" value="<tmpl_var name="LOCAL_PART">" />
 			<input type="hidden" name="name" value="<tmpl_var name="DOMAIN">" />
 		</form>
+	<tmpl_else>
+		<tmpl_var name="STATESTR">
+	</tmpl_if>
 </fieldset>
 </TMPL_LOOP>


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