From 58e87959eacc84c0fc1c9f6a03fdba8355bb7966 Mon Sep 17 00:00:00 2001 From: psc Date: Thu, 8 Oct 2009 12:38:20 +0000 Subject: [PATCH] Bugfix for Trac #3181 - Build a proper $target array for the add_targets function, containing group names and uids. Fixes problems with object group members not added to the target list of a notification event. - Add message checks - Save notify object before handing it to gosa-si git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.6-lhm@14564 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../admin/ogroups/class_ogroupManagement.inc | 50 +++++++++++++++---- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/trunk/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc b/trunk/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc index ece1e48ec..5e5b985d2 100644 --- a/trunk/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc +++ b/trunk/gosa-core/plugins/admin/ogroups/class_ogroupManagement.inc @@ -147,17 +147,40 @@ class ogroupManagement extends plugin if(preg_match("/^event_/",$s_action) && class_available("DaemonEvent")){ $ids = $this->list_get_selected_items(); - $uids = array(); + /* Resolve the selected items to their corresponding uids and group names */ + $targets = array(); foreach($ids as $id){ - $uids[] = $this->ogrouplist[$id]['cn'][0]; + $ogroup = $this->ogrouplist[$id]['cn'][0]; + $ldap = $this->config->get_ldap_link(); + $ldap->search("(&(cn=".$ogroup.")(member=*))", array('member')); + + while ($entry = $ldap->fetch()) { + $members = $entry['member']; + for($i=0;$i<$members['count'];$i++) { + $ldap->cat($members[$i], array('uid','cn','objectClass')); + if ($ldap->count() > 0) { + $attrs = $ldap->fetch(); + + /* Determine which type the object has */ + 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)){ + 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 +193,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