Code

Updated tabs, to re_init correctly
[gosa.git] / gosa-plugins / systems / admin / systems / tabs_server.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id$$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class servtabs extends tabs
24 {
26   function servtabs($config, $data, $dn,$category)
27   {
28     /* Save dn */
29     $this->dn= $dn;
30     $this->config= $config;
32     $baseobject= NULL;
34     foreach ($data as $tab){
35       $this->by_name[$tab['CLASS']]= $tab['NAME'];
37       if ($baseobject === NULL){
38         $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
39         $this->by_object[$tab['CLASS']]= $baseobject;
40       } else {
41         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
42       }
44       $this->by_object[$tab['CLASS']]->parent= &$this;
45       $this->by_object[$tab['CLASS']]->set_acl_category($category);
47       /* Initialize current */
48       if ($this->current == ""){
49         $this->current= $tab['CLASS'];
50       }
51     }
53     /* Add references/acls/snapshots */
54     $this->addSpecialTabs();
55   }
58   /*! \brief Reinitializes the tab classes with fresh ldap values.
59     This maybe usefull if for example the apply button was pressed.
60    */
61   function re_init()
62   {
63     $baseobject= NULL;
64     foreach($this->by_object as $name => $object){
65       $class = get_class($object);
66       if(in_array($class,array("reference","acl"))) continue;
67       if ($baseobject === NULL){
68         $baseobject= new $class($this->config, $this->dn,NULL,$this);
69         $baseobject->enable_CSN_check();
70         $this->by_object[$name]= $baseobject;
71       } else {
72         $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
73       }
74       $this->by_object[$name]->parent= &$this;
75       $this->by_object[$name]->set_acl_category($this->acl_category);
76     }
77   }
80   function save_object($save_current= FALSE)
81   {
82     tabs::save_object($save_current);
84     $baseobject = $this->by_object['servgeneric'];
85     $baseobject->netConfigDNS->cn= $baseobject->cn;
86   }
89   function save($ignore_account= FALSE)
90   {
91     /* Check for new 'dn', in order to propagate the
92        'dn' to all plugins */
93     $baseobject= $this->by_object['servgeneric'];
94     $this->dn= "cn=$baseobject->cn,".get_ou('serverou').$baseobject->base;
96     /* cn is not case sensitive for ldap, but for php it is!! */
97     if($baseobject->orig_dn != "new"){
98       if($this->config->current['DNMODE'] == "cn"){
99         if (strtolower($baseobject->orig_dn) != (strtolower($this->dn))){
100           $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
101         }
102       }else{
103         if ($baseobject->orig_dn != $this->dn){
104           $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
105         }
106       }
107     }
109     $baseobject->dn= $this->dn;
111     foreach ($this->by_object as $key => $obj){
112       $this->by_object[$key]->dn= $this->dn;
113       $this->by_object[$key]->cn= $baseobject->cn;
114     }
116     tabs::save(FALSE);
118     /* Reload server settings after saving */
119     $config = session::get('config');
120     $config->load_servers();
121     session::set('config',$config);
122   }
126 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
127 ?>