diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc
index 4f33ca2cd3e1d62ed2eacd4c62d9faf44ec0ea7c..021c75f9d0f5b6864dbd6fbe27e31abb6d306aac 100644 (file)
}
/* Update dn, to ensure storing as printer instead of WS / terminal */
}
/* Update dn, to ensure storing as printer instead of WS / terminal */
- if($this->BelongsTo == "Terminal"){
+ if(preg_match("/Terminal/i",$this->BelongsTo) || preg_match("/TerminalTemplate/i",$this->BelongsTo)){
$this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
}
$this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
}
- if($this->BelongsTo == "Workstation"){
+ if(preg_match("/Workstation/i",$this->BelongsTo) || preg_match("/WorkstationTemplate/i",$this->BelongsTo)){
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
}
$this->orig_dn = $this->dn;
/* Get printer settings, possibly dn has changed */
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
}
$this->orig_dn = $this->dn;
/* Get printer settings, possibly dn has changed */
- plugin::plugin ($config, $this->dn,$parent_init);
+ plugin::plugin ($config, $this->dn);
/* Get is_account initially_was_account status */
$this->getTypeOfPrinter(true);
/* Get is_account initially_was_account status */
$this->getTypeOfPrinter(true);
/* If is printer it must be a true account.
*/
/* If is printer it must be a true account.
*/
- if($this->BelongsTo == "Printer"){
+ if(preg_match("/printer/i",$this->BelongsTo)){
$this->is_account = true;
}
/* Update dn, to ensure storing as printer instead of WS / terminal
*/
$this->is_account = true;
}
/* Update dn, to ensure storing as printer instead of WS / terminal
*/
- if($this->BelongsTo == "Terminal"){
+ if(preg_match("/terminal/i",$this->BelongsTo)){
$this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
}
$this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
}
- if($this->BelongsTo == "Workstation"){
+ if(preg_match("/workstation/i",$this->BelongsTo)){
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
}
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
}
/* If type of printer couldn't be detected (because of missing parent object in construction)
* hide this tab.
*/
/* If type of printer couldn't be detected (because of missing parent object in construction)
* hide this tab.
*/
- if($this->BelongsTo == "unknown"){
+ if(preg_match("/unknown/i",$this->BelongsTo)){
$display= $this->show_enable_header(_("Add printer extension"),
_("Could not intialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
return($display);
$display= $this->show_enable_header(_("Add printer extension"),
_("Could not intialize printer tab, parameter parent was missing while construction."),TRUE,TRUE);
return($display);
/* Templates can't have printer extensions
*/
/* Templates can't have printer extensions
*/
- if($this->BelongsTo == "WorkstationTemplate"){
+ if(preg_match("/WorkstationTemplate/i",$this->BelongsTo)){
$display= $this->show_enable_header(_("Add printer extension"),
_("This is a workstation template, printer tab is disabled."),TRUE,TRUE);
return($display);
}
$display= $this->show_enable_header(_("Add printer extension"),
_("This is a workstation template, printer tab is disabled."),TRUE,TRUE);
return($display);
}
- if($this->BelongsTo == "TerminalTemplate"){
+ if(preg_match("/TerminalTemplate/i",$this->BelongsTo)){
$display= $this->show_enable_header(_("Add printer extension"),
_("This is a terminal template, printer tab is disabled."),TRUE,TRUE);
return($display);
}
/* Get cn from base object */
$display= $this->show_enable_header(_("Add printer extension"),
_("This is a terminal template, printer tab is disabled."),TRUE,TRUE);
return($display);
}
/* Get cn from base object */
- if($this->BelongsTo == "Workstation"){
+ if(preg_match("/^Workstation$/i",$this->BelongsTo)){
$this->cn = $this->parent->by_object['workgeneric']->cn;
}
$this->cn = $this->parent->by_object['workgeneric']->cn;
}
- if($this->BelongsTo == "Terminal"){
+ if(preg_match("/^Terminal$/i",$this->BelongsTo)){
$this->cn = $this->parent->by_object['termgeneric']->cn;
}
$this->cn = $this->parent->by_object['termgeneric']->cn;
}
$smarty->assign($name."ACL", $this->getacl($name));
}
$smarty->assign($name."ACL", $this->getacl($name));
}
- /* Create base acls */
- $baseACL = $this->getacl("base");
- if(!$this->acl_is_moveable()) {
- $baseACL = preg_replace("/w/","",$baseACL);
- }
- $smarty->assign("baseACL", $baseACL);
-
-
$display="";
/* Tell smarty if this is a standalone object or a terminal / WS depending printer */
$display="";
/* Tell smarty if this is a standalone object or a terminal / WS depending printer */
- if($this->BelongsTo == "Printer"){
+ if(preg_match("/^Printer$/i",$this->BelongsTo)){
$smarty->assign("StandAlone",true);
}else{
$smarty->assign("StandAlone",false);
$smarty->assign("StandAlone",true);
}else{
$smarty->assign("StandAlone",false);
}
/* If this is a WS / Terminal depending printer, display account state button */
}
/* If this is a WS / Terminal depending printer, display account state button */
- if($this->BelongsTo != "Printer"){
+ if(!preg_match("/^Printer$/i",$this->BelongsTo)){
if((empty($this->cn)) && ($this->dn != "new")){
$display= $this->show_enable_header(_("Add printer extension"),
_("This object has printer extension disabled. You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template"),TRUE,TRUE);
if((empty($this->cn)) && ($this->dn != "new")){
$display= $this->show_enable_header(_("Add printer extension"),
_("This object has printer extension disabled. You can't enable it while 'cn' is not present in entry. Possibly you are currently creating a new terminal template"),TRUE,TRUE);
}
if (($this->is_account)){
}
if (($this->is_account)){
- if($this->BelongsTo=="Workstation"){
+ if(preg_match("/^Workstation$/i",$this->BelongsTo)){
$display= $this->show_disable_header(_("Remove printer extension"),
_("This workstation has printer extension enabled.You can disable it by clicking below."));
$display= $this->show_disable_header(_("Remove printer extension"),
_("This workstation has printer extension enabled.You can disable it by clicking below."));
- }elseif($this->BelongsTo=="Terminal"){
+ }elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){
$display= $this->show_disable_header(_("Remove printer extension"),
_("This terminal has printer extension enabled. You can disable it by clicking below."));
}
}else{
$display= $this->show_disable_header(_("Remove printer extension"),
_("This terminal has printer extension enabled. You can disable it by clicking below."));
}
}else{
- if($this->BelongsTo=="Workstation"){
+ if(preg_match("/^Workstation$/i",$this->BelongsTo)){
$display= $this->show_disable_header(_("Add printer extension"),
_("This workstation has printer extension disabled. You can enable it by clicking below."));
$display= $this->show_disable_header(_("Add printer extension"),
_("This workstation has printer extension disabled. You can enable it by clicking below."));
- }elseif($this->BelongsTo=="Terminal"){
+ }elseif(preg_match("/^Terminal$/i",$this->BelongsTo)){
$display= $this->show_enable_header(_("Add printer extension"),
_("This terminal has printer extension disabled. You can enable it by clicking below."));
}
$display= $this->show_enable_header(_("Add printer extension"),
_("This terminal has printer extension disabled. You can enable it by clicking below."));
}
$this->dialog = false;
$this->baseSelection = false;
}elseif($this->dialog->isSelected()){
$this->dialog = false;
$this->baseSelection = false;
}elseif($this->dialog->isSelected()){
- $this->base = $this->dialog->isSelected();
+
+ /* A new base was selected, check if it is a valid one */
+ $tmp = $this->get_allowed_bases();
+ if(isset($tmp[$this->dialog->isSelected()])){
+ $this->base = $this->dialog->isSelected();
+ }
+
$this->dialog= false;
$this->baseSelection = false;
}else{
$this->dialog= false;
$this->baseSelection = false;
}else{
$ppdManager= new ppdManager($path);
if(!empty($this->gotoPrinterPPD)){
if((!file_exists($path.$this->gotoPrinterPPD))){
$ppdManager= new ppdManager($path);
if(!empty($this->gotoPrinterPPD)){
if((!file_exists($path.$this->gotoPrinterPPD))){
- $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD))."</b>";
+ $smarty->assign("driverInfo", "<b>".sprintf(_("Your currently selected PPD file '%s' doesn't exist."),$path.$this->gotoPrinterPPD)."</b>");
}else{
$smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
}
}else{
$smarty->assign("driverInfo", $ppdManager->loadDescription($path.$this->gotoPrinterPPD));
}
asort($userlist);
asort($adminlist);
asort($userlist);
asort($adminlist);
- if($this->BelongsTo != "Printer"){
- if($this->BelongsTo == "Terminal"){
+ if(!preg_match("/Printer/i",$this->BelongsTo)){
+ if(preg_match("/Terminal/i",$this->BelongsTo)){
$smarty->assign("desc" ,sprintf(_("This printer belongs to terminal %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
}else{
$smarty->assign("desc" ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
$smarty->assign("desc" ,sprintf(_("This printer belongs to terminal %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
}else{
$smarty->assign("desc" ,sprintf(_("This printer belongs to workstation %s. You can't rename this printer."),"<b>".$this->cn."</b>"));
$smarty->assign("AdminMember" ,$this->AdminMember);
$smarty->assign("AdminMembers" ,$adminlist);
$smarty->assign("AdminMemberKeys",array_flip($adminlist));
$smarty->assign("AdminMember" ,$this->AdminMember);
$smarty->assign("AdminMembers" ,$adminlist);
$smarty->assign("AdminMemberKeys",array_flip($adminlist));
- if($this->BelongsTo == "Printer"){
+ if(preg_match("/Printer/i",$this->BelongsTo)){
$smarty->assign("netconfig", $this->netConfigDNS->execute());
} else {
$smarty->assign("netconfig", "");
$smarty->assign("netconfig", $this->netConfigDNS->execute());
} else {
$smarty->assign("netconfig", "");
/* Update dn, to ensure storing as printer instead of WS / terminal
*/
/* Update dn, to ensure storing as printer instead of WS / terminal
*/
- if($this->BelongsTo == "Terminal"){
+ if(preg_match("/terminal/i",$this->BelongsTo)){
$this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
}
$this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
}
- if($this->BelongsTo == "Workstation"){
+ if(preg_match("/workstation/i",$this->BelongsTo)){
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
}
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
}
/* Save data to object */
function save_object()
{
/* Save data to object */
function save_object()
{
+ /* Create a base backup and reset the
+ base directly after calling plugin::save_object();
+ Base will be set seperatly a few lines below */
+ $base_tmp = $this->base;
plugin::save_object();
plugin::save_object();
-
+ $this->base = $base_tmp;
+
if(is_object($this->netConfigDNS)){
$this->netConfigDNS->save_object();
}
if(is_object($this->netConfigDNS)){
$this->netConfigDNS->save_object();
}
-
- /* Save base, since this is no LDAP attribute */
- if((isset($_POST['base'])) && ($this->acl_is_moveable()) ) {
- $this->set_acl_base('dummy,'.$_POST['base']);
- if($this->acl_is_moveable()){
-
- if(isset($this->config->idepartments[$_POST['base']])){
- $this->base = $_POST['base'];
- if ($_POST['base'] != $this->base){
- $this->is_modified= TRUE;
- }
- }
- }else{
-
- print_red(sprintf(_("You are not allowed to move this object to '%s'."),LDAP::fix($_POST['base'])));
- $this->set_acl_base('dummy,'.$this->base);
+
+ /* Set new base if allowed */
+ $tmp = $this->get_allowed_bases();
+ if(isset($_POST['base'])){
+ if(isset($tmp[$_POST['base']])){
+ $this->base= $_POST['base'];
}
}
}
}
}
}
{
/* Call common method to give check the hook */
$message= plugin::check();
{
/* Call common method to give check the hook */
$message= plugin::check();
- if ($this->BelongsTo == 'printer'){
+ if (preg_match("/printer/i",$this->BelongsTo)){
$message= array_merge($message, $this->netConfigDNS->check());
}
$message= array_merge($message, $this->netConfigDNS->check());
}
$dn= "cn=".$this->cn.",ou=printers,ou=systems,".$this->base;
/* must: cn */
$dn= "cn=".$this->cn.",ou=printers,ou=systems,".$this->base;
/* must: cn */
- if(($this->BelongsTo == "Printer") && (empty($this->cn))){
+ if(preg_match("/printer/i",$this->BelongsTo) && (empty($this->cn))){
$message[]= "The required field 'Printer name' is not set.";
}
$message[]= "The required field 'Printer name' is not set.";
}
- if($this->BelongsTo == "Printer"){
+ /* Set new acl base */
+ if($this->dn == "new") {
+ $this->set_acl_base($this->base);
+ }
+
+ if(preg_match("/printer/i",$this->BelongsTo)){
if ($this->orig_dn == "new" && !$this->acl_is_createable()){
$message[]= _("You have no permissions to create a group on this 'Base'.");
}
if ($this->orig_dn == "new" && !$this->acl_is_createable()){
$message[]= _("You have no permissions to create a group on this 'Base'.");
}
}
/* Check if there is already an entry with this cn*/
}
/* Check if there is already an entry with this cn*/
- if (($this->orig_dn != $dn)&&($this->BelongsTo == "Printer")){
+ if (($this->orig_dn != $dn)&&( preg_match("/printer/i",$this->BelongsTo))){
$ldap= $this->config->get_ldap_link();
$ldap->cd ($this->base);
$ldap->ls("(cn=".$this->cn.")","ou=printers,ou=systems,".$this->base, array("cn"));
$ldap= $this->config->get_ldap_link();
$ldap->cd ($this->base);
$ldap->ls("(cn=".$this->cn.")","ou=printers,ou=systems,".$this->base, array("cn"));
{
/* Update dn, to ensure storing as printer instead of WS / terminal
*/
{
/* Update dn, to ensure storing as printer instead of WS / terminal
*/
- if($this->BelongsTo == "Terminal"){
+ if(preg_match("/terminal/i",$this->BelongsTo)){
$this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
}
$this->dn= preg_replace("/ou=terminals,/","ou=printers,",$this->dn);
}
- if($this->BelongsTo == "Workstation"){
+ if(preg_match("/workstation/i",$this->BelongsTo)){
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
}
$this->dn= preg_replace("/ou=workstations,/","ou=printers,",$this->dn);
}
}
/* If type is still unknown, the initialisation of this printer failed, abort. */
}
/* If type is still unknown, the initialisation of this printer failed, abort. */
- if($this->BelongsTo == "unknown"){
+ if(preg_match("/unknown/i",$this->BelongsTo)){
return;
}
return;
}
$this->attrs['gotoGroupAdminPrinter'][]=$mem['cn'][0];
}
$this->attrs['gotoGroupAdminPrinter'][]=$mem['cn'][0];
}
- if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
- $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]);
}
}
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]);
}
}
+ }else{
+ if(($this->gosaUnitTag) && (!in_array_ics("gosaAdministrativeUnitTag",$this->attrs['objectClass']))){
+ $this->attrs['objectClass'][] = "gosaAdministrativeUnitTag";
+ }
}
/* Move object in necessary*/
}
/* Move object in necessary*/
}
show_ldap_error($ldap->get_error(), sprintf(_("Saving of system print/generic with dn '%s' failed."),$this->dn));
}
show_ldap_error($ldap->get_error(), sprintf(_("Saving of system print/generic with dn '%s' failed."),$this->dn));
- if($this->BelongsTo == "Printer"){
+ if(preg_match("/printer/i",$this->BelongsTo)){
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->dn = $this->dn;
$this->netConfigDNS->save($this->dn);
$this->netConfigDNS->cn = $this->cn;
$this->netConfigDNS->dn = $this->dn;
$this->netConfigDNS->save($this->dn);
"plDescription" => _("Print generic"),
"plSelfModify" => FALSE,
"plDepends" => array(),
"plDescription" => _("Print generic"),
"plSelfModify" => FALSE,
"plDepends" => array(),
- "plPriority" => 11,
+ "plPriority" => 4,
"plSection" => array("administration"),
"plCategory" => array("printer" => array("description" => _("Printer"),
"plSection" => array("administration"),
"plCategory" => array("printer" => array("description" => _("Printer"),
- "objectClass" => "gotoPrinter"),"workstation"),
+ "objectClass" => "gotoPrinter"),"workstation","terminal"),
"plProvidedAcls"=> array(
"cn" => _("Name"),
"base" => _("Base") ,
"plProvidedAcls"=> array(
"cn" => _("Name"),
"base" => _("Base") ,