X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=plugins%2Fadmin%2Fsystems%2Fclass_glpiAccount.inc;h=9ff5019138a6059b2d135fd975a33db5767d911d;hb=8edf1b0390149b39682c7e02c394fec56940874d;hp=617b8f9b3081134e690b09f7c59e496f3da5f64e;hpb=3081d463fdc06a4b0be017fbaa1d026b8ac71704;p=gosa.git diff --git a/plugins/admin/systems/class_glpiAccount.inc b/plugins/admin/systems/class_glpiAccount.inc index 617b8f9b3..9ff501913 100644 --- a/plugins/admin/systems/class_glpiAccount.inc +++ b/plugins/admin/systems/class_glpiAccount.inc @@ -64,9 +64,9 @@ class glpiAccount extends plugin /* Contructor Sets default values and checks if we already have an existing glpi account */ - function glpiAccount ($config, $dn= NULL) + function glpiAccount ($config, $dn= NULL, $parent= NULL) { - plugin::plugin ($config, $dn); + plugin::plugin ($config, $dn, $parent); $this->ui= get_userinfo(); /* Abort class construction, if no db is defined */ @@ -492,7 +492,8 @@ class glpiAccount extends plugin if(!in_array($id,$users)){ /* If this user doesn't exists in glpi db, we must create him */ - $atr = $ldap->fetch($ldap->cat($id)); + $ldap->cat($id, array('cn', 'mail', 'telephoneNumber')); + $atr = $ldap->fetch(); $tmp = array(); $use = array( "cn" =>"name", "mail" =>"email", @@ -621,7 +622,8 @@ class glpiAccount extends plugin Assign name ... to smarty, if set */ if(isset($users[$this->contact_num])){ - $tr = $ldap->fetch($ldap->cat($users[$this->contact_num])); + $ldap->cat($users[$this->contact_num], array('givenName', 'sn', 'uid')); + $tr = $ldap->fetch(); $str = ""; if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } @@ -635,7 +637,8 @@ class glpiAccount extends plugin Assign name ... to smarty, if set */ if(isset($users[$this->tech_num])){ - $tr = $ldap->fetch($ldap->cat($users[$this->tech_num])); + $tr = $ldap->cat($users[$this->tech_num], array('givenName', 'sn', 'uid')); + $tr = $ldap->fetch(); $str = ""; if(isset($tr['givenName'][0])){ $str .= $tr['givenName'][0]." "; } if(isset($tr['sn'][0])) { $str .= $tr['sn'][0]." "; } @@ -652,9 +655,16 @@ class glpiAccount extends plugin function remove_from_parent() { - $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); - if($this->initialy_was_account){ - $this->handle->removeComputerInformations($this->dn); + if(!$this->initialy_was_account){ + return; + } + if(function_exists("mysql_pconnect")){ + $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + if($this->initialy_was_account){ + $this->handle->removeComputerInformations($this->dn); + } + }else{ + print_red(_("Can't remove glpi account, while mysql extension is missing.")); } } @@ -683,7 +693,7 @@ class glpiAccount extends plugin plugin::save_object(); foreach($this->attributes as $attrs){ if(isset($_POST[$attrs])){ - $this->$attrs = $_POST[$attrs]; + $this->$attrs = stripslashes ($_POST[$attrs]); } } } @@ -692,7 +702,8 @@ class glpiAccount extends plugin /* Check supplied data */ function check() { - $message= array(); + /* Call common method to give check the hook */ + $message= plugin::check(); // if($this->TechnicalResponsible == ""){ // $message[] = _("Please select a technical responsible person for this entry."); @@ -713,8 +724,10 @@ class glpiAccount extends plugin $attrs['name'] = $this->dn; unset($attrs['ID']); $this->handle = new glpiDB($this->data['SERVER'],$this->data['LOGIN'],$this->data['PASSWORD'],$this->data['DB']); + + /* check if we have to update, add */ if($this->initialy_was_account&&$this->is_account){ - $this->handle->updateComputerInformations($attrs,$this->dn); + $this->handle->updateComputerInformations($attrs,$this->orig_dn); }elseif($this->is_account){ $this->handle->addComputerInformations($attrs,$this->dn); }