Code

Added execute methods
[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     /* Show tab dialog headers */
32     $display= "";
34     /* Show main page */
35     $smarty= get_smarty();
37     /* Load attributes */
38     foreach($this->attributes as $val){
39       $smarty->assign("$val", $this->$val);
40       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
41     }
42     if ($this->is_account){
43       $smarty->assign("phpgwState", "checked");
44     } else {
45       $smarty->assign("phpgwState", "");
46       $smarty->assign("fstate", "disabled");
47     }
49     if ($this->parent != NULL){
50       $smarty->assign("tabbed", 1);
51     }
53     $smarty->assign('phpgwAccountACL', chkacl($this->acl, 'phpgwAccount'));
55     $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
56     return ($display);
57   }
59   function remove_from_parent()
60   {
61     /* Cancel if there's nothing to do here */
62     if (!$this->initially_was_account){
63       return;
64     }
65     
66     plugin::remove_from_parent();
67     $ldap= $this->config->get_ldap_link();
69     $ldap->cd($this->dn);
70     @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
71         $this->attributes, "Save");
72     $ldap->modify($this->attrs);
73     show_ldap_error($ldap->get_error());
75     /* Optionally execute a command after we're done */
76     $this->handle_post_events('remove');
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           $this->is_account= TRUE;
88         }
89       } else {
90         $this->is_account= FALSE;
91       }
92     }
94     plugin::save_object();
95     if (isset($_POST["phpgwStatus"])){
96       $this->phpgwStatus = "disabled";
97     } else {
98       $this->phpgwStatus = "enabled";
99     }
100   }
103   /* Save to LDAP */
104   function save()
105   {
106     plugin::save();
108     /* Write back to ldap */
109     $ldap= $this->config->get_ldap_link();
110     $ldap->cd($this->dn);
111     $ldap->modify($this->attrs);
112     show_ldap_error($ldap->get_error());
114     /* Optionally execute a command after we're done */
115     if ($this->initially_was_account == $this->is_account){
116       if ($this->is_modified){
117         $this->handle_post_events("mofify");
118       }
119     } else {
120       $this->handle_post_events("add");
121     }
122   }
126 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
127 ?>