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();
33 $acl= get_permissions ($ui->dn, $ui->subtreeACL);
35 /* Load accounts */
36 foreach ($config->data['TABS']['CONNECTIVITY'] as $plug){
37 $name= $plug['CLASS'];
38 $this->plugin_name[]= $name;
39 $this->plugin[$name]= new $name($config, $dn, $parent);
40 $this->plugin[$name]->acl= get_module_permission($acl, "$name", $ui->dn);
41 }
42 }
44 function execute()
45 {
46 /* Call parent execute */
47 plugin::execute();
49 $display= "";
51 /* Prepare templating */
52 $smarty= get_smarty();
54 /* Do we represent a valid account? */
55 if ($this->parent == NULL){
56 $enabled= true;
57 foreach ($this->plugin_name as $name){
58 if ($this->plugin[$name]->is_account){
59 $enabled= true;
60 break;
61 }
62 }
63 if (!$enabled){
64 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
65 _("This account has no connectivity extensions.")."</b>";
66 $display.= back_to_main();
67 return ($display);
68 }
69 }
71 /* Remove checkboxes in single edit mode */
72 if ($this->parent != NULL){
73 foreach ($this->plugin_name as $name){
74 $this->plugin[$name]->parent= $this->parent;
75 }
76 }
78 /* Execude objects */
79 $is_first= true;
80 foreach ($this->plugin_name as $name){
81 if (!$is_first){
82 $display.= '<p class="seperator"> </p>';
83 } else {
84 $is_first= false;
85 }
86 $display.= $this->plugin[$name]->execute();
87 }
89 /* Mark me as connectivity tab */
90 $display.= "<input type='hidden' name='connectivityTab'>";
92 return($display);
93 }
96 /* Save data to object */
97 function save_object()
98 {
99 if (isset($_POST['connectivityTab'])){
100 foreach ($this->plugin_name as $name){
101 $this->plugin[$name]->save_object();
102 }
103 }
104 }
106 function check()
107 {
108 $message= plugin::check();
110 foreach ($this->plugin_name as $name){
111 $tmp= $this->plugin[$name]->check();
113 $message= array_merge($message, $tmp);
114 }
116 return ($message);
117 }
120 /* Save to LDAP */
121 function save()
122 {
123 /* Save objects */
124 foreach ($this->plugin_name as $name){
125 $this->plugin[$name]->dn= $this->dn;
126 if ($this->plugin[$name]->is_account){
127 $this->plugin[$name]->save();
128 } else {
129 $this->plugin[$name]->remove_from_parent();
130 }
131 }
132 }
134 function remove_from_parent()
135 {
136 /* Remove objects */
137 foreach ($this->plugin_name as $name){
138 $this->plugin[$name]->dn= $this->dn;
139 $this->plugin[$name]->remove_from_parent();
140 }
141 }
143 function adapt_from_template($dn)
144 {
145 /* Adapt objects */
146 foreach ($this->plugin_name as $name){
147 $this->plugin[$name]->dn= $this->dn;
148 $this->plugin[$name]->adapt_from_template($dn);
149 }
150 }
152 /* Prepare the connectivity obj
153 */
154 function PrepareForCopyPaste($obj)
155 {
156 $tmp = $this->plugin;
157 plugin::PrepareForCopyPaste($obj);
158 $this->plugin = $tmp;
159 foreach($obj->plugin as $key => $plug){
160 $this->plugin[$key]->PrepareForCopyPaste($plug);
161 }
162 }
165 }
167 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
168 ?>