TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

April 25, 2024, 08:59:15 PM

Login with username, password and session length
Members
  • Total Members: 3,885
  • Latest: Growner
Stats
  • Total Posts: 195,173
  • Total Topics: 21,219
  • Online today: 319
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online

Events sign-up on Calendar

Started by jayemsee283, November 19, 2007, 07:33:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

darthi8nt

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

Quote from: darthi8nt on April 23, 2008, 03:38:31 AM
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.
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

It should only give events that are for "today" and after. That's what


AND startDate >= $today


is for.

confuzed

Quote from: JPDeni on January 02, 2009, 09:11:19 PM
It should only give events that are for "today" and after. That's what


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

Let's do a test. After


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


add


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

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

Okay. Then try this. Instead of


AND startDate >= $today


use


AND endDate >= '" . strftime('%Y-%m-%d', forum_time(false)) . "'

confuzed

yay!  that works.  :)
Thanks so much!

JPDeni

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