I've tried various 1.x versions including 2.x-dev checked out today ... no luck. I simply cannot get all day events to work. Insists on showing a start time and an end time. The only way to get rid of the end date/time is to make the end time the same as the start time.

In the current version I am working with (in desperation really, 2.x-dev), checking the "all day" box does not stick, and has no effect on the time stored either. And to make matters worse, putting "no time" still shows a time, which seems random.

Comments

Steve Dondley’s picture

First, you can get rid of the "All day" module with this version. Not needed any more.

Second, override the theme_event_nodeapi function with this:

function theme_event_nodeapi($node) {
  if ($node->event['has_time']) {
    $format = 'M d, Y g:i a';
  } else {
    $format = 'M d, Y';
  }

  $output = '<div class="event-nodeapi">
    <div class="'. $node->type. '-start dtstart" title="'. event_format_date($node->event['start'], 'custom', "Y-m-d\TH:i:s\Z") .'"><label>'. t('Start: ') .'</label>'. event_format_date($node->event['start'], 'custom', $format) .'</div></div>'."\n";
  if ($node->event['start'] != $node->event['end']) {
    $output .= '<div class="event-nodeapi">
    <div class="'. $node->type. '-end dtend" title="'. event_format_date($node->event['end'], 'custom', "Y-m-d\TH:i:s\Z") . '"><label>'. t('End: ') .'</label>'. event_format_date($node->event['end'], 'custom', $format) .'</div></div>'."\n";
  }
  if (variable_get('configurable_timezones', 1)) {
    $zone = event_zonelist_by_id($node->event['timezone']);
    $output .= '<div class="event-nodeapi">
    <div class="'. $node->type. '-tz"><label>'. t('Timezone: ') .'</label>'. t($zone['name']) .'</div></div>'."\n";
  }
  return $output;
}
Steve Dondley’s picture

PS, the above is probably not the ideal way of fixing this. The better way of fixing this is to set the $node->event['start_format'] properly in the event.module to begin with. I'll leave that as an exercise for killes.

Unfortunately, I can't spare the time involved with fixing, making a patch, and all the correspondence involved with that.

Killes, if you let me know how to make a small donation, I will.

jsimonis’s picture

Getting this fixed would be great. I've tested it, and sure enough a time always shows up. I've tried both all day event as well as telling it that time is not important. Either way, a time shows up.

underpressure’s picture

how bout one of these as a quick solution?

selecting all day results automatically in start time 12.00am & end time 11.59pm

or

selecting all day results in start time saying all day.

Would altering the module to give one of the two solutions listed above be easier than finding a solution to the bug?

trevorleenc’s picture

any progress on this ?

I just had a mind to start using the event module, and for my application, say music festivals, which are 2-3 day events, time is literally irrelavant...so just having an event that would say cover 3/6/08 - 3/9/08 is what I need, no time etc.

Anonymous’s picture

(subscribing)

glsonline’s picture

subscribe

awong’s picture

Status: Active » Needs review

here are two functions i changed in event_all_day.js, it fixed the problem in my local. Please check and see if it is right. It is working

function eventAllDayDetermine() {
  if (  
    ($("#edit-end-hour").val() == "23") &&
    ($("#edit-end-minute").val() == "59") &&
    ($("#edit-start-hour").val() == "0") &&
    ($("#edit-start-minute").val() == "0")) {
      EventAllDayYes();
      $("#edit-start-minute-all-day").attr("checked","true");
  }
  else if (
    ($("#edit-end-hour").val() == "11") &&
    ($("#edit-end-minute").val() == "59") &&
    ($("#edit-start-hour").val() == "12") &&
    ($("#edit-start-minute").val() == "0") &&
    ($("input[@name='start_ampm']:nth(0)").is(":checked")) &&
    ($("input[@name='end_ampm']:nth(1)").is(":checked"))) {
      EventAllDayYes();
      $("#edit-start-minute-all-day").attr("checked","true");
    }
}

function EventAllDayYes() {
  if ($("input[@name='start_ampm']").val()) {
  $("#edit-end-hour").val(11);
  $("#edit-end-minute").val(59);
  $("input[@name='start_ampm']:nth(0)").attr("checked","checked")
  $("#edit-start-hour").val(12);
  $("#edit-start-minute").val(00);  
  $("input[@name='end_ampm']:nth(1)").attr("checked","checked")
  }
  else {
  $("#edit-end-hour").val(23);
  $("#edit-end-minute").val(59);
  $("#edit-start-hour").val(0);
  $("#edit-start-minute").val(0);
  }
  $("div.time").attr("style", "display: none;");
}
markstos’s picture

Title: All day event does not work » All day event does not work (peer review feedback)
Status: Needs review » Reviewed & tested by the community

I have tested this patch and recommend it for inclusion. It is still not "real" all-day event support, but is better than the current buggy behavior.

Without the patch, checking the "All day" still creates an event with the default times used. With the patch, the times are changed to be from 12:00am to 11:59 am. However, the edit screen still doesn't recognize this as "all day", and the display system still shows the times for the event.

Mark

kriskd’s picture

awong's patch doesn't appear to work for me unless I'm doing something wrong.

I replaced those two functions in sites/all/modules/event/contrib/event_all_day/event_all_day.js and it didn't seem to correct any behavior. When I create a new all day event, check the all day event checkbox, save and then return to edit the event, The checkbox is no longer checked and times appear. Those incorrect times still are displayed instead of 12:00am to 11:59pm as expected.

kiran_lakhotia’s picture

Instead of relying on js to "fix" the all day event issue, wouldn't a much better solution be to create a custom field in the event table, e.g. allday, which is 0 if checkbox isn't checked and 1 if it is checked. The correct display behaviour then becomes trivial.

a) you shouldn't rely on javascript for correct behaviour of the site
b) messing around with the start & end dates seems rather cumbersome

If there is interest for this db change I will post the updated event module code. If the community feels that adding a field to the db is not the way to go then I won't. I'm new to drupal so don't know how peers feel about db changes.

kiran_lakhotia’s picture

Here is what I've done to make the all day work (better)

ALTER TABLE `d0073414`.`event` ADD COLUMN `event_allday` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `event_end`;

add the following to event_all_day.module:

function event_all_day_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
// make sure it's an event enabled node
if(variable_get('event_nodeapi_'. $node->type, 'never') != 'never') {
if(isset($node->start_minute_all_day) && $node->start_minute_all_day == 1)
$node->event_allday = 1;
else
$node->event_allday = 0;
}
}

------

change event_all_day_form_alter (in event_all_day.module) to the following:

function event_all_day_form_alter($form_id, &$form) {

$node = isset($form['#node']) ? $form['#node'] : NULL;

$type = (isset($form['type']) && isset($form['type']['#value'])) ? $form['type']['#value'] : NULL;

$default_value = 0;

if ($form_id == $type .'_node_form' && variable_get('event_nodeapi_'. $type, 'never') != 'never') {
// add all day checkbox

if($node != NULL){
$object = db_fetch_object(db_query('SELECT event_allday FROM {event} WHERE nid = %d', $node->nid));

if(isset($object)){
$default_value = $object->event_allday;
}
}

$form['start_minute_all_day'] = array(
'#type' => 'checkbox',
'#title' => t('All day'),
'#default_value' => $default_value,
'#weight' => -14
);

$path = drupal_get_path('module', 'event_all_day');
drupal_add_js($path . '/event_all_day.js');
// theme_add_style($path . '/event_all_day.css');
}
}

-------

change the eventAllDayDetermine() function in event_all_day.js to the following:

function eventAllDayDetermine() {

eventAllDayToggle();
/*
if (
($("#edit-end-hour").val() == "23") &&
($("#edit-end-minute").val() == "59") &&
($("#edit-start-hour").val() == "0") &&
($("#edit-start-minute").val() == "0")) {
EventAllDayYes();
$("#edit-start-minute-all-day").attr("checked","true");
}*/
}

------

in the event.module file make sure you add the event_allday field to all insert/update SQL statements in the event_nodeapi function. In this function change the case "load" to the following (this can be done more efficiently, but is here cumbersome to illustrate the point):

case 'load':
$object = db_fetch_object(db_query('SELECT event_start, event_end, event_allday, timezone FROM {event} WHERE nid = %d', $node->nid));
switch (variable_get('event_timezone_display', 'event')) {
case 'event' :
include_once(EVENT_PATH .'/event_timezones.inc');
$start_offset = event_get_offset($object->timezone, $object->event_start);
$end_offset = event_get_offset($object->timezone, $object->event_end);
break;
case 'user' :
global $user;
$start_offset = $end_offset = $user->timezone;
break;
case 'site' :
$start_offset = $end_offset = variable_get('date_default_timezone', 0);
break;
}
$ctype = module_invoke('flexinode', 'load_content_type', $node->ctype_id);

$small_format_start = format_date($object->event_start, 'small', '', $start_offset);
$custom_format_start = format_date($object->event_start, 'custom', (variable_get('event_ampm', '0') ? 'g:i a' : 'H:i'), $start_offset);

$small_format_end = format_date($object->event_end, 'small', '', $end_offset);
$custom_format_end = format_date($object->event_end, 'custom', (variable_get('event_ampm', '0') ? 'g:i a' : 'H:i'), $end_offset);

if($object->event_allday == 1){
$small_format_start = format_date($object->event_start, 'custom', 'm/d/Y', $start_offset);
$custom_format_start = format_date($object->event_start, 'custom', 'm/d/Y', $start_offset);

$small_format_end = format_date($object->event_end, 'custom', 'm/d/Y', $end_offset);
$custom_format_end = format_date($object->event_end, 'custom', 'm/d/Y', $end_offset);
}

return array(
'event_start' => $object->event_start,
'event_end' => $object->event_end,
'event_allday' => $object->event_allday,
'timezone' => $object->timezone,
'start_offset' => $start_offset,
'start_format' => $small_format_start,
'start_time_format' => $custom_format_start,
'end_offset' => $end_offset,
'end_format' => $small_format_end,
'end_time_format' => $custom_format_end,
'event_node_title' => ($ctype->name ? $ctype->name : $node->type));
break;
---

this has fixed it for me. Now if the allday checkbox is checked, it remains so during editing, hides the time drop downs correctly and also hides the time information when listing events.

PS:sorry about the rubbish formatting, but it's late

lonehorseend’s picture

Kiran, your patch is work, but it works great . . . :) Remembering to do all the SQL statments is key, though. I think I found 2 or 3 more besides the one you mentioned.

kriskd’s picture

I'm a little gun shy about applying Kiran's patch. I don't know much about the module process, but is there a chance the original mod could just include this fix so each person wouldn't have to do the patch themselves?

kiran_lakhotia’s picture

Hi,

yes, there are a few more SQL statements you need to update, I didn't include them in the example code.

If there's interest I'm happy to create a proper "patch" for this.

kriskd’s picture

If there's interest I'm happy to create a proper "patch" for this.

Yes, very much interested. Thanks!

kiran_lakhotia’s picture

StatusFileSize
new1.47 KB
new563 bytes
new4.3 KB
new2.06 KB

Hi kriskd,

I've finally gotten round to creating the patches. Sorry about the delay.

This is the first time I've done patches, so please review them with extra care. Thanks.

allday.event_.install.patch

This patch adds the "event_allday" column when creating the database, and updates existing tables. I haven't got a PostgreSQL database available, so if someone could check that this works on with PostgreSQL that'd be great.

allday.event_.module.patch

This patch selects the event_allday column and inserts the corresponding form value into the database as part of the event_nodeapi function. It also formats the start and end date for display according to the event_allday flag being set.

event_all_day.js_.patch

This patch just ensures the hour and minute drop downs are toggled correctly.

event_all_day.patch

This patch ensures the "all day" checkbox is selected correctly by default and also ensures its values are saved.

kiran_lakhotia’s picture

StatusFileSize
new1.58 KB

I've also done a patch to only show the hour and minute dropdowns in selected steps (at the moment the steps, e.g. 00, 15, 30.... are hardcoded, but no big deal to make this an administration option)

kiran_lakhotia’s picture

Status: Reviewed & tested by the community » Needs review
Anonymous’s picture

The hour and minute dropdowns work perfectly for me. I guess other would want to have this as an option. It is great for our users as it simplifies inputing events a lot, but others might want to have all 60 mins.

Anonymous’s picture

Re Kiran's #17:

Thanks for the work! Unfortunately, I have problems applying the patches. I started with allday.event_.install.patch, but patch returns

Hunk #1 failed at 8
Hunk #2 failed at 19
Hunk #3 failed at 119

This was using the lates 5.x.2.x-dev version. The same happened with the latest stable version (but only two hunks failed).

Wouldn't it be easier to have just one patch file?

kiran_lakhotia’s picture

StatusFileSize
new1.54 KB
new599 bytes
new9.99 KB
new963 bytes

Hi,

ok, here are the tested patches. Please try those. Note: these patches are for 5x-1.0. I'm currently working on patches for 5.x-2.x-dev

Kiran

kiran_lakhotia’s picture

Status: Needs work » Needs review
StatusFileSize
new1.17 KB
new812 bytes

Hi,

here are the all day patches for version 5.x-2.x-dev

event.patch formats the date so all day events do not display a time (apply to event.module)

event_all_day.module.patch removes the "All day" checkbox. This chechbox is obsolete, since this version already contains a checkbox for 'has_time'

event_all_day.js.patch updates the javascript to look for the new checkbox instead of the old "All day" checkbox

event_dropdown.patch displays the minutes in 15min steps instead of 0-60. (apply to event.module)

Kiran

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

I have installed all the patches and tested them and they work very well. It is great to eventually see "all day" displayed properly in the events calendar. I supported including the patches in the next dev version of the module. Thanks, Kiran!

Anonymous’s picture

Status: Reviewed & tested by the community » Needs work

Ah, it seems I was too quick - I noticed one little quirk. Our site is configured to display dates as DD/MM/YYYY. After installing the patches, all day events were suddenly displayed as MM/DD/YYYY - all other dates remained unchanged. I have played around with the date/time settings, but this did not change the behaviour.

kiran_lakhotia’s picture

StatusFileSize
new2.54 KB
new4.5 KB

Hi TfR75,

you're right, the allday patch didn't respect user configured date format. Please use this new patch.

I've also made the minute dropdown a configurable option in the event.module.dropdown.patch

Please note these patches were created with the latest 5.x-2.x-dev version (from 16th April).

Kiran

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

Works nicely on our site! I would be all for integrating the patches in the module.

Anonymous’s picture

Development work on the event module seems to progress fast. Shouldn't we include these patches rather sooner than later before other dev versions come out and the patches need additional work? I am using the patches on three sites now and it all works perfect! What do others think?

betawavetom’s picture

After spending almost 2 days trying to do it on myself; I am stumped.

I downloaded and installed (locally) a new Drupal 5.7 - ok.
Installed the Events 5.x-2.xdev version - ok.

But the patches don't seem to make sense. I am looking at them manually, trying to make sense of them.
I tried applying Patch (windows) but got 3 hunks that did not work.
I entered:
patch --binary event.module event.module.patch.allday.patch
which gave me:
Hunk #1 failed at 962
Hunk #2 failed at 2231
Hunk #3 failed at 3188

What am I doing wrong?
------------------------------------------------ UPDATE ----------------------------------------
I did figure out the way to do manual patching .. and whilst I was doing that I also figured out how to install cygwin with the patch module in it... and the patching IS working!
So is the event module on Drupal 5.7 but NOT on Drupal 5.3 ... guess my next exercise is updating drupal as well as updating the event module.

Is there a better way to do this upgrade?
I am thinking about re-installing everything - just to make sure...

kiran_lakhotia’s picture

Hi betawavetom,

I've been swamped with work, so had no chance to look at the patches.

The patches were created on Linux using the "diff -up " syntax described on the drupal website. However, we got the same error you described when trying to run them with a windows patch. I hadn't had time to figure out why this is.

Your comment that you got it working under cygwin suggests that there is a some compatibility problem with win/*nix. I will try and look into this asap, and try and correct the problem (unlikely to be before next week though).

Between Drupal 5.7 and 5.3 there seems to have been a major change in the module as far as I can tell. These patches were only created for 5.x-2x without backward-compatibility in mind.

The patches posted earlier should work with 5.3 however.

Anonymous’s picture

Between the time the patches were posted and betawavetom's posting a new dev version of event was published. Maybe there were some changes made to the module that affect the patch? I just assume that betawavetom used the latest dev version, which would be different from the one Kiran used...

betawavetom’s picture

That made sense ... so I checked it out ... and I downloaded another "latest" version --- but in all honesty I lost count and track of all the versions and what I patched where to which of the 3 [identical] testing sites I worked on.

BUT.. I DID get it to work at one point ... and then messed it up by doing data transfers between the databases.
On another occasion, since I updated the event module, I ran the update.php file and it detected an update was needed on "event" (it chose the number 3 although it went all the way up to 8) ... after that update E V E R Y T H I N G fell apart again!

Here is what I am going to be doing now:
- re-install Drupal 5.7 [why not]
- re-install event (WITH THE LATEST PATCHES IN IT)
- create 4 events ... and test test test the date/time feature [so far so good]
- create vocabulary linked to event content type
- edit existing 4 events ... and test test test the date/time feature [still ok]
- install CCK to create custom field
- edit existing 4 events ... and test test test the date/time feature [stil working... and I LOVE the export/import feature of the CCK fields!!!]
- install Views to create custom views
- edit existing 4 events ... and test test test the date/time feature [ohh yessss... I'm still alive and kicking!]

Tomorrow I will upload this to the live server.
(to be continued)

betawavetom’s picture

.. and they lived happily ever after ..

Here's what I did to move the site from my local test machine to the server:
1) removed all existing folders except "files" and "sites"
2) uploaded all folders and files except "files" and "sites"
3) deleted the existing MySQL database
4) transferred all local MySQL data to the server
5) prayed a little prayer
6) shouted YEEHAAA!!! It works! If anyone wants to have a preview you can look at http://www.breastfeedingconferences.com [I still need to refine layout and css formatting though]

:)

Thanks everyone for listening to my rants.
~tom

ps: new skills I learned from this:
1) backup before you do ANYTHING
2) learned how to apply patches
3) learned what CygWin is (cool!)
4) really understand how a local system and remote system is not that different
5) gained more comfort in moving sites between servers

chasryder’s picture

Version: 5.x-2.x-dev » 5.x-1.0
Component: Event All Day » User interface
Assigned: Unassigned » chasryder
Status: Reviewed & tested by the community » Active

I have applied all of these patches, and it has fixed the "all day event" checkbox, however it still shows the time when in the list view when I create a View of Events. Any Ideas would be greatly appreciated. It seem the event all day may only be running when you view the full node. (This is for version 5.x-1.x of the event module)

Anonymous’s picture

It all works nicely on our site - but then we use a custom date format for list and table views; if I change that back to other formats the start time appears again. For all day events that is 0:00 which, I think, is better than what was shown on the site before the patch was applied, but of course not ideal. It does work nicely though in the calendar view.

RobertNelsonVance’s picture

http://drupal.org/comment/reply/199417/811123#comment-811123

ok, here are the tested patches. Please try those. Note: these patches are for 5x-1.0. I'm currently working on patches for 5.x-2.x-dev

I found that each of these patches failed. I am running 5x-1.0.

RobertNelsonVance’s picture

http://drupal.org/comment/reply/199417/818314#comment-818314


Please note these patches were created with the latest 5.x-2.x-dev version (from 16th April).

I tried to apply both of these patches and they both failed.

wxman’s picture

What is the status of this problem. I've tried all three of the 5.x versions, and the patches don't seem to fit anymore. Also the same problem with the all day event is happening to mine as well.

japerry’s picture

Status: Active » Closed (outdated)

Event for Drupal 8 is unrelated to older versions. If an issue similar to this one exists, please open a new issue with the 8.x branch.