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();
26 function connectivity ($config, $dn= NULL)
27 {
28 /* Preseed permissions */
29 $this->dn= $dn;
30 $ui= get_userinfo();
31 $acl= get_permissions ($ui->dn, $ui->subtreeACL);
33 /* Load accounts */
34 foreach ($config->data['TABS']['CONNECTIVITY'] as $plug){
35 $name= $plug['CLASS'];
36 $this->plugin_name[]= $name;
37 $this->plugin[$name]= new $name($config, $dn);
38 $this->plugin[$name]->acl= get_module_permission($acl, "$name", $ui->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= false;
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;
78 foreach ($this->plugin_name as $name){
79 if (!$is_first){
80 $display.= '<p class="seperator"> </p>';
81 } else {
82 $is_first= false;
83 }
84 $display.= $this->plugin[$name]->execute();
85 }
87 /* Mark me as connectivity tab */
88 $display.= "<input type='hidden' name='connectivityTab'>";
90 return($display);
91 }
94 /* Save data to object */
95 function save_object()
96 {
97 if (isset($_POST['connectivityTab'])){
98 foreach ($this->plugin_name as $name){
99 $this->plugin[$name]->save_object();
100 }
101 }
102 }
104 function check()
105 {
106 $message= array();
108 foreach ($this->plugin_name as $name){
109 $tmp= $this->plugin[$name]->check();
111 $message= array_merge($message, $tmp);
112 }
114 return ($message);
115 }
118 /* Save to LDAP */
119 function save()
120 {
121 /* Save objects */
122 foreach ($this->plugin_name as $name){
123 $this->plugin[$name]->dn= $this->dn;
124 if ($this->plugin[$name]->is_account){
125 $this->plugin[$name]->save();
126 $this->plugin[$name]->postcreate();
127 } else {
128 $this->plugin[$name]->remove_from_parent();
129 $this->plugin[$name]->postremove();
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 $this->plugin[$name]->postremove();
141 }
142 }
144 function adapt_from_template($dn)
145 {
146 /* Adapt objects */
147 foreach ($this->plugin_name as $name){
148 $this->plugin[$name]->dn= $this->dn;
149 $this->plugin[$name]->adapt_from_template($dn);
150 }
151 }
153 }
155 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
156 ?>