Code

Added empty lines
[gosa.git] / plugins / personal / connectivity / class_connectivity.inc
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\">&nbsp;<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 (!$this->plugin[$name]->is_account && $this->parent == NULL) continue;
80       if (!$is_first){
81         $display.= '<p class="seperator">&nbsp;</p>';
82       } else {
83         $is_first= false;
84       }
85       $display.= $this->plugin[$name]->execute();
86     }
88     /* Mark me as connectivity tab */
89     $display.= "<input type='hidden' name='connectivityTab'>";
91     return($display);
92   }
95   /* Save data to object */
96   function save_object()
97   {
98     if (isset($_POST['connectivityTab'])){
99       foreach ($this->plugin_name as $name){
100         $this->plugin[$name]->save_object();
101       }
102     }
103   }
105   function check()
106   {
107     $message= array();
109     foreach ($this->plugin_name as $name){
110       $tmp= $this->plugin[$name]->check();
112       $message= array_merge($message, $tmp);
113     }
115     return ($message);
116   }
119   /* Save to LDAP */
120   function save()
121   {
122     /* Save objects */
123     foreach ($this->plugin_name as $name){
124       $this->plugin[$name]->dn= $this->dn;
125       if ($this->plugin[$name]->is_account){
126         $this->plugin[$name]->save();
127         $this->plugin[$name]->postcreate();
128       } else {
129         $this->plugin[$name]->remove_from_parent();
130         $this->plugin[$name]->postremove();
131       }
132     }
133   }
135   function remove_from_parent()
136   {
137     /* Remove objects */
138     foreach ($this->plugin_name as $name){
139       $this->plugin[$name]->dn= $this->dn;
140       $this->plugin[$name]->remove_from_parent();
141       $this->plugin[$name]->postremove();
142     }
143   }
145   function adapt_from_template($dn)
146   {
147     /* Adapt objects */
148     foreach ($this->plugin_name as $name){
149       $this->plugin[$name]->dn= $this->dn;
150       $this->plugin[$name]->adapt_from_template($dn);
151     }
152   }
156 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
157 ?>