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 $display= "";
46 /* Prepare templating */
47 $smarty= get_smarty();
49 /* Do we represent a valid account? */
50 if ($this->parent == NULL){
51 $enabled= false;
52 foreach ($this->plugin_name as $name){
53 if ($this->plugin[$name]->is_account){
54 $enabled= true;
55 break;
56 }
57 }
58 if (!$enabled){
59 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
60 _("This account has no connectivity extensions.")."</b>";
61 $display.= back_to_main();
62 return ($display);
63 }
64 }
66 /* Remove checkboxes in single edit mode */
67 if ($this->parent != NULL){
68 foreach ($this->plugin_name as $name){
69 $this->plugin[$name]->parent= $this->parent;
70 }
71 }
73 /* Execude objects */
74 $is_first= true;
75 foreach ($this->plugin_name as $name){
76 if (!$this->plugin[$name]->is_account && $this->parent == NULL) continue;
77 if (!$is_first){
78 $display.= '<p class="seperator"> </p>';
79 } else {
80 $is_first= false;
81 }
82 $display.= $this->plugin[$name]->execute();
83 }
85 /* Mark me as connectivity tab */
86 $display.= "<input type='hidden' name='connectivityTab'>";
88 return($display);
89 }
92 /* Save data to object */
93 function save_object()
94 {
95 if (isset($_POST['connectivityTab'])){
96 foreach ($this->plugin_name as $name){
97 $this->plugin[$name]->save_object();
98 }
99 }
100 }
102 function check()
103 {
104 $message= array();
106 foreach ($this->plugin_name as $name){
107 $tmp= $this->plugin[$name]->check();
109 $message= array_merge($message, $tmp);
110 }
112 return ($message);
113 }
116 /* Save to LDAP */
117 function save()
118 {
119 /* Save objects */
120 foreach ($this->plugin_name as $name){
121 $this->plugin[$name]->dn= $this->dn;
122 if ($this->plugin[$name]->is_account){
123 $this->plugin[$name]->save();
124 $this->plugin[$name]->postcreate();
125 } else {
126 $this->plugin[$name]->remove_from_parent();
127 $this->plugin[$name]->postremove();
128 }
129 }
130 }
132 function remove_from_parent()
133 {
134 /* Remove objects */
135 foreach ($this->plugin_name as $name){
136 $this->plugin[$name]->dn= $this->dn;
137 $this->plugin[$name]->remove_from_parent();
138 $this->plugin[$name]->postremove();
139 }
140 }
142 function adapt_from_template($dn)
143 {
144 /* Adapt objects */
145 foreach ($this->plugin_name as $name){
146 $this->plugin[$name]->dn= $this->dn;
147 $this->plugin[$name]->adapt_from_template($dn);
148 }
149 }
151 }
153 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
154 ?>