Code

Added attributes to list of acls
[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();
25   var $CopyPasteVars = array("plugin","plugin_name");
28   function connectivity ($config, $dn= 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);
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\">&nbsp;<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">&nbsp;</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         $this->plugin[$name]->postcreate();
129       } else {
130         $this->plugin[$name]->remove_from_parent();
131         $this->plugin[$name]->postremove();
132       }
133     }
134   }
136   function remove_from_parent()
137   {
138     /* Remove objects */
139     foreach ($this->plugin_name as $name){
140       $this->plugin[$name]->dn= $this->dn;
141       $this->plugin[$name]->remove_from_parent();
142       $this->plugin[$name]->postremove();
143     }
144   }
146   function adapt_from_template($dn)
147   {
148     /* Adapt objects */
149     foreach ($this->plugin_name as $name){
150       $this->plugin[$name]->dn= $this->dn;
151       $this->plugin[$name]->adapt_from_template($dn);
152     }
153   }
155   /* Prepare the connectivity obj 
156    */
157   function PrepareForCopyPaste($obj)
158   { 
159     $tmp = $this->plugin;
160     plugin::PrepareForCopyPaste($obj);
161     $this->plugin = $tmp;
162     foreach($obj->plugin as $key => $plug){
163       $this->plugin[$key]->PrepareForCopyPaste($plug);
164     }
165   }
166   
170 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
171 ?>