From 016327e7a9f82a5de12ea815a6ee19c8fcaeef73 Mon Sep 17 00:00:00 2001 From: hickert Date: Mon, 25 Jan 2010 14:08:50 +0000 Subject: [PATCH] first commit of repository service modifications .. -Will support the new style lists soon git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15282 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../repository/class_divListRepositories.inc | 104 +++----- .../repository/class_filterServerService.inc | 29 +++ .../repository/class_servRepository.inc | 228 +++++++++--------- .../services/repository/repository-filter.tpl | 8 + .../services/repository/repository-filter.xml | 22 ++ .../services/repository/repository-list.tpl | 31 +++ .../services/repository/repository-list.xml | 103 ++++++++ .../services/repository/servRepository.tpl | 1 - 8 files changed, 337 insertions(+), 189 deletions(-) create mode 100644 gosa-plugins/fai/admin/systems/services/repository/class_filterServerService.inc create mode 100644 gosa-plugins/fai/admin/systems/services/repository/repository-filter.tpl create mode 100644 gosa-plugins/fai/admin/systems/services/repository/repository-filter.xml create mode 100644 gosa-plugins/fai/admin/systems/services/repository/repository-list.tpl create mode 100644 gosa-plugins/fai/admin/systems/services/repository/repository-list.xml diff --git a/gosa-plugins/fai/admin/systems/services/repository/class_divListRepositories.inc b/gosa-plugins/fai/admin/systems/services/repository/class_divListRepositories.inc index c1e8c4328..96cc1b6a5 100644 --- a/gosa-plugins/fai/admin/systems/services/repository/class_divListRepositories.inc +++ b/gosa-plugins/fai/admin/systems/services/repository/class_divListRepositories.inc @@ -1,83 +1,45 @@ AddCheckBox */ - var $parent ; - var $ui ; + + protected $skipFooter = TRUE; + protected $skipHeader = TRUE; + protected $parent = NULL; - var $regex ="*"; - - function divListRepository ($config,$parent) - { - MultiSelectWindow::MultiSelectWindow($config,"Repository", "server"); - - $this->parent = $parent; - $this->ui = get_userinfo(); - - $this->SetTitle("repositories"); - $this->SetSummary(_("List of configured repositories")); - $this->SetInformation(_("This menu allows you to create, delete and edit repository settings.")); - $this->EnableCloseButton(FALSE); - $this->EnableSaveButton(FALSE); - $this->AddHeader(array("string"=>_("Release"),"attach"=>"style='width:80px;'")); - $this->AddHeader(array("string"=>_("Sections"))); - $this->AddHeader(array("string"=>_("Options"),"attach"=>"style='border-right:0px;width:55px;'")); - $this->AddRegex("regex",_("Regular expression for matching object names"),"*",TRUE); - $this->EnableAplhabet(TRUE); - } - - function GenHeader() + function __construct($config, $parent) { - if($this->parent->acl_is_createable()){ - $this->SetListHeader(""); - } + $this->ui = get_userinfo(); + $this->parent = $parent; + + // Set storage points - We do not have any - We just create a fake list which lists all services + $this->storagePoints = array(); + + // Build filter +# if (session::global_is_set(get_class($this)."_filter")){ +# $filter= session::global_get(get_class($this)."_filter"); +# } else { + $filter = new filter(get_template_path("services/repository/repository-filter.xml", true)); + $filter->setObjectStorage($this->storagePoints); + # } + $this->setFilter($filter); + + // Build headpage + $headpage = new listing(get_template_path("services/repository/repository-list.xml", true)); + $headpage->setFilter($filter); + + parent::__construct($config, $this->ui, "repositories", $headpage); + $this->registerAction('edit', 'forwardToParent'); + $this->registerAction('remove', 'forwardToParent'); + $this->registerAction('new', 'forwardToParent'); } - function execute() + function forwardToParent($action, $target, $all) { - $this->ClearElementsList(); - $this->GenHeader(); - } - - function setEntries($list) - { - $link = "%s"; - $edit = " "; - - /* Hide delete icon, if delete is not allowed */ - if($this->parent->acl_is_removeable()){ - $delete = ""; - }else{ - $delete = " "; + if(!empty($action)){ + $tmp = $action."Entry"; + $this->parent->$tmp($action,$target,$all); } - - foreach($list as $name => $reps){ - - $str = " "; - if(preg_match("/".str_replace("*",".*",$this->regex)."/",$reps['Release'])){ - foreach($reps['Sections'] as $sec){ - $str.=$sec." "; - } - $this->AddElement(array( - array("string"=>sprintf($link,base64_encode($name),$name),"attach"=>"style='width:80px;'"), - array("string"=>sprintf($link,base64_encode($name),_("Sections")." :".$str)), - array("string"=>preg_replace("/%s/",base64_encode($name),$edit.$delete),"attach"=>"style='border-right:0px;width:55px;text- align:right;'") - )); - } - } - - } - - function Save() - { - MultiSelectWindow :: Save(); - } - - function save_object() - { - /* Save automatic created POSTs like regex, checkboxes */ - MultiSelectWindow :: save_object(); } } // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: diff --git a/gosa-plugins/fai/admin/systems/services/repository/class_filterServerService.inc b/gosa-plugins/fai/admin/systems/services/repository/class_filterServerService.inc new file mode 100644 index 000000000..e66224038 --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/class_filterServerService.inc @@ -0,0 +1,29 @@ + $entry){ + $entry['objectClass'] = array('FAKE_OC_FaiRepository'); + $item = array('count' => count($entry)); + $item['dn'] = $key; + foreach($entry as $name => $value){ + $item[] = $name; + if(!is_array($value)) $value=array($value); + $value= array_values($value); + $value['count'] = count($value); + $item[$name] = $value; + + + } + $data[] = $item; + } + return($data); + } +} + +?> diff --git a/gosa-plugins/fai/admin/systems/services/repository/class_servRepository.inc b/gosa-plugins/fai/admin/systems/services/repository/class_servRepository.inc index ecf2d923a..86bf03545 100644 --- a/gosa-plugins/fai/admin/systems/services/repository/class_servRepository.inc +++ b/gosa-plugins/fai/admin/systems/services/repository/class_servRepository.inc @@ -1,5 +1,6 @@ divlist = new divListRepository($this->config,$this); } - function execute() + + function newEntry() { - /* Call parent execute */ - plugin::execute(); + $this->dialog = new servRepositorySetup($this->config,$this->dn); + $this->dialog->parent = $this; + } + - if($this->is_account && !$this->view_logged){ - $this->view_logged = TRUE; - new log("view","server/".get_class($this),$this->dn); - } + function removeEntry($action,$target,$all) + { + $once = true; + $value = preg_replace("/delete_/","",$name); + $value = base64_decode(preg_replace("/_.*$/","",$value)); - if(!$this->fai_activated){ - $str = "

"._("You can't use this plugin until FAI is activated.")."

"; - return $str; - } + $url = $this->repositories[$value]['Url']; + $release = $this->repositories[$value]['Release']; - /* Fill templating stuff */ - $smarty= get_smarty(); - $smarty->assign("is_createable",$this->acl_is_createable()); - $display= ""; + $ldap = $this->config->get_ldap_link(); + $ldap->cd ($this->config->current['BASE']); - /* Show tab dialog headers */ - /* - ADD / EDIT Repository - Dialog Handling - */ - $once = false; - if(isset($_POST['servRepository'])){ - foreach($_POST as $name => $value){ - - if(preg_match("/AddRepository/",$name) && $this->acl_is_createable()){ - $once = true; - $this->dialog = new servRepositorySetup($this->config,$this->dn); - $this->dialog->parent = $this; - } + $found= false; + $auto= false; + $obj= array(); + $aobj= array(); - if((preg_match("/^delete_/",$name)) && (!$once) && $this->acl_is_removeable()){ - $once = true; - $value = preg_replace("/delete_/","",$name); - $value = base64_decode(preg_replace("/_.*$/","",$value)); - - $url = $this->repositories[$value]['Url']; - $release = $this->repositories[$value]['Release']; - - $ldap = $this->config->get_ldap_link(); - $ldap->cd ($this->config->current['BASE']); - - $found= false; - $auto= false; - $obj= array(); - $aobj= array(); - - $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(|(FAIdebianMirror=".$url.")(FAIdebianMirror=auto)))",array("cn","FAIclass", "FAIdebianMirror")); - if ($ldap->count() != 0){ - while($attrs = $ldap->fetch()){ - if (!isset($attrs['FAIclass'])){ - continue; - } - foreach($attrs['FAIclass'] as $class){ - if(preg_match("/:".str_replace("/","\/",$release)."$/i",$class)){ - if (isset($attrs['FAIdebianMirror'][0]) && $attrs['FAIdebianMirror'][0] == "auto") { - $aobj[$ldap->getDN()]= $attrs['cn'][0]; - $auto= true; - } else { - $obj[$ldap->getDN()]= $attrs['cn'][0]; - $found= true; - } - } - } + $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(|(FAIdebianMirror=".$url.")(FAIdebianMirror=auto)))",array("cn","FAIclass", "FAIdebianMirror")); + if ($ldap->count() != 0){ + while($attrs = $ldap->fetch()){ + if (!isset($attrs['FAIclass'])){ + continue; + } + foreach($attrs['FAIclass'] as $class){ + if(preg_match("/:".str_replace("/","\/",$release)."$/i",$class)){ + if (isset($attrs['FAIdebianMirror'][0]) && $attrs['FAIdebianMirror'][0] == "auto") { + $aobj[$ldap->getDN()]= $attrs['cn'][0]; + $auto= true; + } else { + $obj[$ldap->getDN()]= $attrs['cn'][0]; + $found= true; } } - - // Look for automatic releases - if ($auto) { - $usage= 0; - $ldap->search("(&(objectClass=FAIrepositoryServer))",array("FAIrepository")); - if ($ldap->count() != 0){ - while($sattrs = $ldap->fetch()){ - if (!isset($sattrs['FAIrepository'])){ - continue; - } - for ($i= 0; $i < $sattrs['FAIrepository']['count']; $i++){ - $t= split('\|', $sattrs['FAIrepository'][$i]); - if($release == $t[2]){ - $usage++; - } - } - } - - // Are we the last one to provide this release? - if ($usage < 2) { - $obj= array_merge($obj, $aobj); - $found= true; - } - } + } + } + } + // Look for automatic releases + if ($auto) { + $usage= 0; + $ldap->search("(&(objectClass=FAIrepositoryServer))",array("FAIrepository")); + if ($ldap->count() != 0){ + while($sattrs = $ldap->fetch()){ + if (!isset($sattrs['FAIrepository'])){ + continue; } - - if ($found){ - msg_dialog::display(_("Error"), msgPool::stillInUse(_("FAI release"), msgPool::buildList($obj)), ERROR_DIALOG); - }else{ - if(isset($this->repositories[$value])){ - unset($this->repositories[$value]); + for ($i= 0; $i < $sattrs['FAIrepository']['count']; $i++){ + $t= split('\|', $sattrs['FAIrepository'][$i]); + if($release == $t[2]){ + $usage++; } } } - if((preg_match("/^edit_/",$name))&&(!$once)){ - $value = preg_replace("/edit_/","",$name); - $value = base64_decode(preg_replace("/_.$/","",$value)); - - 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->parent = $this; - } + // Are we the last one to provide this release? + if ($usage < 2) { + $obj= array_merge($obj, $aobj); + $found= true; } + } + } + + if ($found){ + msg_dialog::display(_("Error"), msgPool::stillInUse(_("FAI release"), msgPool::buildList($obj)), ERROR_DIALOG); + }else{ + if(isset($this->repositories[$value])){ + unset($this->repositories[$value]); } } - if((isset($_GET['act']))&&($_GET['act']=="open_repository")&&(isset($_GET['id']))){ - $obj = $this->repositories[base64_decode($_GET['id'])]; + } + + + function editEntry($action,$target,$all) + { + $value = preg_replace("/edit_/","",$name); + $value = base64_decode(preg_replace("/_.$/","",$value)); + + 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->parent = $this; } + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + $this->divlist->handleActions($this->divlist->detectPostActions()); + + if($this->is_account && !$this->view_logged){ + $this->view_logged = TRUE; + new log("view","server/".get_class($this),$this->dn); + } + + if(!$this->fai_activated){ + $str = "

"._("You can't use this plugin until FAI is activated.")."

"; + return $str; + } + + /* Fill templating stuff */ + $smarty= get_smarty(); + $smarty->assign("is_createable",$this->acl_is_createable()); + $display= ""; + if(isset($_POST['repository_setup_save']) && is_object($this->dialog)){ $this->dialog->save_object(); @@ -245,8 +236,6 @@ class servrepository extends goService /* Repository setup dialog handling /END */ - - $link = "%s"; $edit = " "; @@ -257,11 +246,10 @@ class servrepository extends goService $delete = " "; } - $this->divlist->execute(); - $this->divlist->setEntries($this->repositories); - $smarty->assign("Repositories",$this->divlist->Draw()); + session::set('RepositoryList', $this->repositories); + $str = $this->divlist->execute(); $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE,dirname(__FILE__))); - return($display); + return($str.$display); } @@ -269,9 +257,6 @@ class servrepository extends goService function save_object() { plugin::save_object(); - if(is_object($this->divlist)){ - $this->divlist->save_object(); - } } @@ -393,6 +378,7 @@ class servrepository extends goService } + function remove_from_parent() { goService::remove_from_parent(); @@ -423,7 +409,15 @@ class servrepository extends goService "Section" => _("Sections")) )); } -} + /*! \brief Returns the list of of services, active services. + * Used in the filter class for services. + * class_filterServerService.inc + */ + static function getRepositoryList() + { + return(session::get('RepositoryList')); + } +} // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: ?> diff --git a/gosa-plugins/fai/admin/systems/services/repository/repository-filter.tpl b/gosa-plugins/fai/admin/systems/services/repository/repository-filter.tpl new file mode 100644 index 000000000..16ddf733c --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/repository-filter.tpl @@ -0,0 +1,8 @@ +
+

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

+
+ +
+
diff --git a/gosa-plugins/fai/admin/systems/services/repository/repository-filter.xml b/gosa-plugins/fai/admin/systems/services/repository/repository-filter.xml new file mode 100644 index 000000000..3799b8ba9 --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/repository-filter.xml @@ -0,0 +1,22 @@ + + + + + server + + true + + + + + Repository + ... + dn + objectClass + name + Message + + auto + + + diff --git a/gosa-plugins/fai/admin/systems/services/repository/repository-list.tpl b/gosa-plugins/fai/admin/systems/services/repository/repository-list.tpl new file mode 100644 index 000000000..0b2cc7960 --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/repository-list.tpl @@ -0,0 +1,31 @@ + + + + + + + +
+
+

 {$HEADLINE} {$SIZELIMIT}

+
+ +
+
+ + +
{$ROOT} {$BACK} {$HOME} {$RELOAD} {$SEPARATOR}  {$ACTIONS}
+
+
+ +
+
+ + + + {$LIST} +
+ {$FILTER} +
+ + diff --git a/gosa-plugins/fai/admin/systems/services/repository/repository-list.xml b/gosa-plugins/fai/admin/systems/services/repository/repository-list.xml new file mode 100644 index 000000000..d1d950b0a --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/repository-list.xml @@ -0,0 +1,103 @@ + + + + + false + false + false + true + + + 1 + + + + FAKE_OC_FaiRepository + server + Repository + images/lits/new.png + + + + + + |||170px;r| + + + + Release + string + %{filter:link(row,dn,"%s",Release)} + true + + + + + Sections + string + %{filter:link(row,dn,"%s",Sections)} + true + + + + + %{filter:actions(dn,row,objectClass)} + + +
+ + + + + sub + images/lists/new.png + + + + new + entry + images/lists/new.png + + + + + + separator + + + + remove + entry + images/lists/trash.png + + + + + separator + + + + exporter + + + + + + + + edit + entry + images/lists/edit.png + + + + + remove + entry + images/lists/trash.png + + + + + +
diff --git a/gosa-plugins/fai/admin/systems/services/repository/servRepository.tpl b/gosa-plugins/fai/admin/systems/services/repository/servRepository.tpl index 0cf596753..c6bd73d80 100644 --- a/gosa-plugins/fai/admin/systems/services/repository/servRepository.tpl +++ b/gosa-plugins/fai/admin/systems/services/repository/servRepository.tpl @@ -1,4 +1,3 @@ -{$Repositories}

 

-- 2.30.2