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 /*! CLI vars */
19 var $cli_summary= "Manage users Intranet account";
20 /*! CLI vars */
21 var $cli_description= "Some longer text\nfor help";
22 /*! CLI vars */
23 var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
25 /* attribute list for save action */
26 var $attributes= array();
27 /* ObjectClasses list for save action */
28 var $objectclasses= array("gosaIntranetAccount");
30 /*! \brief Konstructor
32 \param $config The Config Object used to initialise plugin
33 \param $dn The DN of the currently edited entry
34 \author Harald Falk <hf@doellken-weimar.de>
35 \version 1.00
36 \date 1.07.2005
37 */
38 function intranetAccount ($config, $dn= NULL)
39 {
40 plugin::plugin ($config, $dn);
41 }
43 /*!
44 \brief General execution
45 \author Harald Falk <hf@doellken-weimar.de>
46 \version 1.00
47 \date 1.07.2005
49 Load smarty Template and assign needed smarty vars
50 */
53 function execute()
54 {
55 /* Call parent execute */
56 plugin::execute();
58 $display= "";
60 $smarty= get_smarty();
62 if ($this->is_account){
63 $smarty->assign("intranetState", "checked");
64 $smarty->assign("wstate", "");
65 } else {
66 $smarty->assign("wstate", "disabled");
67 $smarty->assign("intranetState", "");
68 }
70 //! Ever assign vars to smarty in both cases, to avoid php errors (missing variable aso. )
71 if ($this->parent != NULL){
72 $smarty->assign("tabbed", 1);
73 }else{
74 $smarty->assign("tabbed", 0);
75 }
77 $smarty->assign('gosaIntranetACL', chkacl($this->acl, 'intranetAccount'));
79 $display.= $smarty->fetch (get_template_path('intranet.tpl', TRUE, dirname(__FILE__)));
80 return ($display);
81 }
83 /*!
84 \brief Delete ext from User
85 \author Harald Falk <hf@doellken-weimar.de>
86 \version 1.00
87 \date 1.07.2005
88 Handles deletion of this object
89 */
90 function remove_from_parent()
91 {
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 $ldap->modify($this->attrs);
99 show_ldap_error($ldap->get_error());
101 /* Optionally execute a command after we're done */
102 $this->postremove();
103 }
106 /*!
107 \brief handles Post data
108 \author Harald Falk <hf@doellken-weimar.de>
109 \version 1.00
110 \date 1.07.2005
111 Save data to object
112 */
113 function save_object()
114 {
115 /* Do we need to flip is_account state? */
116 if (isset($_POST['connectivityTab'])){
117 if (isset($_POST['intranet'])){
118 if (!$this->is_account && $_POST['intranet'] == "B"){
119 $this->is_account= TRUE;
120 }
121 } else {
122 $this->is_account= FALSE;
123 }
124 }
126 plugin::save_object();
127 if (isset($_POST["INTRANETStatus"])){
128 $this->INTRANETStatus = "disabled";
129 } else {
130 $this->INTRANETStatus = "enabled";
131 }
132 }
135 /*! \brief Handles LDAP saves
136 \author Harald Falk <hf@doellken-weimar.de>
137 \version 1.00
138 \date 1.07.2005
139 Save objectClass for User in LDAP
141 */
142 function save()
143 {
144 plugin::save();
146 /* Write back to ldap */
147 $ldap= $this->config->get_ldap_link();
148 $ldap->cd($this->dn);
149 $ldap->modify($this->attrs);
150 show_ldap_error($ldap->get_error());
152 /* Optionally execute a command after we're done */
153 $this->postcreate();
154 }
156 }
158 ?>