Code

Added uid to post_events.
[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   var $uid ="";
32   /*! \brief Konstructor  
33                 
34         \param $config  The Config Object used to initialise plugin
35         \param $dn              The DN of the currently edited entry    
36       \author  Harald Falk <hf@doellken-weimar.de>
37       \version 1.00
38       \date    1.07.2005
39   */
40   function intranetAccount ($config, $dn= NULL)
41   {
42         plugin::plugin ($config, $dn);
43         
44     /* Setting uid to default */
45     if(isset($this->attrs['uid'][0])){
46       $this->uid = $this->attrs['uid'][0];
47     }
48   }
50   /*!
51         \brief General execution 
52       \author  Harald Falk <hf@doellken-weimar.de>
53       \version 1.00
54       \date    1.07.2005
55         
56         Load smarty Template and assign needed smarty vars
57         */
58         
59         
60   function execute()
61   {
62         /* Call parent execute */
63 //      plugin::execute();
65         $display= "";
67         $smarty= get_smarty();
69         if ($this->is_account){
70                 $smarty->assign("intranetState", "checked");
71                 $smarty->assign("wstate", "");
72         } else {
73                 $smarty->assign("wstate", "disabled");
74                 $smarty->assign("intranetState", "");
75         }
77         //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. ) 
78         if ($this->parent != NULL){
79                 $smarty->assign("tabbed", 1);
80         }else{
81                 $smarty->assign("tabbed", 0);   
82         }
84    $smarty->assign('gosaIntranetACL', chkacl($this->acl, 'intranetAccount'));
86         $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
87         return ($display);
88   }
90   /*! 
91         \brief Delete ext from User
92       \author  Harald Falk <hf@doellken-weimar.de>
93       \version 1.00
94       \date    1.07.2005
95         Handles deletion of this object
96   */
97   function remove_from_parent()
98   {
99           if(chkacl($this->acl, 'intranetAccount') == ""){
100                   plugin::remove_from_parent();
101                   $ldap= $this->config->get_ldap_link();
103                   $ldap->cd($this->dn);
104                   @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
105                                   $this->attributes, "Save");
106                   $this->cleanup();
107                   $ldap->modify ($this->attrs); 
109                   show_ldap_error($ldap->get_error(), _("Removing intranet account failed"));
111                   /* Optionally execute a command after we're done */
112                   $this->postremove(array("uid"=>$this->uid));
113           }
114   }
117   /*!
118         \brief handles Post data 
119       \author  Harald Falk <hf@doellken-weimar.de>
120       \version 1.00
121       \date    1.07.2005
122         Save data to object 
123         */
124   function save_object()
125   {
126         /* Do we need to flip is_account state? */
127         if (isset($_POST['connectivityTab'])){
128                 if (isset($_POST['intranet'])){
129                         if (!$this->is_account && $_POST['intranet'] == "B"){
130                                 $this->is_account= TRUE;
131                         }
132                 } else {
133                         $this->is_account= FALSE;
134                 }
135         }
137         plugin::save_object();
138         if (isset($_POST["INTRANETStatus"])){
139                 $this->INTRANETStatus = "disabled";
140         } else {
141                 $this->INTRANETStatus = "enabled";
142         }
143   }
146   /*! \brief Handles LDAP saves 
147       \author  Harald Falk <hf@doellken-weimar.de>
148       \version 1.00
149       \date    1.07.2005
150         Save objectClass for User in LDAP 
151         
152         */
153   function save()
154   {
155           if(chkacl($this->acl, 'intranetAccount') == ""){
156                   plugin::save();
157                         
158                   /* Write back to ldap */
159                   $ldap= $this->config->get_ldap_link();
160                   $ldap->cd($this->dn);
161                   $this->cleanup();
162                   $ldap->modify ($this->attrs); 
164                   show_ldap_error($ldap->get_error(), _("Saving intranet account failed"));
166                   /* Optionally execute a command after we're done */
167                   $this->postcreate(array("uid"=> $this->uid));
168           }
169   }
173 ?>