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,$hide_refs = FALSE, $hide_acls = FALSE)
28 {
29 /* Save dn */
30 $this->dn= $dn;
31 $this->config= $config;
33 $this->hide_acls = $hide_acls;
34 $this->hide_refs = $hide_refs;
36 $baseobject= NULL;
38 foreach ($data as $tab){
40 if(!class_available($tab['CLASS'])){
41 continue;
42 }
44 $this->by_name[$tab['CLASS']]= $tab['NAME'];
45 if ($baseobject === NULL){
46 $baseobject= new $tab['CLASS']($this->config, $this->dn,NULL,$this);
47 $this->by_object[$tab['CLASS']]= $baseobject;
48 } else {
49 $this->by_object[$tab['CLASS']]= new $tab['CLASS']($this->config, $this->dn, $baseobject,$this);
50 }
52 $this->by_object[$tab['CLASS']]->parent= &$this;
53 $this->by_object[$tab['CLASS']]->set_acl_category($category);
54 $this->read_only |= $this->by_object[$tab['CLASS']]->read_only;
56 /* Initialize current */
57 if ($this->current == ""){
58 $this->current= $tab['CLASS'];
59 }
60 }
62 /* Add references/acls/snapshots */
63 $this->addSpecialTabs();
64 }
67 /*! \brief Reinitializes the tab classes with fresh ldap values.
68 This maybe usefull if for example the apply button was pressed.
69 */
70 function re_init()
71 {
72 $baseobject= NULL;
73 foreach($this->by_object as $name => $object){
74 $class = get_class($object);
75 if(in_array($class,array("reference","acl"))) continue;
76 if ($baseobject === NULL){
77 $baseobject= new $class($this->config, $this->dn,NULL,$this);
78 $baseobject->enable_CSN_check();
79 $this->by_object[$name]= $baseobject;
80 } else {
81 $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
82 }
83 $this->by_object[$name]->parent= &$this;
84 $this->by_object[$name]->set_acl_category($this->acl_category);
85 }
86 }
89 function save_object($save_current= FALSE)
90 {
91 tabs::save_object($save_current);
93 $baseobject = $this->by_object['servgeneric'];
94 $baseobject->netConfigDNS->cn= $baseobject->cn;
95 }
98 function save($ignore_account= FALSE)
99 {
100 /* Check for new 'dn', in order to propagate the
101 'dn' to all plugins */
102 $baseobject= $this->by_object['servgeneric'];
103 $this->dn= "cn=$baseobject->cn,".get_ou('serverRDN').$baseobject->base;
105 /* cn is not case sensitive for ldap, but for php it is!! */
106 if($baseobject->orig_dn != "new"){
107 if($this->config->get_cfg_value("accountPrimaryAttribute") == "cn"){
108 if (strtolower($baseobject->orig_dn) != (strtolower($this->dn))){
109 $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
110 }
111 }else{
112 if ($baseobject->orig_dn != $this->dn){
113 $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
114 }
115 }
116 }
118 $baseobject->dn= $this->dn;
120 foreach ($this->by_object as $key => $obj){
121 $this->by_object[$key]->dn= $this->dn;
122 $this->by_object[$key]->cn= $baseobject->cn;
123 }
125 tabs::save(FALSE);
127 /* Reload server settings after saving */
128 $config = session::get('config');
129 $config->load_servers();
130 session::set('config',$config);
131 }
133 }
135 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
136 ?>