Code

Updated headers
[gosa.git] / gosa-core / plugins / admin / groups / class_groupManagement.inc
index fb8d0148982f0c221952cb20eb2e2a554e828ef2..7a764e80ebc9dcc6c8429ce55fb56b14697fce52 100644 (file)
@@ -1,28 +1,30 @@
 <?php
 /*
-   This code is part of GOsa (https://gosa.gonicus.de)
-   Copyright (C) 2003  Cajus Pollmeier
-
-   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
+ * This code is part of GOsa (http://www.gosa-project.org)
+ * Copyright (C) 2003-2008 GONICUS GmbH
+ *
+ * ID: $$Id$$
+ *
+ * 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 groupManagement extends plugin
 {
   /* Definitions */
   var $plHeadline= "Groups";
-  var $plDescription= "This does something";
+  var $plDescription= "Manage POSIX groups";
 
   /* Dialog attributes */
   var $grouptab           = NULL;
@@ -67,7 +69,7 @@ class groupManagement extends plugin
        plugin::execute();
 
     /* Store these posts if the current object is locked (used by somebody else)*/
-    $_SESSION['LOCK_VARS_TO_USE'] = array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_groups/");
+    session::set('LOCK_VARS_TO_USE',array("/^act$/","/^id$/","/^group_edit_/","/^group_del_/","/^item_selected/","/^remove_multiple_groups/","/^multiple_edit/","/menu_action/"));
 
     /* Save data */
     $s_action   = "";
@@ -142,11 +144,60 @@ class groupManagement extends plugin
     if(isset($_POST['menu_action']) && preg_match("/^remove_multiple/",$_POST['menu_action'])){
       $s_action = "del_multiple";
     }
+    if(isset($_POST['menu_action']) && $_POST['menu_action'] == "multiple_edit"){
+      $s_action = "multiple_edit";
+    }
 
-
+    if(isset($_POST['menu_action']) && preg_match("/^trigger_event_DaemonEvent_notify/",$_POST['menu_action'])){
+      $s_action = "notify";
+    }
 
     $smarty= get_smarty();
 
+
+
+    /********************
+      Create notification event
+     ********************/
+
+    if($s_action == "notify"){
+
+      $ids = $this->list_get_selected_items();
+      $uids = array();
+      foreach($ids as $id){
+        $uids[] = $this->grouplist[$id]['cn'][0];
+      }
+      if(count($uids)){
+        $this->grouptab = new DaemonEvent_notify($this->config);
+        $this->grouptab->add_targets($uids);
+      }
+    }
+
+    /* Abort event dialog */
+    if(isset($_POST['abort_event_dialog'])){
+      $this->grouptab = FALSE;
+    }
+
+    /* Save event */
+    if(isset($_POST['save_event_dialog'])){
+      $o_queue = new gosaSupportDaemon();
+      $o_queue->append($this->grouptab);
+      if($o_queue->is_error()){
+        msg_dialog::display(_("Daemon"),sprintf(_("Something went wrong while talking to the daemon: %s."),
+              $o_queue->get_error()),ERROR_DIALOG);
+      }else{
+        $this->grouptab = FALSE;
+      }
+    }
+
+    /* Display event */
+    if($this->grouptab instanceof DaemonEvent){
+      $this->grouptab->save_object();
+      return($this->grouptab->execute());
+    }
+
+
+
     /********************
       Copy & Paste Handling  ...
      ********************/
@@ -173,7 +224,7 @@ class groupManagement extends plugin
            react on this. */
         $this->dn= "new";
 
-        /* Create new usertab object */
+        /* Create new grouptab object */
         $this->grouptab= new grouptabs($this->config, $this->config->data['TABS']['GROUPTABS'], $this->dn);
 
         /* Set up the group ACL's for this 'dn' */
@@ -219,6 +270,30 @@ class groupManagement extends plugin
     }
 
 
+    /********************
+      Edit multiple entries
+     ********************/
+
+    /* User wants to edit data? */
+    if ($s_action == "multiple_edit" && !isset($this->grouptab->config)){
+
+      $this->dn = array();
+      foreach($this->list_get_selected_items() as $id){
+        $this->dn[] = $this->grouplist[$id]['dn'];;
+      }
+      $tmp = new multi_plug($this->config,"grouptabs",$this->config->data['TABS']['GROUPTABS'],
+            $this->dn,$this->DivListGroup->selectedBase,"groups");
+      if ($tmp->entries_locked()){
+        return($tmp->display_lock_message());
+      }
+      $tmp->lock_entries($this->ui->dn);
+      if($tmp->multiple_available()){
+        $this->grouptab = $tmp;
+        session::set('objectinfo',$this->grouptab->get_object_info());
+      }
+    }
+
+
     /********************
       Edit existing group 
      ********************/
@@ -239,7 +314,7 @@ class groupManagement extends plugin
       /* Register grouptab to trigger edit dialog */
       $this->grouptab= new grouptabs($this->config,$this->config->data['TABS']['GROUPTABS'], $this->dn);
       $this->grouptab->set_acl_base($this->dn);
-      $_SESSION['objectinfo']= $this->dn;
+      session::set('objectinfo',$this->dn);
     }
 
 
@@ -305,7 +380,7 @@ class groupManagement extends plugin
 
             /* Normally this shouldn't be reached, send some extra
                logs to notify the administrator */
-            print_red (_("You are not allowed to delete this group!"));
+            msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG);
             new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
           }
           /* Remove lock file after successfull deletion */
@@ -358,7 +433,7 @@ class groupManagement extends plugin
       } else {
         
         /* Obviously the user isn't allowed to delete. Show message and clean session. */
-        print_red (_("You are not allowed to delete this group!"));
+        msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG);
       }
     }
 
@@ -389,7 +464,7 @@ class groupManagement extends plugin
 
         /* Normally this shouldn't be reached, send some extra
            logs to notify the administrator */
-        print_red (_("You are not allowed to delete this group!"));
+        msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), ERROR_DIALOG);
         new log("security","groups/".get_class($this),$dn,array(),"Tried to trick deletion.");
       }
 
@@ -512,7 +587,7 @@ class groupManagement extends plugin
     /* Prepare ldap class */
     $ldap= $this->config->get_ldap_link();
     $ldap->cd($base);
-    $ldap->set_size_limit($_SESSION['size_limit']);
+    $ldap->set_size_limit(session::get('size_limit'));
 
 
     /********************
@@ -565,17 +640,16 @@ class groupManagement extends plugin
        Only perfrom this search if  ShowFunctionalGroups  is unchecked, else leave arre empty  */ 
     $ff = "(&(cn=$Regex)(objectClass=posixGroup)(!(|(objectClass=gosaMailAccount)(objectClass=gosaApplicationGroup)$sfilter)))";
     if ($SubSearch){
-      $res = get_list($ff, "groups", $base,array("gidNumber", "cn", "description"), GL_SUBSEARCH);
+      $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_SUBSEARCH);
     } else {
-      $res = get_list($ff, "groups", $base,array("gidNumber", "cn", "description"), GL_NONE);
+      $res = get_sub_list($ff, "groups",get_groups_ou(), $base,array("gidNumber", "cn", "description"), GL_NONE);
     }
     foreach($res as $attrs){
       if (!isset($primaries[$attrs['gidNumber'][0]])){
         $functional[$attrs['gidNumber'][0]]= $attrs['gidNumber'][0];
       }
     }
-   
-
     /********************
       Search for the prepared filter 
      ********************/
@@ -661,12 +735,9 @@ class groupManagement extends plugin
     /* Return C&P dialog */
     if($this->start_pasting_copied_objects && $this->CopyPasteHandler->entries_queued()){
 
-      /* Load entry from queue and set base */
-      $this->CopyPasteHandler->load_entry_from_queue();
-      $this->CopyPasteHandler->SetVar("base",$this->DivListGroup->selectedBase);
-
       /* Get dialog */
       $data = $this->CopyPasteHandler->execute();
+      $this->CopyPasteHandler->SetVar("base",$this->DivListGroup->selectedBase);
 
       /* Return dialog data */
       if(!empty($data)){