1
glenp
Agenda-X 2.1.1 bug fix
  • 2004/7/17 15:39

  • glenp

  • Just popping in

  • Posts: 4

  • Since: 2004/3/18


I noticed that the Upcoming 30 day events block would show repeating events more than once and that the sort order looked odd. The get_thisMonth_events function in minical.php seems to be the source of the problem. The original version performed the following steps:

1 - query agendax_events
2 - load results into the event array
3 - query agendax_event_repeats
4 - append the second query results onto the event array

Here are the problems that I see. The repeating events show up in both queries, hence the duplicates. The second query wasn't sorted by date. The appending places non-repeating events before repeating events.

My change retrieves all events in a single step that are sorted by date. Here is my updated logic:

function get_thisMonth_events() {
global $xoopsDB;
$events = array();
$ONE_DAY = 86400;

$userTimestamp = xoops_getUserTimestamp(time());
$date = date("Ymd", $userTimestamp);
$date30days = date("Ymd", $userTimestamp+30*$ONE_DAY);

$query = 'SELECT id, title, date FROM '.$xoopsDB->prefix("agendax_events").' LEFT JOIN '.$xoopsDB->prefix("agendax_event_repeats").' ON id=event_id'.' WHERE approved=1 AND (event_end=0 OR event_end is NULL OR event_end <='.$date30days.') AND date<='.$date30days.' ORDER BY date ASC';
$result = $xoopsDB->queryF($query);
$numrows = $xoopsDB->getRowsNum($result);
while ( $row = $xoopsDB->fetchArray($result) ) {
$events[] = $row;
}

return $events;
}

There are other functions in minical.php that follow the same logic. I updated them as well.

FYI, the original query had 'event_end=NULL' in it. This does not work as expected as it evaluates to null, not true or false. 'event_end is null' will return true if the column contains a null. Nulls in SQL are tricky this way!

wjue, thanks for putting Agenda-x out in the community. It is a great module.

Login

Who's Online

397 user(s) are online (315 user(s) are browsing Support Forums)


Members: 0


Guests: 397


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits