From: hickert Date: Mon, 7 Jul 2008 14:01:48 +0000 (+0000) Subject: Moved repository plugin from 'goto' to 'fai'.. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=35fb647ad688e3c387c3789d35aaaa2958ddb5b6;p=gosa.git Moved repository plugin from 'goto' to 'fai'.. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11547 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/fai/admin/systems/services/repository/class_divListRepositories.inc b/gosa-plugins/fai/admin/systems/services/repository/class_divListRepositories.inc new file mode 100644 index 000000000..19a1e5757 --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/class_divListRepositories.inc @@ -0,0 +1,84 @@ +AddCheckBox */ + var $parent ; + var $ui ; + + 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() + { + if($this->parent->acl_is_createable()){ + $this->SetListHeader(""); + } + } + + function execute() + { + $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 = " "; + } + + 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_servRepository.inc b/gosa-plugins/fai/admin/systems/services/repository/class_servRepository.inc new file mode 100644 index 000000000..565501bc0 --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/class_servRepository.inc @@ -0,0 +1,367 @@ +DisplayName = _("Repository service"); + + /* Skip this if fai is deactivated */ + $tmp= $this->config->search("faiManagement", "CLASS",array('menu','tabs')); + if(!empty($tmp)){ + $this->fai_activated = TRUE; + }else{ + return; + } + + $this->repositories = array(); + if(isset($this->attrs['FAIrepository'])){ + for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){ + $tmp = split("\|",$this->attrs['FAIrepository'][$i]); + $tmp2 = array(); + $tmp3 = array(); + + if(isset($tmp[1])){ + $tmp2['ParentServer'] = $tmp[1]; + if(empty($tmp[1])){ + $tmp2['ParentServer'] = "none"; + } + }else{ + $tmp2['ParentServer'] = "none"; + } + + if(isset($tmp[0])){ + $tmp2['Url'] = $tmp[0]; + }else{ + $tmp2['Url'] = ""; + } + + if(isset($tmp[2])){ + $tmp2['Release'] = $tmp[2]; + }else{ + $tmp2['Release'] = ""; + } + + if(isset($tmp[3])){ + $tmp3 = split(",",$tmp[3]); + foreach($tmp3 as $sec){ + $tmp2['Sections'][$sec]=$sec; + } + }else{ + $tmp['Section']=array(); + } + + $this->repositories[$tmp[2]]=$tmp2; + } + } + + + /* Create divlist */ + $this->divlist = new divListRepository($this->config,$this); + } + + function execute() + { + /* Call parent execute */ + plugin::execute(); + + 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= ""; + + /* 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; + } + + 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']); + + $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass")); + if ($ldap->count() != 0){ + $obj= array(); + $found= false; + while($attrs = $ldap->fetch()){ + foreach($attrs['FAIclass'] as $class){ + if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){ + $obj[$ldap->getDN()]= $attrs['cn'][0]; + $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((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; + } + } + } + } + if((isset($_GET['act']))&&($_GET['act']=="open_repository")&&(isset($_GET['id']))){ + $obj = $this->repositories[base64_decode($_GET['id'])]; + $obj['initialy_was'] = $obj['Release']; + $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj); + $this->dialog->parent = $this; + } + + if(isset($_POST['repository_setup_save']) && is_object($this->dialog)){ + $this->dialog->save_object(); + if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){ + msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG); + }else + + if(count($this->dialog->check())!=0){ + foreach($this->dialog->check() as $msg){ + msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); + } + }else{ + $obj = $this->dialog->save(); + if($this->dialog->is_new_name()){ + $oldname = $this->dialog->initialy_was; + $this->repositories[$obj['Release']]=$obj; + unset($this->repositories[$oldname]); + }else{ + $this->repositories[$obj['Release']]=$obj; + } + $this->dialog = FALSE; + $this->is_dialog= false; + } + } + + if(isset($_POST['repository_setup_cancel'])){ + $this->dialog=FALSE; + $this->is_dialog = false; + } + + if(is_object($this->dialog)){ + $this->dialog->save_object(); + $this->is_dialog = true; + return($this->dialog->execute()); + } + + /* + Repository setup dialog handling /END + */ + + + $link = "%s"; + $edit = " "; + + /* Hide delete icon, if delete is not allowed */ + if($this->acl_is_removeable()){ + $delete = ""; + }else{ + $delete = " "; + } + + $this->divlist->execute(); + $this->divlist->setEntries($this->repositories); + $smarty->assign("Repositories",$this->divlist->Draw()); + $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE,dirname(__FILE__))); + return($display); + } + + + /* Save data to object */ + function save_object() + { + plugin::save_object(); + if(is_object($this->divlist)){ + $this->divlist->save_object(); + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + return ($message); + } + + + /* Save to LDAP */ + function save() + { + if(!$this->fai_activated) return; + + plugin::save(); + + $arr = array(); + foreach($this->repositories as $servername => $conf){ + $str = ""; + foreach($conf['Sections'] as $sec){ + $str.=$sec.","; + } + $str=preg_replace("/,$/","",$str); + + if($conf['ParentServer']=="none"){ + $conf['ParentServer'] =""; + } + + $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, array('dn')); + + if($ldap->count()){ + $ldap->cd($this->dn); + $this->cleanup(); + $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"); + } + + # If there were changes, just tell the server to reload information + if(count($this->attrs)){ + $this->trigger_si_fai_server_reload(); + } + + if($this->initially_was_account){ + new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + }else{ + new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); + } + } + + + function getListEntry() + { + $fields = goService::getListEntry(); + $fields['Message'] = _("Repository service"); + $fields['AllowEdit'] = true; + $fields['AllowStart'] = $fields['AllowStop'] = $fields['AllowRestart'] = false; + return($fields); + } + + + function trigger_si_fai_server_reload() + { + /* Reload GOsa si FAI DB/cache + */ + if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){ + $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT); + if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_server_db'])){ + $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_server_db']; + $tmp = new $evt['CLASS_NAME']($this->config); + $tmp->set_type(TRIGGERED_EVENT); + $tmp->add_targets(array("GOsa")); + $o_queue = new gosaSupportDaemon(); + if(!$o_queue->append($tmp)){ + msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG); + } + } + } + } + + + function remove_from_parent() + { + goService::remove_from_parent(); + $this->trigger_si_fai_server_reload(); + } + + /* Return plugin informations for acl handling */ + static function plInfo() + { + return (array( + "plShortName" => _("Repository"), + "plDescription" => _("Repository service")." ("._("Services").")", + "plSelfModify" => FALSE, + "plDepends" => array(), + "plPriority" => 84, + "plSection" => array("administration"), + "plCategory" => array("server"), + + "plProvidedAcls"=> array( + "cn" => _("Name"), + "start" => _("Start"), + "stop" => _("Stop"), + "restart" => _("Restart"), + "Release" => _("Releases"), + "Section" => _("Sections"), + "ParentServer" => _("Parent server"), + "Url" => _("Url")) + )); + } +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/fai/admin/systems/services/repository/class_servRepositorySetup.inc b/gosa-plugins/fai/admin/systems/services/repository/class_servRepositorySetup.inc new file mode 100644 index 000000000..ad7ee735b --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/class_servRepositorySetup.inc @@ -0,0 +1,218 @@ +$atr = $data[$atr]; + } + } + } + } + + 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']))){ + + /* Replace multiple spaces with a single, and cut of white spaces (trim)*/ + $val = preg_replace("/\ \ * /" , " ", trim($_POST['SectionName'])); + + /* check if there are more than one entry given ( "section1 section2 )*/ + if(preg_match("/ /",$val)){ + + /* Generate list of new section names */ + $vals = split(" ",$val); + + /* Add new entries */ + foreach($vals as $entry){ + $entry = trim($entry); + $this->Sections[$entry]=$entry; + } + }else{ + $this->Sections[$val]=$val; + } + } + + foreach($_POST as $name => $value){ + if(preg_match("/^delete_/",$name)){ + + $val = preg_replace("/^delete_/","",$name); + $val = base64_decode(preg_replace("/_.*$/","",$val)); + + if(isset($this->Sections[$val])){ + unset($this->Sections[$val]); + } + } + } + + $divlist = new divSelectBox("servRepositorySetup"); + $divlist->setHeight("220"); + + $dellink = ""; + + foreach($this->Sections as $sec){ + $divlist->AddEntry(array( + array("string"=>$sec), + array("string"=>sprintf($dellink,base64_encode($sec),$sec),"attach"=>"style='border-right:0px;width:20px;'") + )); + } + + $smarty->assign("Sections",$divlist->DrawList()); + + /* Get && assign acls */ + $tmp = $this->parent->plInfo(); + foreach($tmp['plProvidedAcls'] as $name => $translated){ + $smarty->assign($name."ACL",$this->parent->getacl($name)); + } + + /* Assign values */ + foreach($this->attributes as $attr){ + $smarty->assign($attr ,$this->$attr); + } + + $tmp = $this->getParentServers(); + $smarty->assign("ParentServers" ,$tmp); + $smarty->assign("ParentServerKeys",array_flip($tmp)); + + return($smarty->fetch(get_template_path('servRepositorySetup.tpl', TRUE,dirname(__FILE__)))); + } + + /* Save data to object */ + function save_object() + { + if(isset($_POST['servRepositorySetup_Posted'])) { + + foreach($this->attributes as $attr){ + if(($this->parent->acl_is_writeable($attr)) && (isset($_POST[$attr]))){ + $this->$attr = $_POST[$attr]; + } + } + } + } + + + /* Check supplied data */ + function check() + { + /* Call common method to give check the hook */ + $message= plugin::check(); + + if(empty($this->Release)){ + $message[]= msgPool::required(_("Release")); + } + + if(empty($this->Url)){ + $message[] = msgPool::required(_("Url")); + } + + 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()){ + if($attr['cn'][0] == $this->cn) continue; + $ret[$attr['cn'][0]]= $attr['cn'][0]; + } + + $ret = array_merge($ret,$this->GetHookElements()); + + $ret['none']= " "; + asort($ret); + return($ret); + } + + /* this funtions calls a defined hook + and parses all additional serverdata + */ + function GetHookElements() + { + $ret = array(); + $cmd = $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs')); + if(!empty($cmd)){ + $res = shell_exec($cmd); + $res2 = trim($res); + if(!$res || empty($res2)){ + msg_dialog::display(_("Error"), msgPool::cmdexecfailed("REPOSITORY_HOOK", $cmd, _("Repository service")), ERROR_DIALOG); + }else{ + $tmp = split("\n",$res); + foreach($tmp as $hook){ + /* skip empty */ + if(empty($hook)) continue; + + if(preg_match("/;/",$hook)){ + $hookinfo = split(";",$hook); + $ret[$hookinfo[0]] = $hookinfo[0]; + }else{ + $ret[$hook] = $hook; + } + } + } + } + return($ret); + } + +} + +// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: +?> diff --git a/gosa-plugins/fai/admin/systems/services/repository/servRepository.tpl b/gosa-plugins/fai/admin/systems/services/repository/servRepository.tpl new file mode 100644 index 000000000..0cf596753 --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/servRepository.tpl @@ -0,0 +1,9 @@ +{$Repositories} + + +

 

+
+ +   + +
diff --git a/gosa-plugins/fai/admin/systems/services/repository/servRepositorySetup.tpl b/gosa-plugins/fai/admin/systems/services/repository/servRepositorySetup.tpl new file mode 100644 index 000000000..aa59581c3 --- /dev/null +++ b/gosa-plugins/fai/admin/systems/services/repository/servRepositorySetup.tpl @@ -0,0 +1,58 @@ +

 {t}Repository{/t}

+ + + + + + +
+ + + + + + + + + + + + + +
{t}Parent server{/t} + +{render acl=$ParentServerACL} + +{/render} +
{t}Release{/t} + +{render acl=$ReleaseACL} + +{/render} +
{t}URL{/t} + +{render acl=$UrlACL} + +{/render} +
+
+ {t}Sections{/t}
+{render acl=$SectionACL} + {$Sections} +{/render} +{render acl=$SectionACL} + +{/render} +{render acl=$SectionACL} + +{/render} +
+ +

+ +   + +

+ diff --git a/gosa-plugins/goto/admin/systems/services/repository/class_divListRepositories.inc b/gosa-plugins/goto/admin/systems/services/repository/class_divListRepositories.inc deleted file mode 100644 index 19a1e5757..000000000 --- a/gosa-plugins/goto/admin/systems/services/repository/class_divListRepositories.inc +++ /dev/null @@ -1,84 +0,0 @@ -AddCheckBox */ - var $parent ; - var $ui ; - - 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() - { - if($this->parent->acl_is_createable()){ - $this->SetListHeader(""); - } - } - - function execute() - { - $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 = " "; - } - - 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/goto/admin/systems/services/repository/class_servRepository.inc b/gosa-plugins/goto/admin/systems/services/repository/class_servRepository.inc deleted file mode 100644 index 565501bc0..000000000 --- a/gosa-plugins/goto/admin/systems/services/repository/class_servRepository.inc +++ /dev/null @@ -1,367 +0,0 @@ -DisplayName = _("Repository service"); - - /* Skip this if fai is deactivated */ - $tmp= $this->config->search("faiManagement", "CLASS",array('menu','tabs')); - if(!empty($tmp)){ - $this->fai_activated = TRUE; - }else{ - return; - } - - $this->repositories = array(); - if(isset($this->attrs['FAIrepository'])){ - for($i = 0; $i < $this->attrs['FAIrepository']['count']; $i++){ - $tmp = split("\|",$this->attrs['FAIrepository'][$i]); - $tmp2 = array(); - $tmp3 = array(); - - if(isset($tmp[1])){ - $tmp2['ParentServer'] = $tmp[1]; - if(empty($tmp[1])){ - $tmp2['ParentServer'] = "none"; - } - }else{ - $tmp2['ParentServer'] = "none"; - } - - if(isset($tmp[0])){ - $tmp2['Url'] = $tmp[0]; - }else{ - $tmp2['Url'] = ""; - } - - if(isset($tmp[2])){ - $tmp2['Release'] = $tmp[2]; - }else{ - $tmp2['Release'] = ""; - } - - if(isset($tmp[3])){ - $tmp3 = split(",",$tmp[3]); - foreach($tmp3 as $sec){ - $tmp2['Sections'][$sec]=$sec; - } - }else{ - $tmp['Section']=array(); - } - - $this->repositories[$tmp[2]]=$tmp2; - } - } - - - /* Create divlist */ - $this->divlist = new divListRepository($this->config,$this); - } - - function execute() - { - /* Call parent execute */ - plugin::execute(); - - 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= ""; - - /* 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; - } - - 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']); - - $ldap->search("(&(objectClass=gotoWorkstation)(objectClass=FAIobject)(FAIdebianMirror=".$url."))",array("cn","FAIclass")); - if ($ldap->count() != 0){ - $obj= array(); - $found= false; - while($attrs = $ldap->fetch()){ - foreach($attrs['FAIclass'] as $class){ - if(preg_match("/".str_replace("/","\/",$release)."$/i",$class)){ - $obj[$ldap->getDN()]= $attrs['cn'][0]; - $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((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; - } - } - } - } - if((isset($_GET['act']))&&($_GET['act']=="open_repository")&&(isset($_GET['id']))){ - $obj = $this->repositories[base64_decode($_GET['id'])]; - $obj['initialy_was'] = $obj['Release']; - $this->dialog = new servRepositorySetup($this->config,$this->dn,$obj); - $this->dialog->parent = $this; - } - - if(isset($_POST['repository_setup_save']) && is_object($this->dialog)){ - $this->dialog->save_object(); - if(($this->dialog->is_new_name())&&(isset($this->repositories[$this->dialog->GetName()]))){ - msg_dialog::display(_("Error"), msgPool::duplicated(_("Name")), ERROR_DIALOG); - }else - - if(count($this->dialog->check())!=0){ - foreach($this->dialog->check() as $msg){ - msg_dialog::display(_("Error"), $msg, ERROR_DIALOG); - } - }else{ - $obj = $this->dialog->save(); - if($this->dialog->is_new_name()){ - $oldname = $this->dialog->initialy_was; - $this->repositories[$obj['Release']]=$obj; - unset($this->repositories[$oldname]); - }else{ - $this->repositories[$obj['Release']]=$obj; - } - $this->dialog = FALSE; - $this->is_dialog= false; - } - } - - if(isset($_POST['repository_setup_cancel'])){ - $this->dialog=FALSE; - $this->is_dialog = false; - } - - if(is_object($this->dialog)){ - $this->dialog->save_object(); - $this->is_dialog = true; - return($this->dialog->execute()); - } - - /* - Repository setup dialog handling /END - */ - - - $link = "%s"; - $edit = " "; - - /* Hide delete icon, if delete is not allowed */ - if($this->acl_is_removeable()){ - $delete = ""; - }else{ - $delete = " "; - } - - $this->divlist->execute(); - $this->divlist->setEntries($this->repositories); - $smarty->assign("Repositories",$this->divlist->Draw()); - $display.= $smarty->fetch(get_template_path('servRepository.tpl', TRUE,dirname(__FILE__))); - return($display); - } - - - /* Save data to object */ - function save_object() - { - plugin::save_object(); - if(is_object($this->divlist)){ - $this->divlist->save_object(); - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - return ($message); - } - - - /* Save to LDAP */ - function save() - { - if(!$this->fai_activated) return; - - plugin::save(); - - $arr = array(); - foreach($this->repositories as $servername => $conf){ - $str = ""; - foreach($conf['Sections'] as $sec){ - $str.=$sec.","; - } - $str=preg_replace("/,$/","",$str); - - if($conf['ParentServer']=="none"){ - $conf['ParentServer'] =""; - } - - $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, array('dn')); - - if($ldap->count()){ - $ldap->cd($this->dn); - $this->cleanup(); - $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"); - } - - # If there were changes, just tell the server to reload information - if(count($this->attrs)){ - $this->trigger_si_fai_server_reload(); - } - - if($this->initially_was_account){ - new log("modify","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - }else{ - new log("create","server/".get_class($this),$this->dn,array_keys($this->attrs),$ldap->get_error()); - } - } - - - function getListEntry() - { - $fields = goService::getListEntry(); - $fields['Message'] = _("Repository service"); - $fields['AllowEdit'] = true; - $fields['AllowStart'] = $fields['AllowStop'] = $fields['AllowRestart'] = false; - return($fields); - } - - - function trigger_si_fai_server_reload() - { - /* Reload GOsa si FAI DB/cache - */ - if(class_available("DaemonEvent") && class_available("gosaSupportDaemon")){ - $events = DaemonEvent::get_event_types(SYSTEM_EVENT | HIDDEN_EVENT); - if(isset($events['TRIGGERED']['DaemonEvent_recreate_fai_server_db'])){ - $evt = $events['TRIGGERED']['DaemonEvent_recreate_fai_server_db']; - $tmp = new $evt['CLASS_NAME']($this->config); - $tmp->set_type(TRIGGERED_EVENT); - $tmp->add_targets(array("GOsa")); - $o_queue = new gosaSupportDaemon(); - if(!$o_queue->append($tmp)){ - msg_dialog::display(_("Service infrastructure"),msgPool::siError($o_queue->get_error()),ERROR_DIALOG); - } - } - } - } - - - function remove_from_parent() - { - goService::remove_from_parent(); - $this->trigger_si_fai_server_reload(); - } - - /* Return plugin informations for acl handling */ - static function plInfo() - { - return (array( - "plShortName" => _("Repository"), - "plDescription" => _("Repository service")." ("._("Services").")", - "plSelfModify" => FALSE, - "plDepends" => array(), - "plPriority" => 84, - "plSection" => array("administration"), - "plCategory" => array("server"), - - "plProvidedAcls"=> array( - "cn" => _("Name"), - "start" => _("Start"), - "stop" => _("Stop"), - "restart" => _("Restart"), - "Release" => _("Releases"), - "Section" => _("Sections"), - "ParentServer" => _("Parent server"), - "Url" => _("Url")) - )); - } -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/goto/admin/systems/services/repository/class_servRepositorySetup.inc b/gosa-plugins/goto/admin/systems/services/repository/class_servRepositorySetup.inc deleted file mode 100644 index ad7ee735b..000000000 --- a/gosa-plugins/goto/admin/systems/services/repository/class_servRepositorySetup.inc +++ /dev/null @@ -1,218 +0,0 @@ -$atr = $data[$atr]; - } - } - } - } - - 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']))){ - - /* Replace multiple spaces with a single, and cut of white spaces (trim)*/ - $val = preg_replace("/\ \ * /" , " ", trim($_POST['SectionName'])); - - /* check if there are more than one entry given ( "section1 section2 )*/ - if(preg_match("/ /",$val)){ - - /* Generate list of new section names */ - $vals = split(" ",$val); - - /* Add new entries */ - foreach($vals as $entry){ - $entry = trim($entry); - $this->Sections[$entry]=$entry; - } - }else{ - $this->Sections[$val]=$val; - } - } - - foreach($_POST as $name => $value){ - if(preg_match("/^delete_/",$name)){ - - $val = preg_replace("/^delete_/","",$name); - $val = base64_decode(preg_replace("/_.*$/","",$val)); - - if(isset($this->Sections[$val])){ - unset($this->Sections[$val]); - } - } - } - - $divlist = new divSelectBox("servRepositorySetup"); - $divlist->setHeight("220"); - - $dellink = ""; - - foreach($this->Sections as $sec){ - $divlist->AddEntry(array( - array("string"=>$sec), - array("string"=>sprintf($dellink,base64_encode($sec),$sec),"attach"=>"style='border-right:0px;width:20px;'") - )); - } - - $smarty->assign("Sections",$divlist->DrawList()); - - /* Get && assign acls */ - $tmp = $this->parent->plInfo(); - foreach($tmp['plProvidedAcls'] as $name => $translated){ - $smarty->assign($name."ACL",$this->parent->getacl($name)); - } - - /* Assign values */ - foreach($this->attributes as $attr){ - $smarty->assign($attr ,$this->$attr); - } - - $tmp = $this->getParentServers(); - $smarty->assign("ParentServers" ,$tmp); - $smarty->assign("ParentServerKeys",array_flip($tmp)); - - return($smarty->fetch(get_template_path('servRepositorySetup.tpl', TRUE,dirname(__FILE__)))); - } - - /* Save data to object */ - function save_object() - { - if(isset($_POST['servRepositorySetup_Posted'])) { - - foreach($this->attributes as $attr){ - if(($this->parent->acl_is_writeable($attr)) && (isset($_POST[$attr]))){ - $this->$attr = $_POST[$attr]; - } - } - } - } - - - /* Check supplied data */ - function check() - { - /* Call common method to give check the hook */ - $message= plugin::check(); - - if(empty($this->Release)){ - $message[]= msgPool::required(_("Release")); - } - - if(empty($this->Url)){ - $message[] = msgPool::required(_("Url")); - } - - 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()){ - if($attr['cn'][0] == $this->cn) continue; - $ret[$attr['cn'][0]]= $attr['cn'][0]; - } - - $ret = array_merge($ret,$this->GetHookElements()); - - $ret['none']= " "; - asort($ret); - return($ret); - } - - /* this funtions calls a defined hook - and parses all additional serverdata - */ - function GetHookElements() - { - $ret = array(); - $cmd = $this->config->search("servrepository", "REPOSITORY_HOOK",array('tabs')); - if(!empty($cmd)){ - $res = shell_exec($cmd); - $res2 = trim($res); - if(!$res || empty($res2)){ - msg_dialog::display(_("Error"), msgPool::cmdexecfailed("REPOSITORY_HOOK", $cmd, _("Repository service")), ERROR_DIALOG); - }else{ - $tmp = split("\n",$res); - foreach($tmp as $hook){ - /* skip empty */ - if(empty($hook)) continue; - - if(preg_match("/;/",$hook)){ - $hookinfo = split(";",$hook); - $ret[$hookinfo[0]] = $hookinfo[0]; - }else{ - $ret[$hook] = $hook; - } - } - } - } - return($ret); - } - -} - -// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler: -?> diff --git a/gosa-plugins/goto/admin/systems/services/repository/servRepository.tpl b/gosa-plugins/goto/admin/systems/services/repository/servRepository.tpl deleted file mode 100644 index 0cf596753..000000000 --- a/gosa-plugins/goto/admin/systems/services/repository/servRepository.tpl +++ /dev/null @@ -1,9 +0,0 @@ -{$Repositories} - - -

 

-
- -   - -
diff --git a/gosa-plugins/goto/admin/systems/services/repository/servRepositorySetup.tpl b/gosa-plugins/goto/admin/systems/services/repository/servRepositorySetup.tpl deleted file mode 100644 index aa59581c3..000000000 --- a/gosa-plugins/goto/admin/systems/services/repository/servRepositorySetup.tpl +++ /dev/null @@ -1,58 +0,0 @@ -

 {t}Repository{/t}

- - - - - - -
- - - - - - - - - - - - - -
{t}Parent server{/t} - -{render acl=$ParentServerACL} - -{/render} -
{t}Release{/t} - -{render acl=$ReleaseACL} - -{/render} -
{t}URL{/t} - -{render acl=$UrlACL} - -{/render} -
-
- {t}Sections{/t}
-{render acl=$SectionACL} - {$Sections} -{/render} -{render acl=$SectionACL} - -{/render} -{render acl=$SectionACL} - -{/render} -
- -

- -   - -

-