there are at least a few parts of the signup UI that can be more flexibly and powerfully implemented with views. for example, the /user/N/signups "Current signup schedule", and the block provided for the same info. however, you can't make a better version of /user/N/signups with views if signup.module is already occupying that menu item. plus, if you're running views, why bother loading/parsing all this other code when you're not using it?

so, i'm planning to move everything like this into signup_no_views.inc, and add an 'else' clause to the test for if views is enabled where we include this, instead of signup_views.inc.

is this crazy? ;)

thanks,
-derek

Comments

dww’s picture

StatusFileSize
new11.71 KB

ok, here's a patch for this:

  • rips out the user/N/signups menu item, the callback that handles that page, and the "List of users current signups" block (which i renamed, while i was at it), and puts all of that in a new signup_no_views.inc
  • implements a default "Current signups" view in signup_views.inc for the same stuff
  • conditionally include signup_no_views.inc if views is *not* enabled
  • fixed up some related comments and such

any objections? seems like this will make life better and more flexible for views users (since the menu items won't be in the way and there will be less code to load/parse), and things will still work just the same for folks without views...

dww’s picture

Status: Active » Needs review
add1sun’s picture

Status: Needs review » Needs work

Hm, well as discussed in IRC, its a little strange when switching from no views to installing views. The no_view block disappears and you have to go back to admin blocks to "turn it on again". This only happens of course is you set up your signup block before installing/enabling views. Strange behavior for the average user but the greater good being done here is probably worth it. Would be nice to come up with a better way to inform the user what is happening.

The only other thing is that the current patch loses the user/N/signups link in the block so that should be added in just to lessen overall confusion. ;)

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new13.28 KB

how about this for a dirty hack? ;) i added a DB update that checks if there's an entry in {blocks} owned by signup, and if so, we just print a warning message to the admin about it. they're supposed to run update.php when they upgrade, anyway, and the admin page and site status report will warn them if they haven't. then, at least they get a message about it. ;) i'll certaily put a warning about it in the release notes, either way. i'm not sure anyone would ever re-read the INSTALL.txt or README.txt when upgrading, so i don't think it'd help to put anything in there. :(

i really don't like the idea of keeping hook_block in signup.module when views is enabled, since then we get 2 blocks for the same thing, and i think that's at least as confusing as the fact that your block might disappear when you enable views. :(

either way, this patch adds a footer to provide that "View signup schedule" link again in the views-defined version of the block. ;)

dww’s picture

StatusFileSize
new13.36 KB

slight tweak to query for signup_date_5202(): add an "AND status = 1" to the WHERE clause, to see that the block is actually enabled anywhere...

dww’s picture

StatusFileSize
new12.08 KB

oh, and just since that db update is such a hack, here's a clean patch without it. ;) i'm *really* tempted to just put a nice big, bold warning in the release notes, put a note in the INSTALL.txt, and call that good enough. i'd rather not try to play tricks with hook_block just to keep the block enabled, since it's a *1 time* upgrade task, and it's so much cleaner in the code from here on out if i keep these separate.

dww’s picture

StatusFileSize
new14.25 KB

better yet: i added an "UPGRADE.txt" file and put some wisdom in there about this. might be handy to have in the future, too. ;)

add1sun’s picture

I like the UPDATE.txt addition. Was about to rtbc but there is some views weirdness? When I am on user/N/signups I am getting the Views edit/clone/export tabs and when I click on clone I get a "page not found" and on export I get View '<em>signup_current_signups</em>' not found.

dww’s picture

Status: Needs review » Postponed

thanks for pointing that out, add1sun. turns out the problem is a bug in the views core UI: http://drupal.org/node/138217

i don't think there's anything the signup-provided default view at user/$arg/signups is doing wrong, other than being unlucky enough to contain a '$' in the URL. :( i'll await the results of #138217 before committing this, but i don't think i'll have to change this patch to make things happy once that's resolved...

dww’s picture

Status: Postponed » Needs review

yay! merlin fixed the bug in views 5.x-1.6-beta5, so #7 needs review again.

dww’s picture

Status: Needs review » Needs work

drat, now that i committed http://drupal.org/node/138401, #7 no longer cleanly applies.

dww’s picture

Status: Needs work » Needs review
StatusFileSize
new16.59 KB

re-rolled and improved how we load the views support so we don't rely on hook_init(). hook_menu() is apparently the suggested method for this, and this way everything would still work even with agressive caching enabled. hook_init() is evil, so i'm told. however, see http://drupal.org/node/142997 as a result. ;)

add1sun’s picture

hm, a number of problems popped up (I'm using views-5.x-1.6-beta5 and signup-5.x-2.x-dev). They seem like views problems:

Firstly in admin/build/views the page URL for the signups view is user/$arg/signups. When clicking on it from there, it takes the $ literally and so gives a 404.

Then I went in to Override the view and didn't change anything but just hit Submit. It got really pissy at that:

View successfully added.

    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '1')' at line 1 query: SELECT count(node.nid) FROM node node WHERE (.status = '1') in /home/add1sun/public_html/includes/database.mysql.inc on line 172.
    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '1') LIMIT 0, 20' at line 1 query: SELECT node.nid, node.title AS node_title, node.changed AS node_changed FROM node node WHERE (.status = '1') LIMIT 0, 20 in /home/add1sun/public_html/includes/database.mysql.inc on line 172.
    * user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '= '1') LIMIT 0, 10' at line 1 query: SELECT node.nid, node.title AS node_title, node.changed AS node_changed FROM node node WHERE (.status = '1') LIMIT 0, 10 in /home/add1sun/public_html/includes/database.mysql.inc on line 172.

This user has not signed up for any content.

I am in as user 1 and I am signed up for an event right now. My "current signups" block and user/1/signups page were both working fine before the "override" but then the block suddenly disappeared when this error showed. This would be because now when I go to user/1/signups I don't have anything listed. But I am signed up when I look at the node. I also created a new signup node and signed up - no dice. It seems that overriding or editing the view broke it somehow even though it is identical since I didn't edit anything.

dww’s picture

there's badness with how views is handling the views cache when the signup views hooks are loaded via hook_menu(). :( merlin and i have been discussing this. for now, just clear the views cache (as mentioned in the INSTALL.txt and UPGRADE.txt) whenever you tweak with anything, and all should be well...

add1sun’s picture

ah, OK, that helps. I had done that when I did the original install to get my block but didn't realize I needed to do it everytime I mucked with something.

The $arg in the page URL issue still is a problem though. On admin/build/views the user/$arg/signups link ends up going to user/%24arg/signups when clicked. The link from the block is fine.

dww’s picture

StatusFileSize
new14.69 KB

Ugh, I thought views 5.x-1.6 was going to solve my problems with including signup_views.inc from hook_menu(), but apparently not. So, to avoid all the evil views cache clearing woes, I'm leaving things so that we continue to include signup_views.inc from hook_init(). :(

In IRC, eaton suggested quite the hack: just stick the hook implementations directly in signup.module, but put all the code in private helper functions in signup_views.inc, and have the hooks includes signup_views.inc themselves. Ugh. That's a topic for another issue, for now, hook_init() will have to do...

So, new patch that applies cleanly again, all text updated for views 5.x-1.6 final being out (and signup being 5.x-2.3 by the time this is released), and should hopefully work nicely since everything is still included from hook_init(). Anyone care to review/test once more before I commit?

stborchert’s picture

Status: Needs review » Needs work

Unfortunately the patch failed for me on latest HEAD so I have to do the changes by hand (chance to have a closer look on the code :-)).
I've tested it first without views and it works as expected.
With views enabled there was one thing I assume to be not wanted by you: in signup_views.inc #272 (function views_handler_arg_signup_uid(...)) you add a where clause to the filter query:
$query->add_where("signup.status = 1"); .
This causes the view to load only nodes with open signups, regardless whether this filter is set or not.
If you remove the line one could control this behaviour with the views filter.

With this small change its RTBC, I think.

greetings and good night,

Stefan

dww’s picture

Status: Needs work » Needs review

Uhh, the patch applies just fine to a clean checkout from HEAD for me. Are you sure you were starting from a clean checkout?

Also, thanks for pointing out that issue with the uid argument. However, that's independent of this patch, so I'd rather handle that in a separate issue: http://drupal.org/node/181627

stborchert’s picture

Are you sure you were starting from a clean checkout?

Jup. Tried right now and it failed again.
My directory structure:

contributions
 |- modules
 |  |- signup

If I change all occurences of modules/signup within the patch file (e.g. Index: modules/signup/INSTALL.txt) to signup the patch is working. Maybe its a windows problem with the path separator but now I know how to solve it.

dww’s picture

ahh, well, that's just a question of your patch client. can you apply the patch from the contributions directory without error? i don't know anything about trying to apply patches on windoze, so i don't have specifics to tell you, but perhaps http://drupal.org/patch/apply has some suggestions...

stborchert’s picture

Ah, silly windows :-)
I tried with patch.exe and it failed. If I try with cygwin and patch -p0 < ... it works. Good to know. So far it always worked.

borchert@hermine /cygdrive/d/webserver/cvs/drupal/contributions
$ patch -p0 < signup_no_views.patch_7.txt
patching file modules/signup/INSTALL.txt
patching file modules/signup/README.txt
patching file modules/signup/UPGRADE.txt
patching file modules/signup/signup.module
Hunk #4 succeeded at 1272 (offset -3 lines).
patching file modules/signup/signup_no_views.inc
patching file modules/signup/signup_views.inc

Btw: INSTALL.txt is missing the newer permissions ("email all signed up users" etc.). Should this be a separate patch or included with this one?

dww’s picture

Re: INSTALL.txt -- separate patch please. Thanks.

dww’s picture

Status: Needs review » Fixed

Good grief, I've waited long enough on this issue. Committed to HEAD. ;) Phew.

Anonymous’s picture

Status: Fixed » Closed (fixed)