Code

Added branches container for old stuff
[gosa.git] / gosa-plugins / goto / addons / goto / events / class_DaemonEvent_notify.inc
index 16a2796f9e96518f62170681655347d1dc52bfd2..13bf90dd827c484585dadc17538ad52f442278a6 100644 (file)
@@ -24,13 +24,15 @@ class DaemonEvent_notify extends DaemonEvent
 {
   var $visible_for = USER_EVENT;
 
-  var $users = array();
-  var $groups= array(); 
+  var $user = array();
+  var $group= array(); 
 
   var $message = "";
   var $subject = "";
   var $from    = "";
 
+  var $attributes = array("from","user","group","message","subject");
+
   public function __construct($config,$data = array())
   {
     DaemonEvent::__construct($config,$data);
@@ -39,6 +41,7 @@ class DaemonEvent_notify extends DaemonEvent
     $this->from = $ui->cn; 
  
     $this->message = base64_decode($this->message);
+    $this->subject = base64_decode($this->subject);
 
     $this->s_Menu_Name  = _("Send message");
     $this->s_Event_Name = _("Send message");
@@ -46,8 +49,8 @@ class DaemonEvent_notify extends DaemonEvent
     $this->s_Schedule_Action = "job_send_user_msg";
     $this->s_Trigger_Action= "gosa_send_user_msg";
     $this->s_Queued_Action= "trigger_action_notify";
-    $this->s_Menu_Image = "images/mailto.png";
-    $this->s_List_Image = "images/mailto.png";
+    $this->s_Menu_Image = "plugins/goto/images/notify.png";
+    $this->s_List_Image = "plugins/goto/images/notify.png";
     $this->a_targets = array("GOSA"); // Required to get the event send. Maybe this is a wrong value.
   }
 
@@ -68,8 +71,8 @@ class DaemonEvent_notify extends DaemonEvent
     $smarty->assign("is_new"      , $this->is_new);
     $smarty->assign("timestamp"   , $this->get_time_select());
     
-    $smarty->assign("users" , $this->users);
-    $smarty->assign("groups" , $this->groups);
+    $smarty->assign("user" , $this->user);
+    $smarty->assign("group" , $this->group);
     
     $smarty->assign("add_str", msgPool::addButton(_("Target")));
     $smarty->assign("del_str", msgPool::delButton(_("Target")));
@@ -96,7 +99,7 @@ class DaemonEvent_notify extends DaemonEvent
     if(empty($this->from)){
       $msgs[] = msgPool::required(_("From"));
     }
-    if(!count($this->groups) && !count($this->users)){
+    if(!count($this->group) && !count($this->user)){
       $msgs[] = msgPool::required(_("Target"));
     }
     return($msgs);
@@ -107,17 +110,17 @@ class DaemonEvent_notify extends DaemonEvent
   {
     DaemonEvent::save_object();
 
-    if(isset($_POST['del_any_target']) && isset($_POST['groups'])){
-      foreach($_POST['groups'] as $id){
-        if(isset($this->groups[$id])){
-          unset($this->groups[$id]);
+    if(isset($_POST['del_any_target']) && isset($_POST['group'])){
+      foreach($_POST['group'] as $id){
+        if(isset($this->group[$id])){
+          unset($this->group[$id]);
         }
       }
     }
-    if(isset($_POST['del_any_target']) && isset($_POST['users'])){
-      foreach($_POST['users'] as $id){
-        if(isset($this->users[$id])){
-          unset($this->users[$id]);
+    if(isset($_POST['del_any_target']) && isset($_POST['user'])){
+      foreach($_POST['user'] as $id){
+        if(isset($this->user[$id])){
+          unset($this->user[$id]);
         }
       }
     }
@@ -140,8 +143,8 @@ class DaemonEvent_notify extends DaemonEvent
       $add = array($add);
     }
     foreach($add as $target){
-      if(!in_array($target,$this->users)){
-        $this->users[] = $target;
+      if(!in_array($target,$this->user)){
+        $this->user[] = $target;
       }
     }
   }
@@ -154,8 +157,8 @@ class DaemonEvent_notify extends DaemonEvent
       $add = array($add);
     }
     foreach($add as $target){
-      if(!in_array($target,$this->groups)){
-        $this->groups[] = $target;
+      if(!in_array($target,$this->group)){
+        $this->group[] = $target;
       }
     }
   }
@@ -196,11 +199,11 @@ class DaemonEvent_notify extends DaemonEvent
   public function save()
   {
     $ret = DaemonEvent::save();
-    $ret['users']   = array_values($this->users);
-    $ret['groups']  = array_values($this->groups);
-    $ret['subject'] = $this->subject;
-    $ret['from']    = $this->from;
-    $ret['message'] = base64_encode($this->message);
+    $ret['delivery_time'] = $ret['timestamp'];
+    $ret['user']   = array_values( $ret['user']);
+    $ret['group']  = array_values( $ret['group']);
+    $ret['subject'] = base64_encode($ret['subject']);
+    $ret['message'] = base64_encode($ret['message']);
     return($ret);
   }
 }