[vhffs-dev] Groupes sur admin/show.pl

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

J'ai pensé qu'il serait utile de voir les groupes auxquels appartient
un utilisateur dans son profil accessible aux admins/modos seulement,
j'ai donc fait un petit patch je débute tout juste en perl et dans
vhffs donc faut pas s'inquiéter si c'est mauvais :-P
PS: il faut adapter l'internationalisation et le template mais vu que
j'ai pas trop compris comment mettre à jour le fichier .pot...
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFvQqAuZkXNRo6TiQRAn4KAJ98vp7zFLS85+gZRg3pATr0nWISbQCfYedQ
6kLXiFwgjVS7Y99zBv4J9tw=
=ANlS
-----END PGP SIGNATURE-----

126,142d125
< 	my $group_nb=$object->have_activegroups;
< 	if( $group_nb > 0 )
< 	{
< 		$template->param( VALUE_GROUPLIST => join("\n", @{$object->get_groups} ));
< 	}
< 
< 	elsif( $group_nb < 0 )
< 	{
< 		my $message = gettext( "Cannot fetch object");
< 		$template->param( MESSAGE => $message );
< 	}
< 
< 	else
< 	{
< 		$template->param( VALUE_GROUPLIST => gettext("No groups");
< 	}
< 
#!/usr/bin/perl -w 
# 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.


use POSIX qw(locale_h);
use HTML::Template;
use locale;
use Locale::gettext;
use CGI;
use CGI::Session;
use strict;


use Vhffs::User;
use Vhffs::Group;
use Vhffs::Main;
use Vhffs::Panel::Main;
use Vhffs::Panel::Menu;
use Vhffs::Stats;
use Vhffs::Constants;
use Vhffs::Functions;

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 $username = $cgi->param("NAME");
my $template;

my $templatedir = $vhffs->get_config->get_templatedir;

my $object;

if( ($user->is_moderator != 1 ) && ( $user->is_admin != 1 ) )
{
	
	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
	my $message = gettext( "You are not allowed to see it");
	$template->param( MESSAGE => $message );
}
elsif( ! defined $username )
{
	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
	my $message = gettext( "CGI ERROR !");
	$template->param( MESSAGE => $message );
}
elsif( ( ! defined ( $object = new Vhffs::User( $vhffs , $username , '401' ) ) ) || ( $object->fetch < 0 ) )
{
	$template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
	my $message = gettext( "Cannot fetch object");
	$template->param( MESSAGE => $message );
}
else
{
	$template = new HTML::Template( filename => $templatedir."/admin/user/show.tmpl" );

	$template->param( TITLE => gettext("Show User") );

	$template->param( TEXT_USERNAME => gettext("Username:") );
	$template->param( TEXT_FIRSTNAME => gettext("Firstname") );
	$template->param( TEXT_LASTNAME => gettext("Lastname") );
	$template->param( TEXT_SHELL => gettext("Shell") );
	$template->param( TEXT_HOMEDIR => gettext("Home") );
	$template->param( TEXT_ADMIN => gettext("Admin") );
	$template->param( TEXT_UID => gettext("UID") );
	$template->param( TEXT_GID => gettext("GID") );
	$template->param( TEXT_ADDRESS => gettext("Address") );
	$template->param( TEXT_CITY => gettext("City") );
	$template->param( TEXT_ZIPCODE => gettext("Zipcode") );
	$template->param( TEXT_COUNTRY => gettext("Country") );
	$template->param( TEXT_MAIL => gettext("Mail") );
	$template->param( TEXT_GPG => gettext("GPG key") );
	$template->param( TEXT_STATUS => gettext("Status") );
	$template->param( TEXT_HISTORY => gettext("History") );

	$template->param( VALUE_USERNAME => $object->get_username );
	$template->param( VALUE_FIRSTNAME => $object->get_firstname );
	$template->param( VALUE_LASTNAME => $object->get_lastname );
	$template->param( VALUE_SHELL => $object->get_shell );
	$template->param( VALUE_HOMEDIR => $object->get_home );
	$template->param( VALUE_ADDRESS => $object->get_address );
	$template->param( VALUE_MAIL => $object->get_mail );
	$template->param( VALUE_ZIPCODE => $object->get_zipcode );
	$template->param( VALUE_COUNTRY => $object->get_country );
	$template->param( VALUE_UID => $object->get_uid );
	$template->param( VALUE_GID => $object->get_gid );
	$template->param( VALUE_CITY => $object->get_city );
	$template->param( VALUE_STATUS => Vhffs::Functions::status_string_from_status_id ($object->get_status) );

	my $group_nb=$object->have_activegroups;
	if( $group_nb > 0 )
	{
		$template->param( VALUE_GROUPLIST => join("\n", @{$object->get_groups} ));
	}

	elsif( $group_nb < 0 )
	{
		my $message = gettext( "Cannot fetch object");
		$template->param( MESSAGE => $message );
	}

	else
	{
		$template->param( VALUE_GROUPLIST => gettext("No groups");
	}

	my $oid = $object->{'object_id'};
	$template->param( VALUE_HISTORY => "/history.pl?OID=$oid" );

	if( $object->is_moderator )
	{
		$template->param( VALUE_ADMIN => gettext("Moderator") );
	}
	elsif( $object->is_admin )
	{
		$template->param( VALUE_ADMIN => gettext("Admin") );
	}
	else
	{
		$template->param( VALUE_ADMIN => gettext("Hosted") );
	}
}


display Vhffs::Panel::Main($panel, $template->output);


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