Code

* Fixed current main base problem
[gosa.git] / plugins / personal / connectivity / class_intranetAccount.inc
1 <?php
3 /*!
4       \author  Harald Falk <hf@doellken-weimar.de>
5       \version 1.00
6       \date    1.07.2005
8       \brief   Enables Apache authentification for Intranet through openldap with .htaccess files   
9 */
11 class intranetAccount extends plugin
12 {
13   /*! Definitions */
14   var $plHeadline= "Intranet";
15   /*! Definitions */
16   var $plDescription= "This does something";
18   /*! CLI vars */
19   var $cli_summary= "Manage users Intranet account";
20   /*! CLI vars */
21   var $cli_description= "Some longer text\nfor help";
22   /*! CLI vars */
23   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
25   /* attribute list for save action */
26   var $attributes= array();
27   /* ObjectClasses list for save action */
28   var $objectclasses= array("gosaIntranetAccount");
30   /*! \brief Konstructor  
31                 
32         \param $config  The Config Object used to initialise plugin
33         \param $dn              The DN of the currently edited entry    
34       \author  Harald Falk <hf@doellken-weimar.de>
35       \version 1.00
36       \date    1.07.2005
37   */
38   function intranetAccount ($config, $dn= NULL)
39   {
40         plugin::plugin ($config, $dn);
41   }
43   /*!
44         \brief General execution 
45       \author  Harald Falk <hf@doellken-weimar.de>
46       \version 1.00
47       \date    1.07.2005
48         
49         Load smarty Template and assign needed smarty vars
50         */
51         
52         
53   function execute()
54   {
55         /* Call parent execute */
56 //      plugin::execute();
58         $display= "";
60         $smarty= get_smarty();
62         if ($this->is_account){
63                 $smarty->assign("intranetState", "checked");
64                 $smarty->assign("wstate", "");
65         } else {
66                 $smarty->assign("wstate", "disabled");
67                 $smarty->assign("intranetState", "");
68         }
70         //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. ) 
71         if ($this->parent != NULL){
72                 $smarty->assign("tabbed", 1);
73         }else{
74                 $smarty->assign("tabbed", 0);   
75         }
77    $smarty->assign('gosaIntranetACL', chkacl($this->acl, 'intranetAccount'));
79         $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
80         return ($display);
81   }
83   /*! 
84         \brief Delete ext from User
85       \author  Harald Falk <hf@doellken-weimar.de>
86       \version 1.00
87       \date    1.07.2005
88         Handles deletion of this object
89   */
90   function remove_from_parent()
91   {
92           if(chkacl($this->acl, 'intranetAccount') == ""){
93                   plugin::remove_from_parent();
94                   $ldap= $this->config->get_ldap_link();
96                   $ldap->cd($this->dn);
97                   @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
98                                   $this->attributes, "Save");
99                   $this->cleanup();
100                   $ldap->modify ($this->attrs); 
102                   show_ldap_error($ldap->get_error(), _("Removing intranet account failed"));
104                   /* Optionally execute a command after we're done */
105                   $this->postremove();
106           }
107   }
110   /*!
111         \brief handles Post data 
112       \author  Harald Falk <hf@doellken-weimar.de>
113       \version 1.00
114       \date    1.07.2005
115         Save data to object 
116         */
117   function save_object()
118   {
119         /* Do we need to flip is_account state? */
120         if (isset($_POST['connectivityTab'])){
121                 if (isset($_POST['intranet'])){
122                         if (!$this->is_account && $_POST['intranet'] == "B"){
123                                 $this->is_account= TRUE;
124                         }
125                 } else {
126                         $this->is_account= FALSE;
127                 }
128         }
130         plugin::save_object();
131         if (isset($_POST["INTRANETStatus"])){
132                 $this->INTRANETStatus = "disabled";
133         } else {
134                 $this->INTRANETStatus = "enabled";
135         }
136   }
139   /*! \brief Handles LDAP saves 
140       \author  Harald Falk <hf@doellken-weimar.de>
141       \version 1.00
142       \date    1.07.2005
143         Save objectClass for User in LDAP 
144         
145         */
146   function save()
147   {
148           if(chkacl($this->acl, 'intranetAccount') == ""){
149                   plugin::save();
150                         
151                   /* Write back to ldap */
152                   $ldap= $this->config->get_ldap_link();
153                   $ldap->cd($this->dn);
154                   $this->cleanup();
155                   $ldap->modify ($this->attrs); 
157                   show_ldap_error($ldap->get_error(), _("Saving intranet account failed"));
159                   /* Optionally execute a command after we're done */
160                   $this->postcreate();
161           }
162   }
166 ?>