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 ($this->dn == 'new'){
88 $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
89 $this->by_object['user']= $baseobject;
90 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
91 $this->dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
92 } else {
93 $this->dn= 'cn='.$baseobject->cn.','.get_people_ou().$baseobject->base;
94 }
95 } // != 'new'
96 else
97 {
98 /* Extract cn and compare with actual cn present in 'dn' */
99 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
100 $new_dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
101 } else {
102 $new_dn= "cn=".$baseobject->givenName." ".$baseobject->sn.','.
103 get_people_ou().$baseobject->base;
104 }
106 /* Hickert: 31.08.2005
107 * fixed error = Trying to overwrite cn=*** which already exists.
108 * If you changed one of the "Name" / "Givenname" attributes to lower or upper case, like "test" to "Test", (in DNMODE=cn)
109 * the old_dn and new dn were different. cn=test ... cn=Test ...
110 * The following code decided to move the entry from old_dn to new_dn. (Because they differ)
111 * But the ldap attribute cn is not case sensitive and the function plugin::move() quits with
112 * an error, because source and destination dn are both the same (for ldap, but not for php).
113 * This fix allow you to change the givenname or name attributes.
114 */
115 if(strtolower($this->dn)==strtolower($new_dn)){
116 $this->dn=$new_dn;
117 }
119 if ($this->dn != $new_dn){
121 /* Write entry on new 'dn' */
122 $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
123 $baseobject->move($this->dn, $new_dn);
124 $this->by_object['user']= $baseobject;
126 /* Did we change ourselves? Update ui object. */
127 change_ui_dn($this->dn, $new_dn);
129 /* Happen to use the new one */
130 $this->dn= $new_dn;
131 }
132 }
133 return tabs::save();
134 }
137 function set_template_mode()
138 {
139 foreach ($this->by_object as $key => $obj){
140 $this->by_object[$key]->is_template= TRUE;
141 }
142 }
144 function saveCopyDialog()
145 {
146 tabs::saveCopyDialog();
147 $baseobject= $this->by_object['user'];
148 $uid = $baseobject->uid;
149 foreach($this->by_object as $name => $obj){
150 $this->by_object[$name]->uid = $uid;
151 }
152 }
154 }
156 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
157 ?>