From c8a2eb8a08e1088291c132d412beab64efd0c70f Mon Sep 17 00:00:00 2001 From: cajus Date: Fri, 29 Jan 2010 17:48:50 +0000 Subject: [PATCH] Updated base selectors git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15479 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/goto/class_printGeneric.inc | 64 ++++++------------- .../systems/goto/class_workstationGeneric.inc | 56 ++++++---------- .../goto/admin/systems/goto/printer.tpl | 7 +- .../goto/admin/systems/goto/workstation.tpl | 7 +- 4 files changed, 39 insertions(+), 95 deletions(-) diff --git a/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc index f584a0069..9bc8b69f1 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_printGeneric.inc @@ -41,6 +41,7 @@ class printgeneric extends plugin var $gotoGroupAdminPrinter ; var $gotoGroupPrinter; var $gotoUserPrinter ; + var $baseSelector; /* attribute list for save action */ var $attributes = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress", @@ -176,6 +177,12 @@ class printgeneric extends plugin } $this->orig_cn = $this->cn; $this->orig_base = $this->base; + + /* Instanciate base selector */ + $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base); + $this->baseSelector->setSubmitButton(false); + $this->baseSelector->setHeight(300); + $this->baseSelector->update(true); } function set_acl_base($base) @@ -314,6 +321,7 @@ class printgeneric extends plugin } $smarty= get_smarty(); + $smarty->assign("usePrototype", "true"); /* Assign acls */ $tmp = $this->plInfo(); @@ -375,51 +383,13 @@ class printgeneric extends plugin } } - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_moveable()){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - $this->baseSelection = true; - } - } - - /* Dialog handling for base select dialog - * Check if base was selected, dialog aborted etc */ - if(is_object($this->dialog)){ - - $this->dialog->save_object(); - if($this->baseSelection){ - if($this->dialog->isClosed()){ - $this->dialog = false; - $this->baseSelection = false; - }elseif($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{ - return($this->dialog->execute()); - } - } - } - - /* Fill templating stuff */ - $smarty->assign("bases", $this->get_allowed_bases()); - $smarty->assign("base_select", $this->base); - /* Assign attributes */ foreach ($this->attributes as $attr){ $smarty->assign("$attr", $this->$attr); } + $smarty->assign("base", $this->baseSelector->render()); + // Act on add user/grouo requests if(isset($_POST['AddUser'])){ $this->userSelect = new userGroupSelect($this->config, get_userinfo()); @@ -724,13 +694,17 @@ class printgeneric extends plugin $this->netConfigDNS->save_object(); } - /* Set new base if allowed */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; + /* Refresh base */ + if ($this->acl_is_moveable($this->base)){ + if (!$this->baseSelector->update()) { + msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG); + } + if ($this->base != $this->baseSelector->getBase()) { + $this->base= $this->baseSelector->getBase(); + $this->is_modified= TRUE; } } + } /* Check supplied data */ diff --git a/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc b/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc index 07bb9cd6c..a93579f8c 100644 --- a/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc +++ b/gosa-plugins/goto/admin/systems/goto/class_workstationGeneric.inc @@ -38,6 +38,7 @@ class workgeneric extends plugin var $modes= array(); var $netConfigDNS; + var $baseSelector; var $inheritTimeServer = true; @@ -163,6 +164,12 @@ class workgeneric extends plugin $this->orig_dn= $this->dn; $this->orig_cn= $this->cn; $this->orig_base= $this->base; + + /* Instanciate base selector */ + $this->baseSelector= new baseSelector($this->get_allowed_bases(), $this->base); + $this->baseSelector->setSubmitButton(false); + $this->baseSelector->setHeight(300); + $this->baseSelector->update(true); } @@ -228,37 +235,6 @@ class workgeneric extends plugin return($display); } - /* Base select dialog */ - $once = true; - foreach($_POST as $name => $value){ - if(preg_match("/^chooseBase/",$name) && $once && $this->acl_is_writeable("base")){ - $once = false; - $this->dialog = new baseSelectDialog($this->config,$this,$this->get_allowed_bases()); - $this->dialog->setCurrentBase($this->base); - } - } - - /* Dialog handling */ - if(is_object($this->dialog)){ - /* Must be called before save_object */ - $this->dialog->save_object(); - - if($this->dialog->isClosed()){ - $this->dialog = false; - }elseif($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; - }else{ - return($this->dialog->execute()); - } - } - /* Add new ntp Server to our list */ if((isset($_POST['addNtpServer'])) && (isset($_POST['gotoNtpServers'])) && $this->acl_is_writeable("gotoNtpServer")){ $this->gotoNtpServer[$_POST['gotoNtpServers']] = $_POST['gotoNtpServers']; @@ -273,6 +249,7 @@ class workgeneric extends plugin /* Fill templating stuff */ $smarty= get_smarty(); + $smarty->assign("usePrototype", "true"); /* Set acls */ $tmp = $this->plInfo(); @@ -283,7 +260,6 @@ class workgeneric extends plugin $smarty->assign("cn", $this->cn); $smarty->assign("description", $this->description); $smarty->assign("l", $this->l); - $smarty->assign("bases", $this->get_allowed_bases()); $smarty->assign("staticAddress", ""); $tmp = array(); @@ -328,9 +304,10 @@ class workgeneric extends plugin $smarty->assign("gotoNtpServers", $ntpser); /* Variables */ - foreach(array("base", "gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){ + foreach(array("gotoMode", "gotoSyslogServer", "gotoNtpServer") as $val){ $smarty->assign($val."_select", $this->$val); } + $smarty->assign("base", $this->baseSelector->render()); /* tell smarty the inherit checkbox state */ $smarty->assign("inheritTimeServer",$this->inheritTimeServer); @@ -410,11 +387,14 @@ class workgeneric extends plugin plugin::save_object(); $this->base = $base_tmp; - /* Save base, since this is no LDAP attribute */ - $tmp = $this->get_allowed_bases(); - if(isset($_POST['base'])){ - if(isset($tmp[$_POST['base']])){ - $this->base= $_POST['base']; + /* Refresh base */ + if ($this->acl_is_moveable($this->base)){ + if (!$this->baseSelector->update()) { + msg_dialog::display(_("Error"), msgPool::permMove(), ERROR_DIALOG); + } + if ($this->base != $this->baseSelector->getBase()) { + $this->base= $this->baseSelector->getBase(); + $this->is_modified= TRUE; } } diff --git a/gosa-plugins/goto/admin/systems/goto/printer.tpl b/gosa-plugins/goto/admin/systems/goto/printer.tpl index 4d63647c5..56e280513 100644 --- a/gosa-plugins/goto/admin/systems/goto/printer.tpl +++ b/gosa-plugins/goto/admin/systems/goto/printer.tpl @@ -27,12 +27,7 @@ {$must} {render acl=$baseACL} - -{/render} -{render acl=$baseACL disable_picture='images/lists/folder_grey.png'} - + {$base} {/render} diff --git a/gosa-plugins/goto/admin/systems/goto/workstation.tpl b/gosa-plugins/goto/admin/systems/goto/workstation.tpl index 6309ec774..8e9a09997 100644 --- a/gosa-plugins/goto/admin/systems/goto/workstation.tpl +++ b/gosa-plugins/goto/admin/systems/goto/workstation.tpl @@ -35,12 +35,7 @@ {$must} {render acl=$baseACL} - -{/render} -{render acl=$baseACL disable_picture='images/lists/folder_grey.png'} - + {$base} {/render} -- 2.30.2