1 <?php
2 class phpgwAccount extends plugin
3 {
4 /* Definitions */
5 var $plHeadline= "PHPGroupware";
6 var $plDescription= "This does something";
8 /* CLI vars */
9 var $cli_summary= "Manage users PHPGroupware account";
10 var $cli_description= "Some longer text\nfor help";
11 var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
13 /* GW attributes */
14 var $phpgwAccountExpires= "-1";
15 var $phpgwAccountStatus= "A";
16 var $phpgwAccountType= "u";
18 /* attribute list for save action */
19 var $attributes= array("phpgwAccountExpires", "phpgwAccountStatus", "phpgwAccountType");
20 var $objectclasses= array("phpgwAccount");
22 function phpgwAccount ($config, $dn= NULL)
23 {
24 plugin::plugin ($config, $dn);
25 }
27 function execute()
28 {
29 /* Show tab dialog headers */
30 $display= "";
32 /* Show main page */
33 $smarty= get_smarty();
35 /* Load attributes */
36 foreach($this->attributes as $val){
37 $smarty->assign("$val", $this->$val);
38 $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
39 }
40 if ($this->is_account){
41 $smarty->assign("phpgwState", "checked");
42 } else {
43 $smarty->assign("phpgwState", "");
44 $smarty->assign("fstate", "disabled");
45 }
47 if ($this->parent != NULL){
48 $smarty->assign("tabbed", 1);
49 }
51 $smarty->assign('phpgwAccountACL', chkacl($this->acl, 'phpgwAccount'));
53 $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
54 return ($display);
55 }
57 function remove_from_parent()
58 {
59 /* Cancel if there's nothing to do here */
60 if (!$this->initially_was_account){
61 return;
62 }
64 plugin::remove_from_parent();
65 $ldap= $this->config->get_ldap_link();
67 $ldap->cd($this->dn);
68 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
69 $this->attributes, "Save");
70 $ldap->modify($this->attrs);
71 show_ldap_error($ldap->get_error());
73 /* Optionally execute a command after we're done */
74 $this->handle_post_events('remove');
75 }
78 /* Save data to object */
79 function save_object()
80 {
81 /* Do we need to flip is_account state? */
82 if (isset($_POST['connectivityTab'])){
83 if (isset($_POST['phpgw'])){
84 if (!$this->is_account && $_POST['phpgw'] == "B"){
85 $this->is_account= TRUE;
86 }
87 } else {
88 $this->is_account= FALSE;
89 }
90 }
92 plugin::save_object();
93 if (isset($_POST["phpgwStatus"])){
94 $this->phpgwStatus = "disabled";
95 } else {
96 $this->phpgwStatus = "enabled";
97 }
98 }
101 /* Save to LDAP */
102 function save()
103 {
104 plugin::save();
106 /* Write back to ldap */
107 $ldap= $this->config->get_ldap_link();
108 $ldap->cd($this->dn);
109 $ldap->modify($this->attrs);
110 show_ldap_error($ldap->get_error());
112 /* Optionally execute a command after we're done */
113 if ($this->initially_was_account == $this->is_account){
114 if ($this->is_modified){
115 $this->handle_post_events("mofify");
116 }
117 } else {
118 $this->handle_post_events("add");
119 }
120 }
122 }
124 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
125 ?>