this may or may not be useful to anyone else, but it's incredibly handy for what i'm doing at my site. since i spent the time to get it working, i figured i should share the fruits of my labor. attached is a relatively simple patch that adds another block to the signup module, exported via the signup_block() hook. i'm calling this block "Events Without Signup", and it prints out all events (that haven't started yet) where the current user has not yet signed up. it works just like any other block, so folks don't have to enable it, etc. if the event module is not installed/enabled, this block won't even show up as an option, and creates no output. i suppose the more general thing would be to query all the nodes where signups are enabled, and only do the date stuff if they happen to be event-enabled nodes, but that's a little more complicated than what i wanted, and on my site, the only nodes that are signup-enabled are events, anyway. this probably falls onto the contrib side of the contrib vs. core debate, but i thought i'd post the patch in case anyone else finds it useful.
enjoy,
-derek
p.s. i wrote this relative to revision 1.1.2.24, but i just checked and it applies cleanly to the end of the DRUPAL-4-6 branch (revision 1.1.2.28) as well.
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | signup_available_signups_view.patch_1.txt | 4.32 KB | dww |
| #9 | signup_default_views.patch.txt | 3.73 KB | dww |
| #7 | signup_available_signups_view.patch.txt | 3.69 KB | dww |
| #2 | signup-1.1.2.24-signup_no_reply_block.patch | 3.84 KB | dww |
| #1 | signup-1.1.2.24-event_no_signup_block-2.patch | 3.43 KB | dww |
Comments
Comment #1
dwwwhoops, minor bug in the previous version of this patch: it used to print this block, even for users that don't have 'allow signups' access. the patch attached to this post fixes this so that the block is only visible if the current user can actually signup for events.
please use this patch instead.
thanks,
-derek
Comment #2
dwwand here's yet another improvement. ;) now, the block doesn't depend on the event module at all. plus, this version notices signup-enabled events of any type. basically, instead of querying all the nodes in the {event} table it now queries all the nodes in the {signup} table (duh). just like the existing "current signups" block, IF the event module DOES exist, then it does the fancy stuff of filtering out events in the past, and ordering the list based on start time. so, other than not being quite happy with the name of the block ("Signups Without Reply" -- i couldn't stomach "Signups Without Signup"), and the corresponding description text ("List of events without signups by current user"), i think this is fully ready to go. let me know
what you think.
thanks,
-derek
Comment #3
hunmonk commentedlooks pretty good. couple of things:
if (! user_access('allow signups')) {i think it would be cleaner to wrap the whole thing in a positive statement, instead of having two return pointsthis seems like a logical sister block of the "Current Signups" block. it'll probably go in w/ the above corrections, although i'd like to hold off on the actual commit until i've got the new module architecture down.
Comment #4
dwwahh, right, where i declare the block up in signup_block(). forgot about that. thanks for catching it.
sure, that sounds fine. as i said in a previous post, i wasn't happy with what was there now. on my own site, it's just called "Events without reply", since "Reply" sort of makes more sense for this stuff on my site (where a "signup" could mean anything from definite yes to definite no).
that means the entire function has to be nested another level deeper (indented further, etc). reasonable people disagree about what makes for clearer code. i'm of the opinion that highly nested code is worse than multiple return points, so that's how i usually write things. on the other hand, drupal's 2 space indentation convention makes this issue less of a problem. so, if you really want it the other way, you can easily change it when/if you finally commit it to the official repository. ;)
another thought: my query needs a WHERE clause for (signup.completed == 0), or else this will always show non-event signup-enabled nodes, even when signups are closed for that node.
so yeah, code needs work... ;)
but, this is a low priority for me, especially if you're not planning to commit anytime soon. i think we're both more interested in the whole signup plugin architecture. any news on that? (you should reply to http://drupal.org/node/47561, not here...)
thanks,
-derek
Comment #5
hunmonk commentedlet's move this to postponed, then...
Comment #6
dwwclearly, signup isn't going away anytime soon, and this would be useful. since it's just a block sites can leave disabled if they don't want it, there's even less harm adding it to the current code (even in 4.6). therefore, i'm moving this out of postponed, since i'd like to get this updated and committed in the medium-near future. just want to get feedback from others before i commit. also, the existing patch in this thread still needs a little work (see #4), so i'll re-roll when i get the chance. curious what people think of how useful this would be for their sites.
Comment #7
dwwat long last. ;) now that there's view support, we can just provide a signup contrib module (like the views_bonus pack) that defines this block (and a page view, while we're at it) as a default view. ;)
any objections before i commit this to HEAD?
Comment #8
dwwboth merlinofchaos and hunmonk would prefer a single, catch-all "signup_views_bonus.module", instead of separate modules for each view. no problem. i'll re-roll in a little while.
Comment #9
dwwok, let's just put all the default views in a single contrib module: signup_default_views.(module|info).
any other complaints? ;)
Comment #10
dwwthis is blocked on:
once both of those land, this will be much better, since we can have:
both of these would be directly in signup_views.inc and enabled by default. (so, we'll put off contrib/signup_default_views for another day once i start adding more crazy default view stuff)...
so, you'd have:
and, of course, blocks you could enable for either/both if you wanted...
Comment #11
dwwbump: http://drupal.org/node/137952 just got committed, so this is only blocked on http://drupal.org/node/137911 (which is itself still blocked on http://drupal.org/node/138217 unfortunately)... but, at least we're starting to see progress again. ;)
Comment #12
dwwyay! merlin fixed the bug in views 5.x-1.6-beta5, so #137911 is no longer blocked. as soon as that's committed, i can quickly re-roll this so it applies cleanly. stay tuned. ;)
Comment #13
dwwthis is a patch against signup HEAD with http://drupal.org/files/issues/signup_no_views.patch_6.txt applied from http://drupal.org/node/137911. i think this is the cleanest way to define the view.
Comment #14
dwwCommitted to HEAD -- it's about time! ;)
Comment #15
(not verified) commented