dec3825cd08de032dd198fb5b9b726b97c4441d4
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();
46 $display= "";
48 /* Prepare templating */
49 $smarty= get_smarty();
51 /* Do we represent a valid account? */
52 if ($this->parent == NULL){
53 $enabled= false;
54 foreach ($this->plugin_name as $name){
55 if ($this->plugin[$name]->is_account){
56 $enabled= true;
57 break;
58 }
59 }
60 if (!$enabled){
61 $display= "<img alt=\"\" src=\"images/stop.png\" align=\"middle\"> <b>".
62 _("This account has no connectivity extensions.")."</b>";
63 $display.= back_to_main();
64 return ($display);
65 }
66 }
68 /* Remove checkboxes in single edit mode */
69 if ($this->parent != NULL){
70 foreach ($this->plugin_name as $name){
71 $this->plugin[$name]->parent= $this->parent;
72 }
73 }
75 /* Execude objects */
76 $is_first= true;
77 foreach ($this->plugin_name as $name){
78 if (!$this->plugin[$name]->is_account && $this->parent == NULL) continue;
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 ?>