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);
39 }
40 }
42 function execute()
43 {
44 /* Call parent execute */
45 plugin::execute();
47 $display= "";
49 /* Prepare templating */
50 $smarty= get_smarty();
52 /* Do we represent a valid account? */
53 if ($this->parent == NULL){
54 $enabled= true;
55 foreach ($this->plugin_name as $name){
56 if ($this->plugin[$name]->is_account){
57 $enabled= true;
58 break;
59 }
60 }
61 if (!$enabled){
62 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
63 _("This account has no connectivity extensions.")."</b>";
64 $display.= back_to_main();
65 return ($display);
66 }
67 }
69 /* Remove checkboxes in single edit mode */
70 if ($this->parent != NULL){
71 foreach ($this->plugin_name as $name){
72 $this->plugin[$name]->parent= $this->parent;
73 }
74 }
76 /* Execude objects */
77 $is_first= true;
79 $ReadOnly = (!isset($this->parent) || !$this->parent) && !isset($_SESSION['edit']);
81 foreach ($this->plugin_name as $name){
82 $this->plugin[$name]->ReadOnly = $ReadOnly;
83 if (!$is_first){
84 $display.= '<p class="seperator"> </p>';
85 } else {
86 $is_first= false;
87 }
88 $display.= $this->plugin[$name]->execute();
89 }
91 /* Mark me as connectivity tab */
92 $display.= "<input type='hidden' name='connectivityTab'>";
94 return($display);
95 }
98 /* Save data to object */
99 function save_object()
100 {
101 if (isset($_POST['connectivityTab'])){
102 foreach ($this->plugin_name as $name){
103 $this->plugin[$name]->save_object();
104 }
105 }
106 }
108 function check()
109 {
110 $message= plugin::check();
112 foreach ($this->plugin_name as $name){
113 $tmp= $this->plugin[$name]->check();
115 $message= array_merge($message, $tmp);
116 }
118 return ($message);
119 }
122 /* Save to LDAP */
123 function save()
124 {
125 /* Save objects */
126 foreach ($this->plugin_name as $name){
127 $this->plugin[$name]->dn= $this->dn;
128 if ($this->plugin[$name]->is_account){
129 $this->plugin[$name]->save();
130 $this->plugin[$name]->postcreate();
131 } else {
132 $this->plugin[$name]->remove_from_parent();
133 $this->plugin[$name]->postremove();
134 }
135 }
136 }
138 function remove_from_parent()
139 {
140 /* Remove objects */
141 foreach ($this->plugin_name as $name){
142 $this->plugin[$name]->dn= $this->dn;
143 $this->plugin[$name]->remove_from_parent();
144 $this->plugin[$name]->postremove();
145 }
146 }
148 function adapt_from_template($dn)
149 {
150 /* Adapt objects */
151 foreach ($this->plugin_name as $name){
152 $this->plugin[$name]->dn= $this->dn;
153 $this->plugin[$name]->adapt_from_template($dn);
154 }
155 }
157 /* Prepare the connectivity obj
158 */
159 function PrepareForCopyPaste($obj)
160 {
161 $tmp = $this->plugin;
162 plugin::PrepareForCopyPaste($obj);
163 $this->plugin = $tmp;
164 foreach($obj->plugin as $key => $plug){
165 $this->plugin[$key]->PrepareForCopyPaste($plug);
166 }
167 }
168 }
170 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
171 ?>