"Fossies" - the Fresh Open Source Software Archive

Member "OCSNG_UNIX_SERVER_2.6/Apache/Ocsinventory/Interface/History.pm" (17 Apr 2019, 2570 Bytes) of package /linux/privat/OCSNG_UNIX_SERVER_2.6.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 ###############################################################################
    2 ## Copyright 2005-2016 OCSInventory-NG/OCSInventory-Server contributors.
    3 ## See the Contributors file for more details about them.
    4 ## 
    5 ## This file is part of OCSInventory-NG/OCSInventory-ocsreports.
    6 ##
    7 ## OCSInventory-NG/OCSInventory-Server is free software: you can redistribute
    8 ## it and/or modify it under the terms of the GNU General Public License as
    9 ## published by the Free Software Foundation, either version 2 of the License,
   10 ## or (at your option) any later version.
   11 ##
   12 ## OCSInventory-NG/OCSInventory-Server is distributed in the hope that it
   13 ## will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
   14 ## of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   15 ## GNU General Public License for more details.
   16 ##
   17 ## You should have received a copy of the GNU General Public License
   18 ## along with OCSInventory-NG/OCSInventory-ocsreports. if not, write to the
   19 ## Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
   20 ## MA 02110-1301, USA.
   21 ################################################################################
   22 package Apache::Ocsinventory::Interface::History;
   23 
   24 use Apache::Ocsinventory::Interface::Database;
   25 use XML::Simple;
   26 
   27 use strict;
   28 
   29 require Exporter;
   30 
   31 our @ISA = qw /Exporter/;
   32 
   33 our @EXPORT = qw / 
   34   get_history_events
   35   clear_history_events
   36 /;
   37 
   38 sub get_history_events {
   39   my $offset = shift;
   40   my @tmp;
   41   
   42   $offset = $offset * $ENV{OCS_OPT_WEB_SERVICE_RESULTS_LIMIT};
   43   
   44   my $sth = get_sth( "SELECT DATE,DELETED,EQUIVALENT FROM deleted_equiv ORDER BY DATE,DELETED LIMIT $offset, $ENV{OCS_OPT_WEB_SERVICE_RESULTS_LIMIT}" );
   45     
   46   while( my $row = $sth->fetchrow_hashref() ){
   47     push @tmp, {
   48         'DELETED' => [ $row->{'DELETED'} ],
   49         'DATE' => [ $row->{'DATE'} ],
   50         'EQUIVALENT' => [ $row->{'EQUIVALENT'} ]
   51     }
   52   }
   53   $sth->finish();
   54   return XML::Simple::XMLout( {'EVENT' => \@tmp} , RootName => 'EVENTS' );
   55 }
   56 
   57 sub clear_history_events {
   58   my $offset = shift;
   59   my $ok = 0;
   60 
   61   my $sth = get_sth( "SELECT * FROM deleted_equiv ORDER BY DATE,DELETED LIMIT 0,$offset" );
   62   while( my $row = $sth->fetchrow_hashref() ) {
   63     if( defined $row->{'EQUIVALENT'} ){
   64       do_sql('DELETE FROM deleted_equiv WHERE DELETED=? AND DATE=? AND EQUIVALENT=?', $row->{'DELETED'}, $row->{'DATE'}, $row->{'EQUIVALENT'}) or die;
   65     }
   66     else{
   67       do_sql('DELETE FROM deleted_equiv WHERE DELETED=? AND DATE=? AND EQUIVALENT IS NULL', $row->{'DELETED'}, $row->{'DATE'}) or die;
   68     }
   69     $ok++;
   70   }
   71   return $ok;
   72 }