Code

Updated macro class. Added check -> Empty macros can't be saved.
[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");
22   var $ReadOnly = false;  
24   var $uid ="";
26   /*! \brief Konstructor  
28     \param $config      The Config Object used to initialise plugin
29     \param $dn          The DN of the currently edited entry    
30     \author  Harald Falk <hf@doellken-weimar.de>
31     \version 1.00
32     \date    1.07.2005
33    */
34   function intranetAccount ($config, $dn= NULL, $parent=NULL)
35   {
36     plugin::plugin ($config, $dn,$parent);
38      /* Setting uid to default */
39      if(isset($this->attrs['uid'][0])){
40        $this->uid = $this->attrs['uid'][0];
41      }
42   }
44   /*!
45     \brief General execution 
46     \author  Harald Falk <hf@doellken-weimar.de>
47     \version 1.00
48     \date    1.07.2005
50     Load smarty Template and assign needed smarty vars
51    */
54   function execute()
55   {
56     /* Call parent execute */
57     //  plugin::execute();
59     $display= "";
61     $smarty= get_smarty();
63     if ($this->is_account){
64       $smarty->assign("intranetState", "checked");
65       $smarty->assign("wstate", "");
66     } else {
67       $smarty->assign("wstate", "disabled");
68       $smarty->assign("intranetState", "");
69     }
71     //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. ) 
72     if ($this->parent != NULL){
73       $smarty->assign("tabbed", 1);
74     }else{
75       $smarty->assign("tabbed", 0);     
76     }
79     $smarty->assign('gosaIntranetACL', " disabled ");
80     if((!$this->ReadOnly) && (    ($this->is_account && $this->acl_is_removeable()) 
81                                || (!$this->is_account && $this->acl_is_createable()))){
82       $smarty->assign('gosaIntranetACL', "");
83     }
85     $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
86     return ($display);
87   }
89   /*! 
90     \brief Delete ext from User
91     \author  Harald Falk <hf@doellken-weimar.de>
92     \version 1.00
93     \date    1.07.2005
94     Handles deletion of this object
95    */
96   function remove_from_parent()
97   {
98     if($this->acl_is_removeable()){ 
99       plugin::remove_from_parent();
100       $ldap= $this->config->get_ldap_link();
102       $ldap->cd($this->dn);
103       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
104           $this->attributes, "Save");
105       $this->cleanup();
106       $ldap->modify ($this->attrs); 
108       show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/intranet account with dn '%s' failed."),$this->dn));
110       /* Optionally execute a command after we're done */
111       $this->postremove(array("uid"=>$this->uid));
112     }
113   }
116   /*!
117     \brief handles Post data 
118     \author  Harald Falk <hf@doellken-weimar.de>
119     \version 1.00
120     \date    1.07.2005
121     Save data to object 
122    */
123   function save_object()
124   {
125     /* Do we need to flip is_account state? */
126     if (isset($_POST['connectivityTab'])){
127       if (isset($_POST['intranet'])){
128         if (!$this->is_account && $_POST['intranet'] == "B"){
129           if($this->acl_is_createable()){
130             $this->is_account= TRUE;
131           }
132         }
133       } else {
134         if($this->acl_is_removeable()){
135           $this->is_account= FALSE;
136         }
137       }
138     }
140     plugin::save_object();
141     if (isset($_POST["INTRANETStatus"])){
142       $this->INTRANETStatus = "disabled";
143     } else {
144       $this->INTRANETStatus = "enabled";
145     }
146   }
149   /*! \brief Handles LDAP saves 
150     \author  Harald Falk <hf@doellken-weimar.de>
151     \version 1.00
152     \date    1.07.2005
153     Save objectClass for User in LDAP 
155    */
156   function save()
157   {
158       plugin::save();
160       /* Write back to ldap */
161       $ldap= $this->config->get_ldap_link();
162       $ldap->cd($this->dn);
163       $this->cleanup();
164       $ldap->modify ($this->attrs); 
166       show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/intranet account with dn '%s' failed."),$this->dn));
168       /* Optionally execute a command after we're done */
169       $this->postcreate(array("uid" => $this->uid));
170   }
173   /* Return plugin informations for acl handling */ 
174   function plInfo()
175   {
176     return (array(      
177           "plShortName"     => _("Intranet"),
178           "plDepends"       => array("user"),
179           "plPriority"      => 25,                                 // Position in tabs
180           "plSection"     => array("personal" => _("My account")),
181           "plCategory"    => array("users"),
182           "plOptions"       => array(),
184           "plDescription"       => _("Intranet account settings")."&nbsp;:&nbsp;<u>"._("Connectivity addon")."</u>",
185           "plSelfModify"        => TRUE,
187           "plProvidedAcls"  => array()
188           ));
189   }
192 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
193 ?>