Code

Added trust stuff - not finished yet. Save and load works.
[gosa.git] / gosa-core / plugins / admin / ogroups / class_ogroupManagement.inc
index 39c9ea8ba2aebd81d5e6eca82adfa60aecd404c8..64899b4e4e3e97d873acbaa569cd66e9ecc7a33c 100644 (file)
@@ -1,28 +1,30 @@
 <?php
 /*
-   This code is part of GOsa (https://gosa.gonicus.de)
-   Copyright (C) 2004 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 ogroupManagement extends plugin
 {
   /* Definitions */
   var $plHeadline= "Object groups";
-  var $plDescription= "This does something";
+  var $plDescription= "Manage object groups";
 
   /* attribute list for save action */
   var $attributes= array();
@@ -130,6 +132,56 @@ class ogroupManagement extends plugin
       $s_action = "del_multiple";
     }
 
+    /* Hanlde notification event requests */
+    if(isset($_POST['menu_action']) && preg_match("/^event/",$_POST['menu_action'])){
+      $s_action = $_POST['menu_action'];
+    }
+
+
+    /********************
+      Create notification event
+     ********************/
+
+    if(preg_match("/^event_/",$s_action) && class_available("DaemonEvent")){
+      $ids = $this->list_get_selected_items();
+      $uids = array();
+      foreach($ids as $id){
+        $uids[] = $this->ogrouplist[$id]['cn'][0];
+      }
+      if(count($uids)){
+        $events = DaemonEvent::get_event_types(USER_EVENT);
+        $event = preg_replace("/^event_/","",$s_action);
+        if(isset($events['BY_CLASS'][$event])){
+          $type = $events['BY_CLASS'][$event];
+          $this->ogroup = new $type['CLASS_NAME']($this->config);
+          $this->ogroup->add_targets($uids);
+          $this->ogroup->set_type(TRIGGERED_EVENT);
+        }
+      }
+    }
+
+    /* Abort event dialog */
+    if(isset($_POST['abort_event_dialog'])){
+      $this->ogroup = FALSE;
+    }
+
+    /* Save event */
+    if(isset($_POST['save_event_dialog'])){
+      $o_queue = new gosaSupportDaemon();
+      $o_queue->append($this->ogroup);
+      if($o_queue->is_error()){
+        msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+      }else{
+        $this->ogroup = FALSE;
+      }
+    }
+
+    /* Display event */
+    if($this->ogroup instanceof DaemonEvent){
+      $this->ogroup->save_object();
+      return($this->ogroup->execute());
+    }
+
 
     /****************
       Copy & Paste handling 
@@ -153,7 +205,7 @@ class ogroupManagement extends plugin
          react on this. */
       $this->dn= "new";
 
-      /* Create new usertab object */
+      /* Create new ogroup- object */
       $this->ogroup= new ogrouptabs($this->config,$this->config->data['TABS']['OGROUPTABS'], $this->dn,"ogroups");
       $this->ogroup->set_acl_base($this->DivListOGroup->selectedBase);
     }
@@ -172,18 +224,14 @@ class ogroupManagement extends plugin
           }
           $this->dns[$id] = $dn;
         }
-        $dns_names = "<br><pre>";
+        $dns_names = array();
         foreach($this->dns as $dn){
           add_lock ($dn, $this->ui->dn);
-          $dns_names .= $dn."\n";
+          $dns_names[] = @LDAP::fix($dn);
         }
-        $dns_names .="</pre>";
+
         /* Lock the current entry, so nobody will edit it during deletion */
-        if (count($this->dns) == 1){
-          $smarty->assign("info",     sprintf(_("You're about to delete the following object entry %s"), @LDAP::fix($dns_names)));
-        } else {
-          $smarty->assign("info",     sprintf(_("You're about to delete the following object entries %s"), @LDAP::fix($dns_names)));
-        }
+        $smarty->assign("info", msgPool::deleteInfo($dns_names,_("object group")));
         $smarty->assign("multiple", true);
         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
       }
@@ -212,7 +260,7 @@ class ogroupManagement extends plugin
 
           /* Normally this shouldn't be reached, send some extra
              logs to notify the administrator */
-          msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), INFO_DIALOG);
+          msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
           new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion.");
         }
         /* Remove lock file after successfull deletion */
@@ -257,14 +305,14 @@ class ogroupManagement extends plugin
 
         /* Lock the current entry, so nobody will edit it during deletion */
         add_lock ($this->dn, $this->ui->dn);
-        $smarty->assign("info", sprintf(_("You're about to delete the object group '%s'."), @LDAP::fix($this->dn)));
+        $smarty->assign("info", msgPool::deleteInfo(@LDAP::fix($this->dn),_("object group")));
         $smarty->assign("multiple", false);
         return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
       } else {
 
         /* Obviously the user isn't allowed to delete. Show message and
            clean session. */
-        msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), INFO_DIALOG);
+        msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
       }
     }
 
@@ -291,7 +339,7 @@ class ogroupManagement extends plugin
 
         /* Normally this shouldn't be reached, send some extra
            logs to notify the administrator */
-        msg_dialog::display(_("Permission error"), _("You have no permission to delete this entry!"), INFO_DIALOG);
+        msg_dialog::display(_("Permission error"), msgPool::permDelete(), INFO_DIALOG);
         new log("security","ogroups/".get_class($this),$dn,array(),"Tried to trick deletion.");
       }
 
@@ -364,11 +412,17 @@ class ogroupManagement extends plugin
           unset ($this->ogroup);
           $this->ogroup= NULL;
           session::un_set('objectinfo');
+        }else{
+
+          /* Reinitialize tab */
+          if($this->ogroup instanceof tabs){
+            $this->ogroup->re_init();
+          }
         }
       } else {
         /* Ok. There seem to be errors regarding to the tab data,
            show message and continue as usual. */
-        show_errors($message);
+        msg_dialog::displayChecks($message);
       }
     }
 
@@ -397,13 +451,13 @@ class ogroupManagement extends plugin
       /* Don't show buttons if tab dialog requests this */
       if (!$this->ogroup->by_object[$this->ogroup->current]->dialog){
         $display.= "<p style=\"text-align:right\">\n";
-        $display.= "<input type=submit name=\"edit_finish\" style=\"width:80px\" value=\""._("Ok")."\">\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=\""._("Apply")."\">\n";
+          $display.= "<input type=submit name=\"edit_apply\" value=\"".msgPool::applyButton()."\">\n";
           $display.= "&nbsp;\n";
         }
-        $display.= "<input type=submit name=\"edit_cancel\" value=\""._("Cancel")."\">\n";
+        $display.= "<input type=submit name=\"edit_cancel\" value=\"".msgPool::cancelButton()."\">\n";
         $display.= "</p>";
       }
       return ($display);
@@ -447,16 +501,16 @@ class ogroupManagement extends plugin
     $temp= "";
 
     $conv= array(   
-        "U" => array("select_user.png"        ,_("User")        , "ogroup"),
-        "G" => array("select_groups.png"      ,_("Group")       , "ogroup"),
-        "A" => array("select_application.png" ,_("Application") , "ogroup"),
-        "D" => array("select_department.png"  ,_("Department")  , "ogroup"),
-        "S" => array("select_server.png"      ,_("Server")      , "ogroup"),
-        "F" => array("select_phone.png"       ,_("Phone")       , "phonequeue"),
-        "W" => array("select_workstation.png" ,_("Workstation") , "workstartup"),
-        "O" => array("select_winstation.png" ,_("Windows Install") , "ogroup"),
-        "T" => array("select_terminal.png"    ,_("Terminal")    , "termgroup"),
-        "P" => array("select_printer.png"     ,_("Printer")     , "ogroup"));
+        "U" => array("plugins/generic/images/head.png"        ,_("User")        , "ogroup"),
+        "G" => array("plugins/groups/images/groups.png"       ,_("Group")       , "ogroup"),
+        "A" => array("plugins/ogroups/images/application.png" ,_("Application") , "ogroup"),
+        "D" => array("plugins/departments/department.png"     ,_("Department")  , "ogroup"),
+        "S" => array("plugins/ogroups/images/server.png"      ,_("Server")      , "ogroup"),
+        "F" => array("plugins/ogroups/images/asterisk.png"    ,_("Phone")       , "phonequeue"),
+        "W" => array("plugins/ogroups/images/workstation.png" ,_("Workstation") , "workstartup"),
+        "O" => array("plugins/ogroups/images/winstation.png"  ,_("Windows Install") , "ogroup"),
+        "T" => array("plugins/ogroups/images/terminal.png"    ,_("Terminal")    , "termgroup"),
+        "P" => array("plugins/ogroups/images/printer.png"     ,_("Printer")     , "ogroup"));
 
     /* Assemble picture */
     $type= $input['gosaGroupObjects'][0];
@@ -468,7 +522,7 @@ class ogroupManagement extends plugin
       $p1['lnk']= $conv[$type[0]][2];
       $html_object_1 = "<input type='image' name='".$p1['lnk']."_group_edit_%KEY' ";
     } else {
-      $p1['pic']= "empty.png";
+      $p1['pic']= "images/empty.png";
       $p1['tit']= "";
       $p1['alt']= "";
       $p1['lnk']= "";//$conv[$type[0]][2];
@@ -482,7 +536,7 @@ class ogroupManagement extends plugin
       $p2['lnk']= $conv[$type[1]][2];
       $html_object_2 = "<input type='image' name='".$p2['lnk']."_group_edit_%KEY' ";
     } else {
-      $p2['pic']= "empty.png";
+      $p2['pic']= "images/empty.png";
       $p2['alt']= "";
       $p2['tit']= "";
       $p2['lnk']= ""; //$conv[$type[0]][2];
@@ -490,9 +544,9 @@ class ogroupManagement extends plugin
     }
     
     $temp = $html_object_1." class='center' id='iconA".preg_replace("/_/","",$p1['lnk']."_group_edit_%KEY")."' 
-      src='images/".$p1['pic']."' alt='".$p1['alt']."' title='".$p1['tit']."'>";
+      src='".$p1['pic']."' alt='".$p1['alt']."' title='".$p1['tit']."'>";
     $temp.= $html_object_2." class='center' id='iconB".preg_replace("/_/","",$p2['lnk']."_group_edit_%KEY")."' 
-      src='images/".$p2['pic']."' alt='".$p2['alt']."' title='".$p2['tit']."'>";
+      src='".$p2['pic']."' alt='".$p2['alt']."' title='".$p2['tit']."'>";
     return ($temp);
   }
 
@@ -605,12 +659,9 @@ class ogroupManagement 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->DivListOGroup->selectedBase);
-
       /* Get dialog */
       $data = $this->CopyPasteHandler->execute();
+      $this->CopyPasteHandler->SetVar("base",$this->DivListOGroup->selectedBase);
 
       /* Return dialog data */
       if(!empty($data)){
@@ -628,6 +679,9 @@ class ogroupManagement extends plugin
   function save_object()
   {
     $this->DivListOGroup->save_object();
+    if(is_object($this->CopyPasteHandler)){
+      $this->CopyPasteHandler->save_object();
+    }
   }
 
 }