Code

Followup commit for #2000
[gosa.git] / trunk / gosa-plugins / goto / admin / systems / goto / tabs_terminal.inc
1 <?php
3 class termtabs extends tabs
4 {
5   public $was_activated = FALSE;
7   function termtabs($config, $data, $dn, $category)
8   {
9     tabs::tabs($config, $data, $dn,$category);
11     /* Save dn */
12     $this->dn= $dn;
13     $this->config= $config;
15     $baseobject= NULL;
17     foreach ($data as $tab){
18       if(!class_available($tab['CLASS'])) continue;  
20       $this->by_name[$tab['CLASS']]= $tab['NAME'];
22       if ($baseobject === NULL){
23         $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
24         $this->by_object[$tab['CLASS']]= $baseobject;
25       } else {
26         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
27       }
29       $this->by_object[$tab['CLASS']]->parent= &$this;
30       $this->by_object[$tab['CLASS']]->set_acl_category($category);
31       $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
33       /* Initialize current */
34       if ($this->current == ""){
35         $this->current= $tab['CLASS'];
36       }
37     }
39     /* Add references/acls/snapshots */
40     $this->addSpecialTabs();
41   }
44   /*! \brief Reinitializes the tab classes with fresh ldap values.
45     This maybe usefull if for example the apply button was pressed.
46    */
47   function re_init()
48   {
49     $baseobject= NULL;
50     foreach($this->by_object as $name => $object){
51       $class = get_class($object);
52       if(in_array($class,array("reference","acl"))) continue;
53       if ($baseobject === NULL){
54         $baseobject= new $class($this->config, $this->dn,NULL,$this);
55         $baseobject->enable_CSN_check();
56         $this->by_object[$name]= $baseobject;
57       } else {
58         $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
59       }
60       $this->by_object[$name]->parent= &$this;
61       $this->by_object[$name]->set_acl_category($this->acl_category);
62     }
63   }
66   function save_object($save_current= FALSE)
67   {
68     tabs::save_object($save_current);
70     /* Update reference, transfer variables */
71     if(isset($this->by_object['termstartup'])){
72       $this->by_object['termstartup']->gotoTerminalPath= $this->by_object['termgeneric']->gotoTerminalPath;
73     }
74     
75     $baseobject = $this->by_object['termgeneric'];
76     $baseobject->netConfigDNS->cn= $baseobject->cn;
77     foreach($this->by_object as $name => $plug){
78       $this->by_object[$name]->cn = $baseobject->cn;
79     }
80   }
83   function save($ignore_account= FALSE)
84   {
85     /* Check for new 'dn', in order to propagate the
86        'dn' to all plugins */
87     $baseobject= $this->by_object['termgeneric'];
88     $this->dn= "cn=".$baseobject->cn.",".get_ou('terminalRDN').$baseobject->base;
89     $baseobject->dn= $this->dn;
91     if($this->dn != $baseobject->orig_dn && $baseobject->orig_dn != "new"){
93       /* Udpate acls */
94       $baseobject->update_acls($baseobject->orig_dn,$this->dn);
95       $baseobject->move($baseobject->orig_dn,$this->dn);
96     }
98     foreach ($this->by_object as $key => $obj){
99       $this->by_object[$key]->dn= $this->dn;
100       $this->by_object[$key]->cn= $baseobject->cn;
101     }
103     tabs::save(TRUE);
104     if(isset($this->by_object['printgeneric'])){
105       if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){
106         $this->by_object['printgeneric']->remove_from_parent();
107       }
108     }
109   }
113 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
114 ?>