bc9d0267437f3029d4061b050a8d299151b60df0
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= "Intra net";
17 /*! Definitions */
18 var $plDescription= "Manage user properties of that belong to the internal network";
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 /* check if we are allowed to switch the checkbox.
90 */
91 $smarty->assign('gosaIntranetACL', preg_replace("/w/","",$this->getacl("",$this->ReadOnly)));
92 if(($this->acl_is_removeable() && $this->is_account) ||
93 ($this->acl_is_createable() && !$this->is_account)){
94 $smarty->assign('gosaIntranetACL', $this->getacl("",$this->ReadOnly));
95 }
97 $smarty->assign("use_intranet",in_array("intranet",$this->multi_boxes));
98 $smarty->assign("multiple_support",$this->multiple_support_active);
99 $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
100 return ($display);
101 }
103 /*!
104 \brief Delete ext from User
105 \author Harald Falk <hf@doellken-weimar.de>
106 \version 1.00
107 \date 1.07.2005
108 Handles deletion of this object
109 */
110 function remove_from_parent()
111 {
112 if($this->acl_is_removeable() && $this->initially_was_account){
113 plugin::remove_from_parent();
114 $ldap= $this->config->get_ldap_link();
116 $ldap->cd($this->dn);
117 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
118 $this->attributes, "Save");
119 $this->cleanup();
120 $ldap->modify ($this->attrs);
122 /* Log last action */
123 new log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
125 if (!$ldap->success()){
126 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_DEL, get_class()));
127 }
129 /* Optionally execute a command after we're done */
130 $this->handle_post_events('remove');
131 }
132 }
135 /*!
136 \brief handles Post data
137 \author Harald Falk <hf@doellken-weimar.de>
138 \version 1.00
139 \date 1.07.2005
140 Save data to object
141 */
142 function save_object()
143 {
144 /* Do we need to flip is_account state? */
145 if (isset($_POST['connectivityTab'])){
146 if (isset($_POST['intranet'])){
147 if (!$this->is_account && $_POST['intranet'] == "B"){
148 if($this->acl_is_createable()){
149 $this->is_account= TRUE;
150 }
151 }
152 } else {
153 if($this->acl_is_removeable()){
154 $this->is_account= FALSE;
155 }
156 }
157 }
159 plugin::save_object();
160 if (isset($_POST["INTRANETStatus"])){
161 $this->INTRANETStatus = "disabled";
162 } else {
163 $this->INTRANETStatus = "enabled";
164 }
165 }
168 /*! \brief Handles LDAP saves
169 \author Harald Falk <hf@doellken-weimar.de>
170 \version 1.00
171 \date 1.07.2005
172 Save objectClass for User in LDAP
174 */
175 function save()
176 {
177 plugin::save();
179 /* Write back to ldap */
180 $ldap= $this->config->get_ldap_link();
181 $ldap->cd($this->dn);
182 $this->cleanup();
183 $ldap->modify ($this->attrs);
185 /* Log last action */
186 if($this->initially_was_account){
187 new log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
188 $this->handle_post_events('modify');
189 }else{
190 new log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
191 $this->handle_post_events('add');
192 }
194 if (!$ldap->success()){
195 msg_dialog::display(_("LDAP error"), msgPool::ldaperror($ldap->get_error(), $this->dn, LDAP_MOD, get_class()));
196 }
198 }
201 /* Return plugin informations for acl handling */
202 static function plInfo()
203 {
204 return (array(
205 "plShortName" => _("Intra-net"),
206 "plDepends" => array("user"),
207 "plPriority" => 25, // Position in tabs
208 "plSection" => array("personal" => _("My account")),
209 "plCategory" => array("users"),
210 "plOptions" => array(),
212 "plRequirements"=> array(
213 'ldapSchema' => array('gosaIntranetAccount' => '>=2.7'),
214 'onFailureDisablePlugin' => array(get_class())
215 ),
217 "plDescription" => _("Intra-net account settings")." ("._("Connectivity add-on").")",
218 "plSelfModify" => TRUE,
220 "plProvidedAcls" => array()
221 ));
222 }
225 function multiple_save_object()
226 {
227 if (isset($_POST['connectivityTab'])){
228 plugin::multiple_save_object();
229 if(isset($_POST['use_intranet'])){
230 $this->multi_boxes[] = "intranet";
231 if (isset($_POST['intranet'])){
232 if (!$this->is_account && $_POST['intranet'] == "B"){
233 if($this->acl_is_createable()){
234 $this->is_account= TRUE;
235 }
236 }
237 } else {
238 if($this->acl_is_removeable()){
239 $this->is_account= FALSE;
240 }
241 }
242 }
243 }
244 }
246 function get_multi_edit_values()
247 {
248 $ret = plugin::get_multi_edit_values();
249 if(in_array("intranet",$this->multi_boxes)){
250 $ret['is_account'] = $this->is_account;
251 }
252 return($ret);
253 }
255 function set_multi_edit_values($values)
256 {
257 plugin::set_multi_edit_values($values);
258 if(isset($values['is_account'])){
259 $this->is_account = $values['is_account'];
260 }
261 }
263 function init_multiple_support($attrs,$all)
264 {
265 plugin::init_multiple_support($attrs,$all);
266 if(isset($attrs['objectClass']) && in_array("gosaIntranetAccount",$attrs['objectClass'])){
267 $this->is_account = TRUE;
268 }
269 }
270 }
272 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
273 ?>