[vhffs-dev] [889] Vhffs::Note was a good friend |
[ Thread Index |
Date Index
| More vhffs.org/vhffs-dev Archives
]
Revision: 889
Author: gradator
Date: 2007-09-09 05:04:48 +0000 (Sun, 09 Sep 2007)
Log Message:
-----------
Vhffs::Note was a good friend
Modified Paths:
--------------
trunk/vhffs-api/src/Vhffs/Makefile.am
trunk/vhffs-api/src/Vhffs/Object.pm
trunk/vhffs-api/src/Vhffs/User.pm
trunk/vhffs-irc/modobot.pl
trunk/vhffs-panel/admin/moderation.pl
trunk/vhffs-panel/admin/user/edit.pl
trunk/vhffs-panel/admin/user/edit_note.pl
trunk/vhffs-tools/src/vhffs-moderate
Removed Paths:
-------------
trunk/vhffs-api/src/Vhffs/Note.pm
Modified: trunk/vhffs-api/src/Vhffs/Makefile.am
===================================================================
--- trunk/vhffs-api/src/Vhffs/Makefile.am 2007-09-09 04:42:31 UTC (rev 888)
+++ trunk/vhffs-api/src/Vhffs/Makefile.am 2007-09-09 05:04:48 UTC (rev 889)
@@ -13,7 +13,6 @@
Group.pm \
Intl.pm \
Main.pm \
- Note.pm \
ObjectFactory.pm \
Object.pm \
Robots.pm \
Deleted: trunk/vhffs-api/src/Vhffs/Note.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Note.pm 2007-09-09 04:42:31 UTC (rev 888)
+++ trunk/vhffs-api/src/Vhffs/Note.pm 2007-09-09 05:04:48 UTC (rev 889)
@@ -1,132 +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.
-
-#Vhffs::Note written by sod` <dieu AT gunnm DOT org>
-
-# This software is free software, please read LICENCE file
-
-use Vhffs::Constants;
-
-use strict;
-use diagnostics;
-
-package Vhffs::Note;
-sub set_note
-{
- my $vhffs = shift;
- my $user = shift;
- my $value = shift;
-
- my $sql = 'UPDATE vhffs_user SET note = ? WHERE uid = ?';
- my $dbh = $user->get_db_object;
- my $sth = $dbh->prepare($sql);
- $sth->execute($value, $user->get_uid());
-
- return 1;
-}
-
-
-
-sub inc_note
-{
- my $vhffs = shift;
- my $user = shift;
- my $increase = shift;
-
- return -1 unless( defined $user );
-
- my $sql = 'UPDATE vhffs_users SET note = note + ? WHERE uid = ?';
- my $sth = $vhffs->{'db'}->prepare( $sql );
- $sth->execute( $increase, $user->get_uid );
-
- return 1;
-}
-
-sub get_note
-{
- my $vhffs = shift;
- my $user = shift;
-
- return -1 unless(defined $user);
-
- my $query = 'SELECT note FROM vhffs_users WHERE uid = ?';
-
- my $request = $vhffs->{'db'}->prepare( $query );
- $request->execute($user->get_uid);
- my ($note) = $request->fetchrow();
- return ($note || 0);
-}
-
-1;
-
-__END__
-
-=head1 NAME
-
- Vhffs::Note - handle and manage note for objects on VHFFS platform
-
-=head1 SYNOPSIS
-
- use Vhffs::Note;
- use Vhffs::Main;
-
- $vhffs = init Vhffs::Main;
-
- ...
- (considers that you have a VHFFS user in $user)
- ...
-
- print "Current note for your user : " . Vhffs::Note::get_note( $vhffs , $user );
-
- #We add 3 to the current note
- Vhffs::Note::inc_note( $vhffs , $user , 3 );
-
- #We set the note to 0
- Vhffs::Note::set_note( $vhffs , $user, 0 );
-
- #We decrease the note of 1
- Vhffs::Note::inc_note( $vhffs , $user, -1 );
-
-
-=head1 METHODS
-
- get_note( $vhffs , $user ) : return the note for the given object
-
- set_note( $vhffs , $user , $value ) : set the note
-
- inc_note( $vhffs , $user , $inc ) : add $inc to the current not of object $object
-
-=head1 AUTHOR
-
- Julien Delange <julien at gunnm dot org>
-
-=head1 COPYRIGHT
-
- Copyright 2006 Julien Delange
Modified: trunk/vhffs-api/src/Vhffs/Object.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/Object.pm 2007-09-09 04:42:31 UTC (rev 888)
+++ trunk/vhffs-api/src/Vhffs/Object.pm 2007-09-09 05:04:48 UTC (rev 889)
@@ -412,11 +412,8 @@
Vhffs::Functions::send_mail( $vhffs->get_config->get_moderator_mail , $user->get_mail , $subject , $mail );
- if( $vhffs->get_config->get_users->{'use_notation'} eq 'yes' )
- {
- use Vhffs::Note;
- Vhffs::Note::inc_note( $vhffs , $user , 1 );
- }
+ $user->set_note( $user->get_note +1 );
+ $user->commit;
return $self->commit;
}
@@ -436,12 +433,10 @@
$self->set_status( Vhffs::Constants::VALIDATION_REFUSED );
$self->set_description( $reason );
- if( $vhffs->get_config->get_users->{'use_notation'} eq 'yes' )
- {
- use Vhffs::Note;
- Vhffs::Note::inc_note( $vhffs , $user , -1 );
- }
+ $user->set_note( $user->get_note -1 );
+ $user->commit;
+
return $self->commit;
}
Modified: trunk/vhffs-api/src/Vhffs/User.pm
===================================================================
--- trunk/vhffs-api/src/Vhffs/User.pm 2007-09-09 04:42:31 UTC (rev 888)
+++ trunk/vhffs-api/src/Vhffs/User.pm 2007-09-09 05:04:48 UTC (rev 889)
@@ -281,11 +281,11 @@
return -1 if( $self->SUPER::commit < 0 );
- my $sql = 'UPDATE vhffs_users SET shell = ?, passwd = ?, admin = ?, firstname = ?, lastname = ?, address = ?, zipcode = ?, country = ?, mail = ?, city = ?, gpg_key = ? WHERE uid = ?';
+ my $sql = 'UPDATE vhffs_users SET shell = ?, passwd = ?, admin = ?, firstname = ?, lastname = ?, address = ?, zipcode = ?, country = ?, mail = ?, city = ?, gpg_key = ? , note = ? WHERE uid = ?';
my $sth = $self->{db}->prepare($sql) or return -1;
$sth->execute($self->{'shell'}, $self->{'passwd'}, $self->{'admin'},
$self->{'firstname'}, $self->{'lastname'}, $self->{'address'}, $self->{'zipcode'},
- $self->{'country'}, $self->{'mail'}, $self->{'city'}, $self->{'gpg_key'}, $self->{'uid'}) or return -3;
+ $self->{'country'}, $self->{'mail'}, $self->{'city'}, $self->{'gpg_key'}, $self->{'note'}, $self->{'uid'}) or return -3;
return 1;
}
@@ -502,6 +502,11 @@
return( $self->{'gpg_key'} );
}
+sub get_note
+{
+ my $self = shift;
+ return( $self->{'note'} );
+}
sub set_shell
{
@@ -576,6 +581,13 @@
$self->{'gpg_key'} = $value;
}
+sub set_note
+{
+ my $self = shift;
+ my $value = shift;
+ $self->{'note'} = $value;
+}
+
sub set_password
{
use Vhffs::Functions;
Modified: trunk/vhffs-irc/modobot.pl
===================================================================
--- trunk/vhffs-irc/modobot.pl 2007-09-09 04:42:31 UTC (rev 888)
+++ trunk/vhffs-irc/modobot.pl 2007-09-09 05:04:48 UTC (rev 889)
@@ -15,7 +15,6 @@
use Vhffs::Group;
use Vhffs::Main;
use Vhffs::Constants;
-use Vhffs::Note;
use Vhffs::Object;
use Vhffs::ObjectFactory;
@@ -82,7 +81,7 @@
my $object = Vhffs::ObjectFactory::fetch_object( $vhffs , $obj->{object_id} );
my $msg = Vhffs::Functions::type_string_from_type_id( $obj->{type} ).': '.$obj->get_oid.' '.$user->get_username;
- $msg .= ' ('.Vhffs::Note::get_note( $vhffs , $user ).')' if( $vhffs->get_config->get_users->{'use_notation'} eq 'yes' );
+ $msg .= ' ('.$user->get_note.')' if( $vhffs->get_config->get_users->{'use_notation'} eq 'yes' );
$msg .= ' ['.$user->get_lang.'] '.$group->get_groupname.' '.$obj->get_description;
irc_msg( $msg );
Modified: trunk/vhffs-panel/admin/moderation.pl
===================================================================
--- trunk/vhffs-panel/admin/moderation.pl 2007-09-09 04:42:31 UTC (rev 888)
+++ trunk/vhffs-panel/admin/moderation.pl 2007-09-09 05:04:48 UTC (rev 889)
@@ -44,7 +44,6 @@
use Vhffs::Panel::Main;
use Vhffs::Panel::Menu;
use Vhffs::Constants;
-use Vhffs::Note;
use Vhffs::Object;
use Vhffs::ObjectFactory;
@@ -106,7 +105,7 @@
if( $vhffs->get_config->get_users->{'use_notation'} eq 'yes' )
{
- $subtemplate->param( NOTE => Vhffs::Note::get_note( $vhffs , $user ) );
+ $subtemplate->param( NOTE => $user->get_note );
}
$subtemplate->param( GROUP => $group->get_groupname );
Modified: trunk/vhffs-panel/admin/user/edit.pl
===================================================================
--- trunk/vhffs-panel/admin/user/edit.pl 2007-09-09 04:42:31 UTC (rev 888)
+++ trunk/vhffs-panel/admin/user/edit.pl 2007-09-09 05:04:48 UTC (rev 889)
@@ -247,25 +247,17 @@
$template->param( SELECTED_NORMAL_USER => "selected" );
}
-
-
-
if( $vhffs->get_config->get_users->{'use_notation'} eq 'yes' )
{
- use Vhffs::Note;
my $subtemplate = new HTML::Template( filename => $templatedir."/panel/admin/user/edit-note.tmpl" );
$subtemplate->param( TEXT_NOTE => "Note" );
- $subtemplate->param( VALUE_NOTE => Vhffs::Note::get_note( $vhffs , $object ) );
+ $subtemplate->param( VALUE_NOTE => $object->get_note );
$subtemplate->param( VALUE_USERNAME => $object->get_username );
$subtemplate->param( SEND => gettext("Update note") );
$template->param( NOTE => $subtemplate->output );
}
-
-
-
}
-
$panel->build( $template );
$panel->display;
Modified: trunk/vhffs-panel/admin/user/edit_note.pl
===================================================================
--- trunk/vhffs-panel/admin/user/edit_note.pl 2007-09-09 04:42:31 UTC (rev 888)
+++ trunk/vhffs-panel/admin/user/edit_note.pl 2007-09-09 05:04:48 UTC (rev 889)
@@ -46,7 +46,6 @@
use Vhffs::Panel::Main;
use Vhffs::Panel::Menu;
use Vhffs::Stats;
-use Vhffs::Note;
use Vhffs::Constants;
my $panel = new Vhffs::Panel::Main();
@@ -93,7 +92,8 @@
if( defined $note )
{
- Vhffs::Note::set_note( $vhffs , $object , $note );
+ $object->set_note( $note );
+ $object->commit;
$message = gettext("Note successfully modified");
}
else
Modified: trunk/vhffs-tools/src/vhffs-moderate
===================================================================
--- trunk/vhffs-tools/src/vhffs-moderate 2007-09-09 04:42:31 UTC (rev 888)
+++ trunk/vhffs-tools/src/vhffs-moderate 2007-09-09 05:04:48 UTC (rev 889)
@@ -9,7 +9,6 @@
use lib '%VHFFS_LIB_DIR%';
use Vhffs::Main;
use Vhffs::Constants;
-use Vhffs::Note;
use Vhffs::Object;
use Vhffs::ObjectFactory;