Code

68d30ea43043eed2b20537c8cbcc4834e516639b
[gosa.git] / 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,$hide_refs = FALSE, $hide_acls = FALSE)
8   {
9     /* Save dn */
10     $this->dn= $dn;
11     $this->config= $config;
13     $this->hide_refs = $hide_refs;
14     $this->hide_acls = $hide_acls;
15     $this->acl_category = $category;
17     $baseobject= NULL;
19     foreach ($data as $tab){
20       if(!class_available($tab['CLASS'])) continue;  
22       $this->by_name[$tab['CLASS']]= $tab['NAME'];
24       if ($baseobject === NULL){
25         $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
26         $this->by_object[$tab['CLASS']]= $baseobject;
27       } else {
28         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
29       }
31       $this->by_object[$tab['CLASS']]->parent= &$this;
32       $this->by_object[$tab['CLASS']]->set_acl_category($category);
33       $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
35       /* Initialize current */
36       if ($this->current == ""){
37         $this->current= $tab['CLASS'];
38       }
39     }
41     /* Add references/acls/snapshots */
42     $this->addSpecialTabs();
43   }
46   /*! \brief Reinitializes the tab classes with fresh ldap values.
47     This maybe usefull if for example the apply button was pressed.
48    */
49   function re_init()
50   {
51     $baseobject= NULL;
52     foreach($this->by_object as $name => $object){
53       $class = get_class($object);
54       if(in_array($class,array("reference","acl"))) continue;
55       if ($baseobject === NULL){
56         $baseobject= new $class($this->config, $this->dn,NULL,$this);
57         $baseobject->enable_CSN_check();
58         $this->by_object[$name]= $baseobject;
59       } else {
60         $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
61       }
62       $this->by_object[$name]->parent= &$this;
63       $this->by_object[$name]->set_acl_category($this->acl_category);
64     }
65   }
68   function save_object($save_current= FALSE)
69   {
70     tabs::save_object($save_current);
72     /* Update reference, transfer variables */
73     if(isset($this->by_object['termstartup'])){
74       $this->by_object['termstartup']->gotoTerminalPath= $this->by_object['termgeneric']->gotoTerminalPath;
75     }
76     
77     $baseobject = $this->by_object['termgeneric'];
78     $baseobject->netConfigDNS->cn= $baseobject->cn;
79     foreach($this->by_object as $name => $plug){
80       $this->by_object[$name]->cn = $baseobject->cn;
81     }
82   }
85   function save($ignore_account= FALSE)
86   {
87     /* Check for new 'dn', in order to propagate the
88        'dn' to all plugins */
89     $baseobject= $this->by_object['termgeneric'];
90     $cn      = preg_replace('/,/', '\,', $baseobject->cn);
91     $cn      = preg_replace('/"/', '\"', $cn);
92     $this->dn= "cn=".$cn.",".get_ou("termgeneric", "terminalRDN").$baseobject->base;
93     $baseobject->dn= $this->dn;
95     if($this->dn != $baseobject->orig_dn && $baseobject->orig_dn != "new"){
97       /* Udpate acls */
98       $baseobject->update_acls($baseobject->orig_dn,$this->dn);
99       $baseobject->move($baseobject->orig_dn,$this->dn);
100     }
102     foreach ($this->by_object as $key => $obj){
103       $this->by_object[$key]->dn= $this->dn;
104       $this->by_object[$key]->cn= $baseobject->cn;
105     }
107     tabs::save(TRUE);
108     if(isset($this->by_object['printgeneric'])){
109       if(($this->by_object['printgeneric']->is_account==false)&&($this->by_object['printgeneric']->initially_was_account==true)){
110         $this->by_object['printgeneric']->remove_from_parent();
111       }
112     }
113   }
117 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
118 ?>