From 38e36135b451936d249b671857b133a7d55b7360 Mon Sep 17 00:00:00 2001 From: hickert Date: Fri, 9 Dec 2005 06:11:51 +0000 Subject: [PATCH] Some changes repository plugin git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2263 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/class_servRepository.inc | 86 ++++++++++++++----- .../systems/class_servRepositorySetup.inc | 31 +++---- 2 files changed, 77 insertions(+), 40 deletions(-) diff --git a/plugins/admin/systems/class_servRepository.inc b/plugins/admin/systems/class_servRepository.inc index a20513897..21aa551ac 100644 --- a/plugins/admin/systems/class_servRepository.inc +++ b/plugins/admin/systems/class_servRepository.inc @@ -8,7 +8,7 @@ class servrepository extends plugin var $cli_parameters = array("eins" => "Eins ist toll", "zwei" => "Zwei ist noch besser"); /* attribute list for save action */ -// var $ignore_account = TRUE; + // var $ignore_account = TRUE; var $attributes = array("FAIrepository"); var $objectclasses = array("FAIrepositoryServer"); @@ -26,22 +26,26 @@ class servrepository extends plugin { plugin::plugin ($config, $dn); $this->repositories = array(); - for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){ - $tmp = split("\|",$this->attrs['FAIrepository'][$i]); - $tmp2 = array(); - $tmp3 = array(); - - $tmp2['ParentServer'] = $tmp[1]; - $tmp2['Url'] = $tmp[0]; - $tmp2['Release'] = $tmp[2]; - - $tmp3 = split(",",$tmp[3]); - - foreach($tmp3 as $sec){ - $tmp2['Sections'][$sec]=$sec; - } - $this->repositories[$tmp[2]]=$tmp2; - + if(isset($this->attrs['FAIrepository'])){ + for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){ + $tmp = split("\|",$this->attrs['FAIrepository'][$i]); + $tmp2 = array(); + $tmp3 = array(); + + $tmp2['ParentServer'] = $tmp[1]; + if(empty($tmp[1])){ + $tmp2['ParentServer'] = "none"; + } + $tmp2['Url'] = $tmp[0]; + $tmp2['Release'] = $tmp[2]; + + $tmp3 = split(",",$tmp[3]); + + foreach($tmp3 as $sec){ + $tmp2['Sections'][$sec]=$sec; + } + $this->repositories[$tmp[2]]=$tmp2; + } } } @@ -85,6 +89,13 @@ class servrepository extends plugin $once = false; foreach($_POST as $name => $value){ + if((preg_match("/^delete_/",$name))&&(!$once)){ + if(isset($this->repositories[$value])){ + $once = true; + unset($this->repositories[$value]); + } + } + if((preg_match("/^edit_/",$name))&&(!$once)){ if(isset($this->repositories[$value])){ $once = true; @@ -97,6 +108,13 @@ class servrepository extends plugin } } } + + if((isset($_GET['act']))&&($_GET['act']=="open")&&(isset($_GET['id']))){ + $obj = $this->repositories[$_GET['id']]; + $obj['initialy_was'] = $obj['Release']; + $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj); + $this->dialog->acl = $this->acl; + } if(isset($_POST['AddRepository'])){ $this->dialog = new servRepositorySetup($this->config,$this->dn); @@ -138,8 +156,9 @@ class servrepository extends plugin $divlist = new divSelectBox("repositories"); $divlist->setHeight(400); - - $edit = ""; + $link = "%s"; + $edit = " "; + $delete = ""; foreach($this->repositories as $name => $reps){ $str = " "; @@ -148,9 +167,9 @@ class servrepository extends plugin } $divlist->AddEntry(array( - array("string"=>$name), - array("string"=>_("Sections")." :".$str), - array("string"=>preg_replace("/%s/",$name,$edit),"attach"=>"style='border-right:0px;'") + array("string"=>preg_replace("/%s/",$name,$link)), + array("string"=>sprintf($link,$name,_("Sections")." :".$str)), + array("string"=>preg_replace("/%s/",$name,$edit.$delete),"attach"=>"style='border-right:0px;'") )); } @@ -162,7 +181,23 @@ class servrepository extends plugin function remove_from_parent() { - /* This cannot be removed... */ + plugin::remove_from_parent(); + $ldap= $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); + + $ldap->cat($this->dn); + + if($ldap->count()){ + $ldap->cd($this->dn); + $ldap->modify($this->attrs); + $this->handle_post_events("modify"); + }else{ + $ldap->cd ($this->config->current['BASE']); + $ldap->create_missing_trees($this->dn); + $ldap->cd($this->dn); + $ldap->add($this->attrs); + $this->handle_post_events("add"); + } } @@ -193,6 +228,11 @@ class servrepository extends plugin $str.=$sec.","; } $str=preg_replace("/,$/","",$str); + + if($conf['ParentServer']=="none"){ + $conf['ParentServer'] =""; + } + $arr[]=$conf['Url']."|".$conf['ParentServer']."|".$conf['Release']."|".$str; } $this->attrs['FAIrepository'] = $arr; diff --git a/plugins/admin/systems/class_servRepositorySetup.inc b/plugins/admin/systems/class_servRepositorySetup.inc index 2fa8a7cf6..3336616a0 100644 --- a/plugins/admin/systems/class_servRepositorySetup.inc +++ b/plugins/admin/systems/class_servRepositorySetup.inc @@ -13,24 +13,21 @@ class servRepositorySetup extends plugin var $objectclasses = array("whatever"); /* Attributes */ - var $Release; - var $ParentServer; - var $Url; - var $Sections=array(); - var $ParentServers; - + var $Release =""; + var $ParentServer =""; + var $Url =""; + var $Sections =array(); + var $ParentServers =""; var $initialy_was=false; function servRepositorySetup ($config, $dn= NULL,$data = false) { plugin::plugin ($config, $dn); if($data != false){ - $this->Sections= $data['Sections']; - $this->Url= $data['Url']; - $this->Release= $data['Release']; - $this->ParentServer= $data['ParentServer']; - if(isset($data['initialy_was'])){ - $this->initialy_was= $data['initialy_was']; + foreach(array("Sections","Release","Url","ParentServer","initialy_was") as $atr){ + if(isset($data[$atr])){ + $this->$atr = $data[$atr]; + } } } } @@ -111,10 +108,14 @@ class servRepositorySetup extends plugin { $message= array(); - if(!isset($this->Release)){ + if(empty($this->Release)){ $message[]=_("Please enter a value for 'release'."); } + if(empty($this->Url)){ + $message[] = _("Please specify a valid value for 'url'."); + } + return ($message); } @@ -132,13 +133,9 @@ class servRepositorySetup extends plugin function getParentServers() { - $ret = array(); - $ldap = $this->config->get_ldap_link(); - $ldap->cd($this->config->current['BASE']); - $ldap->search("(objectClass=FAIrepositoryServer)",array("*")); while($attr = $ldap->fetch()){ $ret[$attr['cn'][0]]= $attr['cn'][0]; -- 2.30.2