Attached is some code that will allow users to enter end times into events. End times will NOT be displayed if no end time is entered. This is because the patch checks to see if the end time is before the start time. If it is, it assumes the event does not have a set end time and will not display it.
INSTALLING THE PATCH
==================
++++++++++++++++++
STEP 1: Update database
===================
For the patch to work, you must also add a field into your event table. The name of the field is 'end' and its properties are identitical to the 'start' field. It will hold a timestamp of the end time.
You create this column by using the ALTER TABLE mysql command. First log into the mysql database. Then type 'use '. Then issue the following command:
ALTER TABLE event ADD end int(10) unsigned NOT NULL default '0';
(If you are not using a mysql database, I can't help you. You will have to look up the appropriate commands yourself.)
STEP 2: Install patch
================
To install the patch, drop it into your event.module directory and issues the following command:
patch -p0 event.module event_add_end_time-v1.patch
TECHNICAL NOTES
==============
++++++++++++++
The patch adds a new function to the module called event_validate_time(). Much of the code in event_validate_time() was pulled out of the event_validate() function and modified slightly so it could validate both start times and end times. The new event_validate() function gets called twice by the event_validate() function, once for the start time and once for the end time.
The form is modified by adding the end time form items. It also gives the start time form item names a prefix, 'start_', and the end time form item names a prefix, 'end_'. This is how the two identical time form items are differentiated from each other. The addition of the name prefix is accomplished by passing the prefix string to the event_form_date() function.
| Comment | File | Size | Author |
|---|---|---|---|
| #29 | event_end_time_addon-v1.patch | 2.22 KB | Anonymous (not verified) |
| #19 | event_5.patch | 40.65 KB | Kardboard |
| #18 | event.module_2.patch | 0 bytes | Kardboard |
| #16 | event_2.module | 40.65 KB | Kardboard |
| #10 | event_1.module | 40.59 KB | Kardboard |
Comments
Comment #1
Steve Dondley commentedTypo: the mysql 'use' command mentioned above should read 'use <your_database_name>'. It did not show because I did not escape the less than sign.
Comment #2
(not verified) commentedThe patch looks good at first glance, some comments:
1) Is the end time corrected for time zone?
2) Are either end or start reserved words in pgsql?
3) Shouldn't we rather add "none" as a selectable field for both end and start dates? If "none" is selected we would not display the date. Difficult part: Handle "none" setting for hour/minute only (and keep day, month, and year)
GK
Comment #3
(not verified) commented1) Is the end time corrected for time zone?
Both then end and start time get validated through the same function. So, yes. See code beginning on line 315.
2) Are either end or start reserved words in pgsql?
According http://www.postgresql.org/docs/7.4/static/sql-keywords-appendix.html
Yes they are.
Must we now change the names of these fields?
3) Shouldn't we rather add "none" as a selectable field for both end and start dates? If "none" is selected we would not display the date. Difficult part: Handle "none" setting for hour/minute only (and keep day, month, and year)
Well, every event has a start date, right? How would you display it on the calendar otherwise? If the user does not change the end date, it will not show, so that's already handled.
You could have a checkbox that said, "This event lasts one or more whole days." If the user checks it, the hour/minute would not show for either the start time or end times.
Comment #4
Uwe Hermann commentedYes, please change the field names if possible. It's a very bad idea to use DB keywords as field names, there are already some bugs filed because of this... Nasty things can happen if you use keywords.
Comment #5
Steve Dondley commentedThe maintainer of the event.module will need to change the name of the start column. I have no control over that. --nysus
Comment #6
Kardboard commentedI've successfully installed the patch, but when I try to use it, the end times don't show up. The data is in the database though, so I'm not sure what's up.
Comment #7
Steve Dondley commentedEnd times only display if the end time comes after the start time. Are you sure you set the end time properly? If so, upload your entire file. I'll do a diff with my file and see if I can't find the problem.
Comment #8
Kardboard commentedIt's definately different. I've attached my event.module..thanks!
Comment #9
Kardboard commentedIt's definately different. I've attached my event.module..thanks!
Comment #10
Kardboard commentedIt's definately different. I've attached my event.module..thanks!
Comment #11
Steve Dondley commentedI'm trying to download your module but the permissions are not set correctly on this new server. I'll try later.
Comment #12
Steve Dondley commentedOK, I can see your code formated as HTML when I click the link to your file upload. But I can't directly download your version. This is making it impossible for me to do a comparison.
Post your module again. This time, give it a ".patch" extension.
Comment #13
Steve Dondley commentedOK, I was able to get around the problem somewhat. I saw enough differences to determinet that you are using a different version of the event.module than I am. What version did you apply my patch to?
Comment #14
Kardboard commentedI applied it to version 4.5.0. I've re-attached my event.module, now as with a .patch extension, so maybe you can see it easier. Thanks!
Comment #15
Steve Dondley commentedHmmm...says 0 bytes. I think they are still trying to iron out some bugs with the new server. Try again.
Comment #16
Kardboard commentedOK here we go again.
Comment #17
Steve Dondley commentedWell, you need to give it a .patch extension. Otherwise, all I can see is the module in html format. One more time! :)
Comment #18
Kardboard commentedAhh..oops. I see what you mean. :P
Comment #19
Kardboard commentedDAMMIT! Stupid machines. One more time.
Comment #20
Steve Dondley commentedKardboard,
Sorry for the delay. They need the notify feature on this site.
Well, I put your version of the event module into a test site I have and it worked fine. Are you positive you have a column named "end" of type "int" in your event table?
Comment #21
(not verified) commentedYes, I'm staring right at it. Does capitalization matter? My column is in all-caps.
Comment #22
Steve Dondley commentedAccording to a Google search, it depends on the OS. Apparently it is case sensitive on *nix but not on Windows.
Comment #23
(not verified) commentedOh...so it should be lowercase then?
Comment #24
killes@www.drop.org commentedI am a bit confused about the lengthy discussion around this issue. Is the patch working or are there problems left to resolve?
Comment #25
Steve Dondley commentedIt works as far as I know. I took the code Kardboard is has on his site and put into my test site. It worked fine.
Comment #26
Kardboard commentedLol it must NOT like me. haha
I will try again. Thanks for the help!
Comment #27
(not verified) commentedHi, Just to say that patch is working v.fine - thank you! Best, Wojtek
Comment #28
mwsmedia commentedI don't understand how to apply the patch if you don't have shell access to your server... is there a way around that? Or has an updated .module file been added to CVS that I can use instead of the "add end" patch?
Thanks!
Comment #29
(not verified) commentedHi, I've made an addon for this patch.
1. It makes sure you've got proper 'NOW' message in the block for events that last several days.
2. It shows the event for each day during the event period in calendar table... Feature I needed most.
3. Slight fix for '_event_date' function arguments. It was saying '$time, $format' while logically it should be '$format,$time' as used in gmdate function... NO changes in function behaviour, except for variable name change.
Comment #30
LuckyOne commentedPrevious post was from me, sorry.
You should apply this patch AFTER original 'end_time' patch:
patch -p0 event.module event_end_time_addon-v1.patch
(Drupal event 4.5.0 only, does not work with CVS version)
Comment #31
crunchywelch commentedthis is implemented in 4.6