X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=include%2Fclass_opengw.inc;h=44cc74d6768d9a9d3423419967bc5bfd5d52bffe;hb=bc5bb500ebfc41db2cbbc3263684d0233b978e47;hp=62ff5647319118a49c02d48d06afd169e5e1323d;hpb=3add590869fa80579f8bcc0658eb7ead1b514640;p=gosa.git diff --git a/include/class_opengw.inc b/include/class_opengw.inc old mode 100755 new mode 100644 index 62ff56473..44cc74d67 --- a/include/class_opengw.inc +++ b/include/class_opengw.inc @@ -18,7 +18,7 @@ class ogw{ var $MAY = array( "salutation","firstname","description","degree", "birthday","sex","street","zip","country","zipcity", "state","name1","value_string","number","db_status", - "object_version","is_locked","LocationTeamID","TeamIDis"); + "object_version","is_locked","LocationTeamID","TeamIDis","password"); var $LastError = ""; var $option = ""; @@ -42,8 +42,10 @@ class ogw{ } function SetInfos($infos) - { - $infos['name1'] = $infos['name']; + { + if(isset($infos['name'])) { + $infos['name1'] = $infos['name']; + } $this->info = $infos; } @@ -52,7 +54,7 @@ class ogw{ $ret = array(); $qry = "SELECT is_person,is_account,is_intra_account,is_extra_account, number,owner_id,object_version,company_id,template_user_id,is_locked, - name,firstname,description,salutation,login,degree,birthday,sex + name,firstname,description,salutation,login,degree,birthday,sex FROM person WHERE login='".$uid."';"; $res = $this->ogo->FetchAllRows($this->ogo->Query($qry)); $ret = $res[0]; @@ -99,12 +101,29 @@ class ogw{ if(($this->option == "EDIT")||($this->option=="ADD")){ /* Static variables */ - $this->info['is_person'] = 1; - $this->info['is_account'] = 1; - $this->info['is_intra_account'] = 1; - $this->info['is_extra_account'] = 0; - $this->info['owner_id'] = 10000; - $this->info['is_team'] = 0; + if(!isset($this->info['is_person'])){ + $this->info['is_person'] = 1; + } + + if(!isset($this->is_account)){ + $this->info['is_account'] = 1; + } + + if(!isset($this->info['is_intra_account'])){ + $this->info['is_intra_account'] = 1; + } + + if(!isset($this->info['is_extra_account'])){ + $this->info['is_extra_account'] = 0; + } + + if(!isset($this->info['owner_id'])){ + $this->info['owner_id'] = 10000; + } + + if(!isset($this->info['is_team'])){ + $this->info['is_team'] = 0; + } $this->InfoOK = $this->checkInfos(); @@ -126,7 +145,7 @@ class ogw{ $this->LastError="Can't edit entry, entry doesn't exists."; return(false); }else{ - $this->info['db_status'] = "edited"; + $this->info['db_status'] = "updated"; $this->info['object_version'] = $ist[0]['object_version']++; return($this->EDIT()); } @@ -220,7 +239,12 @@ class ogw{ $this->LastError(sprintf("Can't get company id for login %s",$this->info['login'])); return(false); }else{ + $company_id = $ist[0]['company_id']; + + $qry = "UPDATE person SET login='SKY".$company_id.$this->info['login']."', is_account=0, is_intra_account=0 WHERE company_id=".$company_id.";"; + $this->ogo->Query($qry); + /* $this->ogo->Query("DELETE FROM telephone WHERE company_id=".$company_id.";"); $this->ogo->Query("DELETE FROM address WHERE company_id=".$company_id.";"); $this->ogo->Query("DELETE FROM company_info WHERE company_id=".$company_id.";"); @@ -228,6 +252,7 @@ class ogw{ $this->ogo->Query("DELETE FROM company_assignment WHERE sub_company_id=".$company_id.";"); $this->ogo->Query("DELETE FROM person WHERE company_id=".$company_id.";"); $this->ogo->Query("DELETE FROM staff WHERE company_id=".$company_id.";"); + */ return(true); } } @@ -240,7 +265,7 @@ class ogw{ $arr = array( "company_id","object_version","owner_id","template_user_id", "is_person","is_account","is_intra_account","is_extra_account", "number","description","is_locked","login","name","name","firstname", - "salutation","degree","birthday","sex","db_status"); + "salutation","degree","birthday","sex","db_status","password"); $this->info['company_id'] = $this->ogo->gen_id(); $this->info['userID'] = "OGo".$this->info['company_id']; foreach($arr as $attr){ @@ -378,7 +403,7 @@ class ogw{ $arr = array( "company_id","object_version","owner_id", "template_user_id","is_person","is_account","is_intra_account", "is_extra_account","number","description","is_locked","login","name", - "firstname","salutation","degree","birthday","sex","db_status"); + "firstname","salutation","degree","birthday","sex","db_status","password"); $this->info['company_id'] = $ist[0]['company_id']; $this->info['userID'] = "OGo".$this->info['company_id']; foreach($arr as $attr){ @@ -491,16 +516,19 @@ class ogw{ (SELECT company_id FROM team WHERE is_location_team=1));"; $arr = array("company_assignment_id","company_id","sub_company_id","db_status"); - foreach($this->info['TeamIDis'] as $TeamID){ - $this->info['company_id'] = $TeamID; - $this->info['sub_company_id'] = $ist[0]['company_id']; - $this->info['company_assignment_id']= $this->ogo->gen_id(); - foreach($arr as $attr){ - $add_company_assignment[$attr] = $this->info[$attr]; - } - $QUERY[] = gen_syntax($add_company_assignment,"company_assignment","ADD",false); - } + if(is_array($this->info['TeamIDis'])){ + foreach($this->info['TeamIDis'] as $TeamID){ + $this->info['company_id'] = $TeamID; + $this->info['sub_company_id'] = $ist[0]['company_id']; + $this->info['company_assignment_id']= $this->ogo->gen_id(); + $add_company_assignment = array(); + foreach($arr as $attr){ + $add_company_assignment[$attr] = $this->info[$attr]; + } + $QUERY[] = gen_syntax($add_company_assignment,"company_assignment","ADD",false); + } + } $remove_all = false; foreach($QUERY as $q ){