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 usertabs extends tabs
24 {
25 var $base;
27 function usertabs($config, $data, $dn)
28 {
29 tabs::tabs($config, $data, $dn, 'users');
30 $this->base= $this->by_object['user']->base;
32 /* Add references/acls/snapshots */
33 $this->addSpecialTabs();
35 }
37 function save_object($save_current= FALSE)
38 {
39 tabs::save_object($save_current);
41 /* Update reference, transfer variables */
42 $baseobject= $this->by_object['user'];
43 foreach ($this->by_object as $name => $obj){
45 /* Adding uid to sub plugins of connectivity */
46 if($name == "connectivity"){
47 foreach ($obj->plugin_name as $plg_name){
48 if(isset($obj->plugin[$plg_name]->uid)){
49 $obj->plugin[$plg_name]->uid = $baseobject->uid;
50 }
51 }
52 }
54 /* Don't touch base object */
55 if ($name != 'user'){
56 $obj->parent= &$this;
57 $obj->uid= $baseobject->uid;
58 $obj->sn= $baseobject->uid;
59 $obj->givenName= $baseobject->uid;
60 }
62 /* Copy mail if needed */
63 if ($name == "gofaxAccount"){
64 if (isset($this->by_object['mailAccount']) && $this->by_object['mailAccount']->is_account){
65 $obj->mail= $this->by_object['mailAccount']->mail;
66 }
67 }
69 $this->by_object[$name]= $obj;
71 /* Update parent in base object */
72 $this->by_object['user']->parent= &$this;
73 }
75 /* Move facsimile / phone number if nessecary */
76 if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){
78 /* Move number to fax plugin */
79 $this->by_object['gofaxAccount']->facsimileTelephoneNumber=
80 $this->by_object['user']->facsimileTelephoneNumber;
82 /* Move phone number if plugin exists */
83 if (isset($this->by_object['phoneAccount']) &&
84 !$this->by_object['phoneAccount']->is_account){
85 $this->by_object['phoneAccount']->phoneNumbers= array();
86 if ($this->by_object['user']->telephoneNumber != ""){
87 $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber;
88 }
89 }
90 }
92 /* Move number from fax plugin */
93 if ($this->last == "gofaxAccount"){
95 $this->by_object['user']->facsimileTelephoneNumber=
96 $this->by_object['gofaxAccount']->facsimileTelephoneNumber;
97 }
99 /* Move number from fax plugin */
100 if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){
101 reset($this->by_object['phoneAccount']->phoneNumbers);
102 $number= key($this->by_object['phoneAccount']->phoneNumbers);
104 /* Only the first phoneAccount number, if it is not empty */
105 if(!empty($number)){
106 $this->by_object['user']->telephoneNumber= $number;
107 }
108 }
110 /* Possibly change acl base */
111 $this->set_acl_base();
112 }
114 function save($ignore_account= FALSE)
115 {
116 /* Check for new 'dn', in order to propagate the
117 'dn' to all plugins */
118 $baseobject= $this->by_object['user'];
119 $baseobject->update_new_dn();
120 if ($this->dn != 'new'){
122 $new_dn= $baseobject->new_dn;
124 if ($this->dn != $new_dn){
126 /* Udpate acls */
127 $baseobject->update_acls($this->dn,$new_dn);
128 $baseobject->move($this->dn, $new_dn);
129 $this->by_object['user']= $baseobject;
131 /* Did we change ourselves? Update ui object. */
132 change_ui_dn($this->dn, $new_dn);
133 }
134 }
136 $this->dn= $baseobject->new_dn;
138 return tabs::save();
139 }
142 function set_template_mode()
143 {
144 foreach ($this->by_object as $key => $obj){
145 $this->by_object[$key]->is_template= TRUE;
146 }
147 }
149 function saveCopyDialog()
150 {
151 tabs::saveCopyDialog();
152 $baseobject= $this->by_object['user'];
153 $uid = $baseobject->uid;
154 foreach($this->by_object as $name => $obj){
155 $this->by_object[$name]->uid = $uid;
156 }
157 }
159 }
161 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
162 ?>