[vhffs-dev] [912] Added a refuse_reason field in vhffs_object, display the reason of refusal in the panel

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


Revision: 912
Author:   gradator
Date:     2007-09-11 07:43:14 +0000 (Tue, 11 Sep 2007)

Log Message:
-----------
Added a refuse_reason field in vhffs_object, display the reason of refusal in the panel

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Group.pm
    trunk/vhffs-api/src/Vhffs/Object.pm
    trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
    trunk/vhffs-api/src/Vhffs/Services/DNS.pm
    trunk/vhffs-api/src/Vhffs/Services/Mail.pm
    trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
    trunk/vhffs-api/src/Vhffs/Services/Mysql.pm
    trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm
    trunk/vhffs-api/src/Vhffs/Services/Repository.pm
    trunk/vhffs-api/src/Vhffs/Services/Svn.pm
    trunk/vhffs-api/src/Vhffs/Services/Web.pm
    trunk/vhffs-api/src/Vhffs/User.pm
    trunk/vhffs-backend/src/pgsql/initdb.sql.in
    trunk/vhffs-compat/4.0.sql.in
    trunk/vhffs-panel/object/resubmit.pl
    trunk/vhffs-panel/templates/misc/resubmit.tmpl


Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Group.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -657,7 +657,7 @@
 sub _new {
     no strict 'refs';
     my ($class, $main, $gid, $oid, $owner_uid, $groupname, $passwd, $quota, $quota_used, $date_creation, $description, $state) = @_;
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_GROUP);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_GROUP);
     return undef unless(defined $self);
 
     foreach (qw (gid groupname passwd quota quota_used) ) {

Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Object.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -96,7 +96,7 @@
 }
 
 sub _new {
-    my ($class, $main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, $type) = @_;
+    my ($class, $main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $refuse_reason, $state, $type) = @_;
     
     $self = {};
 
@@ -111,6 +111,7 @@
     $self->{owner_gid} = $owner_gid;
     $self->{date_creation} = $date_creation;
     $self->{description} = $description;
+    $self->{refuse_reason} = $refuse_reason;
     $self->{state} = $state;
     $self->{type} = $type;
     
@@ -232,9 +233,9 @@
     my $self = shift;
     my $request;
 
-    $request = 'UPDATE vhffs_object SET state=?, description=?, owner_uid=?, owner_gid=? WHERE object_id=?';
+    $request = 'UPDATE vhffs_object SET state=?, description=?, refuse_reason=?, owner_uid=?, owner_gid=? WHERE object_id=?';
     my $result = $self->{'db'}->prepare($request);
-    $result->execute( $self->{'state'} , $self->{'description'} , $self->{'owner_uid'} , $self->{'owner_gid'} , $self->{'object_id'} );;
+    $result->execute( $self->{'state'} , $self->{'description'} , $self->{'refuse_reason'}, $self->{'owner_uid'} , $self->{'owner_gid'} , $self->{'object_id'} );
 
 }
 
@@ -384,6 +385,18 @@
 }
 
 
+sub set_refuse_reason {
+        my ($self , $value) = @_;
+	$self->{'refuse_reason'} = $value;
+}
+
+sub get_refuse_reason  {
+	my $self = shift;
+	return gettext('no reason given') if( !defined $self->{'refuse_reason'} || length $self->{'refuse_reason'} <= 0 );
+	return $self->{'refuse_reason'};
+}
+
+
 # Accept this object
 sub moderate_accept
 {
@@ -395,6 +408,7 @@
 	my $user = Vhffs::User::get_by_uid( $vhffs , $self->get_owner_uid );
 
 	$self->set_status( Vhffs::Constants::WAITING_FOR_CREATION );
+	$self->set_refuse_reason( '' );
 
 	my $mail = sprintf(
 		gettext( "Hello,\n\nYour request for a %s (%s) on %s was accepted.\nPlease wait while we are creating your object.\n\nCheers,\nThe moderator team\n\n---------\n%s\n%s" ) ,
@@ -428,19 +442,19 @@
 
 	my $self = shift;
 	my $reason = shift;
-	undef $reason if( defined $reason && length $reason <= 0 );
 
 	my $vhffs = $self->{main};
 	my $user = Vhffs::User::get_by_uid( $vhffs , $self->get_owner_uid );
 
 	$self->set_status( Vhffs::Constants::VALIDATION_REFUSED );
+	$self->set_refuse_reason( $reason );
 
 	my $mail = sprintf(
-		gettext( "Hello,\n\nYour request for a %s (%s) on %s was refused.\n\nThe reason given by moderators is:\n%s\n\nYou can change the description and submit it again for moderation on the\npanel. You can delete this object on the panel if you have made\na mistake. Don't be upset, if you don't understand why your request has\nbeen refused, just reply to this email !\n\nCheers,\nThe moderator team\n\n---------\n%s\n%s" ) ,
+		gettext( "Hello,\n\nYour request for a %s (%s) on %s was refused.\n\nThe reason of refusal given by moderators is:\n%s\n\nYou can change the description and submit it again for moderation on the\npanel. You can delete this object on the panel if you have made\na mistake. Don't be upset, if you don't understand why your request has\nbeen refused, just reply to this email !\n\nCheers,\nThe moderator team\n\n---------\n%s\n%s" ) ,
 		Vhffs::Functions::type_string_from_type_id( $self->get_type ),
 		$self->get_label,
 		$vhffs->get_config->get_host_name,
-		$reason || gettext('no reason given'),
+		$self->get_refuse_reason,
 		$vhffs->get_config->get_host_name,
 		$vhffs->get_config->get_panel->{url}
 		);
@@ -485,7 +499,7 @@
 	my $name = shift;
 	my $state = shift;
 
-	my $query = 'SELECT o.object_id, o.owner_uid, o.owner_gid, o.date_creation , o.description, o.state, o.type FROM vhffs_object o';
+	my $query = 'SELECT o.object_id, o.owner_uid, o.owner_gid, o.date_creation , o.description, o.refuse_reason, o.state, o.type FROM vhffs_object o';
 	my @params;
 
 	if( defined $name )
@@ -572,7 +586,7 @@
     my ($vhffs, $oid) = @_;
     return undef unless ( $oid =~ /^\d+$/ );
 
-    my $query = 'SELECT owner_uid, owner_gid, date_creation, description, state, type FROM vhffs_object WHERE object_id =?';
+    my $query = 'SELECT owner_uid, owner_gid, date_creation, description, refuse_reason, state, type FROM vhffs_object WHERE object_id =?';
     my $sth = $vhffs->get_db_object->prepare( $query );
     my $rows = $sth->execute( $oid );
 

Modified: trunk/vhffs-api/src/Vhffs/Services/Cvs.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Cvs.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Services/Cvs.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -205,7 +205,7 @@
 sub _new {
     my ($class, $main, $cvs_id, $cvsroot, $owner_uid, $owner_gid, $public, $oid, $date_creation, $description, $state) = @_;
     
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_CVS);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_CVS);
     return undef unless(defined $self);
     
     $self->{cvsroot} = $cvsroot;

Modified: trunk/vhffs-api/src/Vhffs/Services/DNS.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/DNS.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Services/DNS.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -325,7 +325,7 @@
 {
     my ($class, $main, $dns_id, $domain, $owner_gid, $ns, $mbox, $serial, $refresh, $retry, $expire, $minimum, $ttl, $oid, $owner_uid, $date_creation, $state, $description, $a, $nsr, $cname, $mx, $srv, $aaaa, $txt) = @_;
 
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_DNS);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_DNS);
 
     $self->{dns_id} = $dns_id;
     $self->{domain} = $domain;

Modified: trunk/vhffs-api/src/Vhffs/Services/Mail.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mail.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Services/Mail.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -595,7 +595,7 @@
 
 sub _new {
     my ($class, $main, $mxdomain_id, $owner_gid, $domain, $unix_user, $boxes_path, $max_popbox, $catchall, $oid, $owner_uid, $date_creation, $state, $description, $boxes, $forwards) = @_;
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_MAIL);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MAIL);
     return undef unless defined($self);
     
     $self->{mxdomain_id} = $mxdomain_id;

Modified: trunk/vhffs-api/src/Vhffs/Services/MailingList.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Services/MailingList.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -173,7 +173,7 @@
 sub _new {
     my ($class, $main, $ml_id, $local_part, $domain, $prefix, $owner_gid, $admin, $open_archive, $reply_to, $sub_ctrl, $post_ctrl, $signature, $oid, $owner_uid, $date_creation, $state, $description, $subs) = @_;
 
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_ML);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_ML);
     return undef unless defined($self);
 
     $self->{ml_id} = $ml_id;

Modified: trunk/vhffs-api/src/Vhffs/Services/Mysql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Mysql.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Services/Mysql.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -217,7 +217,7 @@
 
 sub _new {
     my ($class, $main, $mysql_id, $owner_gid, $dbname, $dbuser, $dbpass, $oid, $owner_uid, $date_creation, $state, $description) = @_;
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_MYSQL);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_MYSQL);
     return undef unless(defined $self);
 
     $self->{mysql_id} = $mysql_id;

Modified: trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Services/Pgsql.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -224,7 +224,7 @@
 
 sub _new {
     my ($class, $main, $pgsql_id, $owner_gid, $dbname, $dbuser, $dbpass, $oid, $owner_uid, $date_creation, $state, $description) = @_;
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_PGSQL);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_PGSQL);
     return undef unless(defined $self);
 
     $self->{pgsql_id} = $pgsql_id;

Modified: trunk/vhffs-api/src/Vhffs/Services/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Repository.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Services/Repository.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -164,7 +164,7 @@
 sub _new {
     my ($class, $main, $repository_id, $name, $owner_uid, $owner_gid, $quota, $quota_used, $oid, $date_creation, $description, $state) = @_;
 
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_REPOSITORY);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_REPOSITORY);
     return undef unless(defined $self);
 
     $self->{repository_id} = $repository_id;

Modified: trunk/vhffs-api/src/Vhffs/Services/Svn.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Svn.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Services/Svn.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -127,7 +127,7 @@
 {
     my ($class, $main, $svn_id, $reponame, $owner_uid, $owner_gid, $public, $ml_name, $oid, $date_creation, $description, $state) = @_;
 
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_SVN);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_SVN);
     return undef unless(defined $self);
 
     $self->{svn_id} = $svn_id;

Modified: trunk/vhffs-api/src/Vhffs/Services/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Web.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/Services/Web.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -334,7 +334,7 @@
 sub _new {
     my ($class, $main, $httpd_id, $servername, $owner_uid, $owner_gid, $oid, $date_creation, $description, $state) = @_;
 
-    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_WEB);
+    my $self = $class->SUPER::_new($main, $oid, $owner_uid, $owner_gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_WEB);
     return undef unless(defined($self));
 
     $self->{http_id} = $httpd_id;

Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2007-09-11 07:43:14 UTC (rev 912)
@@ -88,7 +88,7 @@
 
 sub _new {
     my ($class, $main, $uid, $gid, $oid, $username, $passwd, $homedir, $shell, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, $note, $language, $theme, $date_creation, $description, $state) = @_;
-    my $self = $class->SUPER::_new($main, $oid, $uid, $gid, $date_creation, $description, $state, Vhffs::Constants::TYPE_USER);
+    my $self = $class->SUPER::_new($main, $oid, $uid, $gid, $date_creation, $description, '', $state, Vhffs::Constants::TYPE_USER);
     return undef unless(defined $self);
     $self->{uid} = $uid;
     $self->{gid} = $gid;

Modified: trunk/vhffs-backend/src/pgsql/initdb.sql.in
===================================================================
--- trunk/vhffs-backend/src/pgsql/initdb.sql.in	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-backend/src/pgsql/initdb.sql.in	2007-09-11 07:43:14 UTC (rev 912)
@@ -38,6 +38,7 @@
 	date_creation timestamp NOT NULL,
 	state int4 NOT NULL,
 	description TEXT,
+	refuse_reason TEXT,
 	type int4 NOT NULL DEFAULT 0,
 	CONSTRAINT vhffs_object_pkey PRIMARY KEY (object_id)
 ) WITH OIDS;

Modified: trunk/vhffs-compat/4.0.sql.in
===================================================================
--- trunk/vhffs-compat/4.0.sql.in	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-compat/4.0.sql.in	2007-09-11 07:43:14 UTC (rev 912)
@@ -35,6 +35,7 @@
 
 -- vhffs_object
 ALTER TABLE vhffs_object ADD COLUMN owner_gid int4;
+ALTER TABLE vhffs_object ADD COLUMN refuse_reason TEXT;
 ALTER TABLE vhffs_object ALTER owner_uid SET NOT NULL;
 ALTER TABLE vhffs_object ALTER date_creation SET NOT NULL;
 

Modified: trunk/vhffs-panel/object/resubmit.pl
===================================================================
--- trunk/vhffs-panel/object/resubmit.pl	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-panel/object/resubmit.pl	2007-09-11 07:43:14 UTC (rev 912)
@@ -121,6 +121,9 @@
 	$template->param( OBJECTNAME_TEXT => gettext('Object name') );
 	$template->param( OBJECTNAME => $object->get_label );
 
+	$template->param( REFUSEREASON_TEXT => gettext('Reason of refusal') );
+	$template->param( REFUSEREASON => CGI::escapeHTML( $object->get_refuse_reason ) );
+
 	$template->param( DESCRIPTION_TEXT => gettext('Description') );
 	$template->param( DESCRIPTION => CGI::escapeHTML( $object->get_description ) );
 

Modified: trunk/vhffs-panel/templates/misc/resubmit.tmpl
===================================================================
--- trunk/vhffs-panel/templates/misc/resubmit.tmpl	2007-09-11 06:23:39 UTC (rev 911)
+++ trunk/vhffs-panel/templates/misc/resubmit.tmpl	2007-09-11 07:43:14 UTC (rev 912)
@@ -6,6 +6,9 @@
 		<label><TMPL_VAR NAME="OBJECTNAME_TEXT">:</label> <TMPL_VAR NAME="OBJECTNAME">
 	</p>
 	<p>
+		<label><TMPL_VAR NAME="REFUSEREASON_TEXT">:</label> <TMPL_VAR NAME="REFUSEREASON">
+	</p>
+	<p>
 		<label for="description">
 			<TMPL_VAR NAME="DESCRIPTION_TEXT">:
 		</label>


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