function do_savenotifications() { $oForm = $this->form_editnotifications($this->oState); $res = $oForm->validate(); if (!empty($res['errors'])) { return $oForm->handleError(); } $data = $res['results']; // now, an annoying problem is that we do *not* have the final set. // so we need to get the original, add the new ones, remove the old ones. // // because its not *really* isolated properly, we need to post-process // the data. // we need the old one $aAllowed = KTWorkflowUtil::getInformedForState($this->oState); $user_pattern = '|users\\[(.*)\\]|'; $group_pattern = '|groups\\[(.*)\\]|'; $role_pattern = '|roles\\[(.*)\\]|'; $user = KTUtil::arrayGet($aAllowed, 'user', array()); $group = KTUtil::arrayGet($aAllowed, 'group', array()); $role = KTUtil::arrayGet($aAllowed, 'role', array()); // do a quick overpass $newAllowed = array(); if (!empty($user)) { $newAllowed['user'] = array_combine($user, $user); } else { $newAllowed['user'] = array(); } if (!empty($group)) { $newAllowed['group'] = array_combine($group, $group); } else { $newAllowed['group'] = array(); } if (!empty($role)) { $newAllowed['role'] = array_combine($role, $role); } else { $newAllowed['role'] = array(); } $added = explode(',', $data['users']['added']); $removed = explode(',', $data['users']['removed']); foreach ($added as $akey) { $matches = array(); if (preg_match($user_pattern, $akey, $matches)) { $newAllowed['user'][$matches[1]] = $matches[1]; } else { if (preg_match($group_pattern, $akey, $matches)) { $newAllowed['group'][$matches[1]] = $matches[1]; } else { if (preg_match($role_pattern, $akey, $matches)) { $newAllowed['role'][$matches[1]] = $matches[1]; } } } } foreach ($removed as $akey) { $matches = array(); if (preg_match($user_pattern, $akey, $matches)) { unset($newAllowed['user'][$matches[1]]); } else { if (preg_match($group_pattern, $akey, $matches)) { unset($newAllowed['group'][$matches[1]]); } else { if (preg_match($role_pattern, $akey, $matches)) { unset($newAllowed['role'][$matches[1]]); } } } } // FIXME check that these are all users. $res = KTWorkflowUtil::setInformedForState($this->oState, $newAllowed); if (PEAR::isError($res)) { return $oForm->handleError($res->getMessage()); } $this->successRedirectTo("managenotifications", _kt("Notifications updated.")); }