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.

Comments

Steve Dondley’s picture

Typo: 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.

Anonymous’s picture

The 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

Anonymous’s picture

1) 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.

Uwe Hermann’s picture

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?

Yes, 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.

Steve Dondley’s picture

The maintainer of the event.module will need to change the name of the start column. I have no control over that. --nysus

Kardboard’s picture

I'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.

Steve Dondley’s picture

End 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.

Kardboard’s picture

StatusFileSize
new40.59 KB

It's definately different. I've attached my event.module..thanks!

Kardboard’s picture

StatusFileSize
new40.59 KB

It's definately different. I've attached my event.module..thanks!

Kardboard’s picture

StatusFileSize
new40.59 KB

It's definately different. I've attached my event.module..thanks!

Steve Dondley’s picture

I'm trying to download your module but the permissions are not set correctly on this new server. I'll try later.

Steve Dondley’s picture

OK, 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.

Steve Dondley’s picture

OK, 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?

Kardboard’s picture

I 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!

Steve Dondley’s picture

Hmmm...says 0 bytes. I think they are still trying to iron out some bugs with the new server. Try again.

Kardboard’s picture

StatusFileSize
new40.65 KB

OK here we go again.

Steve Dondley’s picture

Well, you need to give it a .patch extension. Otherwise, all I can see is the module in html format. One more time! :)

Kardboard’s picture

StatusFileSize
new0 bytes

Ahh..oops. I see what you mean. :P

Kardboard’s picture

StatusFileSize
new40.65 KB

DAMMIT! Stupid machines. One more time.

Steve Dondley’s picture

Kardboard,

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?

Anonymous’s picture

Yes, I'm staring right at it. Does capitalization matter? My column is in all-caps.

Steve Dondley’s picture

According to a Google search, it depends on the OS. Apparently it is case sensitive on *nix but not on Windows.

Anonymous’s picture

Oh...so it should be lowercase then?

killes@www.drop.org’s picture

I am a bit confused about the lengthy discussion around this issue. Is the patch working or are there problems left to resolve?

Steve Dondley’s picture

It 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.

Kardboard’s picture

Lol it must NOT like me. haha

I will try again. Thanks for the help!

Anonymous’s picture

Hi, Just to say that patch is working v.fine - thank you! Best, Wojtek

mwsmedia’s picture

I 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!

Anonymous’s picture

Version: » 4.5.x-1.x-dev
StatusFileSize
new2.22 KB

Hi, 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.

LuckyOne’s picture

Previous 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)

crunchywelch’s picture

Version: 4.5.x-1.x-dev » 4.6.x-1.x-dev

this is implemented in 4.6