[vhffs-dev] [2093] renamed Vhffs::Main to Vhffs, renamed Vhffs::Panel::Main to Vhffs:: Panel |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 2093
Author: gradator
Date: 2012-03-02 21:55:43 +0100 (Fri, 02 Mar 2012)
Log Message:
-----------
renamed Vhffs::Main to Vhffs, renamed Vhffs::Panel::Main to Vhffs::Panel
Modified Paths:
--------------
trunk/vhffs-api/examples/add_acl.pl
trunk/vhffs-api/examples/add_acl_dns.pl
trunk/vhffs-api/examples/create_box.pl
trunk/vhffs-api/examples/create_cvs.pl
trunk/vhffs-api/examples/create_cvs_panel.pl
trunk/vhffs-api/examples/create_dns.pl
trunk/vhffs-api/examples/create_forward.pl
trunk/vhffs-api/examples/create_group.pl
trunk/vhffs-api/examples/create_group_by_panel.pl
trunk/vhffs-api/examples/create_list.pl
trunk/vhffs-api/examples/create_mail.pl
trunk/vhffs-api/examples/create_mysql.pl
trunk/vhffs-api/examples/create_mysql_panel.pl
trunk/vhffs-api/examples/create_panel_mail.pl
trunk/vhffs-api/examples/create_postgres.pl
trunk/vhffs-api/examples/create_repository.pl
trunk/vhffs-api/examples/create_user.pl
trunk/vhffs-api/examples/create_web.pl
trunk/vhffs-api/examples/create_web_panel.pl
trunk/vhffs-api/examples/delbox.pl
trunk/vhffs-api/examples/delete_acl.pl
trunk/vhffs-api/examples/generate_password.pl
trunk/vhffs-api/examples/get_list.pl
trunk/vhffs-api/examples/join_group.pl
trunk/vhffs-api/examples/list_themes.pl
trunk/vhffs-api/examples/mailuser.pl
trunk/vhffs-api/examples/mailuser_add_box.pl
trunk/vhffs-api/examples/modify_acl.pl
trunk/vhffs-api/examples/modify_user.pl
trunk/vhffs-api/examples/perm_for_user.pl
trunk/vhffs-api/examples/print_domain.pl
trunk/vhffs-api/examples/show_acl_per_object.pl
trunk/vhffs-api/examples/show_dns_per_group.pl
trunk/vhffs-api/examples/show_dns_per_user.pl
trunk/vhffs-api/examples/show_dumper_cvs.pl
trunk/vhffs-api/examples/show_dumper_group.pl
trunk/vhffs-api/examples/show_dumper_object.pl
trunk/vhffs-api/examples/show_dumper_user.pl
trunk/vhffs-api/examples/show_groups_per_user.pl
trunk/vhffs-api/examples/show_last_users.pl
trunk/vhffs-api/examples/show_mail_conf.pl
trunk/vhffs-api/examples/show_mail_per_group.pl
trunk/vhffs-api/examples/show_members_from_list.pl
trunk/vhffs-api/examples/stats.pl
trunk/vhffs-api/src/Makefile.am
trunk/vhffs-api/src/Vhffs/Broadcast.pm
trunk/vhffs-api/src/Vhffs/Group.pm
trunk/vhffs-api/src/Vhffs/Object.pm
trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm
trunk/vhffs-api/src/Vhffs/Panel/Commons.pm
trunk/vhffs-api/src/Vhffs/Panel/Group.pm
trunk/vhffs-api/src/Vhffs/Panel/Public.pm
trunk/vhffs-api/src/Vhffs/Panel/User.pm
trunk/vhffs-api/src/Vhffs/Robots.pm
trunk/vhffs-api/src/Vhffs/Services/DNS.pm
trunk/vhffs-api/src/Vhffs/Stats.pm
trunk/vhffs-api/src/Vhffs/Tag.pm
trunk/vhffs-api/src/Vhffs/User.pm
trunk/vhffs-api/src/Vhffs/UserGroup.pm
trunk/vhffs-compat/updatedb.pl
trunk/vhffs-cron/src/vhffscron.pl
trunk/vhffs-irc/modobot.pl
trunk/vhffs-jabber/vhffspipe.pl
trunk/vhffs-listengine/src/listengine.pl
trunk/vhffs-panel/index.pl
trunk/vhffs-public/index.pl
trunk/vhffs-robots/src/bazaar.pl
trunk/vhffs-robots/src/broadcast.pl
trunk/vhffs-robots/src/cron.pl
trunk/vhffs-robots/src/cvs.pl
trunk/vhffs-robots/src/dns.pl
trunk/vhffs-robots/src/git.pl
trunk/vhffs-robots/src/group.pl
trunk/vhffs-robots/src/group_quota.pl
trunk/vhffs-robots/src/mail.pl
trunk/vhffs-robots/src/mailinglist.pl
trunk/vhffs-robots/src/mailinglist_mhonarc.pl
trunk/vhffs-robots/src/mercurial.pl
trunk/vhffs-robots/src/mysql.pl
trunk/vhffs-robots/src/mysql_dump.pl
trunk/vhffs-robots/src/object_cleanup.pl
trunk/vhffs-robots/src/pgsql.pl
trunk/vhffs-robots/src/pgsql_dump.pl
trunk/vhffs-robots/src/repository.pl
trunk/vhffs-robots/src/repository_quota.pl
trunk/vhffs-robots/src/repository_stats.pl
trunk/vhffs-robots/src/svn.pl
trunk/vhffs-robots/src/user.pl
trunk/vhffs-robots/src/user_cleanup.pl
trunk/vhffs-robots/src/user_quota.pl
trunk/vhffs-robots/src/usergroup.pl
trunk/vhffs-robots/src/web.pl
trunk/vhffs-robots/src/web_stats.pl
trunk/vhffs-tools/src/vhffs-box-add
trunk/vhffs-tools/src/vhffs-dumpmysql
trunk/vhffs-tools/src/vhffs-groupadd
trunk/vhffs-tools/src/vhffs-groupdel
trunk/vhffs-tools/src/vhffs-groupinfo
trunk/vhffs-tools/src/vhffs-makeadmin
trunk/vhffs-tools/src/vhffs-managedns
trunk/vhffs-tools/src/vhffs-managemail
trunk/vhffs-tools/src/vhffs-moderate
trunk/vhffs-tools/src/vhffs-passwd
trunk/vhffs-tools/src/vhffs-quota
trunk/vhffs-tools/src/vhffs-useradd
trunk/vhffs-tools/src/vhffs-userdel
trunk/vhffs-tools/src/vhffs-userinfo
trunk/vhffs-tools/src/vhffs-usermod
trunk/vhffs-tools/src/vhffs-webdir
trunk/vhffs-tools/src/vhffs-webstats
Added Paths:
-----------
trunk/vhffs-api/src/Vhffs/Panel.pm
trunk/vhffs-api/src/Vhffs.pm
Removed Paths:
-------------
trunk/vhffs-api/src/Vhffs/Main.pm
trunk/vhffs-api/src/Vhffs/Panel/Main.pm
Modified: trunk/vhffs-api/examples/add_acl.pl
===================================================================
--- trunk/vhffs-api/examples/add_acl.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/add_acl.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,10 +5,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::Web;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 servername username level\n") if(@ARGV != 3);
Modified: trunk/vhffs-api/examples/add_acl_dns.pl
===================================================================
--- trunk/vhffs-api/examples/add_acl_dns.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/add_acl_dns.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::DNS;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 domain user level\n") unless(@ARGV == 3);
Modified: trunk/vhffs-api/examples/create_box.pl
===================================================================
--- trunk/vhffs-api/examples/create_box.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_box.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,10 +5,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::Mail;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 mail_domain local_part password\n") unless(@ARGV == 3);
Modified: trunk/vhffs-api/examples/create_cvs.pl
===================================================================
--- trunk/vhffs-api/examples/create_cvs.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_cvs.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Cvs;
@@ -48,7 +48,7 @@
my %infos;
my $group;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
$config = $princ->get_config;
Modified: trunk/vhffs-api/examples/create_cvs_panel.pl
===================================================================
--- trunk/vhffs-api/examples/create_cvs_panel.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_cvs_panel.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::Cvs;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 cvsroot description owner_username owner_groupname\n") unless(@ARGV == 4);
Modified: trunk/vhffs-api/examples/create_dns.pl
===================================================================
--- trunk/vhffs-api/examples/create_dns.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_dns.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,11 +7,11 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::DNS;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage $0 domain_name, description, user, group") unless(@ARGV == 4);
Modified: trunk/vhffs-api/examples/create_forward.pl
===================================================================
--- trunk/vhffs-api/examples/create_forward.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_forward.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,10 +5,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::Mail;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 mxdomain localpart remote_address\n") unless(@ARGV == 3);
Modified: trunk/vhffs-api/examples/create_group.pl
===================================================================
--- trunk/vhffs-api/examples/create_group.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_group.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 groupname owner_username description\n") unless(@ARGV == 3);
Modified: trunk/vhffs-api/examples/create_group_by_panel.pl
===================================================================
--- trunk/vhffs-api/examples/create_group_by_panel.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_group_by_panel.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,10 +5,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::Group;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 groupname owner_username decription\n") unless(@ARGV == 3);
Modified: trunk/vhffs-api/examples/create_list.pl
===================================================================
--- trunk/vhffs-api/examples/create_list.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_list.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,12 +7,12 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Mail;
use Vhffs::Services::MailingList;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 local_part domain admin_email description owner_username owner_groupname\n") unless(@ARGV == 6);
Modified: trunk/vhffs-api/examples/create_mail.pl
===================================================================
--- trunk/vhffs-api/examples/create_mail.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_mail.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,11 +7,11 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Mail;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage $0 domain description owner_username owner_groupname") if(@ARGV != 4);
my ($domain, $description, $username, $groupname) = @ARGV;
Modified: trunk/vhffs-api/examples/create_mysql.pl
===================================================================
--- trunk/vhffs-api/examples/create_mysql.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_mysql.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,11 +7,11 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Mysql;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 dbname dbuser dbpass description owner_username owner_groupname\n") unless(@ARGV == 6);
Modified: trunk/vhffs-api/examples/create_mysql_panel.pl
===================================================================
--- trunk/vhffs-api/examples/create_mysql_panel.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_mysql_panel.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::Mysql;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 dbname dbuser dbpass description owner_username owner_groupname\n") unless(@ARGV == 6);
Modified: trunk/vhffs-api/examples/create_panel_mail.pl
===================================================================
--- trunk/vhffs-api/examples/create_panel_mail.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_panel_mail.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,10 +7,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::Mail;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 domain description owner_username owner_groupname\n") unless(@ARGV == 4);
Modified: trunk/vhffs-api/examples/create_postgres.pl
===================================================================
--- trunk/vhffs-api/examples/create_postgres.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_postgres.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,11 +7,11 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Pgsql;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 dbname dbuser dbpass description user group\n") unless(@ARGV == 6);
Modified: trunk/vhffs-api/examples/create_repository.pl
===================================================================
--- trunk/vhffs-api/examples/create_repository.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_repository.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,11 +7,11 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Repository;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 reponame description username groupname\n") unless(@ARGV == 4);
Modified: trunk/vhffs-api/examples/create_user.pl
===================================================================
--- trunk/vhffs-api/examples/create_user.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_user.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 username password\n") unless(@ARGV == 2);
Modified: trunk/vhffs-api/examples/create_web.pl
===================================================================
--- trunk/vhffs-api/examples/create_web.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_web.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,11 +7,11 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Web;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 servername description owner_username owner_groupname\n") unless(@ARGV == 4);
Modified: trunk/vhffs-api/examples/create_web_panel.pl
===================================================================
--- trunk/vhffs-api/examples/create_web_panel.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/create_web_panel.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::Web;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 servername description owner_username owner_groupname\n") unless(@ARGV == 4);
Modified: trunk/vhffs-api/examples/delbox.pl
===================================================================
--- trunk/vhffs-api/examples/delbox.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/delbox.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -4,10 +4,10 @@
use strict;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::Mail;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 mail_domain box\n") unless(@ARGV == 2);
Modified: trunk/vhffs-api/examples/delete_acl.pl
===================================================================
--- trunk/vhffs-api/examples/delete_acl.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/delete_acl.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,11 +7,11 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Web;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 servername username\n") if(@ARGV != 2);
Modified: trunk/vhffs-api/examples/generate_password.pl
===================================================================
--- trunk/vhffs-api/examples/generate_password.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/generate_password.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,9 +6,9 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 username\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/get_list.pl
===================================================================
--- trunk/vhffs-api/examples/get_list.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/get_list.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,10 +5,10 @@
use lib '%VHFFS_LIB_DIR%';
use Data::Dumper;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::MailingList;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 mladdress\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/join_group.pl
===================================================================
--- trunk/vhffs-api/examples/join_group.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/join_group.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,9 +6,9 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 username groupname\n") unless(@ARGV == 2);
Modified: trunk/vhffs-api/examples/list_themes.pl
===================================================================
--- trunk/vhffs-api/examples/list_themes.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/list_themes.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -3,13 +3,13 @@
use strict;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Panel::Main;
-use Vhffs::Main;
+use Vhffs::Panel;
+use Vhffs;
use Data::Dumper;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
-my @themes = Vhffs::Panel::Main::list_themes( $vhffs );
+my @themes = Vhffs::Panel::list_themes( $vhffs );
foreach( @themes )
{
Modified: trunk/vhffs-api/examples/mailuser.pl
===================================================================
--- trunk/vhffs-api/examples/mailuser.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/mailuser.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,12 +7,12 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::MailUser;
use Vhffs::Panel::Mail;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 username\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/mailuser_add_box.pl
===================================================================
--- trunk/vhffs-api/examples/mailuser_add_box.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/mailuser_add_box.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,12 +7,12 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::MailUser;
use Vhffs::Panel::Mail;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 username password\n") unless(@ARGV == 2);
Modified: trunk/vhffs-api/examples/modify_acl.pl
===================================================================
--- trunk/vhffs-api/examples/modify_acl.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/modify_acl.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,10 +5,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::Web;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 servername username newlevel\n") unless(@ARGV == 3);
Modified: trunk/vhffs-api/examples/modify_user.pl
===================================================================
--- trunk/vhffs-api/examples/modify_user.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/modify_user.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,9 +5,9 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 username new_firstname\n") unless(@ARGV == 2);
Modified: trunk/vhffs-api/examples/perm_for_user.pl
===================================================================
--- trunk/vhffs-api/examples/perm_for_user.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/perm_for_user.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,12 +6,12 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Mysql;
use Vhffs::Services::Web;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 servername username\n") unless(@ARGV == 2);
Modified: trunk/vhffs-api/examples/print_domain.pl
===================================================================
--- trunk/vhffs-api/examples/print_domain.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/print_domain.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,10 +5,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::DNS;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 domainname\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/show_acl_per_object.pl
===================================================================
--- trunk/vhffs-api/examples/show_acl_per_object.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_acl_per_object.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,10 +5,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::Mysql;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 dbname\n\tShows ACL for MySQL service dbname\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/show_dns_per_group.pl
===================================================================
--- trunk/vhffs-api/examples/show_dns_per_group.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_dns_per_group.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::DNS;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 groupname\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/show_dns_per_user.pl
===================================================================
--- trunk/vhffs-api/examples/show_dns_per_user.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_dns_per_user.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::DNS;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 username\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/show_dumper_cvs.pl
===================================================================
--- trunk/vhffs-api/examples/show_dumper_cvs.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_dumper_cvs.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,7 +7,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Web;
use Vhffs::Panel::Group;
@@ -21,7 +21,7 @@
my $backend;
my %infos;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
$config = $princ->get_config;
Modified: trunk/vhffs-api/examples/show_dumper_group.pl
===================================================================
--- trunk/vhffs-api/examples/show_dumper_group.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_dumper_group.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,9 +6,9 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 groupname\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/show_dumper_object.pl
===================================================================
--- trunk/vhffs-api/examples/show_dumper_object.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_dumper_object.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,12 +7,12 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
use Vhffs::Services::Web;
use Vhffs::Panel::Group;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 objectID\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/show_dumper_user.pl
===================================================================
--- trunk/vhffs-api/examples/show_dumper_user.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_dumper_user.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,9 +6,9 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 username\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/show_groups_per_user.pl
===================================================================
--- trunk/vhffs-api/examples/show_groups_per_user.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_groups_per_user.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::Group;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 username\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/show_last_users.pl
===================================================================
--- trunk/vhffs-api/examples/show_last_users.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_last_users.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::User;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
my $users = Vhffs::Panel::User::get_last_users( $princ );
Modified: trunk/vhffs-api/examples/show_mail_conf.pl
===================================================================
--- trunk/vhffs-api/examples/show_mail_conf.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_mail_conf.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,7 +5,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Object;
my $config;
@@ -16,7 +16,7 @@
my $backend;
my %infos;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
$config = $princ->get_config;
my $cmail = $config->get_service( "dns" );
Modified: trunk/vhffs-api/examples/show_mail_per_group.pl
===================================================================
--- trunk/vhffs-api/examples/show_mail_per_group.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_mail_per_group.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -6,10 +6,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::Mail;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 groupname\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/show_members_from_list.pl
===================================================================
--- trunk/vhffs-api/examples/show_members_from_list.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/show_members_from_list.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -5,10 +5,10 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::MailingList;
-my $princ = init Vhffs::Main;
+my $princ = init Vhffs;
die("Usage: $0 mladdress\n") unless(@ARGV == 1);
Modified: trunk/vhffs-api/examples/stats.pl
===================================================================
--- trunk/vhffs-api/examples/stats.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/examples/stats.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -3,10 +3,10 @@
use strict;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Stats;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $stats = new Vhffs::Stats( $vhffs );
print "Users total : ";
Modified: trunk/vhffs-api/src/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Makefile.am 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Makefile.am 2012-03-02 20:55:43 UTC (rev 2093)
@@ -4,14 +4,15 @@
botsdir = @BOTSDIR@
files_do_sed = \
+ Vhffs.pm \
Vhffs/Acl.pm \
+ Vhffs/Broadcast.pm \
Vhffs/Conf.pm \
Vhffs/Constants.pm \
Vhffs/Functions.pm \
Vhffs/Group.pm \
Vhffs/Listengine.pm \
- Vhffs/Broadcast.pm \
- Vhffs/Main.pm \
+ Vhffs/Panel.pm \
Vhffs/ObjectFactory.pm \
Vhffs/Object.pm \
Vhffs/Robots.pm \
@@ -34,7 +35,6 @@
Vhffs/Panel/Mail.pm \
Vhffs/Panel/MailingList.pm \
Vhffs/Panel/Broadcast.pm \
- Vhffs/Panel/Main.pm \
Vhffs/Panel/Mercurial.pm \
Vhffs/Panel/Moderation.pm \
Vhffs/Panel/Mysql.pm \
Modified: trunk/vhffs-api/src/Vhffs/Broadcast.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Broadcast.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Broadcast.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -174,7 +174,7 @@
=head2 get_vhffs
-This method returns the Vhffs::Main object.
+This method returns the Vhffs object.
=cut
sub get_vhffs {
Modified: trunk/vhffs-api/src/Vhffs/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Group.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Group.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -45,8 +45,8 @@
=head1 SYNOPSIS
- use Vhffs::Main;
- my $vhffs = init Vhffs::Main or die();
+ use Vhffs;
+ my $vhffs = init Vhffs or die();
my $group = Vhffs::Group::get_by_groupname( $vhffs , 'mygroup' );
defined $group ? print "Group exists\n" : print "Group does not exist\n";
...
Deleted: trunk/vhffs-api/src/Vhffs/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Main.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Main.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -1,255 +0,0 @@
-# Copyright (c) vhffs project and its contributors
-# All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-#2. Redistributions in binary form must reproduce the above copyright
-# notice, this list of conditions and the following disclaimer in
-# the documentation and/or other materials provided with the
-# distribution.
-#3. Neither the name of vhffs nor the names of its contributors
-# may be used to endorse or promote products derived from this
-# software without specific prior written permission.
-#
-#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
-
-package Vhffs::Main;
-
-use strict;
-use utf8;
-use DBI;
-use Vhffs::Constants;
-use Vhffs::Functions;
-use Vhffs::Conf;
-
-=pod
-=head1 NAME
-
-Vhffs::Main - The Main class of Vhffs API, Config file access and Backend access
-
-=head1 SYNOPSIS
-
- use Vhffs::Main;
- my $vhffs = init Vhffs::Main or die();
- my $conf = $vhffs->get_config;
-
-=head1 DESCRIPTION
-
-The Vhffs::Main object is the main Vhffs class. When you
-invoke init Vhffs::Main, it creates a Vhffs::Main object that read configuration
-and create a Vhffs::Conf object then create by default a connection to backend.
-
-=head1 METHODS
-=cut
-
-=pod
-
-=head1 init( \%opts )
-
-my $vhffs = init Vhffs::Main( { backend => 1 } ) or die();
-
-=cut
-sub init {
- my $class = ref( $_[0] ) || $_[0];
- my $opt = $_[1];
-
- # First, config stuff
- my $config = new Vhffs::Conf( Vhffs::Constants::CONF_PATH );
- return undef unless defined $config;
-
- # Next, create the object
- my $self={};
- bless( $self , $class );
- $self->{'config'} = $config;
-
- # Finally, backend stuff
- $opt->{backend} = 1 unless defined $opt->{backend};
- if( $opt->{backend} and not defined $self->connect ) {
- undef $self;
- return undef;
- }
-
- return $self;
-}
-
-=pod
-
-=head1 get_db
-
-my $dbh = $vhffs->get_db;
-
-Returns a C<DBI> object if backend was connected, otherwise returns undef.
-
-=cut
-sub get_db {
- my $self = shift;
- return $self->{'db'};
-}
-
-=pod
-
-=head1 get_config
-
-my $config = $vhffs->get_cofig;
-
-Returns a C<Vhffs::Conf> object.
-
-=cut
-sub get_config {
- my $self = shift;
- return $self->{'config'};
-}
-
-=pod
-
-=head1 connect
-
-my $dbh = $vhffs->connect;
-
-Connect to backend, should only be used once, and only if backend was set to false in constructor options.
-
-Returns a C<DBI> object if connection succeded, otherwise returns undef.
-
-=cut
-sub connect {
- my $self = shift;
- my $config = $self->{config}->get_database();
-
- unless( defined $config ) {
- warn 'Oops!: I wonder if I am blind but I cannot find the backend area in the Vhffs configuration file :/, could you help me ?'."\n";
- return undef;
- }
-
- if( $config->{'driver'} eq 'pg' ) {
- my $port = ( $config->{'db_port'} or '5432' );
- my $host = ( $config->{'db_host'} or 'localhost' );
-
- my $dbh = DBI->connect('DBI:Pg:dbname='.$config->{'db_name'}.';host='.$host.';port='.$port, $config->{'db_username'}, $config->{'db_password'}, {pg_enable_utf8 => 1} );
- return undef unless defined $dbh;
- $dbh->do( 'SET CLIENT_ENCODING TO \'UTF8\'' );
- $self->{'db'} = $dbh;
- return $dbh;
- }
-
- warn 'Oops!: The specified backend in the configuration file is not supported by Vhffs'."\n";
- return undef;
-}
-
-=pod
-
-=head1 is_connected
-
-my $connected = $vhffs->is_connected;
-
-Returns true if backend connection is alive, otherwise return false.
-
-=cut
-sub is_connected {
- my $self = shift;
- return (defined $self->{db} and $self->{db}->ping() > 0);
-}
-
-=pod
-
-=head1 reconnect
-
-my $dbh = $vhffs->reconnect;
-
-Reconnect to the database if necessary.
-
-Returns a C<DBI> object if everything went fine, otherwise returns undef.
-
-=cut
-sub reconnect {
- my $self = shift;
- return $self->{db} if defined $self->{db} and $self->{db}->ping() > 0;
- $self->{db}->disconnect if defined $self->{db};
- return $self->connect;
-}
-
-=pod
-
-=head1 set_current_user
-
-$vhffs->set_current_user( $user );
-
-Set current user using the API (used for C<Vhffs::Object::add_history>)
-
-=cut
-sub set_current_user {
- my $self = shift;
- my $user = shift;
- $self->{current_user} = $user if defined $user;
- return $user;
-}
-
-=pod
-
-=head1 get_current_user
-
-my $user = $vhffs->get_current_user;
-
-Get current user using the API (used for C<Vhffs::Object::add_history>)
-
-=cut
-sub get_current_user {
- my $self = shift;
- return $self->{current_user};
-}
-
-=pod
-
-=head1 clear_current_user
-
-$vhffs->clear_current_user;
-
-Clear current user using the API. You should use it if Vhffs main class
-is persistent and potentially used by more than one user.
-
-=cut
-sub clear_current_user {
- my $self = shift;
- delete $self->{current_user};
-}
-
-=pod
-
-=head1 get_stats
-
-my $stats = $vhffs->get_stats;
-
-Returns and caches a C<Vhffs::Stats> object.
-
-$time is an optional parameter, default to 3600, the cache is not going to be flushed if data were not flushed $time seconds ago.
-
-=cut
-sub get_stats {
- my $self = shift;
- my $time = shift;
- require Vhffs::Stats;
- $self->{stats} = new Vhffs::Stats( $self ) unless defined $self->{stats};
- $self->{stats}->flush( defined $time ? $time : 3600 );
- return $self->{stats};
-}
-
-1;
-
-__END__
-
-=head1 SEE ALSO
-Vhffs::User, Vhffs::Group
Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Object.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -100,7 +100,7 @@
=over 4
-=item C<$vhffs>: C<Vhffs::Main> instance
+=item C<$vhffs>: C<Vhffs> instance
=item C<$owner_uid>: UID of the owner.
@@ -158,7 +158,7 @@
=pod
-=head2 getall( Vhffs::Main , $name )
+=head2 getall( Vhffs , $name )
The getall is very important and defined in every service. In Vhffs::Object,
it returns all object if $name is not defined (undef). Return all objects that matches with $name if $name is defined.
@@ -285,8 +285,8 @@
=head2 get_vhffs
-This method returns the Vhffs::Main object contained in this object.
-This method can be useful if you have an object and you need a Vhffs::Main instance.
+This method returns the Vhffs object contained in this object.
+This method can be useful if you have an object and you need a Vhffs instance.
=cut
sub get_vhffs {
Modified: trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Panel/Avatar.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -263,10 +263,10 @@
=head1 SYNOPSIS
- use Vhffs::Main;
+ use Vhffs;
use Vhffs::Panel::Avatar;
- my $vhffs = init Vhffs::Main;
+ my $vhffs = init Vhffs;
....
(considers that you create or handle an object in $object var)
Modified: trunk/vhffs-api/src/Vhffs/Panel/Commons.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Commons.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Panel/Commons.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -130,7 +130,7 @@
=over 4
-=item C<$vhffs>: Vhffs::Main instance;
+=item C<$vhffs>: Vhffs instance;
=item C<$select>: C<"SELECT"> clause of the query, will be replaced with C<"SELECT COUNT(*)"> to
get the total count;
Modified: trunk/vhffs-api/src/Vhffs/Panel/Group.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Group.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Panel/Group.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -190,7 +190,7 @@
=item $user: Vhffs::User owner of the group (must be registered
in DB).
-=item $vhffs: Vhffs::Main instance
+=item $vhffs: Vhffs instance
=cut
Deleted: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -1,547 +0,0 @@
-#!%PERL% -w
-
-package Vhffs::Panel::Main;
-require Exporter;
-@ISA = qw(Exporter);
-@EXPORT = qw( display );
-
-use strict;
-use utf8;
-use POSIX qw(locale_h);
-use locale;
-use Locale::gettext;
-use CGI::Session;
-use File::Spec;
-use Encode;
-use Template;
-
-use Vhffs::Main;
-use Vhffs::User;
-use Vhffs::Group;
-use Vhffs::Functions;
-use Vhffs::Constants;
-use Vhffs::Panel::User;
-use Vhffs::Panel::Auth;
-
-=pod
-
-=head1 NAME
-
-Vhffs::Panel::Main - Provides acces to common VHFFS
-functionnalities from Vhffs Panel.
-
-=head1 SYNOPSIS
-
-TODO
-
-=head1 METHODS
-
-=cut
-
-=pod
-
-=head2 check_public
-
- $panel->check_public;
-
-Checks that public area is available, if it's not the case show a message and returns.
-
-=cut
-sub check_public {
- my $panel = shift;
- return $panel->{vhffs}->get_config->get_panel->{'use_public'};
-}
-
-=pod
-
-=head2 is_open
-
- $panel->is_open;
-
-Return 1 if panel is open, else return 0
-
-=cut
-sub is_open {
- my $panel = shift;
- return $panel->{vhffs}->get_config->get_panel->{'open'};
-}
-
-=pod
-
-=head2 is_public
-
- $panel->is_public;
-
-Return 1 if public part is enabled, else return 0
-
-=cut
-sub is_public {
- my $panel = shift;
- return $panel->{vhffs}->get_config->get_panel->{'use_public'};
-}
-
-=pod
-
-=head2 use_avatars
-
- $panel->use_avatars;
-
-Return 1 if either or both users or groups avatars are enabled, else return 0
-
-=cut
-sub use_avatars {
- my $panel = shift;
- return ( $panel->{vhffs}->get_config->get_panel->{'users_avatars'} or $panel->{vhffs}->get_config->get_panel->{'groups_avatars'} );
-}
-
-=pod
-
-=head2 use_users_avatars
-
- $panel->use_users_avatars;
-
-Return 1 if users avatars are enabled, else return 0
-
-=cut
-sub use_users_avatars {
- my $panel = shift;
- return $panel->{vhffs}->get_config->get_panel->{'users_avatars'};
-}
-
-=pod
-
-=head2 use_groups_avatars
-
- $panel->use_groups_avatars;
-
-Return 1 if groups avatars are enabled, else return 0
-
-=cut
-sub use_groups_avatars {
- my $panel = shift;
- return $panel->{vhffs}->get_config->get_panel->{'groups_avatars'};
-}
-
-=pod
-
-
-=head2 check_modo
-
- $panel->check_modo
-
-Checks that logged in user is admin or moderator. If it is
-not the case, show a message and returns.
-
-=cut
-
-sub check_modo {
- my $panel = shift;
- my $user = $panel->{user};
- unless($user->is_moderator or $user->is_admin) {
- $panel->set_title( gettext('Access denied') );
- $panel->render('misc/message.tt', { message => gettext('You are not allowed to access this page') });
- return 0;
- }
- $panel->{display_admin_menu} = 1;
- return 1;
-}
-
-=head2
-
- $panel->check_admin
-
-Check that logged in user is an admin. If it is not
-the case, show a message and returns.
-
-=cut
-
-sub check_admin {
- my $panel = shift;
- my $user = $panel->{user};
- unless($user->is_admin) {
- $panel->set_title( gettext('Access denied') );
- $panel->render('misc/message.tt', { message => gettext('You are not allowed to access this page') });
- return 0;
- }
- $panel->{display_admin_menu} = 1;
- return 1;
-}
-
-sub list_themes {
- my $vhffs = shift;
- return -1 unless defined $vhffs;
-
- my @themes;
-
- my $dir = $vhffs->get_config->get_panel->{'themesdir'};
- return undef unless defined $dir;
-
- opendir( DIR , $dir) or return -2;
- my @files = readdir( DIR );
- foreach( @files )
- {
- next if( /\./);
- if( -d $dir."/".$_ )
- {
- push @themes , $_;
- }
- }
-
- closedir( DIR );
- return @themes;
-}
-
-
-sub list_languages {
- my $vhffs = shift;
- return -1 if( ! defined $vhffs );
-
- return $vhffs->get_config->get_available_languages;
-}
-
-
-
-sub new
-{
- my $class = ref($_[0]) || $_[0];
- my $vhffs = $_[1];
- my $cgi = $_[2];
-
- return undef unless( defined $vhffs and defined $cgi );
-
- $vhffs->clear_current_user;
- $cgi->charset('UTF-8');
-
- my $self = {};
- bless( $self, $class );
- $self->{errors} = [];
- $self->{infos} = [];
- $self->{cookies} = [];
- $self->{vhffs} = $vhffs;
- $self->{cgi} = $cgi;
- $self->{url} = $cgi->url();
- $self->{display_admin_menu} = 0;
-
- my $config = $vhffs->get_config;
- $self->{config} = $config;
- my $templatedir = $config->get_templatedir;
- $self->{templatedir} = $templatedir;
-
- # lang cookie
- my $lang = $cgi->param('lang');
- $self->add_cookie( $cgi->cookie( -name=>'language', -value=>$lang, -expires=>'+10y' ) ) if defined $lang;
- $lang = $cgi->cookie('language') unless defined $lang;
- $lang = $vhffs->get_config->get_default_language() unless defined $lang;
- $lang = 'en_US' unless defined $lang;
- $self->{lang} = $lang;
-
- setlocale(LC_ALL, $lang );
- bindtextdomain('vhffs', '%localedir%');
- textdomain('vhffs');
-
- # theme cookie
- my $theme = $cgi->param('theme');
- $self->add_cookie( $cgi->cookie( -name=>'theme', -value=>$theme, -expires=>'+10y' ) ) if defined $theme;
- $theme = $cgi->cookie('theme') unless defined $theme;
- $theme = $config->get_panel->{'default_theme'} unless defined $theme;
- $theme = 'vhffs' unless( defined $theme and -f $config->get_panel->{'themesdir'}.'/'.$theme.'/main.css' );
-
- # theme feature is more or less deprecated since we never had more than one theme working, let me force to the current theme
- $self->{theme} = 'light-grey';
-
- unless( $vhffs->reconnect() and $vhffs->get_config->get_panel->{'open'} ) {
- $self->render('misc/closed.tt', undef, 'anonymous.tt');
- undef $self;
- return undef;
- }
-
- $self->{is_ajax_request} = (defined $self->{cgi}->http('X-Requested-With')
- and $self->{cgi}->http('X-Requested-With') eq 'XMLHttpRequest');
-
- return $self;
-}
-
-sub get_session {
- my $panel = shift;
- my $vhffs = $panel->{vhffs};
- my $cgi = $panel->{cgi};
-
- my $sid = $cgi->cookie( CGI::Session::name() );
- unless( defined $sid ) {
- $panel->add_error( gettext('No cookie found, please accept the cookie and then please login again !') );
- Vhffs::Panel::Auth::display_login( $panel );
- return undef;
- }
-
- my $session = new CGI::Session( undef, $sid, {Directory=>'/tmp'} );
- unless( defined $session ) {
- $panel->add_error( gettext('Cannot create or fetch session file, please check that /tmp is readable and writeable') );
- Vhffs::Panel::Auth::display_login( $panel );
- return undef;
- }
-
- my $username = $session->param('username');
- my $uid = $session->param('uid');
- unless( defined $username && defined $uid && !$session->is_new() ) {
- $panel->add_error( gettext('Expired session ! Please login again') );
- $session->delete();
- Vhffs::Panel::Auth::display_login( $panel );
- return undef;
- }
-
- my $user = Vhffs::User::get_by_uid($vhffs, $uid);
- unless ( defined $user ) {
- $panel->add_error( gettext('User does not exist') );
- $session->delete();
- Vhffs::Panel::Auth::display_login( $panel );
- return undef;
- }
-
- unless( $user->get_status == Vhffs::Constants::ACTIVATED ) {
- $panel->add_error( gettext('You\'re are not allowed to browse panel') );
- $session->delete();
- Vhffs::Panel::Auth::display_login( $panel );
- return undef;
- }
-
- $panel->{session} = $session;
- $panel->{user} = $user;
- $vhffs->set_current_user( $user );
-
- return $session;
-}
-
-sub set_group {
- my $panel = shift;
- $panel->{group} = shift;
-}
-
-sub has_errors {
- my $panel = shift;
- return (@{$panel->{errors}} > 0);
-}
-
-sub set_title {
- my ($panel, $title) = @_;
- $panel->{title} = $title;
-}
-
-sub add_error {
- my ($panel, $error) = @_;
- # TODO Do not use anonymous hash when Template::Toolkit transition is over.
- push(@{$panel->{errors}}, {msg => $error});
-}
-
-sub add_info {
- my ($panel, $info) = @_;
- # TODO Do not use anonymous hash when Template::Toolkit transition is over.
- push(@{$panel->{infos}}, {msg => $info});
-}
-
-sub add_cookie {
- my ($panel, $cookie) = @_;
- push(@{$panel->{cookies}}, $cookie);
-}
-
-sub clear_infos {
- my $panel = shift;
- $panel->{infos} = [];
-}
-
-=head2 $panel->render($file, $vars, $layout)
-
-Renders given template with substitution variables C<$vars>.
-
-If no C<$layout> is provided, C<layouts/panel.tt> will be used
-otherwise C<$layout> should be the name of the layout relative
-to the C<layouts> folder.
-
-If request was made through Ajax, no layout will be processed.
-
-B<This function never return>.
-
-=cut
-
-
-sub render {
- my ($self, $file, $vars, $layout, $include_path) = @_;
- my $vhffs = $self->{vhffs};
- my $conf = $vhffs->get_config;
- my $cgi = $self->{cgi};
- $vhffs->clear_current_user;
-
- # TODO Should be in parent class when Template::Toolkit switch is over
- my $create_vars = {
- INCLUDE_PATH => $self->{templatedir}.(defined $include_path ? '/'.$include_path.'/' : '/panel/'),
- CONSTANTS => {
- vhffs => {
- VERSION => Vhffs::Constants::VHFFS_VERSION,
- RELEASE_NAME => Vhffs::Constants::VHFFS_RELEASE_NAME,
- },
- object_statuses => {
- WAITING_FOR_VALIDATION => Vhffs::Constants::WAITING_FOR_VALIDATION,
- VALIDATION_REFUSED => Vhffs::Constants::VALIDATION_REFUSED,
- WAITING_FOR_CREATION => Vhffs::Constants::WAITING_FOR_CREATION,
- CREATION_ERROR => Vhffs::Constants::CREATION_ERROR,
- ACTIVATED => Vhffs::Constants::ACTIVATED,
- SUSPEND_PENDING => Vhffs::Constants::SUSPEND_PENDING,
- SUSPENDED => Vhffs::Constants::SUSPENDED,
- WAITING_FOR_MODIFICATION => Vhffs::Constants::WAITING_FOR_MODIFICATION,
- MODIFICATION_ERROR => Vhffs::Constants::MODIFICATION_ERROR,
- WAITING_FOR_DELETION => Vhffs::Constants::WAITING_FOR_DELETION,
- DELETION_ERROR => Vhffs::Constants::DELETION_ERROR
- },
- user_permissions => {
- NORMAL => Vhffs::Constants::USER_NORMAL,
- MODERATOR => Vhffs::Constants::USER_MODERATOR,
- ADMIN => Vhffs::Constants::USER_ADMIN
- },
- acl => {
- UNDEFINED => Vhffs::Constants::ACL_UNDEFINED,
- DENIED => Vhffs::Constants::ACL_DENIED,
- VIEW => Vhffs::Constants::ACL_VIEW,
- MODIFY => Vhffs::Constants::ACL_MODIFY,
- MANAGEACL => Vhffs::Constants::ACL_MANAGEACL,
- DELETE => Vhffs::Constants::ACL_DELETE
- },
- mailinglist => {
- SUBSCRIBE_NO_APPROVAL_REQUIRED => Vhffs::Constants::ML_SUBSCRIBE_NO_APPROVAL_REQUIRED,
- SUBSCRIBE_APPROVAL_REQUIRED => Vhffs::Constants::ML_SUBSCRIBE_APPROVAL_REQUIRED,
- SUBSCRIBE_CLOSED => Vhffs::Constants::ML_SUBSCRIBE_CLOSED,
- POSTING_OPEN_ALL => Vhffs::Constants::ML_POSTING_OPEN_ALL,
- POSTING_MODERATED_ALL => Vhffs::Constants::ML_POSTING_MODERATED_ALL,
- POSTING_OPEN_MEMBERS_MODERATED_OTHERS => Vhffs::Constants::ML_POSTING_OPEN_MEMBERS_MODERATED_OTHERS,
- POSTING_MEMBERS_ONLY => Vhffs::Constants::ML_POSTING_MEMBERS_ONLY,
- POSTING_MEMBERS_ONLY_MODERATED => Vhffs::Constants::ML_POSTING_MEMBERS_ONLY_MODERATED,
- POSTING_ADMINS_ONLY => Vhffs::Constants::ML_POSTING_ADMINS_ONLY,
- RIGHT_SUB_WAITING_FOR_REPLY => Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_REPLY,
- RIGHT_SUB_WAITING_FOR_VALIDATION => Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_VALIDATION,
- RIGHT_SUB => Vhffs::Constants::ML_RIGHT_SUB,
- RIGHT_SUB_WAITING_FOR_DEL => Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_DEL,
- RIGHT_ADMIN => Vhffs::Constants::ML_RIGHT_ADMIN
- }
- },
- FILTERS => {
- i18n => \&gettext,
- mail => sub {
- return Vhffs::Functions::obfuscate_email($vhffs, $_[0]);
- },
- # Format filter accept only one argument
- # pretty_print can 'sprintf' anything, use it as
- # [% '%s is $%d' | pretty_print(article, price)]
- pretty_print => [sub {
- my $context = shift;
- my @args = @_;
- return sub {
- my $format = shift;
- return sprintf($format, @args);
- }
- }, 1],
- stringify_status => sub {
- return Vhffs::Functions::status_string_from_status_id( $_[0] );
- },
- stringify_type => sub {
- Vhffs::Functions::type_string_from_type_id( $_[0] );
- },
- idn_to_unicode => sub {
- require Net::LibIDN;
- Encode::decode_utf8( Net::LibIDN::idn_to_unicode( $_[0] , 'utf-8') );
- },
- },
- PRE_CHOMP => 2
- };
-
- $vars = {} unless(defined $vars);
-
- my $query_string = '';
- foreach( my @params = $cgi->url_param ) {
- my $p = $cgi->url_param($_);
- $query_string .= $_.'='.$p.';' if defined $p and $_ ne 'lang' and $_ ne 'theme';
- }
- chop $query_string;
- undef $query_string unless $query_string;
-
- $vars->{do} = $cgi->url_param('do');
- $vars->{query_string} = $query_string;
- $vars->{theme} = $self->{theme};
- $vars->{panel_url} = $conf->get_panel->{url};
- $vars->{title} = sprintf( gettext( '%s\'s Panel' ), $conf->get_host_name );
- $vars->{page_title} = $self->{title};
- $vars->{public_url} = $vhffs->get_config->get_panel->{'url_public'} if $self->is_public;
- $vars->{msg} = Encode::decode_utf8($self->{cgi}->param('msg')) if defined $self->{cgi}->param('msg');
- my @langs = $vhffs->get_config->get_available_languages;
- $vars->{languages} = \@langs;
- $vars->{language} = $self->{lang};
- $vars->{errors} = $self->{errors};
- $vars->{infos} = $self->{infos};
- $vars->{current_user} = $self->{user};
- $vars->{current_group} = $self->{group};
-
- # Handling ajax stuff
- if($self->{is_ajax_request}) {
- delete $create_vars->{PROCESS};
- } else {
- if(defined $layout) {
- $create_vars->{PROCESS} = 'layouts/'.$layout;
- } else {
- $create_vars->{PROCESS} = 'layouts/panel.tt';
- $vars->{panel_header} = {
- help_url => $conf->get_panel->{'url_help'} || 'http://www.vhffs.org/',
- admin_menu => $self->{display_admin_menu},
- available_services => $conf->get_available_services
- };
- }
- }
-
- my $template = new Template($create_vars);
-
- my $http_accept = ( $cgi->http('HTTP_ACCEPT') or '' );
- print $cgi->header( -cookie=>[ @{$self->{cookies}} ], -type=>( $http_accept =~ /application\/xhtml\+xml/ ? 'application/xhtml+xml' : 'text/html' ), -charset=>'utf-8' );
-
- my $data;
- unless( $template->process($file, $vars, \$data) ) {
- warn 'Error while processing template: '.$template->error();
- return;
- }
- # FCGI does not handle UTF9
- print Encode::encode_utf8( $data );
-}
-
-=pod
-
-=head2 redirect
-
- $panel->redirect($page, $cookies);
-
-Issues a redirection header sending to $page
-(you can specify additional cookies to be sent).
-
-This function never returns.
-
-B<C<$page> should be an absolute path>
-
-B<C<$cookies>> can be a CGI::Cookie or a reference
-to a CGI::Cookie array.
-
-=cut
-sub redirect {
- my ($panel, $dest, $cookies) = @_;
- my $vhffs = $panel->{vhffs};
- my $cgi = $panel->{cgi};
- $vhffs->clear_current_user;
-
- $dest = Encode::encode_utf8( $dest );
-
- if(defined $cookies) {
- if(ref($cookies)) {
- foreach(@$cookies) {
- print "Set-Cookie: $_\n";
- }
- } else {
- print "Set-Cookie: $cookies\n";
- }
- }
- print $cgi->redirect($dest);
-}
-
-1;
Modified: trunk/vhffs-api/src/Vhffs/Panel/Public.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Public.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Panel/Public.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -34,7 +34,7 @@
package Vhffs::Panel::Public;
-use base qw(Vhffs::Panel::Main);
+use base qw(Vhffs::Panel);
use locale;
use Locale::gettext;
Modified: trunk/vhffs-api/src/Vhffs/Panel/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/User.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Panel/User.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -41,8 +41,8 @@
use Vhffs::Constants;
use Vhffs::User;
-use Vhffs::Main;
-use Vhffs::Panel::Main;
+use Vhffs;
+use Vhffs::Panel;
use Vhffs::Panel::User;
use Vhffs::Panel::Object;
use Vhffs::Services::MailUser;
@@ -611,7 +611,7 @@
$panel->set_title( gettext('User Preferences') );
$vars->{user} = $userp;
$vars->{current_language} = Vhffs::Panel::User::get_lang( $userp );
- my @themes = Vhffs::Panel::Main::list_themes( $vhffs );
+ my @themes = Vhffs::Panel::list_themes( $vhffs );
$vars->{themes} = \@themes;
$vars->{current_theme} = Vhffs::Panel::User::get_theme( $userp );
$vars->{user_help_url} = $vhffs->get_config->get_users()->{url_doc};
Copied: trunk/vhffs-api/src/Vhffs/Panel.pm (from rev 2091, trunk/vhffs-api/src/Vhffs/Panel/Main.pm)
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel.pm (rev 0)
+++ trunk/vhffs-api/src/Vhffs/Panel.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -0,0 +1,547 @@
+#!%PERL% -w
+
+package Vhffs::Panel;
+require Exporter;
+@ISA = qw(Exporter);
+@EXPORT = qw( display );
+
+use strict;
+use utf8;
+use POSIX qw(locale_h);
+use locale;
+use Locale::gettext;
+use CGI::Session;
+use File::Spec;
+use Encode;
+use Template;
+
+use Vhffs;
+use Vhffs::User;
+use Vhffs::Group;
+use Vhffs::Functions;
+use Vhffs::Constants;
+use Vhffs::Panel::User;
+use Vhffs::Panel::Auth;
+
+=pod
+
+=head1 NAME
+
+Vhffs::Panel - Provides acces to common VHFFS
+functionnalities from Vhffs Panel.
+
+=head1 SYNOPSIS
+
+TODO
+
+=head1 METHODS
+
+=cut
+
+=pod
+
+=head2 check_public
+
+ $panel->check_public;
+
+Checks that public area is available, if it's not the case show a message and returns.
+
+=cut
+sub check_public {
+ my $panel = shift;
+ return $panel->{vhffs}->get_config->get_panel->{'use_public'};
+}
+
+=pod
+
+=head2 is_open
+
+ $panel->is_open;
+
+Return 1 if panel is open, else return 0
+
+=cut
+sub is_open {
+ my $panel = shift;
+ return $panel->{vhffs}->get_config->get_panel->{'open'};
+}
+
+=pod
+
+=head2 is_public
+
+ $panel->is_public;
+
+Return 1 if public part is enabled, else return 0
+
+=cut
+sub is_public {
+ my $panel = shift;
+ return $panel->{vhffs}->get_config->get_panel->{'use_public'};
+}
+
+=pod
+
+=head2 use_avatars
+
+ $panel->use_avatars;
+
+Return 1 if either or both users or groups avatars are enabled, else return 0
+
+=cut
+sub use_avatars {
+ my $panel = shift;
+ return ( $panel->{vhffs}->get_config->get_panel->{'users_avatars'} or $panel->{vhffs}->get_config->get_panel->{'groups_avatars'} );
+}
+
+=pod
+
+=head2 use_users_avatars
+
+ $panel->use_users_avatars;
+
+Return 1 if users avatars are enabled, else return 0
+
+=cut
+sub use_users_avatars {
+ my $panel = shift;
+ return $panel->{vhffs}->get_config->get_panel->{'users_avatars'};
+}
+
+=pod
+
+=head2 use_groups_avatars
+
+ $panel->use_groups_avatars;
+
+Return 1 if groups avatars are enabled, else return 0
+
+=cut
+sub use_groups_avatars {
+ my $panel = shift;
+ return $panel->{vhffs}->get_config->get_panel->{'groups_avatars'};
+}
+
+=pod
+
+
+=head2 check_modo
+
+ $panel->check_modo
+
+Checks that logged in user is admin or moderator. If it is
+not the case, show a message and returns.
+
+=cut
+
+sub check_modo {
+ my $panel = shift;
+ my $user = $panel->{user};
+ unless($user->is_moderator or $user->is_admin) {
+ $panel->set_title( gettext('Access denied') );
+ $panel->render('misc/message.tt', { message => gettext('You are not allowed to access this page') });
+ return 0;
+ }
+ $panel->{display_admin_menu} = 1;
+ return 1;
+}
+
+=head2
+
+ $panel->check_admin
+
+Check that logged in user is an admin. If it is not
+the case, show a message and returns.
+
+=cut
+
+sub check_admin {
+ my $panel = shift;
+ my $user = $panel->{user};
+ unless($user->is_admin) {
+ $panel->set_title( gettext('Access denied') );
+ $panel->render('misc/message.tt', { message => gettext('You are not allowed to access this page') });
+ return 0;
+ }
+ $panel->{display_admin_menu} = 1;
+ return 1;
+}
+
+sub list_themes {
+ my $vhffs = shift;
+ return -1 unless defined $vhffs;
+
+ my @themes;
+
+ my $dir = $vhffs->get_config->get_panel->{'themesdir'};
+ return undef unless defined $dir;
+
+ opendir( DIR , $dir) or return -2;
+ my @files = readdir( DIR );
+ foreach( @files )
+ {
+ next if( /\./);
+ if( -d $dir."/".$_ )
+ {
+ push @themes , $_;
+ }
+ }
+
+ closedir( DIR );
+ return @themes;
+}
+
+
+sub list_languages {
+ my $vhffs = shift;
+ return -1 if( ! defined $vhffs );
+
+ return $vhffs->get_config->get_available_languages;
+}
+
+
+
+sub new
+{
+ my $class = ref($_[0]) || $_[0];
+ my $vhffs = $_[1];
+ my $cgi = $_[2];
+
+ return undef unless( defined $vhffs and defined $cgi );
+
+ $vhffs->clear_current_user;
+ $cgi->charset('UTF-8');
+
+ my $self = {};
+ bless( $self, $class );
+ $self->{errors} = [];
+ $self->{infos} = [];
+ $self->{cookies} = [];
+ $self->{vhffs} = $vhffs;
+ $self->{cgi} = $cgi;
+ $self->{url} = $cgi->url();
+ $self->{display_admin_menu} = 0;
+
+ my $config = $vhffs->get_config;
+ $self->{config} = $config;
+ my $templatedir = $config->get_templatedir;
+ $self->{templatedir} = $templatedir;
+
+ # lang cookie
+ my $lang = $cgi->param('lang');
+ $self->add_cookie( $cgi->cookie( -name=>'language', -value=>$lang, -expires=>'+10y' ) ) if defined $lang;
+ $lang = $cgi->cookie('language') unless defined $lang;
+ $lang = $vhffs->get_config->get_default_language() unless defined $lang;
+ $lang = 'en_US' unless defined $lang;
+ $self->{lang} = $lang;
+
+ setlocale(LC_ALL, $lang );
+ bindtextdomain('vhffs', '%localedir%');
+ textdomain('vhffs');
+
+ # theme cookie
+ my $theme = $cgi->param('theme');
+ $self->add_cookie( $cgi->cookie( -name=>'theme', -value=>$theme, -expires=>'+10y' ) ) if defined $theme;
+ $theme = $cgi->cookie('theme') unless defined $theme;
+ $theme = $config->get_panel->{'default_theme'} unless defined $theme;
+ $theme = 'vhffs' unless( defined $theme and -f $config->get_panel->{'themesdir'}.'/'.$theme.'/main.css' );
+
+ # theme feature is more or less deprecated since we never had more than one theme working, let me force to the current theme
+ $self->{theme} = 'light-grey';
+
+ unless( $vhffs->reconnect() and $vhffs->get_config->get_panel->{'open'} ) {
+ $self->render('misc/closed.tt', undef, 'anonymous.tt');
+ undef $self;
+ return undef;
+ }
+
+ $self->{is_ajax_request} = (defined $self->{cgi}->http('X-Requested-With')
+ and $self->{cgi}->http('X-Requested-With') eq 'XMLHttpRequest');
+
+ return $self;
+}
+
+sub get_session {
+ my $panel = shift;
+ my $vhffs = $panel->{vhffs};
+ my $cgi = $panel->{cgi};
+
+ my $sid = $cgi->cookie( CGI::Session::name() );
+ unless( defined $sid ) {
+ $panel->add_error( gettext('No cookie found, please accept the cookie and then please login again !') );
+ Vhffs::Panel::Auth::display_login( $panel );
+ return undef;
+ }
+
+ my $session = new CGI::Session( undef, $sid, {Directory=>'/tmp'} );
+ unless( defined $session ) {
+ $panel->add_error( gettext('Cannot create or fetch session file, please check that /tmp is readable and writeable') );
+ Vhffs::Panel::Auth::display_login( $panel );
+ return undef;
+ }
+
+ my $username = $session->param('username');
+ my $uid = $session->param('uid');
+ unless( defined $username && defined $uid && !$session->is_new() ) {
+ $panel->add_error( gettext('Expired session ! Please login again') );
+ $session->delete();
+ Vhffs::Panel::Auth::display_login( $panel );
+ return undef;
+ }
+
+ my $user = Vhffs::User::get_by_uid($vhffs, $uid);
+ unless ( defined $user ) {
+ $panel->add_error( gettext('User does not exist') );
+ $session->delete();
+ Vhffs::Panel::Auth::display_login( $panel );
+ return undef;
+ }
+
+ unless( $user->get_status == Vhffs::Constants::ACTIVATED ) {
+ $panel->add_error( gettext('You\'re are not allowed to browse panel') );
+ $session->delete();
+ Vhffs::Panel::Auth::display_login( $panel );
+ return undef;
+ }
+
+ $panel->{session} = $session;
+ $panel->{user} = $user;
+ $vhffs->set_current_user( $user );
+
+ return $session;
+}
+
+sub set_group {
+ my $panel = shift;
+ $panel->{group} = shift;
+}
+
+sub has_errors {
+ my $panel = shift;
+ return (@{$panel->{errors}} > 0);
+}
+
+sub set_title {
+ my ($panel, $title) = @_;
+ $panel->{title} = $title;
+}
+
+sub add_error {
+ my ($panel, $error) = @_;
+ # TODO Do not use anonymous hash when Template::Toolkit transition is over.
+ push(@{$panel->{errors}}, {msg => $error});
+}
+
+sub add_info {
+ my ($panel, $info) = @_;
+ # TODO Do not use anonymous hash when Template::Toolkit transition is over.
+ push(@{$panel->{infos}}, {msg => $info});
+}
+
+sub add_cookie {
+ my ($panel, $cookie) = @_;
+ push(@{$panel->{cookies}}, $cookie);
+}
+
+sub clear_infos {
+ my $panel = shift;
+ $panel->{infos} = [];
+}
+
+=head2 $panel->render($file, $vars, $layout)
+
+Renders given template with substitution variables C<$vars>.
+
+If no C<$layout> is provided, C<layouts/panel.tt> will be used
+otherwise C<$layout> should be the name of the layout relative
+to the C<layouts> folder.
+
+If request was made through Ajax, no layout will be processed.
+
+B<This function never return>.
+
+=cut
+
+
+sub render {
+ my ($self, $file, $vars, $layout, $include_path) = @_;
+ my $vhffs = $self->{vhffs};
+ my $conf = $vhffs->get_config;
+ my $cgi = $self->{cgi};
+ $vhffs->clear_current_user;
+
+ # TODO Should be in parent class when Template::Toolkit switch is over
+ my $create_vars = {
+ INCLUDE_PATH => $self->{templatedir}.(defined $include_path ? '/'.$include_path.'/' : '/panel/'),
+ CONSTANTS => {
+ vhffs => {
+ VERSION => Vhffs::Constants::VHFFS_VERSION,
+ RELEASE_NAME => Vhffs::Constants::VHFFS_RELEASE_NAME,
+ },
+ object_statuses => {
+ WAITING_FOR_VALIDATION => Vhffs::Constants::WAITING_FOR_VALIDATION,
+ VALIDATION_REFUSED => Vhffs::Constants::VALIDATION_REFUSED,
+ WAITING_FOR_CREATION => Vhffs::Constants::WAITING_FOR_CREATION,
+ CREATION_ERROR => Vhffs::Constants::CREATION_ERROR,
+ ACTIVATED => Vhffs::Constants::ACTIVATED,
+ SUSPEND_PENDING => Vhffs::Constants::SUSPEND_PENDING,
+ SUSPENDED => Vhffs::Constants::SUSPENDED,
+ WAITING_FOR_MODIFICATION => Vhffs::Constants::WAITING_FOR_MODIFICATION,
+ MODIFICATION_ERROR => Vhffs::Constants::MODIFICATION_ERROR,
+ WAITING_FOR_DELETION => Vhffs::Constants::WAITING_FOR_DELETION,
+ DELETION_ERROR => Vhffs::Constants::DELETION_ERROR
+ },
+ user_permissions => {
+ NORMAL => Vhffs::Constants::USER_NORMAL,
+ MODERATOR => Vhffs::Constants::USER_MODERATOR,
+ ADMIN => Vhffs::Constants::USER_ADMIN
+ },
+ acl => {
+ UNDEFINED => Vhffs::Constants::ACL_UNDEFINED,
+ DENIED => Vhffs::Constants::ACL_DENIED,
+ VIEW => Vhffs::Constants::ACL_VIEW,
+ MODIFY => Vhffs::Constants::ACL_MODIFY,
+ MANAGEACL => Vhffs::Constants::ACL_MANAGEACL,
+ DELETE => Vhffs::Constants::ACL_DELETE
+ },
+ mailinglist => {
+ SUBSCRIBE_NO_APPROVAL_REQUIRED => Vhffs::Constants::ML_SUBSCRIBE_NO_APPROVAL_REQUIRED,
+ SUBSCRIBE_APPROVAL_REQUIRED => Vhffs::Constants::ML_SUBSCRIBE_APPROVAL_REQUIRED,
+ SUBSCRIBE_CLOSED => Vhffs::Constants::ML_SUBSCRIBE_CLOSED,
+ POSTING_OPEN_ALL => Vhffs::Constants::ML_POSTING_OPEN_ALL,
+ POSTING_MODERATED_ALL => Vhffs::Constants::ML_POSTING_MODERATED_ALL,
+ POSTING_OPEN_MEMBERS_MODERATED_OTHERS => Vhffs::Constants::ML_POSTING_OPEN_MEMBERS_MODERATED_OTHERS,
+ POSTING_MEMBERS_ONLY => Vhffs::Constants::ML_POSTING_MEMBERS_ONLY,
+ POSTING_MEMBERS_ONLY_MODERATED => Vhffs::Constants::ML_POSTING_MEMBERS_ONLY_MODERATED,
+ POSTING_ADMINS_ONLY => Vhffs::Constants::ML_POSTING_ADMINS_ONLY,
+ RIGHT_SUB_WAITING_FOR_REPLY => Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_REPLY,
+ RIGHT_SUB_WAITING_FOR_VALIDATION => Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_VALIDATION,
+ RIGHT_SUB => Vhffs::Constants::ML_RIGHT_SUB,
+ RIGHT_SUB_WAITING_FOR_DEL => Vhffs::Constants::ML_RIGHT_SUB_WAITING_FOR_DEL,
+ RIGHT_ADMIN => Vhffs::Constants::ML_RIGHT_ADMIN
+ }
+ },
+ FILTERS => {
+ i18n => \&gettext,
+ mail => sub {
+ return Vhffs::Functions::obfuscate_email($vhffs, $_[0]);
+ },
+ # Format filter accept only one argument
+ # pretty_print can 'sprintf' anything, use it as
+ # [% '%s is $%d' | pretty_print(article, price)]
+ pretty_print => [sub {
+ my $context = shift;
+ my @args = @_;
+ return sub {
+ my $format = shift;
+ return sprintf($format, @args);
+ }
+ }, 1],
+ stringify_status => sub {
+ return Vhffs::Functions::status_string_from_status_id( $_[0] );
+ },
+ stringify_type => sub {
+ Vhffs::Functions::type_string_from_type_id( $_[0] );
+ },
+ idn_to_unicode => sub {
+ require Net::LibIDN;
+ Encode::decode_utf8( Net::LibIDN::idn_to_unicode( $_[0] , 'utf-8') );
+ },
+ },
+ PRE_CHOMP => 2
+ };
+
+ $vars = {} unless(defined $vars);
+
+ my $query_string = '';
+ foreach( my @params = $cgi->url_param ) {
+ my $p = $cgi->url_param($_);
+ $query_string .= $_.'='.$p.';' if defined $p and $_ ne 'lang' and $_ ne 'theme';
+ }
+ chop $query_string;
+ undef $query_string unless $query_string;
+
+ $vars->{do} = $cgi->url_param('do');
+ $vars->{query_string} = $query_string;
+ $vars->{theme} = $self->{theme};
+ $vars->{panel_url} = $conf->get_panel->{url};
+ $vars->{title} = sprintf( gettext( '%s\'s Panel' ), $conf->get_host_name );
+ $vars->{page_title} = $self->{title};
+ $vars->{public_url} = $vhffs->get_config->get_panel->{'url_public'} if $self->is_public;
+ $vars->{msg} = Encode::decode_utf8($self->{cgi}->param('msg')) if defined $self->{cgi}->param('msg');
+ my @langs = $vhffs->get_config->get_available_languages;
+ $vars->{languages} = \@langs;
+ $vars->{language} = $self->{lang};
+ $vars->{errors} = $self->{errors};
+ $vars->{infos} = $self->{infos};
+ $vars->{current_user} = $self->{user};
+ $vars->{current_group} = $self->{group};
+
+ # Handling ajax stuff
+ if($self->{is_ajax_request}) {
+ delete $create_vars->{PROCESS};
+ } else {
+ if(defined $layout) {
+ $create_vars->{PROCESS} = 'layouts/'.$layout;
+ } else {
+ $create_vars->{PROCESS} = 'layouts/panel.tt';
+ $vars->{panel_header} = {
+ help_url => $conf->get_panel->{'url_help'} || 'http://www.vhffs.org/',
+ admin_menu => $self->{display_admin_menu},
+ available_services => $conf->get_available_services
+ };
+ }
+ }
+
+ my $template = new Template($create_vars);
+
+ my $http_accept = ( $cgi->http('HTTP_ACCEPT') or '' );
+ print $cgi->header( -cookie=>[ @{$self->{cookies}} ], -type=>( $http_accept =~ /application\/xhtml\+xml/ ? 'application/xhtml+xml' : 'text/html' ), -charset=>'utf-8' );
+
+ my $data;
+ unless( $template->process($file, $vars, \$data) ) {
+ warn 'Error while processing template: '.$template->error();
+ return;
+ }
+ # FCGI does not handle UTF9
+ print Encode::encode_utf8( $data );
+}
+
+=pod
+
+=head2 redirect
+
+ $panel->redirect($page, $cookies);
+
+Issues a redirection header sending to $page
+(you can specify additional cookies to be sent).
+
+This function never returns.
+
+B<C<$page> should be an absolute path>
+
+B<C<$cookies>> can be a CGI::Cookie or a reference
+to a CGI::Cookie array.
+
+=cut
+sub redirect {
+ my ($panel, $dest, $cookies) = @_;
+ my $vhffs = $panel->{vhffs};
+ my $cgi = $panel->{cgi};
+ $vhffs->clear_current_user;
+
+ $dest = Encode::encode_utf8( $dest );
+
+ if(defined $cookies) {
+ if(ref($cookies)) {
+ foreach(@$cookies) {
+ print "Set-Cookie: $_\n";
+ }
+ } else {
+ print "Set-Cookie: $cookies\n";
+ }
+ }
+ print $cgi->redirect($dest);
+}
+
+1;
Modified: trunk/vhffs-api/src/Vhffs/Robots.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Robots.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Robots.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -42,7 +42,7 @@
use Cwd;
use File::Basename;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Functions;
use LockFile::Simple;
Modified: trunk/vhffs-api/src/Vhffs/Services/DNS.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Services/DNS.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Services/DNS.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -167,7 +167,7 @@
}
# Returns an array with ALL the DNS
-# If ionly a ref of a Vhffs::Main instance if given, it returns ALL DNS objects
+# If ionly a ref of a Vhffs instance if given, it returns ALL DNS objects
# If a state (of Vhffs::Constants) is given more, it returns all DNS objects which have this state
sub getall {
my ($vhffs, $state, $name, $group) = @_;
Modified: trunk/vhffs-api/src/Vhffs/Stats.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Stats.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Stats.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -37,7 +37,7 @@
=head1 SYNOPSIS
- my $vhffs = init Vhffs::Main(...);
+ my $vhffs = init Vhffs(...);
my $stats = new Vhffs::Stats($vhffs);
my $lstcount = $stats->get_lists_in_moderation;
@@ -65,7 +65,7 @@
my $stats = new Vhffs::Stats($vhffs);
-Creates a new Vhffs::Stats instance. C<$vhffs> is the C<Vhffs::Main> instance used to get database connection.
+Creates a new Vhffs::Stats instance. C<$vhffs> is the C<Vhffs> instance used to get database connection.
=cut
sub new {
Modified: trunk/vhffs-api/src/Vhffs/Tag.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Tag.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/Tag.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -81,7 +81,7 @@
=over 4
-=item C<$vhffs>: C<Vhffs::Main> instance
+=item C<$vhffs>: C<Vhffs> instance
=item C<$label>: Tag label.
@@ -177,7 +177,7 @@
=over 4
-=item C<$vhffs>: C<Vhffs::Main> instance
+=item C<$vhffs>: C<Vhffs> instance
=item C<$visibility>: C<Vhffs::Constants> TAG_VISIBILITY_* value.
@@ -232,7 +232,7 @@
=over 4
-=item C<$vhffs>: C<Vhffs::Main> instance
+=item C<$vhffs>: C<Vhffs> instance
=item C<$visibility>: C<Vhffs::Constants> TAG_VISIBILITY_* value.
Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/User.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -48,8 +48,8 @@
=head1 SYNOPSIS
- use Vhffs::Main;
- my $vhffs = init Vhffs::Main or die();
+ use Vhffs;
+ my $vhffs = init Vhffs or die();
my $user = Vhffs::User::get_by_username( $vhffs , 'myuser' );
defined $user ? print "User exists\n" : print "User does not exist\n";
...
@@ -1077,7 +1077,7 @@
=head1 SEE ALSO
-Vhffs::Group , Vhffs::Main , Vhffs::Constants
+Vhffs::Group , Vhffs , Vhffs::Constants
=head1 AUTHORS
Modified: trunk/vhffs-api/src/Vhffs/UserGroup.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/UserGroup.pm 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-api/src/Vhffs/UserGroup.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -49,7 +49,7 @@
=head1 SYNOPSIS
use Vhffs::UserGroup;
- my $vhffs = init Vhffs::Main or die();
+ my $vhffs = init Vhffs or die();
my $usergroups = Vhffs::UserGroup::getall( $vhffs, Vhffs::Constants::WAITING_FOR_CREATION );
foreach ( @{$usergroups} ) {
my $user = $usergroup->get_user;
@@ -127,7 +127,7 @@
=head2 get_vhffs
-This method returns the Vhffs::Main object.
+This method returns the Vhffs object.
=cut
sub get_vhffs {
Copied: trunk/vhffs-api/src/Vhffs.pm (from rev 2091, trunk/vhffs-api/src/Vhffs/Main.pm)
===================================================================
--- trunk/vhffs-api/src/Vhffs.pm (rev 0)
+++ trunk/vhffs-api/src/Vhffs.pm 2012-03-02 20:55:43 UTC (rev 2093)
@@ -0,0 +1,255 @@
+# Copyright (c) vhffs project and its contributors
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+#3. Neither the name of vhffs nor the names of its contributors
+# may be used to endorse or promote products derived from this
+# software without specific prior written permission.
+#
+#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+#FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+#COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+#INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+#BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+#CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+package Vhffs;
+
+use strict;
+use utf8;
+use DBI;
+use Vhffs::Constants;
+use Vhffs::Functions;
+use Vhffs::Conf;
+
+=pod
+=head1 NAME
+
+Vhffs - The Main class of Vhffs API, Config file access and Backend access
+
+=head1 SYNOPSIS
+
+ use Vhffs;
+ my $vhffs = init Vhffs or die();
+ my $conf = $vhffs->get_config;
+
+=head1 DESCRIPTION
+
+The Vhffs object is the main Vhffs class. When you
+invoke init Vhffs, it creates a Vhffs object that read configuration
+and create a Vhffs::Conf object then create by default a connection to backend.
+
+=head1 METHODS
+=cut
+
+=pod
+
+=head1 init( \%opts )
+
+my $vhffs = init Vhffs( { backend => 1 } ) or die();
+
+=cut
+sub init {
+ my $class = ref( $_[0] ) || $_[0];
+ my $opt = $_[1];
+
+ # First, config stuff
+ my $config = new Vhffs::Conf( Vhffs::Constants::CONF_PATH );
+ return undef unless defined $config;
+
+ # Next, create the object
+ my $self={};
+ bless( $self , $class );
+ $self->{'config'} = $config;
+
+ # Finally, backend stuff
+ $opt->{backend} = 1 unless defined $opt->{backend};
+ if( $opt->{backend} and not defined $self->connect ) {
+ undef $self;
+ return undef;
+ }
+
+ return $self;
+}
+
+=pod
+
+=head1 get_db
+
+my $dbh = $vhffs->get_db;
+
+Returns a C<DBI> object if backend was connected, otherwise returns undef.
+
+=cut
+sub get_db {
+ my $self = shift;
+ return $self->{'db'};
+}
+
+=pod
+
+=head1 get_config
+
+my $config = $vhffs->get_cofig;
+
+Returns a C<Vhffs::Conf> object.
+
+=cut
+sub get_config {
+ my $self = shift;
+ return $self->{'config'};
+}
+
+=pod
+
+=head1 connect
+
+my $dbh = $vhffs->connect;
+
+Connect to backend, should only be used once, and only if backend was set to false in constructor options.
+
+Returns a C<DBI> object if connection succeded, otherwise returns undef.
+
+=cut
+sub connect {
+ my $self = shift;
+ my $config = $self->{config}->get_database();
+
+ unless( defined $config ) {
+ warn 'Oops!: I wonder if I am blind but I cannot find the backend area in the Vhffs configuration file :/, could you help me ?'."\n";
+ return undef;
+ }
+
+ if( $config->{'driver'} eq 'pg' ) {
+ my $port = ( $config->{'db_port'} or '5432' );
+ my $host = ( $config->{'db_host'} or 'localhost' );
+
+ my $dbh = DBI->connect('DBI:Pg:dbname='.$config->{'db_name'}.';host='.$host.';port='.$port, $config->{'db_username'}, $config->{'db_password'}, {pg_enable_utf8 => 1} );
+ return undef unless defined $dbh;
+ $dbh->do( 'SET CLIENT_ENCODING TO \'UTF8\'' );
+ $self->{'db'} = $dbh;
+ return $dbh;
+ }
+
+ warn 'Oops!: The specified backend in the configuration file is not supported by Vhffs'."\n";
+ return undef;
+}
+
+=pod
+
+=head1 is_connected
+
+my $connected = $vhffs->is_connected;
+
+Returns true if backend connection is alive, otherwise return false.
+
+=cut
+sub is_connected {
+ my $self = shift;
+ return (defined $self->{db} and $self->{db}->ping() > 0);
+}
+
+=pod
+
+=head1 reconnect
+
+my $dbh = $vhffs->reconnect;
+
+Reconnect to the database if necessary.
+
+Returns a C<DBI> object if everything went fine, otherwise returns undef.
+
+=cut
+sub reconnect {
+ my $self = shift;
+ return $self->{db} if defined $self->{db} and $self->{db}->ping() > 0;
+ $self->{db}->disconnect if defined $self->{db};
+ return $self->connect;
+}
+
+=pod
+
+=head1 set_current_user
+
+$vhffs->set_current_user( $user );
+
+Set current user using the API (used for C<Vhffs::Object::add_history>)
+
+=cut
+sub set_current_user {
+ my $self = shift;
+ my $user = shift;
+ $self->{current_user} = $user if defined $user;
+ return $user;
+}
+
+=pod
+
+=head1 get_current_user
+
+my $user = $vhffs->get_current_user;
+
+Get current user using the API (used for C<Vhffs::Object::add_history>)
+
+=cut
+sub get_current_user {
+ my $self = shift;
+ return $self->{current_user};
+}
+
+=pod
+
+=head1 clear_current_user
+
+$vhffs->clear_current_user;
+
+Clear current user using the API. You should use it if Vhffs main class
+is persistent and potentially used by more than one user.
+
+=cut
+sub clear_current_user {
+ my $self = shift;
+ delete $self->{current_user};
+}
+
+=pod
+
+=head1 get_stats
+
+my $stats = $vhffs->get_stats;
+
+Returns and caches a C<Vhffs::Stats> object.
+
+$time is an optional parameter, default to 3600, the cache is not going to be flushed if data were not flushed $time seconds ago.
+
+=cut
+sub get_stats {
+ my $self = shift;
+ my $time = shift;
+ require Vhffs::Stats;
+ $self->{stats} = new Vhffs::Stats( $self ) unless defined $self->{stats};
+ $self->{stats}->flush( defined $time ? $time : 3600 );
+ return $self->{stats};
+}
+
+1;
+
+__END__
+
+=head1 SEE ALSO
+Vhffs::User, Vhffs::Group
Modified: trunk/vhffs-compat/updatedb.pl
===================================================================
--- trunk/vhffs-compat/updatedb.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-compat/updatedb.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -39,7 +39,7 @@
use File::Temp;
use DBI;
use Cwd qw(abs_path getcwd);
-use Vhffs::Main;
+use Vhffs;
use IO::File;
#my $SQL_DIR = '%VHFFS_BACKEND_DIR%/';
Modified: trunk/vhffs-cron/src/vhffscron.pl
===================================================================
--- trunk/vhffs-cron/src/vhffscron.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-cron/src/vhffscron.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -50,7 +50,7 @@
};
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::Cron;
use Vhffs::Robots::Cron;
use Vhffs::Functions;
@@ -58,7 +58,7 @@
#select(STDOUT);
#$| = 1;
-my $vhffs = init Vhffs::Main( { backend => 0 } );
+my $vhffs = init Vhffs( { backend => 0 } );
exit 1 unless defined $vhffs;
$vhffs->connect;
Modified: trunk/vhffs-irc/modobot.pl
===================================================================
--- trunk/vhffs-irc/modobot.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-irc/modobot.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -16,7 +16,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Constants;
use Vhffs::Object;
use Vhffs::ObjectFactory;
@@ -40,7 +40,7 @@
# Connections to servers
-my $vhffs = init Vhffs::Main( { backend => 0 } );
+my $vhffs = init Vhffs( { backend => 0 } );
exit 1 unless defined $vhffs;
$vhffs->connect;
Modified: trunk/vhffs-jabber/vhffspipe.pl
===================================================================
--- trunk/vhffs-jabber/vhffspipe.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-jabber/vhffspipe.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -2,14 +2,14 @@
use strict;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::User;
use MIME::Base64;
# Flush output immediately.
$| = 1;
-my $vhffs = init Vhffs::Main( { backend => 0 } );
+my $vhffs = init Vhffs( { backend => 0 } );
exit 1 unless defined $vhffs;
$vhffs->connect;
Modified: trunk/vhffs-listengine/src/listengine.pl
===================================================================
--- trunk/vhffs-listengine/src/listengine.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-listengine/src/listengine.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -42,7 +42,7 @@
use DateTime;
use DateTime::Format::Mail;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::MailingList;
use Vhffs::Listengine;
use Vhffs::Functions;
@@ -57,7 +57,7 @@
my $action = shift;
my $lpart = shift;
my $domain = shift;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $listengineconfig = $vhffs->get_config->get_listengine;
Modified: trunk/vhffs-panel/index.pl
===================================================================
--- trunk/vhffs-panel/index.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-panel/index.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -40,13 +40,13 @@
use CGI();
use CGI::Fast();
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
-use Vhffs::Panel::Main;
+use Vhffs;
+use Vhffs::Panel;
# -- prefork
CGI->compile();
-my $vhffs = init Vhffs::Main( { backend => 0 } );
+my $vhffs = init Vhffs( { backend => 0 } );
exit 1 unless defined $vhffs;
$vhffs->connect;
@@ -54,7 +54,7 @@
# -- requests loop
while (my $cgi = new CGI::Fast) {
- my $panel = new Vhffs::Panel::Main( $vhffs, $cgi );
+ my $panel = new Vhffs::Panel( $vhffs, $cgi );
next unless defined $panel;
my $do = ( $cgi->url_param('do') or 'login' );
Modified: trunk/vhffs-public/index.pl
===================================================================
--- trunk/vhffs-public/index.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-public/index.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -40,13 +40,13 @@
use CGI();
use CGI::Fast();
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Panel::Public;
# -- prefork
CGI->compile();
-my $vhffs = init Vhffs::Main( { backend => 0 } );
+my $vhffs = init Vhffs( { backend => 0 } );
exit 1 unless defined $vhffs;
$vhffs->connect;
Modified: trunk/vhffs-robots/src/bazaar.pl
===================================================================
--- trunk/vhffs-robots/src/bazaar.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/bazaar.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Bazaar;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'bazaar' );
Modified: trunk/vhffs-robots/src/broadcast.pl
===================================================================
--- trunk/vhffs-robots/src/broadcast.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/broadcast.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Broadcast;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'mailings' );
Modified: trunk/vhffs-robots/src/cron.pl
===================================================================
--- trunk/vhffs-robots/src/cron.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/cron.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Cron;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'cron' );
Modified: trunk/vhffs-robots/src/cvs.pl
===================================================================
--- trunk/vhffs-robots/src/cvs.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/cvs.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Cvs;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'cvs' );
Modified: trunk/vhffs-robots/src/dns.pl
===================================================================
--- trunk/vhffs-robots/src/dns.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/dns.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -36,7 +36,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::DNS;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'dns' );
Modified: trunk/vhffs-robots/src/git.pl
===================================================================
--- trunk/vhffs-robots/src/git.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/git.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -36,7 +36,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Git;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'git' );
Modified: trunk/vhffs-robots/src/group.pl
===================================================================
--- trunk/vhffs-robots/src/group.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/group.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -36,7 +36,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Group;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'group' );
Modified: trunk/vhffs-robots/src/group_quota.pl
===================================================================
--- trunk/vhffs-robots/src/group_quota.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/group_quota.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Group;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'quotagroup' );
Modified: trunk/vhffs-robots/src/mail.pl
===================================================================
--- trunk/vhffs-robots/src/mail.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/mail.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Mail;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
my $mailconf = $vhffs->get_config->get_service('mail');
Modified: trunk/vhffs-robots/src/mailinglist.pl
===================================================================
--- trunk/vhffs-robots/src/mailinglist.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/mailinglist.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::MailingList;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'ml' );
Modified: trunk/vhffs-robots/src/mailinglist_mhonarc.pl
===================================================================
--- trunk/vhffs-robots/src/mailinglist_mhonarc.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/mailinglist_mhonarc.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::MailingList;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
my $listengineconfig = $vhffs->get_config->get_listengine;
Modified: trunk/vhffs-robots/src/mercurial.pl
===================================================================
--- trunk/vhffs-robots/src/mercurial.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/mercurial.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Mercurial;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'mercurial' );
Modified: trunk/vhffs-robots/src/mysql.pl
===================================================================
--- trunk/vhffs-robots/src/mysql.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/mysql.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Mysql;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'mysql' );
Modified: trunk/vhffs-robots/src/mysql_dump.pl
===================================================================
--- trunk/vhffs-robots/src/mysql_dump.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/mysql_dump.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -40,7 +40,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Mysql;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
my $mysqlconf = $vhffs->get_config->get_service('mysql');
Modified: trunk/vhffs-robots/src/object_cleanup.pl
===================================================================
--- trunk/vhffs-robots/src/object_cleanup.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/object_cleanup.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -36,7 +36,7 @@
use Vhffs::Robots;
use Vhffs::ObjectFactory;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'object' );
Modified: trunk/vhffs-robots/src/pgsql.pl
===================================================================
--- trunk/vhffs-robots/src/pgsql.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/pgsql.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Pgsql;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'pgsql' );
Modified: trunk/vhffs-robots/src/pgsql_dump.pl
===================================================================
--- trunk/vhffs-robots/src/pgsql_dump.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/pgsql_dump.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -40,7 +40,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Pgsql;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
my $pgsqlconf = $vhffs->get_config->get_service('pgsql');
Modified: trunk/vhffs-robots/src/repository.pl
===================================================================
--- trunk/vhffs-robots/src/repository.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/repository.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -37,7 +37,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Repository;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'repository' );
Modified: trunk/vhffs-robots/src/repository_quota.pl
===================================================================
--- trunk/vhffs-robots/src/repository_quota.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/repository_quota.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -37,7 +37,7 @@
use Vhffs::Robots::Group;
use Vhffs::Robots::User;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs , 'quotarepository' );
Modified: trunk/vhffs-robots/src/repository_stats.pl
===================================================================
--- trunk/vhffs-robots/src/repository_stats.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/repository_stats.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Repository;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'repositorystats' );
Modified: trunk/vhffs-robots/src/svn.pl
===================================================================
--- trunk/vhffs-robots/src/svn.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/svn.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Svn;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'svn' );
Modified: trunk/vhffs-robots/src/user.pl
===================================================================
--- trunk/vhffs-robots/src/user.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/user.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::User;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'user' );
Modified: trunk/vhffs-robots/src/user_cleanup.pl
===================================================================
--- trunk/vhffs-robots/src/user_cleanup.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/user_cleanup.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -37,7 +37,7 @@
use Vhffs::Robots;
use Vhffs::User;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'user' );
Modified: trunk/vhffs-robots/src/user_quota.pl
===================================================================
--- trunk/vhffs-robots/src/user_quota.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/user_quota.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::User;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'quotauser' );
Modified: trunk/vhffs-robots/src/usergroup.pl
===================================================================
--- trunk/vhffs-robots/src/usergroup.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/usergroup.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::UserGroup;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs , 'usergroup' );
Modified: trunk/vhffs-robots/src/web.pl
===================================================================
--- trunk/vhffs-robots/src/web.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/web.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Web;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'web' );
Modified: trunk/vhffs-robots/src/web_stats.pl
===================================================================
--- trunk/vhffs-robots/src/web_stats.pl 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-robots/src/web_stats.pl 2012-03-02 20:55:43 UTC (rev 2093)
@@ -35,7 +35,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Robots::Web;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
Vhffs::Robots::lock( $vhffs, 'webstats' );
Modified: trunk/vhffs-tools/src/vhffs-box-add
===================================================================
--- trunk/vhffs-tools/src/vhffs-box-add 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-box-add 2012-03-02 20:55:43 UTC (rev 2093)
@@ -9,13 +9,13 @@
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Functions;
use Vhffs::Group;
use Vhffs::Services::Mail;
use Vhffs::User;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
die("Usage $0 maildomain local_part password\n") unless(@ARGV == 3);
Modified: trunk/vhffs-tools/src/vhffs-dumpmysql
===================================================================
--- trunk/vhffs-tools/src/vhffs-dumpmysql 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-dumpmysql 2012-03-02 20:55:43 UTC (rev 2093)
@@ -10,13 +10,13 @@
use strict;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Constants;
use Vhffs::Functions;
use Vhffs::Services::Mysql;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $objs = Vhffs::Services::Mysql::getall( $vhffs , Vhffs::Constants::ACTIVATED );
my $obj;
Modified: trunk/vhffs-tools/src/vhffs-groupadd
===================================================================
--- trunk/vhffs-tools/src/vhffs-groupadd 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-groupadd 2012-03-02 20:55:43 UTC (rev 2093)
@@ -3,9 +3,9 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my ($groupname, $realname, $owner_uid, $description);
Modified: trunk/vhffs-tools/src/vhffs-groupdel
===================================================================
--- trunk/vhffs-tools/src/vhffs-groupdel 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-groupdel 2012-03-02 20:55:43 UTC (rev 2093)
@@ -2,7 +2,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Constants;
if( $#ARGV != 0 )
@@ -11,7 +11,7 @@
exit( 1 );
}
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $group = Vhffs::Group::get_by_groupname( $vhffs , $ARGV[0] );
Modified: trunk/vhffs-tools/src/vhffs-groupinfo
===================================================================
--- trunk/vhffs-tools/src/vhffs-groupinfo 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-groupinfo 2012-03-02 20:55:43 UTC (rev 2093)
@@ -2,9 +2,9 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Group;
-use Vhffs::Main;
+use Vhffs;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $groups = Vhffs::Group::getall( $vhffs , undef , $ARGV[0] );
Modified: trunk/vhffs-tools/src/vhffs-makeadmin
===================================================================
--- trunk/vhffs-tools/src/vhffs-makeadmin 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-makeadmin 2012-03-02 20:55:43 UTC (rev 2093)
@@ -2,7 +2,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Constants;
if( scalar @ARGV != 1 )
@@ -11,7 +11,7 @@
exit( 1 );
}
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $user = Vhffs::User::get_by_username($vhffs, $ARGV[0]);
if ( !defined $user ) {
die "User >$ARGV[0]< does not exists !\n";
Modified: trunk/vhffs-tools/src/vhffs-managedns
===================================================================
--- trunk/vhffs-tools/src/vhffs-managedns 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-managedns 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,14 +7,14 @@
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Functions;
use Vhffs::Group;
use Vhffs::Services::DNS;
use Vhffs::User;
my $ui = new Curses::UI(-clear_on_exit => 1);
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my ($w_start,
$w_new_domain, $w_list_domains,
Modified: trunk/vhffs-tools/src/vhffs-managemail
===================================================================
--- trunk/vhffs-tools/src/vhffs-managemail 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-managemail 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,7 +7,7 @@
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Functions;
use Vhffs::Group;
use Vhffs::Services::Mail;
@@ -15,7 +15,7 @@
use Vhffs::User;
my $ui = new Curses::UI(-clear_on_exit => 1);
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my ($w_start,
$w_new_domain, $w_list_domains,
Modified: trunk/vhffs-tools/src/vhffs-moderate
===================================================================
--- trunk/vhffs-tools/src/vhffs-moderate 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-moderate 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,12 +7,12 @@
use Data::Dumper;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Constants;
use Vhffs::Object;
use Vhffs::ObjectFactory;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
sub list_moderation
Modified: trunk/vhffs-tools/src/vhffs-passwd
===================================================================
--- trunk/vhffs-tools/src/vhffs-passwd 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-passwd 2012-03-02 20:55:43 UTC (rev 2093)
@@ -2,7 +2,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
if( $#ARGV != 1 )
{
@@ -10,7 +10,7 @@
exit( 1 );
}
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $user = Vhffs::User::get_by_username( $vhffs , $ARGV[0] );
Modified: trunk/vhffs-tools/src/vhffs-quota
===================================================================
--- trunk/vhffs-tools/src/vhffs-quota 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-quota 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,7 +7,7 @@
#Use some VHFFS modules, it can be useful
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Group;
@@ -28,7 +28,7 @@
my $size = $ARGV[2] if ( $#ARGV >= 2 );
#Init VHFFS subsystem
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
#Create new group
my $group = Vhffs::Group::get_by_groupname( $vhffs , $groupname );
Modified: trunk/vhffs-tools/src/vhffs-useradd
===================================================================
--- trunk/vhffs-tools/src/vhffs-useradd 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-useradd 2012-03-02 20:55:43 UTC (rev 2093)
@@ -3,11 +3,11 @@
use strict;
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Constants;
use Term::ReadPassword;
use Vhffs::Functions;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my ($username, $password, $conf_password, $access_level, $mail, $firstname, $lastname, $city, $zipcode, $country, $address);
Modified: trunk/vhffs-tools/src/vhffs-userdel
===================================================================
--- trunk/vhffs-tools/src/vhffs-userdel 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-userdel 2012-03-02 20:55:43 UTC (rev 2093)
@@ -2,7 +2,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Constants;
if( $#ARGV != 0 )
@@ -11,7 +11,7 @@
exit( 1 );
}
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $user = Vhffs::User::get_by_username( $vhffs , $ARGV[0] );
Modified: trunk/vhffs-tools/src/vhffs-userinfo
===================================================================
--- trunk/vhffs-tools/src/vhffs-userinfo 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-userinfo 2012-03-02 20:55:43 UTC (rev 2093)
@@ -2,10 +2,10 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Functions;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $arg;
$arg = $ARGV[0];
Modified: trunk/vhffs-tools/src/vhffs-usermod
===================================================================
--- trunk/vhffs-tools/src/vhffs-usermod 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-usermod 2012-03-02 20:55:43 UTC (rev 2093)
@@ -2,7 +2,7 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::User;
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Constants;
if( $#ARGV != 2 )
@@ -13,7 +13,7 @@
exit( 1 );
}
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
my $user = Vhffs::User::get_by_username( $vhffs , $ARGV[0] );
my $mod = $ARGV[1];
my $value = $ARGV[2];
Modified: trunk/vhffs-tools/src/vhffs-webdir
===================================================================
--- trunk/vhffs-tools/src/vhffs-webdir 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-webdir 2012-03-02 20:55:43 UTC (rev 2093)
@@ -7,7 +7,7 @@
use strict;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Services::Web;
if( $#ARGV != 0 ) {
@@ -16,7 +16,7 @@
exit( -1 );
}
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
exit 1 unless defined $vhffs;
my $web = Vhffs::Services::Web::get_by_servername( $vhffs, $ARGV[0] );
Modified: trunk/vhffs-tools/src/vhffs-webstats
===================================================================
--- trunk/vhffs-tools/src/vhffs-webstats 2012-03-02 20:41:46 UTC (rev 2092)
+++ trunk/vhffs-tools/src/vhffs-webstats 2012-03-02 20:55:43 UTC (rev 2093)
@@ -9,7 +9,7 @@
use Getopt::Long;
use lib '%VHFFS_LIB_DIR%';
-use Vhffs::Main;
+use Vhffs;
use Vhffs::Functions;
use Vhffs::Services::Web;
@@ -31,7 +31,7 @@
$obandwidth = $ohits = $opages = $ovisits = 1 unless $obandwidth or $ohits or $opages or $ovisits;
-my $vhffs = init Vhffs::Main;
+my $vhffs = init Vhffs;
die "ERROR: Cannot init VHFFS !!!\n" unless defined $vhffs;
my $webs = Vhffs::Services::Web::getall( $vhffs , Vhffs::Constants::ACTIVATED );