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 }
71 if((!$this->ReadOnly) && ($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable())) {
72 $smarty->assign('gosaIntranetACL', "");
73 }else{
74 $smarty->assign('gosaIntranetACL', " disabled ");
75 }
77 $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
78 return ($display);
79 }
81 /*!
82 \brief Delete ext from User
83 \author Harald Falk <hf@doellken-weimar.de>
84 \version 1.00
85 \date 1.07.2005
86 Handles deletion of this object
87 */
88 function remove_from_parent()
89 {
90 if($this->acl_is_removeable()){
91 plugin::remove_from_parent();
92 $ldap= $this->config->get_ldap_link();
94 $ldap->cd($this->dn);
95 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
96 $this->attributes, "Save");
97 $this->cleanup();
98 $ldap->modify ($this->attrs);
100 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/intranet account with dn '%s' failed."),$this->dn));
102 /* Optionally execute a command after we're done */
103 $this->postremove();
104 }
105 }
108 /*!
109 \brief handles Post data
110 \author Harald Falk <hf@doellken-weimar.de>
111 \version 1.00
112 \date 1.07.2005
113 Save data to object
114 */
115 function save_object()
116 {
117 /* Do we need to flip is_account state? */
118 if (isset($_POST['connectivityTab'])){
119 if (isset($_POST['intranet'])){
120 if (!$this->is_account && $_POST['intranet'] == "B"){
121 if($this->acl_is_createable()){
122 $this->is_account= TRUE;
123 }
124 }
125 } else {
126 if($this->acl_is_removeable()){
127 $this->is_account= FALSE;
128 }
129 }
130 }
132 plugin::save_object();
133 if (isset($_POST["INTRANETStatus"])){
134 $this->INTRANETStatus = "disabled";
135 } else {
136 $this->INTRANETStatus = "enabled";
137 }
138 }
141 /*! \brief Handles LDAP saves
142 \author Harald Falk <hf@doellken-weimar.de>
143 \version 1.00
144 \date 1.07.2005
145 Save objectClass for User in LDAP
147 */
148 function save()
149 {
150 plugin::save();
152 /* Write back to ldap */
153 $ldap= $this->config->get_ldap_link();
154 $ldap->cd($this->dn);
155 $this->cleanup();
156 $ldap->modify ($this->attrs);
158 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/intranet account with dn '%s' failed."),$this->dn));
160 /* Optionally execute a command after we're done */
161 $this->postcreate();
162 }
165 /* Return plugin informations for acl handling */
166 function plInfo()
167 {
168 return (array(
169 "plShortName" => _("Intranet"),
170 "plDepends" => array("user"),
171 "plPriority" => 1, // Position in tabs
172 "plSection" => "personal", // This belongs to personal
173 "plCategory" => array("users"),
174 "plOptions" => array(),
176 "plDescription" => _("Intranet account settings"),
177 "plSelfModify" => TRUE,
179 "plProvidedAcls" => array()
180 ));
181 }
182 }
184 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
185 ?>