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";
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->dn= $dn;
34 $ui= get_userinfo();
36 $this->config = $config;
38 /* Load accounts */
39 foreach ($config->data['TABS']['CONNECTIVITY'] as $plug){
40 if (!class_available($plug['CLASS']) || !plugin_available($plug['CLASS'])) {
41 continue;
42 }
44 $name= $plug['CLASS'];
45 $this->plugin_name[]= $name;
46 $this->plugin[$name]= new $name($config, $dn,$parent);
48 /* Acl base && category configuration,
49 these settings will be overloaded in main.inc,
50 if we are editing ourself */
51 $this->plugin[$name]-> set_acl_category("users");
52 $this->plugin[$name]-> set_acl_base($this->dn);
53 }
54 }
56 function execute()
57 {
58 /* Call parent execute */
59 plugin::execute();
61 $display= "";
63 /* Prepare templating */
64 $smarty= get_smarty();
66 /* Do we represent a valid account? */
67 if ($this->parent === NULL){
68 $enabled= true;
69 foreach ($this->plugin_name as $name){
70 if ($this->plugin[$name]->is_account){
71 $enabled= true;
72 break;
73 }
74 }
75 if (!$enabled){
76 $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\"> <b>".
77 msgPool::noValidExtension()."</b>";
78 $display.= back_to_main();
79 return ($display);
80 }
81 }
83 /* Remove checkboxes in single edit mode */
84 if ($this->parent !== NULL){
85 foreach ($this->plugin_name as $name){
86 $this->plugin[$name]->parent= $this->parent;
87 }
88 }
90 /* Execude objects */
91 $is_first= true;
93 foreach ($this->plugin_name as $name){
94 $this->plugin[$name]->read_only = &$this->read_only;
95 if (!$is_first){
96 $display.= '<hr>';
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 }
264 /* Return plugin informations for acl handling */
265 static function plInfo()
266 {
267 return (array(
268 "plShortName" => _("Connectivity"),
269 "plDepends" => array("user"),
270 "plPriority" => 20, // Position in tabs
271 "plSection" => array("personal" => _("My account")),
272 "plCategory" => array("users"),
273 "plOptions" => array(),
275 "plDescription" => _("Connectivity addon"),
276 "plSelfModify" => TRUE,
278 "plProvidedAcls" => array()
279 ));
280 }
283 }
285 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
286 ?>