Needs review
Project:
Group Admin
Version:
6.x-2.1
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
27 Apr 2010 at 03:22 UTC
Updated:
28 Apr 2010 at 09:03 UTC
Needed to add link to the OG Invite pages o figured easiest way was to hack in a hook to allow other modules to add their own links to your admin page. This isn't the best way to do this as should likely be able to mod $headers as well.
This patch also includes setting group context on the groupadmin page.
should likely be 2 patches... but just one for now
also, my module's use of this hook is:
// Add INVITE link to groupadmin page using hacked in hook
// - see also form_alter here to grab GET username to put in invite form.
function mymodule_groupadmin_links_alter($links, $account, $flag) {
if ($account['is_active'] || $flag != 'is_active') return "";
$gid = arg(1);
$linktext = '<em>• </em>'. t("invite");
$url = "og/invite/" . $gid;
$link = l($linktext, $url, array('attributes' => array('title' => t("invite user to this group")), 'html' => TRUE, 'query' => array('u' => $account['name']))) . ' ';
return $link;
}
plus i have a form_alter to grab the GET username supplied in the hook call to prepopulate the OG Invite form.
Comments
Comment #1
andy inman commentedI hadn't thought of having "invite" in there. So the idea is that group members use the search facility to find friends etc and invite them to join the group, right?
Another way to prepopulate the invite form would be using Prepopulate so that values could be sent in the url. Maybe a better approach for general use, thousands of sites have that module installed.
Thanks for the snippet. I can see how the invite link could be useful in community sites etc, I'll think about how to put it in for the next release. Probably just needs a config option to turn it on/off. Should probably check if the group is open for joining too, no point in showing "invite" otherwise.
Comment #2
liquidcms commentedpatch wasn't actually ot add Invite link; it was to allow other modules to add links - hence the hook. in a separate module i use the hook and the code above to add the invite link.... i.e. "the drupal way".. :)
Comment #3
andy inman commentedah, ok.. sorry for misunderstanding. Still, maybe "invite" should be in there as standard. Likewise a hook to modify the displayed links, there's already one to modify the search query (used by the Profile and CP sub-modules). To be really Drupal-ish, maybe the whole thing needs to be re-written to use Views, I'm not sure if that's feasible though.
Comment #4
liquidcms commentedsweet!!... YES.. it is really too bad this module just didn't simply provide a few much needed Views handlers. I have done some of what you do here with a View but opted to use your module as it provides the "members/not members" selector which is difficult to do in Views (without a new handler).
it also would open up the ability to use VBO.
Comment #5
andy inman commentedThe non-Views approach was for historical reasons - I originally wrote the module a couple of years ago for a client, and at that time Views 2 was not very stable let alone documented.
If you want, take a look at groupadmin_profile.module (or groupadmin_cp which is near-identical.) You'll see it actually provides three hooked functions called by the main module. The hooked functions themselves do nothing more than return an array of function names, and those functions get called later. The one that modifies the query also modifies the table headers and defines which new columns should be included in the text search:
So, with the same approach you could add a new column to the final table display, optionally making it searchable. But maybe another hook is needed to allow additional processing of each row of the table.