Code

first commit of repository service modifications ..
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 25 Jan 2010 14:08:50 +0000 (14:08 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Mon, 25 Jan 2010 14:08:50 +0000 (14:08 +0000)
-Will support the new style lists soon

git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15282 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/fai/admin/systems/services/repository/class_divListRepositories.inc
gosa-plugins/fai/admin/systems/services/repository/class_filterServerService.inc [new file with mode: 0644]
gosa-plugins/fai/admin/systems/services/repository/class_servRepository.inc
gosa-plugins/fai/admin/systems/services/repository/repository-filter.tpl [new file with mode: 0644]
gosa-plugins/fai/admin/systems/services/repository/repository-filter.xml [new file with mode: 0644]
gosa-plugins/fai/admin/systems/services/repository/repository-list.tpl [new file with mode: 0644]
gosa-plugins/fai/admin/systems/services/repository/repository-list.xml [new file with mode: 0644]
gosa-plugins/fai/admin/systems/services/repository/servRepository.tpl

index c1e8c4328531e822a2d9d1a90b5bcee32604f6b9..96cc1b6a5480eb093cb3223a3fa2a7e2047a7af9 100644 (file)
@@ -1,83 +1,45 @@
 <?php
 
-class divListRepository extends MultiSelectWindow
+class divListRepository extends management
 {
-  /* CheckBoxes, to change default values modify $this->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("<input type=\"image\" src=\"plugins/fai/images/fai_new_packages.png\" title=\""._("Add repository")."\"                 name=\"AddRepository\">");
-    }
+    $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   = "<a href='?plug=".$_GET['plug']."&amp;act=open_repository&amp;id=%s'>%s</a>";
-    $edit   = "<input type='image' value='%s' name='edit_%s'   src='images/lists/edit.png'>&nbsp;";
-
-    /* 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='&nbsp;'>";
+    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 (file)
index 0000000..e662240
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+class filterRepository {
+
+  static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+  {
+    $list = servRepository::getRepositoryList();
+
+    $data = array();
+    foreach($list as $key => $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);
+  }
+}
+
+?>
index ecf2d923a21e99cd43fa98763f6b249c672c1777..86bf0354587535d8b7c69c6cd74e874003199bee 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+
 class servrepository extends goService
 {
   /* attribute list for save action */
@@ -79,133 +80,123 @@ class servrepository extends goService
     $this->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 = "<h2>"._("You can't use this plugin until FAI is activated.")."</h2>";
-      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 = "<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= "";
+
 
     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   = "<a href='?plug=".$_GET['plug']."&amp;act=open_repository&amp;id=%s'>%s</a>";
     $edit   = "<input type='image' value='%s' name='edit_%s'   src='images/lists/edit.png'>&nbsp;";
    
@@ -257,11 +246,10 @@ class servrepository extends goService
       $delete = "<img src='images/empty.png' alt='&nbsp;'>";
     }
 
-    $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 (file)
index 0000000..16ddf73
--- /dev/null
@@ -0,0 +1,8 @@
+<div class="contentboxh">
+ <p class="contentboxh">
+  <img src="images/launch.png" align="right" alt="[F]">{t}Filter{/t}
+ </p>
+</div>
+
+<div class="contentboxb">
+</div>
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 (file)
index 0000000..3799b8b
--- /dev/null
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<filterdef>
+  <definition>
+    <category>server</category>
+    <template>services/repository/repository-filter.tpl</template>
+    <initial>true</initial>
+  </definition>
+
+  <search>
+    <query>
+      <backend>Repository</backend>
+      <filter>...</filter>
+      <attribute>dn</attribute>
+      <attribute>objectClass</attribute>
+      <attribute>name</attribute>
+      <attribute>Message</attribute>
+    </query>
+    <scope>auto</scope>
+  </search>
+
+</filterdef>
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 (file)
index 0000000..0b2cc79
--- /dev/null
@@ -0,0 +1,31 @@
+<input type='image' src='images/empty.png' name='no_action_posted' value='do_nothing' alt='' style='width:2px;height:2px;'>
+
+<table summary="" style="width:100%; vertical-align:top; text-align:left;" cellpadding=2>
+  <tr>
+    <td style="vertical-align:top; width:50%;">
+      <div class="contentboxh">
+        <p class="contentboxh">&nbsp;{$HEADLINE}&nbsp;{$SIZELIMIT}</p>
+      </div>
+      
+      <div class="contentboxb">
+       <div style='background:white;padding:0px;padding:3px;'>
+        <table><tr>
+          <td>{$ROOT}&nbsp;</td><td>{$BACK}&nbsp;</td><td>{$HOME}&nbsp;</td><td>{$RELOAD}&nbsp;</td><td>{$SEPARATOR}&nbsp;</td><td><img src='images/rocket.png' alt='' class='center'></td><td> {$ACTIONS}</td>
+        </tr></table>
+       </div>
+      </div>
+      
+      <div style='height:4px;'>
+      </div>
+      
+      <input type="hidden" id="d_save" value="450">
+      <input type="hidden" id="d_space" value="760">
+      {$LIST}
+    </td>
+    <td style='vertical-align:top'>
+      {$FILTER}
+    </td>
+  </tr>
+</table>
+
+<input type="hidden" name="ignore">
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 (file)
index 0000000..d1d950b
--- /dev/null
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<list>
+  <definition>
+    <departmentBrowser>false</departmentBrowser>
+    <departmentRootVisible>false</departmentRootVisible>
+    <baseMode>false</baseMode>
+    <multiSelect>true</multiSelect>
+    <template>services/repository/repository-list.tpl</template>
+    <label>List of repositories</label>
+    <defaultSortColumn>1</defaultSortColumn>
+
+    <objectType>
+      <label>Service</label>
+      <objectClass>FAKE_OC_FaiRepository</objectClass>
+      <category>server</category>
+      <class>Repository</class>
+      <image>images/lits/new.png</image>
+    </objectType>
+
+  </definition>
+
+  <table>
+    <layout>|||170px;r|</layout>
+
+    <column>
+      <label>Release</label>
+      <sortAttribute>Release</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{filter:link(row,dn,"%s",Release)}</value>
+      <export>true</export>
+    </column>
+
+    <column>
+      <label>Sections</label>
+      <sortAttribute>Sections</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{filter:link(row,dn,"%s",Sections)}</value>
+      <export>true</export>
+    </column>
+
+    <column>
+      <label>Actions</label>
+      <value>%{filter:actions(dn,row,objectClass)}</value>
+    </column>
+
+  </table>
+
+  <actionmenu>
+
+    <action>
+     <type>sub</type>
+     <image>images/lists/new.png</image>
+     <label>Create</label>
+
+     <action>
+      <name>new</name>
+      <type>entry</type>
+      <image>images/lists/new.png</image>
+      <label>Release</label>
+     </action>
+    </action>
+
+    <action>
+      <type>separator</type>
+    </action>
+
+    <action>
+      <name>remove</name>
+      <type>entry</type>
+      <image>images/lists/trash.png</image>
+      <label>Remove</label>
+    </action>
+
+    <action>
+      <type>separator</type>
+    </action>
+
+    <action>
+      <type>exporter</type>
+    </action>
+
+  </actionmenu>
+
+  <actiontriggers snapshot="false" copypaste="false">
+
+    <action>
+      <name>edit</name>
+      <type>entry</type>
+      <image>images/lists/edit.png</image>
+      <label>Edit</label>
+    </action>
+
+    <action>
+      <name>remove</name>
+      <type>entry</type>
+      <image>images/lists/trash.png</image>
+      <label>Remove</label>
+    </action>
+
+  </actiontriggers>
+
+</list>
index 0cf5967532c0fc825e490613078389109e62f2f1..c6bd73d80f4ed3bd296a210ea58c90402d3049cb 100644 (file)
@@ -1,4 +1,3 @@
-{$Repositories}
 <input type="hidden" name="servRepository" value="1">
 
 <p class="seperator">&nbsp;</p>