1 <?php
2 /*! \brief connectivity plugin
3 \author Cajus Pollmeier <pollmeier@gonicus.de>
4 \version 2.30
5 \date 29.03.2005
7 This class provides the functionality to read and write all attributes
8 relevant for connectivity settings from/to the LDAP. It does syntax checking
9 and displays the formulars required.
10 */
12 class connectivity extends plugin
13 {
14 /* Definitions */
15 var $plHeadline= "Connectivity";
16 var $plDescription= "This does something";
18 /* attribute list for save action */
19 var $attributes= array();
20 var $objectclasses= array();
22 var $ignore_account= TRUE;
23 var $plugin= array();
24 var $plugin_name= array();
25 var $CopyPasteVars = array("plugin","plugin_name");
27 var $multiple_support = TRUE;
29 function connectivity (&$config, $dn= NULL,$parent =NULL)
30 {
31 /* Preseed permissions */
32 $this->dn= $dn;
33 $ui= get_userinfo();
35 $this->config = $config;
37 /* Load accounts */
38 foreach ($config->data['TABS']['CONNECTIVITY'] as $plug){
39 if (!plugin_available($plug['CLASS'])) {
40 continue;
41 }
42 $name= $plug['CLASS'];
43 $this->plugin_name[]= $name;
44 $this->plugin[$name]= new $name($config, $dn,$parent);
46 /* Acl base && category configuration,
47 these settings will be overloaded in main.inc,
48 if we are editing ourself */
49 $this->plugin[$name]-> set_acl_category("users");
50 $this->plugin[$name]-> set_acl_base($this->dn);
51 }
52 }
54 function execute()
55 {
56 /* Call parent execute */
57 plugin::execute();
59 $display= "";
61 /* Prepare templating */
62 $smarty= get_smarty();
64 /* Do we represent a valid account? */
65 if ($this->parent === NULL){
66 $enabled= true;
67 foreach ($this->plugin_name as $name){
68 if ($this->plugin[$name]->is_account){
69 $enabled= true;
70 break;
71 }
72 }
73 if (!$enabled){
74 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
75 msgPool::noValidExtension()."</b>";
76 $display.= back_to_main();
77 return ($display);
78 }
79 }
81 /* Remove checkboxes in single edit mode */
82 if ($this->parent !== NULL){
83 foreach ($this->plugin_name as $name){
84 $this->plugin[$name]->parent= $this->parent;
85 }
86 }
88 /* Execude objects */
89 $is_first= true;
91 $ReadOnly = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
93 foreach ($this->plugin_name as $name){
94 $this->plugin[$name]->ReadOnly = $ReadOnly;
95 if (!$is_first){
96 $display.= '<p class="seperator"> </p>';
97 } else {
98 $is_first= false;
99 }
100 $display.= $this->plugin[$name]->execute();
101 }
103 /* Mark me as connectivity tab */
104 $display.= "<input type='hidden' name='connectivityTab'>";
105 return($display);
106 }
109 /* Save data to object */
110 function save_object()
111 {
112 if (isset($_POST['connectivityTab'])){
113 foreach ($this->plugin_name as $name){
114 $this->plugin[$name]->save_object();
115 }
116 }
117 }
119 function check()
120 {
121 $message= plugin::check();
123 foreach ($this->plugin_name as $name){
124 if($this->plugin[$name]->is_account){
125 $tmp= $this->plugin[$name]->check();
126 $message= array_merge($message, $tmp);
127 }
128 }
130 return ($message);
131 }
133 function set_acl_category($cat)
134 {
135 plugin::set_acl_category($cat);
136 foreach ($this->plugin_name as $name){
137 $this->plugin[$name]->set_acl_category( $cat);
138 }
139 }
141 function set_acl_base($base)
142 {
143 plugin::set_acl_base($base);
144 foreach ($this->plugin_name as $name){
145 $this->plugin[$name]->set_acl_base( $base);
146 }
147 }
149 /* Save to LDAP */
150 function save()
151 {
152 /* Save objects */
153 foreach ($this->plugin_name as $name){
154 $this->plugin[$name]->dn= $this->dn;
156 if ($this->plugin[$name]->is_account){
157 $this->plugin[$name]->save();
158 } else {
159 $this->plugin[$name]->remove_from_parent();
160 }
161 }
162 }
164 function remove_from_parent()
165 {
166 /* Remove objects */
167 foreach ($this->plugin_name as $name){
168 $this->plugin[$name]->dn= $this->dn;
169 $this->plugin[$name]->remove_from_parent();
170 }
171 }
173 function adapt_from_template($dn, $skip= array())
174 {
175 /* Adapt objects */
176 foreach ($this->plugin_name as $name){
177 $this->plugin[$name]->dn= $this->dn;
178 $this->plugin[$name]->adapt_from_template($dn, $skip);
179 }
180 }
182 /* Prepare the connectivity obj
183 */
184 function PrepareForCopyPaste($obj)
185 {
186 $tmp = $this->plugin;
187 plugin::PrepareForCopyPaste($obj);
188 $this->plugin = $tmp;
189 foreach( $this->plugin as $key => $plug){
190 $this->plugin[$key]->PrepareForCopyPaste($obj);
191 }
192 }
195 function enable_multiple_support()
196 {
197 plugin::enable_multiple_support();
199 foreach($this->plugin_name as $key => $name){
200 if($this->plugin[$name]->multiple_support){
201 $this->plugin[$name]->enable_multiple_support();
202 }else{
203 unset($this->plugin_name[$key]);
204 unset($this->plugin[$name]);
205 }
206 }
207 }
210 function multiple_execute()
211 {
212 return($this->execute());
213 }
215 /* Save data to object */
216 function multiple_save_object()
217 {
218 if (isset($_POST['connectivityTab'])){
219 foreach ($this->plugin_name as $name){
220 $this->plugin[$name]->multiple_save_object();
221 }
222 }
223 }
225 function multiple_check()
226 {
227 $message = plugin::multiple_check();
228 foreach ($this->plugin_name as $name){
229 $message = array_merge($message,$this->plugin[$name]->multiple_check());
230 }
231 return($message);
232 }
234 function get_multi_init_values()
235 {
236 $ret = array();
237 foreach($this->plugin as $name => $plugin){
238 $ret = array_merge($ret,$plugin->get_multi_init_values());
239 }
240 return($ret);
241 }
243 function init_multiple_support($attrs,$attr)
244 {
245 foreach($this->plugin as $name => $plugin){
246 $this->plugin[$name]->init_multiple_support($attrs,$attr);
247 }
248 }
250 function get_multi_edit_values()
251 {
252 $ret['plugin'] = &$this->plugin;
253 return($ret);
254 }
256 function set_multi_edit_values($values)
257 {
258 foreach($values['plugin'] as $name => $plugin){
259 $this->plugin[$name]->set_multi_edit_values($plugin->get_multi_edit_values());
260 }
261 }
262 }
264 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
265 ?>