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();
15 }
17 function save_object($save_current= FALSE)
18 {
19 tabs::save_object($save_current);
21 /* Update reference, transfer variables */
22 $baseobject= $this->by_object['user'];
23 foreach ($this->by_object as $name => $obj){
25 /* Adding uid to sub plugins of connectivity */
26 if($name == "connectivity"){
27 foreach ($obj->plugin_name as $plg_name){
28 if(isset($obj->plugin[$plg_name]->uid)){
29 $obj->plugin[$plg_name]->uid = $baseobject->uid;
30 }
31 }
32 }
34 /* Don't touch base object */
35 if ($name != 'user'){
36 $obj->parent= &$this;
37 $obj->uid= $baseobject->uid;
38 $obj->sn= $baseobject->uid;
39 $obj->givenName= $baseobject->uid;
40 }
42 /* Copy mail if needed */
43 if ($name == "gofaxAccount"){
44 if (isset($this->by_object['mailAccount']) && $this->by_object['mailAccount']->is_account){
45 $obj->mail= $this->by_object['mailAccount']->mail;
46 }
47 }
49 $this->by_object[$name]= $obj;
51 /* Update parent in base object */
52 $this->by_object['user']->parent= &$this;
53 }
55 /* Move facsimile / phone number if nessecary */
56 if ($this->last == "user" && isset($this->by_object['gofaxAccount'])){
58 /* Move number to fax plugin */
59 $this->by_object['gofaxAccount']->facsimileTelephoneNumber=
60 $this->by_object['user']->facsimileTelephoneNumber;
62 /* Move phone number if plugin exists */
63 if (isset($this->by_object['phoneAccount']) &&
64 !$this->by_object['phoneAccount']->is_account){
65 $this->by_object['phoneAccount']->phoneNumbers= array();
66 if ($this->by_object['user']->telephoneNumber != ""){
67 $this->by_object['phoneAccount']->phoneNumbers[$this->by_object['user']->telephoneNumber]= $this->by_object['user']->telephoneNumber;
68 }
69 }
70 }
71 if ($this->last == "gofaxAccount"){
73 /* Move number from fax plugin */
74 $this->by_object['user']->facsimileTelephoneNumber=
75 $this->by_object['gofaxAccount']->facsimileTelephoneNumber;
76 }
77 if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){
78 /* Move number from fax plugin */
79 reset($this->by_object['phoneAccount']->phoneNumbers);
80 $number= key($this->by_object['phoneAccount']->phoneNumbers);
81 $this->by_object['user']->telephoneNumber= $number;
82 }
84 /* Possibly change acl base */
85 $this->set_acl_base();
86 }
88 function save()
89 {
90 /* Check for new 'dn', in order to propagate the
91 'dn' to all plugins */
92 $baseobject= $this->by_object['user'];
94 if ($this->dn != 'new'){
95 $new_dn= $baseobject->new_dn;
96 if (strtolower($this->dn) != strtolower($new_dn)){
98 /* Udpate acls */
99 $baseobject->update_acls($this->dn,$new_dn);
100 $baseobject->move($this->dn, $new_dn);
101 $this->by_object['user']= $baseobject;
103 /* Did we change ourselves? Update ui object. */
104 change_ui_dn($this->dn, $new_dn);
105 }
106 }
108 $this->dn= $baseobject->new_dn;
110 return tabs::save();
111 }
114 function set_template_mode()
115 {
116 foreach ($this->by_object as $key => $obj){
117 $this->by_object[$key]->is_template= TRUE;
118 }
119 }
121 function saveCopyDialog()
122 {
123 tabs::saveCopyDialog();
124 $baseobject= $this->by_object['user'];
125 $uid = $baseobject->uid;
126 foreach($this->by_object as $name => $obj){
127 $this->by_object[$name]->uid = $uid;
128 }
129 }
131 }
133 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
134 ?>