Code

Removed acls from kiosk management dialog , w3c fixes for oxchange
[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     }
38     if ($this->is_account){
39       $smarty->assign("phpgwState", "checked");
40     } else {
41       $smarty->assign("phpgwState", "");
42     }
44     if((!$this->ReadOnly)&&(($this->is_account && $this->acl_is_removeable()) || (!$this->is_account && $this->acl_is_createable()))) {
45       $smarty->assign('phpgwAccountACL', "");
46     }else{
47       $smarty->assign('phpgwAccountACL', " disabled ");
48     }
50     $display.= $smarty->fetch (get_template_path('phpgw.tpl', TRUE, dirname(__FILE__)));
51     return ($display);
52   }
54   function remove_from_parent()
55   {
56     if($this->acl_is_removeable()){
57       /* Cancel if there's nothing to do here */
58       if (!$this->initially_was_account){
59         return;
60       }
62       plugin::remove_from_parent();
63       $ldap= $this->config->get_ldap_link();
65       $ldap->cd($this->dn);
66       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
67           $this->attributes, "Save");
68       $this->cleanup();
69       $ldap->modify ($this->attrs); 
71       show_ldap_error($ldap->get_error(), sprintf(_("Removing of user/PHPgw account with dn '%s' failed."),$this->dn));
73       /* Optionally execute a command after we're done */
74       $this->handle_post_events('remove');
75     }
76   }
79   /* Save data to object */
80   function save_object()
81   {
82     /* Do we need to flip is_account state? */
83     if (isset($_POST['connectivityTab'])){
84       if (isset($_POST['phpgw'])){
85         if (!$this->is_account && $_POST['phpgw'] == "B"){
86           if($this->acl_is_createable()){
87             $this->is_account= TRUE;
88           }
89         }
90       } else {
91         if($this->acl_is_removeable()){
92           $this->is_account= FALSE;
93         }
94       }
95     }
97     plugin::save_object();
98     if (isset($_POST["phpgwStatus"])){
99       $this->phpgwStatus = "disabled";
100     } else {
101       $this->phpgwStatus = "enabled";
102     }
103   }
106   /* Save to LDAP */
107   function save()
108   {
109     plugin::save();
111     /* Write back to ldap */
112     $ldap= $this->config->get_ldap_link();
113     $ldap->cd($this->dn);
114     $this->cleanup();
115     $ldap->modify ($this->attrs); 
117     show_ldap_error($ldap->get_error(), sprintf(_("Saving of user/PHPgw account with dn '%s' failed."),$this->dn));
119     /* Optionally execute a command after we're done */
120     if ($this->initially_was_account == $this->is_account){
121       if ($this->is_modified){
122         $this->handle_post_events("mofify");
123       }
124     } else {
125       $this->handle_post_events("add");
126     }
127   }
130   /* Return plugin informations for acl handling */
131   function plInfo()
132   {
133     return (array(
134           "plShortName"     => _("PHP GW"),
135           "plDescription"   => _("PHP GW account settings"),
136           "plSelfModify"    => TRUE,
137           "plDepends"       => array("user"),
138           "plPriority"      => 5,                                 // Position in tabs
139           "plSection"       => "personal",                        // This belongs to personal
140           "plCategory"      => array("users"),
141           "plOptions"       => array(),
143           "plProvidedAcls"  => array()
144           ));
145   }
148 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
149 ?>