Code

All Lists are now scrollable.
[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       /* Don't touch base object */
22       if ($name != 'user'){
23         $obj->parent= &$this;
24         $obj->uid= $baseobject->uid;
25         $obj->sn= $baseobject->uid;
26         $obj->givenName= $baseobject->uid;
27         $this->by_object[$name]= $obj;
28       }
30       /* Update parent in base object */
31       $this->by_object['user']->parent= &$this;
32     }
34     /* Move facsimile / phone number if nessecary */
35     if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){
37       /* Move number to fax plugin */
38       $this->by_object['gofaxAccount']->facsimileTelephoneNumber=
39         $this->by_object['user']->facsimileTelephoneNumber;
41       /* Move phone number if plugin exists */
42       if (isset($this->by_object['phoneAccount']) && 
43           !$this->by_object['phoneAccount']->is_account){
44         $this->by_object['phoneAccount']->phoneNumbers= array();
45         if ($this->by_object['user']->telephoneNumber != ""){
46           $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber;
47         }
48       }
49     }
50     if ($this->last == "gofaxAccount"){
52       /* Move number from fax plugin */
53       $this->by_object['user']->facsimileTelephoneNumber=
54         $this->by_object['gofaxAccount']->facsimileTelephoneNumber;
55     }
56     if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){
57       /* Move number from fax plugin */
58       reset($this->by_object['phoneAccount']->phoneNumbers);
59       $number= key($this->by_object['phoneAccount']->phoneNumbers);
60       $this->by_object['user']->telephoneNumber= $number;
61     }
62   }
64   function save()
65   {
66     /* Check for new 'dn', in order to propagate the
67        'dn' to all plugins */
68     $baseobject= $this->by_object['user'];
69     if ($this->dn == 'new'){
70       $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
71       $this->by_object['user']= $baseobject;
72       if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
73         $this->dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
74       } else {
75         $this->dn= 'cn='.$baseobject->cn.','.get_people_ou().$baseobject->base;
76       }
77     } // != 'new' 
78     else 
79     {
80       /* Extract cn and compare with actual cn present in 'dn' */
81       if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
82         $new_dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
83       } else {
84         $new_dn= "cn=".$baseobject->givenName." ".$baseobject->sn.','.
85           get_people_ou().$baseobject->base;
86       }
87       
88       /* Hickert: 31.08.2005 
89        * fixed error = Trying to overwrite cn=***  which already exists.
90        * If you changed one of the "Name" / "Givenname" attributes to lower or upper case, like "test" to "Test", (in DNMODE=cn)
91        *  the old_dn and new dn were different. cn=test ... cn=Test ...
92        * The following code decided to move the entry from old_dn to new_dn. (Because they differ)
93        * But the ldap attribute cn is not case sensitive and the function plugin::move() quits with 
94        *  an error, because source and destination dn are both the same (for ldap, but not for php).
95        * This fix allow you to change the givenname or name attributes.
96        */
97       if(strtolower($this->dn)==strtolower($new_dn)){
98         $this->dn=$new_dn;
99       }
100   
101       if ($this->dn != $new_dn){
103         /* Write entry on new 'dn' */
104         $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
105         $baseobject->move($this->dn, $new_dn);
106         $this->by_object['user']= $baseobject;
108         /* Did we change ourselves? Update ui object. */
109         change_ui_dn($this->dn, $new_dn);
111         /* Happen to use the new one */
112         $this->dn= $new_dn;
113       }
114     }
115     return tabs::save();
116   }
119   function set_template_mode()
120   {
121     foreach ($this->by_object as $key => $obj){
122       $this->by_object[$key]->is_template= TRUE;
123     }
124   }
128 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
129 ?>