Code

Added openGW class
[gosa.git] / plugins / personal / connectivity / class_opengwAccount.inc
1 <?php
3 class opengwAccount extends plugin
4 {
5   /* Definitions */
6   var $plHeadline       = "Opengroupware account";
7   var $plDescription    = "This does something";
9   /* CLI vars */
10   var $cli_summary      = "Manage users webdav account";
11   var $cli_description  = "Some longer text\nfor help";
12   var $cli_parameters   = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser");
14   /* attribute list for save action */
15   var $attributes= array();
16   var $objectclasses= array("gosaWebdavAccount");
18   var $handle   = NULL;
20   function opengwAccount ($config, $dn= NULL)
21   {
22     plugin::plugin ($config, $dn);
23     $this->handle = new ogw("ogo","","vserver-18","ogo");//username,$password,$host,$db
24     $info['login'] = $this->uid;
25     if($this->handle->CheckExistence()){
26       $this->info = $this->handle->GetInfo();
27     }else{
28       /* Generic attributes */
29       $info['salutation']         = $this->attrs['vocation'];
30       $info['name']               = $this->attrs['sn'];
31       $info['firstname']          = $this->attrs['givenName'];
32       $info['login']              = $this->attrs['uid'];
33       $info['description']        = $info['firstname']." ".$info['name'];
34       $info['degree']             = $this->attrs['academicTitle'];
35       $info['birthday']           = $this->attrs['dateOfBirth'];
36       
37       if($this->attrs['gender'] == "F"){
38         $info['sex']                = "female";
39       }else{
40         $info['sex']                = "male";
41       }
43       /* address settings */
44       $info['street']             = $this->attrs['street'];//"iweg 2";
45       $info['zip']                = $this->attrs['postalCode'];//"59821";
46 //      $info['country']            = $this->attrs[''];//"Arnbserg";
47       $info['zipcity']            = $info['zip']." ".$info['country'];
48 //      $info['state']              = $this->attrs[''];//"Germany";
50       /* the email address*/
51       $info['value_string']       = $this->attrs['mail'];
53       /* telephone number */
54       $info['number']             = $this->attrs['telephoneNumber'];
56       /* Selectable in GOsa */
57       $info['template_user_id']   = 10130;
58       $info['is_locked']          = 0;
59       $info['LocationTeamID']     = "";
60       $info['TeamIDis']           = array();
61     }
62     $this->info = $info;
63     $this->handle->SetInfos($info);
64   }
66   function execute()
67   {
68     /* Show tab dialog headers */
69     $display= "";
71     print_a($this->info);
73     /* Show main page */
74     $smarty= get_smarty();
76     if ($this->is_account){
77       $smarty->assign("is_account", "true");
78     } else {
79       $smarty->assign("is_account", "false");
80     }
81     $display.= $smarty->fetch (get_template_path('opengw.tpl', TRUE, dirname(__FILE__)));
82     return ($display);
83   }
85   function remove_from_parent()
86   {
87     if(chkacl($this->acl,"webdavAccount")==""){
88       /* Cancel if there's nothing to do here */
89       if (!$this->initially_was_account){
90         return;
91       }
93       plugin::remove_from_parent();
94       $ldap= $this->config->get_ldap_link();
96       $ldap->cd($this->dn);
97       @DEBUG (DEBUG_LDAP, __LINE__, __FUNCTION__, __FILE__,
98           $this->attributes, "Save");
99       $ldap->modify($this->attrs);
100       show_ldap_error($ldap->get_error());
102       /* Optionally execute a command after we're done */
103       $this->handle_post_events('remove');
104     }
105   }
108   /* Save data to object */
109   function save_object()
110   {
111     /* Do we need to flip is_account state? */
112     if (isset($_POST['connectivityTab'])){
113       if (isset($_POST['webdav'])){
114         if (!$this->is_account && $_POST['webdav'] == "B"){
115           $this->is_account= TRUE;
116         }
117       } else {
118         $this->is_account= FALSE;
119       }
120     }
122     plugin::save_object();
123     if (isset($_POST["WEBDAVStatus"])){
124       $this->WEBDAVStatus = "disabled";
125     } else {
126       $this->WEBDAVStatus = "enabled";
127     }
128   }
131   /* Save to LDAP */
132   function save()
133   {
134     if(chkacl($this->acl,"webdavAccount")==""){
135       plugin::save();
137       /* Write back to ldap */
138       $ldap= $this->config->get_ldap_link();
139       $ldap->cd($this->dn);
140       $ldap->modify($this->attrs);
141       show_ldap_error($ldap->get_error());
143       /* Optionally execute a command after we're done */
144       if ($this->initially_was_account == $this->is_account){
145         if ($this->is_modified){
146           $this->handle_post_events("mofify");
147         }
148       } else {
149         $this->handle_post_events("add");
150       }
151     }
152   }
156 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
157 ?>