X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=gosa-si%2Fmodules%2FGosaSupportDaemon.pm;h=a14d5def0d4621b96c32d9ade846b21e067987f7;hb=c461774e974e9866634b0bce54a6a52bfead7643;hp=e33c83eaa5305d9ad72c3a07931ebb2d36fb77db;hpb=7c5ebee2a31e2eeb2b09e5cc0ee0fa6f05716ee7;p=gosa.git diff --git a/gosa-si/modules/GosaSupportDaemon.pm b/gosa-si/modules/GosaSupportDaemon.pm index e33c83eaa..a14d5def0 100644 --- a/gosa-si/modules/GosaSupportDaemon.pm +++ b/gosa-si/modules/GosaSupportDaemon.pm @@ -18,6 +18,7 @@ my @functions = ( "get_limit_statement", "get_orderby_statement", "get_dns_domains", + "get_logged_in_users", ); @EXPORT = @functions; use strict; @@ -27,6 +28,7 @@ use Crypt::Rijndael; use Digest::MD5 qw(md5 md5_hex md5_base64); use MIME::Base64; use XML::Simple; +use Data::Dumper; my $op_hash = { 'eq' => '=', @@ -35,6 +37,7 @@ my $op_hash = { 'gt' => '>', 'le' => '<=', 'lt' => '<', + 'like' => ' LIKE ', }; @@ -248,7 +251,7 @@ sub get_where_statement { if( exists $phrase->{'operator'} ) { my $op = $op_hash->{$phrase->{'operator'}[0]}; if( not defined $op ) { - &main::daemon_log("ERROR: Can not translate operator '$operator' in where ". + &main::daemon_log("ERROR: Can not translate operator '$operator' in where-". "statement to sql valid syntax. Please use 'eq', ". "'ne', 'ge', 'gt', 'le', 'lt' in xml message\n", 1); &main::daemon_log($msg, 8); @@ -261,10 +264,15 @@ sub get_where_statement { my @xml_tags = keys %{$phrase}; my $tag = $xml_tags[0]; my $val = $phrase->{$tag}[0]; - push(@phrase_l, "$tag$operator'$val'"); + # integer columns do not have to have single quotes besides the value + if ($tag eq "id") { + push(@phrase_l, "$tag$operator$val"); + } else { + push(@phrase_l, "$tag$operator'$val'"); + } } my $clause_str .= join(" $connector ", @phrase_l); - push(@clause_l, $clause_str); + push(@clause_l, "($clause_str)"); } if( not 0 == @clause_l ) { @@ -281,7 +289,7 @@ sub get_select_statement { my $select = "*"; if( exists $msg_hash->{'select'} ) { my $select_l = \@{$msg_hash->{'select'}}; - $select = join(' AND ', @{$select_l}); + $select = join(', ', @{$select_l}); } return $select; } @@ -386,4 +394,25 @@ sub get_dns_domains() { return @searches; } + +sub get_logged_in_users { + my $result = qx(/usr/bin/w -hs); + my @res_lines; + + if( defined $result ) { + chomp($result); + @res_lines = split("\n", $result); + } + + my @logged_in_user_list; + foreach my $line (@res_lines) { + chomp($line); + my @line_parts = split(/\s+/, $line); + push(@logged_in_user_list, $line_parts[0]); + } + + return @logged_in_user_list; + +} + 1;