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 /* Remove checkboxes in single edit mode */
90 if ($this->parent !== NULL){
91 foreach ($this->plugin_name as $name){
92 $this->plugin[$name]->parent= $this->parent;
93 }
94 }
96 /* Execude objects */
97 $is_first= true;
99 foreach ($this->plugin_name as $name){
100 $this->plugin[$name]->read_only = &$this->read_only;
101 if (!$is_first){
102 $display.= '<hr>';
103 } else {
104 $is_first= false;
105 }
106 $display.= $this->plugin[$name]->execute();
107 }
109 /* Mark me as connectivity tab */
110 $display.= "<input type='hidden' name='connectivityTab'>";
111 return($display);
112 }
115 /* Save data to object */
116 function save_object()
117 {
118 if (isset($_POST['connectivityTab'])){
119 foreach ($this->plugin_name as $name){
120 $this->plugin[$name]->save_object();
121 }
122 }
123 }
125 function check()
126 {
127 $message= plugin::check();
129 foreach ($this->plugin_name as $name){
130 if($this->plugin[$name]->is_account){
131 $tmp= $this->plugin[$name]->check();
132 $message= array_merge($message, $tmp);
133 }
134 }
136 return ($message);
137 }
139 function set_acl_category($cat)
140 {
141 plugin::set_acl_category($cat);
142 foreach ($this->plugin_name as $name){
143 $this->plugin[$name]->set_acl_category( $cat);
144 }
145 }
147 function set_acl_base($base)
148 {
149 plugin::set_acl_base($base);
150 foreach ($this->plugin_name as $name){
151 $this->plugin[$name]->set_acl_base( $base);
152 }
153 }
155 /* Save to LDAP */
156 function save()
157 {
158 /* Save objects */
159 foreach ($this->plugin_name as $name){
160 $this->plugin[$name]->dn= $this->dn;
162 if ($this->plugin[$name]->is_account){
163 $this->plugin[$name]->save();
164 } else {
165 $this->plugin[$name]->remove_from_parent();
166 }
167 }
168 }
170 function remove_from_parent()
171 {
172 /* Remove objects */
173 foreach ($this->plugin_name as $name){
174 $this->plugin[$name]->dn= $this->dn;
175 $this->plugin[$name]->remove_from_parent();
176 }
177 }
179 function adapt_from_template($dn, $skip= array())
180 {
181 /* Adapt objects */
182 foreach ($this->plugin_name as $name){
183 $this->plugin[$name]->dn= $this->dn;
184 $this->plugin[$name]->adapt_from_template($dn, $skip);
185 }
186 }
188 /* Prepare the connectivity obj
189 */
190 function PrepareForCopyPaste($obj)
191 {
192 $tmp = $this->plugin;
193 plugin::PrepareForCopyPaste($obj);
194 $this->plugin = $tmp;
195 foreach( $this->plugin as $key => $plug){
196 $this->plugin[$key]->PrepareForCopyPaste($obj);
197 }
198 }
201 function enable_multiple_support()
202 {
203 plugin::enable_multiple_support();
205 foreach($this->plugin_name as $key => $name){
206 if($this->plugin[$name]->multiple_support){
207 $this->plugin[$name]->enable_multiple_support();
208 }else{
209 unset($this->plugin_name[$key]);
210 unset($this->plugin[$name]);
211 }
212 }
213 }
216 function multiple_execute()
217 {
218 return($this->execute());
219 }
221 /* Save data to object */
222 function multiple_save_object()
223 {
224 if (isset($_POST['connectivityTab'])){
225 foreach ($this->plugin_name as $name){
226 $this->plugin[$name]->multiple_save_object();
227 }
228 }
229 }
231 function multiple_check()
232 {
233 $message = plugin::multiple_check();
234 foreach ($this->plugin_name as $name){
235 $message = array_merge($message,$this->plugin[$name]->multiple_check());
236 }
237 return($message);
238 }
240 function get_multi_init_values()
241 {
242 $ret = array();
243 foreach($this->plugin as $name => $plugin){
244 $ret = array_merge($ret,$plugin->get_multi_init_values());
245 }
246 return($ret);
247 }
249 function init_multiple_support($attrs,$attr)
250 {
251 foreach($this->plugin as $name => $plugin){
252 $this->plugin[$name]->init_multiple_support($attrs,$attr);
253 }
254 }
256 function get_multi_edit_values()
257 {
258 $ret['plugin'] = &$this->plugin;
259 return($ret);
260 }
262 function set_multi_edit_values($values)
263 {
264 foreach($values['plugin'] as $name => $plugin){
265 $this->plugin[$name]->set_multi_edit_values($plugin->get_multi_edit_values());
266 }
267 }
270 /* Return plugin informations for acl handling */
271 static function plInfo()
272 {
273 return (array(
274 "plShortName" => _("Connectivity"),
275 "plDepends" => array("user"),
276 "plPriority" => 20, // Position in tabs
277 "plSection" => array("personal" => _("My account")),
278 "plCategory" => array("users"),
279 "plOptions" => array(),
281 "plDescription" => _("Connectivity add-on"),
282 "plSelfModify" => TRUE,
284 "plProvidedAcls" => array()
285 ));
286 }
289 }
291 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
292 ?>