TinyPortal

Development => Resources => Topic started by: jayemsee283 on November 19, 2007, 12:33:28 AM

Title: Events sign-up on Calendar
Post by: jayemsee283 on November 19, 2007, 12:33:28 AM
I am looking for a mod that allows members (based on member group) to 'sign up' for an event. On clicking the event, it would add their name to a list with everyone else who has signed up.

This is very useful for planning teams for raids and such, and takes the pain out of organization.

Does anyone know where I could get one? I had it on vBulletin, and was one of the (few) features I just loved. I would post the code, but I couldn't find it within the 2,500 lines of php lol.

If there isn't one, would anyone know hard it would be to make one?
Title: Re: Events sign-up on Calendar
Post by: Zetan on November 19, 2007, 02:13:58 AM
Have you tried the packages at SMF? I know there are a few calendar mods there.
The calendar is part of SMF and we can't offer support, or change it.. You'll get better results at SMF.
Title: Re: Events sign-up on Calendar
Post by: jayemsee283 on November 20, 2007, 10:22:33 PM
Thanks. I have checked those out...none of them work for me.

Hehe...at least you guys respond to your members when they have a question :P.

Sorry for asking this, but maybe you would know ZTN...Is there any way to use a plugin from vBulletin to SMF? I will refrain from asking any other SMF questions now.

Thanks for the response!
Title: Re: Events sign-up on Calendar
Post by: Zetan on November 21, 2007, 04:37:05 AM
No.. I can assure you that vB plugins/Packages will not work with SMF or TinyPortal.
The packages are written to specifically use functions within the SMF shell, or additional functions.

Unless the script is stand alone and does not require integration into the software, then it may work.
People do manage to 'port' plugins and scripts designed for 'other' software.

If the script/plugin is open source 'free', you are welcome to post it.
If you have to purchase it, then I don't suggest posting the source code here.
Title: Re: Events sign-up on Calendar
Post by: TimUSA on November 21, 2007, 08:03:50 AM
There is an event attendee mod at smf for the calender:

http://custom.simplemachines.org/mods/index.php?mod=26
http://custom.simplemachines.org/mods/index.php?mod=138

however neither work for smf 1.4 :(

I agree this would be a great feature
Title: Re: Events sign-up on Calendar
Post by: dry3210 on November 21, 2007, 09:36:48 AM
Would be a great mod :(  Something you could install on a few boards would be great

Or even something that would work for certain articles in TP
Title: Re: Events sign-up on Calendar
Post by: omapie on November 21, 2007, 09:50:14 AM
you've tried this then (Jack's Phat Calendar)? I wondered about it. Have almost tried it several times! LOL

I'm still very new to smf and tp. I don't know enough about coding to update or even come up with a mod I imagine. I'm willing but my knowledge is lacking. sigh.
 ::)

So... anyway. It doesn't seem like there's much in the way of mods when it comes to events (planning, org, etc.) or calendars. ugh

:)

Lori
Title: Re: Events sign-up on Calendar
Post by: dry3210 on November 21, 2007, 10:13:56 AM
you've tried this then (Jack's Phat Calendar)? I wondered about it. Have almost tried it several times! LOL

I'm still very new to smf and tp. I don't know enough about coding to update or even come up with a mod I imagine. I'm willing but my knowledge is lacking. sigh.
 ::)

So... anyway. It doesn't seem like there's much in the way of mods when it comes to events (planning, org, etc.) or calendars. ugh

:)

Lori

Right now I post the events in a thread and as people post saying they are coming I update the list on the first post..its a pain

For awhile we had smf bridge with joomla and that has an event extension that you could "register" for events.  However I hated the bridge and how things ran so we switched to TP
Title: Re: Events sign-up on Calendar
Post by: Zetan on November 21, 2007, 10:40:10 AM
I use the calendar a lot..
http://labradio.co.uk/index.php?action=calendar


So any enhancements would be of interest to me too, I like this calendar:
http://www.liveandunsigned.uk.com/option,com_calendar/Itemid,16/

Which for me would be awesome, we would still need to link events to topics.
Title: Re: Events sign-up on Calendar
Post by: omapie on November 21, 2007, 11:48:16 AM
Zetan -- is that the basic calendar function you're running on your site? Very cool site, btw! Nicely done!
 :up:

Yes, dry3210. That's the problem I'm foreseeing. This specific site is a high school alumni/reunion site (http://jmhs-classmates.net). For the next reunion that's what I figure the problem will be & I sure don't want to have to do it like you're saying. UGH. TEDIOUS!

Plus, the folks who are the reunion coordinators are NOT really computer literate so anything I can do to help them is a good thing!

For this same site, I've got a joomla site set up (http://jmhs-classmates.org) but when I installed the bridge (by joomlashack), it "broke" the site. Needless to say, I got rid of the bridge when I uploaded my last backup. Thank goodness I'd backed up right before trying to get the bridge in place!
 :)

Seems like the bridge causes a lot of probs. I'm liking the SMF-TP solution much better thus far for the forum. Just need more mods re event planning or group management sort of things. And/OR maybe I just don't really understand the membergroups enough yet so.. Guess it'll all come with time! LOL  And maybe it'll handle more event-planning type things than I realize yet! Like I said... I'm so new to this software that I can't make much of a valid assessment I suppose! LOL

Even on the other site I've got TP installed, (http://myfibrofriends.org), I can see a use for the calendar & planning. The people there are ... brain-challenged, lots of memory issues. So it ends up with a lot of questions are, where's __so & so__? Course if you search the posts you can find out & inevitably someone remembers. It's a bit of a pain.
 ::)

But it'd be handy wouldn't it to just be able to refer to a calendar or some sort of package/mod that would help you with planning. I'm thinking calendar only because of the way I use my pda to keep track of things! Wouldn't HAVE to be a calendar I suppose though. Anyway...

Just thinking out loud I guess.

Guess I'm trying to figure out how to integrate these needs into what's existing since there doesn't seem to be anything really specific to these sort of needs. I guess linking posts to the calendar would do the trick for just keeping track of things like who's gone where, etc. wouldn't it!?!
 ;D

Anyway, I'm just thinking it wouldn't really work so well for things like event-planning because of probs like dry3210 mentions.

Lori
Title: Re: Events sign-up on Calendar
Post by: Zetan on November 21, 2007, 11:57:21 AM
Zetan -- is that the basic calendar function you're running on your site? Very cool site, btw! Nicely done!
 :up:

Thanks Lori  :)

The first link with the calendar is my site, the second is another site. I found their calendar interesting, so I bookmarked it.

The problem I've found with the standard calendar is that many of my members find it difficult to use, they have problems spanning multiple days.. theres some maths involved.

For example, if you have an event that has 5 dates:



Then you need to span 8 actual days, not 5. to cover all the days in the event.. there is no option currently to omit dates.
The 3rd, 4th and 6th for example. I have asked this before at SMF with no reply, or I missed the reply. :)
Title: Re: Events sign-up on Calendar
Post by: dry3210 on November 21, 2007, 12:19:50 PM
ZTN, I believe you can link to the calendar twice.  So you could do the first set of days, then again for the 2nd.  Annoying yes, but would work I believe.

As for the joomla bridge...it DOES work.  However theres an update for the joomla, update for the bridge, then if you want to do anything to SMF you have to unbridge it.  Also my members had to reset their passwords to be able to log in after the member sync.  I hated the seperate login for SMF/Joomla.  I hated members having to reset passwords to get in the first time.

Blah, I should just learn how to program this stuff.
Title: Re: Events sign-up on Calendar
Post by: Zetan on November 21, 2007, 12:27:51 PM
ZTN, I believe you can link to the calendar twice.  So you could do the first set of days, then again for the 2nd.  Annoying yes, but would work I believe.



 :) You can link twice, not ideal though when you have a world tour that spans 2 months, like Iron Maidens 2008 tour:
http://labradio.co.uk/index.php/topic,1372.msg9033.html
Title: Re: Events sign-up on Calendar
Post by: omapie on November 21, 2007, 12:47:45 PM
Hey dry3210! Re bridge, I'm only saying I had a bad experience trying to get it in place on the one particular instance I tried. I've seen several examples of where it works so I KNOW you're right that it does. However, because that instance was so bad and sucked up so much of my energy, I'm just not willing to try again right now! LOL

You make a case for not even bothering honestly. Hadn't thought of that but what an incredible hassle with all the different updates. Plus, the coordinated log-in/username was one of the primary draws for me in using a bridge between smf & joomla.

But honestly, (!) I'm very happy with the way TP is solving the problem.
 ;D

Yes, Zetan. Their calendar really IS interesting. Nicely done. Very usable; the little I've looked at it, it appears to be very user-friendly!

On the myfibrofriends site, they've had probs with using the calendar too. I think they just didn't really understand how to use it. Time will tell. I'm pretty new to the group still and we've got a lot of members just now joining or starting to be more active so.. time will tell! LOL

But I see the problem you mention. Of course, like you & dry3210 say, you can link to the calendar multiple times. But that IS a pain. Effective but not the most efficient I wouldn't think. But what do I know. I'm still learning about TP & SMF and there's a lot to learn! LOL

Ya'll take care! Have a great Thanksgiving!
 :laugh:

Lori
Title: Re: Events sign-up on Calendar
Post by: jayemsee283 on November 21, 2007, 01:18:51 PM
For those who would like to see it, I have set up a test account for a limited time (prob will turn off at midnight EST).

Go here (http://www.bloodmourne.net/vbulletin/calendar.php?month=7&year=2007&c=2&do=displaymonth) - login information is: username: test   pass: test
Title: Re: Events sign-up on Calendar
Post by: Zetan on November 21, 2007, 01:31:10 PM
I am familiar with vB, and I've seen similar Attendee scripts like at LastFM. Not seen it for vB though.
LastFM has an excellent profile base, they have avatars and comments of all the people attending.
 
Title: Re: Events sign-up on Calendar
Post by: jayemsee283 on November 21, 2007, 01:33:41 PM
Just thought I would share hehe.
Title: Re: Events sign-up on Calendar
Post by: Zetan on November 21, 2007, 01:41:53 PM
 :) I think that came across wrong. It's something that I would like to see in SMF.
I don't really want to install many more mods at the mo, though a calendar that fitted my needs would tempt me. I did install a calendar mod before that has mini calendars down the left side. It looks great, but messes up the page with narrow themes, so I removed it.
Title: Re: Events sign-up on Calendar
Post by: bluedevil on November 21, 2007, 01:49:25 PM
This called my attention too.  I have been eye ballin' it for awhile.
I tried updating the xml file for 1.1.4 but no luck.

Code: [Select]
<?xml version="1.0" ?>
  <!DOCTYPE package-info (View Source for full doctype...)>
- <package-info xmlns="http://www.simplemachines.org/xml/package-info" xmlns:smf="http://www.simplemachines.org/">
  <id>jack.r.abbit:phatcalpack</id>
  <name>Jack's Phat Calendar Pack</name>
  <version>1.0.4</version>
  <type>modification</type>
- <install for="1.1.4">
  <readme type="inline">This MOD adds the following functionality to the calendar: - Allow Post No Topic - Force Default Board - vCal/iCal Downloads - Event Attendees List All text has been translated for English, German and Spanish Written By Jack.R.Abbit - jack.r.abbit@modsbydesign.com http://www.modsbydesign.com Copyright 2004 - Neither this package or any of it's contents may be distributed without authorization</readme>
  Updated for SMF 1.1.4 by BlueDevil
  <modification format="boardmod" type="file" reverse="false">phatcalpack_v1.0.3_i.mod</modification>
  <code type="file">phatcalpack_v1.0_i_db.php</code>
  <require-file name="calindex.gif" destination="$themedir/images" />
  <require-file name="members.gif" destination="$themedir/images" />
  </install>
- <uninstall>
  <readme type="inline">This will uninstall all the changes made by this mod.</readme>
  <modification format="boardmod" reverse="true" type="file">phatcalpack_v1.0.3_i.mod</modification>
  <code type="file">phatcalpack_v1.0_u_db.php</code>
  <remove-file name="$themedir/images/calindex.gif" />
  <remove-file name="$themedir/images/members.gif" />
  </uninstall>
  </package-info>

Title: Re: Events sign-up on Calendar
Post by: omapie on November 21, 2007, 07:17:29 PM
For those who would like to see it, I have set up a test account for a limited time (prob will turn off at midnight EST).

jayemsee283 -- TY for posting that. That's pretty nifty the way it works. Simple but... concise.
:)

Lori
Title: Re: Events sign-up on Calendar
Post by: jayemsee283 on November 21, 2007, 07:54:21 PM
My pleasure. Its simplicity is its elegance really. Cutting/pasting that to a forum, .txt file, whatever else makes life easier.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 03, 2008, 06:06:04 PM
There is an event attendee mod at smf for the calender:

http://custom.simplemachines.org/mods/index.php?mod=26
http://custom.simplemachines.org/mods/index.php?mod=138

however neither work for smf 1.4 :(

I agree this would be a great feature

Someone has updated this one and it has recently been submitted to the mod site.  This one does work for 1.1.4 as I have it installed :)  The mod author has downloads in the thread until the mod is official.  It gives a nice list of attendees at the top of the thread.

What I would like, and I'm hoping someone would know how to do this, is to have a tiny portal block that displays all the events that a member has signed up for - so it would be different for each member, not a list of everyone's events but just their events that they have agreed to attend.  This would act as a reminder for each member, and have all the events in one place ie the block. 

======================
My events:

Member chat April 17  < link to event thread
Weekend meet April 30 < link to event thread
Music Festival May 15 < link to event thread
Board celebration May 25 < link to event thread

======================

Could someone who is good with the coding work this out for me?  I think it would be very handy for a lot of boards, just tell me what you need.  If you need to see the install file to see what the mod does I can upload it here.

Thanks in advance  :)
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 03, 2008, 06:11:07 PM
I might be able to do it, but I would need to see the code so I'd know what queries to write.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 03, 2008, 06:24:38 PM
ok, sounds good :)

Here is the mod installation file, I hope that's the one you mean - attached actually not attached as it's not an accepted file type for attachments.

Here is the code:

Code: [Select]
<id>
PhatCalPack
</id>

<version>
1.0
</version>

<edit file>
index.php
</edit file>

<search for>
'who' => array('Who.php', 'Who'),
</search for>

<add before>
'toggleVCal' => array('Calendar.php', 'ToggleVCal'),
'showVCal' => array('Calendar.php', 'ShowVCal'),
'dlVCal' => array('Calendar.php', 'DownloadVCal'),
'toggleAttend' => array('Calendar.php', 'ToggleAttend'),
</add before>



<edit file>
Sources/Calendar.php
</edit file>

<search for>
$events = array();
</search for>

<replace>
$result2 = db_query("
SELECT
cal.ID_EVENT, DAYOFMONTH(cal.ID_EVENT) AS day, cal.title, cal.ID_MEMBER, cal.ID_TOPIC, cal.ID_BOARD
FROM {$db_prefix}calendar AS cal
WHERE cal.ID_EVENT BETWEEN '$low_date' AND '$high_date'
AND cal.ID_TOPIC = 0
AND cal.ID_BOARD = 0", __FILE__, __LINE__);

$results = array();
</replace>

<search for>
{
// Censor the title.
</search for>

<add before>
$results[] = $row;
while ($row = mysql_fetch_assoc($result2))
$results[] = $row;

$events = array();
foreach ($results as $row)
</add before>

<search for>
'msg' => $row['ID_FIRST_MSG'],
</search for>

<replace>
'msg' => !empty($row['ID_FIRST_MSG']) ? $row['ID_FIRST_MSG'] : '0',
</replace>

<search for>
?>
</search for>

<add before>
function ToggleAttend()
{
global $ID_MEMBER, $user_info, $db_prefix, $board, $topic, $modSettings, $options;

if ($user_info['is_guest'])
fatal_lang_error(138, false);

if (!allowedTo('calendar_view'))
fatal_lang_error(1, false);

if (empty($modSettings['cal_enabled']) || empty($modSettings['enable_attendees']))
fatal_lang_error('calendar_off', false);

$request = db_query("
SELECT id_event, attendees
FROM {$db_prefix}calendar
WHERE id_board = $board
AND id_topic = $topic
LIMIT 1", __FILE__, __LINE__);

$attendeeinfo = mysql_fetch_assoc($request);

if ($attendeeinfo['id_event'] != '')
{
$attendees = explode(',', $attendeeinfo['attendees']);
if (in_array("$ID_MEMBER", $attendees))
{
$thisArray[] = $ID_MEMBER;
$attendees = array_diff($attendees, $thisArray);
}
else
$attendees[] = $ID_MEMBER;

$attendees = implode(",", array_unique($attendees));
if (substr($attendees,0,1) == ',')
$attendees = substr($attendees,1);

$request = db_query("
UPDATE {$db_prefix}calendar
SET attendees='$attendees'
WHERE id_board = $board
AND id_topic = $topic
LIMIT 1", __FILE__, __LINE__);
}
redirectexit($_SERVER['HTTP_REFERER'], false);
}

function ToggleVCal()
{
global $user_info, $cookiename, $cookie_url, $modSettings, $options;

if ($user_info['is_guest'])
fatal_lang_error(138, false);

if (!allowedTo('calendar_view'))
fatal_lang_error(1, false);

if (empty($modSettings['cal_enabled']) || empty($modSettings['enable_vCal']) || empty($options['vCal_style']))
fatal_lang_error('calendar_off', false);

if (isset($_COOKIE[$cookiename . '-vcal']))
    $vCalList = explode(';', $_COOKIE[$cookiename . '-vcal']);
else
$vCalList = array();

   if (in_array($_GET['calid'], $vCalList))
     $vCalList = array_diff($vCalList, array($_GET['calid']));
else
     $vCalList[] = $_GET['calid'];

  $vCalList = implode(";", array_unique($vCalList));

setcookie($cookiename . '-vcal', $vCalList, 0, $cookie_url[1], $cookie_url[0]);

redirectexit($_SERVER['HTTP_REFERER'], false);
}

function ShowVCal()
{
global $txt, $context, $db_prefix, $user_info, $cookiename, $modSettings, $options;

// This is gonna be needed...
loadTemplate('Calendar');

if ($user_info['is_guest'])
fatal_lang_error(138, false);

if (!allowedTo('calendar_view'))
fatal_lang_error(1, false);

if (empty($modSettings['cal_enabled']) || empty($modSettings['enable_vCal']) || empty($options['vCal_style']))
fatal_lang_error('calendar_off', false);

$context['page_title'] = $context['forum_name'] . ' : vCal/iCal : ' . $txt['vCal_view'];
$context['vcal']['list_empty'] = !isset($_COOKIE[$cookiename . '-vcal']);

if (!$context['vcal']['list_empty'])
{
    $context['vcal']['dlStyle'] = ($options['vCal_style'] == 1 ? 'vCal' : 'iCal');
$vCalList = explode(';', $_COOKIE[$cookiename . '-vcal']);

$request = db_query("
SELECT T1.id_event, T1.eventDate, T1.title FROM {$db_prefix}calendar AS T1
LEFT JOIN {$db_prefix}calendar AS T2
ON T1.id_topic=T2.id_topic
WHERE T1.id_event = " . implode(' OR T1.id_event = ', $vCalList) . "
ORDER BY T1.eventDate ASC", __FILE__, __LINE__);

$context['events'] = array();
while ($eventinfo = mysql_fetch_assoc($request))
{
if (!isset($context['events'][$eventinfo['id_event']]))
{
list($eventinfo['year'], $eventinfo['month'], $eventinfo['day']) = explode('-', $eventinfo['eventDate']);
$context['events'][$eventinfo['id_event']] = $eventinfo;
$context['events'][$eventinfo['id_event']]['span'] = 0;
}
$context['events'][$eventinfo['id_event']]['span'] = $context['events'][$eventinfo['id_event']]['span'] + 1;
}
}

// Set the sub template to the output.
$context['sub_template'] = 'show_vCal';

obExit();
}

function DownloadVCal()
{
global $context, $db_prefix, $user_info, $cookiename, $modSettings, $options;

if (!isset($_COOKIE[$cookiename . '-vcal']))
fatal_lang_error('vCal_empty', false);

if ($user_info['is_guest'])
fatal_lang_error(138, false);

if (!allowedTo('calendar_view'))
fatal_lang_error(1, false);

if (empty($modSettings['cal_enabled']) || empty($modSettings['enable_vCal']) || empty($options['vCal_style']))
fatal_lang_error('calendar_off', false);

if (isset($_COOKIE[$cookiename . '-vcal']))
{
$request = db_query("
SELECT cal.id_event, cal.eventDate, cal.title, mes.body, t.ID_FIRST_MSG, mes.ID_MSG
FROM {$db_prefix}calendar AS cal, {$db_prefix}messages AS mes, {$db_prefix}topics AS t
LEFT JOIN {$db_prefix}calendar AS T2 ON cal.id_topic=T2.id_topic
LEFT JOIN {$db_prefix}topics AS T3 ON T3.ID_FIRST_MSG=cal.id_topic
WHERE (cal.id_event = " . implode(' OR cal.id_event = ', explode(';', $_COOKIE[$cookiename . '-vcal'])) . ")
AND mes.ID_MSG=t.ID_FIRST_MSG
AND cal.id_topic=mes.ID_TOPIC
ORDER BY cal.eventDate", __FILE__, __LINE__);

$trans_table = array_flip(get_html_translation_table(HTML_SPECIALCHARS));
$trans_table['&#39;'] = "'";
$trans_table['&#039;'] = "'";
$trans_table['&#36;'] = "$";
$trans_table['&nbsp;'] = " ";
$trans_table['<br />'] = "=0D=0A";
$trans_table['<br>'] = "=0D=0A";

$context['events'] = array();
while ($eventinfo = mysql_fetch_assoc($request))
{
if (!isset($context['events'][$eventinfo['id_event']]))
{
list($eventinfo['year'], $eventinfo['month'], $eventinfo['day']) = explode('-', $eventinfo['eventDate']);
$eventinfo['body'] = strip_tags(strtr(doUBBC($eventinfo['body'],0), $trans_table));
$context['events'][$eventinfo['id_event']] = $eventinfo;
$context['events'][$eventinfo['id_event']]['span'] = 0;
}
$context['events'][$eventinfo['id_event']]['span'] = $context['events'][$eventinfo['id_event']]['span'] + 1;
}

if ($_REQUEST['dltype'] == 'iCal')
{
$fileExt = '.ics';
$vcalVersion = '2.0';

$repeatRule = '
RRULE:FREQ=DAILY;INTERVAL=1;COUNT={$eventinfo[\'span\']}';

}
else
{
$fileExt = '.vcs';
$vcalVersion = '1.0';

$repeatRule = '
RRULE:D1 {$endDate}';

}

$beginVCAL = 'BEGIN:VCALENDAR
PRODID:SMF Generated
VERSION:{$vcalVersion}
METHOD:PUBLISH
';

$beginEvent = '
BEGIN:VEVENT
UID:event-{$eventinfo[\'id_event\']}
DTSTAMP:' . gmdate("Ymd\THis") . 'Z
DTSTART:{$startDate}Z
DTEND:{$startDate2}Z';

$endEvent = '
SUMMARY:{$eventinfo[\'title\']}
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:{$desc}
END:VEVENT

';

eval("\$vCalString = \"$beginVCAL\";");

foreach ($context['events'] as $eventinfo)
{
$startDate =  gmdate("Ymd\THis",  mktime(0, 0, 0, $eventinfo['month'], $eventinfo['day'], $eventinfo['year']));
$startDate2 =  gmdate("Ymd\THis",  mktime(0, 0, 0, $eventinfo['month'], $eventinfo['day'] + 1, $eventinfo['year']));
$endDate =  gmdate("Ymd",  mktime(0, 0, 0, $eventinfo['month'], $eventinfo['day'] + $eventinfo['span'] - 1, $eventinfo['year']));
$desc = $eventinfo['body'];

eval("\$vCalString .= \"$beginEvent\";");

if ($eventinfo['span'] > 1)
eval("\$vCalString .= \"$repeatRule\";");

eval("\$vCalString .= \"$endEvent\";");
}

$vCalString .= 'END:VCALENDAR

';

setCookie($cookiename . '-vcal', '');
header("Content-Encoding: none");
header("Content-type: octet/stream");
header("Content-disposition: filename=events$fileExt");
header('Cache-Control: private');
header('Connection: close');

echo $vCalString, "\r\n";

obExit(false);
}
}

</add before>

<edit file>
Sources/Display.php
</edit file>

<search for>
// Create the poll info if it exists.
</search for>

<add before>
  // Start with topic not linked to calendar.
$context['cal_linked'] = false;

// Get calendar event info... if one exists.
if (!$user_info['is_guest'] && allowedTo('calendar_view') && $modSettings['cal_enabled'] == '1')
{
$request = db_query("
SELECT id_event, attendees
FROM {$db_prefix}calendar
WHERE id_board = $board
AND id_topic = $topic
LIMIT 1", __FILE__, __LINE__);

$context['cal_linked'] = mysql_num_rows($request) == 1;

if ($context['cal_linked'])
$cal_info = mysql_fetch_assoc($request);
}

// Create the vCal/iCal section
if ($context['cal_linked'] && !empty($modSettings['enable_vCal']) && !empty($options['vCal_style']))
{
global $cookiename;
$context['vcal'] = $cal_info;
$context['vcal']['list_empty'] = !isset($_COOKIE[$cookiename . '-vcal']);
$context['vcal']['toggle_link'] = ((!$context['vcal']['list_empty'] && in_array($context['vcal']['id_event'], split(';', $_COOKIE[$cookiename . '-vcal']))) ? $txt['vCal_remove'] : $txt['vCal_add']);
$context['vcal']['dlStyle'] = ($options['vCal_style'] == 1 ? 'vCal' : 'iCal');
}

// Create the Attendees section
if ($context['cal_linked'] && !empty($modSettings['enable_attendees']))
{
$context['cal_attendees']['id_event'] = $cal_info['id_event'];
$attendees = $cal_info['attendees'];
$context['cal_attendees']['attendees'] = array();
$request = db_query("
SELECT ID_MEMBER, memberName, realName, location
FROM {$db_prefix}members
WHERE (FIND_IN_SET(ID_MEMBER, '$attendees'))
ORDER BY ID_MEMBER ASC", __FILE__, __LINE__);

while ($attendee = mysql_fetch_assoc($request))
$context['cal_attendees']['attendees'][] = $attendee;

if (in_array("$ID_MEMBER", explode(',', $attendees)))
$context['cal_attendees']['toggle_link'] = '<a href="' . $scripturl . '?action=toggleAttend;topic=' . $topic . '">' . $txt['cal_attend_no'] . '</a>';
else
$context['cal_attendees']['toggle_link'] = '<a href="' . $scripturl . '?action=toggleAttend;topic=' . $topic . '">' . $txt['cal_attend_yes'] . '</a>';
}

</add before>

<search for>
$context['calendar_post'] &= !empty($modSettings['cal_enabled']);
</search for>

<replace>
$context['calendar_post'] = !empty($modSettings['cal_enabled']) && (($modSettings['cal_defaultboard'] == $board));
</replace>

<edit file>
Sources/ModSettings.php
</edit file>

<search for>
// Who's online.
array('check', 'who_enabled'),
</search for>

<add after>
                  '',
           
        // Enable the vCal/iCal?
array('check', 'enable_vCal', &$txt['enable_vCal']),
// Enable the Attendee list?
array('check', 'enable_attendees', &$txt['enable_attendees']),
                  array('check', 'cal_force_default', &$txt['cal_force_default']),
array('check', 'cal_allow_no_post', &$txt['cal_allow_no_post']),
</add after>



<edit file>
Sources/Post.php
</edit file>

<search for>
// Posting an event?
$context['make_event'] = isset($_REQUEST['calendar']);
</search for>

<add after>
$context['cal_allow_no_post'] = $context['make_event'] && $modSettings['cal_allow_no_post'];
$context['cal_force_no_post'] = ($modSettings['cal_defaultboard'] == 0) && $modSettings['cal_force_default'] && (empty($_REQUEST['msg']) || $_REQUEST['msg'] == 0);
</add after>

<search for>
{
checkSession('get');

</search for>

<replace>
{
checkSession('get');
if ($_REQUEST['msg'] == 0)
{
$form_subject = '';
$form_message = '';
$context['icon'] = '';
}
else
{
</replace>

<search for>
// Set the destinaton.
</search for>

<add before>
}

</add before>

<search for>
// What are you doing?  Posting a poll, modifying, previewing, new post, or reply...
</search for>

<add before>
$context['cal_posting_denied'] = $context['cal_force_no_post'] || ($context['make_event'] && !$context['event']['new'] && $context['event']['board'] == 0);
</add before>

<search for>
'url' => $scripturl . '?topic=' . $topic . '.' . $_REQUEST['start'],
</search for>

<replace>
'url' => $scripturl . '?topic=' . $topic . '.' . (isset($_REQUEST['start']) ? $_REQUEST['start'] : 0),
</replace>







<edit file>
Themes/default/Calendar.template.php
</edit file>



<search for>
?>
</search for>

<add before>
function template_show_vCal()
{
global $context, $scripturl, $txt;

echo '
<table border="0" width="80%" cellspacing="0" align="center" cellpadding="4" class="tborder">
<tr>
<td class="titlebg"><b>vCal/iCal - ' . $txt['vCal_view'] . '</b></td>
</tr><tr>
<td class="windowbg">';

if (!$context['vcal']['list_empty'])
{
echo '
<script language="JavaScript" type="text/javascript">
<!--
var timerID = 0;
function refreshPage(id) {
if (id == 0) {
timerID = setTimeout("refreshPage(1)", 1000);
} else {
  clearTimeout(timerID);
window.location = "' . $scripturl . '?action=showVCal";
}
}
//-->
</script>';
foreach ($context['events'] as $eventinfo)
{
$startDate =  date("m/d/Y",  mktime(0, 0, 0, $eventinfo['month'] + 1, $eventinfo['day'], $eventinfo['year']));
$endDate =  date("m/d/Y",  mktime(0, 0, 0, $eventinfo['month'] + 1, $eventinfo['day'] + $eventinfo['span'] - 1, $eventinfo['year']));
echo $eventinfo['title'] . ' (' . $startDate;
if ($eventinfo['span'] > 1)
echo ' - ' . $endDate;
echo ') <a href="' . $scripturl . '?action=toggleVCal;calid=' . $eventinfo['id_event'] . '">' . $txt['vCal_remove'] . '</a><br>';
}
echo '<br><a href="', $scripturl, '?action=dlVCal;dltype=' . $context['vcal']['dlStyle'] . '" onClick="refreshPage(0)">' . $txt['vCal_download'] . '</a> (' . $context['vcal']['dlStyle'] . ')';
}
else
{
echo $txt['vCal_empty'];
}

echo '
</td>
</tr>
</table>
<div align="center" style="margin-top: 2ex;"><a href="javascript:history.go(-1)">' . $txt[193] . '</a></div>
';

}

</add before>

<edit file>
Themes/default/Display.template.php
</edit file>

<search for>
// Show the topic information - icon, subject, etc.
</search for>

<add before>
// Is this topic also linked to the calendar?
if ($context['cal_linked'])
{
if (!empty($context['cal_attendees']))
{
echo '
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder" style="border-bottom: 0;">
<tr class="titlebg">
<td valign="middle" align="left" style="padding-left: 6px;">
<img src="', $settings['images_url'], '/members.gif" alt="" align="top" /> ' . $txt['cal_attendee_title'] . '
</td>
</tr>
<tr class="windowbg">
<td>
<table cellpadding="3" cellspacing="0" border="0" width="100%">
<tr>
<td>';

if (empty($context['cal_attendees']['attendees']))
echo '<b>' . $txt['cal_attendees_no'] . '</b>';
else
{
echo '<b>' . $txt['cal_attendees_yes'] . '</b><br />';
foreach ($context['cal_attendees']['attendees'] as $attendee)
{
echo '
<a href="' . $scripturl . '?action=profile;u=' . $attendee['ID_MEMBER'] . '" title="' . $txt[92] . ' ' . $attendee['memberName'] . '">' . $attendee['memberName'] . ' (' . $attendee['realName'] . ')</a>';
if ($attendee['location'] != '')
echo ' - ' . $attendee['location'];
echo '<br />';
}
}

echo '
</td>
<td>&nbsp;</td>
<td>' . $context['cal_attendees']['toggle_link'] . '</td>
</td>
</tr>
</table>
</td>
</tr>
</table>';
}

if (!empty($context['vcal']))
{
echo '
   <!-- vCal/iCal -->
<script language="JavaScript" type="text/javascript">
<!--
var timerID = 0;
function refreshPage(id) {
if (id == 0) {
timerID = setTimeout("refreshPage(1)", 1000);
} else {
  clearTimeout(timerID);
window.location.reload();
}
}
//-->
</script>
<table cellpadding="3" cellspacing="0" border="0" width="100%" class="tborder" style="border-bottom: 0;">
<tr class="titlebg">
<td valign="middle" align="left" style="padding-left: 6px;">
<img src="', $settings['images_url'], '/calindex.gif" alt="" align="top" /> ' . $txt['vCal_title'] . '
</td>
</tr>
<tr class="windowbg">
<td>
<a href="', $scripturl, '?action=toggleVCal;calid=', $context['vcal']['id_event'], ';topic=', $context['current_topic'], '.', $context['start'], '">', $context['vcal']['toggle_link'], '</a>';
if (!$context['vcal']['list_empty'])
{
echo '&nbsp;&nbsp;&nbsp;&nbsp;
<a href="', $scripturl, '?action=showVCal;topic=', $context['current_topic'], '.', $context['start'], '">' . $txt['vCal_view'] . '</a>&nbsp;&nbsp;&nbsp;&nbsp;
<a href="', $scripturl, '?action=dlVCal;dltype=' . $context['vcal']['dlStyle'] . '" onClick="refreshPage(0)">' . $txt['vCal_download'] . '</a> (' . $context['vcal']['dlStyle'] . ')';
}
echo '
</td>
</tr>
</table>';
}
}

</add before>

<edit file>
Themes/default/languages/Modifications.english.php
</edit file>

<search for>
?>
</search for>

<add before>
$txt['vCal_title'] = 'vCal/iCal';
$txt['vCal_remove'] = 'Remove this event';
$txt['vCal_add'] = 'Add this event';
$txt['vCal_view'] = 'View List';
$txt['vCal_download'] = 'Download List';
$txt['vCal_empty'] = 'You have no events in your ' . $txt['vCal_title'] . ' list.';

$txt['cal_attendee_title'] = 'Attendees';
$txt['cal_attendees_no'] = 'No one is attending this event yet.';
$txt['cal_attendees_yes'] = 'Members planning to attend';
$txt['cal_attend_no'] = 'I\'ve changed my mind';
$txt['cal_attend_yes'] = 'I plan to attend this event';

$txt['enable_vCal'] = 'Enable vCal/iCal Downloads';
$txt['enable_attendees'] = 'Enable Attendee List';
$txt['cal_force_default'] = 'Force Default Board';
$txt['cal_allow_no_post'] = 'Allow Post No Topic';

$txt['cal_no_post'] = 'Post No Topic';

$txt['vCal_style'] = 'vCal/iCal download style:';
$txt['vCal_style1'] = 'Disable';
$txt['vCal_style2'] = 'vCal';
$txt['vCal_style3'] = 'iCal';

</add before>

<edit file>
Themes/default/languages/Modifications.german.php
</edit file>

<search for>
?>
</search for>

<add before>
$txt['vCal_title'] = 'vCal/iCal';
$txt['vCal_remove'] = 'Entfernen Sie diesen Fall';
$txt['vCal_add'] = 'Addieren Sie diesen Fall';
$txt['vCal_view'] = 'Ansicht-Liste';
$txt['vCal_download'] = 'Download-Liste';
$txt['vCal_empty'] = 'Sie haben keine Fälle in Ihrer ' . $txt['vCal_title'] . ' Liste.';

$txt['cal_attendee_title'] = 'Teilnehmer';
$txt['cal_attendees_no'] = 'Niemand sorgt sich diesen Fall schon.';
$txt['cal_attendees_yes'] = 'Mitglieder, die planen zu beachten';
$txt['cal_attend_no'] = 'Ich habe meinen Verstand geändert';
$txt['cal_attend_yes'] = 'Ich plane, mich diesen Fall zu sorgen';

$txt['enable_vCal'] = 'Ermöglichen Sie vCal/iCal Downloads';
$txt['enable_attendees'] = 'Ermöglichen Sie Teilnehmer-Liste';
$txt['cal_force_default'] = 'Kraft-Rückstellung Brett';
$txt['cal_allow_no_post'] = 'Erlauben Sie Pfosten Kein Thema';

$txt['cal_no_post'] = 'Geben Sie Kein Thema Bekannt';

$txt['vCal_style'] = 'vCal/iCal Downloadart:';
$txt['vCal_style1'] = 'Sperren Sie';
$txt['vCal_style2'] = 'vCal';
$txt['vCal_style3'] = 'iCal';

</add before>

<edit file>
Themes/default/languages/Modifications.spanish.php
</edit file>

<search for>
?>
</search for>

<add before>
$txt['vCal_title'] = 'vCal/iCal';
$txt['vCal_remove'] = 'Quite este acontecimiento';
$txt['vCal_add'] = 'Agregue este acontecimiento';
$txt['vCal_view'] = 'Lista De la Visión';
$txt['vCal_download'] = 'Lista De la Transferencia directa';
$txt['vCal_empty'] = 'Usted no tiene ningún acontecimiento en su lista de ' . $txt['vCal_title'];

$txt['cal_attendee_title'] = 'Asistentes';
$txt['cal_attendees_no'] = 'Nadie está atendiendo a este acontecimiento todavía.';
$txt['cal_attendees_yes'] = 'Miembros que planean atender';
$txt['cal_attend_no'] = 'He cambiado mi mente';
$txt['cal_attend_yes'] = 'Planeo atender a este acontecimiento';

$txt['enable_vCal'] = 'Permita las transferencias directas de vCal/iCal';
$txt['enable_attendees'] = 'Permita La Lista Del Asistente';
$txt['cal_force_default'] = 'Tablero Del Defecto De la Fuerza';
$txt['cal_allow_no_post'] = 'Prohiba A Poste Asunto';

$txt['cal_no_post'] = 'No fije Ningún Asunto';

$txt['vCal_style'] = 'Estilo de la transferencia directa de vCal/iCal:';
$txt['vCal_style1'] = 'Inhabilite';
$txt['vCal_style2'] = 'vCal';
$txt['vCal_style3'] = 'iCal';

</add before>

<edit file>
Themes/default/Post.template.php
</edit file>

<search for>
// Code for showing and hiding additional options.
if (!empty($settings['additional_options_collapsable']))
</search for>

<replace>
// Code for showing and hiding additional options.
if (!empty($settings['additional_options_collapsable']) && !$context['cal_posting_denied'])
</replace>

<search for>
echo '
<tr>
<td align="right"><b>', $txt['calendar13'], '</b></td>
<td class="smalltext">
<select name="board">';

foreach ($context['event']['boards'] as $board)
echo '
<option value="', $board['id'], '"', $board['id'] == $context['event']['board'] ? ' selected="selected"' : '', '>', $board['cat']['name'], ' - ', $board['prefix'], $board['name'], '</option>';

echo '
</select>
</search for>

<replace>
echo '
<tr>
<td align="right"><b>', $txt['calendar13'], '</b></td>
<td class="smalltext">';
if ($modSettings['cal_force_default'] && $modSettings['cal_allow_no_post'] && $context['event']['board'] != 0)
{
echo '
<select name="board">
<option value="0">' . $txt['cal_no_post'] . '</option>';
foreach ($context['event']['boards'] as $board)
if ($board['id'] == $context['event']['board'])
echo '
<option value="', $board['id'], '"', $board['id'] == $context['event']['board'] ? ' selected="selected"' : '', '>', $board['cat']['name'], ' - ', $board['prefix'], $board['name'], '</option>';
echo '
</select>';
}
else if ($modSettings['cal_force_default'])
{
echo '
<input type="hidden" name="board" value="', $context['event']['board'], '">';
if ($context['cal_force_no_post'])
echo $txt['cal_no_post'];
else
foreach ($context['event']['boards'] as $board)
if ($board['id'] == $context['event']['board'])
echo $board['cat']['name'], ' - ', $board['prefix'], $board['name'];
}
else
{
echo '
<select name="board">';
if ($context['cal_allow_no_post'])
echo '
<option value="0">' . $txt['cal_no_post'] . '</option>';
foreach ($context['event']['boards'] as $board)
echo '
<option value="', $board['id'], '"', $board['id'] == $context['event']['board'] ? ' selected="selected"' : '', '>', $board['cat']['name'], ' - ', $board['prefix'], $board['name'], '</option>';
echo '
</select>';
}

echo '
</replace>

<search for>
// Now show the subject box for this post.
</search for>

<add before>
if ($context['cal_posting_denied'])
{
echo '
<input type="hidden" name="cal_posting_denied" value="1">
<input type="hidden" name="subject" value="">
<input type="hidden" name="message" value="">
<input type="hidden" name="icon" value="">';
}
else
{
      }
</add before>

<search for>
// If the admin has enabled the hiding of the additional options - show a link and image for it.
if (!empty($settings['additional_options_collapsable']))
</search for>

<replace>
// If the admin has enabled the hiding of the additional options - show a link and image for it.
if (!empty($settings['additional_options_collapsable']) && !$context['cal_posting_denied'])
</replace>



<edit file>
Themes/default/Settings.template.php
</edit file>

<search for>
array(
'id' => 'return_to_post',
'label' => $txt['return_to_post'],
'default' => true,
),
</search for>

<add after>
array(
'id' => 'vCal_style',
'label' => $txt['vCal_style'],
'options' => array(
0 => $txt['vCal_style1'],
1 => $txt['vCal_style2'],
2 => $txt['vCal_style3']
),
),

</add after>

Hope you can work it out :)
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 07, 2008, 07:42:39 AM
hi was that the right information jpdeni or do you need me to provide something else?

Thanks
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 07, 2008, 08:12:12 AM
I don't know how it works, really. I can't seem to figure it out by looking at the code. I'll see if I can figure it out by installing the mod on my test site and then see what I can do about creating a block for it. It'll likely take several days.
Title: Re: Events sign-up on Calendar
Post by: Heero on April 07, 2008, 08:18:14 AM
Another neat idea would be allowing users to sign up via an article which creates an automatic post upon their submission !
As I remember there is a block done which could possibly do this with a few additional edits ;)! Check this one out! (http://www.tinyportal.net/index.php?topic=9840.msg84957#msg84957)
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 07, 2008, 08:25:22 AM
confuzed, where is the mod? I don't know which one to use. I need the whole package.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 07, 2008, 08:32:09 AM
sorry, latest download of mod can be found in this post http://www.simplemachines.org/community/index.php?topic=200368.msg1491804#msg1491804
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 07, 2008, 09:47:06 AM
Cool. :) I got it.

I need a few people to sign up for an event so I can see how things look in the database. If you have a little bit of time, could you sign up for an account at http://www.jpdeni.com/snippets/index.php?action=forum and then say you want to attend the one event that I've got there. It's in General Discussion and the topic is "Really cool event." That'll help me to figure out how the information is stored in the database.
Title: Re: Events sign-up on Calendar
Post by: Ken. on April 07, 2008, 09:54:41 AM
Just signed up and gave it a try JP... this is looking good.  :up:
On one of my sites this would be useful often... maybe more that once a month.
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 07, 2008, 10:05:39 AM
Well, at this point, it's a mod that's available from SMF. I'm writing some block code that will list what events the user has signed up for. I just needed data to play with.

I appreciate the help!!
Title: Re: Events sign-up on Calendar
Post by: omapie on April 07, 2008, 11:37:04 AM
I just signed up... looks cool.. very useful potentially. ;)

Keep us informed. On my high school reunion website, I'm thinking this could be very useful. TY!  :up:

Lori
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 07, 2008, 11:44:21 AM
Thanks much!! There's another event (even cooler than the first ;) ) that you can sign up for. And then you can see the list of events that you've signed up for in the right panel.

This goes into a php 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 . '?topic=' . $row[0] . '.0">' . $row[1] . '</a> ' . date('F j',strtotime($row[2]));
    if  ($row[2] < $row[3])
      echo ' - ' . date('F j',strtotime($row[3]));
    echo '<br>';
  }
}

You might want to play around with the html for this so the display is how you want.

In order to see it in action, you'll need to register at http://www.jpdeni.com/snippets and check that you are going to attend both events listed in the General Discussion board.

Edited to add:

I've moved things around a bit. If you want to see the block, go to http://www.jpdeni.com/snippets/index.php?page=7  after you have logged in. It makes no sense to allow guests to see the block, because it only lists information for the logged-in user.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 07, 2008, 02:04:43 PM
wow!  that's really great JPDeni.  I just tried the block on my site and it works brilliantly.  Thanks for working that out and so quickly

*confused is very excited now*

I love this attendee mod but I thought it would also be handy to be able to see your own events all in one place.

This is it!   
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 07, 2008, 02:08:56 PM
I'm glad you like it. :-) It wasn't hard to do once I figured out how the info was stored in the database.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 07, 2008, 05:31:07 PM
uh oh, I don't think it's working properly though, it seems to be showing the same events for every member regardless of whether they are attending or not
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 07, 2008, 08:22:35 PM
Hmmmmm. I don't get that. I only have two events defined, but when I have a user sign up for one, only that one is displayed in the block. If a user hasn't signed up for any, it's not showing anything, which I should fix.

Now, if there's nothing returned from the search, it says that the user hasn't signed up for anything yet.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 08, 2008, 02:52:15 AM
I tried the code again but it is still showing a list of all events whether the user is attending or not.
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 08, 2008, 06:16:56 AM
I'm not sure what to tell you. Did you go to my "snippets" site to test it out?
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 08, 2008, 06:34:01 AM
I didnt want to register at another site, but I have now and it seems to be working on yours.  I wonder why it isn't working on mine. 

I will start over


edited:  ok it seems to be working now, I don't know what I did different, but it is showing the correct events for each member.  But if you are an Admin it shows all events even if you have signed up for none.  That was what was confusing me, as I logged in under another account to look and it showed all events, but that was an admin account too.  I logged in as a regular member and saw only the events I signed up for.

thanks again
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 08, 2008, 06:51:54 AM
The code is written to search for the person who is viewing the block. It wouldn't do any good to use it as it stands in the profile summary.

For example, if you looked at my profile summary, you would not be able to see the events that I had signed up for. You would see the events that you signed up for. In order for you to see the events that I had signed up for, the query would have to be different.

Not sure why it's not working on your site, though. Maybe a start-over will help.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 08, 2008, 06:54:53 AM
sorry, I edited the above post before I realised you had replied

But if you are an Admin it shows all events even if you have signed up for none.  That was what was confusing me, as I logged in under another account to look and it showed all events, but that was an admin account too.  I logged in as a regular member and saw only the events I signed up for.
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 08, 2008, 07:48:08 AM
Quote
But if you are an Admin it shows all events even if you have signed up for none.
It doesn't on mine. I don't know why it does on yours.

Can you access your database directly, through phpMyAdmin? If you can, take a look at the calendar table and see if your user number is in all of the "attendees" field. That's the only way it would do what you're saying. The code doesn't look at the admin status of the user, but only looks at the "attendees" field in the calendar.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 08, 2008, 09:46:46 AM
ok I'll take a look after work :)
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 08, 2008, 12:07:30 PM
ok it is working now :)

now I wanted to put it on another part of the site, like in profiles, is that possible or do you have to change the code?  As an admin I would like to see other people's lists of events and I thought putting it in profiles would be a way to do it.   
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 08, 2008, 12:30:27 PM
You would have to change the code. The code looks at the current user's ID and uses that for the query. That's what the variable $ID_MEMBER is. You'd have to look at the profile script to know what variable is used for the queries on the profile and then substitute that for $ID_MEMBER.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 08, 2008, 01:26:14 PM
ok thanks, I'll have a look but I don't know anything about coding.  Maybe something will pop out at me lol
Title: Re: Events sign-up on Calendar
Post by: JPDeni on April 08, 2008, 01:34:47 PM
It's just that altering the profile isn't part of TP and we're supposed to focus on TP here. Maybe you can get help from the mod creator or someone at SMF.
Title: Re: Events sign-up on Calendar
Post by: confuzed on April 08, 2008, 06:20:00 PM
thanks, understood.  I looked at it myself but it's all greek to me.   

Alternately would it be possible to have an admin only block with the data in it, as I really want to see by member, who is attending events, as we want to keep stats.  It doesnt matter really where it is when I think about it, I could have a block for just Admin to view showing all members which might work out better, as it would be all in one place rather than having to check profiles :)
Title: Re: Events sign-up on Calendar
Post by: darthi8nt 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>';




  }
}
Title: Re: Events sign-up on Calendar
Post by: confuzed 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?
Title: Re: Events sign-up on Calendar
Post by: JPDeni 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.
Title: Re: Events sign-up on Calendar
Post by: confuzed 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
Title: Re: Events sign-up on Calendar
Post by: JPDeni 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.
Title: Re: Events sign-up on Calendar
Post by: confuzed 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.   :(
Title: Re: Events sign-up on Calendar
Post by: JPDeni 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)) . "'
Title: Re: Events sign-up on Calendar
Post by: confuzed on January 03, 2009, 07:27:20 AM
yay!  that works.  :)
Thanks so much!
Title: Re: Events sign-up on Calendar
Post by: JPDeni 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.
Title: Re: Events sign-up on Calendar
Post by: confuzed on January 03, 2009, 10:10:50 AM
well it worked :) you are a genius :)
Title: Re: Events sign-up on Calendar
Post by: Inny on January 31, 2009, 03:37:22 AM
If you still are looking for an Event sign-up calendar i can suggest you PhpRaider (http://www.phpraider.com/). Its basically designed for World Of Warcraft and Raiding. Code is fully customizable and you can remove most of the World of Warcraft Attributes to make it just a simple Event Sign-up Calendar. It has also SMF-Login if you install the database in your SMF database.

Tho there are few downsides with that, the ability to sign up according to you membergroup wont exist, but if you are having only one membergroup that will sign you can make a new HTML article and make the calendar show up with Iframe. Then disable access to the article for specific membergroups.

If you are using the SMF-Login as soon as someone loads the page he/she gets into the member list, after that in order to sign up for the events you have to create a Character. You can make through that Groups that the characters belong to and disable sign ups for them .

I dont remember any other downside it might have according to your first post due to the fact that phpRaider is designed for a game.

I suggest go with a demo installation and see all the options it offers. I believe with basic html and php you can even make it pull the membergroups from the database. I wont be amazed if there's such a topic for the membergroup pulling over to phpRaider forums aswell.

Im using phpRaider for my event sign ups for the last 2 years and i don't think im changing it soon.

Best Regards,
Inny
Title: Re: Events sign-up on Calendar
Post by: kripz on July 30, 2009, 04:58:16 AM
Watch this space: http://www.simplemachines.org/community/index.php?topic=324260.0
Title: Re: Events sign-up on Calendar
Post by: IchBin™ on July 30, 2009, 09:21:32 AM
Very cool. Thanks for sharing!
Title: Re: Events sign-up on Calendar
Post by: thefley on July 30, 2009, 09:15:21 PM
Watch this space: http://www.simplemachines.org/community/index.php?topic=324260.0

That is just what I need!!!!  thx for posting
Title: Re: Events sign-up on Calendar
Post by: Heero on August 06, 2009, 12:11:42 PM
He posted the beta version upon his first post now.
I hope that also a block comes out of this for signed up. :)
Title: Re: Events sign-up on Calendar
Post by: lillekanin on August 17, 2009, 10:54:48 AM
hey can this plz be updated for this mod:
http://www.simplemachines.org/community/index.php?topic=331107.msg2214457#msg2214457 (http://www.simplemachines.org/community/index.php?topic=331107.msg2214457#msg2214457)
its new and the old one doesn't work for me anymore I would appreciate it !!!