Code

Added branches container for old stuff
[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   
36       if(!class_available($tab['CLASS'])){
37         continue;
38       }
40       $this->by_name[$tab['CLASS']]= $tab['NAME'];
41       if ($baseobject === NULL){
42         $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
43         $this->by_object[$tab['CLASS']]= $baseobject;
44       } else {
45         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
46       }
48       $this->by_object[$tab['CLASS']]->parent= &$this;
49       $this->by_object[$tab['CLASS']]->set_acl_category($category);
51       /* Initialize current */
52       if ($this->current == ""){
53         $this->current= $tab['CLASS'];
54       }
55     }
57     /* Add references/acls/snapshots */
58     $this->addSpecialTabs();
59   }
62   /*! \brief Reinitializes the tab classes with fresh ldap values.
63     This maybe usefull if for example the apply button was pressed.
64    */
65   function re_init()
66   {
67     $baseobject= NULL;
68     foreach($this->by_object as $name => $object){
69       $class = get_class($object);
70       if(in_array($class,array("reference","acl"))) continue;
71       if ($baseobject === NULL){
72         $baseobject= new $class($this->config, $this->dn,NULL,$this);
73         $baseobject->enable_CSN_check();
74         $this->by_object[$name]= $baseobject;
75       } else {
76         $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
77       }
78       $this->by_object[$name]->parent= &$this;
79       $this->by_object[$name]->set_acl_category($this->acl_category);
80     }
81   }
84   function save_object($save_current= FALSE)
85   {
86     tabs::save_object($save_current);
88     $baseobject = $this->by_object['servgeneric'];
89     $baseobject->netConfigDNS->cn= $baseobject->cn;
90   }
93   function save($ignore_account= FALSE)
94   {
95     /* Check for new 'dn', in order to propagate the
96        'dn' to all plugins */
97     $baseobject= $this->by_object['servgeneric'];
98     $this->dn= "cn=$baseobject->cn,".get_ou('serverou').$baseobject->base;
100     /* cn is not case sensitive for ldap, but for php it is!! */
101     if($baseobject->orig_dn != "new"){
102       if($this->config->get_cfg_value("dnmode") == "cn"){
103         if (strtolower($baseobject->orig_dn) != (strtolower($this->dn))){
104           $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
105         }
106       }else{
107         if ($baseobject->orig_dn != $this->dn){
108           $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
109         }
110       }
111     }
113     $baseobject->dn= $this->dn;
115     foreach ($this->by_object as $key => $obj){
116       $this->by_object[$key]->dn= $this->dn;
117       $this->by_object[$key]->cn= $baseobject->cn;
118     }
120     tabs::save(FALSE);
122     /* Reload server settings after saving */
123     $config = session::get('config');
124     $config->load_servers();
125     session::set('config',$config);
126   }
130 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
131 ?>