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");
28 function connectivity ($config, $dn= NULL,$parent =NULL)
29 {
30 /* Preseed permissions */
31 $this->dn= $dn;
32 $ui= get_userinfo();
34 /* Load accounts */
35 foreach ($config->data['TABS']['CONNECTIVITY'] as $plug){
36 $name= $plug['CLASS'];
37 $this->plugin_name[]= $name;
38 $this->plugin[$name]= new $name($config, $dn,$parent);
40 /* Acl base && category configuration,
41 these settings will be overloaded in main.inc,
42 if we are editing ourself */
43 $this->plugin[$name]-> set_acl_category("users");
44 $this->plugin[$name]-> set_acl_base($this->dn);
45 }
46 }
48 function execute()
49 {
50 /* Call parent execute */
51 plugin::execute();
53 $display= "";
55 /* Prepare templating */
56 $smarty= get_smarty();
58 /* Do we represent a valid account? */
59 if ($this->parent == NULL){
60 $enabled= true;
61 foreach ($this->plugin_name as $name){
62 if ($this->plugin[$name]->is_account){
63 $enabled= true;
64 break;
65 }
66 }
67 if (!$enabled){
68 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
69 _("This account has no connectivity extensions.")."</b>";
70 $display.= back_to_main();
71 return ($display);
72 }
73 }
75 /* Remove checkboxes in single edit mode */
76 if ($this->parent != NULL){
77 foreach ($this->plugin_name as $name){
78 $this->plugin[$name]->parent= $this->parent;
79 }
80 }
82 /* Execude objects */
83 $is_first= true;
85 $ReadOnly = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']);
87 foreach ($this->plugin_name as $name){
88 $this->plugin[$name]->ReadOnly = $ReadOnly;
89 if (!$is_first){
90 $display.= '<p class="seperator"> </p>';
91 } else {
92 $is_first= false;
93 }
94 $display.= $this->plugin[$name]->execute();
95 }
97 /* Mark me as connectivity tab */
98 $display.= "<input type='hidden' name='connectivityTab'>";
100 return($display);
101 }
104 /* Save data to object */
105 function save_object()
106 {
107 if (isset($_POST['connectivityTab'])){
108 foreach ($this->plugin_name as $name){
109 $this->plugin[$name]->save_object();
110 }
111 }
112 }
114 function check()
115 {
116 $message= plugin::check();
118 foreach ($this->plugin_name as $name){
119 $tmp= $this->plugin[$name]->check();
121 $message= array_merge($message, $tmp);
122 }
124 return ($message);
125 }
127 function set_acl_category($cat)
128 {
129 plugin::set_acl_category($cat);
130 foreach ($this->plugin_name as $name){
131 $this->plugin[$name]->set_acl_category( $cat);
132 }
133 }
135 function set_acl_base($base)
136 {
137 plugin::set_acl_base($base);
138 foreach ($this->plugin_name as $name){
139 $this->plugin[$name]->set_acl_base( $base);
140 }
141 }
143 /* Save to LDAP */
144 function save()
145 {
146 /* Save objects */
147 foreach ($this->plugin_name as $name){
148 $this->plugin[$name]->dn= $this->dn;
150 if ($this->plugin[$name]->is_account){
151 $this->plugin[$name]->save();
152 } else {
153 $this->plugin[$name]->remove_from_parent();
154 }
155 }
156 }
158 function remove_from_parent()
159 {
160 /* Remove objects */
161 foreach ($this->plugin_name as $name){
162 $this->plugin[$name]->dn= $this->dn;
163 $this->plugin[$name]->remove_from_parent();
164 }
165 }
167 function adapt_from_template($dn)
168 {
169 /* Adapt objects */
170 foreach ($this->plugin_name as $name){
171 $this->plugin[$name]->dn= $this->dn;
172 $this->plugin[$name]->adapt_from_template($dn);
173 }
174 }
176 /* Prepare the connectivity obj
177 */
178 function PrepareForCopyPaste($obj)
179 {
180 $tmp = $this->plugin;
181 plugin::PrepareForCopyPaste($obj);
182 $this->plugin = $tmp;
183 foreach( $this->plugin as $key => $plug){
184 $this->plugin[$key]->PrepareForCopyPaste($obj);
185 }
186 }
187 }
189 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
190 ?>