Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

May 28, 2020, 09:33:06 PM

Login with username, password and session length
Members
Stats
  • Total Posts: 190002
  • Total Topics: 20832
  • Online Today: 128
  • Online Ever: 917
  • (January 21, 2020, 09:02:26 AM)
Users Online
Users: 0
Guests: 73
Total: 73

Author Topic: Events sign-up on Calendar  (Read 30004 times)

0 Members and 1 Guest are viewing this topic.

darthi8nt

  • Guest
Re: Events sign-up on Calendar
« Reply #50 on: April 22, 2008, 08:38:31 PM »
Changed the code slightly to be able to remove yourself from the event list in the block. Why? because if you attend many events it keeps track of them all even if the event has expired past the date. So if you attended an event a week ago there is no sense in keeping yourself as attending so this will allow you to delete yourself and keep your other list of events you plan on attending there in the block. call it an Event Reminder block.
Code: [Select]
global $ID_MEMBER, $db_prefix, $scripturl;

$today = date('Y-m-d');

$request = db_query("
  SELECT ID_TOPIC, title, startDate, endDate
  FROM {$db_prefix}calendar
  WHERE FIND_IN_SET($ID_MEMBER, attendees)
  AND startDate >= $today
  ORDER BY startDate", __FILE__, __LINE__);

if (mysql_num_rows($request) == 0)
  echo "You haven't signed up for any events yet.";
else {
  while ($row = mysql_fetch_row($request)) {
echo '<a href="' . $scripturl . '?action=toggleAttend;topic=' . $row[0] . '.0">' . $row[1] . '</a>' ." " . date('F j',strtotime($row[2])) . " Remove from Event!" ;
   
if  ($row[2] < $row[3])
      echo ' - ' . date('F j',strtotime($row[3]));
    echo '<br>';




  }
}

confuzed

  • Guest
Re: Events sign-up on Calendar
« Reply #51 on: January 02, 2009, 12:10:19 PM »
Changed the code slightly to be able to remove yourself from the event list in the block. Why? because if you attend many events it keeps track of them all even if the event has expired past the date. So if you attended an event a week ago there is no sense in keeping yourself as attending so this will allow you to delete yourself and keep your other list of events you plan on attending there in the block. call it an Event Reminder block.
Code: [Select]
global $ID_MEMBER, $db_prefix, $scripturl;

$today = date('Y-m-d');

$request = db_query("
  SELECT ID_TOPIC, title, startDate, endDate
  FROM {$db_prefix}calendar
  WHERE FIND_IN_SET($ID_MEMBER, attendees)
  AND startDate >= $today
  ORDER BY startDate", __FILE__, __LINE__);

if (mysql_num_rows($request) == 0)
  echo "You haven't signed up for any events yet.";
else {
  while ($row = mysql_fetch_row($request)) {
echo '<a href="' . $scripturl . '?action=toggleAttend;topic=' . $row[0] . '.0">' . $row[1] . '</a>' ." " . date('F j',strtotime($row[2])) . " Remove from Event!" ;
   
if  ($row[2] < $row[3])
      echo ' - ' . date('F j',strtotime($row[3]));
    echo '<br>';




  }
}

I wonder if it would be possible to alter the block to just show current and future events and not display the expired/past ones instead of relying on members to remove themselves to prevent the block getting bigger?

I would still like to have a record of who attended what so I don't really want them removed from the events but if the code in the block could be changed to automatically not display past events then that would be wonderful.

Kinda like the calendar does in the Info Center, where current and future events are displayed until they are over.  Except I would like it to display events say for 2009 and not for 2008, and next year it would only display for 2010 - even if you had to alter the code each time that would be great for us.

Any chance anyone can do that?

JPDeni

  • Guest
Re: Events sign-up on Calendar
« Reply #52 on: January 02, 2009, 02:11:19 PM »
It should only give events that are for "today" and after. That's what

Code: [Select]
AND startDate >= $today

is for.

confuzed

  • Guest
Re: Events sign-up on Calendar
« Reply #53 on: January 02, 2009, 05:43:24 PM »
It should only give events that are for "today" and after. That's what

Code: [Select]
AND startDate >= $today

is for.

Mine is displaying all events that I signed up for right back to last March unless I remove myself from each the events individually.  I don't want to do that as I want a record of who attended what.

It wasn't a big deal last year as we wanted to display a full year of events but now that we are in a new year we only want the 2009 events to show without members having to remove themselves from last year's events.   The start date greater than today isn't working using the above code but if it was then that would be good, or the ability to enter a start date like 1.1.09

thanks for any help

JPDeni

  • Guest
Re: Events sign-up on Calendar
« Reply #54 on: January 02, 2009, 10:11:36 PM »
Let's do a test. After

Code: [Select]
$today = date('Y-m-d');

add

Code: [Select]
echo $today . '<br />';

See if you get that day's date displayed at the top of the list. Then remove the new line.

I just did a search within phpMyAdmin, using this code and it worked just like it's supposed to.

confuzed

  • Guest
Re: Events sign-up on Calendar
« Reply #55 on: January 03, 2009, 03:59:08 AM »
ok, I added that code and it displayed today's date and then all of last year's events underneath it same as before.   :(

JPDeni

  • Guest
Re: Events sign-up on Calendar
« Reply #56 on: January 03, 2009, 07:00:44 AM »
Okay. Then try this. Instead of

Code: [Select]
AND startDate >= $today

use

Code: [Select]
AND endDate >= '" . strftime('%Y-%m-%d', forum_time(false)) . "'

confuzed

  • Guest
Re: Events sign-up on Calendar
« Reply #57 on: January 03, 2009, 07:27:20 AM »
yay!  that works.  :)
Thanks so much!

JPDeni

  • Guest
Re: Events sign-up on Calendar
« Reply #58 on: January 03, 2009, 09:26:04 AM »
Cool! It's difficult for me to do any testing because I don't have a place to use it right now.  But I did use that other code in another script, so I thought it might work.

confuzed

  • Guest
Re: Events sign-up on Calendar
« Reply #59 on: January 03, 2009, 10:10:50 AM »
well it worked :) you are a genius :)