Last week in every month does not display properly in month view.

Woeka - February 12, 2008 - 17:36
Project:Event
Version:6.x-2.x-dev
Component:Event Views
Category:bug report
Priority:critical
Assigned:Woeka
Status:closed
Description

I've got event installed. But when using the month view, fabruary 29 is shown on a Monday instead of Friday. It does not have anything to do with which the day of the week it starts with.

#1

cjeanson - February 13, 2008 - 03:50

I can confirm this as well, noticed on the fresh Drupal 6 RC4 installation + event setup I just set up.

AttachmentSize
event_calendar.jpg48.17 KB

#2

cjeanson - February 13, 2008 - 18:52
Priority:normal» critical

Updating to critical, can't have the calendar displaying improperly!

Wish I knew PHP better, I would try to fix this myself!

#3

wyllie - February 14, 2008 - 22:59
Title:February leap year view problem » February leap year view problem - not just February but all months...

Not sure if this helps or not - but it's not just February, but all of the months are displaying incorrectly for the last week of the month.

#4

wyllie - February 15, 2008 - 01:22

Hey, I took a look at the code and made the following change in event.module around line 635
which seems to take care of the problem:

if ($cur_date['day'] >= $last_date['day']) {
last;
#$x = 8;
}

Sorry, I'm new to drupal and I have not really figured out how to submit an official patch yet.

Thanks,
Andrew

#5

cjeanson - February 15, 2008 - 22:42

What did you change?

Without posing what you changed, I am at a bit of a loss as to what should be done.

#6

wyllie - February 16, 2008 - 01:46

Oh,sorry about that.

In the original event.module file, around line 635, the code set $x=8 to get out of the for loop. I changed that to a 'last;' instead which is much cleaner and that's it.

I'm not sure why this really makes a difference because $x is not used again as far as I can tell but that change fixed the problem.

#7

cjeanson - February 16, 2008 - 04:10

Hrm, I added the line of code and it didn't seem to make any difference to my site.

I wonder if this will be addressed by an Event coder...

#8

wyllie - February 16, 2008 - 21:10

Hey, I haven't tried this one myself, but I saw another fix on the version 5 branch of this module. They changed the conditional statement to look like this:

orig:
if ($cur_date['day'] >= $last_date['day']) {
$x = 8;
}

new:
if ($cur_date['day'] > $last_date['day']) {
$x=8;
}

So, basically they just changed the '>=' to a '>'.

Like I said before, I just change the $x=8 to a last statement:
if ($cur_date['day'] >= $last_date['day']) {
last;
}

maybe that will help?

#9

cjeanson - February 17, 2008 - 01:14

Golden!

Now, I will see if I can figure out how to write a proper patch and we'll be good to go!

#10

Woeka - February 18, 2008 - 22:39
Title:February leap year view problem - not just February but all months... » February leap year view problem - not just February but all months - showing days of next month

Well I didn't know where to look, but with the pointers from you people I fixed the problem.

The line of code was probably meant to end the loop when the last day of the month is over. Preventing the calender to show days of the next month.

This is what I've changed, somewhere around line 630:


    for ($x = $start; $x < 7; $x++) {
      $cur_day = (($week * 7) + ($x + 1) - $offset);
      if ($cur_date['day'] <= $last_date['day']) {
        $row[$x] = array(
          'class' => strtolower($weekdays[$x]['day']) .' day-'. $cur_date['day'] . ($cur_date == $today ? ' today' : '') . ($cur_date['day'] == $day ? ' selected' : ''),
          'data' => $callback($cur_date, $view, $types, $terms, $rewrite_parameter));
      }
      if ($cur_date['day'] == $last_date['day']) {
        $x = 8;
      }
      $cur_date = event_date_later($cur_date, 1);
    }

See also the patch

AttachmentSize
event.module.patch1.15 KB
event.JPG26.24 KB

#11

Woeka - February 18, 2008 - 22:52
Assigned to:Anonymous» Woeka
Status:active» patch (to be ported)

#12

Woeka - February 18, 2008 - 22:53
Status:patch (to be ported)» patch (code needs review)

#13

cjeanson - February 19, 2008 - 04:15

Code change works really well. The event module is really starting to come along!

#14

mattjabs - February 19, 2008 - 15:41

I installed the patch successfully & now everything is working great!

Thanks.

PS...for those of you who don't know how to install a patch (like I didn't), here's how I did it:

On CentOS 5, I installed "patch" via yum with this command:

yum install patch

Then I copied the patch file into the event module directory and ran the following command and all is now good:

patch -bi event.module_58.patch

Sorry to the drup experts for this newbie type post, but I figured it may be helpful to some.

#15

cjeanson - February 19, 2008 - 23:24
Title:February leap year view problem - not just February but all months - showing days of next month» Last week in every month does not display properly in month view.

Updated title so a few more people may try out the patch before it is readied to be committed...

#16

PhilUK - February 25, 2008 - 16:37

Isn't a better fix - Drupal 6.0 - Events v 1.352

while (event_is_later($last_date, $cur_date)) {
$week = 0;
for ($x = $start; $x < 7 && event_is_later($last_date, $cur_date); $x++) {
$cur_day = (($week * 7) + ($x + 1) - $offset);
$row[$x] = array(
'class' => strtolower($weekdays[$x]['day']) .' day-'. $cur_date['day'] . ($cur_date == $today ? ' today' : '') . ($cur_date['day'] == $day ? ' selected' : ''),
'data' => $callback($cur_date, $view, $types, $terms, $rewrite_parameter));
$cur_date = event_date_later($cur_date, 1);
//if ($cur_date['day'] >= $last_date['day']) {
// last;
//}
}
$week++;
$start = 0;
$tbody[] = array_pad($row, 7, array('class' => 'pad'));
$row = array();
}

As this doesn't then show any of next months proceeding dates? I'm like above a Drupal and PHP noob - so no idea how to get this fix into a release.

#17

drdrup - February 26, 2008 - 23:42

I too encountered the same original problem.

I didn't try the patches yet. However, I just updated the event module on another site, with Drupal 5. The calendar display was OK before (ver of 2008.01.01), but the new version (ver of 2008.02.08) of "event" messed it up in the same way.

The difference was only one line, where ">" was changed to ">=" by the author. I have no idea why. I switched it back to ">", and the problem seems to go away.

I don't speak PHP'ish good enough to explore the difference between this and the patches offered above.

--- event.module_20080101       2008-01-01 16:37:57.000000000 -0700
+++ event.module_20080208       2008-02-08 10:06:52.000000000 -0700
@@ -1,5 +1,5 @@
<?php
-// $Id: event.module,v 1.348 2008/01/01 23:37:57 killes Exp $
+// $Id: event.module,v 1.348.2.1 2008/02/08 17:06:52 killes Exp $

define('EVENT_API', '5.2');
define('EVENT_PATH', drupal_get_path('module', 'event'));
@@ -566,7 +566,7 @@
         'class' => strtolower($weekdays[$x]['day']) . ' day-'. $cur_date['day'] . ($cur_date == $today ? ' today' : '') . ($cur_date['day'] == $day ? ' selected' : ''),
         'data' => $callback($cur_date, $view, $types, $terms, $rewrite_parameter));
       $cur_date = event_date_later($cur_date, 1);
-      if ($cur_date['day'] > $last_date['day']) {
+      if ($cur_date['day'] >= $last_date['day']) {
         $x = 8;
       }
     }

#18

Woeka - February 27, 2008 - 18:20

Changing only the >= doesn't stop the calender to go on and show days of the next month in the monthly calender. That will only fix the location of the week.

#19

manerhabe - March 10, 2008 - 01:59

Changing the >= to > on line 569 seemed to work for me. Thanks!

#20

killes@www.drop.org - March 10, 2008 - 14:01
Status:patch (code needs review)» fixed

Thanks, I've fixed this in both 5.2 and D6 dev releases as indicated by PhilUK in #16.

#21

cjeanson - March 11, 2008 - 03:15
Status:fixed» active

Now I get a list of errors and events don't display in the calendar since the update. They are displayed in list view, but in month view the module appears broken.

This is what I get:

* warning: include(./modules/event/event-node-month.tpl.php) [function.include]: failed to open stream: No such file or directory in [snip]/theme.inc on line 963.
* warning: include() [function.include]: Failed opening './modules/event/event-node-month.tpl.php' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in [snip]/theme.inc on line 963.
* warning: include(./modules/event/event-node-month.tpl.php) [function.include]: failed to open stream: No such file or directory in [snip]/theme.inc on line 963.
* warning: include() [function.include]: Failed opening './modules/event/event-node-month.tpl.php' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in [snip]/theme.inc on line 963.

It appears to me the problem is that event-node-month.tpl.php doesn't exist. Not in the current version, or in any other version.

#22

katesouthworth - March 16, 2008 - 09:02

i had this problem too -i.e list of errors

* warning: include(./modules/event/event-node-month.tpl.php) [function.include]: failed to open stream: No such file or directory in [snip]/theme.inc on line 963.
* warning: include() [function.include]: Failed opening './modules/event/event-node-month.tpl.php' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in [snip]/theme.inc on line 963.
* warning: include(./modules/event/event-node-month.tpl.php) [function.include]: failed to open stream: No such file or directory in [snip]/theme.inc on line 963.
* warning: include() [function.include]: Failed opening './modules/event/event-node-month.tpl.php' for inclusion (include_path='.:/usr/local/php5/lib/php:/usr/local/lib/php') in [snip]/theme.inc on line 963.

. i renamed the event-node-day.tpl.php to event-node-month.tpl.php and uploaded. this removed all the warnings.

i changed all the refs from 'day' to 'month' on the tpl.php - but don't know quite what that will do. 'm an artist not a coder so my logic is a bit different to you guys.

#23

cjeanson - March 16, 2008 - 18:37

I will be honest, I didn't even look at how to fix the latest release. I reverted to the previous version and it works great again. I am surprised such an important module doesn't have more active development. I love Event!

#24

macgirvin - April 22, 2008 - 21:08

subscribe

#25

killes@www.drop.org - April 26, 2008 - 21:17
Status:active» fixed

This is fixed. The errors posted were from another issue.

#26

Anonymous (not verified) - May 10, 2008 - 21:21
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.