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 }
29 }
31 function execute()
32 {
33 /* Call parent execute */
34 // plugin::execute();
36 /* Show tab dialog headers */
37 $display= "";
39 /* Show main page */
40 $smarty= get_smarty();
42 /* Load attributes */
43 foreach($this->attributes as $val){
44 $smarty->assign("$val", $this->$val);
45 }
46 if ($this->is_account){
47 $smarty->assign("phpgwState", "checked");
48 } else {
49 $smarty->assign("phpgwState", "");
50 }
52 if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
53 $smarty->assign('phpgwAccountACL', "");
54 }else{
55 $smarty->assign('phpgwAccountACL', " disabled ");
56 }
58 $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
59 return ($display);
60 }
62 function remove_from_parent()
63 {
64 if($this->acl_is_removeable()){
65 /* Cancel if there's nothing to do here */
66 if (!$this->initially_was_account){
67 return;
68 }
70 plugin::remove_from_parent();
71 $ldap= $this->config->get_ldap_link();
73 $ldap->cd($this->dn);
74 @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
75 $this->attributes, "Save");
76 $this->cleanup();
77 $ldap->modify ($this->attrs);
79 show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPgw account with dn '%s' failed."),$this->dn));
81 /* Optionally execute a command after we're done */
82 $this->handle_post_events('remove',array("uid" => $this->uid));
83 }
84 }
87 /* Save data to object */
88 function save_object()
89 {
90 /* Do we need to flip is_account state? */
91 if (isset($_POST['connectivityTab'])){
92 if (isset($_POST['phpgw'])){
93 if (!$this->is_account && $_POST['phpgw'] == "B"){
94 if($this->acl_is_createable()){
95 $this->is_account= TRUE;
96 }
97 }
98 } else {
99 if($this->acl_is_removeable()){
100 $this->is_account= FALSE;
101 }
102 }
103 }
105 plugin::save_object();
106 if (isset($_POST["phpgwStatus"])){
107 $this->phpgwStatus = "disabled";
108 } else {
109 $this->phpgwStatus = "enabled";
110 }
111 }
114 /* Save to LDAP */
115 function save()
116 {
117 plugin::save();
119 /* Write back to ldap */
120 $ldap= $this->config->get_ldap_link();
121 $ldap->cd($this->dn);
122 $this->cleanup();
123 $ldap->modify ($this->attrs);
125 show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPgw account with dn '%s' failed."),$this->dn));
127 /* Optionally execute a command after we're done */
128 if ($this->initially_was_account == $this->is_account){
129 if ($this->is_modified){
130 $this->handle_post_events("modify",array("uid" => $this->uid));
131 }
132 } else {
133 $this->handle_post_events("add",array("uid" => $this->uid));
134 }
135 }
138 /* Return plugin informations for acl handling */
139 function plInfo()
140 {
141 return (array(
142 "plShortName" => _("PHP GW"),
143 "plDescription" => _("PHP GW account settings")." : <u>"._("Connectivity addon")."</u>",
144 "plSelfModify" => TRUE,
145 "plDepends" => array("user"),
146 "plPriority" => 24, // Position in tabs
147 "plSection" => "personal", // This belongs to personal
148 "plCategory" => array("users"),
149 "plOptions" => array(),
151 "plProvidedAcls" => array()
152 ));
153 }
154 }
156 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
157 ?>