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= "Manage connectivity user settings";
17 var $plIcon = "plugins/connectivity/images/plugin.png";
19 /* attribute list for save action */
20 var $attributes= array();
21 var $objectclasses= array();
23 var $ignore_account= TRUE;
24 var $plugin= array();
25 var $plugin_name= array();
26 var $CopyPasteVars = array("plugin","plugin_name");
28 var $multiple_support = TRUE;
30 function connectivity (&$config, $dn= NULL,$parent =NULL)
31 {
32 /* Preseed permissions */
33 $this->initTime = microtime(TRUE);
34 $this->dn= $dn;
35 $ui= get_userinfo();
37 $this->config = $config;
39 /* Load accounts */
40 foreach ($config->data['TABS']['CONNECTIVITY'] as $plug){
41 if (!class_available($plug['CLASS']) || !plugin_available($plug['CLASS'])) {
42 continue;
43 }
45 $name= $plug['CLASS'];
46 $this->plugin_name[]= $name;
47 $this->plugin[$name]= new $name($config, $dn,$parent);
49 /* Acl base && category configuration,
50 these settings will be overloaded in main.inc,
51 if we are editing ourself */
52 $this->plugin[$name]-> set_acl_category("users");
53 $this->plugin[$name]-> set_acl_base($this->dn);
54 }
56 // Create statistic table entry
57 stats::log('plugin', $class = get_class($this), $category = array($this->acl_category), $action = 'open',
58 $amount = 1, $duration = (microtime(TRUE) - $this->initTime));
60 }
62 function execute()
63 {
64 /* Call parent execute */
65 plugin::execute();
67 $display= "";
69 /* Prepare templating */
70 $smarty= get_smarty();
72 /* Do we represent a valid account? */
73 if ($this->parent === NULL){
74 $enabled= true;
75 foreach ($this->plugin_name as $name){
76 if ($this->plugin[$name]->is_account){
77 $enabled= true;
78 break;
79 }
80 }
81 if (!$enabled){
82 $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\"> <b>".
83 msgPool::noValidExtension()."</b>";
84 $display.= back_to_main();
85 return ($display);
86 }
87 }
89 if ($this->parent !== NULL){
90 foreach ($this->plugin_name as $name){
91 $this->plugin[$name]->parent= $this->parent;
92 }
93 }
95 /* Execude objects */
96 $is_first= true;
98 foreach ($this->plugin_name as $name){
99 $this->plugin[$name]->read_only = &$this->read_only;
100 if (!$is_first){
101 $display.= '<hr>';
102 } else {
103 $is_first= false;
104 }
105 $display.= $this->plugin[$name]->execute();
106 }
108 /* Mark me as connectivity tab */
109 $display.= "<input type='hidden' name='connectivityTab'>";
110 return($display);
111 }
114 /* Save data to object */
115 function save_object()
116 {
117 if (isset($_POST['connectivityTab'])){
118 foreach ($this->plugin_name as $name){
119 $this->plugin[$name]->save_object();
120 }
121 }
122 }
124 function check()
125 {
126 $message= plugin::check();
128 foreach ($this->plugin_name as $name){
129 if($this->plugin[$name]->is_account){
130 $tmp= $this->plugin[$name]->check();
131 $message= array_merge($message, $tmp);
132 }
133 }
135 return ($message);
136 }
138 function set_acl_category($cat)
139 {
140 plugin::set_acl_category($cat);
141 foreach ($this->plugin_name as $name){
142 $this->plugin[$name]->set_acl_category( $cat);
143 }
144 }
146 function set_acl_base($base)
147 {
148 plugin::set_acl_base($base);
149 foreach ($this->plugin_name as $name){
150 $this->plugin[$name]->set_acl_base( $base);
151 }
152 }
154 /* Save to LDAP */
155 function save()
156 {
157 // Append parent to sub-plugins.
158 if ($this->parent !== NULL){
159 foreach ($this->plugin_name as $name){
160 $this->plugin[$name]->parent= $this->parent;
161 }
162 }
164 /* Save objects */
165 foreach ($this->plugin_name as $name){
166 $this->plugin[$name]->dn= $this->dn;
168 if ($this->plugin[$name]->is_account){
169 $this->plugin[$name]->save();
170 } else {
171 $this->plugin[$name]->remove_from_parent();
172 }
173 }
174 }
176 function remove_from_parent()
177 {
178 // Append parent to sub-plugins.
179 if ($this->parent !== NULL){
180 foreach ($this->plugin_name as $name){
181 $this->plugin[$name]->parent= $this->parent;
182 }
183 }
185 /* Remove objects */
186 foreach ($this->plugin_name as $name){
187 $this->plugin[$name]->dn= $this->dn;
188 $this->plugin[$name]->remove_from_parent();
189 }
190 }
192 function adapt_from_template($dn, $skip= array())
193 {
194 /* Adapt objects */
195 foreach ($this->plugin_name as $name){
196 $this->plugin[$name]->dn= $this->dn;
197 $this->plugin[$name]->adapt_from_template($dn, $skip);
198 }
199 }
201 /* Prepare the connectivity obj
202 */
203 function PrepareForCopyPaste($obj)
204 {
205 $tmp = $this->plugin;
206 plugin::PrepareForCopyPaste($obj);
207 $this->plugin = $tmp;
208 foreach( $this->plugin as $key => $plug){
209 $this->plugin[$key]->PrepareForCopyPaste($obj);
210 }
211 }
214 function enable_multiple_support()
215 {
216 plugin::enable_multiple_support();
218 foreach($this->plugin_name as $key => $name){
219 if($this->plugin[$name]->multiple_support){
220 $this->plugin[$name]->enable_multiple_support();
221 }else{
222 unset($this->plugin_name[$key]);
223 unset($this->plugin[$name]);
224 }
225 }
226 }
229 function multiple_execute()
230 {
231 return($this->execute());
232 }
234 /* Save data to object */
235 function multiple_save_object()
236 {
237 if (isset($_POST['connectivityTab'])){
238 foreach ($this->plugin_name as $name){
239 $this->plugin[$name]->multiple_save_object();
240 }
241 }
242 }
244 function multiple_check()
245 {
246 $message = plugin::multiple_check();
247 foreach ($this->plugin_name as $name){
248 $message = array_merge($message,$this->plugin[$name]->multiple_check());
249 }
250 return($message);
251 }
253 function get_multi_init_values()
254 {
255 $ret = array();
256 foreach($this->plugin as $name => $plugin){
257 $ret = array_merge($ret,$plugin->get_multi_init_values());
258 }
259 return($ret);
260 }
262 function init_multiple_support($attrs,$attr)
263 {
264 foreach($this->plugin as $name => $plugin){
265 $this->plugin[$name]->init_multiple_support($attrs,$attr);
266 }
267 }
269 function get_multi_edit_values()
270 {
271 $ret['plugin'] = &$this->plugin;
272 return($ret);
273 }
275 function set_multi_edit_values($values)
276 {
277 foreach($values['plugin'] as $name => $plugin){
278 $this->plugin[$name]->set_multi_edit_values($plugin->get_multi_edit_values());
279 }
280 }
283 /* Return plugin informations for acl handling */
284 static function plInfo()
285 {
286 return (array(
287 "plShortName" => _("Connectivity"),
288 "plDepends" => array("user"),
289 "plPriority" => 20, // Position in tabs
290 "plSection" => array("personal" => _("My account")),
291 "plCategory" => array("users"),
292 "plOptions" => array(),
294 "plDescription" => _("Connectivity add-on"),
295 "plSelfModify" => TRUE,
297 "plProvidedAcls" => array()
298 ));
299 }
302 }
304 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
305 ?>