Code

4e79a2f12b9a2b518a0c7834b88b431baa5892c2
[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   /* CLI vars */
9   var $cli_summary= "Manage users PHPGroupware account";
10   var $cli_description= "Some longer text\nfor help";
11   var $cli_parameters= array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
13   /* GW attributes */
14   var $phpgwAccountExpires= "-1";
15   var $phpgwAccountStatus= "A";
16   var $phpgwAccountType= "u";
18   /* attribute list for save action */
19   var $attributes= array("phpgwAccountExpires", "phpgwAccountStatus", "phpgwAccountType");
20   var $objectclasses= array("phpgwAccount");
22   function phpgwAccount ($config, $dn= NULL)
23   {
24     plugin::plugin ($config, $dn);
25   }
27   function execute()
28   {
29         /* Call parent execute */
30 //      plugin::execute();
31   
32     /* Show tab dialog headers */
33     $display= "";
35     /* Show main page */
36     $smarty= get_smarty();
38     /* Load attributes */
39     foreach($this->attributes as $val){
40       $smarty->assign("$val", $this->$val);
41       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
42     }
43     if ($this->is_account){
44       $smarty->assign("phpgwState", "checked");
45     } else {
46       $smarty->assign("phpgwState", "");
47     }
49     $smarty->assign('phpgwAccountACL', chkacl($this->acl, 'phpgwAccount'));
51     $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
52     return ($display);
53   }
55   function remove_from_parent()
56   {
57     if(chkacl($this->acl,"phpgwAccount") == ""){
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       $ldap->modify($this->attrs);
70       show_ldap_error($ldap->get_error());
72       /* Optionally execute a command after we're done */
73       $this->handle_post_events('remove');
74     }
75   }
78   /* Save data to object */
79   function save_object()
80   {
81     /* Do we need to flip is_account state? */
82     if (isset($_POST['connectivityTab'])){
83       if (isset($_POST['phpgw'])){
84         if (!$this->is_account && $_POST['phpgw'] == "B"){
85           $this->is_account= TRUE;
86         }
87       } else {
88         $this->is_account= FALSE;
89       }
90     }
92     plugin::save_object();
93     if (isset($_POST["phpgwStatus"])){
94       $this->phpgwStatus = "disabled";
95     } else {
96       $this->phpgwStatus = "enabled";
97     }
98   }
101   /* Save to LDAP */
102   function save()
103   {
104     if(chkacl($this->acl,"phpgwAccount") == ""){
105       plugin::save();
106       
107       /* Write back to ldap */
108       $ldap= $this->config->get_ldap_link();
109       $ldap->cd($this->dn);
110       $ldap->modify($this->attrs);
111       show_ldap_error($ldap->get_error());
113       /* Optionally execute a command after we're done */
114       if ($this->initially_was_account == $this->is_account){
115         if ($this->is_modified){
116           $this->handle_post_events("mofify");
117         }
118       } else {
119         $this->handle_post_events("add");
120       }
121     }
122   }
125 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
126 ?>