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 }
16 function save_object($save_current= FALSE)
17 {
18 tabs::save_object($save_current);
20 /* Update reference, transfer variables */
21 $baseobject= $this->by_object['user'];
22 foreach ($this->by_object as $name => $obj){
24 /* Adding uid to sub plugins of connectivity */
25 if($name == "connectivity"){
26 foreach ($obj->plugin_name as $plg_name){
27 if(isset($obj->plugin[$plg_name]->uid)){
28 $obj->plugin[$plg_name]->uid = $baseobject->uid;
29 }
30 }
31 }
33 /* Don't touch base object */
34 if ($name != 'user'){
35 $obj->parent= &$this;
36 $obj->uid= $baseobject->uid;
37 $obj->sn= $baseobject->uid;
38 $obj->givenName= $baseobject->uid;
39 }
41 /* Copy mail if needed */
42 if ($name == "gofaxAccount"){
43 if (isset($this->by_object['mailAccount']) && $this->by_object['mailAccount']->is_account){
44 $obj->mail= $this->by_object['mailAccount']->mail;
45 }
46 }
48 $this->by_object[$name]= $obj;
50 /* Update parent in base object */
51 $this->by_object['user']->parent= &$this;
52 }
54 /* Move facsimile / phone number if nessecary */
55 if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){
57 /* Move number to fax plugin */
58 $this->by_object['gofaxAccount']->facsimileTelephoneNumber=
59 $this->by_object['user']->facsimileTelephoneNumber;
61 /* Move phone number if plugin exists */
62 if (isset($this->by_object['phoneAccount']) &&
63 !$this->by_object['phoneAccount']->is_account){
64 $this->by_object['phoneAccount']->phoneNumbers= array();
65 if ($this->by_object['user']->telephoneNumber != ""){
66 $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber;
67 }
68 }
69 }
70 if ($this->last == "gofaxAccount"){
72 /* Move number from fax plugin */
73 $this->by_object['user']->facsimileTelephoneNumber=
74 $this->by_object['gofaxAccount']->facsimileTelephoneNumber;
75 }
76 if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){
77 /* Move number from fax plugin */
78 reset($this->by_object['phoneAccount']->phoneNumbers);
79 $number= key($this->by_object['phoneAccount']->phoneNumbers);
80 $this->by_object['user']->telephoneNumber= $number;
81 }
83 /* Possibly change acl base */
84 $this->set_acl_base();
85 }
87 function save()
88 {
89 /* Check for new 'dn', in order to propagate the
90 'dn' to all plugins */
91 $baseobject= $this->by_object['user'];
92 if ($this->dn == 'new'){
93 $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
94 $this->by_object['user']= $baseobject;
95 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
96 $this->dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
97 } else {
98 $this->dn= 'cn='.$baseobject->cn.','.get_people_ou().$baseobject->base;
99 }
100 } // != 'new'
101 else
102 {
103 /* Extract cn and compare with actual cn present in 'dn' */
104 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
105 $new_dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
106 } else {
107 $new_dn= "cn=".$baseobject->givenName." ".$baseobject->sn.','.
108 get_people_ou().$baseobject->base;
109 }
111 /* Hickert: 31.08.2005
112 * fixed error = Trying to overwrite cn=*** which already exists.
113 * If you changed one of the "Name" / "Givenname" attributes to lower or upper case, like "test" to "Test", (in DNMODE=cn)
114 * the old_dn and new dn were different. cn=test ... cn=Test ...
115 * The following code decided to move the entry from old_dn to new_dn. (Because they differ)
116 * But the ldap attribute cn is not case sensitive and the function plugin::move() quits with
117 * an error, because source and destination dn are both the same (for ldap, but not for php).
118 * This fix allow you to change the givenname or name attributes.
119 */
120 if(strtolower($this->dn)==strtolower($new_dn)){
121 $this->dn=$new_dn;
122 }
124 if ($this->dn != $new_dn){
126 /* Write entry on new 'dn' */
127 $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
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);
134 /* Happen to use the new one */
135 $this->dn= $new_dn;
136 }
137 }
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 ?>