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");
16 var $ReadOnly = false;
18 var $uid = "";
20 function phpgwAccount ($config, $dn= NULL)
21 {
22 plugin::plugin ($config, $dn);
24 /* Setting uid to default */
25 if(isset($this->attrs['uid'][0])){
26 $this->uid = $this->attrs['uid'][0];
27 }
30 if($this->is_account){
31 @log::log("view","users/".get_class($this),$this->dn);
32 }
33 }
35 function execute()
36 {
37 /* Call parent execute */
38 // plugin::execute();
40 /* Show tab dialog headers */
41 $display= "";
43 /* Show main page */
44 $smarty= get_smarty();
46 /* Load attributes */
47 foreach($this->attributes as $val){
48 $smarty->assign("$val", $this->$val);
49 }
50 if ($this->is_account){
51 $smarty->assign("phpgwState", "checked");
52 } else {
53 $smarty->assign("phpgwState", "");
54 }
56 if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
57 $smarty->assign('phpgwAccountACL', "");
58 }else{
59 $smarty->assign('phpgwAccountACL', " disabled ");
60 }
62 $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
63 return ($display);
64 }
66 function remove_from_parent()
67 {
68 if($this->acl_is_removeable()){
69 /* Cancel if there's nothing to do here */
70 if (!$this->initially_was_account){
71 return;
72 }
74 plugin::remove_from_parent();
75 $ldap= $this->config->get_ldap_link();
77 $ldap->cd($this->dn);
78 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
79 $this->attributes, "Save");
80 $this->cleanup();
81 $ldap->modify ($this->attrs);
83 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPgw account with dn '%s' failed."),$this->dn));
85 @log::log("remove","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
87 /* Optionally execute a command after we're done */
88 $this->handle_post_events('remove',array("uid" => $this->uid));
89 }
90 }
93 /* Save data to object */
94 function save_object()
95 {
96 /* Do we need to flip is_account state? */
97 if (isset($_POST['connectivityTab'])){
98 if (isset($_POST['phpgw'])){
99 if (!$this->is_account && $_POST['phpgw'] == "B"){
100 if($this->acl_is_createable()){
101 $this->is_account= TRUE;
102 }
103 }
104 } else {
105 if($this->acl_is_removeable()){
106 $this->is_account= FALSE;
107 }
108 }
109 }
111 plugin::save_object();
112 if (isset($_POST["phpgwStatus"])){
113 $this->phpgwStatus = "disabled";
114 } else {
115 $this->phpgwStatus = "enabled";
116 }
117 }
120 /* Save to LDAP */
121 function save()
122 {
123 plugin::save();
125 /* Write back to ldap */
126 $ldap= $this->config->get_ldap_link();
127 $ldap->cd($this->dn);
128 $this->cleanup();
129 $ldap->modify ($this->attrs);
131 if($this->initially_was_account){
132 @log::log("modify","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
133 }else{
134 @log::log("create","users/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error());
135 }
137 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPgw account with dn '%s' failed."),$this->dn));
139 /* Optionally execute a command after we're done */
140 if ($this->initially_was_account == $this->is_account){
141 if ($this->is_modified){
142 $this->handle_post_events("modify",array("uid" => $this->uid));
143 }
144 } else {
145 $this->handle_post_events("add",array("uid" => $this->uid));
146 }
148 }
151 /* Return plugin informations for acl handling */
152 function plInfo()
153 {
154 return (array(
155 "plShortName" => _("PHP GW"),
156 "plDescription" => _("PHP GW account settings")." : <u>"._("Connectivity addon")."</u>",
157 "plSelfModify" => TRUE,
158 "plDepends" => array("user"),
159 "plPriority" => 24, // Position in tabs
160 "plSection" => array("personal" => _("My account")),
161 "plCategory" => array("users"),
162 "plOptions" => array(),
164 "plProvidedAcls" => array()
165 ));
166 }
167 }
169 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
170 ?>