From 5f0d5aa40e10c234b363150e35232fcbd0c959f1 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 20 Oct 2009 09:15:26 +0000 Subject: [PATCH] Updated ogroup management. -Send messages to correct recipients. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14609 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/ogroups/class_ogroupManagement.inc | 61 ++++++++++++++++--- 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc b/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc index ece1e48ec..49a434fcf 100644 --- a/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc +++ b/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc @@ -146,18 +146,52 @@ class ogroupManagement extends plugin ********************/ if(preg_match("/^event_/",$s_action) && class_available("DaemonEvent")){ + + /* Resolve the selected items to their corresponding uids and group names */ $ids = $this->list_get_selected_items(); - $uids = array(); + $targets = array(); + $m_list = array(); + $ldap = $this->config->get_ldap_link(); + + // Collect selected ogroups foreach($ids as $id){ - $uids[] = $this->ogrouplist[$id]['cn'][0]; + $ogroup = $this->ogrouplist[$id]['cn'][0]; + $ldap->search("(&(cn=".$ogroup.")(member=*))", 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; + } + } + } } - if(count($uids)){ + + // We've at least one recipient + if(count($targets)){ $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->add_targets($targets); $this->ogroup->set_type(TRIGGERED_EVENT); } } @@ -170,12 +204,19 @@ class ogroupManagement extends plugin /* 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; + $this->ogroup->save_object(); + $msgs = $this->ogroup->check(); + if (count($msgs)) { + msg_dialog::displayChecks($msgs); + } + else { + $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; + } } } -- 2.30.2