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 (!plugin_available($plug['CLASS'])) {
41 continue;
42 }
43 $name= $plug['CLASS'];
44 $this->plugin_name[]= $name;
45 $this->plugin[$name]= new $name($config, $dn,$parent);
47 /* Acl base && category configuration,
48 these settings will be overloaded in main.inc,
49 if we are editing ourself */
50 $this->plugin[$name]-> set_acl_category("users");
51 $this->plugin[$name]-> set_acl_base($this->dn);
52 }
53 }
55 function execute()
56 {
57 /* Call parent execute */
58 plugin::execute();
60 $display= "";
62 /* Prepare templating */
63 $smarty= get_smarty();
65 /* Do we represent a valid account? */
66 if ($this->parent === NULL){
67 $enabled= true;
68 foreach ($this->plugin_name as $name){
69 if ($this->plugin[$name]->is_account){
70 $enabled= true;
71 break;
72 }
73 }
74 if (!$enabled){
75 $display= "<img alt=\"\" src=\"images/small-error.png\" align=\"middle\"> <b>".
76 msgPool::noValidExtension()."</b>";
77 $display.= back_to_main();
78 return ($display);
79 }
80 }
82 /* Remove checkboxes in single edit mode */
83 if ($this->parent !== NULL){
84 foreach ($this->plugin_name as $name){
85 $this->plugin[$name]->parent= $this->parent;
86 }
87 }
89 /* Execude objects */
90 $is_first= true;
92 $ReadOnly = (!isset($this->parent) || !$this->parent) && !session::is_set('edit');
94 foreach ($this->plugin_name as $name){
95 $this->plugin[$name]->ReadOnly = $ReadOnly;
96 if (!$is_first){
97 $display.= '<p class="seperator"> </p>';
98 } else {
99 $is_first= false;
100 }
101 $display.= $this->plugin[$name]->execute();
102 }
104 /* Mark me as connectivity tab */
105 $display.= "<input type='hidden' name='connectivityTab'>";
106 return($display);
107 }
110 /* Save data to object */
111 function save_object()
112 {
113 if (isset($_POST['connectivityTab'])){
114 foreach ($this->plugin_name as $name){
115 $this->plugin[$name]->save_object();
116 }
117 }
118 }
120 function check()
121 {
122 $message= plugin::check();
124 foreach ($this->plugin_name as $name){
125 if($this->plugin[$name]->is_account){
126 $tmp= $this->plugin[$name]->check();
127 $message= array_merge($message, $tmp);
128 }
129 }
131 return ($message);
132 }
134 function set_acl_category($cat)
135 {
136 plugin::set_acl_category($cat);
137 foreach ($this->plugin_name as $name){
138 $this->plugin[$name]->set_acl_category( $cat);
139 }
140 }
142 function set_acl_base($base)
143 {
144 plugin::set_acl_base($base);
145 foreach ($this->plugin_name as $name){
146 $this->plugin[$name]->set_acl_base( $base);
147 }
148 }
150 /* Save to LDAP */
151 function save()
152 {
153 /* Save objects */
154 foreach ($this->plugin_name as $name){
155 $this->plugin[$name]->dn= $this->dn;
157 if ($this->plugin[$name]->is_account){
158 $this->plugin[$name]->save();
159 } else {
160 $this->plugin[$name]->remove_from_parent();
161 }
162 }
163 }
165 function remove_from_parent()
166 {
167 /* Remove objects */
168 foreach ($this->plugin_name as $name){
169 $this->plugin[$name]->dn= $this->dn;
170 $this->plugin[$name]->remove_from_parent();
171 }
172 }
174 function adapt_from_template($dn, $skip= array())
175 {
176 /* Adapt objects */
177 foreach ($this->plugin_name as $name){
178 $this->plugin[$name]->dn= $this->dn;
179 $this->plugin[$name]->adapt_from_template($dn, $skip);
180 }
181 }
183 /* Prepare the connectivity obj
184 */
185 function PrepareForCopyPaste($obj)
186 {
187 $tmp = $this->plugin;
188 plugin::PrepareForCopyPaste($obj);
189 $this->plugin = $tmp;
190 foreach( $this->plugin as $key => $plug){
191 $this->plugin[$key]->PrepareForCopyPaste($obj);
192 }
193 }
196 function enable_multiple_support()
197 {
198 plugin::enable_multiple_support();
200 foreach($this->plugin_name as $key => $name){
201 if($this->plugin[$name]->multiple_support){
202 $this->plugin[$name]->enable_multiple_support();
203 }else{
204 unset($this->plugin_name[$key]);
205 unset($this->plugin[$name]);
206 }
207 }
208 }
211 function multiple_execute()
212 {
213 return($this->execute());
214 }
216 /* Save data to object */
217 function multiple_save_object()
218 {
219 if (isset($_POST['connectivityTab'])){
220 foreach ($this->plugin_name as $name){
221 $this->plugin[$name]->multiple_save_object();
222 }
223 }
224 }
226 function multiple_check()
227 {
228 $message = plugin::multiple_check();
229 foreach ($this->plugin_name as $name){
230 $message = array_merge($message,$this->plugin[$name]->multiple_check());
231 }
232 return($message);
233 }
235 function get_multi_init_values()
236 {
237 $ret = array();
238 foreach($this->plugin as $name => $plugin){
239 $ret = array_merge($ret,$plugin->get_multi_init_values());
240 }
241 return($ret);
242 }
244 function init_multiple_support($attrs,$attr)
245 {
246 foreach($this->plugin as $name => $plugin){
247 $this->plugin[$name]->init_multiple_support($attrs,$attr);
248 }
249 }
251 function get_multi_edit_values()
252 {
253 $ret['plugin'] = &$this->plugin;
254 return($ret);
255 }
257 function set_multi_edit_values($values)
258 {
259 foreach($values['plugin'] as $name => $plugin){
260 $this->plugin[$name]->set_multi_edit_values($plugin->get_multi_edit_values());
261 }
262 }
265 /* Return plugin informations for acl handling */
266 static function plInfo()
267 {
268 return (array(
269 "plShortName" => _("Connectivity"),
270 "plDepends" => array("user"),
271 "plPriority" => 20, // Position in tabs
272 "plSection" => array("personal" => _("My account")),
273 "plCategory" => array("users"),
274 "plOptions" => array(),
276 "plDescription" => _("Connectivity addon"),
277 "plSelfModify" => TRUE,
279 "plProvidedAcls" => array()
280 ));
281 }
284 }
286 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
287 ?>