Code

Fixed ogroup saving
[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   var $uid  = "";
24   function phpgwAccount ($config, $dn= NULL, $parent=NULL)
25   {
26     plugin::plugin ($config, $dn, $parent);
28     /* Setting uid to default */
29     if(isset($this->attrs['uid'][0])){
30       $this->uid = $this->attrs['uid'][0];
31     }
33   }
35   function execute()
36   {
37         /* Call parent execute */
38 //      plugin::execute();
39   
40     /* Show tab dialog headers */
41     $display= "";
43     /* Show main page */
44     $smarty= get_smarty();
46     /* Load attributes */
47     foreach($this->attributes as $val){
48       $smarty->assign("$val", $this->$val);
49       $smarty->assign($val."ACL", chkacl($this->acl, "$val"));
50     }
51     if ($this->is_account){
52       $smarty->assign("phpgwState", "checked");
53     } else {
54       $smarty->assign("phpgwState", "");
55     }
57     $smarty->assign('phpgwAccountACL', chkacl($this->acl, 'phpgwAccount'));
59     $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
60     return ($display);
61   }
63   function remove_from_parent()
64   {
65     if(chkacl($this->acl,"phpgwAccount") == ""){
66       /* Cancel if there's nothing to do here */
67       if (!$this->initially_was_account){
68         return;
69       }
71       plugin::remove_from_parent();
72       $ldap= $this->config->get_ldap_link();
74       $ldap->cd($this->dn);
75       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
76           $this->attributes, "Save");
77       $this->cleanup();
78       $ldap->modify ($this->attrs); 
80       show_ldap_error($ldap->get_error(), _("Removing PHPgw account failed"));
82       /* Optionally execute a command after we're done */
83       $this->handle_post_events('remove',array("uid" => $this->uid));
84     }
85   }
88   /* Save data to object */
89   function save_object()
90   {
91     /* Do we need to flip is_account state? */
92     if (isset($_POST['connectivityTab'])){
93       if (isset($_POST['phpgw'])){
94         if (!$this->is_account && $_POST['phpgw'] == "B"){
95           $this->is_account= TRUE;
96         }
97       } else {
98         $this->is_account= FALSE;
99       }
100     }
102     plugin::save_object();
103     if (isset($_POST["phpgwStatus"])){
104       $this->phpgwStatus = "disabled";
105     } else {
106       $this->phpgwStatus = "enabled";
107     }
108   }
111   /* Save to LDAP */
112   function save()
113   {
114     if(chkacl($this->acl,"phpgwAccount") == ""){
115       plugin::save();
116       
117       /* Write back to ldap */
118       $ldap= $this->config->get_ldap_link();
119       $ldap->cd($this->dn);
120       $this->cleanup();
121       $ldap->modify ($this->attrs); 
123       show_ldap_error($ldap->get_error(), _("Saving PHPgw account failed"));
125       /* Optionally execute a command after we're done */
126       if ($this->initially_was_account == $this->is_account){
127         if ($this->is_modified){
128           $this->handle_post_events("modify",array("uid" => $this->uid));
129         }
130       } else {
131         $this->handle_post_events("add",array("uid" => $this->uid));
132       }
133     }
134   }
137 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
138 ?>