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