Code

Fixed post handling.
[gosa.git] / gosa-plugins / goto / addons / goto / events / class_DaemonEvent.inc
index ba24adf9d42a45c60433370e100ca05e00263cc6..6e56949ad80c86255a9477c0bdfd687876dc0c27 100644 (file)
@@ -59,7 +59,7 @@ class DaemonEvent
   protected $mode         = SCHEDULED_EVENT; // Default action is sheduled.
 
   /* Sub dialog hanlding */
-  protected $target_divlist       = NULL;     // The divlist used by the target add dialog
+  protected $target_listing       = NULL;     // The listing used by the target add dialog
   protected $target_add_list_used = FALSE;    // Indicates that the target add list was used.
   protected $time_select_used     = FALSE;    // Indicates that we have used the timestamp select boxes.
   protected $target_list_used     = FALSE;    // Target list was diaplayed?
@@ -111,13 +111,25 @@ class DaemonEvent
     }
 
     if(isset($data['PERIODIC']) && !preg_match("/none/i",$data['PERIODIC'])){
-      $tmp = split("_",$data['PERIODIC']);
+      $tmp = explode("_",$data['PERIODIC']);
       if(count($tmp) == 2){
         $this->activate_periodical_job = TRUE;
         $this->periodValue = $tmp[0];
         $this->periodType = $tmp[1];
       }
     }
+
+    // Prepare lists
+    $this->targetList = new sortableListing();
+    $this->targetList->setDeleteable(true);
+    $this->targetList->setInstantDelete(false);
+    $this->targetList->setEditable(false);
+    $this->targetList->setWidth("100%");
+    $this->targetList->setHeight("200px");
+    $this->targetList->setColspecs(array('*'));
+    $this->targetList->setHeader(array(_("Mac")));
+    $this->targetList->setDefaultSortColumn(0);
+    $this->targetList->setAcl('rwcdm');
   }
 
 
@@ -129,11 +141,10 @@ class DaemonEvent
     $this->time_select_used = FALSE;
     $this->target_list_used = FALSE;
 
-    $str = "<h2>"._("This job has no template!")."</h2>";
-    $str.= "<p class='seperator'></p>";
-    $str.= "<div style='text-align:right;width:100%;padding:3px;'>
-      <input type='submit' name='abort_event_dialog' value='".msgPool::cancelButton()."'>
-      </div>";
+    $str = "<h3>"._("This job has no template!")."</h3>";
+    $str.= "<hr>";
+    $str.= "<div class='plugin-actions'>
+      <button type='submit' name='abort_event_dialog'>".msgPool::cancelButton()."</button> </div>";
     return($str);
   }
 
@@ -145,7 +156,7 @@ class DaemonEvent
     if($this->target_add_list_used){
       return("");
     }
-    $str = "<h2>".sprintf(_("Create '%s' job"),$this->s_Event_Name)."</h2>";
+    $str = "<h3>".sprintf(_("Create '%s' job"),$this->s_Event_Name)."</h3>";
     return($str);
   }
 
@@ -158,10 +169,10 @@ class DaemonEvent
     if($this->target_add_list_used){
       return("");
     }
-    $str = "<p class='seperator'></p>";
-    $str.= "<div style='text-align:right;width:99%;padding:5px;'>
-      <input type='submit' name='save_event_dialog' value='".msgPool::saveButton()."'>&nbsp;
-    <input type='submit' name='abort_event_dialog' value='".msgPool::cancelButton()."'>
+    $str = "<hr>";
+    $str.= "<div class='plugin-actions'>
+        <button type='submit' name='save_event_dialog'>".msgPool::saveButton()."</button>&nbsp;
+        <button type='submit' name='abort_event_dialog'>".msgPool::cancelButton()."</button>
       </div>";
     return($str);
   }
@@ -243,39 +254,38 @@ class DaemonEvent
   } 
 
 
-  /*! \brief  HTML representation of all currently assigned targets using (divSelectBox).
+  /*! \brief  HTML representation of all currently assigned targets.
     @return String Returns a listbox with all used targets.
    */
   public function get_target_list()
   {
+    $data = $lData = array();
+
     $this->target_list_used = TRUE;
-    $divlist = new divSelectBox("EventTargets");
     foreach($this->a_targets as $key => $target){
-      $divlist->AddEntry(array(
-            array("string"  => $target),
-            array("string"  => "<input type='image' src='images/lists/trash.png' title='"._("Remove")."' name='del_target_".$key."'>",
-              "attach"  => "style='width:20px; border-right:0px;'")
-            ));
+      $data[$key] = $target;
+      $lData[$key] = array('data' => array($target));
     }
-    $list_footer = "<input type='submit' name='open_target_list' value='"._("Add")."'>";
-    return($divlist->DrawList().$list_footer);
+    $this->targetList->setListData($data, $lData);
+    $this->targetList->update();
+    $list_footer = "<button type='submit' name='open_target_list'>"._("Add")."</button>";
+    return($this->targetList->render().$list_footer);
   }
 
 
   /*! \brief  Returns HTML content, displaying a dialog which allows to add new targets.
-    @return String HTML content. (EventTargetAddList)
+    @return String HTML content. (EventAddSystemDialog)
    */
   public function get_target_add_list()
   {
     $this->target_add_list_used = TRUE;
 
-    if($this->target_divlist == NULL){ 
-      $this->target_divlist = new EventTargetAddList($this->config,$this);
+    if($this->target_listing == NULL){ 
+      $this->target_listing = new EventAddSystemDialog($this->config,$this);
     }
-    $this->target_divlist->execute();
 
     $smarty = get_smarty();
-    $smarty->assign("divlist",$this->target_divlist->Draw());
+    $smarty->assign("listing",$this->target_listing->execute());
     return($smarty->fetch(get_template_path('target_list.tpl', TRUE, dirname(__FILE__))));
   }
 
@@ -287,18 +297,18 @@ class DaemonEvent
     if(isset($_POST['open_target_list'])){
       $this->target_add_list_used =TRUE;
     }
-    if($this->target_divlist != NULL){
-      $this->target_divlist->save_object();
+    if($this->target_listing != NULL){
+      $this->target_listing->save_object();
     }
     if($this->target_add_list_used){
       if(isset($_POST['abort_target_dialog'])){
         $this->target_add_list_used =FALSE;
-        $this->target_divlist = NULL;
+        $this->target_listing = NULL;
       }
       if(isset($_POST['save_target_dialog'])){
         $this->target_add_list_used =FALSE;
-        $this->add_targets($this->target_divlist->get_selected_targets());
-        $this->target_divlist = NULL;
+        $this->add_targets($this->target_listing->get_selected_targets());
+        $this->target_listing = NULL;
       }
     }
 
@@ -327,16 +337,11 @@ class DaemonEvent
       }
     }
 
-    if($this->target_list_used){
-      foreach($_POST as $name => $value){
-        if(preg_match("/^del_target_/",$name)){
-          $id = preg_replace("/^del_target_([0-9]*)_.*/","\\1",$name);
-          if(isset($this->a_targets[$id])){
-            unset($this->a_targets[$id]);
-          }
-          break; 
-        }
-      }
+    $this->targetList->save_object();
+    $action = $this->targetList->getAction();
+    if($action['action'] == 'delete'){
+        $id = $this->targetList->getKey($action['targets'][0]);
+        unset($this->a_targets[$id]);
     } 
   }