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