From 6a798c99f3cd57b6e98610975ac80dcd7e094a90 Mon Sep 17 00:00:00 2001 From: hickert Date: Thu, 8 Dec 2005 13:43:51 +0000 Subject: [PATCH] Added initialy repository setup git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2259 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/systems/class_servRepository.inc | 221 ++++++++++++++++++ .../systems/class_servRepositorySetup.inc | 153 ++++++++++++ plugins/admin/systems/servRepository.tpl | 48 ++++ plugins/admin/systems/servRepositorySetup.tpl | 46 ++++ 4 files changed, 468 insertions(+) create mode 100644 plugins/admin/systems/class_servRepository.inc create mode 100644 plugins/admin/systems/class_servRepositorySetup.inc create mode 100644 plugins/admin/systems/servRepository.tpl create mode 100644 plugins/admin/systems/servRepositorySetup.tpl diff --git a/plugins/admin/systems/class_servRepository.inc b/plugins/admin/systems/class_servRepository.inc new file mode 100644 index 000000000..a20513897 --- /dev/null +++ b/plugins/admin/systems/class_servRepository.inc @@ -0,0 +1,221 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ +// var $ignore_account = TRUE; + var $attributes = array("FAIrepository"); + var $objectclasses = array("FAIrepositoryServer"); + + /* Search filter */ + var $regex = "*"; + + /* Configurationdialog for repositories */ + var $dialog = NULL; + + /* Repositories */ + var $repositories = array(); + var $FAIrepository = array(); + + function servrepository ($config, $dn= NULL) + { + 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; + + } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + $display= ""; + + /* Smarty vars*/ + $smarty->assign("search_image", get_template_path('images/search.png')); + $smarty->assign("launchimage", get_template_path('images/small_filter.png')); + $smarty->assign("tree_image", get_template_path('images/tree.png')); + $smarty->assign("alphabet", generate_alphabet()); + $smarty->assign("apply", apply_filter()); + $smarty->assign("regex", $this->regex); + + + /* Do we need to flip is_account state? */ + if (isset($_POST['modify_state'])){ + $this->is_account= !$this->is_account; + } + + /* Show tab dialog headers */ + if ($this->is_account){ + $display= $this->show_header(_("Remove FAI repository extension."), + _("This server has FAI repository features enabled. You can disable them by clicking below.")); + } else { + $display= $this->show_header(_("Add FAI repository extension."), + _("This server has FAI repository features disabled. You can enable them by clicking below.")); + return ($display); + } + + /* + ADD / EDIT Repository + Dialog Handling + */ + + $once = false; + foreach($_POST as $name => $value){ + if((preg_match("/^edit_/",$name))&&(!$once)){ + if(isset($this->repositories[$value])){ + $once = true; + $obj = $this->repositories[$value]; + + /* to be able to detect if this was renamed */ + $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); + $this->dialog->acl = $this->acl; + } + + if(isset($_POST['repository_setup_save'])){ + $this->dialog->save_object(); + if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){ + print_red(_("This name is already in use.")); + }else + + if(count($this->dialog->check())!=0){ + foreach($this->dialog->check() as $msg){ + print_red($msg); + } + }else{ + $obj = $this->dialog->save(); + $this->dialog = NULL; + $this->is_dialog= false; + $this->repositories[$obj['Release']]=$obj; + } + } + + if(isset($_POST['repository_setup_cancel'])){ + $this->dialog=NULL; + $this->is_dialog = false; + } + + if($this->dialog != NULL){ + $this->dialog->save_object(); + $this->is_dialog = true; + return($this->dialog->execute()); + } + + /* + Repository setup dialog handling /END + */ + + $divlist = new divSelectBox("repositories"); + $divlist->setHeight(400); + + $edit = ""; + + foreach($this->repositories as $name => $reps){ + $str = " "; + foreach($reps['Sections'] as $sec){ + $str.=$sec." "; + } + + $divlist->AddEntry(array( + array("string"=>$name), + array("string"=>_("Sections")." :".$str), + array("string"=>preg_replace("/%s/",$name,$edit),"attach"=>"style='border-right:0px;'") + )); + } + + $smarty -> assign("Repositories",$divlist->DrawList()); + + $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE)); + return($display); + } + + function remove_from_parent() + { + /* This cannot be removed... */ + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + } + + + /* Check supplied data */ + function check() + { + $message= array(); + return ($message); + } + + + /* Save to LDAP */ + function save() + { + plugin::save(); + + $arr = array(); + foreach($this->repositories as $servername => $conf){ + $str = ""; + foreach($conf['Sections'] as $sec){ + $str.=$sec.","; + } + $str=preg_replace("/,$/","",$str); + $arr[]=$conf['Url']."|".$conf['ParentServer']."|".$conf['Release']."|".$str; + } + $this->attrs['FAIrepository'] = $arr; + + $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"); + } + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/class_servRepositorySetup.inc b/plugins/admin/systems/class_servRepositorySetup.inc new file mode 100644 index 000000000..2fa8a7cf6 --- /dev/null +++ b/plugins/admin/systems/class_servRepositorySetup.inc @@ -0,0 +1,153 @@ + "Eins ist toll", "zwei" => "Zwei ist noch besser"); + + /* attribute list for save action */ + var $ignore_account = TRUE; + var $attributes = array("Release","ParentServer","Url"); + var $objectclasses = array("whatever"); + + /* Attributes */ + 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']; + } + } + } + + function GetName() + { + return($this->Release); + } + + function is_new_name() + { + if(!$this->initialy_was){ + return(true); + }else{ + if($this->Release != $this->initialy_was){ + return(true); + } + } + return(false); + } + + + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + /* Fill templating stuff */ + $smarty= get_smarty(); + + if((isset($_POST['AddSection']))&&(isset($_POST['SectionName']))&&(!empty($_POST['SectionName']))){ + $this->Sections[$_POST['SectionName']]=$_POST['SectionName']; + } + + foreach($_POST as $name => $value){ + if(preg_match("/^delete_/",$name)){ + if(isset($this->Sections[$value])){ + unset($this->Sections[$value]); + } + } + } + + $divlist = new divSelectBox("servRepositorySetup"); + $divlist->setHeight("120"); + + $dellink = ""; + + foreach($this->Sections as $sec){ + $divlist->AddEntry(array( + array("string"=>$sec), + array("string"=>sprintf($dellink,$sec,$sec),"attach"=>"style='border-right:0px;width:20px;'") + )); + } + + $smarty->assign("Sections",$divlist->DrawList()); + + foreach($this->attributes as $attr){ + $smarty->assign($attr ,$this->$attr); + $smarty->assign($attr."ACL" ,chkacl($this->acl,$attr)); + } + + $smarty->assign("ParentServers" ,$this->getParentServers()); + $smarty->assign("ParentServerKeys",array_flip($this->getParentServers())); + + return($smarty->fetch(get_template_path('servRepositorySetup.tpl', TRUE))); + } + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + } + + + /* Check supplied data */ + function check() + { + $message= array(); + + if(!isset($this->Release)){ + $message[]=_("Please enter a value for 'release'."); + } + + return ($message); + } + + + /* Save to LDAP */ + function save() + { + $tmp = array(); + $tmp['ParentServer'] = $this->ParentServer; + $tmp['Url'] = $this->Url; + $tmp['Release'] = $this->Release; + $tmp['Sections'] = $this->Sections; + return($tmp); + } + + 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]; + } + $ret['none']=_("Master"); + return($ret); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/plugins/admin/systems/servRepository.tpl b/plugins/admin/systems/servRepository.tpl new file mode 100644 index 000000000..4453b44f5 --- /dev/null +++ b/plugins/admin/systems/servRepository.tpl @@ -0,0 +1,48 @@ + + + + + + +
+ +
+

+ {t}Repositories{/t} +

+
+ +
+

+ {$Repositories} + +

+
+ +
+
+

+ [F] + {t}Filters{/t} +

+
+ +
+ + {$alphabet} +
+ + + + + + +
+  {t}Display groups of user{/t} + + +
+ {$apply} +
+
diff --git a/plugins/admin/systems/servRepositorySetup.tpl b/plugins/admin/systems/servRepositorySetup.tpl new file mode 100644 index 000000000..fb39b0e66 --- /dev/null +++ b/plugins/admin/systems/servRepositorySetup.tpl @@ -0,0 +1,46 @@ +

 {t}Repository{/t}

+ + + + + + +
+ + + + + + + + + + + + + +
{t}Release{/t} : + + +
{t}Parent server{/t} : + + +
{t}Url{/t} : + + +
+
+ {t}Sections{/t} :
+ {$Sections} + + +
+

+ +   + +

+ + -- 2.30.2