X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_printGeneric.inc;h=3738b4f4ac4b377b78588a0cbe85d81e43da65ba;hb=8edf1b0390149b39682c7e02c394fec56940874d;hp=dd7cf2e30bf8b2035252c405160e13a04415fc24;hpb=626fcae40c67ec091a1b379d3a53b85c5ed4851c;p=gosa.git diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc index dd7cf2e30..3738b4f4a 100644 --- a/plugins/admin/systems/class_printGeneric.inc +++ b/plugins/admin/systems/class_printGeneric.inc @@ -73,6 +73,7 @@ class printgeneric extends plugin } $this->orig_dn = $this->dn; + $ui= get_userinfo(); /* Get printer settings, possibly dn has changed */ plugin::plugin ($config, $this->dn); @@ -92,7 +93,6 @@ class printgeneric extends plugin /* Set base */ if ($this->dn == "new"){ - $ui= get_userinfo(); $this->base= dn2base($ui->dn); $this->cn= ""; } else { @@ -128,17 +128,30 @@ class printgeneric extends plugin unset($this->attrs[$attr]['count']); } + /* Set tag attribute if we've tagging activated */ + $tag= ""; + if ($ui->gosaUnitTag != "" && isset($config->current['STRICT_UNITS']) && + preg_match('/TRUE/i', $config->current['STRICT_UNITS'])){ + $tag= "(gosaUnitTag=".$ui->gosaUnitTag.")"; + } + if(isset($this->attrs[$attr])){ foreach($this->attrs[$attr] as $mem){ if(preg_match("/Group/",$type)){ - $ldap->search("(&(objectClass=posixGroup)(cn=".$mem."))",array("cn","description")); - $entry = $ldap->fetch(); - $this->member[$type][$entry['cn'][0]]=$entry; + $ldap->search("(&(objectClass=posixGroup)$tag(cn=".$mem."))",array("cn","description")); + if($ldap->count()){ + $entry = $ldap->fetch(); + if(isset($entry['cn'])){ + $this->member[$type][$entry['cn'][0]]=$entry; + } + } }else{ - $ldap->search("(&(objectClass=person)(objectClass=inetOrgPerson)(uid=".$mem."))",array("cn","uid")); - $entry = $ldap->fetch(); - if(isset($entry['uid'])){ - $this->member[$type][$entry['uid'][0]]=$entry; + $ldap->search("(&(objectClass=person)$tag(objectClass=inetOrgPerson)(uid=".$mem."))",array("cn","uid")); + if($ldap->count()){ + $entry = $ldap->fetch(); + if(isset($entry['uid'])){ + $this->member[$type][$entry['uid'][0]]=$entry; + } } } } @@ -508,7 +521,11 @@ class printgeneric extends plugin $smarty->assign("AdminMember" ,$this->AdminMember); $smarty->assign("AdminMembers" ,$adminlist); $smarty->assign("AdminMemberKeys",array_flip($adminlist)); - $smarty->assign("netconfig", $this->netConfigDNS->execute()); + if($this->BelongsTo == "Printer"){ + $smarty->assign("netconfig", $this->netConfigDNS->execute()); + } else { + $smarty->assign("netconfig", ""); + } return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE))); } @@ -577,7 +594,9 @@ class printgeneric extends plugin { /* Call common method to give check the hook */ $message= plugin::check(); - $message= array_merge($message, $this->netConfigDNS->check()); + if ($this->BelongsTo == 'printer'){ + $message= array_merge($message, $this->netConfigDNS->check()); + } /* Don't display check messages if this is a template object */ if(isset($this->parent->by_object['workgeneric'])){ @@ -596,6 +615,16 @@ class printgeneric extends plugin if(($this->BelongsTo == "Printer") && (empty($this->cn))){ $message[]= "The required field 'Printer name' is not set."; } + + if($this->BelongsTo == "Printer"){ + $ui= get_userinfo(); + $acl= get_permissions ($dn, $ui->subtreeACL); + $acl= get_module_permission($acl, "printer", $this->dn); + if (chkacl($acl, "create") != ""){ + $message[]= _("You have no permissions to create a printer on this 'Base'."); + } + } + /* must: labeledURI */ if(empty($this->labeledURI)){ @@ -632,6 +661,8 @@ class printgeneric extends plugin if($this->BelongsTo == "Workstation"){ $this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn); + $mac = $this->parent->by_object['workgeneric']->netConfigDNS->macAddress; + $this->netConfigDNS->macAddress = $mac; } if(!$this->is_account) return; @@ -655,6 +686,19 @@ class printgeneric extends plugin $this->PPDdialogToSave->save_ppd(); } + if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ + $method="https://"; + }else{ + $method="http://"; + } + + /* If no ppd is selected, remove this attribute */ + if(!empty($this->gotoPrinterPPD)) { + $this->gotoPrinterPPD = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD); + }else{ + $this->gotoPrinterPPD = array(); + } + $dn= $this->dn; plugin::save(); $ldap= $this->config->get_ldap_link(); @@ -674,14 +718,6 @@ class printgeneric extends plugin $this->attrs= $attrs; } - if(preg_match("/https/i",$_SERVER['HTTP_REFERER'])){ - $method="https://"; - }else{ - $method="http://"; - } - - $this->attrs['gotoPrinterPPD'] = $method.str_replace("//","/",$_SERVER['SERVER_NAME']."/ppd/".$this->gotoPrinterPPD); - /* Append printer user */ $this->attrs['gotoUserPrinter']=array(); @@ -714,6 +750,14 @@ class printgeneric extends plugin $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag"; } + if($this->orig_dn == 'new'){ + foreach(array("gotoGroupPrinter","gotoUserAdminPrinter","gotoGroupAdminPrinter","gotoUserPrinter") as $checkVar){ + if(count($this->attrs[$checkVar]) == 0 || empty($this->attrs[$checkVar])){ + unset($this->attrs[$checkVar]); + } + } + } + /* Write back to ldap */ $ldap= $this->config->get_ldap_link(); if ($this->orig_dn == 'new'){ @@ -735,12 +779,16 @@ class printgeneric extends plugin } show_ldap_error($ldap->get_error(), _("Saving printer failed")); + $this->netConfigDNS->cn = $this->cn; $this->netConfigDNS->dn = $this->dn; $this->netConfigDNS->save($this->dn); /* Optionally execute a command after we're done */ $this->postcreate(); + + /* This is a multi object. Handle tagging here... */ + $this->handle_object_tagging(); } function generateList(){