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;
30 /*! \brief Konstructor
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, $parent=NULL)
39 {
40 plugin::plugin ($config, $dn,$parent);
42 /* Setting uid to default */
43 if(isset($this->attrs['uid'][0])){
44 $this->uid = $this->attrs['uid'][0];
45 }
46 }
48 /*!
49 \brief General execution
50 \author Harald Falk <hf@doellken-weimar.de>
51 \version 1.00
52 \date 1.07.2005
54 Load smarty Template and assign needed smarty vars
55 */
58 function execute()
59 {
60 /* Call parent execute */
61 // plugin::execute();
63 /* Log view */
64 if($this->is_account && !$this->view_logged){
65 $this->view_logged = TRUE;
66 new log("view","users/".get_class($this),$this->dn);
67 }
69 $display= "";
71 $smarty= get_smarty();
73 if ($this->is_account){
74 $smarty->assign("intranetState", "checked");
75 $smarty->assign("wstate", "");
76 } else {
77 $smarty->assign("wstate", "disabled");
78 $smarty->assign("intranetState", "");
79 }
81 //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. )
82 if ($this->parent !== NULL){
83 $smarty->assign("tabbed", 1);
84 }else{
85 $smarty->assign("tabbed", 0);
86 }
89 $smarty->assign('gosaIntranetACL', " disabled ");
90 if((!$this->ReadOnly) && ( ($this->is_account && $this->acl_is_removeable())
91 || (!$this->is_account && $this->acl_is_createable()))){
92 $smarty->assign('gosaIntranetACL', "");
93 }
95 $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
96 return ($display);
97 }
99 /*!
100 \brief Delete ext from User
101 \author Harald Falk <hf@doellken-weimar.de>
102 \version 1.00
103 \date 1.07.2005
104 Handles deletion of this object
105 */
106 function remove_from_parent()
107 {
108 if($this->acl_is_removeable() && $this->initially_was_account){
109 plugin::remove_from_parent();
110 $ldap= $this->config->get_ldap_link();
112 $ldap->cd($this->dn);
113 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
114 $this->attributes, "Save");
115 $this->cleanup();
116 $ldap->modify ($this->attrs);
118 /* Log last action */
119 new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
121 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/intranet account with dn '%s' failed."),$this->dn));
123 /* Optionally execute a command after we're done */
124 $this->postremove(array("uid"=>$this->uid));
125 }
126 }
129 /*!
130 \brief handles Post data
131 \author Harald Falk <hf@doellken-weimar.de>
132 \version 1.00
133 \date 1.07.2005
134 Save data to object
135 */
136 function save_object()
137 {
138 /* Do we need to flip is_account state? */
139 if (isset($_POST['connectivityTab'])){
140 if (isset($_POST['intranet'])){
141 if (!$this->is_account && $_POST['intranet'] == "B"){
142 if($this->acl_is_createable()){
143 $this->is_account= TRUE;
144 }
145 }
146 } else {
147 if($this->acl_is_removeable()){
148 $this->is_account= FALSE;
149 }
150 }
151 }
153 plugin::save_object();
154 if (isset($_POST["INTRANETStatus"])){
155 $this->INTRANETStatus = "disabled";
156 } else {
157 $this->INTRANETStatus = "enabled";
158 }
159 }
162 /*! \brief Handles LDAP saves
163 \author Harald Falk <hf@doellken-weimar.de>
164 \version 1.00
165 \date 1.07.2005
166 Save objectClass for User in LDAP
168 */
169 function save()
170 {
171 plugin::save();
173 /* Write back to ldap */
174 $ldap= $this->config->get_ldap_link();
175 $ldap->cd($this->dn);
176 $this->cleanup();
177 $ldap->modify ($this->attrs);
179 /* Log last action */
180 if($this->initially_was_account){
181 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
182 }else{
183 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
184 }
186 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/intranet account with dn '%s' failed."),$this->dn));
188 /* Optionally execute a command after we're done */
189 $this->postcreate(array("uid" => $this->uid));
190 }
193 /* Return plugin informations for acl handling */
194 function plInfo()
195 {
196 return (array(
197 "plShortName" => _("Intranet"),
198 "plDepends" => array("user"),
199 "plPriority" => 25, // Position in tabs
200 "plSection" => array("personal" => _("My account")),
201 "plCategory" => array("users"),
202 "plOptions" => array(),
204 "plDescription" => _("Intranet account settings")." : <u>"._("Connectivity addon")."</u>",
205 "plSelfModify" => TRUE,
207 "plProvidedAcls" => array()
208 ));
209 }
210 }
212 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
213 ?>