368ae95222066f60e69fccf38431c261bca3818e
1 <?php
2 class phpgwAccount extends plugin
3 {
4 /* Definitions */
5 var $plHeadline= "PHPGroupware";
6 var $plDescription= "This does something";
8 /* GW attributes */
9 var $phpgwAccountExpires= "-1";
10 var $phpgwAccountStatus= "A";
11 var $phpgwAccountType= "u";
13 /* attribute list for save action */
14 var $attributes= array("phpgwAccountExpires", "phpgwAccountStatus", "phpgwAccountType");
15 var $objectclasses= array("phpgwAccount");
17 function phpgwAccount ($config, $dn= NULL)
18 {
19 plugin::plugin ($config, $dn);
20 }
22 function execute()
23 {
24 /* Call parent execute */
25 // plugin::execute();
27 /* Show tab dialog headers */
28 $display= "";
30 /* Show main page */
31 $smarty= get_smarty();
33 /* Load attributes */
34 foreach($this->attributes as $val){
35 $smarty->assign("$val", $this->$val);
36 $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
37 }
38 if ($this->is_account){
39 $smarty->assign("phpgwState", "checked");
40 } else {
41 $smarty->assign("phpgwState", "");
42 }
44 $smarty->assign('phpgwAccountACL', chkacl($this->acl, 'phpgwAccount'));
46 $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
47 return ($display);
48 }
50 function remove_from_parent()
51 {
52 if(chkacl($this->acl,"phpgwAccount") == ""){
53 /* Cancel if there's nothing to do here */
54 if (!$this->initially_was_account){
55 return;
56 }
58 plugin::remove_from_parent();
59 $ldap= $this->config->get_ldap_link();
61 $ldap->cd($this->dn);
62 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
63 $this->attributes, "Save");
64 $this->cleanup();
65 $ldap->modify ($this->attrs);
67 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPgw account with dn '%s' failed."),$this->dn));
69 /* Optionally execute a command after we're done */
70 $this->handle_post_events('remove');
71 }
72 }
75 /* Save data to object */
76 function save_object()
77 {
78 /* Do we need to flip is_account state? */
79 if (isset($_POST['connectivityTab'])){
80 if (isset($_POST['phpgw'])){
81 if (!$this->is_account && $_POST['phpgw'] == "B"){
82 $this->is_account= TRUE;
83 }
84 } else {
85 $this->is_account= FALSE;
86 }
87 }
89 plugin::save_object();
90 if (isset($_POST["phpgwStatus"])){
91 $this->phpgwStatus = "disabled";
92 } else {
93 $this->phpgwStatus = "enabled";
94 }
95 }
98 /* Save to LDAP */
99 function save()
100 {
101 if(chkacl($this->acl,"phpgwAccount") == ""){
102 plugin::save();
104 /* Write back to ldap */
105 $ldap= $this->config->get_ldap_link();
106 $ldap->cd($this->dn);
107 $this->cleanup();
108 $ldap->modify ($this->attrs);
110 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPgw account with dn '%s' failed."),$this->dn));
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 }
121 }
124 /* Return plugin informations for acl handling
125 #FIME ACL attributes arn't translated yet */
126 function plInfo()
127 {
128 return (array( "plDescription" => _("Intranet account settings"),
129 "plSelfModify" => TRUE,
130 "plDepends" => array("objectClass" => "gosaAccount"),
131 "phpgwAccountExpires" =>"!!! FIXME "._("phpgwAccountExpires"),
132 "phpgwAccountStatus" =>_("phpgwAccountStatus"),
133 "phpgwAccountType" =>_("phpgwAccountType")));
134 }
137 }
139 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
140 ?>