[vhffs-dev] [624] Added administration index.

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


Revision: 624
Author:   beuss
Date:     2007-05-23 09:32:08 +0000 (Wed, 23 May 2007)

Log Message:
-----------
Added administration index.

Modified Paths:
--------------
    branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Admin.pm
    branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Main.pm
    branches/vhffs-design/vhffs-panel/Makefile.am
    branches/vhffs-design/vhffs-panel/admin/index.pl
    branches/vhffs-design/vhffs-panel/templates/Makefile.am
    branches/vhffs-design/vhffs-panel/themes/vhffs-ng/images/homeentry.png
    branches/vhffs-design/vhffs-panel/themes/vhffs-ng/images/userentry.png
    branches/vhffs-design/vhffs-panel/themes/vhffs-ng/main.css

Added Paths:
-----------
    branches/vhffs-design/vhffs-panel/templates/admin/index.tmpl
    branches/vhffs-design/vhffs-panel/themes/vhffs-ng/images/groupentry.png


Modified: branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Admin.pm
===================================================================
--- branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Admin.pm	2007-05-23 06:15:23 UTC (rev 623)
+++ branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Admin.pm	2007-05-23 09:32:08 UTC (rev 624)
@@ -41,17 +41,289 @@
 use HTML::Template;
 use locale;
 use Locale::gettext;
-use CGI;
-use CGI::Session;
 use strict;
 use Vhffs::User;
 use Vhffs::Main;
 use Vhffs::Acl;
-use Vhffs::Services::Cvs;
 use Vhffs::Panel::Main;
 use Vhffs::Constants;
 
+=pod
 
+=head1 NAME
+
+Vhffs::Panel::Admin - Handle administration functionnalities of VHFFS panel.
+
+=head1 METHODS
+
+=cut
+
+=pod
+
+=head2 get_modo_category
+
+    Vhffs::Panel::Admin::get_modo_category;
+
+Returns a hashref (CATNAME, ITEMS) where catname is the name of the
+general category for moderation and ITEMS the corresponding menu
+items.
+
+=cut
+
+sub get_modo_category {
+    my $items = [
+        { LINK => '/admin/stats.pl',            LABEL => gettext( 'Get Statistics' ) },
+        { LINK => '/admin/moderation.pl',       LABEL => gettext( 'Moderation' ) }
+    ];
+    return { CATNAME => gettext( 'General' ),   ITEMS => $items, CATTYPE => 'general' };
+}
+
+=head2 get_general_category
+
+    Vhffs::Panel::Admin::get_general_category;
+
+Returns a hashref (CATNAME, ITEMS) containing general administration
+items.
+
+=cut
+
+sub get_general_category {
+    my $items = [
+        { LINK => '/admin/stats.pl',            LABEL => gettext( 'Get Statistics' ) },
+        { LINK => '/admin/su.pl',               LABEL => gettext( 'Change user-id' ) },
+        { LINK => '/admin/moderation.pl',       LABEL => gettext( 'Moderation' ) },
+        { LINK => '/admin/object/list.pl',      LABEL => gettext( 'List all objects' ) },
+        { LINK => '/admin/object/search.pl',    LABEL => gettext( 'Search for an object' ) },
+        { LINK => '/admin/broadcast.pl',        LABEL => gettext( 'Mail to all hosted people' ) },
+        { LINK => '/admin/broadcast_list.pl',   LABEL => gettext( 'Manage mailings' ) }
+    ];
+    return { CATNAME => gettext( 'General' ),   ITEMS => $items, CATTYPE => 'general' };
+}
+
+=head2 get_user_category
+
+    Vhffs::Panel::Admin::get_user_category;
+
+Returns a hashref (CATNAME, ITEM) containing users' administration
+items.
+
+=cut
+
+sub get_user_category {
+    my $items = [
+        { LINK => '/admin/user/list.pl',        LABEL => gettext( 'List all users' ) },
+        { LINK => '/admin/user/search.pl',      LABEL => gettext( 'Search for an user' ) }
+    ];
+    return { CATNAME => gettext( 'User Admin' ),    ITEMS => $items, CATTYPE => 'user'  };
+}
+
+=head2 get_user_category
+
+    Vhffs::Panel::Admin::get_group_category;
+
+Returns a hashref (CATNAME, ITEM) containing groups' administration
+items.
+
+=cut
+
+sub get_group_category {
+    my $items = [
+        { LINK => '/admin/group/list.pl',        LABEL => gettext( 'List all groups' ) },
+        { LINK => '/admin/group/search.pl',      LABEL => gettext( 'Search for a group' ) }
+    ];
+    return { CATNAME => gettext( 'Group Admin' ),    ITEMS => $items, CATTYPE => 'group'  };
+}
+
+
+=head2 get_web_category
+
+    Vhffs::Panel::Admin::get_web_category;
+
+Returns a hashref (CATNAME, ITEM) containing webareas' administration
+items.
+
+=cut
+
+sub get_web_category {
+    my $items = [
+        { LINK => '/admin/web/list.pl',        LABEL => gettext( 'List all webareas' ) },
+        { LINK => '/admin/web/search.pl',      LABEL => gettext( 'Search for a webarea' ) }
+    ];
+    return { CATNAME => gettext( 'Web Admin' ),    ITEMS => $items, CATTYPE => 'web'  };
+}
+
+=head2 get_svn_category
+
+    Vhffs::Panel::Admin::get_svn_category;
+
+Returns a hashref (CATNAME, ITEM) containing svn's administration
+items.
+
+=cut
+
+sub get_svn_category {
+    my $items = [
+        { LINK => '/admin/svn/list.pl',        LABEL => gettext( 'List all SVN repos' ) },
+        { LINK => '/admin/svn/search.pl',      LABEL => gettext( 'Search for a SVN repository' ) }
+    ];
+    return { CATNAME => gettext( 'SVN Admin' ),    ITEMS => $items, CATTYPE => 'svn'  };
+}
+
+
+=head2 get_cvs_category
+
+    Vhffs::Panel::Admin::get_cvs_category;
+
+Returns a hashref (CATNAME, ITEM) containing cvs' administration
+items.
+
+=cut
+
+sub get_cvs_category {
+    my $items = [
+        { LINK => '/admin/cvs/list.pl',        LABEL => gettext( 'List all CVS repos' ) },
+        { LINK => '/admin/cvs/search.pl',      LABEL => gettext( 'Search for a CVS repository' ) }
+    ];
+    return { CATNAME => gettext( 'CVS Admin' ),    ITEMS => $items, CATTYPE => 'cvs'  };
+}
+
+=head2 get_mysql_category
+
+    Vhffs::Panel::Admin::get_mysql_category;
+
+Returns a hashref (CATNAME, ITEM) containing mysql's administration
+items.
+
+=cut
+
+sub get_mysql_category {
+    my $items = [
+        { LINK => '/admin/mysql/list.pl',        LABEL => gettext( 'List all MySQL databases' ) },
+        { LINK => '/admin/mysql/search.pl',      LABEL => gettext( 'Search for a MySQL database' ) }
+    ];
+    return { CATNAME => gettext( 'MySQL Admin' ),    ITEMS => $items, CATTYPE => 'mysql'  };
+}
+
+=head2 get_pgsql_category
+
+    Vhffs::Panel::Admin::get_pgsql_category;
+
+Returns a hashref (CATNAME, ITEM) containing PostgreSQL's administration
+items.
+
+=cut
+
+sub get_pgsql_category {
+    my $items = [
+        { LINK => '/admin/pgsql/list.pl',        LABEL => gettext( 'List all Pg databases' ) },
+        { LINK => '/admin/pgsql/search.pl',      LABEL => gettext( 'Search for a Pg database' ) }
+    ];
+    return { CATNAME => gettext( 'PostgreSQL Admin' ),    ITEMS => $items, CATTYPE => 'pgsql'  };
+}
+
+=head2 get_mail_category
+
+    Vhffs::Panel::Admin::get_mail_category;
+
+Returns a hashref (CATNAME, ITEM) containing mail domains' administration
+items.
+
+=cut
+
+sub get_mail_category {
+    my $items = [
+        { LINK => '/admin/mail/list.pl',        LABEL => gettext( 'List all mail domains' ) },
+        { LINK => '/admin/mail/search.pl',      LABEL => gettext( 'Search for a mail domain' ) }
+    ];
+    return { CATNAME => gettext( 'Mail domains Admin' ),    ITEMS => $items, CATTYPE => 'mail'  };
+}
+
+
+=head2 get_mailing_category
+
+    Vhffs::Panel::Admin::get_mailing_category;
+
+Returns a hashref (CATNAME, ITEM) containing mailing lists' administration
+items.
+
+=cut
+
+sub get_mailing_category {
+    my $items = [
+        { LINK => '/admin/mailing/list.pl',        LABEL => gettext( 'List all mailing lists' ) },
+        { LINK => '/admin/mailing/search.pl',      LABEL => gettext( 'Search for a mailing list' ) }
+    ];
+    return { CATNAME => gettext( 'Mailing lists Admin' ),    ITEMS => $items, CATTYPE => 'mailing'  };
+}
+
+
+=head2 get_dns_category
+
+    Vhffs::Panel::Admin::get_dns_category;
+
+Returns a hashref (CATNAME, ITEM) containing DNS' administration
+items.
+
+=cut
+
+sub get_dns_category {
+    my $items = [
+        { LINK => '/admin/dns/list.pl',        LABEL => gettext( 'List all domain names' ) },
+        { LINK => '/admin/dns/search.pl',      LABEL => gettext( 'Search for a domain name' ) }
+    ];
+    return { CATNAME => gettext( 'DNS Admin' ),    ITEMS => $items, CATTYPE => 'dns'  };
+}
+
+
+=head2 get_repo_category
+
+    Vhffs::Panel::Admin::get_repo_category;
+
+Returns a hashref (CATNAME, ITEM) containing download repositories' administration
+items.
+
+=cut
+
+sub get_repo_category {
+    my $items = [
+        { LINK => '/admin/repository/list.pl',        LABEL => gettext( 'List all download repositories' ) },
+        { LINK => '/admin/repository/search.pl',      LABEL => gettext( 'Search for a download repository' ) }
+    ];
+    return { CATNAME => gettext( 'Download repositories Admin' ),    ITEMS => $items, CATTYPE => 'repo'  };
+}
+
+
+=head2 get_all_categories
+
+    Vhffs::Panel::Admin::get_all_categories($vhffs);
+
+Return an arrayref of hashrefs (CATNAME, ITEM) containing all administration
+categories and items based on configuration of $vhffs.
+
+=cut
+
+sub get_all_categories($) {
+    my $vhffs = shift;
+    my $config = $vhffs->get_config;
+    my $categories = [];
+
+    push @$categories, get_general_category;
+    push @$categories, get_user_category;
+    push @$categories, get_group_category;
+    push @$categories, get_web_category     if($config->use_web);
+    push @$categories, get_mysql_category   if($config->use_mysql);
+    push @$categories, get_pgsql_category   if($config->use_postgres);
+    push @$categories, get_cvs_category     if($config->use_cvs);
+    push @$categories, get_svn_category     if($config->use_svn);
+    push @$categories, get_dns_category     if($config->use_dns);
+    push @$categories, get_mail_category    if($config->use_mail);
+    push @$categories, get_mailing_category if($config->use_mailing);
+    push @$categories, get_repo_category    if($config->use_repository);
+
+
+    return $categories;
+}
+
 sub menu
 {
 	my ($class ,  $data ) = @_;

Modified: branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Main.pm	2007-05-23 06:15:23 UTC (rev 623)
+++ branches/vhffs-design/vhffs-api/src/Vhffs/Panel/Main.pm	2007-05-23 09:32:08 UTC (rev 624)
@@ -67,7 +67,16 @@
 	return 0;
 }
 
+=pod
 
+=head2 check_public
+
+    $panel->check_public;
+
+Checks that public area is available, if it's ot the case show a message and exits.
+
+=cut
+
 sub check_public {
     my $self = shift;
     my $vhffs = $self->{vhffs};
@@ -83,6 +92,28 @@
     }
 }
 
+=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 exits.
+
+=cut
+
+sub check_modo {
+    my $self = shift;
+    my $user = $self->{user};
+    unless($user->is_moderator || $user->is_admin) {
+        $self->set_title( gettext('Access denied') );
+        $self->add_error( gettext('You are not granted to access this page') );
+        $self->display( '' );
+        exit( 0 );
+    }
+}
+
 sub list_themes
 {
 	my $vhffs = shift;

Modified: branches/vhffs-design/vhffs-panel/Makefile.am
===================================================================
--- branches/vhffs-design/vhffs-panel/Makefile.am	2007-05-23 06:15:23 UTC (rev 623)
+++ branches/vhffs-design/vhffs-panel/Makefile.am	2007-05-23 09:32:08 UTC (rev 624)
@@ -249,10 +249,12 @@
 	themes/vhffs-ng/images/es_ES.png \
 	themes/vhffs-ng/images/fr_FR.png \
 	themes/vhffs-ng/images/good.png \
+	themes/vhffs-ng/images/groupentry.png \
 	themes/vhffs-ng/images/help.png \
 	themes/vhffs-ng/images/help_bg.png \
 	themes/vhffs-ng/images/help_little.png \
 	themes/vhffs-ng/images/home.png \
+	themes/vhffs-ng/images/homeentry.png \
 	themes/vhffs-ng/images/inputbg.png \
 	themes/vhffs-ng/images/it_IT.png \
 	themes/vhffs-ng/images/largefilecreate.png \

Modified: branches/vhffs-design/vhffs-panel/admin/index.pl
===================================================================
--- branches/vhffs-design/vhffs-panel/admin/index.pl	2007-05-23 06:15:23 UTC (rev 623)
+++ branches/vhffs-design/vhffs-panel/admin/index.pl	2007-05-23 09:32:08 UTC (rev 624)
@@ -34,33 +34,33 @@
 use HTML::Template;
 use locale;
 use Locale::gettext;
-use CGI;
-use CGI::Session;
 use strict;
 
 
 use lib '%VHFFS_LIB_DIR%';
-use Vhffs::User;
-use Vhffs::Group;
-use Vhffs::Main;
 use Vhffs::Panel::Main;
-use Vhffs::Panel::Menu;
-use Vhffs::Stats;
-use Vhffs::Constants;
 my $panel = new Vhffs::Panel::Main();
 if(!$panel)  {
         exit 0;
 }
 
-my $vhffs = $panel->{'vhffs'};
-my $session = $panel->{'session'};
-my $maintemplate = $panel->{'template'};
-my $user = $panel->{'user'};
-#my $group = $panel->{'group'};
-my $projectname = $session->param("project");
-my $cgi = $panel->{'cgi'};
-my $servername = $cgi->param("name");
-my $template;
+$panel->check_modo;
 
+my $templatedir = $panel->{templatedir};
+my $user = $panel->{user};
+my $template = new HTML::Template(filename => $templatedir.'/admin/index.tmpl');
+
 $panel->set_title(gettext('Administration'));
-$panel->display('');
+
+my $categories = [];
+my $items;
+my $c;
+if( $user->is_moderator ) {
+    push @$categories, Vhffs::Panel::Admin::get_modo_category;
+} else {
+    $categories = Vhffs::Panel::Admin::get_all_categories($panel->{vhffs});
+}
+
+$template->param( CATEGORIES => $categories );
+
+$panel->display($template->output);

Modified: branches/vhffs-design/vhffs-panel/templates/Makefile.am
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/Makefile.am	2007-05-23 06:15:23 UTC (rev 623)
+++ branches/vhffs-design/vhffs-panel/templates/Makefile.am	2007-05-23 09:32:08 UTC (rev 624)
@@ -2,6 +2,7 @@
 nobase_paneltemplates_DATA = \
 	acl/view_each.tmpl \
 	acl/view.tmpl \
+	admin/index.tmpl \
 	admin/cvs/edit.tmpl \
 	admin/cvs/menu.tmpl \
 	admin/cvs/part-modo.tmpl \

Added: branches/vhffs-design/vhffs-panel/templates/admin/index.tmpl
===================================================================
--- branches/vhffs-design/vhffs-panel/templates/admin/index.tmpl	2007-05-23 06:15:23 UTC (rev 623)
+++ branches/vhffs-design/vhffs-panel/templates/admin/index.tmpl	2007-05-23 09:32:08 UTC (rev 624)
@@ -0,0 +1,10 @@
+<tmpl_loop name="CATEGORIES">
+    <fieldset>
+        <legend><tmpl_var name="CATNAME"></legend>
+        <ul class="<tmpl_var name="CATTYPE">List">
+        <tmpl_loop name="ITEMS">
+            <li><a href="<tmpl_var name="LINK">"><tmpl_var name="LABEL"></a></li>
+        </tmpl_loop>
+        </ul>
+    </fieldset>
+</tmpl_loop>

Added: branches/vhffs-design/vhffs-panel/themes/vhffs-ng/images/groupentry.png
===================================================================
(Binary files differ)


Property changes on: branches/vhffs-design/vhffs-panel/themes/vhffs-ng/images/groupentry.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: branches/vhffs-design/vhffs-panel/themes/vhffs-ng/images/homeentry.png
===================================================================
(Binary files differ)

Modified: branches/vhffs-design/vhffs-panel/themes/vhffs-ng/images/userentry.png
===================================================================
(Binary files differ)

Modified: branches/vhffs-design/vhffs-panel/themes/vhffs-ng/main.css
===================================================================
--- branches/vhffs-design/vhffs-panel/themes/vhffs-ng/main.css	2007-05-23 06:15:23 UTC (rev 623)
+++ branches/vhffs-design/vhffs-panel/themes/vhffs-ng/main.css	2007-05-23 09:32:08 UTC (rev 624)
@@ -706,6 +706,18 @@
     list-style-image: url('images/dnsentry.png');
 }
 
+ul.generalList {
+    list-style-image: url('images/homeentry.png');
+}
+
+ul.userList {
+    list-style-image: url('images/userentry.png');
+}
+
+ul.groupList {
+    list-style-image: url('images/groupentry.png');
+}
+
 div.acltable * {
 margin:0;
 padding:0;


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