Code

changed xml-structure for event send_usr_msg
authorrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 29 Apr 2008 14:29:29 +0000 (14:29 +0000)
committerrettenbe <rettenbe@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 29 Apr 2008 14:29:29 +0000 (14:29 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@10728 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-si/gosa-si-server
gosa-si/server/events/gosaTriggered.pm

index 5432c1a8e2525deb0a2dd508baefa87df72632d2..45d0b2c1e49ef601d1469f8880ea5cd7f48a7712 100755 (executable)
@@ -1382,19 +1382,32 @@ sub watch_for_new_messages {
         my $message_to = @{$hit}[3];
 
         # translate message_to to plain login name
-# TODO implement reciever translation
-        my @reciever_l = split(/,/, $message_to);  
+        my @message_to_l = split(/,/, $message_to);  
+               my %receiver_h; 
+               foreach my $receiver (@message_to_l) {
+                       if ($receiver =~ /^u_([\s\S]*)$/) {
+                               $receiver_h{$1} = 0;
+                       } elsif ($receiver =~ /^g_([\s\S]*)$/) {
+# TODO implement receiver translation
+                       } else {
+                               my $sbjct = &encode_base64(@{$hit}[1]);
+                               my $msg = &encode_base64(@{$hit}[7]);
+                               &daemon_log("M WARNING: unknown receiver '$receiver' for a user-message 'sbjct - msg'", 3); 
+                       }
+               }
+               my @receiver_l = keys(%receiver_h);
+
         my $message_id = @{$hit}[0];
 
         #add each outgoing msg to messaging_db
-        my $reciever;
-        foreach $reciever (@reciever_l) {
+        my $receiver;
+        foreach $receiver (@receiver_l) {
             my $sql_statement = "INSERT INTO $messaging_tn (id, subject, message_from, message_to, flag, direction, delivery_time, message, timestamp) ".
                 "VALUES ('".
                 $message_id."', '".    # id
                 @{$hit}[1]."', '".     # subject
                 @{$hit}[2]."', '".     # message_from
-                $reciever."', '".      # message_to
+                $receiver."', '".      # message_to
                 "none"."', '".         # flag
                 "out"."', '".          # direction
                 @{$hit}[6]."', '".     # delivery_time
@@ -1403,7 +1416,7 @@ sub watch_for_new_messages {
                 ")";
             &daemon_log("M DEBUG: $sql_statement", 1);
             my $res = $messaging_db->exec_statement($sql_statement);
-            &daemon_log("M INFO: message '".@{$hit}[0]."' is prepared for delivery to reciever '$reciever'", 5);
+            &daemon_log("M INFO: message '".@{$hit}[0]."' is prepared for delivery to receiver '$receiver'", 5);
         }
 
         # set incoming message to flag d=deliverd
index 5fbb787cf75eb48a3a40573948289425b7269fe6..371d408f00da7cc0470b59b213bb53ee8efbb026 100644 (file)
@@ -57,6 +57,16 @@ sub get_events {
 }
 
 sub send_user_msg {
+
+# msg from gosa
+# <xml><header>gosa_send_user_msg</header><source>GOSA</source><target>GOSA</target>
+# <timestamp>20080429151605</timestamp>
+# <users>andreas.rettenberger</users>
+# <subject>hallo</subject>
+# <message>test</message>
+# <macaddress>GOSA</macaddress>
+# </xml>
+
     my ($msg, $msg_hash, $session_id) = @_ ;
     my $header = @{$msg_hash->{'header'}}[0];
     my $source = @{$msg_hash->{'source'}}[0];
@@ -65,7 +75,8 @@ sub send_user_msg {
     #my $subject = &decode_base64(@{$msg_hash->{'subject'}}[0]);
     my $subject = @{$msg_hash->{'subject'}}[0];
     my $from = @{$msg_hash->{'from'}}[0];
-    my @to = @{$msg_hash->{'to'}};
+    my @users = @{$msg_hash->{'users'}};
+       my @groups = @{$msg_hash->{'groups'}}[0];
     my $delivery_time = @{$msg_hash->{'delivery_time'}}[0];
     #my $message = &decode_base64(@{$msg_hash->{'message'}}[0]);
     my $message = @{$msg_hash->{'message'}}[0];
@@ -94,12 +105,18 @@ sub send_user_msg {
         $new_msg_id += 1;
     }
 
+       # highlight user name and group name
+       @users = map("u_", @users);
+       my $users_list = join(",", @users);
+       @groups = map("g_", @groups);
+       my $groups_list = join(",", @groups);
+
     my $func_dic = {table=>$main::messaging_tn,
         primkey=>[],
         id=>$new_msg_id,
         subject=>$subject,
         message_from=>$from,
-        message_to=>join(",",@to),
+        message_to=>"$users_list,$groups_list",
         flag=>"n",
         direction=>"in",
         delivery_time=>$delivery_time,