Code

fixed printGeneric acls
[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, 'users');
10     $this->base= $this->by_object['user']->base;
12     /* Add references/acls/snapshots */
13     $this->addSpecialTabs();
14     $this->set_acl_base();
15   }
17   function save_object($save_current= FALSE)
18   {
19     tabs::save_object($save_current);
21     /* Update reference, transfer variables */
22     $baseobject= $this->by_object['user'];
23     foreach ($this->by_object as $name => $obj){
25       /* Adding uid to sub plugins of connectivity */
26       if($name == "connectivity"){
27         foreach ($obj->plugin_name as $plg_name){
28           if(isset($obj->plugin[$plg_name]->uid)){
29             $obj->plugin[$plg_name]->uid = $baseobject->uid;
30           }
31         }
32       }
34       /* Don't touch base object */
35       if ($name != 'user'){
36         $obj->parent= &$this;
37         $obj->uid= $baseobject->uid;
38         $obj->sn= $baseobject->uid;
39         $obj->givenName= $baseobject->uid;
40       }
42       /* Copy mail if needed */
43       if ($name == "gofaxAccount"){
44         if (isset($this->by_object['mailAccount']) && $this->by_object['mailAccount']->is_account){
45           $obj->mail= $this->by_object['mailAccount']->mail;
46         }
47       }
49       $this->by_object[$name]= $obj;
51       /* Update parent in base object */
52       $this->by_object['user']->parent= &$this;
53     }
55     /* Move facsimile / phone number if nessecary */
56     if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){
58       /* Move number to fax plugin */
59       $this->by_object['gofaxAccount']->facsimileTelephoneNumber=
60         $this->by_object['user']->facsimileTelephoneNumber;
62       /* Move phone number if plugin exists */
63       if (isset($this->by_object['phoneAccount']) && 
64           !$this->by_object['phoneAccount']->is_account){
65         $this->by_object['phoneAccount']->phoneNumbers= array();
66         if ($this->by_object['user']->telephoneNumber != ""){
67           $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber;
68         }
69       }
70     }
71     if ($this->last == "gofaxAccount"){
73       /* Move number from fax plugin */
74       $this->by_object['user']->facsimileTelephoneNumber=
75         $this->by_object['gofaxAccount']->facsimileTelephoneNumber;
76     }
77     if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){
78       /* Move number from fax plugin */
79       reset($this->by_object['phoneAccount']->phoneNumbers);
80       $number= key($this->by_object['phoneAccount']->phoneNumbers);
81       $this->by_object['user']->telephoneNumber= $number;
82     }
84     /* Possibly change acl base */
85     $this->set_acl_base();
86   }
88   function save()
89   {
90     /* Check for new 'dn', in order to propagate the
91        'dn' to all plugins */
92     $baseobject= $this->by_object['user'];
93     if ($this->dn == 'new'){
94       $baseobject->cn= $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=".$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= $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 ?>