1 <?php
3 /*!
4 \author Harald Falk <hf@doellken-weimar.de>
5 \version 1.00
6 \date 1.07.2005
8 \brief Enables Apache authentification for Intranet through openldap with .htaccess files
9 */
11 class intranetAccount extends plugin
12 {
13 /*! Definitions */
14 var $plHeadline= "Intranet";
15 /*! Definitions */
16 var $plDescription= "This does something";
18 /* attribute list for save action */
19 var $attributes= array();
20 /* ObjectClasses list for save action */
21 var $objectclasses= array("gosaIntranetAccount");
22 var $ReadOnly = false;
24 /*! \brief Konstructor
26 \param $config The Config Object used to initialise plugin
27 \param $dn The DN of the currently edited entry
28 \author Harald Falk <hf@doellken-weimar.de>
29 \version 1.00
30 \date 1.07.2005
31 */
32 function intranetAccount ($config, $dn= NULL)
33 {
34 plugin::plugin ($config, $dn);
35 }
37 /*!
38 \brief General execution
39 \author Harald Falk <hf@doellken-weimar.de>
40 \version 1.00
41 \date 1.07.2005
43 Load smarty Template and assign needed smarty vars
44 */
47 function execute()
48 {
49 /* Call parent execute */
50 // plugin::execute();
52 $display= "";
54 $smarty= get_smarty();
56 if ($this->is_account){
57 $smarty->assign("intranetState", "checked");
58 $smarty->assign("wstate", "");
59 } else {
60 $smarty->assign("wstate", "disabled");
61 $smarty->assign("intranetState", "");
62 }
64 //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. )
65 if ($this->parent != NULL){
66 $smarty->assign("tabbed", 1);
67 }else{
68 $smarty->assign("tabbed", 0);
69 }
72 $smarty->assign('gosaIntranetACL', " disabled ");
73 if((!$this->ReadOnly) && ( ($this->is_account && $this->acl_is_removeable())
74 || (!$this->is_account && $this->acl_is_createable()))){
75 $smarty->assign('gosaIntranetACL', "");
76 }
78 $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
79 return ($display);
80 }
82 /*!
83 \brief Delete ext from User
84 \author Harald Falk <hf@doellken-weimar.de>
85 \version 1.00
86 \date 1.07.2005
87 Handles deletion of this object
88 */
89 function remove_from_parent()
90 {
91 if($this->acl_is_removeable()){
92 plugin::remove_from_parent();
93 $ldap= $this->config->get_ldap_link();
95 $ldap->cd($this->dn);
96 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
97 $this->attributes, "Save");
98 $this->cleanup();
99 $ldap->modify ($this->attrs);
101 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/intranet account with dn '%s' failed."),$this->dn));
103 /* Optionally execute a command after we're done */
104 $this->postremove();
105 }
106 }
109 /*!
110 \brief handles Post data
111 \author Harald Falk <hf@doellken-weimar.de>
112 \version 1.00
113 \date 1.07.2005
114 Save data to object
115 */
116 function save_object()
117 {
118 /* Do we need to flip is_account state? */
119 if (isset($_POST['connectivityTab'])){
120 if (isset($_POST['intranet'])){
121 if (!$this->is_account && $_POST['intranet'] == "B"){
122 if($this->acl_is_createable()){
123 $this->is_account= TRUE;
124 }
125 }
126 } else {
127 if($this->acl_is_removeable()){
128 $this->is_account= FALSE;
129 }
130 }
131 }
133 plugin::save_object();
134 if (isset($_POST["INTRANETStatus"])){
135 $this->INTRANETStatus = "disabled";
136 } else {
137 $this->INTRANETStatus = "enabled";
138 }
139 }
142 /*! \brief Handles LDAP saves
143 \author Harald Falk <hf@doellken-weimar.de>
144 \version 1.00
145 \date 1.07.2005
146 Save objectClass for User in LDAP
148 */
149 function save()
150 {
151 plugin::save();
153 /* Write back to ldap */
154 $ldap= $this->config->get_ldap_link();
155 $ldap->cd($this->dn);
156 $this->cleanup();
157 $ldap->modify ($this->attrs);
159 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/intranet account with dn '%s' failed."),$this->dn));
161 /* Optionally execute a command after we're done */
162 $this->postcreate();
163 }
166 /* Return plugin informations for acl handling */
167 function plInfo()
168 {
169 return (array(
170 "plShortName" => _("Intranet"),
171 "plDepends" => array("user"),
172 "plPriority" => 1, // Position in tabs
173 "plSection" => "personal", // This belongs to personal
174 "plCategory" => array("users"),
175 "plOptions" => array(),
177 "plDescription" => _("Intranet account settings"),
178 "plSelfModify" => TRUE,
180 "plProvidedAcls" => array()
181 ));
182 }
183 }
185 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
186 ?>