Code

Updated post handling
[gosa.git] / gosa-core / plugins / admin / ogroups / class_ogroupManagement.inc
index cfde13495aef80c3bdd2ac63f21d20bf70505efc..093da699880d5bb8921b5a7110d0ca1a014fae9b 100644 (file)
 
 class ogroupManagement extends management
 {
-  var $plHeadline     = "Object groups";
-  var $plDescription  = "Manage object groups";
-  var $plIcon  = "plugins/ogroups/images/plugin.png";
-
-  // Tab definition 
-  protected $tabClass = "ogrouptabs";
-  protected $tabType = "OGROUPTABS";
-  protected $aclCategory = "ogroups";
-  protected $aclPlugin   = "ogroup";
-  protected $objectName   = "object group";
-
-  function __construct($config,$ui)
-  {
-    $this->config = $config;
-    $this->ui = $ui;
-
-    $this->storagePoints = array(get_ou("ogroupRDN"));
-
-    // 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("ogroup-filter.xml", true));
-      $filter->setObjectStorage($this->storagePoints);
-    }
-    $this->setFilter($filter);
+    var $plHeadline     = "Object groups";
+    var $plDescription  = "Combine different types of objects to make use of this relationship";
+    var $plIcon  = "plugins/ogroups/images/plugin.png";
+
+    // Tab definition 
+    protected $tabClass = "ogrouptabs";
+    protected $tabType = "OGROUPTABS";
+    protected $aclCategory = "ogroups";
+    protected $aclPlugin   = "ogroup";
+    protected $objectName   = "object group";
+
+    function __construct($config,$ui)
+    {
+        $this->config = $config;
+        $this->ui = $ui;
+
+        $this->storagePoints = array(get_ou("group", "ogroupRDN"));
+
+        // 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("ogroup-filter.xml", true));
+            $filter->setObjectStorage($this->storagePoints);
+        }
+        $this->setFilter($filter);
 
-    // Build headpage
-    $headpage = new listing(get_template_path("ogroup-list.xml", true));
-    $headpage->registerElementFilter("filterProperties", "ogroupManagement::filterProperties");
-    $headpage->setFilter($filter);
+        // Build headpage
+        $headpage = new listing(get_template_path("ogroup-list.xml", true));
+        $headpage->registerElementFilter("filterProperties", "ogroupManagement::filterProperties");
+        $headpage->setFilter($filter);
 
-    // Add copy&paste and snapshot handler.
-    if ($this->config->boolValueIsTrue("main", "copyPaste")){
-      $this->cpHandler = new CopyPasteHandler($this->config);
+        // Add copy&paste and snapshot handler.
+        if ($this->config->boolValueIsTrue("core", "copyPaste")){
+            $this->cpHandler = new CopyPasteHandler($this->config);
+        }
+        if($this->config->get_cfg_value("core","enableSnapshots") == "true"){
+            $this->snapHandler = new SnapshotHandler($this->config);
+        }
+        parent::__construct($config, $ui, "ogroups", $headpage);
+
+        $this->registerAction("edit_ogroup","editEntry");
+        $this->registerAction("edit_phonequeue","editEntry");
+        $this->registerAction("edit_workstartup","editEntry");
+        $this->registerAction("edit_termgroup","editEntry");
+
+        $this->registerAction("sendMessage", "sendMessage");
+        $this->registerAction("saveEventDialog", "saveEventDialog");
+        $this->registerAction("abortEventDialog", "closeDialogs");
     }
-    if($this->config->get_cfg_value("enableSnapshots") == "true"){
-      $this->snapHandler = new SnapshotHandler($this->config);
+
+
+    // Inject user actions
+    function detectPostActions()
+    {
+        $action = management::detectPostActions();
+
+        if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEventDialog";
+        if(isset($_POST['abort_event_dialog'])) $action['action'] = "abortEventDialog";
+        return($action);
     }
-    parent::__construct($config, $ui, "ogroups", $headpage);
-
-    $this->registerAction("edit_ogroup","editEntry");
-    $this->registerAction("edit_phonequeue","editEntry");
-    $this->registerAction("edit_workstartup","editEntry");
-    $this->registerAction("edit_termgroup","editEntry");
-
-    $this->registerAction("sendMessage", "sendMessage");
-    $this->registerAction("saveEventDialog", "saveEventDialog");
-    $this->registerAction("abortEventDialog", "closeDialogs");
-  }
-
-
-  // Inject user actions
-  function detectPostActions()
-  {
-    $action = management::detectPostActions();
-
-    if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEventDialog";
-    if(isset($_POST['abort_event_dialog'])) $action['action'] = "abortEventDialog";
-    return($action);
-  }
-
-
-  function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
-  {
-    $str = management::editEntry($action,$target);
-    if(preg_match("/^edit_/",$action)){
-      $tab = preg_replace("/^edit_/","",$action);
-      if(isset($this->tabObject->by_object[$tab])){
-        $this->tabObject->current = $tab;
-      }else{
-        trigger_error("Unknown tab: ".$tab);
-      }
+
+
+    function editEntry($action="",$target=array(),$all=array(), $altTabClass ="", $altTabType = "", $altAclCategory="")
+    {
+        $str = management::editEntry($action,$target);
+        if(preg_match("/^edit_/",$action)){
+            $tab = preg_replace("/^edit_/","",$action);
+            if(isset($this->tabObject->by_object[$tab])){
+                $this->tabObject->current = $tab;
+            }else{
+                trigger_error("Unknown tab: ".$tab);
+            }
+        }
+        if(!empty($str)) return($str);
     }
-    if(!empty($str)) return($str);
-  }
-
-
-  /*! \brief  Sends a message to a set of users using gosa-si events.
-   */
-  function saveEventDialog()
-  {
-    $this->dialogObject->save_object();
-    $msgs = $this->dialogObject->check();
-    if(count($msgs)){
-      msg_dialog::displayChecks($msgs);
-    }else{
-      $o_queue = new gosaSupportDaemon();
-      $o_queue->append($this->dialogObject);
-      if($o_queue->is_error()){
-        msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
-      }
-      $this->closeDialogs();
+
+
+    /*! \brief  Sends a message to a set of users using gosa-si events.
+     */
+    function saveEventDialog()
+    {
+        $this->dialogObject->save_object();
+        $msgs = $this->dialogObject->check();
+        if(count($msgs)){
+            msg_dialog::displayChecks($msgs);
+        }else{
+            $o_queue = new gosaSupportDaemon();
+            $o_queue->append($this->dialogObject);
+            if($o_queue->is_error()){
+                msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+            }
+            $this->closeDialogs();
+        }
     }
-  }
 
 
-  /*! \brief  Sends a message to a set of users using gosa-si events.
-   */
-  function sendMessage($action="",$target=array(),$all=array())
-  {
+    /*! \brief  Sends a message to a set of users using gosa-si events.
+     */
+    function sendMessage($action="",$target=array(),$all=array())
+    {
 
-    if(class_available("DaemonEvent_notify")){
+        if(class_available("DaemonEvent_notify")){
 
-      // Resolv targets  
-      $targets = array();
-      $m_list  = array();
-      $ldap = $this->config->get_ldap_link();
+            // Resolv targets  
+            $targets = array();
+            $m_list  = array();
+            $ldap = $this->config->get_ldap_link();
 
-      // Collect selected ogroups
-      foreach($target as $dn){
-        $ldap->cat($dn, array('member'));
-        while ($entry = $ldap->fetch()) {
-          $m_list[] = $entry;
-        }
-      }
-
-      // Collect object group member dns
-      foreach($m_list as $entry){
-        $members = $entry['member'];
-        for($i=0;$i<$members['count'];$i++) {
-
-          // Fetch member object
-          $ldap->cat($members[$i], array('uid','cn','objectClass'));
-          if ($ldap->count() > 0) {
-
-            // Determine which type the object has
-            $attrs = $ldap->fetch();
-            if (array_search('gosaAccount', $attrs['objectClass'])) {
-              $uid = $attrs['uid'][0];
-              $targets['USERS'][] = $uid;
-            }elseif (array_search('posixGroup', $attrs['objectClass'])) {
-              $group = $attrs['cn'][0];
-              $targets['GROUPS'][] = $group;
+            // Collect selected ogroups
+            foreach($target as $dn){
+                $ldap->cat($dn, array('member'));
+                while ($entry = $ldap->fetch()) {
+                    $m_list[] = $entry;
+                }
             }
-          }
-        }
-      }
-    
-      // We've at least one recipient
-      if(count($targets)){
-        $events = DaemonEvent::get_event_types(USER_EVENT);
-        if(isset($events['BY_CLASS']['DaemonEvent_notify'])){
-          $type = $events['BY_CLASS']['DaemonEvent_notify'];
-          $this->dialogObject = new $type['CLASS_NAME']($this->config);
-          $this->dialogObject->add_targets($targets);
-          $this->dialogObject->set_type(TRIGGERED_EVENT);
-        }
-      }
 
+            // Collect object group member dns
+            foreach($m_list as $entry){
+                $members = $entry['member'];
+                for($i=0;$i<$members['count'];$i++) {
+
+                    // Fetch member object
+                    $ldap->cat($members[$i], array('uid','cn','objectClass'));
+                    if ($ldap->count() > 0) {
+
+                        // Determine which type the object has
+                        $attrs = $ldap->fetch();
+                        if (array_search('gosaAccount', $attrs['objectClass'])) {
+                            $uid = $attrs['uid'][0];
+                            $targets['USERS'][] = $uid;
+                        }elseif (array_search('posixGroup', $attrs['objectClass'])) {
+                            $group = $attrs['cn'][0];
+                            $targets['GROUPS'][] = $group;
+                        }
+                    }
+                }
+            }
+
+            // We've at least one recipient
+            if(count($targets)){
+                $events = DaemonEvent::get_event_types(USER_EVENT);
+                if(isset($events['BY_CLASS']['DaemonEvent_notify'])){
+                    $type = $events['BY_CLASS']['DaemonEvent_notify'];
+                    $this->dialogObject = new $type['CLASS_NAME']($this->config);
+                    $this->dialogObject->add_targets($targets);
+                    $this->dialogObject->set_type(TRIGGERED_EVENT);
+                }
+            }
+
+        }
     }
-  }
-
-  static function filterProperties($row, $gosaGroupObjects)
-  {
-
-    $conv= array(
-        "Y" => array("plugins/users/images/select_template.png",_("Templates") , "ogroup"),
-        "U" => array("plugins/generic/images/head.png"        ,_("User")        , "ogroup"),
-        "G" => array("plugins/groups/images/select_group.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"));
-
-    $types = preg_replace("/[^a-z]/i","",$gosaGroupObjects[0]);
-    $result ="";
-    for($i = 0 ; $i < strlen($types); $i++){
-      $type = $types[$i];
-      $result.= image($conv[$type][0], 'listing_edit_'.$conv[$type][2].'_'.$row,$conv[$type][1]);
+
+    static function filterProperties($row, $gosaGroupObjects)
+    {
+
+        $conv= array(
+                "Y" => array("plugins/users/images/select_template.png",_("Templates") , "ogroup"),
+                "U" => array("plugins/generic/images/head.png"        ,_("User")        , "ogroup"),
+                "G" => array("plugins/groups/images/select_group.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"));
+
+        $types = preg_replace("/[^a-z]/i","",$gosaGroupObjects[0]);
+        $result ="";
+        for($i = 0 ; $i < strlen($types); $i++){
+            $type = $types[$i];
+            $result.= image($conv[$type][0], 'listing_edit_'.$conv[$type][2].'_'.$row,$conv[$type][1]);
+        }
+        return($result);
     }
-    return($result);
-  }
 } 
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>