From: naoki i. <am...@us...> - 2008-04-18 12:41:46
|
Update of /cvsroot/popfile/engine/Classifier In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14105/Classifier Modified Files: Bayes.pm Log Message: Change Log 1. Added 'Current active user sessions' section in the administration tab ( in the multiuser mode only ) 2. New function get_current_sessions() UI/HTML.pm Classifier/Bayes.pm POPFile/API.pm skins/default/administration-page.thtml languages/English.msg languages/Nihongo.msg This will allow administrators to check the current users' activities. NOTE : The administrator's session ( got by get_administrator_session_key ) is not be shown. 3. In the multiuser mode, the login user name is shown at the bottom of the UI UI/HTML.pm The login user name is shown instead of the last login user name. 4. XML-RPC stealth/server setting is now configured correctly UI/XMLRPC.pm 5. Add some status messages in the UI UI/HTML.pm UI/XMLRPC.pm Proxy/POP3.pm Proxy/SMTP.pm Proxy/NNTP.pm languages/English.msg languages/Nihongo.msg tests/TestHTML.script Magnet tab Administration tab 6. Avoid redirect to logout or shutdown page from the password page UI/HTML.pm 7. Password page for the single user mode is restored UI/HTML.pm 8. Update language file languages/Nihongo.msg 9. Minor changes of the skins skins/default/common-bottom.thtml skins/default/administration-page.thtml Current state of the test suite: TestBayesScript PASS TestBayes PASS TestConfiguration PASS * TestHistory PASS TestHTML PASS * TestHTTP PASS TestIMAP PASS TestInsertScript PASS * TestLogger PASS TestMailParse PASS TestModule PASS TestMQ PASS TestMutex PASS TestPipeScript PASS TestPOP3 PASS TestProxy PASS TestWordMangle PASS TestXMLRPC PASS * : TODO : needs to add tests for multi user support Index: Bayes.pm =================================================================== RCS file: /cvsroot/popfile/engine/Classifier/Bayes.pm,v retrieving revision 1.367 retrieving revision 1.368 diff -C2 -d -r1.367 -r1.368 *** Bayes.pm 17 Apr 2008 15:13:04 -0000 1.367 --- Bayes.pm 18 Apr 2008 12:41:49 -0000 1.368 *************** *** 1939,1942 **** --- 1939,1973 ---- #---------------------------------------------------------------------------- # + # get_current_sessions + # + # Gets the current active user session list (ADMIN ONLY) + # + # $session Valid administrator session + # + # Returns current active sessions as an array + # + #---------------------------------------------------------------------------- + sub get_current_sessions + { + my ( $self, $session ) = @_; + + return undef if ( !$self->is_admin_session( $session ) ); + + my @result; + foreach my $current_session ( keys %{$self->{api_sessions__}} ) { + next if ( defined( $self->{api_sessions__}{$current_session}{notexpired} ) ); + + my %row; + $row{session} = $current_session; + $row{userid} = $self->{api_sessions__}{$current_session}{userid}; + $row{lastused} = $self->{api_sessions__}{$current_session}{lastused}; + push ( @result, \%row ); + } + + return \@result; + } + + #---------------------------------------------------------------------------- + # # get_top_bucket__ # *************** *** 3000,3003 **** --- 3031,3035 ---- # Returns 1 if the account was added successfully, or 0 for an error, # -1 if another user already has that account associated with it + # # ---------------------------------------------------------------------------- sub add_account *************** *** 3478,3482 **** # If there is a non-default value for this parameter then return it. ! $self->{db_get_bucket_parameter__}->execute( $self->{db_bucketid__}{$userid}{$bucket}{id}, $self->{db_parameterid__}{$parameter} ); my $result = $self->{db_get_bucket_parameter__}->fetchrow_arrayref; --- 3510,3516 ---- # If there is a non-default value for this parameter then return it. ! $self->{db_get_bucket_parameter__}->execute( ! $self->{db_bucketid__}{$userid}{$bucket}{id}, ! $self->{db_parameterid__}{$parameter} ); my $result = $self->{db_get_bucket_parameter__}->fetchrow_arrayref; *************** *** 3541,3545 **** my $quoted_user = $self->db_()->quote( $new_user ); my $quoted_hash = $self->db_()->quote( $password_hash ); ! $self->db_()->do( "insert into users ( name, password ) values ( $quoted_user, $quoted_hash );" ); my $id = $self->get_user_id( $session, $new_user ); --- 3575,3580 ---- my $quoted_user = $self->db_()->quote( $new_user ); my $quoted_hash = $self->db_()->quote( $password_hash ); ! $self->db_()->do( "insert into users ( name, password ) ! values ( $quoted_user, $quoted_hash );" ); my $id = $self->get_user_id( $session, $new_user ); *************** *** 3565,3569 **** # Clone user's parameters ! my $h = $self->db_()->prepare( "select utid, val from user_params where userid = ?;" ); $h->execute( $clid ); --- 3600,3605 ---- # Clone user's parameters ! my $h = $self->db_()->prepare( ! "select utid, val from user_params where userid = ?;" ); $h->execute( $clid ); *************** *** 3574,3579 **** $h->finish; ! $h = $self->db_()->prepare( "insert into user_params ( userid, utid, val ) ! values ( ?, ?, ? );" ); foreach my $utid (keys %add) { $h->execute( $id, $utid, $add{$utid} ); --- 3610,3616 ---- $h->finish; ! $h = $self->db_()->prepare( ! "insert into user_params ( userid, utid, val ) ! values ( ?, ?, ? );" ); foreach my $utid (keys %add) { $h->execute( $id, $utid, $add{$utid} ); *************** *** 3583,3587 **** # Clone buckets (optional) ! $h = $self->db_()->prepare( "select name, pseudo from buckets where userid = ?;" ); $h->execute( $clid ); my %buckets; --- 3620,3625 ---- # Clone buckets (optional) ! $h = $self->db_()->prepare( ! "select name, pseudo from buckets where userid = ?;" ); $h->execute( $clid ); my %buckets; *************** *** 3591,3596 **** $h->finish; ! $h = $self->db_()->prepare( "insert into buckets ( userid, name, pseudo ) ! values ( ?, ?, ? );" ); foreach my $name (keys %buckets) { $h->execute( $id, $name, $buckets{$name} ); --- 3629,3635 ---- $h->finish; ! $h = $self->db_()->prepare( ! "insert into buckets ( userid, name, pseudo ) ! values ( ?, ?, ? );" ); foreach my $name (keys %buckets) { $h->execute( $id, $name, $buckets{$name} ); *************** *** 3624,3629 **** $h->finish; ! $h = $self->db_()->prepare( "insert into bucket_params ( bucketid, btid, val) ! values ( ?, ?, ? );" ); foreach my $bucketid ( keys %bucket_params ) { foreach my $btid ( keys %{$bucket_params{$bucketid}} ) { --- 3663,3669 ---- $h->finish; ! $h = $self->db_()->prepare( ! "insert into bucket_params ( bucketid, btid, val) ! values ( ?, ?, ? );" ); foreach my $bucketid ( keys %bucket_params ) { foreach my $btid ( keys %{$bucket_params{$bucketid}} ) { *************** *** 3648,3653 **** $h->finish; ! $h = $self->db_()->prepare( "insert into magnets ( bucketid, mtid, val ) ! values ( ?, ?, ? );" ); foreach my $bucketid ( keys %magnets ) { foreach my $mtid ( keys %{$magnets{$bucketid}} ) { --- 3688,3694 ---- $h->finish; ! $h = $self->db_()->prepare( ! "insert into magnets ( bucketid, mtid, val ) ! values ( ?, ?, ? );" ); foreach my $bucketid ( keys %magnets ) { foreach my $mtid ( keys %{$magnets{$bucketid}} ) { *************** *** 3663,3668 **** if ( $copy_corpus ) { $h = $self->db_()->prepare( ! "select matrix.bucketid, matrix.wordid, matrix.times from matrix, buckets ! where matrix.bucketid = buckets.id and buckets.userid = ?;" ); $h->execute( $clid ); --- 3704,3709 ---- if ( $copy_corpus ) { $h = $self->db_()->prepare( ! "select matrix.bucketid, matrix.wordid, matrix.times from matrix, buckets ! where matrix.bucketid = buckets.id and buckets.userid = ?;" ); $h->execute( $clid ); *************** *** 3673,3678 **** $h->finish; ! $h = $self->db_()->prepare( "insert into matrix ( bucketid, wordid, times ) ! values ( ?, ?, ? );" ); foreach my $bucketid ( keys %matrix ) { foreach my $wordid ( keys %{$matrix{$bucketid}} ) { --- 3714,3720 ---- $h->finish; ! $h = $self->db_()->prepare( ! "insert into matrix ( bucketid, wordid, times ) ! values ( ?, ?, ? );" ); foreach my $bucketid ( keys %matrix ) { foreach my $wordid ( keys %{$matrix{$bucketid}} ) { *************** *** 3694,3698 **** # default settings ! $self->db_()->do( "insert into buckets ( name, pseudo, userid ) values ( 'unclassified', 1, $id );" ); # Copy the global language setting to the user's language setting --- 3736,3741 ---- # default settings ! $self->db_()->do( "insert into buckets ( name, pseudo, userid ) ! values ( 'unclassified', 1, $id );" ); # Copy the global language setting to the user's language setting *************** *** 3987,3991 **** if ( $current_userid != $userid ) { ! # If the current user id is not the specified user id, check can_admin if ( !$self->is_admin_session( $session ) ) { --- 4030,4035 ---- if ( $current_userid != $userid ) { ! # If the current user id is not the specified user id, check if the ! # user is admin if ( !$self->is_admin_session( $session ) ) { *************** *** 4133,4139 **** my ( $self, $session ) = @_; - # my ( $package, $filename, $line, $subroutine ) = caller; - # $self->log_( 1, "is_admin_session is called from $package @ $line to check the session key $session" ); - my $result = $self->get_user_parameter( $session, 'GLOBAL_can_admin' ); --- 4177,4180 ---- *************** *** 4175,4179 **** if ( !defined( $result ) ) { $self->{db_get_user_parameter_default__}->execute( # PROFILE BLOCK START ! $self->{db_user_parameterid__}{$parameter} ); # PROFILE BLOCK STOP $result = $self->{db_get_user_parameter_default__}->fetchrow_arrayref; $default = 1; --- 4216,4220 ---- if ( !defined( $result ) ) { $self->{db_get_user_parameter_default__}->execute( # PROFILE BLOCK START ! $self->{db_user_parameterid__}{$parameter} ); # PROFILE BLOCK STOP $result = $self->{db_get_user_parameter_default__}->fetchrow_arrayref; $default = 1; *************** *** 4898,4902 **** #---------------------------------------------------------------------------- # ! # add_stopword, remove_stopword # # Adds or removes a stop word --- 4939,4943 ---- #---------------------------------------------------------------------------- # ! # add_stopword, remove_stopword (ADMIN ONLY) # # Adds or removes a stop word *************** *** 4915,4918 **** --- 4956,4963 ---- return undef if ( !defined( $userid ) ); + if ( !$self->is_admin_session( $session ) ) { + return undef; + } + # Pass language parameter to add_stopword() *************** *** 4927,4930 **** --- 4972,4979 ---- return undef if ( !defined( $userid ) ); + if ( !$self->is_admin_session( $session ) ) { + return undef; + } + # Pass language parameter to remove_stopword() |