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){
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);
52 /* Initialize current */
53 if ($this->current == ""){
54 $this->current= $tab['CLASS'];
55 }
56 }
58 /* Add references/acls/snapshots */
59 $this->addSpecialTabs();
60 }
63 /*! \brief Reinitializes the tab classes with fresh ldap values.
64 This maybe usefull if for example the apply button was pressed.
65 */
66 function re_init()
67 {
68 $baseobject= NULL;
69 foreach($this->by_object as $name => $object){
70 $class = get_class($object);
71 if(in_array($class,array("reference","acl"))) continue;
72 if ($baseobject === NULL){
73 $baseobject= new $class($this->config, $this->dn,NULL,$this);
74 $baseobject->enable_CSN_check();
75 $this->by_object[$name]= $baseobject;
76 } else {
77 $this->by_object[$name]= new $class($this->config, $this->dn, $baseobject,$this);
78 }
79 $this->by_object[$name]->parent= &$this;
80 $this->by_object[$name]->set_acl_category($this->acl_category);
81 }
82 }
85 function save_object($save_current= FALSE)
86 {
87 tabs::save_object($save_current);
89 $baseobject = $this->by_object['servgeneric'];
90 $baseobject->netConfigDNS->cn= $baseobject->cn;
91 }
94 function save($ignore_account= FALSE)
95 {
96 /* Check for new 'dn', in order to propagate the
97 'dn' to all plugins */
98 $baseobject= $this->by_object['servgeneric'];
99 $this->dn= "cn=$baseobject->cn,".get_ou('serverRDN').$baseobject->base;
101 /* cn is not case sensitive for ldap, but for php it is!! */
102 if($baseobject->orig_dn != "new"){
103 if($this->config->get_cfg_value("accountPrimaryAttribute") == "cn"){
104 if (strtolower($baseobject->orig_dn) != (strtolower($this->dn))){
105 $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
106 }
107 }else{
108 if ($baseobject->orig_dn != $this->dn){
109 $baseobject->recursive_move($baseobject->orig_dn, $this->dn);
110 }
111 }
112 }
114 $baseobject->dn= $this->dn;
116 foreach ($this->by_object as $key => $obj){
117 $this->by_object[$key]->dn= $this->dn;
118 $this->by_object[$key]->cn= $baseobject->cn;
119 }
121 tabs::save(FALSE);
123 /* Reload server settings after saving */
124 $config = session::get('config');
125 $config->load_servers();
126 session::set('config',$config);
127 }
129 }
131 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
132 ?>