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 /* Don't touch base object */
22 if ($name != 'user'){
23 $obj->parent= &$this;
24 $obj->uid= $baseobject->uid;
25 $obj->sn= $baseobject->uid;
26 $obj->givenName= $baseobject->uid;
27 $this->by_object[$name]= $obj;
28 }
30 /* Update parent in base object */
31 $this->by_object['user']->parent= &$this;
32 }
34 /* Move facsimile / phone number if nessecary */
35 if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){
37 /* Move number to fax plugin */
38 $this->by_object['gofaxAccount']->facsimileTelephoneNumber=
39 $this->by_object['user']->facsimileTelephoneNumber;
41 /* Move phone number if plugin exists */
42 if (isset($this->by_object['phoneAccount']) &&
43 !$this->by_object['phoneAccount']->is_account){
44 $this->by_object['phoneAccount']->phoneNumbers= array();
45 if ($this->by_object['user']->telephoneNumber != ""){
46 $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber;
47 }
48 }
49 }
50 if ($this->last == "gofaxAccount"){
52 /* Move number from fax plugin */
53 $this->by_object['user']->facsimileTelephoneNumber=
54 $this->by_object['gofaxAccount']->facsimileTelephoneNumber;
55 }
56 if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){
57 /* Move number from fax plugin */
58 reset($this->by_object['phoneAccount']->phoneNumbers);
59 $number= key($this->by_object['phoneAccount']->phoneNumbers);
60 $this->by_object['user']->telephoneNumber= $number;
61 }
62 }
64 function save()
65 {
66 /* Check for new 'dn', in order to propagate the
67 'dn' to all plugins */
68 $baseobject= $this->by_object['user'];
69 if ($this->dn == 'new'){
70 $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
71 $this->by_object['user']= $baseobject;
72 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
73 $this->dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
74 } else {
75 $this->dn= 'cn='.$baseobject->cn.','.get_people_ou().$baseobject->base;
76 }
77 } // != 'new'
78 else
79 {
80 /* Extract cn and compare with actual cn present in 'dn' */
81 if (isset($this->config->current['DNMODE']) && $this->config->current['DNMODE'] == "uid"){
82 $new_dn= 'uid='.$baseobject->uid.','.get_people_ou().$baseobject->base;
83 } else {
84 $new_dn= "cn=".$baseobject->givenName." ".$baseobject->sn.','.
85 get_people_ou().$baseobject->base;
86 }
88 if ($this->dn != $new_dn){
90 /* Write entry on new 'dn' */
91 $baseobject->cn= $baseobject->givenName." ".$baseobject->sn;
92 $baseobject->move($this->dn, $new_dn);
93 $this->by_object['user']= $baseobject;
95 /* Did we change ourselves? Update ui object. */
96 change_ui_dn($this->dn, $new_dn);
98 /* Happen to use the new one */
99 $this->dn= $new_dn;
100 }
101 }
102 return tabs::save();
103 }
106 function set_template_mode()
107 {
108 foreach ($this->by_object as $key => $obj){
109 $this->by_object[$key]->is_template= TRUE;
110 }
111 }
113 }
115 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
116 ?>