Code

Moved gotomasses to gosa-plugins/goto
authorcajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 15 Feb 2008 14:47:36 +0000 (14:47 +0000)
committercajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 15 Feb 2008 14:47:36 +0000 (14:47 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8933 594d385d-05f5-0310-b6e9-bd551577e9d8

14 files changed:
gosa-core/plugins/addons/gotomasses/class_goto_task.inc [deleted file]
gosa-core/plugins/addons/gotomasses/class_gotomasses.inc [deleted file]
gosa-core/plugins/addons/gotomasses/class_target_list.inc [deleted file]
gosa-core/plugins/addons/gotomasses/goto_task.tpl [deleted file]
gosa-core/plugins/addons/gotomasses/gotomasses.tpl [deleted file]
gosa-core/plugins/addons/gotomasses/main.inc [deleted file]
gosa-core/plugins/addons/gotomasses/remove.tpl [deleted file]
gosa-plugins/goto/addons/gotomasses/class_goto_task.inc [new file with mode: 0644]
gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc [new file with mode: 0644]
gosa-plugins/goto/addons/gotomasses/class_target_list.inc [new file with mode: 0644]
gosa-plugins/goto/addons/gotomasses/goto_task.tpl [new file with mode: 0644]
gosa-plugins/goto/addons/gotomasses/gotomasses.tpl [new file with mode: 0644]
gosa-plugins/goto/addons/gotomasses/main.inc [new file with mode: 0644]
gosa-plugins/goto/addons/gotomasses/remove.tpl [new file with mode: 0644]

diff --git a/gosa-core/plugins/addons/gotomasses/class_goto_task.inc b/gosa-core/plugins/addons/gotomasses/class_goto_task.inc
deleted file mode 100644 (file)
index e6f0eb2..0000000
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-
-class goto_task extends plugin
-{
-  /* Definitions */
-  var $plHeadline     = "System mass deployment";
-  var $plDescription  = "This does something";
-  var $parent   = NULL;
-  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;
-  }
-
-
-  function execute()
-  {
-    $smarty = get_smarty();
-    $smarty->assign("Actions",$this->parent->get_actions());
-    foreach($this->attributes as $attr){
-      if(isset($this->data[$attr])){
-        $smarty->assign($attr,$this->data[$attr]);
-      }else{
-        $smarty->assign($attr,"");
-      }
-    }
-
-    $year   = substr($this->data['TIMESTAMP'],0,4);
-    $month  = substr($this->data['TIMESTAMP'],4,2);
-    $day    = substr($this->data['TIMESTAMP'],6,2);
-    
-    $hour   = substr($this->data['TIMESTAMP'],8,2);
-    $minute = substr($this->data['TIMESTAMP'],10,2);
-    $second = substr($this->data['TIMESTAMP'],12,2);
-
-    $years = array();
-    for($i = date("Y",time()); $i <= 2037 ;$i ++){
-      $years[$i] = $i;
-    }
-    $months = array();
-    for($i = 1; $i <= 12; $i ++){
-      $e = str_pad($i,2,"0",STR_PAD_LEFT);
-      $months[$e] = $e;
-    }
-    $days = array();
-    for($i = 1; $i <= cal_days_in_month(CAL_GREGORIAN,$month,$year); $i ++){
-      $e = str_pad($i,2,"0",STR_PAD_LEFT);
-      $days[$e] = $e;
-    }
-    $hours = array();
-    for($i = 0; $i < 24; $i ++){
-      $e = str_pad($i,2,"0",STR_PAD_LEFT);
-      $hours[$e] = $e;
-    }
-    $minutes = array();
-    for($i = 0; $i < 60; $i ++){
-      $e = str_pad($i,2,"0",STR_PAD_LEFT);
-      $minutes[$e] = $e;
-    }
-    $seconds = array();
-    for($i = 0; $i < 60; $i ++){
-      $e = str_pad($i,2,"0",STR_PAD_LEFT);
-      $seconds[$e] = $e;
-    }
-
-    $smarty->assign("years", $years);
-    $smarty->assign("months", $months);
-    $smarty->assign("days", $days);
-    $smarty->assign("hours", $hours);
-    $smarty->assign("minutes", $minutes);
-    $smarty->assign("seconds", $seconds);
-    $smarty->assign("time_year",$year); 
-    $smarty->assign("time_month",$month); 
-    $smarty->assign("time_day",$day); 
-    $smarty->assign("time_hour",$hour); 
-    $smarty->assign("time_minute",$minute); 
-    $smarty->assign("time_second",$second); 
-
-    return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE)));
-  }
-
-
-  function save_object()
-  {
-    if(isset($_POST['HeaderTag'])){
-      $possible_tags = $this->parent->get_actions();
-      $tag = $_POST['HeaderTag'];
-      if(isset($possible_tags[$tag])){
-        $this->data['HEADERTAG'] = $tag;
-      }
-    }
-    foreach(array("status","macaddress") as $attr){
-      if(isset($_POST[$attr])){
-        $this->data[strtoupper($attr)] = $_POST[$attr];
-      }
-    }
-    $date = "";
-    foreach(array("time_year","time_month","time_day","time_hour","time_minute","time_second") as $attr){
-      if(isset($_POST[$attr])){
-        $date .= $_POST[$attr];
-      }
-    }
-    if(strlen($date) == 14){
-      $this->data['TIMESTAMP'] = $date;
-    }
-  }
-
-  function save()
-  {
-    $tmp = array();   
-    foreach(array("STATUS","MACADDRESS","HEADERTAG","TIMESTAMP") as $attr){
-      if(isset($this->data[$attr])){
-        $tmp[$attr] = $this->data[$attr];
-      }
-    }
-    return($tmp);
-  }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc b/gosa-core/plugins/addons/gotomasses/class_gotomasses.inc
deleted file mode 100644 (file)
index 75b40f6..0000000
+++ /dev/null
@@ -1,485 +0,0 @@
-<?php
-
-class gotomasses extends plugin
-{
-  /* Definitions */
-  var $plHeadline     = "System deployment";
-  var $plDescription  = "This does something";
-
-  /* attribute list for save action */
-  var $attributes= array();
-  var $objectclasses= array();
-
-  /* Queue tasks */
-  var $current        = FALSE;
-  var $dialog         = FALSE;
-  var $ids_to_remove  = array();
-  var $divlist        = NULL;
-
-  var $sort_by  = "Schedule";
-  var $sort_dir = "down";
-
-  var $range    = 25;
-  var $start    = 0;
-
-  function gotomasses(&$config, $dn= NULL)
-  {
-    /* Include config object */
-    $this->config= &$config;
-    $this->o_queue = new gosaSupportDaemon(TRUE,10);
-  }
-
-
-  function execute()
-  {
-    $smarty = get_smarty();
-
-    /************
-     * Handle posts 
-     ************/
-    
-    $s_entry = $s_action = "";
-    $arr = array( 
-        "/^stop_/"      => "stop",
-        "/^stop_all/"  => "stop_all",
-        "/^start_/"      => "start",
-        "/^start_all/"  => "start_all",
-
-        "/^edit_task_/"             =>  "edit",
-        "/^remove_task_/"           =>  "remove",
-        "/^new_task_/"              =>  "new_task",
-        "/^remove_multiple_task_/"  => "remove_multiple");
-
-    foreach($arr as $regex => $action){
-      foreach($_POST as $name => $value){
-        if(preg_match($regex,$name)){
-          $s_action = $action;
-          $s_entry  = preg_replace($regex,"",$name);
-          $s_entry  = preg_replace("/_(x|y)$/","",$s_entry);
-        }
-      }
-    }
-
-    /* Edit posted from list link */
-    if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id']) && isset($this->tasks[$_GET['id']])){
-      $s_action = "edit";
-      $s_entry = $_GET['id'];
-    }
-
-
-    /************
-     * Handle Priority modifications  
-     ************/
-
-    if(preg_match("/^start/",$s_action) || preg_match("/^stop/",$s_action)){
-
-      switch($s_action){
-        case 'start_all'   : $this->start_queue_entries($this->list_get_selected_items());break;
-        case 'start'       : $this->start_queue_entries(array($s_entry));break; 
-        case 'stop_all'    : $this->stop_queue_entries ($this->list_get_selected_items());break;
-        case 'stop'        : $this->stop_queue_entries (array($s_entry));break; 
-        default : trigger_error("Undefined priority setting used.");
-      }
-      if($this->o_queue->is_error()){
-        msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
-      }
-    }
-
-    /************
-     * REMOVE 
-     ************/
-
-    /* Remove multiple */
-    if($s_action == "remove_multiple" || $s_action == "remove"){
-
-      if(!$this->acl_is_removeable()){
-        msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG);
-      }else{
-
-        if($s_action == "remove"){
-          $ids = array($s_entry);
-        }else{
-          $ids = $this->list_get_selected_items();
-        }
-        if(count($ids)){
-          $this->ids_to_remove = $ids;
-          $ret = $this->o_queue->ids_exist($this->ids_to_remove);
-          $ret = $this->o_queue->get_entries_by_id($ret);
-
-          $tmp = "";
-          foreach($ret as $task){
-            $tmp.= "\n".$task['ID']." - ".$task['HEADERTAG']."&nbsp;".$task['MACADDRESS'];
-          }
-          $smarty->assign("multiple", TRUE); 
-          $smarty->assign("info",sprintf(_("Your are about to delete the following tasks: %s"),"<pre>".$tmp."</pre>"));
-          $this->current = $s_entry;
-          return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
-        }
-      }
-    }
-
-    /* Remove specified tasks */
-    if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){
-      $this->o_queue->remove_entries($this->ids_to_remove);
-      $this->save();
-    }
-
-    /* Remove aborted */
-    if(isset($_POST['delete_cancel'])){
-      $this->ids_to_remove = array();;
-    }
-
-
-    /************
-     * EDIT 
-     ************/
-
-    /* Edit selected entry */
-    if($s_action == "edit"){
-      $entry = $this->o_queue->get_entry_by_id($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){
-          msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
-        }
-      }else{  
-
-        if($this->o_queue->id_exists($this->current)){
-          $this->o_queue->update_entries(array($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)){
-            msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
-          }
-        }
-        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 
-     ************/
-
-    $divlist = new MultiSelectWindow($this->config,"gotoMasses",array("gotomasses"));
-    $divlist->SetInformation(_("This menu allows you to remove and change the properties of GOsa deamon tasks."));
-    $divlist->SetSummary(_("List of queued deamon jobs."));
-    $divlist->EnableCloseButton(FALSE);
-    $divlist->EnableSaveButton(FALSE);
-    $divlist->SetHeadpageMode();
-
-    if($this->sort_dir == "up"){
-      $sort_img = "<img src='images/sort_up.png' alt='/\' border=0>";
-    }else{
-      $sort_img = "<img src='images/sort_down.png' alt='\/' border=0>";
-    }
-
-    if($this->sort_by == "TargetName"){ $sort_img_1 = $sort_img; } else { $sort_img_1 = "" ;}
-    if($this->sort_by == "TaskID"){ $sort_img_2 = $sort_img; } else { $sort_img_2 = "" ;}
-    if($this->sort_by == "Schedule"){ $sort_img_3 = $sort_img; } else { $sort_img_3 = "" ;}
-    if($this->sort_by == "Action"){ $sort_img_4 = $sort_img; } else { $sort_img_4 = "" ;}
-
-    /* Display add button if allowed */
-    $header = "<div style='padding:5px'>";
-    if($this->acl_is_removeable()){
-      $header .= "<input type='image' src='images/edittrash.png' name='remove_multiple_task' class='center'>&nbsp;";
-    }
-    if(preg_match("/w/",$this->getacl(""))){
-      $header .= "<input type='image' src='images/status_stop_all.png' name='stop_all' class='center'>&nbsp;";
-      $header .= "<input type='image' src='images/status_start_all.png' name='start_all' class='center'>&nbsp;";
-    }
-    $header .= "</div>";
-
-    /* Create divlist */
-    $divlist->SetListHeader($header);
-
-    $plug  = $_GET['plug'];
-    $chk = "<input type='checkbox' id='select_all' name='select_all'
-               onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
-
-    /* set Page header */
-    $divlist->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
-    $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=TargetName'>"._("Target").$sort_img_1."</a>&nbsp;/&nbsp;".
-                                     "<a href='?plug=".$plug."&amp;sort=TaskID'>"._("Task").$sort_img_2."</a>"));
-    $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=Schedule'>"._("Schedule").$sort_img_3."</a>",
-                                      "attach"=>"style='width:100px;'"));
-    $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=Action'>"._("Status").$sort_img_4."</a>",
-                                      "attach"=>"style='width:80px;'"));
-    $divlist->AddHeader(array("string"=>_("Action"),
-                                      "attach"=>"style='border-right:0px;width:120px;'"));
-
-
-    $entries = $this->get_queued_entries();
-
-    foreach($entries as $key => $task){
-
-      $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;";
-
-      $action = "<input type='image' src='images/edit.png' name='edit_task_".$task['ID']."' 
-        class='center' alt='"._("Edit")."'>";
-
-      if($this->acl_is_removeable()){
-        $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$task['ID']."' 
-          class='center' alt='"._("Reomve")."'>";
-      }
-
-      $color = "";
-      $display = $task['MACADDRESS'];
-      $display2= $task['HEADERTAG'];
-
-      /* Create each field */
-      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$task['ID']."' name='item_selected_".$task['ID']."'>" ,
-                      "attach" => "style='width:20px;".$color."'");
-      $field1 = array("string" => $display,
-                      "attach" => "style='".$color."'");
-      $field1a= array("string" => $display2,
-                      "attach" => "style='".$color.";width:80px;'");
-      $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:100px;'");
-      $field3 = array("string" => $task['STATUS'],"attach" => "style='".$color.";width:80px;'");
-      $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
-      $divlist->AddElement(array($field0,$field1,$field1a,$field2,$field3,$field4));
-    }
-
-
-    $smarty = get_smarty();
-    $smarty->assign("start",$this->start);
-    $smarty->assign("start_real", ($this->start + 1));
-    $smarty->assign("ranges", array("10" => "10",
-                                    "20" => "20",
-                                    "25" => "25",
-                                    "50" => "50",
-                                    "100"=> "100",
-                                    "200"=> "200",
-                                    "9999" => "*"));
-
-    $count = $this->o_queue->number_of_queued_entries();
-    $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"range"));
-    $smarty->assign("range",$this->range);
-    $smarty->assign("div",$divlist->Draw());
-    return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__))));
-  }
-
-
-  /*! \brief  Force queue job to be done as far as possible.
-   *  @return Boolean TRUE in case of success, else FALSE. 
-   */
-  private function start_queue_entries($ids)
-  {
-    if(!count($ids)){
-      return;
-    }
-  
-    $data = array("timestamp" => date("YmdHis"),
-                  "status"    => "-");
-    if(!$this->o_queue->update_entries($ids,$data)){
-      msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
-      return(FALSE);
-    }
-    return(TRUE);
-  }
-
-
-  /*! \brief Stops the specified queue entry from execution.
-   *  @return Boolean TRUE in case of success, else FALSE. 
-   */
-  private function stop_queue_entries($ids)
-  {
-    if(!count($ids)){
-      return;
-    }
-    $data = array("timestamp" => "20490101010101",
-                  "status"    => "Stoppped");
-    if(!$this->o_queue->update_entries($ids,$data)){
-      msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
-      return(FALSE);
-    }
-    return(TRUE);
-  }
-
-
-  /*! \brief  Request list of queued jobs.
-   *  @return Returns an array of all queued jobs.
-   */
-  function get_queued_entries()
-  {
-    $map = array(
-        "QueuePosition" => "id",
-        "Action"        => "status",
-        "TaskID"        => "headertag",
-        "TargetName"    => "macaddress",
-        "Schedule"      => "timestamp");
-
-    if(!isset($map[$this->sort_by])){
-      $sort = "id DESC";
-    }else{
-      $sort   = $map[$this->sort_by]; 
-      if($this->sort_dir == "up"){
-        $sort.= " ASC";
-      }else{
-        $sort.= " DESC";
-      }
-    }
-      
-    $start  = $this->start; 
-    $stop   = $this->range;
-    $entries = $this->o_queue->get_queued_entries($start,$stop,$sort);
-    if(!is_array($entries) || !isset($entries['XML']) || !is_array($entries['XML'])){
-      if ($this->o_queue->get_error()){
-        msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "<br><br>".$this->o_queue->get_error()), ERROR_DIALOG);
-      }
-      return(array());
-    }
-
-    $ret = array();
-    foreach($entries['XML'] as $entry){
-      $task = $entry['ID']; 
-      $ret[]= $entry;
-    }
-    return($ret);
-  }
-
-
-  /*! \brief  Handle post jobs, like sorting.
-   */
-  function save_object()
-  {
-    $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID");
-    if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){
-      $sort = $_GET['sort'];
-      if($this->sort_by == $sort){
-        if($this->sort_dir == "up"){
-          $this->sort_dir = "down";
-        }else{
-          $this->sort_dir = "up";
-        }
-      }
-      $this->sort_by = $sort;
-    }
-    if(isset($_POST['range']) && is_numeric($_POST['range'])){
-      $this->range = $_POST['range'];
-    }
-    if(isset($_GET['start'])){
-      $start = $_GET['start'];
-      if(is_numeric($start) || $start == 0){
-        $this->start = $start;
-      }
-    }
-
-    /* Check start stop and reset if necessary */
-    $count = $this->o_queue->number_of_queued_entries();
-    if($this->start >= $count){
-      $this->start = $count -1;
-    }
-    if($this->start < 0){
-      $this->start = 0;
-    }
-  }
-
-
-  /* Return list of object groups */
-  function get_object_groups()
-  {
-    $ret = array();
-    $ldap = $this->config->get_ldap_link();
-    $ldap->cd($this->config->current['BASE']);
-    $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn"));
-    while($attrs = $ldap->fetch()){
-      $ret[$attrs['cn'][0]] = $attrs['cn'][0];
-    }
-    return($ret); 
-  }
-
-
-  function save()
-  {
-    // We do not save anything here.
-  }
-
-
-  /*! \brief  Return a list of all selected items.
-    @return Array   Returns an array containing all selected item ids.
-   */
-  function list_get_selected_items()
-  {
-    $ids = array();
-    foreach($_POST as $name => $value){
-      if(preg_match("/^item_selected_[0-9]*$/",$name)){
-        $id   = preg_replace("/^item_selected_/","",$name);
-        $ids[$id] = $id;
-      }
-    }
-    return($ids);
-  }
-
-
-  function get_actions()
-  {
-    /* Prepare list of available actions */
-    $actions = array(      
-        "gosa_ping"       => _("GOsa ping"),
-        "ping"            => _("Ping"),
-        "sayHello"        => _("Say hello"));
-    return($actions);
-  }
-
-
-  static function plInfo()
-  {
-    return (array(
-          "plShortName"   => _("System mass deployment"),
-          "plDescription" => _("Provide a mechanism to automatically activate a set of systems"),
-          "plSelfModify"  => FALSE,
-          "plDepends"     => array(),
-          "plPriority"    => 0,
-          "plSection"     => array("addon"),
-          "plCategory"    => array("gotomasses" => array("objectClass" => "none", "description" => _("System mass deployment"))),
-          "plProvidedAcls" => array("Comment"   => _("Description"), 
-            "Action"    => _("Action"),
-            "Day"       => _("Day"),
-            "Minute"    => _("Minute"),
-            "Hour"      => _("Hour"),
-            "Month"     => _("Month"),
-            "Weekday"   => _("Week day"),
-            "Target"    => _("Target"))
-          ));
-  }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/gotomasses/class_target_list.inc b/gosa-core/plugins/addons/gotomasses/class_target_list.inc
deleted file mode 100644 (file)
index 2cf1a24..0000000
+++ /dev/null
@@ -1,303 +0,0 @@
-<?php
-
-class target_list extends MultiSelectWindow
-{
-  var $config;
-  var $list         =array();
-  var $Targets_used =array();
-
-  /* Current base */
-  var $selectedBase       = "";
-  var $departments        = array();
-
-  /* Regex */
-  var $Regex              = "*";
-  var $IP_start           = "0.0.0.0";
-  var $IP_end             = "255.255.255.255";
-
-  /* CheckBoxes, to change default values modify $this->AddCheckBox */
-  var $ogroups        ;
-  var $servers        ;
-  var $workstations   ;
-
-
-  /* Subsearch checkbox */
-  var $SubSearch          ;
-  var $IPMatch            ;
-  var $parent             ;
-  var $ui                 ;
-  function target_list(&$config,$Targets_used)
-  {
-    MultiSelectWindow::MultiSelectWindow($config, "Targetselection", array("ogroup","gotomasses"));
-
-    $this->Targets_used = $Targets_used;
-    
-    $this->SetInformation(  _("Select the target objects for your scheduled action."));
-    $this->SetTitle(        _("Available targets"));
-    $this->SetSummary(      _("Available targets"));
-    $this->SetHeadpageMode(FALSE);
-    
-    /* set Page header */
-    $chk = "<input type='checkbox' id='select_all' name='select_all'
-               onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
-    $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
-
-    $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
-    $this->AddHeader(array("string" => _("Object name"), "attach" => "style=''"));
-
-    /* Text ,Value, Name, Is selected */
-    $this->AddCheckBox("ogroups",       _("Select to see object groups"),  _("Show object groups"), true);
-    $this->AddCheckBox("servers",       _("Select to see servers")  ,   _("Show servers"), true);
-    $this->AddCheckBox("workstations",  _("Select to see workstations"),_("Show workstations"), true);
-
-    /* Add SubSearch checkbox */
-    $this->AddCheckBox(SEPERATOR);
-    $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Search in subtrees"), false);
-    $this->AddCheckBox("IPMatch",    _("Select to search for a specific IP range only"), _("Match IP range"), false);
-
-    /* Name,Text,Default  , Connect with alphabet  */
-    $this->AddRegex   ("Regex",     _("Regular expression for matching group names"), "*" , true);
-    $this->AddRegex   ("IP_start",  _("IP range start"),  "0.0.0.0" , true);
-    $this->AddRegex   ("IP_end",    _("IP range end"),    "255.255.255.255" , true);
-    $this->EnableAplhabet(TRUE);
-  }
-
-
-  function GenHeader()
-  {
-    $options= "";
-
-    /* Get all departments within this subtree */
-    $ui= get_userinfo();
-    $first = "";
-    $found = FALSE;
-    $base = $this->config->current['BASE'];
-
-    /* Add base */
-    $tmp = array();
-    $tmp[] = array("dn"=>$this->config->current['BASE']);
-    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
-                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
-
-    $deps = array();
-    foreach($tmp as $tm){
-      $deps[$tm['dn']] = $tm['dn'];
-    }
-
-    /* Load possible departments */
-    $ui= get_userinfo();
-    $tdeps= $ui->get_module_departments("ogroups");
-    $ids = $this->config->idepartments;
-    $first = "";
-    $found = FALSE;
-    foreach($ids as $dep => $name){
-      if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
-
-        /* Keep first base dn in mind, we could need this
-         *  info if no valid base was found
-         */
-        if(empty($first)) {
-          $first = $dep['dn'];
-        }
-
-        $value = $ids[$dep];
-        if ($this->selectedBase == $dep){
-          $found = TRUE;
-          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
-        } else {
-          $options.= "<option value='".$dep."'>$value</option>";
-        }
-      }
-    }
-
-    /* The currently used base is not visible with your acl setup.
-     * Set base to first useable base.
-     */
-    if(!$found){
-      $this->selectedBase = $first;
-    }
-
-    /* Get copy & paste icon */
-    $acls  = $ui->get_permissions($this->selectedBase,"ogroups/ogroup");
-    $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups");
-
-    /* Add default header */
-    $listhead = MultiSelectWindow::get_default_header();
-
-    /* Add department selector */
-    $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
-      " <input class='center' type='image' src='images/list_submit.png' align='middle'
-      title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
-    $listhead .="</div>";
-
-    $this->SetListHeader($listhead);
-  }
-
-
-  function execute()
-  {
-    $this->ClearElementsList();
-    $this->GenHeader();
-    $this->reload();
-    $this->SetEntries($this->list);
-    return($this->Draw());
-  }
-
-  
-  function SetEntries($list)
-  {
-      /* Add Copy & Paste buttons if copy&paste is enabled
-     */
-    // Defining Links
-    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
-    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
-
-    $ui = get_userinfo();
-
-    // Assigning ogroups
-    foreach($list as $key => $val){
-
-      if(in_array($val['cn'][0],$this->Targets_used) || 
-         isset($val['macAddress'][0]) && in_array($val['macAddress'][0],$this->Targets_used)) continue;
-
-      $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
-      if(!isset($val['description'][0])){
-        $desc = "";
-      }else{
-        $desc = " - [ ".$val['description'][0]." ]";
-      }
-      if(!isset($val['ipHostNumber'][0])){
-        $desc.= "";
-      }else{
-        $desc.= " - ".$val['ipHostNumber'][0]."";
-      }
-
-
-      $img ="Hmm";
-      if(in_array("goServer",$val['objectClass'])){
-        $img = "<img src='images/select_server.png' alt='"._("Server")."' ".$title.">";
-      }elseif(in_array("gotoWorkstation",$val['objectClass'])){
-        $img = "<img src='images/select_workstation.png' alt='"._("Workstation")."' ".$title.">";
-      }elseif(in_array("gosaGroupOfNames",$val['objectClass'])){
-        $img = "<img src='images/list_ogroup.png' alt='"._("Object group")."' ".$title.">";
-      }
-
-      /* Create each field */
-      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
-                      "attach" => "style='width:20px;'");
-      $field1 = array("string" => $img, 
-                      "attach" => "style='text-   align:center;width: 20px;'");
-      $field2 = array("string" => $val['cn'][0].$desc, 
-                      "attach" => "style='border-right:0px;' ".$title);
-
-      $this->AddElement(array($field0,$field1,$field2));
-    }
-  }
-
-  
-  function save()
-  { 
-    $ret = array();
-    $items = $this->list_get_selected_items();
-    foreach($items as $item){
-      $ret[] = $this->list[$item];
-    }
-    return($ret);
-  }
-
-
-  function save_object()
-  {
-    MultiSelectWindow::save_object();
-  }
-
-  
-  function reload()
-  {
-    /* Set base for all searches && initialise some vars */
-    $this->list= array();
-    $base     = $this->selectedBase;
-    $filter   = "";
-    $Regex    = $this->Regex;
-    $IP_start = $this->IP_start;
-    $IP_end   = $this->IP_end;
-
-    if($this->IPMatch){
-      if(!tests::is_ip($IP_start)){
-       msg_dialog::display(_("Error"), _("IP range is invalid!"), ERROR_DIALOG);
-        return;
-      }
-      if(!tests::is_ip($IP_end)){
-       msg_dialog::display(_("Error"), _("IP range is invalid!"), ERROR_DIALOG);
-        return;
-      }
-    }
-  
-
-    $chk = array(
-        "ogroups"       => "(&(objectClass=gosaGroupOfNames)(|(gosaGroupObjects=*S*)(gosaGroupObjects=*W*)))" ,
-        "servers"       => "(objectClass=goServer)" ,
-        "workstations"  => "(objectClass=gotoWorkstation)");
-
-    /* Create filter */
-    foreach($chk as $chkBox => $FilterPart){
-      if($this->$chkBox){
-        $filter .=  $FilterPart;
-      }
-    }
-    $filter= "(&(cn=".$Regex.")(|".$filter."))";
-
-    if($this->SubSearch){
-      $res= get_list($filter, array("ogroups","workstations","servers"), $base, 
-            array("cn","objectClass","gosaGroupObjects","ipHostNumber","description"), GL_SIZELIMIT | GL_SUBSEARCH);
-    }else{
-      $res= get_list($filter, "ogroups", get_groups_ou().$base, 
-            array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT );
-      $res= array_merge($res,get_list($filter, "workstation",  get_ou('workstationou').$base, 
-            array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT ));
-      $res= array_merge($res,get_list($filter, "server", get_ou('serverou').$base, 
-            array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT ));
-    }
-
-    $this->list= $res;
-    ksort ($this->list);
-    reset ($this->list);
-    $tmp=array();
-    foreach($this->list as $tkey => $val ){
-
-      if($this->IPMatch){
-        if(isset($val['ipHostNumber'][0])){
-          if(tests::is_ip_range($IP_start,$val['ipHostNumber'][0]) && tests::is_ip_range($val['ipHostNumber'][0],$IP_end)){
-            $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
-          }
-        }
-      }else{
-        $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
-      }
-    }
-    ksort($tmp);
-    $this->list=array();
-    foreach($tmp as $val){
-      $this->list[]=$val;
-    }
-    reset ($this->list);
-  }
-
-  function list_get_selected_items()
-  {
-    $ids = array();
-    foreach($_POST as $name => $value){
-      if(preg_match("/^item_selected_[0-9]*$/",$name)){
-        $id   = preg_replace("/^item_selected_/","",$name);
-        $ids[$id] = $id;
-      }
-    }
-    return($ids);
-  }
-}
-
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/gotomasses/goto_task.tpl b/gosa-core/plugins/addons/gotomasses/goto_task.tpl
deleted file mode 100644 (file)
index 61220bd..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-<table style='width:100%'>
-       <tr>
-               <td colspan="2">
-                       <h2><img alt="" src="images/head.png" class="center" align="middle"> {t}Job details{/t}</h2>
-               </td>
-       </tr>
-       <tr>
-               <td style="width:50%;">
-                       <table>
-                <tr><td>{t}Job ID{/t}</td><td>{$ID}</td></tr>
-                               <tr>
-                                       <td>
-                                               {t}Header Tag{/t}
-                                       </td>
-                                       <td>
-                                               <select name="HeaderTag" onChange="document.mainform.submit();">
-                                                       {html_options options=$Actions selected=$HEADERTAG} 
-                                               </select>       
-                                               <input type='image' src="images/list_reload.png"
-                                                alt="{t}Reload{/t}" title="{t}Reload{/t}" class="center">
-                                       </td>
-                               </tr>
-                               <tr>
-                                       <td>&nbsp;
-                                       </td>
-                               </tr>
-                               <tr>
-                                       <td style="vertical-align: top;">       
-                                               {t}Schedule Execution{/t}
-                                       </td>
-                                       <td>
-                                               <table cellspacing="0" cellpadding="0">
-                                                       <tr>
-                                                               <td>{t}Jahr{/t}</td>
-                                                               <td>{t}Monat{/t}</td>
-                                                               <td>{t}Tag{/t}</td>
-                                                               <td>{t}Stunde{/t}</td>
-                                                               <td>{t}Minute{/t}</td>
-                                                               <td>{t}Sekunde{/t}</td>
-                                                       </tr>
-                                                       <tr>
-                                                               <td>    
-                                                                       <select name="time_year" onChange="document.mainform.submit();">
-                                                                               {html_options values=$years options=$years selected=$time_year}
-                                                                       </select>&nbsp;
-                                                               </td>
-                                                               <td>    
-                                                                       <select name="time_month" onChange="document.mainform.submit();">
-                                                                               {html_options values=$months options=$months selected=$time_month}
-                                                                       </select>&nbsp;
-                                                               </td>
-                                                               <td>    
-                                                                       <select name="time_day">
-                                                                               {html_options values=$days options=$days selected=$time_day}
-                                                                       </select>&nbsp;
-                                                               </td>
-                                                               <td>    
-                                                                       <select name="time_hour">
-                                                                               {html_options values=$hours options=$hours selected=$time_hour}
-                                                                       </select>&nbsp;
-                                                               </td>
-                                                               <td>    
-                                                                       <select name="time_minute">
-                                                                               {html_options values=$minutes options=$minutes selected=$time_minute}
-                                                                       </select>&nbsp;
-                                                               </td>
-                                                               <td>    
-                                                                       <select name="time_second">
-                                                                               {html_options values=$seconds options=$seconds selected=$time_second}
-                                                                       </select>
-                                                               </td>
-                                                       </tr>
-                                               </table>
-                                       </td>
-                               </tr>
-                       </table>
-               </td>
-               <td>
-                       <table>
-{if $HEADERTAG == "ping"}
-                               <tr><td>{t}Status{/t}</td><td><input type="text" name="status" value="{$STATUS}"></td></tr>
-                   <tr><td>{t}Mac{/t}</td><td><input type="text" name="macaddress" value="{$MACADDRESS}"></td></tr>
-{elseif $HEADERTAG == "sayHello"}
-                               <tr><td>{t}Status{/t}</td><td><input type="text" name="status" value="{$STATUS}"></td></tr>
-                   <tr><td>{t}Mac{/t}</td><td><input type="text" name="macaddress" value="{$MACADDRESS}"></td></tr>
-{else}
-                               <tr><td>{t}Job type not implented{/t}</td></tr>
-{/if}
-                       </table>
-               </td>
-       </tr>
-</table>
-       
-<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}'>
-       <input type='submit' name='close_goto_task' value='{t}Cancel{/t}'>
-</p>
diff --git a/gosa-core/plugins/addons/gotomasses/gotomasses.tpl b/gosa-core/plugins/addons/gotomasses/gotomasses.tpl
deleted file mode 100644 (file)
index 844cdeb..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-{$div}
-<div style="width:65%; text-align: center; float:left;" >
-{$range_selector}
-</div>
diff --git a/gosa-core/plugins/addons/gotomasses/main.inc b/gosa-core/plugins/addons/gotomasses/main.inc
deleted file mode 100644 (file)
index 7a517fe..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-/*
-  This code is part of GOsa (https://gosa.gonicus.de)
-  Copyright (C) 2003  Cajus Pollmeier
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; either version 2 of the License, or
-  (at your option) any later version.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-  along with this program; if not, write to the Free Software
-  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-if (!$remove_lock){
-
-       /* Create gotomasses object on demand */
-       if (!session::is_set('gotomasses') || (isset($_GET['reset']) && $_GET['reset'] == 1) || isset($_POST['reload_gotomass_data'])){
-               $gotomasses= new gotomasses ($config);
-               $gotomasses->set_acl_category("gotomasses");
-
-        /* Check root dn and user dn for acl informations */
-        $gotomasses->set_acl_base($config->current['BASE']);
-        if($gotomasses->getacl("") == ""){
-            $gotomasses->set_acl_base($ui->dn);
-        }
-               
-               /* Check if we have acl on our own base */
-        if($gotomasses->getacl("") == ""){
-            $gotomasses->set_acl_base(dn2base($ui->dn));
-        }
-               session::set("gotomasses",$gotomasses);
-       }
-       $gotomasses = session::get('gotomasses');
-
-       /* Execute formular */
-       $display= $gotomasses->save_object();
-       if(isset($_POST['save_gotomass_changes'])){
-               $gotomasses->save();
-       }
-       $display= $gotomasses->execute ();
-
-       /* Page header*/
-       $display= print_header(get_template_path('images/system.png'), _("System deployment")).$display;
-
-       /* Store changes  in session */
-       session::set('gotomasses',$gotomasses);
-}
diff --git a/gosa-core/plugins/addons/gotomasses/remove.tpl b/gosa-core/plugins/addons/gotomasses/remove.tpl
deleted file mode 100644 (file)
index 023142f..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-<div style="font-size:18px;">
- <img alt="" src="images/button_cancel.png" align=top>&nbsp;{t}Warning{/t}
-</div>
-<p>
-  {$info}
-  {t}This includes all account data, system access rules, imap settings, etc. for this user. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
-</p>
-
-<p>
- {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t}
-</p>
-
-<p class="plugbottom">
-{if $multiple}
-  <input type=submit name="delete_multiple_confirm" value="{t}Delete{/t}">
-{else}
-  <input type=submit name="delete_confirm" value="{t}Delete{/t}">
-{/if}
-  <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
-</p>
-
diff --git a/gosa-plugins/goto/addons/gotomasses/class_goto_task.inc b/gosa-plugins/goto/addons/gotomasses/class_goto_task.inc
new file mode 100644 (file)
index 0000000..e6f0eb2
--- /dev/null
@@ -0,0 +1,130 @@
+<?php
+
+class goto_task extends plugin
+{
+  /* Definitions */
+  var $plHeadline     = "System mass deployment";
+  var $plDescription  = "This does something";
+  var $parent   = NULL;
+  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;
+  }
+
+
+  function execute()
+  {
+    $smarty = get_smarty();
+    $smarty->assign("Actions",$this->parent->get_actions());
+    foreach($this->attributes as $attr){
+      if(isset($this->data[$attr])){
+        $smarty->assign($attr,$this->data[$attr]);
+      }else{
+        $smarty->assign($attr,"");
+      }
+    }
+
+    $year   = substr($this->data['TIMESTAMP'],0,4);
+    $month  = substr($this->data['TIMESTAMP'],4,2);
+    $day    = substr($this->data['TIMESTAMP'],6,2);
+    
+    $hour   = substr($this->data['TIMESTAMP'],8,2);
+    $minute = substr($this->data['TIMESTAMP'],10,2);
+    $second = substr($this->data['TIMESTAMP'],12,2);
+
+    $years = array();
+    for($i = date("Y",time()); $i <= 2037 ;$i ++){
+      $years[$i] = $i;
+    }
+    $months = array();
+    for($i = 1; $i <= 12; $i ++){
+      $e = str_pad($i,2,"0",STR_PAD_LEFT);
+      $months[$e] = $e;
+    }
+    $days = array();
+    for($i = 1; $i <= cal_days_in_month(CAL_GREGORIAN,$month,$year); $i ++){
+      $e = str_pad($i,2,"0",STR_PAD_LEFT);
+      $days[$e] = $e;
+    }
+    $hours = array();
+    for($i = 0; $i < 24; $i ++){
+      $e = str_pad($i,2,"0",STR_PAD_LEFT);
+      $hours[$e] = $e;
+    }
+    $minutes = array();
+    for($i = 0; $i < 60; $i ++){
+      $e = str_pad($i,2,"0",STR_PAD_LEFT);
+      $minutes[$e] = $e;
+    }
+    $seconds = array();
+    for($i = 0; $i < 60; $i ++){
+      $e = str_pad($i,2,"0",STR_PAD_LEFT);
+      $seconds[$e] = $e;
+    }
+
+    $smarty->assign("years", $years);
+    $smarty->assign("months", $months);
+    $smarty->assign("days", $days);
+    $smarty->assign("hours", $hours);
+    $smarty->assign("minutes", $minutes);
+    $smarty->assign("seconds", $seconds);
+    $smarty->assign("time_year",$year); 
+    $smarty->assign("time_month",$month); 
+    $smarty->assign("time_day",$day); 
+    $smarty->assign("time_hour",$hour); 
+    $smarty->assign("time_minute",$minute); 
+    $smarty->assign("time_second",$second); 
+
+    return ($smarty->fetch (get_template_path('goto_task.tpl', TRUE)));
+  }
+
+
+  function save_object()
+  {
+    if(isset($_POST['HeaderTag'])){
+      $possible_tags = $this->parent->get_actions();
+      $tag = $_POST['HeaderTag'];
+      if(isset($possible_tags[$tag])){
+        $this->data['HEADERTAG'] = $tag;
+      }
+    }
+    foreach(array("status","macaddress") as $attr){
+      if(isset($_POST[$attr])){
+        $this->data[strtoupper($attr)] = $_POST[$attr];
+      }
+    }
+    $date = "";
+    foreach(array("time_year","time_month","time_day","time_hour","time_minute","time_second") as $attr){
+      if(isset($_POST[$attr])){
+        $date .= $_POST[$attr];
+      }
+    }
+    if(strlen($date) == 14){
+      $this->data['TIMESTAMP'] = $date;
+    }
+  }
+
+  function save()
+  {
+    $tmp = array();   
+    foreach(array("STATUS","MACADDRESS","HEADERTAG","TIMESTAMP") as $attr){
+      if(isset($this->data[$attr])){
+        $tmp[$attr] = $this->data[$attr];
+      }
+    }
+    return($tmp);
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc b/gosa-plugins/goto/addons/gotomasses/class_gotomasses.inc
new file mode 100644 (file)
index 0000000..75b40f6
--- /dev/null
@@ -0,0 +1,485 @@
+<?php
+
+class gotomasses extends plugin
+{
+  /* Definitions */
+  var $plHeadline     = "System deployment";
+  var $plDescription  = "This does something";
+
+  /* attribute list for save action */
+  var $attributes= array();
+  var $objectclasses= array();
+
+  /* Queue tasks */
+  var $current        = FALSE;
+  var $dialog         = FALSE;
+  var $ids_to_remove  = array();
+  var $divlist        = NULL;
+
+  var $sort_by  = "Schedule";
+  var $sort_dir = "down";
+
+  var $range    = 25;
+  var $start    = 0;
+
+  function gotomasses(&$config, $dn= NULL)
+  {
+    /* Include config object */
+    $this->config= &$config;
+    $this->o_queue = new gosaSupportDaemon(TRUE,10);
+  }
+
+
+  function execute()
+  {
+    $smarty = get_smarty();
+
+    /************
+     * Handle posts 
+     ************/
+    
+    $s_entry = $s_action = "";
+    $arr = array( 
+        "/^stop_/"      => "stop",
+        "/^stop_all/"  => "stop_all",
+        "/^start_/"      => "start",
+        "/^start_all/"  => "start_all",
+
+        "/^edit_task_/"             =>  "edit",
+        "/^remove_task_/"           =>  "remove",
+        "/^new_task_/"              =>  "new_task",
+        "/^remove_multiple_task_/"  => "remove_multiple");
+
+    foreach($arr as $regex => $action){
+      foreach($_POST as $name => $value){
+        if(preg_match($regex,$name)){
+          $s_action = $action;
+          $s_entry  = preg_replace($regex,"",$name);
+          $s_entry  = preg_replace("/_(x|y)$/","",$s_entry);
+        }
+      }
+    }
+
+    /* Edit posted from list link */
+    if(isset($_GET['act']) && $_GET['act'] == "edit" && isset($_GET['id']) && isset($this->tasks[$_GET['id']])){
+      $s_action = "edit";
+      $s_entry = $_GET['id'];
+    }
+
+
+    /************
+     * Handle Priority modifications  
+     ************/
+
+    if(preg_match("/^start/",$s_action) || preg_match("/^stop/",$s_action)){
+
+      switch($s_action){
+        case 'start_all'   : $this->start_queue_entries($this->list_get_selected_items());break;
+        case 'start'       : $this->start_queue_entries(array($s_entry));break; 
+        case 'stop_all'    : $this->stop_queue_entries ($this->list_get_selected_items());break;
+        case 'stop'        : $this->stop_queue_entries (array($s_entry));break; 
+        default : trigger_error("Undefined priority setting used.");
+      }
+      if($this->o_queue->is_error()){
+        msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
+      }
+    }
+
+    /************
+     * REMOVE 
+     ************/
+
+    /* Remove multiple */
+    if($s_action == "remove_multiple" || $s_action == "remove"){
+
+      if(!$this->acl_is_removeable()){
+        msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG);
+      }else{
+
+        if($s_action == "remove"){
+          $ids = array($s_entry);
+        }else{
+          $ids = $this->list_get_selected_items();
+        }
+        if(count($ids)){
+          $this->ids_to_remove = $ids;
+          $ret = $this->o_queue->ids_exist($this->ids_to_remove);
+          $ret = $this->o_queue->get_entries_by_id($ret);
+
+          $tmp = "";
+          foreach($ret as $task){
+            $tmp.= "\n".$task['ID']." - ".$task['HEADERTAG']."&nbsp;".$task['MACADDRESS'];
+          }
+          $smarty->assign("multiple", TRUE); 
+          $smarty->assign("info",sprintf(_("Your are about to delete the following tasks: %s"),"<pre>".$tmp."</pre>"));
+          $this->current = $s_entry;
+          return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+        }
+      }
+    }
+
+    /* Remove specified tasks */
+    if(count($this->ids_to_remove) && isset($_POST['delete_multiple_confirm'])){
+      $this->o_queue->remove_entries($this->ids_to_remove);
+      $this->save();
+    }
+
+    /* Remove aborted */
+    if(isset($_POST['delete_cancel'])){
+      $this->ids_to_remove = array();;
+    }
+
+
+    /************
+     * EDIT 
+     ************/
+
+    /* Edit selected entry */
+    if($s_action == "edit"){
+      $entry = $this->o_queue->get_entry_by_id($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){
+          msg_dialog::display(_("Error"), $msg, ERROR_DIALOG);
+        }
+      }else{  
+
+        if($this->o_queue->id_exists($this->current)){
+          $this->o_queue->update_entries(array($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)){
+            msg_dialog::display(_("Error"), $this->o_queue->get_error(), ERROR_DIALOG);
+          }
+        }
+        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 
+     ************/
+
+    $divlist = new MultiSelectWindow($this->config,"gotoMasses",array("gotomasses"));
+    $divlist->SetInformation(_("This menu allows you to remove and change the properties of GOsa deamon tasks."));
+    $divlist->SetSummary(_("List of queued deamon jobs."));
+    $divlist->EnableCloseButton(FALSE);
+    $divlist->EnableSaveButton(FALSE);
+    $divlist->SetHeadpageMode();
+
+    if($this->sort_dir == "up"){
+      $sort_img = "<img src='images/sort_up.png' alt='/\' border=0>";
+    }else{
+      $sort_img = "<img src='images/sort_down.png' alt='\/' border=0>";
+    }
+
+    if($this->sort_by == "TargetName"){ $sort_img_1 = $sort_img; } else { $sort_img_1 = "" ;}
+    if($this->sort_by == "TaskID"){ $sort_img_2 = $sort_img; } else { $sort_img_2 = "" ;}
+    if($this->sort_by == "Schedule"){ $sort_img_3 = $sort_img; } else { $sort_img_3 = "" ;}
+    if($this->sort_by == "Action"){ $sort_img_4 = $sort_img; } else { $sort_img_4 = "" ;}
+
+    /* Display add button if allowed */
+    $header = "<div style='padding:5px'>";
+    if($this->acl_is_removeable()){
+      $header .= "<input type='image' src='images/edittrash.png' name='remove_multiple_task' class='center'>&nbsp;";
+    }
+    if(preg_match("/w/",$this->getacl(""))){
+      $header .= "<input type='image' src='images/status_stop_all.png' name='stop_all' class='center'>&nbsp;";
+      $header .= "<input type='image' src='images/status_start_all.png' name='start_all' class='center'>&nbsp;";
+    }
+    $header .= "</div>";
+
+    /* Create divlist */
+    $divlist->SetListHeader($header);
+
+    $plug  = $_GET['plug'];
+    $chk = "<input type='checkbox' id='select_all' name='select_all'
+               onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+
+    /* set Page header */
+    $divlist->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
+    $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=TargetName'>"._("Target").$sort_img_1."</a>&nbsp;/&nbsp;".
+                                     "<a href='?plug=".$plug."&amp;sort=TaskID'>"._("Task").$sort_img_2."</a>"));
+    $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=Schedule'>"._("Schedule").$sort_img_3."</a>",
+                                      "attach"=>"style='width:100px;'"));
+    $divlist->AddHeader(array("string"=>"<a href='?plug=".$plug."&amp;sort=Action'>"._("Status").$sort_img_4."</a>",
+                                      "attach"=>"style='width:80px;'"));
+    $divlist->AddHeader(array("string"=>_("Action"),
+                                      "attach"=>"style='border-right:0px;width:120px;'"));
+
+
+    $entries = $this->get_queued_entries();
+
+    foreach($entries as $key => $task){
+
+      $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;";
+
+      $action = "<input type='image' src='images/edit.png' name='edit_task_".$task['ID']."' 
+        class='center' alt='"._("Edit")."'>";
+
+      if($this->acl_is_removeable()){
+        $action.= "<input type='image' src='images/edittrash.png' name='remove_task_".$task['ID']."' 
+          class='center' alt='"._("Reomve")."'>";
+      }
+
+      $color = "";
+      $display = $task['MACADDRESS'];
+      $display2= $task['HEADERTAG'];
+
+      /* Create each field */
+      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$task['ID']."' name='item_selected_".$task['ID']."'>" ,
+                      "attach" => "style='width:20px;".$color."'");
+      $field1 = array("string" => $display,
+                      "attach" => "style='".$color."'");
+      $field1a= array("string" => $display2,
+                      "attach" => "style='".$color.";width:80px;'");
+      $field2 = array("string" => date("d.m.Y H:i:s",strtotime($task['TIMESTAMP'])),"attach" => "style='".$color.";width:100px;'");
+      $field3 = array("string" => $task['STATUS'],"attach" => "style='".$color.";width:80px;'");
+      $field4 = array("string" => $prio_actions.$action,"attach" => "style='".$color.";text-align:right;width:120px;border-right:0px;'");
+      $divlist->AddElement(array($field0,$field1,$field1a,$field2,$field3,$field4));
+    }
+
+
+    $smarty = get_smarty();
+    $smarty->assign("start",$this->start);
+    $smarty->assign("start_real", ($this->start + 1));
+    $smarty->assign("ranges", array("10" => "10",
+                                    "20" => "20",
+                                    "25" => "25",
+                                    "50" => "50",
+                                    "100"=> "100",
+                                    "200"=> "200",
+                                    "9999" => "*"));
+
+    $count = $this->o_queue->number_of_queued_entries();
+    $smarty->assign("range_selector", range_selector($count, $this->start, $this->range,"range"));
+    $smarty->assign("range",$this->range);
+    $smarty->assign("div",$divlist->Draw());
+    return($smarty->fetch (get_template_path('gotomasses.tpl', TRUE, dirname(__FILE__))));
+  }
+
+
+  /*! \brief  Force queue job to be done as far as possible.
+   *  @return Boolean TRUE in case of success, else FALSE. 
+   */
+  private function start_queue_entries($ids)
+  {
+    if(!count($ids)){
+      return;
+    }
+  
+    $data = array("timestamp" => date("YmdHis"),
+                  "status"    => "-");
+    if(!$this->o_queue->update_entries($ids,$data)){
+      msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
+      return(FALSE);
+    }
+    return(TRUE);
+  }
+
+
+  /*! \brief Stops the specified queue entry from execution.
+   *  @return Boolean TRUE in case of success, else FALSE. 
+   */
+  private function stop_queue_entries($ids)
+  {
+    if(!count($ids)){
+      return;
+    }
+    $data = array("timestamp" => "20490101010101",
+                  "status"    => "Stoppped");
+    if(!$this->o_queue->update_entries($ids,$data)){
+      msg_dialog::display(_("Error"), sprintf(_("Could not update queue entry: %s"),$id) , ERROR_DIALOG);
+      return(FALSE);
+    }
+    return(TRUE);
+  }
+
+
+  /*! \brief  Request list of queued jobs.
+   *  @return Returns an array of all queued jobs.
+   */
+  function get_queued_entries()
+  {
+    $map = array(
+        "QueuePosition" => "id",
+        "Action"        => "status",
+        "TaskID"        => "headertag",
+        "TargetName"    => "macaddress",
+        "Schedule"      => "timestamp");
+
+    if(!isset($map[$this->sort_by])){
+      $sort = "id DESC";
+    }else{
+      $sort   = $map[$this->sort_by]; 
+      if($this->sort_dir == "up"){
+        $sort.= " ASC";
+      }else{
+        $sort.= " DESC";
+      }
+    }
+      
+    $start  = $this->start; 
+    $stop   = $this->range;
+    $entries = $this->o_queue->get_queued_entries($start,$stop,$sort);
+    if(!is_array($entries) || !isset($entries['XML']) || !is_array($entries['XML'])){
+      if ($this->o_queue->get_error()){
+        msg_dialog::display(_("Error"), sprintf(_("Cannot load queue entries: %s"), "<br><br>".$this->o_queue->get_error()), ERROR_DIALOG);
+      }
+      return(array());
+    }
+
+    $ret = array();
+    foreach($entries['XML'] as $entry){
+      $task = $entry['ID']; 
+      $ret[]= $entry;
+    }
+    return($ret);
+  }
+
+
+  /*! \brief  Handle post jobs, like sorting.
+   */
+  function save_object()
+  {
+    $sort_vals = array("Action","QueuePosition","TargetName","Schedule","TaskID");
+    if(isset($_GET['sort']) && in_array($_GET['sort'],$sort_vals)){
+      $sort = $_GET['sort'];
+      if($this->sort_by == $sort){
+        if($this->sort_dir == "up"){
+          $this->sort_dir = "down";
+        }else{
+          $this->sort_dir = "up";
+        }
+      }
+      $this->sort_by = $sort;
+    }
+    if(isset($_POST['range']) && is_numeric($_POST['range'])){
+      $this->range = $_POST['range'];
+    }
+    if(isset($_GET['start'])){
+      $start = $_GET['start'];
+      if(is_numeric($start) || $start == 0){
+        $this->start = $start;
+      }
+    }
+
+    /* Check start stop and reset if necessary */
+    $count = $this->o_queue->number_of_queued_entries();
+    if($this->start >= $count){
+      $this->start = $count -1;
+    }
+    if($this->start < 0){
+      $this->start = 0;
+    }
+  }
+
+
+  /* Return list of object groups */
+  function get_object_groups()
+  {
+    $ret = array();
+    $ldap = $this->config->get_ldap_link();
+    $ldap->cd($this->config->current['BASE']);
+    $ldap->search("(&(objectClass=gosaGroupOfNames)(cn=*))",array("cn"));
+    while($attrs = $ldap->fetch()){
+      $ret[$attrs['cn'][0]] = $attrs['cn'][0];
+    }
+    return($ret); 
+  }
+
+
+  function save()
+  {
+    // We do not save anything here.
+  }
+
+
+  /*! \brief  Return a list of all selected items.
+    @return Array   Returns an array containing all selected item ids.
+   */
+  function list_get_selected_items()
+  {
+    $ids = array();
+    foreach($_POST as $name => $value){
+      if(preg_match("/^item_selected_[0-9]*$/",$name)){
+        $id   = preg_replace("/^item_selected_/","",$name);
+        $ids[$id] = $id;
+      }
+    }
+    return($ids);
+  }
+
+
+  function get_actions()
+  {
+    /* Prepare list of available actions */
+    $actions = array(      
+        "gosa_ping"       => _("GOsa ping"),
+        "ping"            => _("Ping"),
+        "sayHello"        => _("Say hello"));
+    return($actions);
+  }
+
+
+  static function plInfo()
+  {
+    return (array(
+          "plShortName"   => _("System mass deployment"),
+          "plDescription" => _("Provide a mechanism to automatically activate a set of systems"),
+          "plSelfModify"  => FALSE,
+          "plDepends"     => array(),
+          "plPriority"    => 0,
+          "plSection"     => array("addon"),
+          "plCategory"    => array("gotomasses" => array("objectClass" => "none", "description" => _("System mass deployment"))),
+          "plProvidedAcls" => array("Comment"   => _("Description"), 
+            "Action"    => _("Action"),
+            "Day"       => _("Day"),
+            "Minute"    => _("Minute"),
+            "Hour"      => _("Hour"),
+            "Month"     => _("Month"),
+            "Weekday"   => _("Week day"),
+            "Target"    => _("Target"))
+          ));
+  }
+}
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/addons/gotomasses/class_target_list.inc b/gosa-plugins/goto/addons/gotomasses/class_target_list.inc
new file mode 100644 (file)
index 0000000..2cf1a24
--- /dev/null
@@ -0,0 +1,303 @@
+<?php
+
+class target_list extends MultiSelectWindow
+{
+  var $config;
+  var $list         =array();
+  var $Targets_used =array();
+
+  /* Current base */
+  var $selectedBase       = "";
+  var $departments        = array();
+
+  /* Regex */
+  var $Regex              = "*";
+  var $IP_start           = "0.0.0.0";
+  var $IP_end             = "255.255.255.255";
+
+  /* CheckBoxes, to change default values modify $this->AddCheckBox */
+  var $ogroups        ;
+  var $servers        ;
+  var $workstations   ;
+
+
+  /* Subsearch checkbox */
+  var $SubSearch          ;
+  var $IPMatch            ;
+  var $parent             ;
+  var $ui                 ;
+  function target_list(&$config,$Targets_used)
+  {
+    MultiSelectWindow::MultiSelectWindow($config, "Targetselection", array("ogroup","gotomasses"));
+
+    $this->Targets_used = $Targets_used;
+    
+    $this->SetInformation(  _("Select the target objects for your scheduled action."));
+    $this->SetTitle(        _("Available targets"));
+    $this->SetSummary(      _("Available targets"));
+    $this->SetHeadpageMode(FALSE);
+    
+    /* set Page header */
+    $chk = "<input type='checkbox' id='select_all' name='select_all'
+               onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+    $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
+
+    $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
+    $this->AddHeader(array("string" => _("Object name"), "attach" => "style=''"));
+
+    /* Text ,Value, Name, Is selected */
+    $this->AddCheckBox("ogroups",       _("Select to see object groups"),  _("Show object groups"), true);
+    $this->AddCheckBox("servers",       _("Select to see servers")  ,   _("Show servers"), true);
+    $this->AddCheckBox("workstations",  _("Select to see workstations"),_("Show workstations"), true);
+
+    /* Add SubSearch checkbox */
+    $this->AddCheckBox(SEPERATOR);
+    $this->AddCheckBox("SubSearch",  _("Select to search within subtrees"), _("Search in subtrees"), false);
+    $this->AddCheckBox("IPMatch",    _("Select to search for a specific IP range only"), _("Match IP range"), false);
+
+    /* Name,Text,Default  , Connect with alphabet  */
+    $this->AddRegex   ("Regex",     _("Regular expression for matching group names"), "*" , true);
+    $this->AddRegex   ("IP_start",  _("IP range start"),  "0.0.0.0" , true);
+    $this->AddRegex   ("IP_end",    _("IP range end"),    "255.255.255.255" , true);
+    $this->EnableAplhabet(TRUE);
+  }
+
+
+  function GenHeader()
+  {
+    $options= "";
+
+    /* Get all departments within this subtree */
+    $ui= get_userinfo();
+    $first = "";
+    $found = FALSE;
+    $base = $this->config->current['BASE'];
+
+    /* Add base */
+    $tmp = array();
+    $tmp[] = array("dn"=>$this->config->current['BASE']);
+    $tmp=  array_merge($tmp,get_list("(&(|(ou=*)(description=*))(objectClass=gosaDepartment))", $this->module, $base,
+                    array("ou", "description"), GL_SIZELIMIT | GL_SUBSEARCH));
+
+    $deps = array();
+    foreach($tmp as $tm){
+      $deps[$tm['dn']] = $tm['dn'];
+    }
+
+    /* Load possible departments */
+    $ui= get_userinfo();
+    $tdeps= $ui->get_module_departments("ogroups");
+    $ids = $this->config->idepartments;
+    $first = "";
+    $found = FALSE;
+    foreach($ids as $dep => $name){
+      if(isset($deps[$dep]) && in_array_ics($dep, $tdeps)){
+
+        /* Keep first base dn in mind, we could need this
+         *  info if no valid base was found
+         */
+        if(empty($first)) {
+          $first = $dep['dn'];
+        }
+
+        $value = $ids[$dep];
+        if ($this->selectedBase == $dep){
+          $found = TRUE;
+          $options.= "<option selected='selected' value='".$dep."'>$value</option>";
+        } else {
+          $options.= "<option value='".$dep."'>$value</option>";
+        }
+      }
+    }
+
+    /* The currently used base is not visible with your acl setup.
+     * Set base to first useable base.
+     */
+    if(!$found){
+      $this->selectedBase = $first;
+    }
+
+    /* Get copy & paste icon */
+    $acls  = $ui->get_permissions($this->selectedBase,"ogroups/ogroup");
+    $acl_all= $ui->has_complete_category_acls($this->selectedBase,"ogroups");
+
+    /* Add default header */
+    $listhead = MultiSelectWindow::get_default_header();
+
+    /* Add department selector */
+    $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
+      " <input class='center' type='image' src='images/list_submit.png' align='middle'
+      title='"._("Submit department")."' name='submit_department' alt='"._("Submit")."'>&nbsp;";
+    $listhead .="</div>";
+
+    $this->SetListHeader($listhead);
+  }
+
+
+  function execute()
+  {
+    $this->ClearElementsList();
+    $this->GenHeader();
+    $this->reload();
+    $this->SetEntries($this->list);
+    return($this->Draw());
+  }
+
+  
+  function SetEntries($list)
+  {
+      /* Add Copy & Paste buttons if copy&paste is enabled
+     */
+    // Defining Links
+    $linkopen = "<a href='?plug=".$_GET['plug']."&amp;act=dep_open&amp;dep_id=%s'>%s</a>";
+    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
+
+    $ui = get_userinfo();
+
+    // Assigning ogroups
+    foreach($list as $key => $val){
+
+      if(in_array($val['cn'][0],$this->Targets_used) || 
+         isset($val['macAddress'][0]) && in_array($val['macAddress'][0],$this->Targets_used)) continue;
+
+      $title = "title='".preg_replace('/ /', '&nbsp;', @LDAP::fix($val['dn']))."'";
+      if(!isset($val['description'][0])){
+        $desc = "";
+      }else{
+        $desc = " - [ ".$val['description'][0]." ]";
+      }
+      if(!isset($val['ipHostNumber'][0])){
+        $desc.= "";
+      }else{
+        $desc.= " - ".$val['ipHostNumber'][0]."";
+      }
+
+
+      $img ="Hmm";
+      if(in_array("goServer",$val['objectClass'])){
+        $img = "<img src='images/select_server.png' alt='"._("Server")."' ".$title.">";
+      }elseif(in_array("gotoWorkstation",$val['objectClass'])){
+        $img = "<img src='images/select_workstation.png' alt='"._("Workstation")."' ".$title.">";
+      }elseif(in_array("gosaGroupOfNames",$val['objectClass'])){
+        $img = "<img src='images/list_ogroup.png' alt='"._("Object group")."' ".$title.">";
+      }
+
+      /* Create each field */
+      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
+                      "attach" => "style='width:20px;'");
+      $field1 = array("string" => $img, 
+                      "attach" => "style='text-   align:center;width: 20px;'");
+      $field2 = array("string" => $val['cn'][0].$desc, 
+                      "attach" => "style='border-right:0px;' ".$title);
+
+      $this->AddElement(array($field0,$field1,$field2));
+    }
+  }
+
+  
+  function save()
+  { 
+    $ret = array();
+    $items = $this->list_get_selected_items();
+    foreach($items as $item){
+      $ret[] = $this->list[$item];
+    }
+    return($ret);
+  }
+
+
+  function save_object()
+  {
+    MultiSelectWindow::save_object();
+  }
+
+  
+  function reload()
+  {
+    /* Set base for all searches && initialise some vars */
+    $this->list= array();
+    $base     = $this->selectedBase;
+    $filter   = "";
+    $Regex    = $this->Regex;
+    $IP_start = $this->IP_start;
+    $IP_end   = $this->IP_end;
+
+    if($this->IPMatch){
+      if(!tests::is_ip($IP_start)){
+       msg_dialog::display(_("Error"), _("IP range is invalid!"), ERROR_DIALOG);
+        return;
+      }
+      if(!tests::is_ip($IP_end)){
+       msg_dialog::display(_("Error"), _("IP range is invalid!"), ERROR_DIALOG);
+        return;
+      }
+    }
+  
+
+    $chk = array(
+        "ogroups"       => "(&(objectClass=gosaGroupOfNames)(|(gosaGroupObjects=*S*)(gosaGroupObjects=*W*)))" ,
+        "servers"       => "(objectClass=goServer)" ,
+        "workstations"  => "(objectClass=gotoWorkstation)");
+
+    /* Create filter */
+    foreach($chk as $chkBox => $FilterPart){
+      if($this->$chkBox){
+        $filter .=  $FilterPart;
+      }
+    }
+    $filter= "(&(cn=".$Regex.")(|".$filter."))";
+
+    if($this->SubSearch){
+      $res= get_list($filter, array("ogroups","workstations","servers"), $base, 
+            array("cn","objectClass","gosaGroupObjects","ipHostNumber","description"), GL_SIZELIMIT | GL_SUBSEARCH);
+    }else{
+      $res= get_list($filter, "ogroups", get_groups_ou().$base, 
+            array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT );
+      $res= array_merge($res,get_list($filter, "workstation",  get_ou('workstationou').$base, 
+            array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT ));
+      $res= array_merge($res,get_list($filter, "server", get_ou('serverou').$base, 
+            array("cn","objectClass","ipHostNumber","description"), GL_SIZELIMIT ));
+    }
+
+    $this->list= $res;
+    ksort ($this->list);
+    reset ($this->list);
+    $tmp=array();
+    foreach($this->list as $tkey => $val ){
+
+      if($this->IPMatch){
+        if(isset($val['ipHostNumber'][0])){
+          if(tests::is_ip_range($IP_start,$val['ipHostNumber'][0]) && tests::is_ip_range($val['ipHostNumber'][0],$IP_end)){
+            $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
+          }
+        }
+      }else{
+        $tmp[strtolower($val['cn'][0]).$val['cn'][0]]=$val;
+      }
+    }
+    ksort($tmp);
+    $this->list=array();
+    foreach($tmp as $val){
+      $this->list[]=$val;
+    }
+    reset ($this->list);
+  }
+
+  function list_get_selected_items()
+  {
+    $ids = array();
+    foreach($_POST as $name => $value){
+      if(preg_match("/^item_selected_[0-9]*$/",$name)){
+        $id   = preg_replace("/^item_selected_/","",$name);
+        $ids[$id] = $id;
+      }
+    }
+    return($ids);
+  }
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/goto/addons/gotomasses/goto_task.tpl b/gosa-plugins/goto/addons/gotomasses/goto_task.tpl
new file mode 100644 (file)
index 0000000..61220bd
--- /dev/null
@@ -0,0 +1,99 @@
+<table style='width:100%'>
+       <tr>
+               <td colspan="2">
+                       <h2><img alt="" src="images/head.png" class="center" align="middle"> {t}Job details{/t}</h2>
+               </td>
+       </tr>
+       <tr>
+               <td style="width:50%;">
+                       <table>
+                <tr><td>{t}Job ID{/t}</td><td>{$ID}</td></tr>
+                               <tr>
+                                       <td>
+                                               {t}Header Tag{/t}
+                                       </td>
+                                       <td>
+                                               <select name="HeaderTag" onChange="document.mainform.submit();">
+                                                       {html_options options=$Actions selected=$HEADERTAG} 
+                                               </select>       
+                                               <input type='image' src="images/list_reload.png"
+                                                alt="{t}Reload{/t}" title="{t}Reload{/t}" class="center">
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td>&nbsp;
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td style="vertical-align: top;">       
+                                               {t}Schedule Execution{/t}
+                                       </td>
+                                       <td>
+                                               <table cellspacing="0" cellpadding="0">
+                                                       <tr>
+                                                               <td>{t}Jahr{/t}</td>
+                                                               <td>{t}Monat{/t}</td>
+                                                               <td>{t}Tag{/t}</td>
+                                                               <td>{t}Stunde{/t}</td>
+                                                               <td>{t}Minute{/t}</td>
+                                                               <td>{t}Sekunde{/t}</td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td>    
+                                                                       <select name="time_year" onChange="document.mainform.submit();">
+                                                                               {html_options values=$years options=$years selected=$time_year}
+                                                                       </select>&nbsp;
+                                                               </td>
+                                                               <td>    
+                                                                       <select name="time_month" onChange="document.mainform.submit();">
+                                                                               {html_options values=$months options=$months selected=$time_month}
+                                                                       </select>&nbsp;
+                                                               </td>
+                                                               <td>    
+                                                                       <select name="time_day">
+                                                                               {html_options values=$days options=$days selected=$time_day}
+                                                                       </select>&nbsp;
+                                                               </td>
+                                                               <td>    
+                                                                       <select name="time_hour">
+                                                                               {html_options values=$hours options=$hours selected=$time_hour}
+                                                                       </select>&nbsp;
+                                                               </td>
+                                                               <td>    
+                                                                       <select name="time_minute">
+                                                                               {html_options values=$minutes options=$minutes selected=$time_minute}
+                                                                       </select>&nbsp;
+                                                               </td>
+                                                               <td>    
+                                                                       <select name="time_second">
+                                                                               {html_options values=$seconds options=$seconds selected=$time_second}
+                                                                       </select>
+                                                               </td>
+                                                       </tr>
+                                               </table>
+                                       </td>
+                               </tr>
+                       </table>
+               </td>
+               <td>
+                       <table>
+{if $HEADERTAG == "ping"}
+                               <tr><td>{t}Status{/t}</td><td><input type="text" name="status" value="{$STATUS}"></td></tr>
+                   <tr><td>{t}Mac{/t}</td><td><input type="text" name="macaddress" value="{$MACADDRESS}"></td></tr>
+{elseif $HEADERTAG == "sayHello"}
+                               <tr><td>{t}Status{/t}</td><td><input type="text" name="status" value="{$STATUS}"></td></tr>
+                   <tr><td>{t}Mac{/t}</td><td><input type="text" name="macaddress" value="{$MACADDRESS}"></td></tr>
+{else}
+                               <tr><td>{t}Job type not implented{/t}</td></tr>
+{/if}
+                       </table>
+               </td>
+       </tr>
+</table>
+       
+<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}'>
+       <input type='submit' name='close_goto_task' value='{t}Cancel{/t}'>
+</p>
diff --git a/gosa-plugins/goto/addons/gotomasses/gotomasses.tpl b/gosa-plugins/goto/addons/gotomasses/gotomasses.tpl
new file mode 100644 (file)
index 0000000..844cdeb
--- /dev/null
@@ -0,0 +1,4 @@
+{$div}
+<div style="width:65%; text-align: center; float:left;" >
+{$range_selector}
+</div>
diff --git a/gosa-plugins/goto/addons/gotomasses/main.inc b/gosa-plugins/goto/addons/gotomasses/main.inc
new file mode 100644 (file)
index 0000000..7a517fe
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/*
+  This code is part of GOsa (https://gosa.gonicus.de)
+  Copyright (C) 2003  Cajus Pollmeier
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+if (!$remove_lock){
+
+       /* Create gotomasses object on demand */
+       if (!session::is_set('gotomasses') || (isset($_GET['reset']) && $_GET['reset'] == 1) || isset($_POST['reload_gotomass_data'])){
+               $gotomasses= new gotomasses ($config);
+               $gotomasses->set_acl_category("gotomasses");
+
+        /* Check root dn and user dn for acl informations */
+        $gotomasses->set_acl_base($config->current['BASE']);
+        if($gotomasses->getacl("") == ""){
+            $gotomasses->set_acl_base($ui->dn);
+        }
+               
+               /* Check if we have acl on our own base */
+        if($gotomasses->getacl("") == ""){
+            $gotomasses->set_acl_base(dn2base($ui->dn));
+        }
+               session::set("gotomasses",$gotomasses);
+       }
+       $gotomasses = session::get('gotomasses');
+
+       /* Execute formular */
+       $display= $gotomasses->save_object();
+       if(isset($_POST['save_gotomass_changes'])){
+               $gotomasses->save();
+       }
+       $display= $gotomasses->execute ();
+
+       /* Page header*/
+       $display= print_header(get_template_path('images/system.png'), _("System deployment")).$display;
+
+       /* Store changes  in session */
+       session::set('gotomasses',$gotomasses);
+}
diff --git a/gosa-plugins/goto/addons/gotomasses/remove.tpl b/gosa-plugins/goto/addons/gotomasses/remove.tpl
new file mode 100644 (file)
index 0000000..023142f
--- /dev/null
@@ -0,0 +1,21 @@
+<div style="font-size:18px;">
+ <img alt="" src="images/button_cancel.png" align=top>&nbsp;{t}Warning{/t}
+</div>
+<p>
+  {$info}
+  {t}This includes all account data, system access rules, imap settings, etc. for this user. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
+</p>
+
+<p>
+ {t}So - if you're sure - press 'Delete' to continue or 'Cancel' to abort.{/t}
+</p>
+
+<p class="plugbottom">
+{if $multiple}
+  <input type=submit name="delete_multiple_confirm" value="{t}Delete{/t}">
+{else}
+  <input type=submit name="delete_confirm" value="{t}Delete{/t}">
+{/if}
+  <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+</p>
+