Code

Updated gotomasses
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Jan 2010 08:59:40 +0000 (08:59 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Fri, 29 Jan 2010 08:59:40 +0000 (08:59 +0000)
-Display action buttons now

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

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

index fdb665c1476b4ef72af9fb77688ff1e188319991..0e43a046229908cf6933bcef60e55838694f894a 100644 (file)
@@ -2,11 +2,16 @@
 class filterGotoEvents extends  filterLDAP {
   static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
   {
-
+    global $config;
 
     $o_queue = new gosaSupportDaemon(TRUE,5);
     $events  = DaemonEvent::get_event_types( SYSTEM_EVENT);
 
+    /* Get tags that will be used in queue searches */
+    $event_tags = array("none");
+    foreach($events['SCHEDULED'] as $evt){
+      $event_tags[] = $evt['s_Queued_Action'];
+    }
 
     $entries = $o_queue->get_queued_entries($event_tags,0,9999999,"id");
     if ($o_queue->is_error()){
@@ -16,26 +21,91 @@ class filterGotoEvents extends  filterLDAP {
     /* Assign entries by id.
      */
     $data= array();
+    $ui = get_userinfo();
+
+
+    $ui= get_userinfo();
+    $acl_base = $config->current['BASE'];
+    $acl_is_writeable = preg_match('/w/', $ui->get_permissions($acl_base, "gotomasses/gotomasses", "0"));
+    $acl_is_removeable = preg_match('/d/', $ui->get_permissions($acl_base, "gotomasses/gotomasses", "0"));
+    $acl_is_readable = preg_match('/r/', $ui->get_permissions($acl_base, "gotomasses/gotomasses", "0"));
+
     foreach($entries as $entry){
 
+      // Detect entry status 
+      $entry['objectClass'][] = "FAKE_OC__gotoEvent";
+
+      /* If WAITING add priority action
+       */
+      if(in_array($entry['STATUS'],array("waiting")) && $acl_is_writeable){
+        $entry['objectClass'][] = "FAKE_OC__prioUp";
+        $entry['objectClass'][] = "FAKE_OC__prioDown";
+        $entry['objectClass'][] = "FAKE_OC__prioPause";
+      }
+
+      /* If PAUSED add resume action
+       */
+      if(in_array($entry['STATUS'],array("paused")) && $acl_is_writeable){
+        $entry['objectClass'][] = "FAKE_OC__prioResume";
+      }
+
+      /* If PAUSED or WAITING add execution action
+       */
+      if(in_array($entry['STATUS'],array("paused","waiting")) && $acl_is_writeable){
+        $entry['objectClass'][] = "FAKE_OC__processNow";
+      }
+
+      /* Add logview button, currently ever.
+       */
+      if($acl_is_readable){
+        $entry['objectClass'][] = "FAKE_OC__viewLogs";
+      }
+
+      /* If PAUSED or WAITING add edit action
+       */
+      if(in_array($entry['STATUS'],array("waiting")) && $acl_is_writeable){
+        $entry['objectClass'][] = "FAKE_OC__edit";
+      }
+
+
+      /* If PROCESSING add abort action
+       */
+      if(in_array($entry['STATUS'],array("processing")) && preg_match("/install/",$entry['HEADERTAG']) && $acl_is_writeable){
+        $entry['objectClass'][] = "FAKE_OC__abort";
+      }
+
+      /* If WAITING or ERROR add remove action
+       */
+      if( $acl_is_removeable && in_array($entry['STATUS'],array("waiting","error","processed"))){
+        $entry['objectClass'][] = "FAKE_OC__remove";
+      }
+      if($acl_is_writeable && in_array($entry['STATUS'],array("processing")) && !preg_match("/install/",$entry['HEADERTAG'])){
+        $entry['objectClass'][] = "FAKE_OC__remove";
+      }
+
       $item = array();
-      
       $item['count'] = 0;
-      $item['dn']= implode($entry,", item=");
+      $item['dn']= $entry['MACADDRESS'].",".$entry['TIMESTAMP'];
 
       foreach($entry as $name => $value){
         $item[] = $name;
-        $item[$name]=array('count' => 1, $value);
+        if(!is_array($value)){
+          $item[$name]=array('count' => 1, $value);
+        }else{
+          $item[$name] = $value;
+          $item[$name]['count'] = count($value);
+        }
         $item['count'] ++;
       }
 
 
 #     /* Skip entries which will be removed within the next seconds */
-#     if(isset($entry['MACADDRESS']) && in_array($entry['MACADDRESS'],$this->recently_removed)){
+#     if(isset($entry['MACADDRESS']) && in_array($entry['MACADDRESS'],$recently_removed)){
 #       continue;
 #     }
       $data[] = $item;
     }
+
     return($data);
   }
 }
index b62f0734c4d0820e5d74f05615092a83f01b6c03..c5f5e4d6fbb8a75ed78c839b1c9fc7107eff471e 100644 (file)
@@ -63,6 +63,7 @@ class gotomasses extends management
     $headpage->registerElementFilter("filterTask","gotomasses::filterTask");
     $headpage->registerElementFilter("filterPeriod","gotomasses::filterPeriod");
     $headpage->registerElementFilter("filterSchedule","gotomasses::filterSchedule");
+    $headpage->registerElementFilter("filterStatus","gotomasses::filterStatus");
     $headpage->setFilter($filter);
 
     parent::__construct($config, $ui, "Events", $headpage);
@@ -103,7 +104,7 @@ class gotomasses extends management
 
   static function filterPeriod($periodic=array())
   {
-    $period = "";
+    $period = "&nbsp;-";
     if(isset($periodic[0]) && !preg_match("/none/i",$periodic[0])){
       $tmp = explode("_", $periodic[0]);
       if(count($tmp) == 2){
@@ -121,24 +122,52 @@ class gotomasses extends management
       return(date("d.m.Y H:i:s",strtotime($stamp[0])));
     }
   }
-  
-
-
-
-
-
-
-
-
-
 
 
+  static function filterStatus($status, $mac,$headertag, $progress)
+  {
 
+    $mac = $mac[0];
+    $status = $status[0];
+    $progress = $progress[0];
+    $headertag = $headertag[0];
 
+    if($status == "waiting"){
+      $status = "<img class='center' src='plugins/goto/images/clock.png' alt=''>&nbsp;"._("Waiting");
+    }
+    if($status == "error"){
+      $status = "<img class='center' src='images/false.png' alt=''>&nbsp;"._("Error");
+    }
+    if($status == "processed"){
+      $status = "<img class='center' src='images/true.png' alt=''>&nbsp;"._("Processed");
+    }
 
+    /* Special handling for all entries that have
+       STATUS == "processing" && PROGRESS == NUMERIC
+     */
+    if($status == "processing" && $progress){
+      $percent = $progress;
 
+      /* Show activation? */
+      if ($percent == "goto-activation"){
+        $status = "<img class='center' src='images/lists/off.png' alt=''>&nbsp;"._("Locked");
 
+        /* Show hardware detect? */
+      } elseif ($percent == "goto-hardware-detection") {
+        $status = "<img class='center' src='plugins/goto/images/hardware.png' alt=''>&nbsp;"._("Detection");
 
+        /* Real percent */
+      } else {
+        if (preg_match('/install/', $headertag)){
+          $status = "<img src='progress.php?x=80&y=13&p=".$progress."' alt=''
+            id='progress_".preg_replace("/:/","_",$mac)."'>";
+        } else {
+          $status = preg_replace('/ /', '&nbsp;', _("in progress"));
+        }
+      }
+    }
+    return($status);
+  }
 
 
 
index 84bbcb3be2951d2358777c2865eee9a2e5565d09..592acdee2c88fa70b6e85e7c7d4d0e6d0c227e61 100644 (file)
@@ -21,7 +21,7 @@
   </definition>
 
   <table>
-    <layout>|||||||</layout>
+    <layout>|160|160|20|20|20||</layout>
 
     <column>
       <label>Target</label>
@@ -59,7 +59,7 @@
       <label>Status</label>
       <sortAttribute>uid</sortAttribute>
       <sortType>string</sortType>
-      <value>%{filter:filterStatus(TIMESTAMP)}</value>
+      <value>%{filter:filterStatus(STATUS,MACADDRESS,HEADERTAG,PROGRESS)}</value>
       <export>true</export>
     </column>
 
   <actiontriggers snapshot="true" copypaste="true">
 
     <action>
-      <name>newfromtpl</name>
+      <name>prioUp</name>
       <type>entry</type>
-      <image>images/lists/new.png</image>
-      <objectclass>gosaUserTemplate</objectclass>
-      <label>New user from template</label>
+      <objectclass>FAKE_OC__prioUp</objectclass>
+      <image>plugins/goto/images/prio_increase.png</image>
+      <label>Up</label>
     </action>
 
     <action>
-      <name>cp</name>
-      <objectclass>!gosaUserTemplate</objectclass>
-      <type>copypaste</type>
+      <name>prioDown</name>
+      <type>entry</type>
+      <objectclass>FAKE_OC__prioDown</objectclass>
+      <image>plugins/goto/images/prio_decrease.png</image>
+      <label>Down</label>
     </action>
 
     <action>
-      <name>edit</name>
+      <name>prioPause</name>
       <type>entry</type>
-      <objectclass>gosaAccount</objectclass>
-      <image>images/lists/edit.png</image>
-      <label>Edit user</label>
+      <objectclass>FAKE_OC__prioPause</objectclass>
+      <image>images/status_pause.png</image>
+      <label>Pause</label>
     </action>
 
     <action>
-      <name>lock</name>
+      <name>processNow</name>
       <type>entry</type>
-      <objectclass>!gosaUserTemplate</objectclass>
-      <image>%{filter:lockImage(userPassword)}</image>
-      <acl>uniBonnAccount/password[w]</acl>
-      <label>%{filter:lockLabel(userPassword)}</label>
+      <objectclass>FAKE_OC__processNow</objectclass>
+      <image>images/rocket.png</image>
+      <label>Process now</label>
     </action>
 
     <action>
-      <name>password</name>
+      <name>viewLogs</name>
       <type>entry</type>
-      <objectclass>!gosaUserTemplate</objectclass>
-      <image>plugins/users/images/list_password.png</image>
-      <label>Change password</label>
+      <objectclass>FAKE_OC__viewLogs</objectclass>
+      <image>plugins/goto/images/view_logs.png</image>
+      <label>View logs</label>
     </action>
 
     <action>
-      <name>snapshot</name>
-      <type>snapshot</type>
-      <objectclass>!gosaUserTemplate</objectclass>
+      <name>edit</name>
+      <type>entry</type>
+      <objectclass>FAKE_OC__edit</objectclass>
+      <image>images/lists/edit.png</image>
+      <label>Edit</label>
     </action>
 
     <action>
       <name>remove</name>
       <type>entry</type>
+      <objectclass>FAKE_OC__remove</objectclass>
       <image>images/lists/trash.png</image>
-      <objectclass>gosaAccount</objectclass>
-      <acl>users/user[d]</acl>
-      <label>Remove user</label>
+      <label>Remove</label>
     </action>
 
   </actiontriggers>
 
 </list>
+