From: hickert Date: Tue, 29 Sep 2009 13:28:25 +0000 (+0000) Subject: Added ACL handling to license managmenet X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=40244856f0e6d5eb338c514cc5d7cbcfdcb9d51b;p=gosa.git Added ACL handling to license managmenet git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14390 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc index b2cc4d6e1..d37719ae8 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_licenseGeneric.inc @@ -50,10 +50,12 @@ class licenseGeneric extends plugin "notificationDate","licenseModel","licenseKey","maximumInstallations", "licensePoolId", "usedByHost","boundToHost"); - function __construct(&$config, $license, $hosts = array()) + function __construct(&$config, $dn, $license, $hosts = array()) { + $this->config = $config; $this->data = $license; + $this->dn = $dn; $this->si = new opsiLicenceHandler($this->config); $this->opsiHosts = $hosts; @@ -120,6 +122,16 @@ class licenseGeneric extends plugin $smarty->assign("initially_was_account", $this->initially_was_account); $smarty->assign("hosts", $this->getHosts()); + $ui = get_userinfo(); + + $acl_base = $this->dn; + if($acl_base == "new"){ + $acl_base = $this->config->current['BASE']; + } + + $smarty->assign("licenseACL", $ui->get_permissions($acl_base,"opsi/licensePoolGeneric","licenses")); + $smarty->assign("writeable", preg_match("/w/",$ui->get_permissions($acl_base,"opsi/licensePoolGeneric","licenses"))); + $smarty->assign("notUsedHosts", array_diff($this->getHosts(), $this->usedByHost)); $smarty->assign("boundToHost", $this->boundToHost[0]); $smarty->assign("licenseKey", $this->licenseKey[0]); diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc index 7b70dd492..ae4e6b01a 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc +++ b/gosa-plugins/opsi/admin/opsiLicenses/class_licensePoolGeneric.inc @@ -211,13 +211,14 @@ class licensePoolGeneric extends plugin if($this->dialog instanceOf plugin){ $this->dialog->save_object(); $display = $this->dialog->execute(); - $display.= - "

-   - -

"; + $display.= "

"; + + if($this->acl_is_writeable("licenses")){ + $display.=" "; + } + + $display.="

"; return($display); } @@ -245,19 +246,22 @@ class licensePoolGeneric extends plugin { $list = new divSelectBox("test"); $list->setHeight(100); - foreach($this->licenses as $i => $license){ - $keys = implode($license['licenseKey'],", "); - $link = ""; - $link.= ""; - - $f1 = array("string" => $license['cn']); - $f2 = array("string" => $license['licenseModel']); - $f3 = array("string" => $license['expirationDate']); - $f4 = array("string" => $license['maximumInstallations']); - $f5 = array("string" => rtrim($keys,", ")); - $f6 = array("string" => $link, "attach" => "style='border-right: 0px; width:32px;'"); - - $list->addEntry(array($f1,$f2,$f3,$f4,$f5,$f6)); + + if($this->acl_is_readable("licenses")){ + foreach($this->licenses as $i => $license){ + $keys = implode($license['licenseKey'],", "); + $link = ""; + if(preg_match("/w/", $this->getacl("licenses"))){ + $link.= ""; + } + $f1 = array("string" => $license['cn']); + $f2 = array("string" => $license['licenseModel']); + $f3 = array("string" => $license['expirationDate']); + $f4 = array("string" => $license['maximumInstallations']); + $f5 = array("string" => rtrim($keys,", ")); + $f6 = array("string" => $link, "attach" => "style='border-right: 0px; width:32px;'"); + $list->addEntry(array($f1,$f2,$f3,$f4,$f5,$f6)); + } } return($list->DrawList()); } @@ -296,61 +300,73 @@ class licensePoolGeneric extends plugin if($this->initially_was_account) $this->cn = $this->orig_cn; // We've to add prodcuts here - if(isset($_POST['availableProduct']) && isset($_POST['addProduct'])){ - $pro = get_post('availableProduct'); - if(isset($this->availableProductIds[$pro]) && !in_array($this->availableProductIds[$pro], $this->productIds)){ - $this->productIds[] =$this->availableProductIds[$pro]; + if(preg_match("/w/",$this->getacl("productIds"))){ + if(isset($_POST['availableProduct']) && isset($_POST['addProduct'])){ + $pro = get_post('availableProduct'); + if(isset($this->availableProductIds[$pro]) && !in_array($this->availableProductIds[$pro], $this->productIds)){ + $this->productIds[] =$this->availableProductIds[$pro]; + } } } // We've to remove products here - if(isset($_POST['productIds']) && isset($_POST['removeProduct'])){ - foreach($_POST['productIds'] as $key){ - if(isset($this->productIds[$key])){ - unset($this->productIds[$key]); + if(preg_match("/w/",$this->getacl("productIds"))){ + if(isset($_POST['productIds']) && isset($_POST['removeProduct'])){ + foreach($_POST['productIds'] as $key){ + if(isset($this->productIds[$key])){ + unset($this->productIds[$key]); + } } } } // We've to add software here - if(isset($_POST['newSoftwareId']) && isset($_POST['addSoftware'])){ - $soft = trim(get_post('newSoftwareId')); - if(!empty($soft) && !in_array($soft, $this->softwareIds)){ - $this->softwareIds[] = $soft; + if(preg_match("/w/",$this->getacl("windowsSoftwareIds"))){ + if(isset($_POST['newSoftwareId']) && isset($_POST['addSoftware'])){ + $soft = trim(get_post('newSoftwareId')); + if(!empty($soft) && !in_array($soft, $this->softwareIds)){ + $this->softwareIds[] = $soft; + } } } // We've to remove software Ids here - if(isset($_POST['softwareIds']) && isset($_POST['removeSoftware'])){ - foreach($_POST['softwareIds'] as $key){ - if(isset($this->softwareIds[$key])){ - unset($this->softwareIds[$key]); + if(preg_match("/w/",$this->getacl("windowsSoftwareIds"))){ + if(isset($_POST['softwareIds']) && isset($_POST['removeSoftware'])){ + foreach($_POST['softwareIds'] as $key){ + if(isset($this->softwareIds[$key])){ + unset($this->softwareIds[$key]); + } } } } // We've to create a new license - if(isset($_POST['addLicense'])){ - $this->dialog = new licenseGeneric($this->config,array(), $this->opsiHosts); - $this->dialog->set_acl_base($this->config->current['BASE']); + if(preg_match("/w/",$this->getacl("licenses"))){ + if(isset($_POST['addLicense'])){ + $this->dialog = new licenseGeneric($this->config,$this->dn,array(), $this->opsiHosts); + $this->dialog->set_acl_base($this->config->current['BASE']); + } } // Search post for image button clicks. - foreach($_POST as $name => $value){ - if(preg_match("/^editLicense_/",$name)){ - $id = preg_replace("/^editLicense_(.*)_.$/","\\1",$name); - if(isset($this->licenses[$id])){ - $this->dialog = new licenseGeneric($this->config,$this->licenses[$id], $this->opsiHosts); - $this->dialog->set_acl_base($this->config->current['BASE']); + if(preg_match("/r/",$this->getacl("licenses"))){ + foreach($_POST as $name => $value){ + if(preg_match("/^editLicense_/",$name)){ + $id = preg_replace("/^editLicense_(.*)_.$/","\\1",$name); + if(isset($this->licenses[$id])){ + $this->dialog = new licenseGeneric($this->config,$this->dn,$this->licenses[$id], $this->opsiHosts); + $this->dialog->set_acl_base($this->config->current['BASE']); + } + break; } - break; - } - if(preg_match("/^removeLicense_/",$name)){ - $id = preg_replace("/^removeLicense_(.*)_.$/","\\1",$name); - if(isset($this->licenses[$id])){ - unset($this->licenses[$id]); + if(preg_match("/^removeLicense_/",$name)){ + $id = preg_replace("/^removeLicense_(.*)_.$/","\\1",$name); + if(isset($this->licenses[$id])){ + unset($this->licenses[$id]); + } + break; } - break; } } } @@ -478,8 +494,8 @@ class licensePoolGeneric extends plugin static function plInfo() { return (array( - "plShortName" => _("Generic"), - "plDescription" => _("License generic"), + "plShortName" => _("Pool generic"), + "plDescription" => _("License pool generic"), "plSelfModify" => FALSE, "plDepends" => array(), "plPriority" => 1, @@ -487,7 +503,10 @@ class licensePoolGeneric extends plugin "plCategory" => array("opsi"), "plProvidedAcls"=> array( "cn" => _("Name"), - "description" => _("Description")) + "description" => _("Description"), + "productIds" => _("Applications"), + "windowsSoftwareIds" => _("Windows software IDs"), + "licenses" => _("Licenses")) )); } } diff --git a/gosa-plugins/opsi/admin/opsiLicenses/licenseGeneric.tpl b/gosa-plugins/opsi/admin/opsiLicenses/licenseGeneric.tpl index 45dd1eb46..1ca85f471 100644 --- a/gosa-plugins/opsi/admin/opsiLicenses/licenseGeneric.tpl +++ b/gosa-plugins/opsi/admin/opsiLicenses/licenseGeneric.tpl @@ -22,7 +22,9 @@ {if $initially_was_account} {else} +{render acl=$licenseACL} +{/render} {/if} @@ -31,7 +33,9 @@ {t}Partner{/t} +{render acl=$licenseACL} +{/render} @@ -45,7 +49,9 @@ {t}Description{/t} +{render acl=$licenseACL} +{/render} @@ -64,7 +70,9 @@ {t}Conclusion date{/t} +{render acl=$licenseACL} +{/render} @@ -72,7 +80,9 @@ {t}Expiration date{/t} +{render acl=$licenseACL} +{/render} @@ -86,7 +96,9 @@ {t}Notification date{/t} +{render acl=$licenseACL} +{/render} @@ -137,7 +149,9 @@ {t}License key{/t}{$must} +{render acl=$licenseACL} +{/render} {if $licenseModel == "VOLUME"} @@ -146,7 +160,9 @@ {t}Maximum installations{/t} +{render acl=$licenseACL} +{/render} {/if} @@ -156,10 +172,12 @@ {t}Reserved for Host{/t} +{render acl=$licenseACL} +{/render} {/if} @@ -172,10 +190,12 @@ {t}Used by Host{/t}
+{render acl=$licenseACL}
+{/render}