Code

Updated gotmasses.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Feb 2008 07:45:55 +0000 (07:45 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 26 Feb 2008 07:45:55 +0000 (07:45 +0000)
-Can edit events now.

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

gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc
gosa-plugins/goto/addons/gotomasses/events/DaemonEvent_wakeup.tpl
gosa-plugins/goto/addons/gotomasses/events/class_DaemonEvent.inc
gosa-plugins/goto/addons/gotomasses/events/class_DaemonEvent_wakeup.inc

index b59bd6b1ad27a52f38a5673b6e72956faf09a404..9351fc9b47a9d73e529ac3ad94528a092dd32a59 100644 (file)
@@ -189,22 +189,33 @@ class gotomasses extends plugin
     /* Close dialog */
     if(isset($_POST['save_event_dialog'])){
 
-      if($this->dialog->is_new()){
-        $header     = $this->dialog->get_header_tag();
-        $targets    = $this->dialog->get_targets();
-        $data       = $this->dialog->save();
-        $data['timestamp'] = $this->dialog->get_timestamp(); 
-        
-
-        foreach($targets as $target){
-          $data['mac'] =  $target;
-          if(!$this->o_queue->send($header,$target,$data,TRUE)){
-            msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
-                  $this->o_queue->get_error()),ERROR_DIALOG);
-          }  
+      if(is_object($this->dialog)){
+
+        if($this->dialog->is_new()){
+          $header     = $this->dialog->get_header_tag();
+          $targets    = $this->dialog->get_targets();
+          $data       = $this->dialog->save();
+          $data['timestamp'] = $this->dialog->get_timestamp(); 
+
+
+          foreach($targets as $target){
+            $data['mac'] =  $target;
+            if(!$this->o_queue->send($header,$target,$data,TRUE)){
+              msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
+                    $this->o_queue->get_error()),ERROR_DIALOG);
+            }  
+          }
+          $this->dialog = FALSE; 
+          $this->current = -1;
+        }else{
+          $id                 = $this->dialog->get_id();
+          $data               = $this->dialog->save();
+          $data['timestamp']  = $this->dialog->get_timestamp();
+          if($this->o_queue->update_entries(array($id),$data)){
+            $this->dialog = FALSE;
+            $this->current = -1;
+          }
         }
-        $this->dialog = FALSE; 
-        $this->current = -1;
       }
     }
 
@@ -286,16 +297,16 @@ class gotomasses extends plugin
 
     foreach($this->entries as $key => $task){
 
-      $prio_actions = "<input class='center' type='image' src='images/prio_increase.png' name='prio_up_".$task['ID']."'>&nbsp;";
-      $prio_actions.= "<input class='center' type='image' src='images/prio_decrease.png' name='prio_down_".$task['ID']."'>&nbsp;";
-      $prio_actions.= "<input class='center' type='image' src='images/status_stop_all.png' name='stop_".$task['ID']."'>&nbsp;";
-      $prio_actions.= "<input class='center' type='image' src='images/status_start_all.png' name='start_".$task['ID']."'>&nbsp;";
+      $prio_actions = "<input class='center' type='image' src='images/prio_increase.png' name='prio_up_".$key."'>&nbsp;";
+      $prio_actions.= "<input class='center' type='image' src='images/prio_decrease.png' name='prio_down_".$key."'>&nbsp;";
+      $prio_actions.= "<input class='center' type='image' src='images/status_stop_all.png' name='stop_".$key."'>&nbsp;";
+      $prio_actions.= "<input class='center' type='image' src='images/status_start_all.png' name='start_".$key."'>&nbsp;";
 
-      $action = "<input type='image' src='images/edit.png' name='edit_task_".$task['ID']."' 
+      $action = "<input type='image' src='images/edit.png' name='edit_task_".$key."' 
         class='center' alt='"._("Edit")."'>";
 
       if($this->acl_is_removeable()){
-        $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$task['ID']."' 
+        $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$key."' 
           class='center' alt='"._("Reomve")."'>";
       }
 
@@ -309,7 +320,7 @@ class gotomasses extends plugin
       }
 
       /* Create each field */
-      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$task['ID']."' name='item_selected_".$task['ID']."'>" ,
+      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
                       "attach" => "style='width:20px;".$color."'");
       $field1 = array("string" => $display,
                       "attach" => "style='".$color."'");
index 04a278c368613eb5f508ce535f3fdcc3f2616352..4e3fc127d969422457a48dc11387dc7298378bbb 100644 (file)
@@ -1,4 +1,6 @@
 
+{if $is_new}
+
 <table style='width:100%;'>
        <tr>
                <td style='width:50%; vertical-align:top;'>
                </td>
        </tr>
 </table>
+
+{else}
+
+<table style='width:100%;'>
+       <tr>
+               <td style='width:50%; vertical-align:top;'>
+                       <table>
+                               <tr>
+                                       <td>{t}ID{/t}</td>
+                                       <td>{$data.ID}</td>
+                               </tr>
+                               <tr>
+                                       <td>{t}Status{/t}</td>
+                                       <td>{$data.STATUS}</td>
+                               </tr>
+                               <tr>
+                                       <td>{t}Result{/t}</td>
+                                       <td>{$data.RESULT}</td>
+                               </tr>
+                               <tr>
+                                       <td>{t}Target{/t}</td>
+                                       <td>{$data.MACADDRESS}</td>
+                               </tr>
+                               <tr>
+                                       <td style='vertical-align:top'>{t}Timestamp{/t}</td>
+                                       <td>{$timestamp}</td>
+                               </tr>
+                       </table>
+               </td>
+               <td style='width:50%; vertical-align:top;'>
+                       <table >
+                       </table>
+               </td>
+       </tr>
+</table>
+
+{/if}
index df4c05a119ce4cdd085638e8123ddfb0fdbc9c18..8da1e500e332f9b3d998d6bc0db9bdbb44272790 100644 (file)
@@ -58,6 +58,11 @@ class DaemonEvent
     /* Load values from given data */
     if(count($data)){
       $this->is_new = FALSE;
+  
+      $attrs = array("id" => "ID");
+      foreach($attrs as $to => $from){
+        $this->$to = $data[$from];
+      }
     }
   }
 
@@ -349,6 +354,19 @@ class DaemonEvent
   }
 
 
+  /*! \brief  Returns the event ID
+      @return Returns the event ID
+   */
+  public function get_id()
+  {
+    if($this->is_new){
+      return(-1);
+    }else{
+      return($this->data['ID']);
+    }
+  }
+
+
   /*! \brief  Returns a set of elements selected in a MultiSelectWindow
       @return Array[integer]=integer
    */
index bb1530d6a5bcd32f25dd29de478e5e0b00e67023..9386ea1d11c1ec8970950472e8f66a10b9074884 100644 (file)
@@ -19,16 +19,19 @@ class DaemonEvent_wakeup extends DaemonEvent
 
     $display = $this->get_header();
 
+    $tmp = $this->data;
+
     /* Check if target add dialog is open */
-    if($this->is_target_list_open()){
-      $display .= $this->get_target_add_list();
-    }else{
-      $smarty = get_smarty();
-      $smarty->assign("target_list" , $this->get_target_list());
-      $smarty->assign("timestamp"   , $this->get_time_select());
-      $display.= $smarty->fetch(get_template_path('DaemonEvent_wakeup.tpl', TRUE, dirname(__FILE__)));
-    }   
+    if($this->is_target_list_open() && $this->is_new){
+      return($this->get_target_add_list());
+    }
+
+    $smarty = get_smarty();
+    $smarty->assign("data"        , $this->data);
+    $smarty->assign("target_list" , $this->get_target_list());
+    $smarty->assign("is_new"      , $this->is_new);
+    $smarty->assign("timestamp"   , $this->get_time_select());
+    $display.= $smarty->fetch(get_template_path('DaemonEvent_wakeup.tpl', TRUE, dirname(__FILE__)));
     $display.= $this->get_footer();
     return($display);
   }