fd58160e4bc1bc732e055e5802c8e83ef30c9a0e
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 /* Call parent execute */
30 plugin::execute();
32 /* Show tab dialog headers */
33 $display= "";
35 /* Show main page */
36 $smarty= get_smarty();
38 /* Load attributes */
39 foreach($this->attributes as $val){
40 $smarty->assign("$val", $this->$val);
41 $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
42 }
43 if ($this->is_account){
44 $smarty->assign("phpgwState", "checked");
45 } else {
46 $smarty->assign("phpgwState", "");
47 $smarty->assign("fstate", "disabled");
48 }
50 if ($this->parent != NULL){
51 $smarty->assign("tabbed", 1);
52 }
54 $smarty->assign('phpgwAccountACL', chkacl($this->acl, 'phpgwAccount'));
56 $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
57 return ($display);
58 }
60 function remove_from_parent()
61 {
62 /* Cancel if there's nothing to do here */
63 if (!$this->initially_was_account){
64 return;
65 }
67 plugin::remove_from_parent();
68 $ldap= $this->config->get_ldap_link();
70 $ldap->cd($this->dn);
71 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
72 $this->attributes, "Save");
73 $ldap->modify($this->attrs);
74 show_ldap_error($ldap->get_error());
76 /* Optionally execute a command after we're done */
77 $this->handle_post_events('remove');
78 }
81 /* Save data to object */
82 function save_object()
83 {
84 /* Do we need to flip is_account state? */
85 if (isset($_POST['connectivityTab'])){
86 if (isset($_POST['phpgw'])){
87 if (!$this->is_account && $_POST['phpgw'] == "B"){
88 $this->is_account= TRUE;
89 }
90 } else {
91 $this->is_account= FALSE;
92 }
93 }
95 plugin::save_object();
96 if (isset($_POST["phpgwStatus"])){
97 $this->phpgwStatus = "disabled";
98 } else {
99 $this->phpgwStatus = "enabled";
100 }
101 }
104 /* Save to LDAP */
105 function save()
106 {
107 plugin::save();
109 /* Write back to ldap */
110 $ldap= $this->config->get_ldap_link();
111 $ldap->cd($this->dn);
112 $ldap->modify($this->attrs);
113 show_ldap_error($ldap->get_error());
115 /* Optionally execute a command after we're done */
116 if ($this->initially_was_account == $this->is_account){
117 if ($this->is_modified){
118 $this->handle_post_events("mofify");
119 }
120 } else {
121 $this->handle_post_events("add");
122 }
123 }
125 }
127 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
128 ?>