]> git.tokkee.org Git - gosa.git/commitdiff

Code

Added queue position update
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Jan 2010 11:30:16 +0000 (11:30 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Jan 2010 11:30:16 +0000 (11:30 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15446 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/goto/addons/goto/class_gotomasses.inc
gosa-plugins/goto/addons/goto/deploy-list.xml

index c5f5e4d6fbb8a75ed78c839b1c9fc7107eff471e..68d10ba00d6add61e1b0abbee5d30aa03ee66bfe 100644 (file)
@@ -67,6 +67,12 @@ class gotomasses extends management
     $headpage->setFilter($filter);
 
     parent::__construct($config, $ui, "Events", $headpage);
+
+    $this->registerAction('prioDown',   "prioDown");
+    $this->registerAction('prioUp',     "prioUp");
+    $this->registerAction('prioPause',  "prioPause");
+    $this->registerAction('processNow', "processNow");
+    $this->registerAction('viewLogs',   "viewLogs");
   }
 
   static function filterHostName($mac, $name ="")
@@ -169,64 +175,91 @@ class gotomasses extends management
     return($status);
   }
 
+  function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
+  {
+    print_a($all);
+  }
 
-
-
-
-
-
-
-
-
-
-
-
-
-  function _execute()
+  function removeEntryRequested($action="",$target=array(),$all=array())
   {
-    $smarty = get_smarty();
+    print_a($all);
+  }
 
-    /************
-     * Handle posts 
-     ************/
+  function prioDown($action="",$target=array(),$all=array())
+  {
+    if(count($target) == 1){
+      $this->update_priority($target[0], 'down');
+    }
+  }
 
-    $s_entry = $s_action = "";
-    $arr = array( 
+  function prioUp($action="",$target=array(),$all=array())
+  {
+    if(count($target) == 1){
+      $this->update_priority($target[0], 'up');
+    }
+  }
 
-        "/^pause_/"           => "pause",
-        "/^resume_/"          => "resume",
-        "/^execute_process_/" => "execute_process",
-        "/^abort_process_/"   => "abort_process",
+  function prioPause($action="",$target=array(),$all=array())
+  {
+    print_a($all);
+  }
 
-        "/^prio_up_/"     => "prio_up",
-        "/^prio_down_/"   => "prio_down",
+  function processNow($action="",$target=array(),$all=array())
+  {
+    print_a($all);
+  }
 
-        "/^edit_task_/"             =>  "edit",
-        "/^log_view_/"              =>  "logview",
-        "/^remove_task_/"           =>  "remove",
-        "/^new_task_/"              =>  "new_task");;
+  function viewLogs($action="",$target=array(),$all=array())
+  {
+    print_a($all);
+  }
 
-    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);
-        }
+  /*! \brief  Move an entry up or down in the queue, by updating its execution timestamp                             
+    @param  $id     Integer  The ID of the entry which should be updated.                                            
+    @param  $type   String   "up" / "down"                                                                           
+    @return boolean TRUE in case of success else FALSE                                                               
+   */                                                                                                                
+  public function update_priority($id,$type = "up")                                                                  
+  {                                          
+    $headpage = $this->getHeadpage();
+    $entries = $headpage->getEntries();
+    $entry = $headpage->getEntry($id);
+
+    $map = array();
+    $last = 0;
+    $next = 0;
+    foreach($entries as $pa){
+      $map[$pa['TIMESTAMP'][0]] = $pa['TIMESTAMP'][0];
+    }
+    krsort($map);
+    $found = 0;
+    $cur = 0;
+    foreach($map as $ts){
+      if($found){
+        $next = $ts;
+        break;
+      }
+      if($ts == $entry['TIMESTAMP'][0]){
+        $found = TRUE;  
+        $cur = $ts;
+      }else{
+        $last = $ts;
       }
     }
 
-    /* Menu actions */
-    if(isset($_POST['menu_action']) && !empty($_POST['menu_action'])){
-      $s_action = $_POST['menu_action'];
+    if($type == "up" && $next != 0){
+      echo "Von: ".date('d.m.Y H:i:s', strtotime($entry['TIMESTAMP'][0]))." nach ".date('d.m.Y H:i:s',strtotime($next))."<br>";
+      return($this->o_queue->update_entries(array($id),array("timestamp" => $next)));
+    }elseif($type == "down" && $last != 0){
+      echo "Von: ".date('d.m.Y H:i:s', strtotime($entry['TIMESTAMP'][0]))." nach ".date('d.m.Y H:i:s',strtotime($last))."<br>";
+      return($this->o_queue->update_entries(array($id),array("timestamp" => $last)));
     }
+  }
+
 
-    /* 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'];
-    }
 
+  function _execute()
+  {
 
     /************
      * Import CSV file  
@@ -712,40 +745,6 @@ class gotomasses extends management
   }
 
 
-  /*! \brief  Move an entry up or down in the queue, by updating its execution timestamp  
-    @param  $id     Integer  The ID of the entry which should be updated.
-    @param  $type   String   "up" / "down"
-    @return boolean TRUE in case of success else FALSE
-   */
-  public function update_priority($id,$type = "up")
-  {
-    if($type == "up"){
-      $tmp = $this->o_queue->get_queued_entries($this->event_tags,-1,-1,"timestamp DESC");
-    }else{
-      $tmp = $this->o_queue->get_queued_entries($this->event_tags,-1,-1,"timestamp ASC");
-    }
-    $last = array();
-    foreach($tmp as $entry){
-      if($entry['ID'] == $id){
-        if(count($last)){
-          $time = strtotime($last['TIMESTAMP']);
-          if($type == "up"){
-            $time ++;
-          }else{
-            $time --;
-          }
-          $time_str = date("YmdHis",$time); 
-          return($this->o_queue->update_entries(array($id),array("timestamp" => $time_str)));
-        }else{
-          return(FALSE);
-        }
-      }
-      $last = $entry;
-    }
-    return(FALSE);
-  }
-
-
   /*! \brief  Resumes to status 'waiting'.
    *  @return Boolean TRUE in case of success, else FALSE. 
    */
index 592acdee2c88fa70b6e85e7c7d4d0e6d0c227e61..2ec342519ee90b2efc1f26ec9bbc073486b62ca7 100644 (file)
@@ -21,7 +21,7 @@
   </definition>
 
   <table>
-    <layout>|160|160|20|20|20||</layout>
+    <layout>|160|160|||||</layout>
 
     <column>
       <label>Target</label>
@@ -49,8 +49,8 @@
 
     <column>
       <label>Schedule</label>
-      <sortAttribute>uid</sortAttribute>
-      <sortType>string</sortType>
+      <sortAttribute>Schedule</sortAttribute>
+      <sortType>date</sortType>
       <value>%{filter:filterSchedule(TIMESTAMP)}</value>
       <export>true</export>
     </column>