Code

Added Autoscroll for department rename
[gosa.git] / plugins / admin / users / tabs_user.inc
1 <?php
3 class usertabs extends tabs
4 {
5   var $base;
7   function usertabs($config, $data, $dn)
8   {
9     tabs::tabs($config, $data, $dn);
10     $this->base= $this->by_object['user']->base;
11   }
13   function save_object($save_current= FALSE)
14   {
15     tabs::save_object($save_current);
17     /* Update reference, transfer variables */
18     $baseobject= $this->by_object['user'];
19     foreach ($this->by_object as $name => $obj){
21       /* Adding uid to sub plugins of connectivity */
22       if($name == "connectivity"){
23         foreach ($obj->plugin_name as $plg_name){
24           if(isset($obj->plugin[$plg_name]->uid)){
25             $obj->plugin[$plg_name]->uid = $baseobject->uid;
26           }
27         }
28       }
30       /* Copy mail if needed */
31       if ($name == "gofaxAccount"){
32         if (isset($this->by_object['mailAccount']) && $this->by_object['mailAccount']->is_account){
33           $obj->mail= $this->by_object['mailAccount']->mail;
34         }
35       }
37       /* Don't touch base object */
38       if ($name != 'user'){
39         $obj->parent= &$this;
40         $obj->uid= $baseobject->uid;
41         $obj->sn= $baseobject->uid;
42         $obj->givenName= $baseobject->uid;
43       }
45       /* Store changes */
46       $this->by_object[$name]= $obj;
48       /* Update parent in base object */
49       $this->by_object['user']->parent= &$this;
50     }
52     /* Move facsimile / phone number if nessecary */
53     if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){
55       /* Move number to fax plugin */
56       $this->by_object['gofaxAccount']->facsimileTelephoneNumber=
57         $this->by_object['user']->facsimileTelephoneNumber;
59       /* Move phone number if plugin exists */
60       if (isset($this->by_object['phoneAccount']) && 
61           !$this->by_object['phoneAccount']->is_account){
62         $this->by_object['phoneAccount']->phoneNumbers= array();
63         if ($this->by_object['user']->telephoneNumber != ""){
64           $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber;
65         }
66       }
67     }
68     if ($this->last == "gofaxAccount"){
70       /* Move number from fax plugin */
71       $this->by_object['user']->facsimileTelephoneNumber=
72         $this->by_object['gofaxAccount']->facsimileTelephoneNumber;
73     }
74     if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){
75       /* Move number from fax plugin */
76       reset($this->by_object['phoneAccount']->phoneNumbers);
77       $number= key($this->by_object['phoneAccount']->phoneNumbers);
78       $this->by_object['user']->telephoneNumber= $number;
79     }
80   }
82   function save()
83   {
84     /* Check for new 'dn', in order to propagate the
85        'dn' to all plugins */
86     $baseobject= $this->by_object['user'];
87     if ($baseobject->personalTitle == ""){
88       $pt= "";
89     } else {
90       $pt= $baseobject->personalTitle." ";
91     }
93     if ($this->dn == 'new'){
94       $baseobject->cn= $pt.$baseobject->givenName." ".$baseobject->sn;
95       $this->by_object['user']= $baseobject;
96       if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
97         $this->dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
98       } else {
99         $this->dn= 'cn='.$baseobject->cn.','.get_people_ou().$baseobject->base;
100       }
101     } // != 'new' 
102     else 
103     {
104       /* Extract cn and compare with actual cn present in 'dn' */
105       if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
106         $new_dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
107       } else {
108         $new_dn= "cn=".$pt.$baseobject->givenName." ".$baseobject->sn.','.
109           get_people_ou().$baseobject->base;
110       }
111       
112       /* Hickert: 31.08.2005 
113        * fixed error = Trying to overwrite cn=***  which already exists.
114        * If you changed one of the "Name" / "Givenname" attributes to lower or upper case, like "test" to "Test", (in DNMODE=cn)
115        *  the old_dn and new dn were different. cn=test ... cn=Test ...
116        * The following code decided to move the entry from old_dn to new_dn. (Because they differ)
117        * But the ldap attribute cn is not case sensitive and the function plugin::move() quits with 
118        *  an error, because source and destination dn are both the same (for ldap, but not for php).
119        * This fix allow you to change the givenname or name attributes.
120        */
121       if(strtolower($this->dn)==strtolower($new_dn)){
122         $this->dn=$new_dn;
123       }
124   
125       if ($this->dn != $new_dn){
127         /* Write entry on new 'dn' */
128         $baseobject->cn= $pt.$baseobject->givenName." ".$baseobject->sn;
129         $baseobject->move($this->dn, $new_dn);
130         $this->by_object['user']= $baseobject;
132         /* Did we change ourselves? Update ui object. */
133         change_ui_dn($this->dn, $new_dn);
135         /* Happen to use the new one */
136         $this->dn= $new_dn;
137       }
138     }
139     return tabs::save();
140   }
143   function set_template_mode()
144   {
145     foreach ($this->by_object as $key => $obj){
146       $this->by_object[$key]->is_template= TRUE;
147     }
148   }
149   
150   function saveCopyDialog()
151   {
152     tabs::saveCopyDialog();
153     $baseobject= $this->by_object['user'];
154     $uid = $baseobject->uid;
155     foreach($this->by_object as  $name => $obj){
156       $this->by_object[$name]->uid = $uid;
157     }
158   }
162 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
163 ?>