[vhffs-dev] [2008] reworked Vhffs::Constants

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


Revision: 2008
Author:   gradator
Date:     2012-02-12 21:25:28 +0100 (Sun, 12 Feb 2012)
Log Message:
-----------
reworked Vhffs::Constants

Modified Paths:
--------------
    trunk/vhffs-api/src/Vhffs/Conf.pm
    trunk/vhffs-api/src/Vhffs/Constants.pm
    trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
    trunk/vhffs-api/src/Vhffs/Robots/Web.pm
    trunk/vhffs-api/src/Vhffs/User.pm
    trunk/vhffs-robots/src/repository_getquota.pl
    trunk/vhffs-robots/src/repository_setquota.pl

Modified: trunk/vhffs-api/src/Vhffs/Conf.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Conf.pm	2012-02-12 18:37:03 UTC (rev 2007)
+++ trunk/vhffs-api/src/Vhffs/Conf.pm	2012-02-12 20:25:28 UTC (rev 2008)
@@ -63,6 +63,7 @@
 		-ConfigFile => $filename,
 		-DefaultConfig => {
 			'global' => {
+				'default_language' => 'en_US',
 				'available_languages' => 'en_US'
 			},
 			'users' => {

Modified: trunk/vhffs-api/src/Vhffs/Constants.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Constants.pm	2012-02-12 18:37:03 UTC (rev 2007)
+++ trunk/vhffs-api/src/Vhffs/Constants.pm	2012-02-12 20:25:28 UTC (rev 2008)
@@ -4,83 +4,88 @@
 use utf8;
 use Locale::gettext;
 
-use constant
-{
-    VHFFS_VERSION => '4.4-dev (Revision: %VHFFS_REVISION%)',
-    VHFFS_RELEASE_NAME => undef,
+=pod
 
-    CONF_PATH => '/etc/vhffs/vhffs.conf',
-    
-    WAITING_FOR_VALIDATION => 1,
-    VALIDATION_REFUSED => 2,
-    WAITING_FOR_CREATION => 3,
-    CREATING_ERROR => 4,
-    CREATED => 5,
-    ACTIVATED => 6,
-    SUSPEND_PENDING => 7,
-    SUSPENDED => 8,
-    WAITING_FOR_MODIFICATION => 9,
-    MODIFICATION_ERROR => 10,
-    MODIFICATION_APPLIED => 11,
-    TO_DELETE => 12,
-    
-    ACL_UNDEFINED => -1,
-    ACL_DENIED => 0,
-    ACL_VIEW => 2,
-    ACL_MODIFY => 4,
-    ACL_MANAGEACL => 8,
-    ACL_DELETE => 10,
-    
-    USER_NORMAL => 0,
-    USER_ADMIN => 1,
-    USER_MODERATOR => 2,
-    
-    REPOSITORYDIR => "repository/",
-    
-    WEB_SUFFIX => "-web",
-    REPOSITORY_SUFFIX => "-repository",
-    
-    DEFAULT_THEME => "default",
-    DEFAULT_LANG => "en_US",
+=head1 NAME
 
-    ML_RIGHT_SUB_WAITING_FOR_REPLY => 2,	
-    ML_RIGHT_SUB_WAITING_FOR_VALIDATION => 3,
-    ML_RIGHT_SUB                   => 4,
-    ML_RIGHT_ADMIN                 => 10,
-    ML_RIGHT_SUB_WAITING_FOR_DEL   => 12,
+Vhffs::Constants - Define VHFFS global constants
 
-    ML_SUBSCRIBE_NO_APPROVAL_REQUIRED => 0,
-    ML_SUBSCRIBE_APPROVAL_REQUIRED => 1,
-    ML_SUBSCRIBE_CLOSED => 2,
-    ML_POSTING_OPEN_ALL => 0,
-    ML_POSTING_MODERATED_ALL => 1,
-    ML_POSTING_OPEN_MEMBERS_MODERATED_OTHERS => 2,
-    ML_POSTING_MEMBERS_ONLY => 3,
-    ML_POSTING_MEMBERS_ONLY_MODERATED => 4,
-    ML_POSTING_ADMINS_ONLY => 5,
+=head1 DESCRIPTION
 
-# Objects' types
-    TYPE_USER => 10,
-    TYPE_GROUP => 11,
-    TYPE_WEB => 20,
-    TYPE_REPOSITORY => 21,
-    TYPE_MYSQL => 30,
-    TYPE_PGSQL => 31,
-    TYPE_CVS => 40,
-    TYPE_SVN => 41,
-    TYPE_GIT => 42,
-    TYPE_MERCURIAL => 43,
-    TYPE_BAZAAR => 44,
-    TYPE_DNS => 50,
-    TYPE_MAIL => 60,
-    TYPE_ML => 61,
-    TYPE_CRON => 70,
-    
-# Tags visibility MUST BE ORDERED BY PRIVILEGE LEVEL!
+Vhffs::Constants is a class that define all constants values in VHFFS.
+So, you can use Vhffs::Constants::ConstantName to get the value of ConstantName.
+
+=cut
+
+use constant {
+	VHFFS_VERSION => '4.4-dev (Revision: %VHFFS_REVISION%)',
+	VHFFS_RELEASE_NAME => undef,
+
+	CONF_PATH => '/etc/vhffs/vhffs.conf',
+
+	WAITING_FOR_VALIDATION => 1,
+	VALIDATION_REFUSED => 2,
+	WAITING_FOR_CREATION => 3,
+	CREATING_ERROR => 4,
+	CREATED => 5,
+	ACTIVATED => 6,
+	SUSPEND_PENDING => 7,
+	SUSPENDED => 8,
+	WAITING_FOR_MODIFICATION => 9,
+	MODIFICATION_ERROR => 10,
+	MODIFICATION_APPLIED => 11,
+	TO_DELETE => 12,
+	
+	ACL_UNDEFINED => -1,
+	ACL_DENIED => 0,
+	ACL_VIEW => 2,
+	ACL_MODIFY => 4,
+	ACL_MANAGEACL => 8,
+	ACL_DELETE => 10,
+	
+	USER_NORMAL => 0,
+	USER_ADMIN => 1,
+	USER_MODERATOR => 2,
+	
+	ML_RIGHT_SUB_WAITING_FOR_REPLY => 2,	
+	ML_RIGHT_SUB_WAITING_FOR_VALIDATION => 3,
+	ML_RIGHT_SUB => 4,
+	ML_RIGHT_ADMIN => 10,
+	ML_RIGHT_SUB_WAITING_FOR_DEL => 12,
+
+	ML_SUBSCRIBE_NO_APPROVAL_REQUIRED => 0,
+	ML_SUBSCRIBE_APPROVAL_REQUIRED => 1,
+	ML_SUBSCRIBE_CLOSED => 2,
+
+	ML_POSTING_OPEN_ALL => 0,
+	ML_POSTING_MODERATED_ALL => 1,
+	ML_POSTING_OPEN_MEMBERS_MODERATED_OTHERS => 2,
+	ML_POSTING_MEMBERS_ONLY => 3,
+	ML_POSTING_MEMBERS_ONLY_MODERATED => 4,
+	ML_POSTING_ADMINS_ONLY => 5,
+
+	# Objects' types
+	TYPE_USER => 10,
+	TYPE_GROUP => 11,
+	TYPE_WEB => 20,
+	TYPE_REPOSITORY => 21,
+	TYPE_MYSQL => 30,
+	TYPE_PGSQL => 31,
+	TYPE_CVS => 40,
+	TYPE_SVN => 41,
+	TYPE_GIT => 42,
+	TYPE_MERCURIAL => 43,
+	TYPE_BAZAAR => 44,
+	TYPE_DNS => 50,
+	TYPE_MAIL => 60,
+	TYPE_ML => 61,
+	TYPE_CRON => 70,
+	
+	# Tags visibility MUST BE ORDERED BY PRIVILEGE LEVEL!
 	TAG_VISIBILITY_GROUP_CREATION => 10,
-	TAG_VISIBILITY_PUBLIC		=> 20,
-	TAG_VISIBILITY_MODERATORS	=> 30,
-	TAG_VISIBILITY_ADMINS		=> 40,
+	TAG_VISIBILITY_PUBLIC => 20,
+	TAG_VISIBILITY_MODERATORS => 30,
+	TAG_VISIBILITY_ADMINS => 40,
 };
 
 use constant {
@@ -141,62 +146,85 @@
 
 __END__
 
-=head1 SYNOPSIS
+=head1 MAIN CONSTANTS
+=head2 VHFFS_VERSION
+=head2 VHFFS_RELEASE_NAME
+=head2 CONF_PATH
 
-Vhffs::Constants - Constants for VHFFS
-
-=head1 DESCRIPTION
-
-Vhffs::Constants if a class that defined all constants values in VHFFS.
-So, you can use Vhffs::Constants::ConstantName to get the value of CosntantName.
-
-=head1 CONSTANTS
-	
+=head1 OBJECT STATUS CONSTANTS
 =head2 WAITING_FOR_VALIDATION
-
 =head2 VALIDATION_REFUSED
-
 =head2 WAITING_FOR_CREATION
-
 =head2 CREATING_ERROR
-
 =head2 CREATED
-
 =head2 ACTIVATED
-
 =head2 SUSPEND_PENDING
-
 =head2 SUSPENDED
-
 =head2 WAITING_FOR_MODIFICATION
-
 =head2 MODIFICATION_ERROR
-
 =head2 MODIFICATION_APPLIED
-
 =head2 TO_DELETE
 
-=head2 DEFAULT_THEME
+=head1 ACL CONSTANTS
+=head2 ACL_UNDEFINED
+=head2 ACL_DENIED
+=head2 ACL_VIEW
+=head2 ACL_MODIFY
+=head2 ACL_MANAGEACL
+=head2 ACL_DELETE
 
+=head1 USER CONSTANTS
+=head2 USER_NORMAL
+=head2 USER_ADMIN
+=head2 USER_MODERATOR
+
+=head1 MAILING LISTS CONSTANTS
 =head2 ML_RIGHT_SUB_WAITING_FOR_REPLY
-
+=head2 ML_RIGHT_SUB_WAITING_FOR_VALIDATION
 =head2 ML_RIGHT_SUB
-
 =head2 ML_RIGHT_ADMIN
-
 =head2 ML_RIGHT_SUB_WAITING_FOR_DEL
+=head2 ML_SUBSCRIBE_NO_APPROVAL_REQUIRED
+=head2 ML_SUBSCRIBE_APPROVAL_REQUIRED
+=head2 ML_SUBSCRIBE_CLOSED
+=head2 ML_POSTING_OPEN_ALL
+=head2 ML_POSTING_MODERATED_ALL
+=head2 ML_POSTING_OPEN_MEMBERS_MODERATED_OTHERS
+=head2 ML_POSTING_MEMBERS_ONLY
+=head2 ML_POSTING_MEMBERS_ONLY_MODERATED
+=head2 ML_POSTING_ADMINS_ONLY
 
-=head2 USER_NORMAL
+=head1 OBJECT TYPE CONSTANTS
+=head2 TYPE_USER
+=head2 TYPE_GROUP
+=head2 TYPE_WEB
+=head2 TYPE_REPOSITORY
+=head2 TYPE_MYSQL
+=head2 TYPE_PGSQL
+=head2 TYPE_CVS
+=head2 TYPE_SVN
+=head2 TYPE_GIT
+=head2 TYPE_MERCURIAL
+=head2 TYPE_BAZAAR
+=head2 TYPE_DNS
+=head2 TYPE_MAIL
+=head2 TYPE_ML
+=head2 TYPE_CRON
 
-=head2 USER_ADMIN
+=head1 TAG CONSTANTS
+=head2 TAG_VISIBILITY_GROUP_CREATION
+=head2 TAG_VISIBILITY_PUBLIC
+=head2 TAG_VISIBILITY_MODERATORS
+=head2 TAG_VISIBILITY_ADMINS
 
-=head2 USER_MODERATOR
-	
+=head1 STATUS STRINGS
 
-=head1 AUTHOR
-	
-	Julien Delange <julien at gunnm dot org>
+my $statusstr = Vhffs::Constants::STATUS_STRINGS->{ OBJECT STATUS CONSTANTS };
 
-=head1 COPYRIGHT
+=head1 TYPES STRINGS
 
-	Julien Delange <julien at gunnm dot org>
+my $typesstr = Vhffs::Constants::TYPES_STRINGS->{ OBJECT TYPE };
+
+=head1 TYPES STRINGS FOR FILESYSTEM
+
+my $typesstrfs = Vhffs::Constants::TYPES_STRINGS_FS->{ OBJECT TYPE };

Modified: trunk/vhffs-api/src/Vhffs/Robots/Repository.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Repository.pm	2012-02-12 18:37:03 UTC (rev 2007)
+++ trunk/vhffs-api/src/Vhffs/Robots/Repository.pm	2012-02-12 20:25:28 UTC (rev 2008)
@@ -76,7 +76,7 @@
 
 		# remove the link in group directory
 		my $group = Vhffs::Group::get_by_gid( $vhffs , $repo->get_owner_gid );
-		Vhffs::Robots::unlink_from_group( $group, $repo->get_name.Vhffs::Constants::REPOSITORY_SUFFIX, $vhffs );
+		Vhffs::Robots::unlink_from_group( $group, $repo->get_name.'-repository', $vhffs );
 
 		$repo->delete;
 	}
@@ -104,7 +104,7 @@
 
 	my $group = Vhffs::Group::get_by_gid( $vhffs , $repo->get_owner_gid );
 
-	if(Vhffs::Robots::link_to_group( $repodir, $group, $repo->get_name.Vhffs::Constants::REPOSITORY_SUFFIX, $vhffs ) < 0)
+	if(Vhffs::Robots::link_to_group( $repodir, $group, $repo->get_name.'-repository', $vhffs ) < 0)
 	{
 		$repo->add_history( "Can't link the download repository to the specified group");
 		return -3;

Modified: trunk/vhffs-api/src/Vhffs/Robots/Web.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2012-02-12 18:37:03 UTC (rev 2007)
+++ trunk/vhffs-api/src/Vhffs/Robots/Web.pm	2012-02-12 20:25:28 UTC (rev 2008)
@@ -66,7 +66,7 @@
 		chmod( 02775 , $webdir . "/tmp" );
 	
 		my $group = Vhffs::Group::get_by_gid( $main , $web->get_owner_gid );
-		if(Vhffs::Robots::link_to_group( $webdir,$group,$web->get_servername.Vhffs::Constants::WEB_SUFFIX,$main) < 0)
+		if(Vhffs::Robots::link_to_group( $webdir,$group,$web->get_servername.'-web',$main) < 0)
 		{
 			$web->add_history( "Can't link the webdirectory to the specified group");
 		}
@@ -94,7 +94,7 @@
 		$web->add_history( "Ok, the robot will delete this object. Web directory will be removed");
 		my $webdir = $web->get_dir;	
 		my $group = $web->get_group;
-		if(Vhffs::Robots::unlink_from_group( $group,$web->get_servername.Vhffs::Constants::WEB_SUFFIX,$main) < 0)
+		if(Vhffs::Robots::unlink_from_group( $group,$web->get_servername.'-web',$main) < 0)
 		{
 			$web->add_history( "Can't unlink the webdirectory from the specified group");
 		}

Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm	2012-02-12 18:37:03 UTC (rev 2007)
+++ trunk/vhffs-api/src/Vhffs/User.pm	2012-02-12 20:25:28 UTC (rev 2008)
@@ -171,7 +171,7 @@
 		my $homedir = $main->get_config->get_datadir.'/home/'.substr( $username, 0, 1 ).'/'.substr( $username, 1, 1 ).'/'.$username;
 
 		my $sth = $dbh->prepare('INSERT INTO vhffs_users (uid, gid, username, shell, passwd, homedir, admin, firstname, lastname, address, zipcode, city, country, mail, gpg_key, note, language, theme, lastloginpanel, object_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, ?, NULL, NULL, ?)');
-		$sth->execute($uid, $gid, $username, $userconf->{'default_shell'}, Vhffs::Functions::password_encrypt($password), $homedir, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, Vhffs::Constants::DEFAULT_LANG, $parent->get_oid);
+		$sth->execute($uid, $gid, $username, $userconf->{'default_shell'}, Vhffs::Functions::password_encrypt($password), $homedir, $admin, $firstname, $lastname, $address, $zipcode, $city, $country, $mail, $gpg_key, $main->get_config->get_default_language, $parent->get_oid);
 		
 		my $group = Vhffs::Group::create($main, $username, undef, $uid, $gid);
 		die('Error creating group') unless (defined $group);

Modified: trunk/vhffs-robots/src/repository_getquota.pl
===================================================================
--- trunk/vhffs-robots/src/repository_getquota.pl	2012-02-12 18:37:03 UTC (rev 2007)
+++ trunk/vhffs-robots/src/repository_getquota.pl	2012-02-12 20:25:28 UTC (rev 2008)
@@ -53,7 +53,7 @@
 my $repos;
 my $repo;
 my $su;
-my $dev = Quota::getqcarg($vhffs->get_config->get_datadir."/".Vhffs::Constants::REPOSITORYDIR);
+my $dev = Quota::getqcarg($vhffs->get_config->get_datadir.'/repository');
 
 foreach $group ( @{$groups} )
 {

Modified: trunk/vhffs-robots/src/repository_setquota.pl
===================================================================
--- trunk/vhffs-robots/src/repository_setquota.pl	2012-02-12 18:37:03 UTC (rev 2007)
+++ trunk/vhffs-robots/src/repository_setquota.pl	2012-02-12 20:25:28 UTC (rev 2008)
@@ -55,7 +55,7 @@
 my $repo;
 my $users;
 my $user;
-my $dev = Quota::getqcarg($vhffs->get_config->get_datadir."/".Vhffs::Constants::REPOSITORYDIR);
+my $dev = Quota::getqcarg($vhffs->get_config->get_datadir.'/repository');
 
 foreach $group ( @{$groups} )
 {


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