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 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/intranet account with dn '%s' failed."),$this->dn));
120 /* Optionally execute a command after we're done */
121 $this->postremove(array("uid"=>$this->uid));
122 }
123 }
126 /*!
127 \brief handles Post data
128 \author Harald Falk <hf@doellken-weimar.de>
129 \version 1.00
130 \date 1.07.2005
131 Save data to object
132 */
133 function save_object()
134 {
135 /* Do we need to flip is_account state? */
136 if (isset($_POST['connectivityTab'])){
137 if (isset($_POST['intranet'])){
138 if (!$this->is_account && $_POST['intranet'] == "B"){
139 if($this->acl_is_createable()){
140 $this->is_account= TRUE;
141 }
142 }
143 } else {
144 if($this->acl_is_removeable()){
145 $this->is_account= FALSE;
146 }
147 }
148 }
150 plugin::save_object();
151 if (isset($_POST["INTRANETStatus"])){
152 $this->INTRANETStatus = "disabled";
153 } else {
154 $this->INTRANETStatus = "enabled";
155 }
156 }
159 /*! \brief Handles LDAP saves
160 \author Harald Falk <hf@doellken-weimar.de>
161 \version 1.00
162 \date 1.07.2005
163 Save objectClass for User in LDAP
165 */
166 function save()
167 {
168 plugin::save();
170 /* Write back to ldap */
171 $ldap= $this->config->get_ldap_link();
172 $ldap->cd($this->dn);
173 $this->cleanup();
174 $ldap->modify ($this->attrs);
176 /* Log last action */
177 if($this->initially_was_account){
178 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
179 }else{
180 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
181 }
183 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/intranet account with dn '%s' failed."),$this->dn));
185 /* Optionally execute a command after we're done */
186 $this->postcreate(array("uid" => $this->uid));
187 }
190 /* Return plugin informations for acl handling */
191 static function plInfo()
192 {
193 return (array(
194 "plShortName" => _("Intranet"),
195 "plDepends" => array("user"),
196 "plPriority" => 25, // Position in tabs
197 "plSection" => array("personal" => _("My account")),
198 "plCategory" => array("users"),
199 "plOptions" => array(),
201 "plDescription" => _("Intranet account settings")." : <u>"._("Connectivity addon")."</u>",
202 "plSelfModify" => TRUE,
204 "plProvidedAcls" => array()
205 ));
206 }
209 function multiple_save_object()
210 {
211 if (isset($_POST['connectivityTab'])){
212 plugin::multiple_save_object();
213 if(isset($_POST['use_intranet'])){
214 $this->multi_boxes[] = "intranet";
215 if (isset($_POST['intranet'])){
216 if (!$this->is_account && $_POST['intranet'] == "B"){
217 if($this->acl_is_createable()){
218 $this->is_account= TRUE;
219 }
220 }
221 } else {
222 if($this->acl_is_removeable()){
223 $this->is_account= FALSE;
224 }
225 }
226 }
227 }
228 }
230 function get_multi_edit_values()
231 {
232 $ret = plugin::get_multi_edit_values();
233 if(in_array("intranet",$this->multi_boxes)){
234 $ret['is_account'] = $this->is_account;
235 }
236 return($ret);
237 }
239 function set_multi_edit_values($values)
240 {
241 plugin::set_multi_edit_values($values);
242 if(isset($values['is_account'])){
243 $this->is_account = $values['is_account'];
244 }
245 }
247 function init_multiple_support($attrs,$all)
248 {
249 plugin::init_multiple_support($attrs,$all);
250 if(isset($attrs['objectClass']) && in_array("gosaIntranetAccount",$attrs['objectClass'])){
251 $this->is_account = TRUE;
252 }
253 }
254 }
256 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
257 ?>