--- rsvp-old/rsvp.module 2008-07-15 20:17:40.000000000 -0400 +++ rsvp/rsvp.module 2008-11-20 09:54:34.000000000 -0500 @@ -60,7 +60,7 @@ * @ingroup rsvp_core */ function rsvp_perm() { - return array("administer rsvp", "rsvp on events", "rsvp on own events", "rsvp newsletters subscribers", "rsvp system users", "rsvp buddylist"); + return array("administer rsvp", "rsvp on events", "rsvp on own events", "rsvp newsletters subscribers", "rsvp system users", "rsvp buddylist", "rsvp groups"); } /** @@ -112,6 +112,7 @@ 'access' => user_access('access content'), 'type' => MENU_CALLBACK); + if (arg(0) == 'node' && is_numeric(arg(1))) { $nid = arg(1); $node = node_load($nid); @@ -184,6 +185,12 @@ 'callback arguments' => array(arg(6)), 'type' => MENU_CALLBACK, 'weight' => '2'); + $items[] = array('path' => 'node/'. $nid . '/rsvp/'. $rid.'/attendees/group', + 'access' => ($access && user_access('rsvp groups')), + 'callback' => 'rsvp_attendees_groups', + 'callback arguments' => array(arg(6)), + 'type' => MENU_CALLBACK, + 'weight' => '2'); $items[] = array('path' => 'node/'. $nid .'/rsvp/'. $rid .'/message', 'title' => t('Send message'), 'access' => $access, @@ -578,6 +585,9 @@ if (user_access('rsvp system users')) { $content .= rsvp_list_roles($rid); } + if (user_access('rsvp groups')) { + $content .= rsvp_list_groups($rid); + } $content .= drupal_get_form('rsvp_attendee_form', $rid); $content .= rsvp_show_attendees(rsvp_load($rid)); return $content; @@ -1373,12 +1383,40 @@ ), ); } - $content .= theme('table', $header, $rows); return $content; } +function rsvp_list_groups($rid) { + global $user; + $rsvp = rsvp_load($rid); + $content = t('

You may invite the following groups:

'); + $rows = array(); + $header = array(t('Groups'), array('data' => t('Operations'))); + + if ( in_array('site_administrator', array($user->roles))) { + $my_groups = og_all_groups_options(); + } + else { + $groups = og_get_subscriptions($user->uid); + foreach ($groups as $key => $val) + $my_groups[$key] = $val['title']; + } + + if ( count($my_groups) == 0 ) + return; + + foreach ($my_groups as $key => $group) { + $rows[] = array( + $group, + l(t('Add'), 'node/'.$rsvp->nid.'/rsvp/'.$rid.'/attendees/group/'.$key,array('onclick' => "$.get($(this).attr('href'), function(data){ $('#edit-invite-list').val(data); }); return false;")), + ); + } + $content .= theme('table', $header, $rows); + return $content; +} + /** * Returns a list of newsletter subscribers. * @@ -1420,6 +1458,20 @@ } } +function rsvp_attendees_groups($gid) { + if (is_numeric($gid)) { + $subs = ""; + + $query = db_query('SELECT u.name FROM {users} u, {og_uid} ogu WHERE u.uid = ogu.uid AND ogu.nid = %d',$gid); + + while ($u = db_fetch_object($query)) { + $subs .= $u->name ."\r\n"; + } + print $subs; + exit(); + } +} + /** * Returns the rsvps that a user is the owner of. *