From: naoki i. <am...@us...> - 2008-03-30 05:33:53
|
Update of /cvsroot/popfile/engine/POPFile In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29156/POPFile Modified Files: Database.pm History.pm Log Message: Change Log 1. Add an interface and a function to change/initialize user's password UI/HTML.pm Classifier/Bayes.pm skins/default/users-page.thtml languages/English.msg 2. Bucket parameters are now copied from cloned user's Classifier/Bayes.pm 3. Non admin users can't access the Administration, Users and Advanced tabs. UI/HTML.pm 4. The history messages are now stored per user. 5. Users can't see/remove other users' history messages. Classifier/Bayes.pm POPFile/History.pm UI/HTML.pm 6. Sorting history messages now work correctly UI/HTML.pm skins/default/history-page.thtml 7. Server Mode options for SMTP and NNTP proxy are saved correctly 8. Server Mode checkboxes are disabled if all the modules are local UI/HTML.pm Proxy/POP3.pm Proxy/SMTP.pm Proxy/NNTP.pm 9. The 'Config Bar' string is now localizable skins/default/configration-bar.thtml languages/English.msg 10. The 'Stealth Mode' and 'Server Mode' strings are now localizable skins/default/administration-page.thtml languages/English.msg 11. Update language files languages/English.msg languages/Nihongo.msg Index: History.pm =================================================================== RCS file: /cvsroot/popfile/engine/POPFile/History.pm,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** History.pm 9 Feb 2008 09:05:39 -0000 1.46 --- History.pm 30 Mar 2008 05:33:58 -0000 1.47 *************** *** 237,241 **** sub reserve_slot { ! my ( $self ) = @_; my $r; --- 237,244 ---- sub reserve_slot { ! my ( $self, $session ) = @_; ! ! my $userid = $self->classifier_()->valid_session_key__( $session ); ! return undef if ( !defined( $userid ) ); my $r; *************** *** 268,272 **** my $now = time; $self->db_()->do( ! "insert into history ( userid, committed, inserted ) values ( 1, $r, $now );" ); last; } --- 271,275 ---- my $now = time; $self->db_()->do( ! "insert into history ( userid, committed, inserted ) values ( $userid, $r, $now );" ); last; } *************** *** 381,385 **** my $oldbucketid = 0; if ( !$undo ) { ! my @fields = $self->get_slot_fields( $slot ); $oldbucketid = $fields[10]; } --- 384,388 ---- my $oldbucketid = 0; if ( !$undo ) { ! my @fields = $self->get_slot_fields( $slot, $session ); $oldbucketid = $fields[10]; } *************** *** 399,409 **** # # slot The slot to update # #---------------------------------------------------------------------------- sub revert_slot_classification { ! my ( $self, $slot ) = @_; ! my @fields = $self->get_slot_fields( $slot ); my $oldbucketid = $fields[9]; --- 402,413 ---- # # slot The slot to update + # session A valid API session # #---------------------------------------------------------------------------- sub revert_slot_classification { ! my ( $self, $slot, $session ) = @_; ! my @fields = $self->get_slot_fields( $slot, $session ); my $oldbucketid = $fields[9]; *************** *** 426,436 **** sub get_slot_fields { ! my ( $self, $slot ) = @_; return $self->db_()->selectrow_array( "select $fields_slot from history, buckets, magnets ! where history.id = $slot and ! buckets.id = history.bucketid and ! magnets.id = magnetid;" ); } --- 430,444 ---- sub get_slot_fields { ! my ( $self, $slot, $session ) = @_; ! ! my $userid = $self->classifier_()->valid_session_key__( $session ); ! return undef if ( !defined($userid) ); return $self->db_()->selectrow_array( "select $fields_slot from history, buckets, magnets ! where history.id = $slot and ! history.userid = $userid and ! buckets.id = history.bucketid and ! magnets.id = magnetid;" ); } *************** *** 442,453 **** # # slot The slot id # #--------------------------------------------------------------------------- sub is_valid_slot { ! my ( $self, $slot ) = @_; my @row = $self->db_()->selectrow_array( ! "select id from history where history.id = $slot;" ); return ( ( @row ) && ( $row[0] == $slot ) ); --- 450,467 ---- # # slot The slot id + # session A valid API session # #--------------------------------------------------------------------------- sub is_valid_slot { ! my ( $self, $slot, $session ) = @_; ! ! my $userid = $self->classifier_()->valid_session_key__( $session ); ! return 0 if ( !defined($userid) ); my @row = $self->db_()->selectrow_array( ! "select id from history ! where history.id = $slot and ! history.userid = $userid;" ); return ( ( @row ) && ( $row[0] == $slot ) ); *************** *** 633,644 **** # $slot The slot ID # $archive 1 if it's OK to archive this entry # # --------------------------------------------------------------------------- sub delete_slot { ! my ( $self, $slot, $archive ) = @_; my $file = $self->get_slot_file( $slot ); ! $self->log_( 2, "delete_slot called for slot $slot, file $file" ); if ( $archive && $self->config_( 'archive' ) ) { --- 647,681 ---- # $slot The slot ID # $archive 1 if it's OK to archive this entry + # $session A valid API session + # $cleanup 1 if force delete this entry + # ( from cleanup_history only ) # # --------------------------------------------------------------------------- sub delete_slot { ! my ( $self, $slot, $archive, $session, $cleanup ) = @_; ! ! my $userid = $self->classifier_()->valid_session_key__( $session ); ! return if ( !defined($userid) ); ! ! my @b; ! if ( $cleanup ) { ! @b = $self->db_()->selectrow_array( ! "select buckets.name from history, buckets ! where history.bucketid = buckets.id and ! history.id = $slot;" ); ! } else { ! @b = $self->db_()->selectrow_array( ! "select buckets.name from history, buckets ! where history.bucketid = buckets.id and ! history.userid = $userid and ! history.id = $slot;" ); ! } my $file = $self->get_slot_file( $slot ); ! $self->log_( 2, "delete_slot called for slot $slot, file $file from userid $userid" ); ! ! my $bucket = $b[0]; ! return if ( !defined($bucket) ); if ( $archive && $self->config_( 'archive' ) ) { *************** *** 647,657 **** $self->make_directory__( $path ); - my @b = $self->db_()->selectrow_array( - "select buckets.name from history, buckets - where history.bucketid = buckets.id and - history.id = $slot;" ); - - my $bucket = $b[0]; - if ( ( $bucket ne 'unclassified' ) && ( $bucket ne 'unknown class' ) ) { --- 684,687 ---- *************** *** 963,967 **** # Add the sort option (if there is one) ! if ( $sort ne '' ) { $sort =~ s/^(\-)//; my $direction = defined($1)?'desc':'asc'; --- 993,997 ---- # Add the sort option (if there is one) ! if ( $sort ne '' ) {print "$sort"; $sort =~ s/^(\-)//; my $direction = defined($1)?'desc':'asc'; *************** *** 1009,1017 **** # # id The ID returned by start_query # #---------------------------------------------------------------------------- sub delete_query { ! my ( $self, $id ) = @_; $self->start_deleting(); --- 1039,1048 ---- # # id The ID returned by start_query + # session A valid API session # #---------------------------------------------------------------------------- sub delete_query { ! my ( $self, $id, $session ) = @_; $self->start_deleting(); *************** *** 1027,1031 **** } foreach my $id (@ids) { ! $self->delete_slot( $id, 1 ); } --- 1058,1062 ---- } foreach my $id (@ids) { ! $self->delete_slot( $id, 1, $session, 0 ); } *************** *** 1263,1278 **** my ( $self ) = @_; my $seconds_per_day = 24 * 60 * 60; ! my $old = time - $self->user_config_( 1, 'history_days' )*$seconds_per_day; ! my $d = $self->db_()->prepare( "select id from history ! where inserted < $old;" ); ! $d->execute; ! my @row; my @ids; ! while ( @row = $d->fetchrow_array ) { ! push ( @ids, $row[0] ); } foreach my $id (@ids) { ! $self->delete_slot( $id, 1 ); } } --- 1294,1317 ---- my ( $self ) = @_; + # TODO : multi-user support + my $session = $self->classifier_()->get_administrator_session_key(); + my $users = $self->classifier_()->get_user_list( $session ); + my $seconds_per_day = 24 * 60 * 60; ! my @ids; ! foreach my $userid ( keys %$users ) { ! my $old = time - $self->user_config_( $userid, 'history_days' )*$seconds_per_day; ! my $d = $self->db_()->prepare( "select id from history ! where userid = $userid and ! inserted < $old;" ); ! $d->execute; ! my @row; ! while ( @row = $d->fetchrow_array ) { ! push ( @ids, $row[0] ); ! } } foreach my $id (@ids) { ! $self->delete_slot( $id, 1, $session, 1 ); } } Index: Database.pm =================================================================== RCS file: /cvsroot/popfile/engine/POPFile/Database.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Database.pm 20 Feb 2006 02:01:57 -0000 1.7 --- Database.pm 30 Mar 2008 05:33:58 -0000 1.8 *************** *** 83,87 **** # database parameter above. ! $self->config_( 'dbconnect', 'dbi:SQLite:dbname=$dbname' ); $self->config_( 'dbuser', '' ); $self->config_( 'dbauth', '' ); --- 83,87 ---- # database parameter above. ! $self->config_( 'dbconnect', 'dbi:SQLite2:dbname=$dbname' ); $self->config_( 'dbuser', '' ); $self->config_( 'dbauth', '' ); |