Code

Updated opsi activation .
[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 {
25   public $was_activated = FALSE;
27   function servtabs($config, $data, $dn,$category)
28   {
29     /* Save dn */
30     $this->dn= $dn;
31     $this->config= $config;
33     $baseobject= NULL;
35     foreach ($data as $tab){
36   
37       if(!class_available($tab['CLASS'])){
38         continue;
39       }
41       $this->by_name[$tab['CLASS']]= $tab['NAME'];
42       if ($baseobject === NULL){
43         $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
44         $this->by_object[$tab['CLASS']]= $baseobject;
45       } else {
46         $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
47       }
49       $this->by_object[$tab['CLASS']]->parent= &$this;
50       $this->by_object[$tab['CLASS']]->set_acl_category($category);
51       $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
53       /* Initialize current */
54       if ($this->current == ""){
55         $this->current= $tab['CLASS'];
56       }
57     }
59     /* Add references/acls/snapshots */
60     $this->addSpecialTabs();
61   }
64   /*! \brief Reinitializes the tab classes with fresh ldap values.
65     This maybe usefull if for example the apply button was pressed.
66    */
67   function re_init()
68   {
69     $baseobject= NULL;
70     foreach($this->by_object as $name => $object){
71       $class = get_class($object);
72       if(in_array($class,array("reference","acl"))) continue;
73       if ($baseobject === NULL){
74         $baseobject= new $class($this->config, $this->dn,NULL,$this);
75         $baseobject->enable_CSN_check();
76         $this->by_object[$name]= $baseobject;
77       } else {
78         $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
79       }
80       $this->by_object[$name]->parent= &$this;
81       $this->by_object[$name]->set_acl_category($this->acl_category);
82     }
83   }
86   function save_object($save_current= FALSE)
87   {
88     tabs::save_object($save_current);
90     $baseobject = $this->by_object['servgeneric'];
91     $baseobject->netConfigDNS->cn= $baseobject->cn;
92   }
95   function save($ignore_account= FALSE)
96   {
97     /* Check for new 'dn', in order to propagate the
98        'dn' to all plugins */
99     $baseobject= $this->by_object['servgeneric'];
100     $this->dn= "cn=$baseobject->cn,".get_ou('serverRDN').$baseobject->base;
102     /* cn is not case sensitive for ldap, but for php it is!! */
103     if($baseobject->orig_dn != "new"){
104       if($this->config->get_cfg_value("accountPrimaryAttribute") == "cn"){
105         if (strtolower($baseobject->orig_dn) != (strtolower($this->dn))){
106           $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
107         }
108       }else{
109         if ($baseobject->orig_dn != $this->dn){
110           $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
111         }
112       }
113     }
115     $baseobject->dn= $this->dn;
117     foreach ($this->by_object as $key => $obj){
118       $this->by_object[$key]->dn= $this->dn;
119       $this->by_object[$key]->cn= $baseobject->cn;
120     }
122     tabs::save(FALSE);
124     /* Reload server settings after saving */
125     $config = session::get('config');
126     $config->load_servers();
127     session::set('config',$config);
128   }
132 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
133 ?>