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