This is a very handy module but the attendees list includes all the websites users. If an event is created in an organic group it would be nice to have only the groups subscribers available as attendees. We have hundreds of users with organic groups of 4-30, most meetings are within groups.

Neil

CommentFileSizeAuthor
#5 minutes_og.patch8.4 KBdavid lesieur

Comments

lenzjo’s picture

Hi there,

I too would like this feature and as it hasn't been followed up yet, I thought I would take a stab at it and this is the result. It works for what I want, an event for a single group, I want it so that I can take "register" for classes. I don't need multi-group events... yet.

What I did was rename the _minutes_valid_users function (at the bottom of the module) to _oldminutes_valid_users() (just incase) then I added the following:

function _minutes_valid_users($eid) {
    $excluded_users = module_invoke('excluded_users', 'get_excluded_uids');
    if (!isset($excluded_users)) {
        $excluded_users = array(0);
    }
    $result = db_query("SELECT gid FROM {node_access} WHERE nid = %d", $eid); // Is event for a group?
    if (db_num_rows($result) == 0) { // Non-Group event
        $users_query = db_query("SELECT uid FROM {users} WHERE uid not in (" . implode(",",$excluded_users) . ") and status = 1");
    }
     else { // It's a group event!!
        $ev = db_fetch_object($result);
        $gid = $ev->gid;
        $users_query = db_query("SELECT uid FROM {og_uid} WHERE uid NOT IN (" . implode(",",$excluded_users) . ") AND is_active = 1 AND nid = %d", $gid);
    }
    $users = array();
    while($users_res = db_fetch_array($users_query)) {
        $users[$users_res['uid']] = _minutes_uid_to_display($users_res['uid']);
    }
    asort($users);
    return $users;
}

And then up around line 185 in the attendee's form bit

    '#options' => _minutes_valid_users(),

changed to:

    '#options' => _minutes_valid_users($node->event_id),

This works (on my limited 4.7.3 testing tonite) on both group and non-group events, HTH

pukku’s picture

Assigned: Unassigned » pukku

Hi! Thanks for this. When I get around to actually doing this, I'll be glad to make use of your code. My plan is to actually allow minutes to have a number of ways to get a list of users (we have an internal module called excluded_users that we use) that you can choose between.

Ricky

pukku’s picture

Hi! So there are a few issues with this that I need to work through.

I don't use OG, so I can't test this code (I use my module OI instead, which fills a similar though very different need :-)

Your test to see if the event is a part of a group isn't good enough — testing the {node_access} table will tell you that some node access module is interested in the node, but won't tell you which.

I need to figure out how I want to determine how to grab the correct user list, and whether it should be some kind of administrator thing, or whether I should try to magically determine what group restricting modules are available.

pukku’s picture

Hi! I've started working on this. So far, I've modified the module so that it is possible to select how the users list is made, and made a few hooks to allow it to be extended. I've only got one right now, which doesn't do you much good, but is a start. Next I'll work on OI integration, because I can test that, then I'll write up docs so that someone who is using OG (or, if I find the time, I) can submit the code required.

david lesieur’s picture

Status: Active » Needs review
StatusFileSize
new8.4 KB

Here is a patch that allows for OG integration. It implements a more flexible hook to filter the list of potential attendees in Minutes. This patch:

  • Allows to combine many filters (for example, filtering with both "Excluded users" and "Group users").
  • Allows to select a different combination of filters for each event type (node type).
  • Selects the potential attendees in a single query.
  • Avoids any dependency in Minutes towards the modules that do the filtering.

In fact, I did not see how to integrate OG cleanly without making these changes.

For the actual OG integration, I created a new og_minutes module which requires this patch.

I'll also submit a patch for excluded_users that works with this hook. It's fun to see excluded_users and og_minutes play together nicely.

I hope you'll like this stuff.

david lesieur’s picture

See http://drupal.org/node/93351 for the patch for excluded_users.

pukku’s picture

Hi! I'm about to leave on a two-week vacation, so I'm very busy at home and at work trying to get everything ready. I will look at this when I get back.

Thanks!

Ricky

pukku’s picture

Hi! As per your private email, I've given you CVS access to this module, so you can apply changes.

Looking over what you're proposing, it seems ok to me -- I may make a few changes when I get back and get a chance to see it all in one place.

A few things, though:

1) could you implement a "default" hook_minutes_attendees? Something like:

function minutes_minutes_attendees($op, $event = null) {
  switch ($op) {
    case 'title':
      return 'Default';
    
    case 'filter':
      return array(
        'condition' => array('u.uid != 0'),
      );
  }
}

This basically implements what the excluded_users stuff was supposed to do when excluded_users isn't present (I realized last night that it doesn't actually work, which is kind of stupid on my part, but it was supposed to...). This attendees list would then become the default one.

2) could you add an update function to minutes.install which will add any new variables needed to default to what the previous behaviour would have been, so that already existing installations will be able to update and have things work, and then make changes.

3) I will deal with making excluded_users work with this when I get back. For my own site, this update is not any kind of priority because minutes was designed to work in our environment, so I can worry about this when I get back.

4) Please update the CHANGELOG.txt file when you commit changes.

Thanks very much for these improvements — getting it to work with OG is great, and since I don't use it, it's very hard for me to do it.

pukku’s picture

Hi! Sorry, I just realized, I would prefer it to be called hook_minutes_event_attendees() — what we're getting is the event attendees, not the minutes attendees...

Thanks,
Ricky

david lesieur’s picture

Hi Ricky! Thanks a lot for the CVS access. I'll integrate your requirements before committing anything. Regarding excluded_users, this patch should make it work, unless I missed something. ;-)

david lesieur’s picture

Status: Needs review » Fixed

Committed to DRUPAL-4-7.

Ricky, regarding your comment: could you implement a "default" hook_minutes_attendees?

I don't think it is necessary. If no hook is enabled, it means that all users are considered as potential attendees, as before.

david lesieur’s picture

Note: To benefit from these changes, interested users need to install the small OG Minutes module.

pukku’s picture

Hi! The reason to have a default "minutes" version of the hook is to exclude user zero, which otherwise messes things up. However, perhaps your check that the status=1 does the same — once I get settled back into things, I'll see what happens.

Thanks,
Ricky

david lesieur’s picture

Exactly, the status=1 condition prevents user 0 from appearing in the attendees. ;-)

Anonymous’s picture

Status: Fixed » Closed (fixed)