summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d510dbe)
raw | patch | inline | side by side (parent: d510dbe)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 7 Jul 2008 14:01:48 +0000 (14:01 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 7 Jul 2008 14:01:48 +0000 (14:01 +0000) |
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
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+
+class divListRepository extends MultiSelectWindow
+{
+ /* CheckBoxes, to change default values modify $this->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("<input type=\"image\" src=\"images/fai_new_packages.png\" title=\""._("Add repository")."\" name=\"AddRepository\">");
+ }
+ }
+
+ function execute()
+ {
+ $this->ClearElementsList();
+ $this->GenHeader();
+ }
+
+ function setEntries($list)
+ {
+ $link = "<a href='?plug=".$_GET['plug']."&act=open_repository&id=%s'>%s</a>";
+ $edit = "<input type='image' value='%s' name='edit_%s' src='images/lists/edit.png'> ";
+
+ /* Hide delete icon, if delete is not allowed */
+ if($this->parent->acl_is_removeable()){
+ $delete = "<input type='image' value='%s' name='delete_%s' src='images/lists/trash.png'>";
+ }else{
+ $delete = "<img src='images/empty.png' alt=' '>";
+ }
+
+ 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
--- /dev/null
@@ -0,0 +1,367 @@
+<?php
+
+class servrepository extends goService
+{
+ /* attribute list for save action */
+ // var $ignore_account = TRUE;
+ var $attributes = array("FAIrepository");
+ var $objectclasses = array("FAIrepositoryServer");
+
+ /* Repositories */
+ var $repositories = array();
+ var $FAIrepository = array();
+ var $conflicts = array("FAIrepositoryServer");
+ var $DisplayName = "";
+ var $StatusFlag = "";
+
+ var $view_logged = FALSE;
+ var $fai_activated = FALSE;
+
+ var $divlist = NULL;
+
+ function servrepository (&$config, $dn= NULL, $parent= NULL)
+ {
+ plugin::plugin ($config, $dn,$parent);
+
+ $this->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 = "<h2>"._("You can't use this plugin until FAI is activated.")."</h2>";
+ 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 = "<a href='?plug=".$_GET['plug']."&act=open_repository&id=%s'>%s</a>";
+ $edit = "<input type='image' value='%s' name='edit_%s' src='images/lists/edit.png'> ";
+
+ /* Hide delete icon, if delete is not allowed */
+ if($this->acl_is_removeable()){
+ $delete = "<input type='image' value='%s' name='delete_%s' src='images/lists/trash.png'>";
+ }else{
+ $delete = "<img src='images/empty.png' alt=' '>";
+ }
+
+ $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
--- /dev/null
@@ -0,0 +1,218 @@
+<?php
+
+class servRepositorySetup extends plugin
+{
+ /* attribute list for save action */
+ var $ignore_account = TRUE;
+ var $attributes = array("Release","ParentServer","Url","cn");
+ var $objectclasses = array("whatever");
+
+ /* Attributes */
+ var $Release = "";
+ var $ParentServer = "";
+ var $Url = "";
+ var $Sections = array();
+ var $ParentServers = "";
+ var $initialy_was = false;
+ var $cn = "";
+ var $parent = "";
+
+ function servRepositorySetup (&$config, $dn= NULL,$data = false)
+ {
+ plugin::plugin ($config, $dn);
+ if($data != false){
+ foreach(array("Sections","Release","Url","ParentServer","initialy_was") as $atr){
+ if(isset($data[$atr])){
+ $this->$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 = "<input type='image' src='images/lists/trash.png' title='delete' alt='delete' name='delete_%s' value='%s'>";
+
+ 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
--- /dev/null
@@ -0,0 +1,9 @@
+{$Repositories}
+<input type="hidden" name="servRepository" value="1">
+
+<p class="seperator"> </p>
+<div style="width:100%; text-align:right;">
+ <input type='submit' name='SaveService' value='{msgPool type=saveButton}'>
+
+ <input type='submit' name='CancelService' value='{msgPool type=cancelButton}'>
+</div>
diff --git a/gosa-plugins/fai/admin/systems/services/repository/servRepositorySetup.tpl b/gosa-plugins/fai/admin/systems/services/repository/servRepositorySetup.tpl
--- /dev/null
@@ -0,0 +1,58 @@
+<h2><img src="images/fai_small.png" alt=''> {t}Repository{/t}</h2>
+
+<table width="100%" summary=''>
+ <tr>
+ <td width="50%" valign="top" style="border-right:1px solid #A0A0A0">
+ <table summary=''>
+ <tr>
+ <td>{t}Parent server{/t}
+ </td>
+ <td>
+{render acl=$ParentServerACL}
+ <select name="ParentServer">
+ {html_options options=$ParentServers values=$ParentServerKeys selected=$ParentServer}
+ </select>
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}Release{/t}
+ </td>
+ <td>
+{render acl=$ReleaseACL}
+ <input type="text" value="{$Release}" name="Release">
+{/render}
+ </td>
+ </tr>
+ <tr>
+ <td>{t}URL{/t}
+ </td>
+ <td>
+{render acl=$UrlACL}
+ <input type="text" size="40" value="{$Url}" name="Url">
+{/render}
+ </td>
+ </tr>
+ </table>
+ </td>
+ <td>
+ {t}Sections{/t}<br>
+{render acl=$SectionACL}
+ {$Sections}
+{/render}
+{render acl=$SectionACL}
+ <input type="text" name="SectionName" value="" style='width:100%;'>
+{/render}
+{render acl=$SectionACL}
+ <input type="submit" name="AddSection" value="{msgPool type=addButton}">
+{/render}
+ </td>
+ </tr>
+</table>
+<input type='hidden' name='servRepositorySetup_Posted' value='1'>
+<p class="plugbottom">
+ <input type=submit name="repository_setup_save" value="{msgPool type=applyButton}">
+
+ <input type=submit name="repository_setup_cancel" value="{msgPool type=cancelButton}">
+</p>
+
diff --git a/gosa-plugins/goto/admin/systems/services/repository/class_divListRepositories.inc b/gosa-plugins/goto/admin/systems/services/repository/class_divListRepositories.inc
+++ /dev/null
@@ -1,84 +0,0 @@
-<?php
-
-class divListRepository extends MultiSelectWindow
-{
- /* CheckBoxes, to change default values modify $this->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("<input type=\"image\" src=\"images/fai_new_packages.png\" title=\""._("Add repository")."\" name=\"AddRepository\">");
- }
- }
-
- function execute()
- {
- $this->ClearElementsList();
- $this->GenHeader();
- }
-
- function setEntries($list)
- {
- $link = "<a href='?plug=".$_GET['plug']."&act=open_repository&id=%s'>%s</a>";
- $edit = "<input type='image' value='%s' name='edit_%s' src='images/lists/edit.png'> ";
-
- /* Hide delete icon, if delete is not allowed */
- if($this->parent->acl_is_removeable()){
- $delete = "<input type='image' value='%s' name='delete_%s' src='images/lists/trash.png'>";
- }else{
- $delete = "<img src='images/empty.png' alt=' '>";
- }
-
- 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
+++ /dev/null
@@ -1,367 +0,0 @@
-<?php
-
-class servrepository extends goService
-{
- /* attribute list for save action */
- // var $ignore_account = TRUE;
- var $attributes = array("FAIrepository");
- var $objectclasses = array("FAIrepositoryServer");
-
- /* Repositories */
- var $repositories = array();
- var $FAIrepository = array();
- var $conflicts = array("FAIrepositoryServer");
- var $DisplayName = "";
- var $StatusFlag = "";
-
- var $view_logged = FALSE;
- var $fai_activated = FALSE;
-
- var $divlist = NULL;
-
- function servrepository (&$config, $dn= NULL, $parent= NULL)
- {
- plugin::plugin ($config, $dn,$parent);
-
- $this->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 = "<h2>"._("You can't use this plugin until FAI is activated.")."</h2>";
- 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 = "<a href='?plug=".$_GET['plug']."&act=open_repository&id=%s'>%s</a>";
- $edit = "<input type='image' value='%s' name='edit_%s' src='images/lists/edit.png'> ";
-
- /* Hide delete icon, if delete is not allowed */
- if($this->acl_is_removeable()){
- $delete = "<input type='image' value='%s' name='delete_%s' src='images/lists/trash.png'>";
- }else{
- $delete = "<img src='images/empty.png' alt=' '>";
- }
-
- $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
+++ /dev/null
@@ -1,218 +0,0 @@
-<?php
-
-class servRepositorySetup extends plugin
-{
- /* attribute list for save action */
- var $ignore_account = TRUE;
- var $attributes = array("Release","ParentServer","Url","cn");
- var $objectclasses = array("whatever");
-
- /* Attributes */
- var $Release = "";
- var $ParentServer = "";
- var $Url = "";
- var $Sections = array();
- var $ParentServers = "";
- var $initialy_was = false;
- var $cn = "";
- var $parent = "";
-
- function servRepositorySetup (&$config, $dn= NULL,$data = false)
- {
- plugin::plugin ($config, $dn);
- if($data != false){
- foreach(array("Sections","Release","Url","ParentServer","initialy_was") as $atr){
- if(isset($data[$atr])){
- $this->$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 = "<input type='image' src='images/lists/trash.png' title='delete' alt='delete' name='delete_%s' value='%s'>";
-
- 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
+++ /dev/null
@@ -1,9 +0,0 @@
-{$Repositories}
-<input type="hidden" name="servRepository" value="1">
-
-<p class="seperator"> </p>
-<div style="width:100%; text-align:right;">
- <input type='submit' name='SaveService' value='{msgPool type=saveButton}'>
-
- <input type='submit' name='CancelService' value='{msgPool type=cancelButton}'>
-</div>
diff --git a/gosa-plugins/goto/admin/systems/services/repository/servRepositorySetup.tpl b/gosa-plugins/goto/admin/systems/services/repository/servRepositorySetup.tpl
+++ /dev/null
@@ -1,58 +0,0 @@
-<h2><img src="images/fai_small.png" alt=''> {t}Repository{/t}</h2>
-
-<table width="100%" summary=''>
- <tr>
- <td width="50%" valign="top" style="border-right:1px solid #A0A0A0">
- <table summary=''>
- <tr>
- <td>{t}Parent server{/t}
- </td>
- <td>
-{render acl=$ParentServerACL}
- <select name="ParentServer">
- {html_options options=$ParentServers values=$ParentServerKeys selected=$ParentServer}
- </select>
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}Release{/t}
- </td>
- <td>
-{render acl=$ReleaseACL}
- <input type="text" value="{$Release}" name="Release">
-{/render}
- </td>
- </tr>
- <tr>
- <td>{t}URL{/t}
- </td>
- <td>
-{render acl=$UrlACL}
- <input type="text" size="40" value="{$Url}" name="Url">
-{/render}
- </td>
- </tr>
- </table>
- </td>
- <td>
- {t}Sections{/t}<br>
-{render acl=$SectionACL}
- {$Sections}
-{/render}
-{render acl=$SectionACL}
- <input type="text" name="SectionName" value="" style='width:100%;'>
-{/render}
-{render acl=$SectionACL}
- <input type="submit" name="AddSection" value="{msgPool type=addButton}">
-{/render}
- </td>
- </tr>
-</table>
-<input type='hidden' name='servRepositorySetup_Posted' value='1'>
-<p class="plugbottom">
- <input type=submit name="repository_setup_save" value="{msgPool type=applyButton}">
-
- <input type=submit name="repository_setup_cancel" value="{msgPool type=cancelButton}">
-</p>
-