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");
23 /*! \brief Konstructor
25 \param $config The Config Object used to initialise plugin
26 \param $dn The DN of the currently edited entry
27 \author Harald Falk <hf@doellken-weimar.de>
28 \version 1.00
29 \date 1.07.2005
30 */
31 function intranetAccount ($config, $dn= NULL)
32 {
33 plugin::plugin ($config, $dn);
34 }
36 /*!
37 \brief General execution
38 \author Harald Falk <hf@doellken-weimar.de>
39 \version 1.00
40 \date 1.07.2005
42 Load smarty Template and assign needed smarty vars
43 */
46 function execute()
47 {
48 /* Call parent execute */
49 // plugin::execute();
51 $display= "";
53 $smarty= get_smarty();
55 if ($this->is_account){
56 $smarty->assign("intranetState", "checked");
57 $smarty->assign("wstate", "");
58 } else {
59 $smarty->assign("wstate", "disabled");
60 $smarty->assign("intranetState", "");
61 }
63 //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. )
64 if ($this->parent != NULL){
65 $smarty->assign("tabbed", 1);
66 }else{
67 $smarty->assign("tabbed", 0);
68 }
70 $smarty->assign('gosaIntranetACL', chkacl($this->acl, 'intranetAccount'));
72 $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
73 return ($display);
74 }
76 /*!
77 \brief Delete ext from User
78 \author Harald Falk <hf@doellken-weimar.de>
79 \version 1.00
80 \date 1.07.2005
81 Handles deletion of this object
82 */
83 function remove_from_parent()
84 {
85 if(chkacl($this->acl, 'intranetAccount') == ""){
86 plugin::remove_from_parent();
87 $ldap= $this->config->get_ldap_link();
89 $ldap->cd($this->dn);
90 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
91 $this->attributes, "Save");
92 $this->cleanup();
93 $ldap->modify ($this->attrs);
95 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/intranet account with dn '%s' failed."),$this->dn));
97 /* Optionally execute a command after we're done */
98 $this->postremove();
99 }
100 }
103 /*!
104 \brief handles Post data
105 \author Harald Falk <hf@doellken-weimar.de>
106 \version 1.00
107 \date 1.07.2005
108 Save data to object
109 */
110 function save_object()
111 {
112 /* Do we need to flip is_account state? */
113 if (isset($_POST['connectivityTab'])){
114 if (isset($_POST['intranet'])){
115 if (!$this->is_account && $_POST['intranet'] == "B"){
116 $this->is_account= TRUE;
117 }
118 } else {
119 $this->is_account= FALSE;
120 }
121 }
123 plugin::save_object();
124 if (isset($_POST["INTRANETStatus"])){
125 $this->INTRANETStatus = "disabled";
126 } else {
127 $this->INTRANETStatus = "enabled";
128 }
129 }
132 /*! \brief Handles LDAP saves
133 \author Harald Falk <hf@doellken-weimar.de>
134 \version 1.00
135 \date 1.07.2005
136 Save objectClass for User in LDAP
138 */
139 function save()
140 {
141 if(chkacl($this->acl, 'intranetAccount') == ""){
142 plugin::save();
144 /* Write back to ldap */
145 $ldap= $this->config->get_ldap_link();
146 $ldap->cd($this->dn);
147 $this->cleanup();
148 $ldap->modify ($this->attrs);
150 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/intranet account with dn '%s' failed."),$this->dn));
152 /* Optionally execute a command after we're done */
153 $this->postcreate();
154 }
155 }
158 /* Return pluign informations for acl handling
159 #FIXME This is only an enable/disable checkbox for this account, there is possibly a better solution available later */
160 function plInfo()
161 {
162 return (array(
163 "plDescription" => _("Intranet account settings"),
164 "plSelfModify" => TRUE,
165 "plDepends" => array("objectClass" => "gosaAccount"),
166 "gosaIntranetAccount" => "!!! FIME "._("GOsa intranet account")));
167 }
168 }
170 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
171 ?>