Code

Updated Daemon event - notify.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 18 Mar 2008 08:31:58 +0000 (08:31 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 18 Mar 2008 08:31:58 +0000 (08:31 +0000)
-Added user/group targets.
-Added subject/message

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@9912 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/addons/goto/events/DaemonEvent_notify.tpl
gosa-plugins/goto/addons/goto/events/class_DaemonEvent_notify.inc

index 2e6baa6e21e577827fbb730c09aa20583088988e..276b513f1eeb7bdeb63dff0b146be3ab99325373 100644 (file)
@@ -4,22 +4,52 @@
 <table style='width:100%;'>
   <tr>
     <td style='width:50%; vertical-align:top; border-right:1px solid #AAA'>
-      <table>
-        <tr>
-          <td style='vertical-align:top'><b>{t}Time schedule{/t}</b><br><br>
-          {$timestamp}</td>
-        </tr>
+         <b>{t}Message settings{/t}</b>
+         <table style="width:100%;">
+               <tr>
+                       <td>{t}Subject{/t}</td>
+                       <td><input type='text' name="subject" value="{$subject}" style="width:100%;"></td>
+               </tr>
+               <tr>
+                       <td colspan="2">{t}Message{/t} :</td>
+               </tr>
+               <tr>
+                       <td colspan="2" style="width:100%;">
+                               <textarea style="width:100%;height:250px;" name="message" style="100%;">{$message}</textarea>
+                       </td>
+               </tr>
       </table>
     </td>
     <td style='width:50%; vertical-align:top;'>
+         <b>{t}Time schedule{/t}</b>
+      <table>
+        <tr>
+          <td colspan="2" style='vertical-align:top'>{$timestamp}<br><br></td>
+        </tr>
+         </table>
       <table style='width:100%;'>
         <tr>
+          <td style="width:50%;">
+            <b>{t}Target users{/t}</b>
+            <br>
+                       <select style="height:180px;width:100%" name="users[]"  multiple size=4>
+                               {html_options options=$users}
+                       </select>
+          </td>
           <td>
-            <b>{t}System list{/t}</b>
+            <b>{t}Target groups{/t}</b>
             <br>
-            {$target_list}
+                       <select style="height:180px;width:100%" name="groups[]"  multiple size=4>
+                               {html_options options=$groups}
+                       </select>
           </td>
         </tr>
+               <tr>
+                       <td colspan="2">
+                               <input type="submit" name="add_any_target" value="{$add_str}">
+                               <input type="submit" name="del_any_target" value="{$del_str}">
+                       </td>
+               </tr>
       </table>
     </td>
   </tr>
index 7486e7ea89d5432f8fb3661b3050de65a2ce84fb..15465aa3fb8ada1c2965485303aa417fef076690 100644 (file)
 class DaemonEvent_notify extends DaemonEvent
 {
   var $visible_for = USER_EVENT;
+
+  var $users = array();
+  var $groups= array(); 
+
+  var $message = "";
+  var $subject = "";
+
   public function __construct($config,$data = array())
   {
     DaemonEvent::__construct($config,$data);
@@ -33,8 +40,7 @@ class DaemonEvent_notify extends DaemonEvent
     $this->s_Queued_Action= "trigger_action_notify";
     $this->s_Menu_Image = "images/mailto.png";
     $this->s_List_Image = "images/mailto.png";
-
-    $this->a_targets = array("GOsa");
+    $this->a_targets = array("GOsa"); // Required to get the event send. Maybe this is a wrong value.
   }
 
   public function execute()
@@ -46,24 +52,81 @@ class DaemonEvent_notify extends DaemonEvent
     $smarty->assign("subject" ,"subject");
     $smarty->assign("message" ,"message");
     $smarty->assign("data"        , $this->data);
-    $smarty->assign("data"        , $this->data);
     $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("add_str", msgPool::addButton(_("Target")));
+    $smarty->assign("del_str", msgPool::delButton(_("Target")));
+
+    $smarty->assign("subject", xmlentities($this->subject));
+    $smarty->assign("message", xmlentities($this->message));
+
     $display.= $smarty->fetch(get_template_path('DaemonEvent_notify.tpl', TRUE, dirname(__FILE__)));
     $display.= $this->get_footer();
     return($display);
   }
 
+
+  public function check()
+  {
+    $msgs = DaemonEvent::check();
+    if(empty($this->subject)){
+      $msgs[] = msgPool::required(_("Subject"));
+    }
+    if(empty($this->message)){
+      $msgs[] = msgPool::required(_("Message"));
+    }
+    return($msgs);
+  }
+
+
   public function save_object()
   {
     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['users'])){
+      foreach($_POST['users'] as $id){
+        if(isset($this->users[$id])){
+          unset($this->users[$id]);
+        }
+      }
+    }
+
+    if(isset($_POST['subject'])){
+      $this->subject = get_post('subject');
+    }
+    if(isset($_POST['message'])){
+      $this->message = get_post('message');
+    }
+  }
+
+  public function add_users($targets)
+  {
+    $this->users = $targets;
+  }
+
+  public function add_groups($targets)
+  {
+    $this->groups = $targets;
   }
 
   public function save()
   {
     $ret = DaemonEvent::save();
-    $ret['user'] = array("test","asdf");
-    print_a($ret);
+    $ret['users']   = array_values($this->users);
+    $ret['groups']  = array_values($this->groups);
+    $ret['subject'] = $this->subject;
+    $ret['message'] = $this->message;
     return($ret);
   }
 }