Code

Made mail plugin w3c conform
[gosa.git] / plugins / personal / connectivity / class_phpgwAccount.inc
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   function phpgwAccount ($config, $dn= NULL)
19   {
20     plugin::plugin ($config, $dn);
21   }
23   function execute()
24   {
25         /* Call parent execute */
26 //      plugin::execute();
27   
28     /* Show tab dialog headers */
29     $display= "";
31     /* Show main page */
32     $smarty= get_smarty();
34     /* Load attributes */
35     foreach($this->attributes as $val){
36       $smarty->assign("$val", $this->$val);
37       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
38     }
39     if ($this->is_account){
40       $smarty->assign("phpgwState", "checked");
41     } else {
42       $smarty->assign("phpgwState", "");
43     }
45     if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
46       $smarty->assign('phpgwAccountACL', "");
47     }else{
48       $smarty->assign('phpgwAccountACL', " disabled ");
49     }
51     $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
52     return ($display);
53   }
55   function remove_from_parent()
56   {
57     if($this->acl_is_removeable()){
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           if($this->acl_is_createable()){
88             $this->is_account= TRUE;
89           }
90         }
91       } else {
92         if($this->acl_is_removeable()){
93           $this->is_account= FALSE;
94         }
95       }
96     }
98     plugin::save_object();
99     if (isset($_POST["phpgwStatus"])){
100       $this->phpgwStatus = "disabled";
101     } else {
102       $this->phpgwStatus = "enabled";
103     }
104   }
107   /* Save to LDAP */
108   function save()
109   {
110     plugin::save();
112     /* Write back to ldap */
113     $ldap= $this->config->get_ldap_link();
114     $ldap->cd($this->dn);
115     $this->cleanup();
116     $ldap->modify ($this->attrs); 
118     show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPgw account with dn '%s' failed."),$this->dn));
120     /* Optionally execute a command after we're done */
121     if ($this->initially_was_account == $this->is_account){
122       if ($this->is_modified){
123         $this->handle_post_events("mofify");
124       }
125     } else {
126       $this->handle_post_events("add");
127     }
128   }
131   /* Return plugin informations for acl handling */
132   function plInfo()
133   {
134     return (array(
135           "plShortName"     => _("PHP GW"),
136           "plDescription"   => _("PHP GW account settings"),
137           "plSelfModify"    => TRUE,
138           "plDepends"       => array("user"),
139           "plPriority"      => 5,                                 // Position in tabs
140           "plSection"       => "personal",                        // This belongs to personal
141           "plCategory"      => array("users"),
142           "plOptions"       => array(),
144           "plProvidedAcls"  => array()
145           ));
146   }
149 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
150 ?>