[vhffs-dev] [1924] history source uid is back |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 1924
Author: gradator
Date: 2012-01-22 22:54:23 +0100 (Sun, 22 Jan 2012)
Log Message:
-----------
history source uid is back
Modified Paths:
--------------
trunk/TODO
trunk/vhffs-api/src/Vhffs/Main.pm
trunk/vhffs-api/src/Vhffs/Object.pm
trunk/vhffs-api/src/Vhffs/Panel/Main.pm
trunk/vhffs-irc/modobot.pl
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2012-01-22 01:48:55 UTC (rev 1923)
+++ trunk/TODO 2012-01-22 21:54:23 UTC (rev 1924)
@@ -1,5 +1,3 @@
-redo all $self->add_history( /// $user lost
-
own session management using VHFFS database
ECML : https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion
Modified: trunk/vhffs-api/src/Vhffs/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Main.pm 2012-01-22 01:48:55 UTC (rev 1923)
+++ trunk/vhffs-api/src/Vhffs/Main.pm 2012-01-22 21:54:23 UTC (rev 1924)
@@ -133,6 +133,24 @@
return $self->connect;
}
+# set current user using the API (used for Vhffs::Object::add_history)
+sub set_current_user {
+ my $self = shift;
+ my $user = shift;
+ $self->{current_user} = $user if defined $user;
+ return $user;
+}
+
+sub get_current_user {
+ my $self = shift;
+ return $self->{current_user};
+}
+
+sub clear_current_user {
+ my $self = shift;
+ delete $self->{current_user};
+}
+
1;
__END__
Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm 2012-01-22 01:48:55 UTC (rev 1923)
+++ trunk/vhffs-api/src/Vhffs/Object.pm 2012-01-22 21:54:23 UTC (rev 1924)
@@ -369,13 +369,11 @@
use Vhffs::Main;
my $self = shift;
my $message = shift;
- # TODO: REDO SOURCE
- my $source = undef;
- $message = $message;
+ my $user = $self->{main}->get_current_user->get_uid if defined $self->{main}->get_current_user;
my $query = 'INSERT INTO vhffs_history(object_id, date, message, source_uid) VALUES(?, ?, ?, ?)';
my $request = $self->{'db'}->prepare( $query );
- $request->execute( $self->{'object_id'}, time(), $message, $source ) or return -2;
+ $request->execute( $self->{'object_id'}, time(), $message, $user ) or return -2;
return $self->{'db'}->last_insert_id(undef, undef, 'vhffs_history', undef);;
}
Modified: trunk/vhffs-api/src/Vhffs/Panel/Main.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2012-01-22 01:48:55 UTC (rev 1923)
+++ trunk/vhffs-api/src/Vhffs/Panel/Main.pm 2012-01-22 21:54:23 UTC (rev 1924)
@@ -247,6 +247,7 @@
return undef unless( defined $vhffs and defined $cgi );
+ $vhffs->clear_current_user;
$cgi->charset('UTF-8');
my $self = {};
@@ -343,6 +344,7 @@
$panel->{session} = $session;
$panel->{user} = $user;
+ $vhffs->set_current_user( $user );
return $session;
}
@@ -401,9 +403,11 @@
sub render {
my ($self, $file, $vars, $layout, $include_path) = @_;
- my $conf = $self->{vhffs}->get_config;
+ 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/'),
@@ -455,7 +459,7 @@
FILTERS => {
i18n => \&gettext,
mail => sub {
- return Vhffs::Functions::obfuscate_email($self->{vhffs}, $_[0]);
+ return Vhffs::Functions::obfuscate_email($vhffs, $_[0]);
},
# Format filter accept only one argument
# pretty_print can 'sprintf' anything, use it as
@@ -486,9 +490,9 @@
$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} = $self->{vhffs}->get_config->get_panel->{'url_public'} if $self->is_public;
+ $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 = $self->{vhffs}->get_config->get_available_languages;
+ my @langs = $vhffs->get_config->get_available_languages;
$vars->{languages} = \@langs;
$vars->{language} = $self->{lang};
$vars->{errors} = $self->{errors};
@@ -544,7 +548,9 @@
=cut
sub redirect {
my ($panel, $dest, $cookies) = @_;
+ my $vhffs = $panel->{vhffs};
my $cgi = $panel->{cgi};
+ $vhffs->clear_current_user;
$dest = Encode::encode_utf8( $dest );
Modified: trunk/vhffs-irc/modobot.pl
===================================================================
--- trunk/vhffs-irc/modobot.pl 2012-01-22 01:48:55 UTC (rev 1923)
+++ trunk/vhffs-irc/modobot.pl 2012-01-22 21:54:23 UTC (rev 1924)
@@ -486,6 +486,7 @@
my ($nick, $mynick)=($event->nick, $self->nick);
my $texte=$event->{args}[0];
my $user = ( Vhffs::User::get_by_ircnick($vhffs, $nick) or Vhffs::User::get_by_username($vhffs, $nick) );
+ $vhffs->set_current_user( $user );
$texte =~ s/\s*$//;
@@ -621,6 +622,7 @@
}
+ $vhffs->clear_current_user;
} # on_public
sub on_kick {