diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc
index c68fd3bbe0d522807376fa71b129437636d5b70a..df9f7f12879878165062bdcb7a533e930683fa9c 100644 (file)
/* Needed values and lists */
var $base = "";
var $cn = "";
- var $macAddress = "";
- var $ipHostNumber = "";
var $l = "";
var $description = "";
var $labeledURI = "";
var $AdminMemberKeys =array();
var $is_terminalBased = false;
+ var $gotoUserPrinter ;
var $PPDdialogToSave = NULL;
var $type = "";
var $dialog =NULL;
+ var $netConfigDNS;
+ var $baseSelection = false;
+
+ var $macAddress = "";
+
/* attribute list for save action */
- var $attributes = array("cn", "description", "l", "labeledURI", "macAddress", "ipHostNumber","gotoPrinterPPD");
+ var $attributes = array("cn", "description", "l", "labeledURI", "gotoPrinterPPD","gotoUserPrinter", "macAddress");
var $objectclasses = array("top", "gotoPrinter");
function printgeneric ($config, $dn= NULL)
{
plugin::plugin ($config, $dn);
$ldap= $this->config->get_ldap_link();
+
+ $this->netConfigDNS = new termDNS($this->config, $this->dn,$this->objectclasses);
+
/* Set base */
if ($this->dn == "new"){
}else{
$this->type = "terminal";
$this->is_terminal = "true";
- $this->dn = preg_replace("/ou=terminal/","ou=printers",$this->dn);
+ $this->dn = preg_replace("/ou=terminals/","ou=printers",$this->dn);
}
}else{
/* Save dn for later references */
* If there was a new single printer created, it was never saved.
* -This allows new printers to be saved.
*/
- if($this->dn == "new"){
+ if(($this->dn == "new")&&(!$this->is_terminal)){
$this->is_account = true;
}
}
if(isset($this->parent->by_name['workgeneric'])){
// echo "workstation";
+ if($this->parent->by_object['workgeneric']->cn == "wdefault"){
+ $display= $this->show_header(_("Add printer extension"),
+ _("This is a workstation template, printer tab is disabled."),TRUE,TRUE);
+ $this->is_account= false;
+ return $display;
+ }
}elseif(isset($this->parent->by_name['termgeneric'])){
if($this->parent->by_object['termgeneric']->cn == "default"){
$display= $this->show_header(_("Add printer extension"),
}
}
+ /* Base select dialog */
+ $once = true;
+ foreach($_POST as $name => $value){
+ if(preg_match("/^chooseBase/",$name) && $once){
+ $once = false;
+ $this->dialog = new baseSelectDialog($this->config);
+ $this->dialog->setCurrentBase($this->base);
+ $this->baseSelection = true;
+ }
+ }
+
+ /* Dialog handling */
+ if(is_object($this->dialog)){
+ /* Must be called before save_object */
+ $this->dialog->save_object();
+ if($this->baseSelection){
+ if($this->dialog->isClosed()){
+ $this->dialog = false;
+ $this->baseSelection = false;
+ }elseif($this->dialog->isSelected()){
+ $this->base = $this->dialog->isSelected();
+ $this->dialog= false;
+ $this->baseSelection = false;
+ }else{
+ return($this->dialog->execute());
+ }
+ }
+ }
/* Do we represent a valid printer? */
if (!$this->is_account && $this->parent == NULL){
return $display;
}
- /* Don't show Asterisk for non-required attribute ipHostNumber and macAddress */
- $smarty->assign("staticAddress", "");
-
-
require_once ("class_ppdManager.inc");
if((isset($_SESSION['config']->data['MAIN']['PPD_PATH']))&&(is_dir($_SESSION['config']->data['MAIN']['PPD_PATH']))){
$smarty->assign("AdminMember" ,$this->AdminMember);
$smarty->assign("AdminMembers" ,$adminlist);
$smarty->assign("AdminMemberKeys",array_flip($adminlist));
- $smarty->assign("netconfig", dirname(__FILE__)."/network.tpl");
+ $smarty->assign("netconfig", $this->netConfigDNS->execute());
return($display.$smarty->fetch (get_template_path('printer.tpl', TRUE)));
}
function remove_from_parent()
{
- $this->dn= preg_replace('/ou=workstations,/', 'ou=printers,', $this->dn);
- $ldap= $this->config->get_ldap_link();
- $ldap->rmdir($this->dn);
- show_ldap_error($ldap->get_error());
- $this->handle_post_events("remove");
-
- /* Delete references to object groups */
- $ldap->cd ($this->config->current['BASE']);
- $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
- while ($ldap->fetch()){
- $og= new ogroup($this->config, $ldap->getDN());
- unset($og->member[$this->dn]);
- $og->save ();
+ if($this->initially_was_account){
+ $ldap= $this->config->get_ldap_link();
+ $ldap->cat($this->dn);
+ if(count($ldap->fetch()) ){
+
+ $this->netConfigDNS->remove_from_parent();
+ $ldap->rmdir($this->dn);
+ show_ldap_error($ldap->get_error());
+ $this->handle_post_events("remove");
+
+ /* Delete references to object groups */
+ $ldap->cd ($this->config->current['BASE']);
+ $ldap->search ("(&(objectClass=gosaGroupOfNames)(member=".$this->dn."))", array("cn"));
+ while ($ldap->fetch()){
+ $og= new ogroup($this->config, $ldap->getDN());
+ unset($og->member[$this->dn]);
+ $og->save ();
+ }
+ }
}
}
-
/* Save data to object */
function save_object()
{
plugin::save_object();
-
+ $this->netConfigDNS->save_object();
/* Save base, since this is no LDAP attribute */
if (isset($_POST['base']) && chkacl($this->acl, "create") == ""){
$this->base= $_POST['base'];
/* Check supplied data */
function check()
{
- $message= array();
+ /* Call common method to give check the hook */
+ $message= plugin::check();
+ $message= array_merge($message, $this->netConfigDNS->check());
+
+ if(isset($this->parent->by_name['workgeneric'])){
+ if($this->parent->by_object['workgeneric']->cn == "wdefault"){
+ return $message;
+ }
+ }elseif(isset($this->parent->by_name['termgeneric'])){
+ if($this->parent->by_object['termgeneric']->cn == "default"){
+ return $message;
+ }
+ }
+
$this->dn= "cn=".$this->cn.",ou=printers,ou=systems,".$this->base;
/* must: cn */
if (!$this->is_account){
return;
}
-
+ if(isset($this->parent->by_name['workgeneric'])){
+ if($this->parent->by_object['workgeneric']->cn == "wdefault"){
+ return;
+ }
+ }elseif(isset($this->parent->by_name['termgeneric'])){
+ if($this->parent->by_object['termgeneric']->cn == "default"){
+ return;
+ }
+ }
+
if($this->PPDdialogToSave){
$this->PPDdialogToSave->save_ppd();
}
/* Append printer user
*/
+ if(is_string( $this->attrs['gotoUserPrinter'])){
+ $this->attrs['gotoUserPrinter']=array();
+ }
foreach($this->member['AddUser'] as $mem){
$this->attrs['gotoUserPrinter'][]=$mem['uid'][0];
}
}
$ldap->cd($this->dn);
- $ldap->modify($this->attrs);
+ $this->cleanup();
+$ldap->modify ($this->attrs);
+
$this->handle_post_events("modify");
}
show_ldap_error($ldap->get_error());
+ $this->netConfigDNS->cn = $this->cn;
+ $this->netConfigDNS->save($this->dn);
+
/* Optionally execute a command after we're done */
$this->postcreate();
}