Code

Added a flag for connectivity classes, to allow grey out of every input when not...
[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;
81     $ReadOnly = (!is_object($this->parent) && !isset($_SESSION['edit']));
83     foreach ($this->plugin_name as $name){
84       $this->plugin[$name]->ReadOnly = $ReadOnly;
85       if (!$is_first){
86         $display.= '<p class="seperator">&nbsp;</p>';
87       } else {
88         $is_first= false;
89       }
90       $display.= $this->plugin[$name]->execute();
91     }
93     /* Mark me as connectivity tab */
94     $display.= "<input type='hidden' name='connectivityTab'>";
96     return($display);
97   }
100   /* Save data to object */
101   function save_object()
102   {
103     if (isset($_POST['connectivityTab'])){
104       foreach ($this->plugin_name as $name){
105         $this->plugin[$name]->save_object();
106       }
107     }
108   }
110   function check()
111   {
112     $message= plugin::check();
114     foreach ($this->plugin_name as $name){
115       $tmp= $this->plugin[$name]->check();
117       $message= array_merge($message, $tmp);
118     }
120     return ($message);
121   }
124   /* Save to LDAP */
125   function save()
126   {
127     /* Save objects */
128     foreach ($this->plugin_name as $name){
129       $this->plugin[$name]->dn= $this->dn;
130       if ($this->plugin[$name]->is_account){
131         $this->plugin[$name]->save();
132         $this->plugin[$name]->postcreate();
133       } else {
134         $this->plugin[$name]->remove_from_parent();
135         $this->plugin[$name]->postremove();
136       }
137     }
138   }
140   function remove_from_parent()
141   {
142     /* Remove objects */
143     foreach ($this->plugin_name as $name){
144       $this->plugin[$name]->dn= $this->dn;
145       $this->plugin[$name]->remove_from_parent();
146       $this->plugin[$name]->postremove();
147     }
148   }
150   function adapt_from_template($dn)
151   {
152     /* Adapt objects */
153     foreach ($this->plugin_name as $name){
154       $this->plugin[$name]->dn= $this->dn;
155       $this->plugin[$name]->adapt_from_template($dn);
156     }
157   }
159   /* Prepare the connectivity obj 
160    */
161   function PrepareForCopyPaste($obj)
162   { 
163     $tmp = $this->plugin;
164     plugin::PrepareForCopyPaste($obj);
165     $this->plugin = $tmp;
166     foreach($obj->plugin as $key => $plug){
167       $this->plugin[$key]->PrepareForCopyPaste($plug);
168     }
169   }
171 /* Return plugin informations for acl handling 
172 #FIXME We should check here, if the user has access to one of the subClasses */ 
173   function plInfo()
174   {
175     return (array(  
176           "plShortName"       => _("Connectivity"),
177           "plDescription"     => _("Connectivity settings"),
178           "plSelfModify"      => TRUE,
179           "plDepends"         => array("user"),
180           "plPriority"        => 5,                                 // Position in tabs
181           "plSection"       => "personal",                        // This belongs to personal
182           "plCategory"      => array("users"),
183           "plOptions"       => array(),
184           "plProvidedAcls"  => array()
185           ));
186   }
189 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
190 ?>