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 }
49 $smarty->assign('phpgwAccountACL', chkacl($this->acl, 'phpgwAccount'));
51 $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
52 return ($display);
53 }
55 function remove_from_parent()
56 {
57 if(chkacl($this->acl,"phpgwAccount") == ""){
58 /* Cancel if there's nothing to do here */
59 if (!$this->initially_was_account){
60 return;
61 }
63 plugin::remove_from_parent();
64 $ldap= $this->config->get_ldap_link();
66 $ldap->cd($this->dn);
67 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
68 $this->attributes, "Save");
69 $this->cleanup();
70 $ldap->modify ($this->attrs);
72 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPgw account with dn '%s' failed."),$this->dn));
74 /* Optionally execute a command after we're done */
75 $this->handle_post_events('remove');
76 }
77 }
80 /* Save data to object */
81 function save_object()
82 {
83 /* Do we need to flip is_account state? */
84 if (isset($_POST['connectivityTab'])){
85 if (isset($_POST['phpgw'])){
86 if (!$this->is_account && $_POST['phpgw'] == "B"){
87 $this->is_account= TRUE;
88 }
89 } else {
90 $this->is_account= FALSE;
91 }
92 }
94 plugin::save_object();
95 if (isset($_POST["phpgwStatus"])){
96 $this->phpgwStatus = "disabled";
97 } else {
98 $this->phpgwStatus = "enabled";
99 }
100 }
103 /* Save to LDAP */
104 function save()
105 {
106 if(chkacl($this->acl,"phpgwAccount") == ""){
107 plugin::save();
109 /* Write back to ldap */
110 $ldap= $this->config->get_ldap_link();
111 $ldap->cd($this->dn);
112 $this->cleanup();
113 $ldap->modify ($this->attrs);
115 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPgw account with dn '%s' failed."),$this->dn));
117 /* Optionally execute a command after we're done */
118 if ($this->initially_was_account == $this->is_account){
119 if ($this->is_modified){
120 $this->handle_post_events("mofify");
121 }
122 } else {
123 $this->handle_post_events("add");
124 }
125 }
126 }
129 function plInfo()
130 {
131 return (array( "plDescription" => _("Intranet account settings"),
132 "plSelfModify" => TRUE,
133 "plDepends" => array("objectClass" => "gosaAccount"),
134 "phpgwAccountExpires" =>"#FIXME not translated"._("phpgwAccountExpires"),
135 "phpgwAccountStatus" =>_("phpgwAccountStatus"),
136 "phpgwAccountType" =>_("phpgwAccountType")));
137 }
140 }
142 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
143 ?>