c6565337e4dad2934cb112b70e14698a519f88de
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 }
72 /* Move number from fax plugin */
73 if ($this->last == "gofaxAccount"){
75 $this->by_object['user']->facsimileTelephoneNumber=
76 $this->by_object['gofaxAccount']->facsimileTelephoneNumber;
77 }
79 /* Move number from fax plugin */
80 if ($this->last == "phoneAccount" && $this->by_object['phoneAccount']->is_account){
81 reset($this->by_object['phoneAccount']->phoneNumbers);
82 $number= key($this->by_object['phoneAccount']->phoneNumbers);
84 /* Only the first phoneAccount number, if it is not empty */
85 if(!empty($number)){
86 $this->by_object['user']->telephoneNumber= $number;
87 }
88 }
90 /* Possibly change acl base */
91 $this->set_acl_base();
92 }
94 function save($ignore_account= FALSE)
95 {
96 /* Check for new 'dn', in order to propagate the
97 'dn' to all plugins */
98 $baseobject= $this->by_object['user'];
99 $baseobject->update_new_dn();
100 if ($this->dn != 'new'){
102 $new_dn= $baseobject->new_dn;
104 if (strtolower($this->dn) != strtolower($new_dn)){
106 /* Udpate acls */
107 $baseobject->update_acls($this->dn,$new_dn);
108 $baseobject->move($this->dn, $new_dn);
109 $this->by_object['user']= $baseobject;
111 /* Did we change ourselves? Update ui object. */
112 change_ui_dn($this->dn, $new_dn);
113 }
114 }
116 $this->dn= $baseobject->new_dn;
118 return tabs::save();
119 }
122 function set_template_mode()
123 {
124 foreach ($this->by_object as $key => $obj){
125 $this->by_object[$key]->is_template= TRUE;
126 }
127 }
129 function saveCopyDialog()
130 {
131 tabs::saveCopyDialog();
132 $baseobject= $this->by_object['user'];
133 $uid = $baseobject->uid;
134 foreach($this->by_object as $name => $obj){
135 $this->by_object[$name]->uid = $uid;
136 }
137 }
139 }
141 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
142 ?>