Code

Updated opsiLicenses
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Jan 2010 09:05:05 +0000 (09:05 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 5 Jan 2010 09:05:05 +0000 (09:05 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@15036 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-plugins/opsi/admin/opsiLicenses/class_divListLicenses.inc [deleted file]
gosa-plugins/opsi/admin/opsiLicenses/class_filterOpsiLicense.inc [new file with mode: 0644]
gosa-plugins/opsi/admin/opsiLicenses/class_opsiLicenses.inc
gosa-plugins/opsi/admin/opsiLicenses/main.inc
gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-filter.tpl [new file with mode: 0644]
gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-filter.xml [new file with mode: 0644]
gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-list.tpl [new file with mode: 0644]
gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-list.xml [new file with mode: 0644]

diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_divListLicenses.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_divListLicenses.inc
deleted file mode 100644 (file)
index b2b2864..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-<?php
-/*
- * This code is part of GOsa (http://www.gosa-project.org)
- * Copyright (C) 2003-2008 GONICUS GmbH
- *
- * ID: $$Id: class_divListLicense.inc 12852 2008-10-31 16:19:40Z cajus $$
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-class divListLicense extends MultiSelectWindow
-{
-
-  // Current base 
-  var $selectedBase       = "";
-  var $departments        = array();
-
-  // Regex 
-  var $Regex              = "*";
-
-  // Subsearch checkbox 
-  var $SubSearch          ;
-  var $parent             ;
-  var $ui                 ;
-
-  function divListLicense (&$config,$parent)
-  {
-    MultiSelectWindow::MultiSelectWindow($config, "opsi", "licenseGeneric");
-    
-    $this->parent       = $parent;
-    $this->ui           = get_userinfo();
-
-    // Dynamic action col, depending on snapshot icons 
-    $action_col_size = 90;
-    if($this->parent->snapshotEnabled()){
-      $action_col_size += 38;
-    }
-
-    // Set list strings 
-    $this->SetTitle(_("List of license pools"));
-    $this->SetSummary(_("List of license pools"));
-    $this->EnableAplhabet(true);
-
-    // Result page will look like a headpage 
-    $this->SetHeadpageMode();
-  
-    // Disable buttonsm 
-    $this->EnableCloseButton(false);
-    $this->EnableSaveButton (false);
-
-    // Add checkbox: Toggle all selected / deselected 
-    $chk = "<input type='checkbox' id='select_all' name='select_all' title='"._("Select all")."'
-               onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
-
-    // Set Page col headers 
-    $this->AddHeader(array("string" => $chk,"attach"=>"style='width:20px;'"));
-    $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
-    $this->AddHeader(array("string" => _("License pools"), "attach" => "style=''"));
-    $this->AddHeader(array("string" => _("Actions"), 
-          "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'"));
-
-    // Add regex user input field
-    $this->AddRegex   ("Regex", _("Regular expression for matching license pools"), "*" , true);
-  }
-
-
-  function GenHeader()
-  {
-    /* Get all departments within this subtree */
-    $ui= get_userinfo();
-    $first = "";
-    $found = FALSE;
-    $base = $this->config->current['BASE'];
-    $options  = $this->create_department_list($this->module);
-
-    /* Get copy & paste icon */
-    $acls  = $ui->get_permissions($this->selectedBase,"opsi/licenseGeneric");
-    $acl_all= $ui->has_complete_category_acls($this->selectedBase,"opsi");
-
-    /* Add default header */
-    $listhead = MultiSelectWindow::get_default_header(false);
-  
-    /* Create Layers menu */
-    $s  = ".|"._("Actions")."|\n";
-
-    /* Append create options */
-    if(preg_match("/c/",$acls)) {
-      $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
-        "&nbsp;"._("Create")."|\n";
-      $s.= "...|<input class='center' type='image' src='plugins/opsiLicenses/images/new.png' alt=''>".
-        "&nbsp;"._("License")."|license_new|\n";
-    }
-
-    /* Multiple options */
-    $s.= "..|---|\n";
-
-    if(preg_match("/d/",$acls)) {
-      $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
-        "&nbsp;"._("Remove")."|"."remove_multiple_licenses|\n";
-    }
-  
-    $this->SetDropDownHeaderMenu($s);
-    $this->SetListHeader($listhead);
-  }
-
-
-  function execute()
-  {
-    $this->ClearElementsList();
-    $this->GenHeader();
-  }
-
-  function setEntries($list)
-  {
-    // Defining Links
-    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
-
-    // Dynamic action col, depending on snapshot icons 
-    $action_col_size = 90;
-    if($this->parent->snapshotEnabled()){
-      $action_col_size += 38;
-    }
-  
-    $ui = get_userinfo();
-
-    // Assigning licenses
-    foreach($list as $key => $val){
-     
-      // Get object permissions
-      $acl    = $ui->get_permissions($val['dn'],"opsi/licenseGeneric");
-      $acl_all= $ui->has_complete_category_acls($val['dn'],"opsi");
-
-      // Create edit and remove icon buttons
-      $actions = "<input class='center' type='image'
-        src='images/lists/edit.png' alt='"._("edit")."' 
-        name='license_edit_%KEY%' title='"._("Edit this entry")."'>";
-      if(preg_match("/d/",$acl)){
-        $actions.= "<input class='center' type='image'
-          src='images/lists/trash.png' alt='"._("delete")."' 
-          name='license_del_%KEY%' title='"._("Delete this entry")."'>";
-      }else{
-        $actions.= "<img class='center' src='images/empty.png' alt='&nbsp;'
-          title='".msgPool::permDelete()."'>";
-      }
-
-
-      // Append license descriptio, if available
-      $title = "title='".preg_replace('/ /', '&nbsp;', LDAP::fix($val['dn']))."'";
-      if(!isset($val['description'][0])){
-        $desc = "";
-      }else{
-        $desc = " - [ ".$val['description'][0]." ]";
-      }
-      $display = $val['cn'][0].$desc;
-
-      // Append the entry to the divlist
-      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$key."' 
-          name='item_selected_".$key."'>" ,
-          "attach" => "style='width:20px;'");
-      $field1 = array("string" => "<img src='plugins/opsi/images/license.png' 
-          alt='"._("License")."' ".$title.">", 
-          "attach" => "style='text-align:center;width: 20px;'");
-      $field2 = array("string" => sprintf($editlink,$key,$display), 
-          "attach" => "style='' ".$title);
-      $field4 = array("string" => preg_replace("/%KEY%/", $key, $actions), 
-          "attach" => "style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
-
-      $this->AddElement(array($field0,$field1,$field2,$field4));
-    }
-   
-    // Create the list summary 
-    $num_deps=0;
-    if(!$this->SubSearch){
-      $num_deps = count($this->Added_Departments);
-    }
-    $num_objs = count($list);
-    $num_obj_str = _("Number of listed license pools");
-    $str = "<img class='center' src='plugins/opsi/images/license.png'
-              title='".$num_obj_str."' alt='".$num_obj_str."'>&nbsp;".$num_objs."&nbsp;&nbsp;&nbsp;&nbsp;";
-    $this->set_List_Bottom_Info($str);
-  }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/class_filterOpsiLicense.inc b/gosa-plugins/opsi/admin/opsiLicenses/class_filterOpsiLicense.inc
new file mode 100644 (file)
index 0000000..2a45bb0
--- /dev/null
@@ -0,0 +1,45 @@
+<?php
+
+class filterOpsiLicense {
+
+  static function query($base, $scope, $filter, $attributes, $category, $objectStorage= "")
+  {
+    $config= session::global_get('config');
+    $si = new opsiLicenceHandler($config);
+    $res = $si->listPools();
+    $result = array();
+    if($si->is_error() || !is_array($res)){
+      $this->init_successfull = FALSE;
+      msg_dialog::display(_("Error"),msgPool::siError($si->get_error()),ERROR_DIALOG);
+      return;
+    }else{
+
+      // Reset the list of licenses
+      foreach($res as $item){
+
+        // Fake an ldap entry, this enables ACL checks.
+        $entry['dn'] = "opsi:cn=".$item['cn'][0].",".$config->current['BASE'];
+        foreach($item as $name => $value){
+          $entry[] = $name;
+          $entry[$name] = $value;
+        }
+        $entry['count'] = count($item);
+        $result[] = $entry;
+      }
+    }
+    return(filterACL::unifyResult($result));
+  }
+
+  static function unifyResult($result)
+  {
+    $res=array();
+    foreach($result as $entry){
+      if(!isset($res[$entry['dn']])){
+        $res[$entry['dn']]=$entry;
+      }
+    }
+    return(array_values($res)); 
+  }
+}
+
+?>
index 27466eb68f4ba2f6c4e01ee767d9f0b4f585b46e..76e279151e1b0199aadfec7ee0bf0027cf8eac94 100644 (file)
 <?php
 /*
-* This code is part of GOsa (http://www.gosa-project.org)
-* Copyright (C) 2003-2008 GONICUS GmbH
-*
-* ID: $$Id: class_licenseManagement.inc 13520 2009-03-09 14:54:13Z hickert $$
-*
-* This program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program; if not, write to the Free Software
-* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-*/
-
-class opsiLicenses extends plugin
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id: class_roleManagement.inc 14742 2009-11-04 13:18:33Z hickert $$
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+class opsiLicenses extends management
 {
-  /* Definitions */
-  var $plHeadline= "Software licenses";
-  var $plDescription= "Software licenses";
-  var $plIcon= "plugins/opsi/images/plugin.png";
-
-  // The headpage list handler. 
-  var $DivListLicenses    = NULL;
-
-  // A list of currently visible licenses
-  var $licenses = array();
-
-  // A list of currently edited/removed/aso licenses.
-  var $dns = array();
-
-  // Permission modules to use.
-  var $acl_module   = array("opsi");  
-
-  // Construct and initialize the plugin 
-  function __construct (&$config, $dn= NULL)
-  {
-    // Include config object 
-    $this->config= &$config;
-    $this->ui= get_userinfo();
-
-    // Initialize the corresponding list class.
-    $this->DivListLicenses = new divListLicense($this->config,$this);
-  }
-
-
-  function execute()
+  var $plHeadline     = "Opsi Licenses";
+  var $plDescription  = "License management";
+  var $plIcon  = "plugins/opsi/images/plugin.png";
+
+  // Tab definition 
+  protected $tabClass = "licenseTabs";
+  protected $tabType = "OPSILICENSETABS";
+  protected $aclCategory = "opsi";
+  protected $aclPlugin   = "licenseGeneric";
+  protected $objectName   = "license";
+
+  function __construct($config,$ui)
   {
-    // Call parent execute 
-    plugin::execute();
-
-    // Variables to restore after 'entry locked' warning was displayed 
-    session::set('LOCK_VARS_TO_USE',array('/^license_/','/^act/',
-          '/^id/','/^menu_action/','/^item/'));
-
-    $smarty     = get_smarty();
-
-    /***************
-     * Handle _POST/_GET variables
-     ***************/
+    $this->config = $config;
+    $this->ui = $ui;
    
-    // Get entry related posts 
-    $s_action   = "";
-    $s_entry    = "";
-    foreach($_POST as $name => $value){
-      if(preg_match("/^license_edit_/",$name)){
-        $s_action = "edit";  
-        $s_entry = preg_replace("/^license_edit_([0-9]*)_.*$/","\\1",$name);
-        break;
-      }
-      if(preg_match("/^license_del_/",$name)){
-        $s_action = "remove";  
-        $s_entry = preg_replace("/^license_del_([0-9]*)_.*$/","\\1",$name);
-        break;
-      }
-    }
-
-    if(isset($_GET['act']) && $_GET['act'] == "edit_entry" && isset($_GET['id'])){
-      $id = $_GET['id'];
-      if(isset($this->licenses[$id])){
-        $s_action = "edit";
-        $s_entry = $id;
-      }
-    }
+    $this->storagePoints = array();
  
-    // Get menu related posts 
-    if(isset($_POST['menu_action'])) {
-      if($_POST['menu_action'] == "remove_multiple_licenses"){
-        $s_action = "remove_multiple";
-      }
-      if($_POST['menu_action'] == "license_new"){
-        $s_action = "new";
-      }
-    }
-
-
-
-    /***************
-     * Remove handling
-     ***************/
-
-    if($s_action == "remove_multiple" || $s_action == "remove"){
-    
-      if($s_action == "remove_multiple"){
-        $ids = $this->list_get_selected_items();
-      }else{
-        $ids = array($s_entry);
-      }
-
-      if(count($ids)){
-        $this->dns = array();
-        $disallowed = array();
-        foreach($ids as $id){
-          $dn = $this->licenses[$id]['dn'];
-          $acl = $this->ui->get_permissions($dn, "opsi/licenseGeneric");
-          if(preg_match("/d/",$acl)){
-            $this->dns[$id] = $dn;
-          }else{
-            $disallowed[] = $dn;
-          }
-        }
-
-        if(count($disallowed)){
-          msg_dialog::display(_("Permission"),msgPool::permDelete($disallowed),INFO_DIALOG);
-        }
-
-        if(count($this->dns)){
-
-          $dns_names = array();
-          foreach($this->dns as $dn){
-            $dns_names[] = LDAP::fix($dn);
-          }
-
-          $smarty->assign("info", msgPool::deleteInfo($dns_names,_("License")));
-          $smarty->assign("multiple", true);
-          return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
-        }
-      }
-    } 
-
-
-    /* Remove lock */
-    if(isset($_POST['delete_multiple_licenses_cancel'])){
-
-      /* Remove lock file after successfull deletion */
-      $this->remove_lock();
-      $this->dns = 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("opsiLicense-filter.xml", true));
+      $filter->setObjectStorage($this->storagePoints);
+#    }
+    $this->setFilter($filter);
+
+    // Build headpage
+    $headpage = new listing(get_template_path("opsiLicense-list.xml", true));
+    $headpage->setFilter($filter);
+
+    // Add copy&paste and snapshot handler.
+    if ($this->config->boolValueIsTrue("main", "copyPaste")){
+      $this->cpHandler = new CopyPasteHandler($this->config);
     }
-
-
-    /* Confirmation for deletion has been passed. Users should be deleted. */
-    if (isset($_POST['delete_multiple_licenses_confirm'])){
-
-      /* Remove user by user and check acls before removeing them */
-      foreach($this->dns as $key => $dn){
-
-        $acl = $this->ui->get_permissions($dn, "opsi/licenseGeneric");
-        if (preg_match('/d/', $acl)){
-          $this->dialog = new licenseTabs($this->config, $this->config->data['TABS']['OPSILICENSETABS'],$dn, "opsi");
-          $this->dialog->set_acl_base($this->config->current['BASE']);
-          $this->dialog->delete();
-          $this->dialog= NULL;
-        } else {
-
-          /* Normally this shouldn't be reached, send some extra
-             logs to notify the administrator */
-          msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
-          new log("security","opsi/".get_class($this),$dn,array(),"Tried to trick deletion.");
-        }
-      }
-
-      /* Remove lock file after successfull deletion */
-      $this->remove_lock();
-      $this->dns = array();
-    }
-
-
-    /***************
-     * New handling
-     ***************/
-
-    if($s_action == "new" && !$this->dialog instanceOf tabs){
-      $this->dn = "new";
-      $this->dialog = new licenseTabs($this->config, $this->config->data['TABS']['OPSILICENSETABS'],$this->dn, "opsi");
-      $this->dialog->set_acl_base($this->config->current['BASE']);
+    if($this->config->get_cfg_value("enableSnapshots") == "true"){
+      $this->snapHandler = new SnapshotHandler($this->config);
     }
-    
-    /***************
-     * Edit handling
-     ***************/
-
-    if($s_action == "edit" && !$this->dialog instanceOf tabs){
-      if(!isset($this->licenses[$s_entry])){
-        trigger_error("Unknown entry!"); 
-      }else{
-
-        $entry = $this->licenses[$s_entry];
-        $this->dn = $entry['dn'];
-
-        /* Open the dialog */
-        $this->dialog = new licenseTabs($this->config, $this->config->data['TABS']['OPSILICENSETABS'], 
-            $entry['dn'], "opsi");
-        $this->dialog->set_acl_base($this->config->current['BASE']);
-        set_object_info($this->dn);
-      }
-    }
-
-
-    /***************
-     * Dialog handling
-     ***************/
-
-    if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && $this->dialog instanceOf tabs){
-      $this->dialog->save_object();
-      $msgs = $this->dialog->check();
-      if(count($msgs)){
-        msg_dialog::displayChecks($msgs);
-      }else{
-        $this->dialog->save();
-        if (!isset($_POST['edit_apply'])){
-          $this->remove_lock();
-          $this->dialog= NULL;
-          set_object_info();
-        }else{
-          $this->dialog->re_init();
-        }
-      }
-    }
-
-    if (isset($_POST['edit_cancel']) && $this->dialog instanceOf tabs){
-      $this->remove_lock();
-      $this->dialog= NULL;
-      set_object_info();
-    }
-
-    if($this->dialog instanceOf tabs){
-      $display= $this->dialog->execute();
-
-      $dialog_opened = ($this->dialog->by_object[$this->dialog->current]->dialog instanceOf plugin);
-
-      if(!$dialog_opened){
-        if($this->dialog->read_only   == TRUE){
-          $display.= "<p style=\"text-align:right\">
-            <input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">
-            </p>";
-        }else{
-
-          $display.= "<p style=\"text-align:right\">\n";
-          $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" 
-            value=\"".msgPool::okButton(). "\">\n";
-          $display.= "&nbsp;\n";
-          if ($this->dn != "new"){
-            $display.= "<input type=submit name=\"edit_apply\" 
-              value=\"".msgPool::applyButton()."\">\n";
-            $display.= "&nbsp;\n";
-          }
-          $display.= "<input type=submit name=\"edit_cancel\" 
-            value=\"".msgPool::cancelButton()."\">\n";
-          $display.= "</p>";
-        }
-      }
-      return ($display);
-    }
-
-
-    /***************
-     * List handling
-     ***************/
-
-    // Display dialog with group list 
-    $this->DivListLicenses->parent = $this;
-    $this->DivListLicenses->execute();
-    $this->reload ();
-    $this->DivListLicenses->setEntries($this->licenses);
-    return($this->DivListLicenses->Draw());
+    parent::__construct($config, $ui, "licenses", $headpage);
   }
-
-
-  // Refreshes the list of known license objects. 
-  function reload()
-  {
-
-    // Get current ldap base and filter settings.
-    $base     = $this->DivListLicenses->selectedBase;
-    $Regex    = $this->DivListLicenses->Regex;
-
-    $si = new opsiLicenceHandler($this->config);
-    $this->licenses = array();
-    $res = $si->listPools();
-    if($si->is_error() || !is_array($res)){
-      $this->init_successfull = FALSE;
-      msg_dialog::display(_("Error"),msgPool::siError($si->get_error()),ERROR_DIALOG);
-      return;
-    }else{
-
-      // Reset the list of licenses 
-      foreach($res as $item){
-
-        // Fake an ldap entry, this enables ACL checks.
-        $item['dn'] = "opsi:cn=".$item['cn'][0].",".$this->config->current['BASE'];
-        $this->licenses[] = $item;
-      }
-    }
-  }
-
-
-  /* \brief  Returns a list of selected entry ids.
-   *         E.g. remove multiple entries.
-   * @return Array  A list of entry IDs
-   */
-  function list_get_selected_items()
-  {
-    $ids = array();
-    foreach($_POST as $name => $value){
-      if(preg_match("/^item_selected_[0-9]*$/",$name)){
-        $id   = preg_replace("/^item_selected_/","",$name);
-        $ids[$id] = $id;
-      }
-    }
-    return($ids);
-  }
-
-
-  function remove_lock()
-  {
-    if (isset($this->dialog->dn)){
-      del_lock ($this->dialog->dn);
-    }elseif(isset($this->dn) && !empty($this->dn) && $this->dn != "new"){
-      del_lock($this->dn);
-    }
-    if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
-      del_lock($this->dns);
-    }
-  }
-
-  function save_object()
-  {
-    $this->DivListLicenses->save_object();
-  }
-}
-
+} 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 865e23b2c4c4fbe650a45540876007f12b9bb974..292ebc98099b988d754e82d3420880d6a58581e7 100644 (file)
@@ -3,7 +3,7 @@
  * This code is part of GOsa (http://www.gosa-project.org)
  * Copyright (C) 2003-2008 GONICUS GmbH
  *
- * ID: $$Id: main.inc 13288 2008-12-12 14:54:13Z hickert $$
+ * ID: $$Id: main.inc 14752 2009-11-05 10:00:17Z hickert $$
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-
-// Remove locks created by this plugin
+/* Remove locks created by this plugin
+*/
 if ($remove_lock){
   if(session::is_set('opsiLicenses')){
-    $macl = session::get('opsiLicenses');
-    $macl->remove_lock();
+      $macl = session::get('opsiLicenses');
+      $macl->remove_lock();
   }
 }
 
 /* Remove this plugin from session
 */
 if ( $cleanup ){
-  $macl = session::get('opsiLicenses');
-  $macl->remove_lock();
   session::un_set('opsiLicenses');
 }else{
 
-  /* Create object object on demand */
+  /* Create opsiLicenses object on demand */
   if (!session::is_set('opsiLicenses')){
-    session::set('opsiLicenses',new opsiLicenses($config));
+    $opsiLicenses= new opsiLicenses ($config, $ui);
+    session::set('opsiLicenses',$opsiLicenses);
   }
   $opsiLicenses = session::get('opsiLicenses');
+  $display= $opsiLicenses->execute();
 
-  /* Execute formular */
-  $opsiLicenses->save_object();
-  $output= $opsiLicenses->execute ();
-
-  /* Page header*/
-  if (get_object_info() != ""){
-    $display= print_header(get_template_path('plugins/opsi/images/plugin.png'),
-        _("Software licenses"),
-        "<img alt=\"\" align=\"middle\" src=\"".get_template_path('images/lists/locked.png')."\"> ".
-        LDAP::fix(get_object_info()));
-  } else {
-    $display= print_header(get_template_path('plugins/opsi/images/plugin.png'), _("Software licenses"));
+  /* Reset requested? */
+  if (isset($_GET['reset']) && $_GET['reset'] == 1){
+    session::un_set ('opsiLicenses');
   }
 
-  $display.= $output;
-
-  /* Store changes  in session */
+  /* Show and save dialog */
   session::set('opsiLicenses',$opsiLicenses);
 }
 
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-filter.tpl b/gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-filter.tpl
new file mode 100644 (file)
index 0000000..ba7af5c
--- /dev/null
@@ -0,0 +1,33 @@
+<div class="contentboxh">
+ <p class="contentboxh">
+  <img src="images/launch.png" align="right" alt="[F]">{t}Filter{/t}
+ </p>
+</div>
+
+<div class="contentboxb">
+
+<div style="border-top:1px solid #AAAAAA"></div>
+
+ {$SCOPE}
+
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+  <tr>
+   <td>
+    <label for="NAME">
+     <img src="images/lists/search.png" align=middle>&nbsp;Name
+    </label>
+   </td>
+   <td>
+    {$NAME}
+   </td>
+  </tr>
+ </table>
+
+ <table summary=""  width="100%"  style="background:#EEEEEE;border-top:1px solid #B0B0B0;">
+  <tr>
+   <td width="100%" align="right">
+    {$APPLY}
+   </td>
+  </tr>
+ </table>
+</div>
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-filter.xml b/gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-filter.xml
new file mode 100644 (file)
index 0000000..af1ba4e
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<filterdef>
+  <definition>
+    <category>roles</category>
+    <template>opsiLicense-filter.tpl</template>
+    <initial>true</initial>
+  </definition>
+
+  <search>
+    <query>
+      <backend>OpsiLicense</backend>
+      <filter>(&amp;(objectClass=organizationalRole)$NAME)</filter>
+      <attribute>dn</attribute>
+      <attribute>objectClass</attribute>
+      <attribute>cn</attribute>
+      <attribute>description</attribute>
+    </query>
+    <scope>auto</scope>
+  </search>
+
+  <element>
+    <type>textfield</type>
+    <tag>NAME</tag>
+    <size>20</size>
+    <maxlength>60</maxlength>
+    <default></default>
+    <unset></unset>
+    <set>(cn=*$*)</set>
+    <alphabet>false</alphabet>
+    <autocomplete>
+      <backend>LDAP</backend>
+      <filter>(&amp;(objectClass=organizationalRole)(cn=*$NAME*))</filter>
+      <attribute>cn</attribute>
+      <frequency>0.5</frequency>
+      <characters>3</characters>
+    </autocomplete>
+  </element>
+
+</filterdef>
diff --git a/gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-list.tpl b/gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-list.tpl
new file mode 100644 (file)
index 0000000..b233c58
--- /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>{t}Base{/t} {$BASE}&nbsp;<input class='center' type='image' src='images/lists/submit.png' align='middle' title='{t}Update{/t}' name='submit_department' alt='{t}Submit{/t}'>&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/opsi/admin/opsiLicenses/opsiLicense-list.xml b/gosa-plugins/opsi/admin/opsiLicenses/opsiLicense-list.xml
new file mode 100644 (file)
index 0000000..17aab50
--- /dev/null
@@ -0,0 +1,143 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<list>
+  <definition>
+    <departmentBrowser>true</departmentBrowser>
+    <departmentRootVisible>false</departmentRootVisible>
+    <baseMode>true</baseMode>
+    <multiSelect>true</multiSelect>
+    <template>opsiLicense-list.tpl</template>
+    <module>roles</module>
+    <label>List of roles</label>
+    <defaultSortColumn>1</defaultSortColumn>
+
+    <objectType>
+      <label>Role</label>
+      <objectClass>organizationalRole</objectClass>
+      <category>roles</category>
+      <class>role</class>
+      <image>plugins/rolemanagement/images/role.png</image>
+    </objectType>
+
+  </definition>
+
+  <table>
+    <layout>|20px;c||250px|170px;r|</layout>
+
+    <department>
+      <value>%{filter:objectType(dn,objectClass)}</value>
+    </department>
+
+    <department>
+      <value>%{filter:departmentLink(row,dn,description)}</value>
+      <span>2</span>
+    </department>
+
+    <column>
+      <value>%{filter:objectType(dn,objectClass)}</value>
+    </column>
+
+    <column>
+      <label>Name</label>
+      <sortAttribute>cn</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{filter:link(row,dn,"%s",cn)}</value>
+      <export>true</export>
+    </column>
+
+    <column>
+      <label>Description</label>
+      <sortAttribute>description</sortAttribute>
+      <sortType>string</sortType>
+      <value>%{filter:link(row,dn,"%s",description)}</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>plugins/rolemanagement/images/new.png</image>
+      <label>Role</label>
+     </action>
+    </action>
+
+    <action>
+      <type>separator</type>
+    </action>
+
+    <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>
+
+    <action>
+      <type>exporter</type>
+    </action>
+
+    <action>
+      <type>separator</type>
+    </action>
+
+    <action>
+      <type>copypaste</type>
+    </action>
+
+    <action>
+      <type>snapshot</type>
+    </action>
+
+  </actionmenu>
+
+  <actiontriggers snapshot="true" copypaste="true">
+
+    <action>
+      <name>cp</name>
+      <type>copypaste</type>
+    </action>
+
+    <action>
+      <name>edit</name>
+      <type>entry</type>
+      <image>images/lists/edit.png</image>
+      <label>Edit role</label>
+    </action>
+
+    <action>
+      <name>snapshot</name>
+      <type>snapshot</type>
+    </action>
+
+    <action>
+      <name>remove</name>
+      <type>entry</type>
+      <image>images/lists/trash.png</image>
+      <acl>roles/role[d]</acl>
+      <label>Remove role</label>
+    </action>
+
+  </actiontriggers>
+
+</list>