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 /*! \brief Konstructor
30 \param $config The Config Object used to initialise plugin
31 \param $dn The DN of the currently edited entry
32 \author Harald Falk <hf@doellken-weimar.de>
33 \version 1.00
34 \date 1.07.2005
35 */
36 function intranetAccount ($config, $dn= NULL, $parent=NULL)
37 {
38 plugin::plugin ($config, $dn,$parent);
40 /* Setting uid to default */
41 if(isset($this->attrs['uid'][0])){
42 $this->uid = $this->attrs['uid'][0];
43 }
45 /* Log view */
46 if($this->is_account){
47 @log::log("view","users/".get_class($this),$this->dn);
48 }
49 }
51 /*!
52 \brief General execution
53 \author Harald Falk <hf@doellken-weimar.de>
54 \version 1.00
55 \date 1.07.2005
57 Load smarty Template and assign needed smarty vars
58 */
61 function execute()
62 {
63 /* Call parent execute */
64 // plugin::execute();
66 $display= "";
68 $smarty= get_smarty();
70 if ($this->is_account){
71 $smarty->assign("intranetState", "checked");
72 $smarty->assign("wstate", "");
73 } else {
74 $smarty->assign("wstate", "disabled");
75 $smarty->assign("intranetState", "");
76 }
78 //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. )
79 if ($this->parent != NULL){
80 $smarty->assign("tabbed", 1);
81 }else{
82 $smarty->assign("tabbed", 0);
83 }
86 $smarty->assign('gosaIntranetACL', " disabled ");
87 if((!$this->ReadOnly) && ( ($this->is_account && $this->acl_is_removeable())
88 || (!$this->is_account && $this->acl_is_createable()))){
89 $smarty->assign('gosaIntranetACL', "");
90 }
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 @log::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 @log::log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
179 }else{
180 @log::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 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 }
207 }
209 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
210 ?>