Code

Fixed self edit mode
[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   /* attribute list for save action */
19   var $attributes= array();
20   /* ObjectClasses list for save action */
21   var $objectclasses= array("gosaIntranetAccount");
23   /*! \brief Konstructor  
25     \param $config      The Config Object used to initialise plugin
26     \param $dn          The DN of the currently edited entry    
27     \author  Harald Falk <hf@doellken-weimar.de>
28     \version 1.00
29     \date    1.07.2005
30    */
31   function intranetAccount ($config, $dn= NULL)
32   {
33     plugin::plugin ($config, $dn);
34   }
36   /*!
37     \brief General execution 
38     \author  Harald Falk <hf@doellken-weimar.de>
39     \version 1.00
40     \date    1.07.2005
42     Load smarty Template and assign needed smarty vars
43    */
46   function execute()
47   {
48     /* Call parent execute */
49     //  plugin::execute();
51     $display= "";
53     $smarty= get_smarty();
55     if ($this->is_account){
56       $smarty->assign("intranetState", "checked");
57       $smarty->assign("wstate", "");
58     } else {
59       $smarty->assign("wstate", "disabled");
60       $smarty->assign("intranetState", "");
61     }
63     //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. ) 
64     if ($this->parent != NULL){
65       $smarty->assign("tabbed", 1);
66     }else{
67       $smarty->assign("tabbed", 0);     
68     }
70     if(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) {
71       $smarty->assign('gosaIntranetACL', "");
72     }else{
73       $smarty->assign('gosaIntranetACL', " disabled ");
74     }
76     $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
77     return ($display);
78   }
80   /*! 
81     \brief Delete ext from User
82     \author  Harald Falk <hf@doellken-weimar.de>
83     \version 1.00
84     \date    1.07.2005
85     Handles deletion of this object
86    */
87   function remove_from_parent()
88   {
89     if($this->acl_is_removeable()){ 
90       plugin::remove_from_parent();
91       $ldap= $this->config->get_ldap_link();
93       $ldap->cd($this->dn);
94       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
95           $this->attributes, "Save");
96       $this->cleanup();
97       $ldap->modify ($this->attrs); 
99       show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/intranet account with dn '%s' failed."),$this->dn));
101       /* Optionally execute a command after we're done */
102       $this->postremove();
103     }
104   }
107   /*!
108     \brief handles Post data 
109     \author  Harald Falk <hf@doellken-weimar.de>
110     \version 1.00
111     \date    1.07.2005
112     Save data to object 
113    */
114   function save_object()
115   {
116     /* Do we need to flip is_account state? */
117     if (isset($_POST['connectivityTab'])){
118       if (isset($_POST['intranet'])){
119         if (!$this->is_account && $_POST['intranet'] == "B"){
120           if($this->acl_is_createable()){
121             $this->is_account= TRUE;
122           }
123         }
124       } else {
125         if($this->acl_is_removeable()){
126           $this->is_account= FALSE;
127         }
128       }
129     }
131     plugin::save_object();
132     if (isset($_POST["INTRANETStatus"])){
133       $this->INTRANETStatus = "disabled";
134     } else {
135       $this->INTRANETStatus = "enabled";
136     }
137   }
140   /*! \brief Handles LDAP saves 
141     \author  Harald Falk <hf@doellken-weimar.de>
142     \version 1.00
143     \date    1.07.2005
144     Save objectClass for User in LDAP 
146    */
147   function save()
148   {
149       plugin::save();
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(), sprintf(_("Saving of user/intranet account with dn '%s' failed."),$this->dn));
159       /* Optionally execute a command after we're done */
160       $this->postcreate();
161   }
164   /* Return plugin informations for acl handling */ 
165   function plInfo()
166   {
167     return (array(      
168           "plShortName"     => _("Intranet"),
169           "plDepends"       => array("user"),
170           "plPriority"      => 1,                                 // Position in tabs
171           "plSection"       => "personal",                        // This belongs to personal
172           "plCategory"      => array("users"),
173           "plOptions"       => array(),
175           "plDescription"       => _("Intranet account settings"),
176           "plSelfModify"        => TRUE,
178           "plProvidedAcls"  => array()
179           ));
180   }
183 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
184 ?>