Code

Only show date selector while dates are writeable
[gosa.git] / gosa-plugins / opsi / admin / opsiLicenses / class_licenseByProduct.inc
index 6d916a5033a593b4a3d3a37977fa0bc3401da883..8609c135d0b35b20c5042b37e60a681546953aa9 100644 (file)
@@ -35,15 +35,17 @@ class licenseByProduct extends plugin
     $this->dn = $this->orig_dn = $dn;
     $this->si = new opsiLicenceHandler($this->config);
 
+    // Is this a new object? 
     $this->is_account=TRUE;
     if($this->dn == "new"){
       $this->initially_was_account = FALSE;
     }else{
       $this->initially_was_account = TRUE;
+      
+      // Extract pool name out of the fake dn.
       $this->cn = $this->orig_cn = preg_replace("/^opsi:cn=([^,]*),.*$/","\\1",$dn);
     }
 
-    // Extract pool name out of the fake dn.
     $this->init();
   }
 
@@ -55,20 +57,15 @@ class licenseByProduct extends plugin
       $this->init_successfull = TRUE;
     }else{
 
+      // Get license information for the current product.
       $res = $this->si->getLicensesForProduct($this->cn);
-      if($this->si->is_error() || !$res){
+      if($this->si->is_error()){
         $this->init_successfull = FALSE;
         msg_dialog::display(_("Error"),msgPool::siError($this->si->get_error()),ERROR_DIALOG);
         return;
       }
 
-      if(isset($res['USEDBY'])){
-        foreach($res['USEDBY'] as $host){
-          $data = $res;
-          $data['HOST'][0] = $host;
-          $this->licenseUses[] = $data;
-        }
-      }
+      $this->licenseUses = $res;
       $this->init_successfull = TRUE;
     }
   }
@@ -81,34 +78,32 @@ class licenseByProduct extends plugin
     if(!$this->init_successfull){
       $smarty = get_smarty();
       $smarty->assign("init_successfull", $this->init_successfull);
-      return($smarty->fetch(get_template_path('licenseGeneric.tpl',TRUE,dirname(__FILE__))));
+      return($smarty->fetch(get_template_path('licenseByProduct.tpl',TRUE,dirname(__FILE__))));
     }
     
     // Create usage list
     $list = new divSelectBox("licenseUsage");
   
-    foreach($this->licenseUses as $license){
-      $f1 = array("string" => $license['HOST'][0]['VALUE']);
-      $f3 = array("string" => $license['LICENSEPOOLID'][0]['VALUE'],
-                 "attach" => "style='border-right:0px;'");
-      $list->addEntry(array($f1,$f3));
+    $ui = get_userinfo();
+    $readable = $ui->get_permissions($this->config->current['BASE'], "opsi/licenseByProduct","");
+    if($readable) {
+      foreach($this->licenseUses as $license){
+        $f1 = array("string" => $license['HOSTID'][0]['VALUE']);
+        $f2 = array("string" => $license['SOFTWARELICENSEID'][0]['VALUE']);
+        $f3 = array("string" => $license['LICENSEPOOLID'][0]['VALUE'],
+            "attach" => "style='border-right:0px;'");
+        $list->addEntry(array($f1,$f2,$f3));
+      } 
     } 
 
     $smarty = get_smarty();
 
     // Assign ACls 
     $plInfo = $this->plInfo();
-    foreach($plInfo['plProvidedAcls'] as $name => $desc){
-      $smarty->assign("{$name}ACL",$this->getacl($name));
-    }
-    foreach($this->attributes as $attr){
-      $smarty->assign($attr,$this->$attr);
-    }
-
     $smarty->assign("licenseUses", $list->DrawList());
     $smarty->assign("init_successfull", $this->init_successfull);
     $smarty->assign("initially_was_account", $this->initially_was_account);
-    return($smarty->fetch(get_template_path('licenseUsage.tpl',TRUE,dirname(__FILE__))));
+    return($smarty->fetch(get_template_path('licenseByProduct.tpl',TRUE,dirname(__FILE__))));
   }
 
  
@@ -138,17 +133,14 @@ class licenseByProduct extends plugin
   static function plInfo()
   {
     return (array(
-          "plShortName"   => _("Usage"),
-          "plDescription" => _("License usage"),
+          "plShortName"   => _("Usage by product"),
+          "plDescription" => _("License usage by product"),
           "plSelfModify"  => FALSE,
           "plDepends"     => array(),
-          "plPriority"    => 1,
+          "plPriority"    => 12,
           "plSection"     => array("administration"),
           "plCategory"    => array("opsi"),
-          "plProvidedAcls"=> array(
-            "cn"                => _("Name"),
-            "description" => _("Description"))
-          ));
+          "plProvidedAcls"=> array()));
   }
 }