Code

Updated sudo management
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 22 Dec 2009 13:43:25 +0000 (13:43 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 22 Dec 2009 13:43:25 +0000 (13:43 +0000)
-Uses new list handling now.

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

gosa-plugins/sudo/admin/sudo/class_divListSudo.inc [deleted file]
gosa-plugins/sudo/admin/sudo/class_sudoManagement.inc
gosa-plugins/sudo/admin/sudo/main.inc
gosa-plugins/sudo/admin/sudo/sudo-filter.tpl [new file with mode: 0644]
gosa-plugins/sudo/admin/sudo/sudo-filter.xml [new file with mode: 0644]
gosa-plugins/sudo/admin/sudo/sudo-list.tpl [new file with mode: 0644]
gosa-plugins/sudo/admin/sudo/sudo-list.xml [new file with mode: 0644]

diff --git a/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc b/gosa-plugins/sudo/admin/sudo/class_divListSudo.inc
deleted file mode 100644 (file)
index 924115d..0000000
+++ /dev/null
@@ -1,243 +0,0 @@
-<?php
-/*
- * This code is part of GOsa (http://www.gosa-project.org)
- * Copyright (C) 2003-2008 GONICUS GmbH
- *
- * ID: $$Id: class_divListSudSudo.inc 9934 2008-03-18 20:26:47Z 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
- */
-
-
-/*! \brief  The sudo management class.
-            This class lists all configured sudo roles.
- */
-class divListSudo extends MultiSelectWindow
-{
-  /* Regex */
-  public $Regex              = "*";
-  public $UserRegex          = "*";
-
-  /* Subsearch checkbox */
-  public $SubSearch          = FALSE;
-  protected $parent             ;
-  public $ui                 ;
-
-
-  /*! \brief  Initialize this class 
-      @param  Object $config  The GOsa configuration object.
-      @param  Object $parent  The parent class.
-   */
-  function divListSudo (&$config, &$parent)
-  {
-    MultiSelectWindow::MultiSelectWindow($config, "sudo", "sudo");
-    
-    $this->parent       = &$parent;
-    $this->ui           = get_userinfo();
-
-    /* Set list strings */
-    $this->SetTitle(  _("List of sudo roles"));
-    $this->SetSummary(_("List of sudo roles"));
-    $this->EnableAplhabet(true);
-
-    /* Result page will look like a headpage */
-    $this->SetHeadpageMode();
-  
-    /* Disable buttonsm */
-    $this->EnableCloseButton(false);
-    $this->EnableSaveButton (false);
-
-    /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 54;
-    if($this->parent->snapshotEnabled()){
-      $action_col_size += 32;
-    }
-    if($this->parent->CopyPasteHandler){
-      $action_col_size += 20;
-    }
-
-    /* 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 header */
-    $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
-    $this->AddHeader(array("string"=>"&nbsp;","attach"=>"style='width:20px;'"));
-    $this->AddHeader(array("string"=>_("Name")."&nbsp;/&nbsp;"._("Department")));
-    $this->AddHeader(array("string"=>_("Actions"),"attach"=>"style='width:".$action_col_size."px;border-right:0px;'"));
-
-    /* Add SubSearch checkbox */    
-    $this->AddCheckBox("SubSearch",  msgPool::selectToView("","subsearch"),msgPool::selectToView("","subsearch_small"), false);
-    $this->AddRegex   ("Regex"    , _("Regular expression for matching role names")       , 
-      "*" , true);
-    $this->AddRegex   ("UserRegex", _("Regular expression for matching role member names"),
-      "*" , FALSE,"images/lists/search-user.png");
-  }
-
-
-  /*! \brief  Generate the list header.
-   */
-  function GenHeader()
-  {
-    /* Prepare departments,
-       which are shown in the listbox on top of the listbox
-     */
-    $base  = sudo::get_sudoers_ou($this->config);
-    $acl    = $this->ui->get_permissions($base,"sudo/sudo"); 
-    $acl_all= $this->ui->get_category_permissions($base,"sudo"); 
-    /* Add default header */
-    $listhead = MultiSelectWindow::get_default_header(false);
-    
-    /* Create Layers menu */
-    $s  = ".|"._("Actions")."|\n";
-    $s .= "..|<img src='images/lists/new.png' alt='' border='0' class='center'>".
-      "&nbsp;"._("Create")."|\n";
-
-    /* Append create options */
-    if(preg_match("/c/",$acl)) {
-      $s.= "...|<input class='center' type='image' src='plugins/sudo/images/list_new_sudo.png' alt=''>&nbsp;"._("Role")."|new_role|\n";
-      $s.= "...|<input class='center' type='image' src='plugins/sudo/images/list_new_sudo.png' alt=''>&nbsp;"._("Default")."|new_default|\n";
-    }
-
-    /* Append multiple remove */
-    if(preg_match("/r/",$acl)){
-      $s.= "..|---|\n";
-      $s.= "..|<img src='images/lists/trash.png' alt='' border='0' class='center'>".
-        "&nbsp;"._("Remove")."|"."del_role|\n";
-    }
-
-    /* Add Copy & Paste header */
-    $s .= $this->parent->get_copypaste_header($this->selectedBase,$this->module);
-
-    /* Add snapshot icons */
-    $s .= $this->parent->get_snapshot_header($this->selectedBase,$this->module);   
-    $this->SetDropDownHeaderMenu($s);
-    $this->SetListHeader($listhead);
-  }
-
-
-  /*! \brief  Prepare the plguin to list a set of objects 
-   */
-  function execute()
-  {
-    $this->ClearElementsList();
-    $this->GenHeader();
-  }
-
-
-  /*! \brief  Create a list of all objects that should be displayed 
-      @param  Array $list   The list of sudo roles, passed from the sudoManagement class.
-   */
-  function setEntries($list)
-  {
-    /* Prepare links */
-    $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
-    $userimg  = "<img class='center' src='plugins/sudo/images/select_sudo.png' alt='Sudo' title='%s'>";
-    $ui       = get_userinfo();
-
-    $action_col_size = 54;
-    if($this->parent->snapshotEnabled()){
-      $action_col_size += 32;
-    }
-    if($this->parent->CopyPasteHandler){
-      $action_col_size += 20;
-    }
-
-    // Test Every Entry and generate divlist Array
-    foreach($list as $key => $val){
-    
-      /* Create action icons - copy & paste icons */
-      $acl    = $ui->get_permissions($val['dn'],"sudo/sudo");
-      $acl_all= $this->ui->get_category_permissions($val['dn'],"sudo"); 
-
-      /* Add copy & cut functionality */
-      $actions = $this->parent->get_copypaste_action($val['dn'],"sudo","sudo",TRUE,FALSE);
-
-      $actions.= "<input class='center' type='image'
-        src='images/lists/edit.png' alt='".msgPool::editButton()."' name='sudo_edit_%KEY%' title='"._("Edit this entry")."'>";
-
-      /* Add snapshot icon */
-      $actions.= $this->parent->get_snapshot_action($val['dn'],$this->module);
-
-      if(preg_match("/d/",$acl)){
-        $actions.= "<input class='center' type='image'
-          src='images/lists/trash.png' alt='".msgPool::delButton()."' name='sudo_del_%KEY%' title='"._("Delete this entry")."'>";
-      }
-
-      $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;
-     
-      /* Highlight defaults entry */ 
-      if(preg_match("/^defaults$/i",$val['cn'][0])){
-        $display = "<b>$display</b>";
-      }
-
-      /* Cutted objects should be displayed in light grey */
-      if($this->parent->CopyPasteHandler){
-        foreach($this->parent->CopyPasteHandler->queue as $queue_key => $queue_data){
-          if($queue_data['dn'] == $val['dn']) {
-            $display = "<font color='#999999'>".$display."</font>";
-            break;
-          }
-        }
-      }
-
-      $field1 = array("string" => "<input type='checkbox' id='item_selected_".$key."' name='item_selected_".$key."'>" ,
-          "attach" => "style='width:20px;'");
-      $field2 = array("string" => sprintf($userimg,$val['dn']), 
-          "attach" => "style='text-align:center;width:20px;'");
-      $field3 = 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($field1,$field2,$field3,$field4));
-    }
-
-    /* Create summary string for list footer */
-    $num     = count($list);
-    $num_str  = _("Number of listed roles");
-    $str = "<img class='center' src='plugins/sudo/images/select_sudo.png'
-              title='".$num_str."' alt='".$num_str."'>&nbsp;".$num."&nbsp;";
-    $this->set_List_Bottom_Info($str);
-  }
-
-  
-  /*! \brief  Save this plugin. In this case nothing will be saved
-    */
-  function Save()
-  {
-    MultiSelectWindow :: Save();  
-  }
-
-  /*! \brief  Save all relevant HTML inputs for this plugin.
-    */
-  function save_object()
-  {
-    /* Save automatic created POSTs like regex, checkboxes */
-    MultiSelectWindow::save_object();   
-  }
-}
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
index 7a1365bb4cab64bd60b08440eb5167f5004b0d18..2d98e4a00bb0a593e62b7f22d38c82124431c84e 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: class_sudoManagement.inc 10099 2008-04-01 12:52:01Z hickert $$
+ * 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
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-/*! \brief This is the sudo management class. \
-           This class allows to add/remove/edit sudo roles with GOsa. \
-           All roles will be listed by this plugin, the displayed objects \
-            can also be filtered.
-*/
-class sudoManagement extends plugin
+class sudoManagement extends management
 {
-  /* Definitions */
-  public $plHeadline     = "Sudo roles";
-  public $plDescription  = "Manage sudo roles";
-  public $plIcon  ="plugins/sudo/images/sudo.png";
-
-  private $DivListSudo    = NULL;
-  private $sudotabs       = NULL;
-  private $base           = "";
-
-  private $start_pasting_copied_objects = FALSE;
-
-  public $acl_module = array("sudo");
-  public $CopyPasteHandler = NULL;
-  /*! \brief */ 
-  public function __construct(&$config, &$ui)
-  {
-    /* Save configuration for internal use */
-    $this->config = &$config;
-    $this->ui     = &$ui;
-    $this->base   = sudo::get_sudoers_ou($this->config);
-
-    /* Copy & Paste enabled ?*/
-    if ($this->config->get_cfg_value("copyPaste") == "true"){
-      $this->CopyPasteHandler = new CopyPasteHandler($this->config);
-    }
-
-    /* Create dialog object */
-    $this->DivListSudo = new divListSudo($this->config,$this);
-  }
-
-
-  /*! \brief Generate && Display HTML content 
-   */
-  public function execute()
-  {
-    /* Call parent execute */
-    plugin::execute();
-
-    /********************
-      Handle Posts
-     ********************/
-
-    /* Store these posts if the current object is locked (used by somebody else)*/
-    session::set('LOCK_VARS_TO_USE',array(
-          "/^act$/","/^id$/","/^sudo_edit_/","/^cut_/","/^copy_/",
-          "/^sudo_del_/","/^item_selected/","/menu_action/"));
-
-
-    /* Get html posts */
-    $s_action   = "";
-    $s_entry    = "";
-    foreach($_POST as $name => $value){
-      if(preg_match("/^sudo_edit_/",$name)){
-        $s_action = "edit_role";
-        $s_entry  = preg_replace("/^sudo_edit_([0-9]*).*$/","\\1",$name);
-      }
-      if(preg_match("/^sudo_del_/",$name)){
-        $s_action = "del_role";
-        $s_entry  = preg_replace("/^sudo_del_([0-9]*).*$/","\\1",$name);
-      }elseif(preg_match("/^editPaste.*/i",$name)){
-        $s_action="editPaste";
-      }elseif(preg_match("/^copy_.*/",$name)){
-        $s_action="copy";
-        $s_entry  = preg_replace("/^copy_([0-9]*).*$/i","\\1",$name);
-#      }elseif(preg_match("/^cut_.*/",$name)){
-#        $s_action="cut";
-#        $s_entry  = preg_replace("/^cut_([0-9]*).*$/i","\\1",$name);
-      }
-    }
-
-    if(isset($_GET['act']) && isset($_GET['id']) && $_GET['act'] == "edit_entry"){
-      $id = trim($_GET['id']);
-      if(isset($this->list[$id])){
-        $s_action = "edit_role";
-        $s_entry  = $id;
-      } 
-    }
-
-    if(isset($_POST['menu_action']) && in_array($_POST['menu_action'],array("new_role","del_role","new_default","editPaste"))){
-      $s_action = $_POST['menu_action'];
-    }
-
-    /* handle C&P from layers menu */
-    if(isset($_POST['menu_action']) && preg_match("/^multiple_copy_systems/",$_POST['menu_action'])){
-      $s_action = "copy_multiple";
-    }
-
-    $smarty= get_smarty();
-
-    /********************
-      Copy & Paste Handling  ...
-     ********************/
-
-    /* Display the copy & paste dialog, if it is currently open */
-    $ret = $this->copyPasteHandling_from_queue($s_action,$s_entry);
-    if($ret){
-      return($ret);
-    }
-
-
-    /********************
-      Create a new sudo  ...
-     ********************/
-
-    /* New sudo? */
-    if ($s_action=="new_role" || $s_action == "new_default"){
-
-      /* Check create permissions */
-      $acl = $this->ui->get_permissions($this->base,"sudo/sudo");
-      if(preg_match("/c/",$acl)){
-
-        /* By default we set 'dn' to 'new', all relevant plugins will
-           react on this. */
-        $this->dn= "new";
-
-        /* Create new sudotabs object */
-        $this->sudotabs= new sudotabs($this->config, $this->config->data['TABS']['SUDOTABS'], $this->dn);
-
-        /* Set up the sudo ACL's for this 'dn' */
-        $this->sudotabs->set_acl_base($this->base);
-
-        /* This entry will become the default entry */
-        if($s_action == "new_default"){
-          $this->sudotabs->set_default(TRUE);
-        }
-      }
-    }
-
-
-    /********************
-      Save Sudo Tab/Object Changes
-     ********************/
-
-    /* Save changes */
-    if ((isset($_POST['edit_finish']) || isset($_POST['edit_apply'])) && is_object($this->sudotabs)){
-
-      /* Check tabs, will feed message array 
-         Save, or display error message? */
-      $message= $this->sudotabs->check();
-      if (count($message) == 0){
-
-        /* Save user data to ldap */
-        $this->sudotabs->save();
-
-        if (!isset($_POST['edit_apply'])){
-
-          /* Sudo has been saved successfully, remove lock from LDAP. */
-          if ($this->dn != "new"){
-            $this->remove_lock();
-          }
-          unset ($this->sudotabs);
-          $this->sudotabs= NULL;
-          set_object_info();
-        }else{
-
-          /* Reinitialize tab */
-          if($this->sudotabs instanceof tabs){
-            $this->sudotabs->re_init();
-          }
-        }
-      } else {
-        /* Ok. There seem to be errors regarding to the tab data,
-           show message and continue as usual. */
-        msg_dialog::displayChecks($message);
-      }
-    }
-
-
-    /********************
-      Edit existing role 
-     ********************/
-
-    /* User wants to edit data? */
-    if (($s_action=="edit_role") &&  !is_object($this->sudotabs)){
-
-      /* Get 'dn' from posted 'uid', must be unique */
-      $this->dn= $this->list[trim($s_entry)]['dn'];
-
-      /* Check locking & lock entry if required */
-      $user = get_lock($this->dn);
-      if ($user != ""){
-        return(gen_locked_message ($user, $this->dn));
-      }
-      add_lock ($this->dn, $this->ui->dn);
-
-      /* Register sudotabs to trigger edit dialog */
-      $this->sudotabs= new sudotabs($this->config,$this->config->data['TABS']['SUDOTABS'], $this->dn);
-      $this->sudotabs->set_acl_base($this->base);
-      set_object_info($this->dn);
-    }
-
-
-    /********************
-      Delete entries requested, display confirm dialog
-     ********************/
-
-    if ($s_action=="del_role"){
-      $ids = $this->list_get_selected_items();
-      if(!count($ids) && $s_entry!=""){
-        $ids = array($s_entry);
-      }
-
-      $this->dns = array();
-      if(count($ids)){
-        $disallowed = array();
-        foreach($ids as $id){
-          $dn = $this->list[$id]['dn'];
-          $acl = $this->ui->get_permissions($dn, "sudo/sudo");
-          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)){
-
-          /* Check locking of entries */
-          $users = get_multiple_locks($this->dns);
-          if(count($users)){
-            return(gen_locked_message($users,$this->dns));
-          }
-
-          /* Add locks */
-          add_lock($this->dns,$this->ui->dn);
-
-          /* Lock the current entry, so nobody will edit it during deletion */
-          $smarty->assign("info", msgPool::deleteInfo($this->dns,_("Sudo role")));
-          return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
-        }
-      }
-    }
-
-
-    /********************
-      Delete entries confirmed
-     ********************/
-
-    /* Confirmation for deletion has been passed. Sudo should be deleted. */
-    if (isset($_POST['delete_sudos_confirmed'])){
-
-      /* Remove user by user and check acls before removeing them */
-      foreach($this->dns as $key => $dn){
-
-        /* Load permissions for selected 'dn' and check if
-           we're allowed to remove this 'dn' */
-        $acl = $this->ui->get_permissions($dn,"sudo/sudo");
-        if(preg_match("/d/",$acl)){
-
-          /* Delete request is permitted, perform LDAP action */
-          $this->sudotabs= new sudotabs($this->config,$this->config->data['TABS']['SUDOTABS'], $dn);
-          $this->sudotabs->set_acl_base($dn);
-          $this->sudotabs->delete ();
-          unset ($this->sudotabs);
-          $this->sudotabs= NULL;
-
-        } else {
-
-          /* Normally this shouldn't be reached, send some extra
-             logs to notify the administrator */
-          msg_dialog::display(_("Permission error"), msgPool::permDelete(), ERROR_DIALOG);
-          new log("security","sudo/".get_class($this),$dn,array(),"Tried to trick deletion.");
-        }
-      }
-
-      /* Remove lock file after successfull deletion */
-      $this->remove_lock();
-      $this->dns = array();
-    }
-
-
-    /********************
-      Delete entries Canceled
-     ********************/
-
-    /* Remove lock */
-    if(isset($_POST['delete_sudo_cancel'])){
-      $this->remove_lock();
-      $this->dns = array();
-    }
-
-    /********************
-      A dialog was canceled  
-     ********************/
-
-    /* Cancel dialogs */
-    if (isset($_POST['edit_cancel']) && is_object($this->sudotabs)){
-      $this->remove_lock();
-      $this->sudotabs= NULL;
-      set_object_info();
-    }
-
-
-    /********************
-      If there is currently a dialog open, display it
-     ********************/
-
-    /* Show tab dialog if object is present */
-    if (is_object($this->sudotabs)){
-      $display= $this->sudotabs->execute();
-
-      /* Don't show buttons if tab dialog requests this */
-      if(isset($this->sudotabs->by_object)){
-        if (!$this->sudotabs->by_object[$this->sudotabs->current]->dialog){
-          $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);
-    }
-
-    /* Check if there is a snapshot dialog open */
-    if($str = $this->showSnapshotDialog(sudo::get_sudoers_ou($this->config),$this->get_used_snapshot_bases(),$this)){
-      return($str);
-    }
-
-    /* Display dialog with sudo list */
-    $this->DivListSudo->execute();
-    $this->reload ();
-    $this->DivListSudo->setEntries($this->list);
-    return($this->DivListSudo->Draw());
-  }
-
-  
-  /*! \brief  Return all selected elements from HTML list 
-      @return Array List of all selected list elements 
-    */
-  private function list_get_selected_items()
+  var $plHeadline     = "Sudo";
+  var $plDescription  = "Sudo management";
+  var $plIcon  = "plugins/sudo/images/sudo.png";
+
+  // Tab definition 
+  protected $tabClass = "sudotabs";
+  protected $tabType = "SUDOTABS";
+  protected $aclCategory = "sudo";
+  protected $aclPlugin   = "sudo";
+  protected $objectName   = "sudo";
+
+  function __construct($config,$ui)
   {
-    $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);
-  }
-
-
-  /*! \brief  Reload the list of sudo roles. 
-   */
-  private function reload($CreatePosixsList=false)
-  {
-    $this->list             = array();
-    $base                   = $this->base;
-
-    $Regex                  = trim($this->DivListSudo->Regex);
-    $UserRegex              = trim($this->DivListSudo->UserRegex);
-    $SubSearch              = $this->DivListSudo->SubSearch;
-
-    /********************
-      Create filter depending on selected checkboxes 
-     ********************/
-    $values = array("cn","description","sudoUser","sudoCommand","sudoOption");
-    if($UserRegex == "*"){
-      $ff     = "(&(|(cn=".$Regex.")(description=".$Regex."))(objectClass=sudoRole))";
-    }else{
-      $ff     = "(&(|(cn=".$Regex.")(description=".$Regex."))(sudoUser=".$UserRegex.")(objectClass=sudoRole))";
-    }
-    $res = get_list($ff, "sudo",$base,$values, GL_SIZELIMIT);
-    $tmp = array();
-    foreach($res as $attrs){
-      $tmp[$attrs['cn'][0]] = $attrs;
-    }
-    uksort($tmp, 'strnatcasecmp');  
-    $this->list = array_values($tmp);
-  }
-
-
-  /*! \brief Save HTML post data to object 
-   */
-  public function save_object()
-  {
-    $this->DivListSudo->save_object();
-    if(is_object($this->CopyPasteHandler)){
-      $this->CopyPasteHandler->save_object();
-    }
-  }
-
-  
-  /*! \brief Remove this account 
-   */
-  public function remove_from_parent()
-  {
-    /* Optionally execute a command after we're done */
-    $this->postremove();
-  }
-
-
-  /*! \brief Save to LDAP 
-   */
-  public function save()
-  {
-    /* Optionally execute a command after we're done */
-    $this->postcreate();
-  }
-
-  
-  /*! \brief Remove lock from entry 
-   */
-  public function remove_lock()
-  {
-    if (is_object($this->sudotabs) && $this->sudotabs->dn != "new"){
-      del_lock ($this->sudotabs->dn);
-    }
-    if(isset($this->dns) && is_array($this->dns) && count($this->dns)){
-      del_lock($this->dns);
-    }
-  }
-
-  function get_used_snapshot_bases()
-  {
-    return(array(sudo::get_sudoers_ou($this->config)));
-  }
-
-
-  function copyPasteHandling_from_queue($s_action,$s_entry)
-  {
-    /* Check if Copy & Paste is disabled */
-    if(!is_object($this->CopyPasteHandler)){
-      return("");
-    }
-
-    $ui = get_userinfo();
-
-    /* Add a single entry to queue */
-    if($s_action == "cut" || $s_action == "copy"){
-
-      /* Cleanup object queue */
-      $this->CopyPasteHandler->cleanup_queue();
-      $dn = $this->list[$s_entry]['dn'];
-
-      if($s_action == "copy" && $ui->is_copyable($dn,"sudo","sudo")){
-        $this->CopyPasteHandler->add_to_queue($dn,$s_action,"sudotabs","SUDOTABS","sudo");
-      }
-#      if($s_action == "cut" && $ui->is_cutable($dn,"sudo","sudo")){ 
-#        $this->CopyPasteHandler->add_to_queue($dn,$s_action,"sudotabs","SUDOTABS","sudo");
-#      }
-    }
-
-    /* Add entries to queue */
-    if($s_action == "copy_multiple" || $s_action == "cut_multiple"){
-
-      /* Cleanup object queue */
-      $this->CopyPasteHandler->cleanup_queue();
-
-      /* Add new entries to CP queue */
-      foreach($this->list_get_selected_items() as $id){
-        $dn = $this->list[$id]['dn'];
-
-        if($s_action == "copy_multiple" && $ui->is_copyable($dn,"sudo","sudo")){ 
-          $this->CopyPasteHandler->add_to_queue($dn,"copy","sudotabs","SUDOTABS","sudo");
-        }
-#        if($s_action == "cut_multiple" && $ui->is_cutable($dn,"sudo","sudo")){
-#          $this->CopyPasteHandler->add_to_queue($dn,"cut","sudotabs","SUDOTABS","sudo");
-#        }
-      }
-    }
-
-    /* Start pasting entries */
-    if($s_action == "editPaste"){
-      $this->start_pasting_copied_objects = TRUE;
-    }
-
-    /* Return C&P dialog */
-    if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
-
-      /* Get dialog */
-      $this->CopyPasteHandler->SetVar("base",$this->DivListSudo->selectedBase);
-      $data = $this->CopyPasteHandler->execute();
-
-      /* Return dialog data */
-      if(!empty($data)){
-        return($data);
-      }
-    }
-
-    /* Automatically disable status for pasting */
-    if(!$this->CopyPasteHandler->entries_queued()){
-      $this->start_pasting_copied_objects = FALSE;
-    }
-    return("");
+    $this->config = $config;
+    $this->ui = $ui;
+   
+    $this->storagePoints = array(get_ou("sudoRDN"));
+    // 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("sudo-filter.xml", true));
+      $filter->setObjectStorage($this->storagePoints);
+   # }
+    $this->setFilter($filter);
+
+    // Build headpage
+    $headpage = new listing(get_template_path("sudo-list.xml", true));
+    $headpage->setFilter($filter);
+
+    // Add copy&paste and snapshot handler.
+    if ($this->config->boolValueIsTrue("main", "copyPaste")){
+      $this->cpHandler = new CopyPasteHandler($this->config);
+    }
+    if($this->config->get_cfg_value("enableSnapshots") == "true"){
+      $this->snapHandler = new SnapshotHandler($this->config);
+    }
+    parent::__construct($config, $ui, "sudo", $headpage);
   }
-}
+} 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index e30efdd7b5deb161c4871687ac903d32835e6423..95f4dd58be5282d6f6fc7bf72da6a7bc326044df 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 9275 2008-03-04 07:29:22Z cajus $$
+ * ID: $$Id: main.inc 14740 2009-11-04 09:41:16Z 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
@@ -20,7 +20,6 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-
 /* Remove locks created by this plugin
 */
 if ($remove_lock){
@@ -36,25 +35,13 @@ if ( $cleanup ){
   session::un_set('sudoManagement');
 }else{
 
-  /* Create sudoManagement object on demand */
+  /* Create rolemanagement object on demand */
   if (!session::is_set('sudoManagement')){
-    session::set('sudoManagement',new sudoManagement ($config, $ui));
+    $sudoManagement= new sudoManagement ($config, $ui);
+    session::set('sudoManagement',$sudoManagement);
   }
   $sudoManagement = session::get('sudoManagement');
-  $sudoManagement->save_object();
-  $output= $sudoManagement->execute();
-
-  /* Page header*/
-  if (get_object_info() != ""){
-    $display= print_header(get_template_path('plugins/sudo/images/sudo.png'),
-                            _("Sudo role administration"), "<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/sudo/images/sudo.png'), _("Sudo role administration"));
-  }
-
-  $display.= $output;
+  $display= $sudoManagement->execute();
 
   /* Reset requested? */
   if (isset($_GET['reset']) && $_GET['reset'] == 1){
diff --git a/gosa-plugins/sudo/admin/sudo/sudo-filter.tpl b/gosa-plugins/sudo/admin/sudo/sudo-filter.tpl
new file mode 100644 (file)
index 0000000..aeee111
--- /dev/null
@@ -0,0 +1,39 @@
+<div class="contentboxh">
+ <p class="contentboxh">
+  <img src="images/launch.png" align="right" alt="[F]">{t}Filter{/t}
+ </p>
+</div>
+
+<div class="contentboxb">
+
+ <table summary="" style="width:100%;border-top:1px solid #B0B0B0;">
+  <tr>
+   <td>
+    <label for="NAME">
+     <img src="images/lists/search.png" align=middle>&nbsp;{t}Name{/t}
+    </label>
+   </td>
+   <td>
+    {$NAME}
+   </td>
+  </tr>
+  <tr>
+   <td>
+    <label for="USER">
+     <img src="images/lists/search.png" align=middle>&nbsp;{t}User{/t}
+    </label>
+   </td>
+   <td>
+    {$USER}
+   </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/sudo/admin/sudo/sudo-filter.xml b/gosa-plugins/sudo/admin/sudo/sudo-filter.xml
new file mode 100644 (file)
index 0000000..02e1cbc
--- /dev/null
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<filterdef>
+  <definition>
+    <category>sudo</category>
+    <template>sudo-filter.tpl</template>
+    <initial>true</initial>
+  </definition>
+
+  <search>
+    <query>
+      <backend>LDAP</backend>
+      <filter>(&amp;(objectClass=sudoRole)$NAME$USER)</filter>
+      <attribute>dn</attribute>
+      <attribute>objectClass</attribute>
+      <attribute>cn</attribute>
+      <attribute>description</attribute>
+      <attribute>sudoUser</attribute>
+      <attribute>sudoHost</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=*$*)(description=*$*))</set>
+    <alphabet>true</alphabet>
+    <autocomplete>
+      <backend>LDAP</backend>
+      <filter>(&amp;(objectClass=sudoRole)(|(cn=*$NAME*)(description=*$NAME*)))</filter>
+      <attribute>cn</attribute>
+      <frequency>0.5</frequency>
+      <characters>3</characters>
+    </autocomplete>
+  </element>
+
+  <element>
+    <type>textfield</type>
+    <tag>USER</tag>
+    <size>20</size>
+    <maxlength>60</maxlength>
+    <default></default>
+    <unset></unset>
+    <set>(|(sudoHost=*$*)(sudoUser=*$*))</set>
+    <alphabet>true</alphabet>
+    <autocomplete>
+      <backend>LDAP</backend>
+      <filter>(&amp;(objectClass=sudoRole)(|(sudoHost=*$USER*)(sudoUser=*$USER*)))</filter>
+      <attribute>cn</attribute>
+      <frequency>0.5</frequency>
+      <characters>3</characters>
+    </autocomplete>
+  </element>
+
+</filterdef>
diff --git a/gosa-plugins/sudo/admin/sudo/sudo-list.tpl b/gosa-plugins/sudo/admin/sudo/sudo-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/sudo/admin/sudo/sudo-list.xml b/gosa-plugins/sudo/admin/sudo/sudo-list.xml
new file mode 100644 (file)
index 0000000..ed887a4
--- /dev/null
@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<list>
+  <definition>
+    <departmentBrowser>false</departmentBrowser>
+    <departmentRootVisible>false</departmentRootVisible>
+    <baseMode>false</baseMode>
+    <multiSelect>true</multiSelect>
+    <template>sudo-list.tpl</template>
+    <module>sudo</module>
+    <label>List of sudo roles</label>
+    <defaultSortColumn>1</defaultSortColumn>
+
+    <objectType>
+      <label>Role</label>
+      <objectClass>sudoRole</objectClass>
+      <category>sudo</category>
+      <class>sudo</class>
+      <image>plugins/sudo/images/select_sudo.png</image>
+    </objectType>
+
+  </definition>
+
+  <table>
+    <layout>|16px|120px||170px;r|</layout>
+
+    <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/sudo/images/list_new_sudo.png</image>
+      <label>Role</label>
+     </action>
+
+     <action>
+      <name>new_default</name>
+      <type>entry</type>
+      <image>plugins/sudo/images/list_new_sudo.png</image>
+      <label>Default</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>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 sudo 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>sudo/sudo[d]</acl>
+      <label>Remove sudo role</label>
+    </action>
+
+  </actiontriggers>
+
+</list>