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 $name= $plug['CLASS'];
40 $this->plugin_name[]= $name;
41 $this->plugin[$name]= new $name($config, $dn,$parent);
43 /* Acl base && category configuration,
44 these settings will be overloaded in main.inc,
45 if we are editing ourself */
46 $this->plugin[$name]-> set_acl_category("users");
47 $this->plugin[$name]-> set_acl_base($this->dn);
48 }
49 }
51 function execute()
52 {
53 /* Call parent execute */
54 plugin::execute();
56 $display= "";
58 /* Prepare templating */
59 $smarty= get_smarty();
61 /* Do we represent a valid account? */
62 if ($this->parent === NULL){
63 $enabled= true;
64 foreach ($this->plugin_name as $name){
65 if ($this->plugin[$name]->is_account){
66 $enabled= true;
67 break;
68 }
69 }
70 if (!$enabled){
71 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
72 _("This account has no connectivity extensions.")."</b>";
73 $display.= back_to_main();
74 return ($display);
75 }
76 }
78 /* Remove checkboxes in single edit mode */
79 if ($this->parent !== NULL){
80 foreach ($this->plugin_name as $name){
81 $this->plugin[$name]->parent= $this->parent;
82 }
83 }
85 /* Execude objects */
86 $is_first= true;
88 $ReadOnly = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']);
90 foreach ($this->plugin_name as $name){
91 $this->plugin[$name]->ReadOnly = $ReadOnly;
92 if (!$is_first){
93 $display.= '<p class="seperator"> </p>';
94 } else {
95 $is_first= false;
96 }
97 $display.= $this->plugin[$name]->execute();
98 }
100 /* Mark me as connectivity tab */
101 $display.= "<input type='hidden' name='connectivityTab'>";
102 return($display);
103 }
106 /* Save data to object */
107 function save_object()
108 {
109 if (isset($_POST['connectivityTab'])){
110 foreach ($this->plugin_name as $name){
111 $this->plugin[$name]->save_object();
112 }
113 }
114 }
116 function check()
117 {
118 $message= plugin::check();
120 foreach ($this->plugin_name as $name){
121 $tmp= $this->plugin[$name]->check();
123 $message= array_merge($message, $tmp);
124 }
126 return ($message);
127 }
129 function set_acl_category($cat)
130 {
131 plugin::set_acl_category($cat);
132 foreach ($this->plugin_name as $name){
133 $this->plugin[$name]->set_acl_category( $cat);
134 }
135 }
137 function set_acl_base($base)
138 {
139 plugin::set_acl_base($base);
140 foreach ($this->plugin_name as $name){
141 $this->plugin[$name]->set_acl_base( $base);
142 }
143 }
145 /* Save to LDAP */
146 function save()
147 {
148 /* Save objects */
149 foreach ($this->plugin_name as $name){
150 $this->plugin[$name]->dn= $this->dn;
152 if ($this->plugin[$name]->is_account){
153 $this->plugin[$name]->save();
154 } else {
155 $this->plugin[$name]->remove_from_parent();
156 }
157 }
158 }
160 function remove_from_parent()
161 {
162 /* Remove objects */
163 foreach ($this->plugin_name as $name){
164 $this->plugin[$name]->dn= $this->dn;
165 $this->plugin[$name]->remove_from_parent();
166 }
167 }
169 function adapt_from_template($dn)
170 {
171 /* Adapt objects */
172 foreach ($this->plugin_name as $name){
173 $this->plugin[$name]->dn= $this->dn;
174 $this->plugin[$name]->adapt_from_template($dn);
175 }
176 }
178 /* Prepare the connectivity obj
179 */
180 function PrepareForCopyPaste($obj)
181 {
182 $tmp = $this->plugin;
183 plugin::PrepareForCopyPaste($obj);
184 $this->plugin = $tmp;
185 foreach( $this->plugin as $key => $plug){
186 $this->plugin[$key]->PrepareForCopyPaste($obj);
187 }
188 }
191 function enable_multiple_support()
192 {
193 plugin::enable_multiple_support();
195 foreach($this->plugin_name as $key => $name){
196 if($this->plugin[$name]->multiple_support){
197 $this->plugin[$name]->enable_multiple_support();
198 }else{
199 unset($this->plugin_name[$key]);
200 unset($this->plugin[$name]);
201 }
202 }
203 }
206 function multiple_execute()
207 {
208 return($this->execute());
209 }
211 /* Save data to object */
212 function multiple_save_object()
213 {
214 if (isset($_POST['connectivityTab'])){
215 foreach ($this->plugin_name as $name){
216 $this->plugin[$name]->multiple_save_object();
217 }
218 }
219 }
221 function multiple_check()
222 {
223 $message = plugin::multiple_check();
224 foreach ($this->plugin_name as $name){
225 $message = array_merge($message,$this->plugin[$name]->multiple_check());
226 }
227 return($message);
228 }
230 function get_multi_init_values()
231 {
232 $ret = array();
233 foreach($this->plugin as $name => $plugin){
234 $ret = array_merge($ret,$plugin->get_multi_init_values());
235 }
236 return($ret);
237 }
239 function init_multiple_support($attrs,$attr)
240 {
241 foreach($this->plugin as $name => $plugin){
242 $this->plugin[$name]->init_multiple_support($attrs,$attr);
243 }
244 }
246 function get_multi_edit_values()
247 {
248 $ret['plugin'] = &$this->plugin;
249 return($ret);
250 }
252 function set_multi_edit_values($values)
253 {
254 foreach($values['plugin'] as $name => $plugin){
255 $this->plugin[$name]->set_multi_edit_values($plugin->get_multi_edit_values());
256 }
257 }
258 }
260 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
261 ?>