c3d726f1e9a92dd596ec1488fa549c2d83b5fdcc
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;
12 /* Add references/acls/snapshots */
13 $this->addSpecialTabs();
14 $this->set_acl_base();
16 /* Set category for environment tab */
17 if (isset($this->by_object['environment'])){
18 $this->by_object['environment']->set_acl_category('users');
19 }
20 }
22 function save_object($save_current= FALSE)
23 {
24 tabs::save_object($save_current);
26 /* Update reference, transfer variables */
27 $baseobject= $this->by_object['user'];
28 foreach ($this->by_object as $name => $obj){
30 /* Don't touch base object */
31 if ($name != 'user'){
32 $obj->parent= &$this;
33 $obj->uid= $baseobject->uid;
34 $obj->sn= $baseobject->uid;
35 $obj->givenName= $baseobject->uid;
36 $this->by_object[$name]= $obj;
37 }
39 /* Copy mail if needed */
40 if ($name == "gofaxAccount"){
41 if (isset($this->by_object['mailAccount']) && $this->by_object['mailAccount']->is_account){
42 $obj->mail= $this->by_object['mailAccount']->mail;
43 }
44 }
46 /* Update parent in base object */
47 $this->by_object['user']->parent= &$this;
48 }
50 /* Move facsimile / phone number if nessecary */
51 if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){
53 /* Move number to fax plugin */
54 $this->by_object['gofaxAccount']->facsimileTelephoneNumber=
55 $this->by_object['user']->facsimileTelephoneNumber;
57 /* Move phone number if plugin exists */
58 if (isset($this->by_object['phoneAccount']) &&
59 !$this->by_object['phoneAccount']->is_account){
60 $this->by_object['phoneAccount']->phoneNumbers= array();
61 if ($this->by_object['user']->telephoneNumber != ""){
62 $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber;
63 }
64 }
65 }
66 if ($this->last == "gofaxAccount"){
68 /* Move number from fax plugin */
69 $this->by_object['user']->facsimileTelephoneNumber=
70 $this->by_object['gofaxAccount']->facsimileTelephoneNumber;
71 }
72 if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){
73 /* Move number from fax plugin */
74 reset($this->by_object['phoneAccount']->phoneNumbers);
75 $number= key($this->by_object['phoneAccount']->phoneNumbers);
76 $this->by_object['user']->telephoneNumber= $number;
77 }
79 /* Possibly change acl base */
80 $this->set_acl_base();
81 }
83 function save()
84 {
85 /* Check for new 'dn', in order to propagate the
86 'dn' to all plugins */
87 $baseobject= $this->by_object['user'];
88 if ($this->dn == 'new'){
89 $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
90 $this->by_object['user']= $baseobject;
91 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
92 $this->dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
93 } else {
94 $this->dn= 'cn='.$baseobject->cn.','.get_people_ou().$baseobject->base;
95 }
96 } // != 'new'
97 else
98 {
99 /* Extract cn and compare with actual cn present in 'dn' */
100 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
101 $new_dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
102 } else {
103 $new_dn= "cn=".$baseobject->givenName." ".$baseobject->sn.','.
104 get_people_ou().$baseobject->base;
105 }
107 /* Hickert: 31.08.2005
108 * fixed error = Trying to overwrite cn=*** which already exists.
109 * If you changed one of the "Name" / "Givenname" attributes to lower or upper case, like "test" to "Test", (in DNMODE=cn)
110 * the old_dn and new dn were different. cn=test ... cn=Test ...
111 * The following code decided to move the entry from old_dn to new_dn. (Because they differ)
112 * But the ldap attribute cn is not case sensitive and the function plugin::move() quits with
113 * an error, because source and destination dn are both the same (for ldap, but not for php).
114 * This fix allow you to change the givenname or name attributes.
115 */
116 if(strtolower($this->dn)==strtolower($new_dn)){
117 $this->dn=$new_dn;
118 }
120 if ($this->dn != $new_dn){
122 /* Write entry on new 'dn' */
123 $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
124 $baseobject->move($this->dn, $new_dn);
125 $this->by_object['user']= $baseobject;
127 /* Did we change ourselves? Update ui object. */
128 change_ui_dn($this->dn, $new_dn);
130 /* Happen to use the new one */
131 $this->dn= $new_dn;
132 }
133 }
134 return tabs::save();
135 }
138 function set_template_mode()
139 {
140 foreach ($this->by_object as $key => $obj){
141 $this->by_object[$key]->is_template= TRUE;
142 }
143 }
145 function saveCopyDialog()
146 {
147 tabs::saveCopyDialog();
148 $baseobject= $this->by_object['user'];
149 $uid = $baseobject->uid;
150 foreach($this->by_object as $name => $obj){
151 $this->by_object[$name]->uid = $uid;
152 }
153 }
155 }
157 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
158 ?>