1 <?php
3 /*
4 This code is part of GOsa (https://gosa.gonicus.de)
5 Copyright (C) 2005 Benoit Mortier
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
22 class glpiAccount extends plugin
23 {
24 /* Definitions */
25 var $plHeadline= "GLPI";
26 var $plDescription= "This does something";
28 /* CLI vars */
29 var $cli_summary= "Manage users gpli account";
30 var $cli_description= "Some longer text\nfor help";
31 var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
33 /* attribute list for save action */
34 var $attributes= array();
35 var $objectclasses= array("glpiAccount");
37 function glpiAccount ($config, $dn= NULL)
38 {
39 plugin::plugin ($config, $dn);
40 }
42 function execute()
43 {
44 /* Call parent execute */
45 //plugin::execute();
47 /* Show tab dialog headers */
48 $display= "";
50 /* Show main page */
51 $smarty= get_smarty();
53 if ($this->is_account){
54 $smarty->assign("glpiState", "checked");
55 } else {
56 $smarty->assign("glpiState", "");
57 $smarty->assign("wstate", "disabled");
58 }
60 if ($this->parent != NULL){
61 $smarty->assign("tabbed", 1);
62 }
64 $smarty->assign('glpiACL', chkacl($this->acl, 'gosaglpi'));
66 $display.= $smarty->fetch (get_template_path('glpi.tpl', TRUE, dirname(__FILE__)));
67 return ($display);
68 }
70 function remove_from_parent()
71 {
72 /* Cancel if there's nothing to do here */
73 if (!$this->initially_was_account){
74 return;
75 }
77 plugin::remove_from_parent();
78 $ldap= $this->config->get_ldap_link();
80 $ldap->cd($this->dn);
81 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
82 $this->attributes, "Save");
83 $ldap->modify($this->attrs);
84 show_ldap_error($ldap->get_error());
86 /* Optionally execute a command after we're done */
87 $this->handle_post_events('remove');
88 }
91 /* Save data to object */
92 function save_object()
93 {
94 /* Do we need to flip is_account state? */
95 if (isset($_POST['connectivityTab'])){
96 if (isset($_POST['glpi'])){
97 if (!$this->is_account && $_POST['glpi'] == "B"){
98 $this->is_account= TRUE;
99 }
100 } else {
101 $this->is_account= FALSE;
102 }
103 }
105 plugin::save_object();
106 if (isset($_POST["glpiStatus"])){
107 $this->glpiStatus = "disabled";
108 } else {
109 $this->glpiStatus = "enabled";
110 }
111 }
114 /* Save to LDAP */
115 function save()
116 {
117 plugin::save();
119 /* Write back to ldap */
120 $ldap= $this->config->get_ldap_link();
121 $ldap->cd($this->dn);
122 $ldap->modify($this->attrs);
123 show_ldap_error($ldap->get_error());
125 /* Optionally execute a command after we're done */
126 if ($this->initially_was_account == $this->is_account){
127 if ($this->is_modified){
128 $this->handle_post_events("mofify");
129 }
130 } else {
131 $this->handle_post_events("add");
132 }
134 }
136 }
138 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
139 ?>