Code

Removed show_ldap_error() calls
[gosa.git] / gosa-plugins / connectivity / personal / connectivity / class_intranetAccount.inc
1 <?php
5 /*!
6   \author  Harald Falk <hf@doellken-weimar.de>
7   \version 1.00
8   \date    1.07.2005
10   \brief   Enables Apache authentification for Intranet through openldap with .htaccess files   
11  */
13 class intranetAccount extends plugin
14 {
15   /*! Definitions */
16   var $plHeadline= "Intranet";
17   /*! Definitions */
18   var $plDescription= "This does something";
20   /* attribute list for save action */
21   var $attributes= array();
22   /* ObjectClasses list for save action */
23   var $objectclasses= array("gosaIntranetAccount");
24   var $ReadOnly = false;  
26   var $uid ="";
28   var $view_logged = FALSE;
29   var $multiple_support = TRUE;
31   /*! \brief Konstructor  
33     \param $config      The Config Object used to initialise plugin
34     \param $dn          The DN of the currently edited entry    
35     \author  Harald Falk <hf@doellken-weimar.de>
36     \version 1.00
37     \date    1.07.2005
38    */
39   function intranetAccount (&$config, $dn= NULL, $parent=NULL)
40   {
41     plugin::plugin ($config, $dn,$parent);
43     /* Setting uid to default */
44     if(isset($this->attrs['uid'][0])){
45       $this->uid = $this->attrs['uid'][0];
46     }
47   }
49   /*!
50     \brief General execution 
51     \author  Harald Falk <hf@doellken-weimar.de>
52     \version 1.00
53     \date    1.07.2005
55     Load smarty Template and assign needed smarty vars
56    */
59   function execute()
60   {
61     /* Call parent execute */
62     //  plugin::execute();
64     /* Log view */
65     if($this->is_account && !$this->view_logged){
66       $this->view_logged = TRUE;
67       new log("view","users/".get_class($this),$this->dn);
68     }
70     $display= "";
72     $smarty= get_smarty();
74     if ($this->is_account){
75       $smarty->assign("intranetState", "checked");
76       $smarty->assign("wstate", "");
77     } else {
78       $smarty->assign("wstate", "disabled");
79       $smarty->assign("intranetState", "");
80     }
82     //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. ) 
83     if ($this->parent !== NULL){
84       $smarty->assign("tabbed", 1);
85     }else{
86       $smarty->assign("tabbed", 0);     
87     }
89     $smarty->assign('gosaIntranetACL', $this->getacl("",$this->ReadOnly));
90     $smarty->assign("use_intranet",in_array("intranet",$this->multi_boxes));
91     $smarty->assign("multiple_support",$this->multiple_support_active);
92     $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
93     return ($display);
94   }
96   /*! 
97     \brief Delete ext from User
98     \author  Harald Falk <hf@doellken-weimar.de>
99     \version 1.00
100     \date    1.07.2005
101     Handles deletion of this object
102    */
103   function remove_from_parent()
104   {
105     if($this->acl_is_removeable() && $this->initially_was_account){ 
106       plugin::remove_from_parent();
107       $ldap= $this->config->get_ldap_link();
109       $ldap->cd($this->dn);
110       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
111           $this->attributes, "Save");
112       $this->cleanup();
113       $ldap->modify ($this->attrs); 
115       /* Log last action */
116       new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
118       if (!$ldap->success()){
119         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
120       }
122       /* Optionally execute a command after we're done */
123       $this->postremove(array("uid"=>$this->uid));
124     }
125   }
128   /*!
129     \brief handles Post data 
130     \author  Harald Falk <hf@doellken-weimar.de>
131     \version 1.00
132     \date    1.07.2005
133     Save data to object 
134    */
135   function save_object()
136   {
137     /* Do we need to flip is_account state? */
138     if (isset($_POST['connectivityTab'])){
139       if (isset($_POST['intranet'])){
140         if (!$this->is_account && $_POST['intranet'] == "B"){
141           if($this->acl_is_createable()){
142             $this->is_account= TRUE;
143           }
144         }
145       } else {
146         if($this->acl_is_removeable()){
147           $this->is_account= FALSE;
148         }
149       }
150     }
152     plugin::save_object();
153     if (isset($_POST["INTRANETStatus"])){
154       $this->INTRANETStatus = "disabled";
155     } else {
156       $this->INTRANETStatus = "enabled";
157     }
158   }
161   /*! \brief Handles LDAP saves 
162     \author  Harald Falk <hf@doellken-weimar.de>
163     \version 1.00
164     \date    1.07.2005
165     Save objectClass for User in LDAP 
167    */
168   function save()
169   {
170       plugin::save();
172       /* Write back to ldap */
173       $ldap= $this->config->get_ldap_link();
174       $ldap->cd($this->dn);
175       $this->cleanup();
176       $ldap->modify ($this->attrs); 
178       /* Log last action */
179       if($this->initially_was_account){
180         new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
181       }else{
182         new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
183       }
185       if (!$ldap->success()){
186         msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
187       }
189       /* Optionally execute a command after we're done */
190       $this->postcreate(array("uid" => $this->uid));
191   }
194   /* Return plugin informations for acl handling */ 
195   static function plInfo()
196   {
197     return (array(      
198           "plShortName"     => _("Intranet"),
199           "plDepends"       => array("user"),
200           "plPriority"      => 25,                                 // Position in tabs
201           "plSection"     => array("personal" => _("My account")),
202           "plCategory"    => array("users"),
203           "plOptions"       => array(),
205           "plDescription"       => _("Intranet account settings")."&nbsp;:&nbsp;<u>"._("Connectivity addon")."</u>",
206           "plSelfModify"        => TRUE,
208           "plProvidedAcls"  => array()
209           ));
210   }
212   
213   function multiple_save_object()
214   {
215     if (isset($_POST['connectivityTab'])){
216       plugin::multiple_save_object();
217       if(isset($_POST['use_intranet'])){
218         $this->multi_boxes[] = "intranet";
219         if (isset($_POST['intranet'])){
220           if (!$this->is_account && $_POST['intranet'] == "B"){
221             if($this->acl_is_createable()){
222               $this->is_account= TRUE;
223             }
224           }
225         } else {
226           if($this->acl_is_removeable()){
227             $this->is_account= FALSE;
228           }
229         }
230       }
231     }
232   }
234   function get_multi_edit_values()
235   {
236     $ret = plugin::get_multi_edit_values();
237     if(in_array("intranet",$this->multi_boxes)){
238       $ret['is_account'] = $this->is_account;
239     }
240     return($ret);
241   }
243   function set_multi_edit_values($values)
244   {
245     plugin::set_multi_edit_values($values);
246     if(isset($values['is_account'])){
247       $this->is_account = $values['is_account'];
248     }
249   }
251   function init_multiple_support($attrs,$all)
252   {
253     plugin::init_multiple_support($attrs,$all);
254     if(isset($attrs['objectClass']) && in_array("gosaIntranetAccount",$attrs['objectClass'])){
255       $this->is_account = TRUE;
256     }
257   }
260 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
261 ?>