Code

Added dummy 'edit' mechanism.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 14 Jan 2008 14:42:32 +0000 (14:42 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 14 Jan 2008 14:42:32 +0000 (14:42 +0000)
-Edit of queued jobs, partly implemented. SAn't be saved yet,only job is selectable.

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

gosa-core/include/class_gosaSupportDaemon.inc
gosa-core/plugins/addons/gotomasses/class_divListMasses.inc
gosa-core/plugins/addons/gotomasses/class_goto_task.inc
gosa-core/plugins/addons/gotomasses/class_gotomasses.inc
gosa-core/plugins/addons/gotomasses/goto_task.tpl

index f3d903329b674b72fa70309a1f40389ee5bbc68f..6cf2291880998373a64ddc88dfae8ad46231b79a 100755 (executable)
@@ -17,13 +17,13 @@ class gosaSupportDaemon
   private $b_error  = FALSE;
 
   public function __construct($host,$port,$key="secret-gosa-password",$connect=TRUE,$timeout=0.2)
-       {
+  {
     $this->s_host    = $host;
     $this->i_port    = $port;
     $this->f_timeout = $timeout;
     $this->s_encryption_key = $key;
   }
-  
+
   public function connect()
   {
     $this->o_sock = new Socket_Client($this->s_host,$this->i_port,TRUE,$this->f_timeout);
@@ -137,6 +137,63 @@ class gosaSupportDaemon
   {
     return($this->s_error);
   }
+
+  public function decrease_entry_priority($id)
+  {
+    echo $id;
+  }
+
+  public function increase_entry_priority($id)
+  {
+    echo $id;
+  }
+
+  public function max_entry_priority($id)
+  {
+    echo $id;
+  }
+
+  public function min_entry_priority($id)
+  {
+    echo $id;
+  }
+
+  public function id_exists($id)
+  {
+    return(TRUE);
+  }
+
+  public function get_entry($id)
+  {
+    foreach($this->entries as $entry){
+      if($entry['ID'] == $id){
+        return($entry);
+      }
+    }
+  }
+
+  public function update_entry($id,$entry)
+  {
+    $xml_msg = "";
+
+    if($this->is_connected){
+      $this->o_sock->write($xml_msg);
+      $str = trim($this->o_sock->read());
+      $entries = $this->xml_to_array($str);
+      $this->disconnect();
+      return(TRUE);
+    }
+    $this->set_error("Could not establish socket connection.");
+    return(FALSE);
+  }
+
+  public function add_multiple($multiple)
+  {
+  }
+
+  public function remove_entry($id)
+  {
+  }
 }
 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index 61bcb1111f9ea7c54509624dee919b1309c2e1f9..c02d3c012292b069ca8248318a7359f462a5d103 100644 (file)
@@ -116,7 +116,7 @@ class divListMasses extends MultiSelectWindow
 #      }
 
       /* Create actions */
-      $id         = $task['ROWID'];
+      $id         = $task['ID'];
       $queue_pos  = $id;
       $prio_actions = "<input class='center' type='image' src='images/prio_top.png'      name='prio_top_".$id."'>&nbsp;";
       $prio_actions.= "<input class='center' type='image' src='images/prio_increase.png' name='prio_increase_".$id."'>&nbsp;";
index 1fa84d1cb1c88b2cb8e26a8fb28a381debb6901b..b4d855cb5d753352c16d35563b78708a4d91fe5a 100644 (file)
@@ -7,478 +7,50 @@ class goto_task extends plugin
   var $plDescription  = "This does something";
  
   var $parent   = NULL;
-  var $Minute   = "*";
-  var $Hour     = "*";
-  var $Day      = "*";
-  var $Month    = "*";
-  var $Weekday  = "*";
-  var $Action   = "install";
-
-  var $Zone     = "";
-  var $Section  = "";
-
-  var $Zones    = array();
-  var $Sections = array();
-
-  var $Comment  = "";
-  var $OGroup   = "keep_current";
-  var $OGroups  = array();
-  var $Target   = array();
-  var $Initial_Target   = array();
-  var $Actions  = array();
-  var $new      = FALSE;
-  var $ID = 0;
-  var $TASK_ID =0;
-  var $attributes     = array("ID","TASK_ID","Zone","Section","OGroup","Minute","Hour","Day",
-                              "Month","Weekday","Action","Comment","Target","Initial_Target");
-
-  var $configure_dhcp = FALSE;
-  var $configure_dns  = FALSE;
+  var $data     = array();
 
+  var $attributes = array("MACADDRESS","ID","STATUS","HEADERTAG");
 
   function goto_task(&$config, &$parent, $data = array())
   {
     /* Set parent object */
     $this->parent = &$parent;
+    $this->data = $data;
 
     /* Intialize plugin */
     $this->config = &$config;
-    if(count($data)){
-      $tmp = $this->get_array_values();
-      foreach($this->attributes as $attr){
-        if(!isset($data[$attr])){
-          trigger_error("Missing parameter: '".$attr."' for goto_task contruction.");
-        }else{
-          $this->$attr = $data[$attr];
-        }
-      }
-    }else{
-      $this->new = TRUE;
-    }
-
-    if(!empty($this->Zone) && !preg_match("/^\"\"$/",$this->Zone)){
-      $this->configure_dns = TRUE;
-    }
-    if(!empty($this->Section) && !preg_match("/^\"\"$/",$this->Section)){
-      $this->configure_dhcp = TRUE;
-    }
-
-    /* Set dns and dhcp attributes */
-    foreach(getAvailableZones($this->config) as $zone){
-      $name = preg_replace("#^[^/]+/#","",$zone);
-      $this->Zones[$name] = $zone; 
-    }
-    $this->Sections = $this->get_dhcp_sections();
-
-    /* Create ogroup select list */
-    $this->OGroups = array("\"\""     => "["._("Keep current")."]");
-    $this->OGroups = array_merge($this->OGroups,$this->parent->get_object_groups());
-
-    /* Prepare list of available actions */
-    $this->Actions = $this->parent->get_actions();
   }
 
 
   function execute()
   {
-    /********
-     * Handle Posts  
-     ********/
-  
-    /* Handle Target options */
-    foreach($_POST as $name => $value){
-      if(preg_match("/^remove_/",$name)){
-        $value = preg_replace("/^remove_([0-9]*)_(x|y)$/i","\\1",$name);
-        if(isset($this->Target[$value]) && $this->Action != "initial_install"){
-          unset($this->Target[$value]);
-        }elseif(isset($this->Initial_Target[$value]) && $this->Action == "initial_install"){
-          unset($this->Initial_Target[$value]);
-        }
-      }
-    }
-
-    if($this->Action != "initial_install"){
-      
-      /* Add target */
-      if($this->ID == 0 && isset($_POST['add_target']) && !empty($_POST['target_text'])){
-        $target = get_post("target_text");
-        if($this->is_valid_target($target) && !in_array($target,$this->Target)){
-          $this->Target[] = $target;
-        }else{
-          print_red(_("You must specify a valid MAC address or host name."));
-        }
-      }
-    }else{
-
-      /* Add target */
-      if($this->ID ==0 && isset($_POST['add_target']) && !empty($_POST['task_MAC'])){
-        $MAC = $_POST['task_MAC'];
-        $NAME= "";
-        $IP  = "";
-        $DNS   = "";
-        $DHCP  = "";
-        if(isset($_POST['task_Name'])){
-          $NAME = $_POST['task_Name'];
-        }
-        if(isset($_POST['task_IP']) && tests::is_ip($_POST['task_IP'])){
-          $IP = $_POST['task_IP'];
-        }
-        if(isset($_POST['configure_dns']) && isset($_POST['Zone']) && isset($this->Zones[$_POST['Zone']])){
-          $DNS = $_POST['Zone'];
-        }
-        if(isset($_POST['configure_dhcp']) && isset($_POST['Section']) && isset($this->Sections[$_POST['Section']])){
-          $DHCP = $_POST['Section'];
-        }
-        if(tests::is_mac($MAC)){
-          $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME);
-        }
-      }
-    }
-
-    /* Add via csv */
-    if($this->ID == 0 && isset($_FILES['import_file'])){
-      $file = $_FILES['import_file']['tmp_name'];
-      if(file_exists($file) && is_readable($file)){
-        $str ="";
-        $fp = fopen($file,"r");
-        while(!feof($fp)){
-          $line = fgets($fp,512);
-          $tmp = preg_split("/(,|;)/",$line);
-
-          $MAC = $IP = $NAME; 
-          if(isset($tmp[0])){
-            $MAC = trim($tmp[0]);
-          }
-          if(isset($tmp[1])){
-            $IP = trim($tmp[1]);
-          }
-          if(isset($tmp[2])){
-            $NAME = trim($tmp[2]);
-          }
-          if(tests::is_mac($MAC)){
-            $this->Initial_Target[] = array("MAC"=>$MAC,"IP"=>$IP,"NAME"=>$NAME);
-          }
-        }
-      }
-    }
-  
-    /********
-     * Add target from list 
-     ********/
-
-    /* If add from list is was requsted, display this list */ 
-    if(isset($_POST['add_from_list'])){
-      $this->dialog = new target_list($this->config,$this->Target);
-    }
-
-    /* Save selected objects as target */
-    if(isset($_POST['SaveMultiSelectWindow']) && is_object($this->dialog)){
-      $this->dialog->save_object();
-      $ret = $this->dialog->save();
-      foreach($ret as $entry){
-        $this->Target[] = $entry['cn'][0];
-      }
-      $this->dialog = FALSE;
-    }
-
-    /* Cancel object listing */
-    if(isset($_POST['CloseMultiSelectWindow'])){
-      $this->dialog = FALSE;
-    }
-
-    /* Display object Listing */
-    if(is_object($this->dialog)){
-      $this->dialog->save_object();
-      return($this->dialog->execute());
-    }
-
-    /********
-     * Display this plugin  
-     ********/
-
-    $divlist = new divlist("goto_task");
-#    $divlist->SetPluginMode(); 
-    $divlist->setHeight(200);
-    $divlist->SetWidth("100%");
-    $divlist->SetEntriesPerPage(0);
-
-    $acl_target = $this->parent->getacl("Target");
-    if(preg_match("/w/i",$acl_target)){
-      $field_del = array("string" => "<input type='image' src='images/edittrash.png' name='remove_%KEY%'>" , 
-          "attach" => "style='width:44px;border-right:0px;'");
-    }else{
-      $field_del = array("string" => "",
-          "attach" => "style='width:44px;border-right:0px;'");
-    }
-
-    /* Add entries to divlist */
-    if($this->Action == "initial_install"){
-      $divlist->SetHeader(array(
-                            array("string" => _("Target systems") ,"attach" => "style='width:120px;'"),
-                            array("string" => _("IP")      , "attach" => "style='width:90px;'"),
-                            array("string" => _("Name")    , "attach" => "style='width:150px;'"),
-                            array("string" => _("Actions") , "attach" => "style='width:44px;border-right:0px;text-align:right;'")));
-      foreach($this->Initial_Target as $key => $target){
-        $field1 = array("string" => $target['MAC']  ,"attach" => "style='width:120px;'");
-        $field2 = array("string" => $target['IP']   ,"attach" => "style='width:90px;'");
-        $field3 = array("string" =>  $target['NAME'] ,"attach" => "style='width:150px;'");
-        $divlist->AddEntry(array($field1,$field2,$field3,preg_replace("/%KEY%/",$key,$field_del)));
-      } 
-    }else{
-      $divlist->SetHeader(array(
-                            array("string" => "Target", "attach" => "style=''"),
-                            array("string" => "Actions" , "attach" => "style='width:44px;border-right:0px;text-align:right;'")));
-      foreach($this->Target as $key => $target){
-        $field1 = array("string" => $target);
-        $divlist->AddEntry(array($field1,preg_replace("/%KEY%/",$key,$field_del)));
-      } 
-    }
-
     $smarty = get_smarty();
+    $smarty->assign("Actions",$this->parent->get_actions());
     foreach($this->attributes as $attr){
-      $smarty->assign($attr."ACL", $this->parent->getacl($attr));
-      $smarty->assign($attr,$this->$attr);
-    }
-
-    $smarty->assign("Zones", $this->Zones);
-    $smarty->assign("Sections", $this->Sections);
-
-    $smarty->assign("ID",$this->ID);
-  
-    $smarty->assign("Zone", $this->Zone);
-    $smarty->assign("Section", $this->Section);
-
-    $smarty->assign("configure_dhcp", $this->configure_dhcp);
-    $smarty->assign("configure_dns", $this->configure_dns);
-
-    $tmp = $this->get_array_values();
-    $smarty->assign("JS"      , session::get('js'));
-    $smarty->assign("Minutes" , $tmp['Minute']);
-    $smarty->assign("Hours"   , $tmp['Hour']);
-    $smarty->assign("Days"    , $tmp['Day']);
-    $smarty->assign("Months"  , $tmp['Month']);
-    $smarty->assign("Weekdays", $tmp['Weekday']);
-    $smarty->assign("OGroups" , $this->OGroups);
-    $smarty->assign("Actions"     , $this->Actions);
-    $smarty->assign("Target_list" , $divlist->DrawList());
-    $smarty->assign("new"      , $this->new);
-    return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE)));
-  }
-
-
-  function create_tree($arr,$base,$current = "")
-  {
-    $ret = array();
-    foreach($arr as $r => $name){
-      $base_part = str_replace($base,"",$r);
-      if(preg_match("/^[a-z]*=".normalizePreg($name)."(|,)$/i",$base_part)){
-        $ret[$r] = $current.$name;
-        $tmp = $this->create_tree($arr,$r,$current.".&nbsp;");
-        foreach($tmp as $sub_key => $sub_name){
-          $ret[$sub_key] = $sub_name;
-        }
-      }
-    }
-    return($ret);
-  }
-
-
-
-  function get_dhcp_sections()
-  {
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(objectClass=dhcpService)",array("dhcpPrimaryDN"));
-
-    $tmp   = array();
-    $tmp2  = array();
-
-    $dhcp_dns = array();
-    while($attr = $ldap->fetch()){
-      $dhcp_dns[$attr['dn']] = $attr['dhcpPrimaryDN'][0];
-    }
-
-    foreach($dhcp_dns as $key => $pri_dns){
-      $ldap->cat($pri_dns,array("cn"));
-      $tmp = $ldap->fetch();
-      $dhcp_dns[$key] = $tmp['cn'][0];
-    }
-
-    foreach($dhcp_dns as $dn => $cn){
-      $ldap->cd($dn);
-      $ldap->search("(|(objectClass=dhcpService)(objectClass=dhcpGroup)".
-                    "(objectClass=dhcpSubnet)(objectClass=dhcpSharedNetwork))",array("cn"));
-      $tmp = array();
-      while($attr = $ldap->fetch()){
-        $tmp[$attr['dn']] = $attr['cn'][0];
-      }
-      $tmp2 = $this->create_tree($tmp,preg_replace("/^[^,]+,/i","",$dn),"(".$cn.")&nbsp;");
-    }
-    $ret = array();
-    foreach($tmp2 as $key => $label){
-      $ret[$tmp[$key]] = $label;
-    }
-    return($ret);
-  }
-
-  
-  /* check given values */
-  function check()
-  {
-    $message = plugin::check();
-    $tmp = array(
-      "OGroup" => _("Object group") ,"Minute" => _("Minute"),
-      "Hour"   => _("Hour")         ,"Day"    => _("Day"),
-      "Month"  => _("Month")        ,"Weekday"=> _("Week day"),
-      "Action" => _("Action")       ,"Comment"=> _("Description"));
-    
-    foreach($tmp as $name => $desc){
-      if(empty($this->$name) && $this->$name != 0){
-        $message[] = sprintf(_("The given value for attribute '%s' is invalid."),$desc);
+      if(isset($this->data[$attr])){
+        $smarty->assign($attr,$this->data[$attr]);
+      }else{
+        $smarty->assign($attr,"");
       }
     }
-    if(count($this->Target) == 0 && $this->Action != "initial_install"){
-      $message[] = sprintf(_("You must specify at least one target"));
-    }
-    if(count($this->Initial_Target) == 0 && $this->Action == "initial_install"){
-      $message[] = sprintf(_("You must specify at least one target"));
-    }
-    return($message);
-  }
-  
-
-  /* Map acl function, to be able to use plugin::save_object() */
-  function acl_is_writeable($attribute,$skip_write = FALSE)
-  {
-    return($this->parent->acl_is_writeable($attribute,$skip_write));
+    return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE)));
   }
 
 
   function save_object()
   {
-    if(isset($_POST['goto_task_posted'])){
-
-      if($this->Action == "initial_install"){
-        if(isset($_POST['configure_dns'])){
-          $this->configure_dns = TRUE;
-          if(isset($_POST['Zone'])){
-            $this->Zone = get_post("Zone");
-          }
-        }else{
-          $this->Zone = "\"\"";
-          $this->configure_dns = FALSE;
-        }
-
-        if(isset($_POST['configure_dhcp'])){
-          $this->configure_dhcp = TRUE;
-          if(isset($_POST['Section'])){
-            $this->Section = get_post("Section");
-          }
-        }else{
-          $this->configure_dhcp = FALSE;
-          $this->Section = "\"\"";
-        }
-      }
-      plugin::save_object();
-    }
-  }  
-
-
-  /* Check if given target is vald.
-   * It must either be a valid MAC address or an existing object group
-   */
-  function is_valid_target($str)
-  {
-    if(tests::is_mac($str)){
-      return(TRUE);
-    }else{
-      $ldap = $this->config->get_ldap_link();
-      $ldap->cd($this->config->current['BASE']);
-      $ldap->search("(&(objectClassgosaGroupOfNames)(cn=".$str."))",array("cn"));
-      if($ldap->count()){
-        return(TRUE);
+    if(isset($_POST['HeaderTag'])){
+      $possible_tags = $this->parent->get_actions();
+      $tag = $_POST['HeaderTag'];
+      if(isset($possible_tags[$tag])){
+        $this->data['HEADERTAG'] = $tag;
       }
     }
   }
 
   function save()
   {
-    $tmp = array();
-    foreach($this->attributes as $attr){
-      $tmp[$attr] = $this->$attr;
-    }
-
-    if($this->Action != "initial_install" || !$this->configure_dns){
-      $tmp['Zone'] = "\"\"";
-    }
-    if($this->Action != "initial_install" || !$this->configure_dhcp){
-      $tmp['Section'] = "\"\"";
-    }
-    return($tmp);
-  }
-
-
-  /* Return values for listboxes. 
-   */
-  function get_array_values()
-  {
-    $ret = array();    
-
-    /* Create minute array */
-    $Minute = array( "*"    => "*",
-                      "*/1"  => "*/1",
-                      "*/3"  => "*/3",
-                      "*/5"  => "*/5",
-                      "*/10" => "*/10",
-                      "*/15" => "*/15",
-                      "*/30" => "*/30",
-                      "*/45" => "*/45",
-                      "*/60" => "*/60"); 
-    for($i = 0; $i < 60 ; $i ++){
-      $Minute[$i] = $i;
-    }
-
-    /* Create hour array */
-    $Hour = array(   "*" => "*");
-    for($i = 1 ; $i < 24 ; $i ++ ){
-      $Hour["*/".$i] = "*/".$i;
-    } 
-    for($i = 0 ; $i < 24 ; $i ++ ){
-      $Hour[$i] = $i;
-    } 
-
-    /* Create hour array */
-    $Day = array( "*" => "*");
-    for($i = 1 ; $i < 32 ; $i ++ ){
-      $Day["*/".$i] = "*/".$i;
-    } 
-    for($i = 1 ; $i < 32 ; $i ++ ){
-      $Day[$i] = $i;
-    } 
-   
-    /* Create month array */
-    $Month = array( "*" => "*");
-    for($i = 1 ; $i <= 12 ; $i ++ ){
-      $Month["*/".$i] = "*/".$i;
-    } 
-    for($i = 1 ; $i <= 12 ; $i ++ ){
-      $Month[$i] = $i;
-    } 
-   
-    /* Create week day array */
-    $Weekday = array( "*" => "*");
-    for($i = 1 ; $i <= 7 ; $i ++ ){
-      $Weekday["*/".$i] = "*/".$i;
-    } 
-    for($i = 0 ; $i <= 7 ; $i ++ ){
-      $Weekday[$i] = $i;
-    } 
-   
-    foreach(array("Minute","Weekday","Hour","Day","Month") as $var){
-      $ret[$var] = $$var;
-    }
-    return($ret);
+    return($this->data);
   }
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
index f3655367aa9e115229097d1f79c582d7ec648f5e..d34a7364176b893d032d94b75ff42063a3125e1a 100644 (file)
@@ -126,7 +126,7 @@ class gotomasses extends plugin
         foreach($this->ids_to_remove as $key => $id){
           if($this->o_queue->id_exists($id)){
             $task = $this->o_queue->get_entry($id);
-            $tmp.= "\n".$task['ROWID'];
+            $tmp.= "\n".$task['ID'];
           }else{
             unset($this->ids_to_remove[$key]);
           }
@@ -154,68 +154,68 @@ class gotomasses extends plugin
     }
 
 
-#   /************
-#    * EDIT 
-#    ************/
-#
-#   /* Edit selected entry */
-#   if($s_action == "edit"){
-#     $entry = $this->o_queue->get_entry($s_entry);
-#     if($entry){
-#       $this->dialog = new goto_task($this->config,$this,$entry);
-#       $this->current = $s_entry;
-#     }
-#   }
-#
-#   /* New entry */
-#   if($s_action== "new_task" && $this->acl_is_createable()){
-#     $this->dialog = new goto_task($this->config,$this);
-#     $this->current = -1;
-#   }
-# 
-#   /* Close dialog */
-#   if(isset($_POST['close_goto_task'])){
-#     $this->dialog = FALSE;
-#     $this->current = -1;
-#   }
-#
-#   /* Close dialog */
-#   if((isset($_POST['save_goto_task']) || isset($_POST['apply_goto_task'])) && is_object($this->dialog) ){
-#     $this->dialog->save_object();
-#     $msgs = $this->dialog->check();
-#     if(count($msgs)){
-#       foreach($msgs as $msg){
-#         print_red($msg);  
-#       }
-#     }else{  
-#       
-#       if($this->o_queue->id_exists($this->current)){
-#         $this->o_queue->update_entry($this->current,$this->dialog->save());
-#       }else{
-#         $tmp = $this->dialog->save();
-#         $tmp2= array();
-#         $targets =$tmp['Target'];
-#         foreach($targets as $target){
-#           $tmp['Target'] = array($target);
-#           $tmp2[] = $tmp;
-#         }
-#         if(!$this->o_queue->add_multiple($tmp2)){
-#           print_red($this->o_queue->get_error());
-#         }
-#       }
-#       if(!isset($_POST['apply_goto_task'])){
-#         $this->dialog = FALSE;
-#         $this->current = -1;
-#       }
-#       $this->save();
-#     }
-#   }
-#
-#   /* Display dialogs if currently opened */
-#   if(is_object($this->dialog)){
-#     $this->dialog->save_object();
-#     return($this->dialog->execute());
-#   }
+   /************
+    * EDIT 
+    ************/
+
+   /* Edit selected entry */
+   if($s_action == "edit"){
+     $entry = $this->o_queue->get_entry($s_entry);
+     if($entry){
+       $this->dialog = new goto_task($this->config,$this,$entry);
+       $this->current = $s_entry;
+     }
+   }
+
+   /* New entry */
+   if($s_action== "new_task" && $this->acl_is_createable()){
+     $this->dialog = new goto_task($this->config,$this);
+     $this->current = -1;
+   }
+   /* Close dialog */
+   if(isset($_POST['close_goto_task'])){
+     $this->dialog = FALSE;
+     $this->current = -1;
+   }
+
+   /* Close dialog */
+   if((isset($_POST['save_goto_task']) || isset($_POST['apply_goto_task'])) && is_object($this->dialog) ){
+     $this->dialog->save_object();
+     $msgs = $this->dialog->check();
+     if(count($msgs)){
+       foreach($msgs as $msg){
+         print_red($msg);  
+       }
+     }else{  
+       
+       if($this->o_queue->id_exists($this->current)){
+         $this->o_queue->update_entry($this->current,$this->dialog->save());
+       }else{
+         $tmp = $this->dialog->save();
+         $tmp2= array();
+         $targets =$tmp['Target'];
+         foreach($targets as $target){
+           $tmp['Target'] = array($target);
+           $tmp2[] = $tmp;
+         }
+         if(!$this->o_queue->add_multiple($tmp2)){
+           print_red($this->o_queue->get_error());
+         }
+       }
+       if(!isset($_POST['apply_goto_task'])){
+         $this->dialog = FALSE;
+         $this->current = -1;
+       }
+       $this->save();
+     }
+   }
+
+   /* Display dialogs if currently opened */
+   if(is_object($this->dialog)){
+     $this->dialog->save_object();
+     return($this->dialog->execute());
+   }
 
     /************
      * Handle Divlist 
@@ -240,10 +240,10 @@ class gotomasses extends plugin
     $tasks = array();
     $ret = array();
     while($entry = $this->o_queue->fetch()){
-      $task = $entry['ROWID']; 
+      $task = $entry['ID']; 
       $ret[]= $entry;
     }
-    $map = array("QueuePosition" => "ROWID",
+    $map = array("QueuePosition" => "ID",
                  "Action"        => "STATUS",
                  "TaskID"        => "HEADERTAG",
                  "TargetName"    => "MACADDRESS",
@@ -323,17 +323,10 @@ class gotomasses extends plugin
  function get_actions()
  {
    /* Prepare list of available actions */
-   $actions = array(       
-       "Dummy."          => "!!!!!!!! Update",                     
-       "reboot"          => _("Reboot"),
-       "localboot"       => _("Localboot"),
-       "halt"            => _("Halt system"),
-       "initial_install" => _("Initial installation"),
-       "update"          => _("Update"),
-       "reinstall"       => _("(Re)Install"),
-       "rescan"          => _("Rescan"),
-       "wake"            => _("Wake"),
-       "memcheck"        => _("Memory check"));
+   $actions = array(      
+       "gosa_ping"       => _("GOsa ping"),
+       "ping"            => _("Ping"),
+       "sayHello"        => _("Say hello"));
    return($actions);
  }
 
index f841a4fd8501750d433c1f93afb59fffa9892add..bc0cf044a7890f7410b03cb5b926b1cc9e383857 100644 (file)
                </td>
        </tr>
        <tr>
-               <td style='width:50%;border-right: 1px solid rgb(160, 160, 160);'>
+               <td>
                        <table>
                                <tr>
                                        <td>
-                                               {t}Description{/t}
-                                       </td>
-                                       <td>
-                                               {render acl=$CommentACL}
-                                               <input type="text" name="Comment" value="{$Comment}">
-                                               {/render}
+                                               {t}Job ID{/t}
                                        </td>
+                                       <td>    
+                                               {$ID}
+                                       </td>   
                                </tr>
                                <tr>
                                        <td>
-                                               {t}Object group membership{/t}
-                                       </td>
-                                       <td>
-                                               {render acl=$OGroupACL}
-                                               <select name="OGroup">
-                                                       {html_options options=$OGroups selected=$OGroup}
-                                               </select>
-                                               {/render}
+                                               {t}Status{/t}
                                        </td>
+                                       <td>    
+                                               {$STATUS}
+                                       </td>   
                                </tr>
-                               {if $Action == "initial_install"}
-                               <tr>
-                                       <td><input class='center' {if $configure_dns} checked {/if} id='configure_dns'
-                                               type='checkbox' name='configure_dns' value='1' onClick="changeState('Zone');">
-                                               <label for='configure_dns'>{t}Configure DNS{/t}</label>
-                                       </td>
-                                       <td>
-                                               <select name="Zone" id="Zone" {if !$configure_dns} disabled {/if}>
-                                                       {html_options options=$Zones selected=$Zone}
-                                               </select>
-                                       </td>
-                               </tr>
-                               <tr>
-                                       <td><input class='center' {if $configure_dhcp} checked {/if} id='configure_dhcp' 
-                                                       type='checkbox' name='configure_dhcp' value='1' onClick="changeState('Section');">
-                                               <label for='configure_dhcp'>{t}Configure DHCP{/t}</label>
-                                       </td>
-                                       <td>
-                                               <select name="Section" id="Section" {if !$configure_dhcp} disabled {/if}>
-                                                       {html_options options=$Sections selected=$Section}
-                                               </select>
-                                       </td>
-                               </tr>
-                               {/if}
-                       </table>
-               </td>
-               <td style='vertical-align:top'>
-                       <table>
-                               <tr>
-                                       <td>
-                                               {t}Action{/t}
-                                       </td>
-                                       <td>
-                                               {render acl=$ActionACL}
-                                               <select name="Action" onChange="document.mainform.submit();">
-                                                       {html_options options=$Actions selected=$Action}
-                                               </select>
-                                               {/render}
-                                               {if !$JS}
-                                                       <input type='image' src='images/list_reload.png' class='center'>
-                                               {/if}
-                                       </td>
-                               </tr>
-                       </table>
-
-               </td>
-       </tr>
-</table>
-{if $Action == "initial_install"}
-{if $ID == 0}
-<p class='seperator'>&nbsp;</p>
-<table style='width:100%;'>
-       <tr>
-               <td colspan="2" style='padding-top:5px;'>
-                       <h2><img alt="" src="images/select_workstation.png" class="center" align="middle"> {t}Systems{/t}</h2>
-               </td>
-       </tr>
-       <tr>
-               <td colspan="2">
-            <table  summary="" style="border:1px solid #B0B0B0;width:100%; " cellspacing=0 cellpadding=0>
-                <tr>   
+                   <tr>
                     <td>
-                                               {render acl=$TargetACL}
-                                               {$Target_list}  
-                                               {/render}
-                                       </td>
-                               </tr>
-                       </table>
-               </td>
-       </tr>
-       <tr>
-               <td style="width:50%; border-right: 1px solid #A0A0A0;">
-                       <table>
-                               <tr>
-                                       <td>{t}MAC address{/t}{$must}
-                                       </td>
-                                       <td><input type="text" name="task_MAC" value="">        
-                                       </td>
-                               </tr>
-                               <tr>
-                                       <td>{t}Name{/t}
-                                       </td>
-                                       <td><input type="text" name="task_Name" value="">       
-                                       </td>
-                               </tr>
-                               <tr>
-                                       <td>{t}IP address{/t}
-                                       </td>
-                                       <td><input type="text" name="task_IP" value=""> 
-                                               {render acl=$TargetACL}
-                                               <input type="submit" name="add_target" value="{t}Add{/t}">
-                                               {/render}
-                                       </td>
-                               </tr>
-                       </table>
-               </td>
-               <td style='vertical-align:top'>
-                       <table>
-                               <tr><td>{t}CVS import from file{/t}</td></tr>
+                        {t}Mac{/t}
+                    </td>
+                    <td>
+                        {$MACADDRESS}
+                    </td>
+                </tr>
                                <tr>
                                        <td>
-            &nbsp;
+                                               {t}Header Tag{/t}
                                        </td>
-                               </tr>
-                               <tr>
                                        <td>
-                                               <input type="hidden" name="MAX_FILE_SIZE" value="2000000">
-                                   <input name="import_file" type="file" size="20" maxlength="255" accept="*.csv">
-                                               {render acl=$TargetACL}
-                                               <input type="submit" name="add_import" value="{t}Import{/t}">
-                                               {/render}
+                                               <select name="HeaderTag">
+                                                       <option value="unknown">{t}Unknown{/t}</option>
+                                                       {html_options options=$Actions selected=$HEADERTAG} 
+                                               </select>       
                                        </td>
                                </tr>
                        </table>
                </td>
        </tr>
 </table>
-{/if}
-{else}
-<p class='seperator'>&nbsp;</p>
-<table style='width:100%;'>
-       <tr>
-               <td colspan="2">
-                       <h2><img alt="" src="images/time.png" class="center" align="middle"> {t}Schedule{/t}</h2>
-               </td>
-       </tr>
-       <tr>
-               <td colspan="2">
-                       {t}Minute{/t}
-                       {render acl=$MinuteACL}
-                               <select name='Minute'>
-                               {html_options options=$Minutes selected=$Minute}
-                               </select>
-                       {/render}
-                       {t}Hour{/t}
-                       {render acl=$HourACL}
-                               <select name='Hour'>
-                               {html_options options=$Hours selected=$Hour}
-                               </select>
-                       {/render}
-                       {t}Day{/t}
-                       {render acl=$DayACL}
-                               <select name='Day'>
-                               {html_options options=$Days selected=$Day}
-                               </select>
-                       {/render}
-                       {t}Month{/t}
-                       {render acl=$MonthACL}
-                               <select name='Month'>
-                               {html_options options=$Months selected=$Month}
-                               </select>
-                       {/render}
-                       {t}Week day{/t}
-                       {render acl=$WeekdayACL}
-                               <select name='Weekday'>
-                               {html_options options=$Weekdays selected=$Weekday}
-                               </select>
-                       {/render}
-               </td>
-       </tr>
-</table>
-{if $ID == 0}
-<p class='seperator'>&nbsp;</p>
-<table style='width:100%;'>
-       <tr>
-               <td colspan="2" style='padding-top:5px;'>
-                       <h2><img alt="" src="images/select_workstation.png" class="center" align="middle"> {t}Target systems{/t}</h2>
-               </td>
-       </tr>
-       <tr>
-               <td colspan="2">
-            <table  summary="" style="border:1px solid #B0B0B0;width:100%; " cellspacing=0 cellpadding=0>
-                <tr>
-                    <td>
-                                               {render acl=$TargetACL}
-                                               {$Target_list}  
-                                               {/render}
-                                       </td>
-                               </tr>
-                       </table>
-                                               {render acl=$TargetACL}
-                                               <input type="text" name="target_text" value="">
-                                               {/render}
-                                               {render acl=$TargetACL}
-                                               <input type="submit" name="add_target" value="{t}Add{/t}">
-                                               {/render}
-                                               {render acl=$TargetACL}
-                                               <input type="submit" name="add_from_list" value="{t}Add from list{/t}">
-                                               {/render}
 
-               </td>
-       </tr>
-</table>
-{/if}
-{/if}
+<input type="submit" name="test" value="Test submit()">
+       
 <p class='seperator'>&nbsp;</p>
 <input type='hidden' name='goto_task_posted' value='1'>
 <p style="text-align:right">
        <input type='submit' name='save_goto_task' value='{t}Ok{/t}'>
-{if !$new}
-       <input type='submit' name='apply_goto_task' value='{t}Apply{/t}'>
-{/if}
        <input type='submit' name='close_goto_task' value='{t}Cancel{/t}'>
 </p>