[vhffs-dev] [svn] commit: r123 - in /trunk: vhffs-api/src/Vhffs/Panel/ vhffs-panel/ vhffs-panel/admin/ vhffs-panel/templates/admin/main/ vhffs-panel/templates/admin/misc/ vhffs-tools/src/ |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
- To: vhffs-dev@xxxxxxxxx
- Subject: [vhffs-dev] [svn] commit: r123 - in /trunk: vhffs-api/src/Vhffs/Panel/ vhffs-panel/ vhffs-panel/admin/ vhffs-panel/templates/admin/main/ vhffs-panel/templates/admin/misc/ vhffs-tools/src/
- From: vhffs-dev@xxxxxxxxx
- Date: Mon Dec 19 08:38:17 2005 +00
Author: soda
Date: Mon Dec 19 09:38:10 2005
New Revision: 123
Log:
Add su mecanism in vhffs panel
Added:
trunk/vhffs-panel/admin/su.pl (with props)
trunk/vhffs-panel/templates/admin/misc/su.tmpl
Modified:
trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
trunk/vhffs-panel/panel.pl
trunk/vhffs-panel/templates/admin/main/general-modo.tmpl
trunk/vhffs-panel/templates/admin/main/general.tmpl
trunk/vhffs-tools/src/vhffs-userinfo
Modified: trunk/vhffs-api/src/Vhffs/Panel/Admin.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Admin.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Panel/Admin.pm Mon Dec 19 09:38:10 2005
@@ -57,6 +57,7 @@
$subtemplate->param( TEXT_MODERATION => gettext( "Moderation" ) );
if( $user->is_admin == 1 ) {
+ $subtemplate->param( TEXT_VHFFSSU => gettext( "Change user-id" ) );
$subtemplate->param( TEXT_MAILING => gettext( "Mail to all hosted people" ) );
$subtemplate->param( TEXT_AMAILING => gettext( "Manage mailings" ) );
$subtemplate->param( TEXT_OBJECT_LIST => gettext( "List all objects" ) );
Modified: trunk/vhffs-panel/panel.pl
==============================================================================
--- trunk/vhffs-panel/panel.pl (original)
+++ trunk/vhffs-panel/panel.pl Mon Dec 19 09:38:10 2005
@@ -23,14 +23,53 @@
my $maintemplate = $panel->{'template'};
my $user = $panel->{'user'};
my $cgi = $panel->{'cgi'};
+my $su_user = $cgi->param('su_user');
+my $message;
+
+#We try to know if an admin want to su
+if( defined $su_user )
+{
+ if( $user->is_admin == 1 )
+ {
+ my $user_bis = new Vhffs::User( $vhffs , $su_user , '401' );
+ if( defined( $user_bis ) && ( $user_bis->fetch > 0 ) )
+ {
+ $user = undef;
+ $user = $user_bis;
+ $session->clear("username");
+ $session->clear("uid");
+ $session->param("username", $user_bis->get_username);
+ $session->param("uid", $user_bis->get_uid);
+ $session->flush();
+ $panel = new Vhffs::Panel::Main();
+ $message = gettext( sprintf( "Su successfull with name %s " , $su_user) );
+ }
+ else
+ {
+ $message = sprintf( gettext( "User %s does not exists" ) , $su_user );
+ }
+ }
+ else
+ {
+ $message = gettext( "You're not an administrator" );
+ }
+}
my $template;
my $projectname = $session->param("project");
+my $templatedir = $vhffs->get_config->get_templatedir;
-if( $projectname ) {
+
+if( defined $su_user )
+{
+ $template = new HTML::Template( filename => $templatedir."/misc/simplemsg.tmpl" );
+ $template->param( MESSAGE => $message );
+}
+elsif( ( defined $projectname ) && ( $projectname eq "none" ) ) {
$template = project_info Vhffs::Panel::Main($vhffs , $session , $user);
}
-else {
+else
+{
$template = right_first Vhffs::Panel::Main($vhffs , $session , $user);
}
Modified: trunk/vhffs-panel/templates/admin/main/general-modo.tmpl
==============================================================================
--- trunk/vhffs-panel/templates/admin/main/general-modo.tmpl (original)
+++ trunk/vhffs-panel/templates/admin/main/general-modo.tmpl Mon Dec 19 09:38:10 2005
@@ -6,6 +6,7 @@
<tmpl_var name="TEXT_STATS">
</a>
</li>
+
<li id="adminHomeModeration">
<a href="/admin/moderation.pl">
<tmpl_var name="TEXT_MODERATION">
Modified: trunk/vhffs-panel/templates/admin/main/general.tmpl
==============================================================================
--- trunk/vhffs-panel/templates/admin/main/general.tmpl (original)
+++ trunk/vhffs-panel/templates/admin/main/general.tmpl Mon Dec 19 09:38:10 2005
@@ -4,6 +4,11 @@
<li id="adminHomeStats">
<a href="/admin/stats.pl">
<tmpl_var name="TEXT_STATS">
+ </a>
+ </li>
+ <li id="adminHomeStats">
+ <a href="/admin/su.pl">
+ <tmpl_var name="TEXT_VHFFSSU">
</a>
</li>
<li id="adminHomeModeration">
Modified: trunk/vhffs-tools/src/vhffs-userinfo
==============================================================================
--- trunk/vhffs-tools/src/vhffs-userinfo (original)
+++ trunk/vhffs-tools/src/vhffs-userinfo Mon Dec 19 09:38:10 2005
@@ -5,9 +5,17 @@
use Vhffs::Functions;
my $vhffs = init Vhffs::Main;
+my $arg;
+$arg = $ARGV[0];
-my $users = Vhffs::User::getall( $vhffs , undef , $ARGV[0] );
+if( ( $arg eq "--help" ) or ( $arg eq "-h" ) )
+{
+ print "Use vhffs-userinfo username\n";
+ exit( 2 );
+}
+
+my $users = Vhffs::User::getall( $vhffs , undef , $arg );
my $user;
if( defined $users )