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)
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);
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 }
128 /* Save to LDAP */
129 function save()
130 {
131 /* Save objects */
132 foreach ($this->plugin_name as $name){
133 $this->plugin[$name]->dn= $this->dn;
134 if ($this->plugin[$name]->is_account){
135 $this->plugin[$name]->save();
136 $this->plugin[$name]->postcreate();
137 } else {
138 $this->plugin[$name]->remove_from_parent();
139 $this->plugin[$name]->postremove();
140 }
141 }
142 }
144 function remove_from_parent()
145 {
146 /* Remove objects */
147 foreach ($this->plugin_name as $name){
148 $this->plugin[$name]->dn= $this->dn;
149 $this->plugin[$name]->remove_from_parent();
150 $this->plugin[$name]->postremove();
151 }
152 }
154 function adapt_from_template($dn)
155 {
156 /* Adapt objects */
157 foreach ($this->plugin_name as $name){
158 $this->plugin[$name]->dn= $this->dn;
159 $this->plugin[$name]->adapt_from_template($dn);
160 }
161 }
163 /* Prepare the connectivity obj
164 */
165 function PrepareForCopyPaste($obj)
166 {
167 $tmp = $this->plugin;
168 plugin::PrepareForCopyPaste($obj);
169 $this->plugin = $tmp;
170 foreach($obj->plugin as $key => $plug){
171 $this->plugin[$key]->PrepareForCopyPaste($plug);
172 }
173 }
174 }
176 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
177 ?>