Advertisement:

Author Topic: Event Registration Mod  (Read 157823 times)

Offline ExSpirit

  • Jr. Member
  • **
  • Posts: 190
Re: Event Registration Mod
« Reply #20 on: August 17, 2009, 07:40:46 PM »
  • And another thing is - maybe it would be OK to have options to enable/disable "Confirm"... Or maybe if member registers at event and already have option to Confirm - it's auto confirmed already, since it's pointless to press two buttons just to apply.
No its not pointless, you may have a month of registrations and 1 week before the event allow them to confirm. This will give more accurate numbers rather than going alone on registrations. Some people may forget, have things come up etc etc.
I ment if I set event 1 week before start and I select "Days before allowing confirmation" 7 or if member Registeres when "allowing confirmation" is already active then he has to click "Register" and again "Confirm"... Would be good if "allowing confirmation" would be already active user who registers is automatically "Confirmed".

  • Another great feature would be that admin/event started would be able to remove some people from event (this is kind of must be, since some people are unwanted).
Quote
I probably will not do this until i figure out how to use permissions.
Well if you won't be able to figure out how to set permission for event starter you can always use "if ($user_info['is_admin'])" so that at least admin may remove users from list or admin and mods "if (($user_info['is_admin']) || ($user_info['is_mod']))"
« Last Edit: August 17, 2009, 07:46:19 PM by ExSpirit »

Offline 4b11l

  • Jr. Member
  • **
  • Posts: 355
Re: Event Registration Mod
« Reply #21 on: August 18, 2009, 03:48:59 AM »
Slight problem.

The way SMF links the posts to the events, it's a two step process. So, it starts with the EVENT. (pic 1)
Then, when you click on POST, it'll take you to another screen where you can input the message context/subject, etc.. (pic2)

It doesn't seem like it's saving/storing what is inputted into the first step. Your modification shows 50, 7, 4, 0 and it'll always change back to this no matter what you put in the first step. The second step will always show those numbers. Is this something you can fix or is it SMF so that if it was changed in the first step, it'll be saved and applied on step 2. (i.e. 100, 5, 3, 1)

Side note, just pointing it out that the #'s doesn't seem to affect/show up on the first step. Not a big deal to me, but might be for others. I'd like the issue above addressed first if possible. 

Is anyone else having this problem too, or is it just me?

Thanks!
« Last Edit: August 18, 2009, 03:56:49 AM by 4b11l »

Offline RustyBarnacle

  • Sr. Member
  • ****
  • Posts: 722
    • Saving Tallingroth
Re: Event Registration Mod
« Reply #22 on: August 18, 2009, 12:29:57 PM »
I've never had that problem but I just click a calendar date and it takes me straight to step 2.

Offline Rafferty

  • Jr. Member
  • **
  • Posts: 318
  • Gender: Male
    • 16 Air Defence Regiment Members
Re: Event Registration Mod
« Reply #23 on: August 18, 2009, 09:04:43 PM »
I think it may be important to attempt to make the confirmation dates more flexible. For most events, confirming 7 days before just isnt long enough. Now if it were a selectable choice of say 7, 14 & 30 days, or the facility to put in your own, the mod would be much more useful other than for the more minor events.

It's a great mod and works very well, Well done & I look forward to the improvements.
Don't Follow me I got No Idea what I'm Doing

Offline kripz

  • Semi-Newbie
  • *
  • Posts: 63
Re: Event Registration Mod
« Reply #24 on: August 18, 2009, 10:50:37 PM »
I think it may be important to attempt to make the confirmation dates more flexible. For most events, confirming 7 days before just isnt long enough. Now if it were a selectable choice of say 7, 14 & 30 days, or the facility to put in your own, the mod would be much more useful other than for the more minor events.

It's a great mod and works very well, Well done & I look forward to the improvements.


Quote
0.16 BETA: Added login/register text for guest view.
           Added option to customize the number of days before closing event registrations, event sorting and event confirmations.
           Added administrative options to each event allowing admins to PM registrants, confirmed attendants or unconfirmed

Currently working on a Terms and Conditions page before registering. Next thing is permissions.

Offline Rafferty

  • Jr. Member
  • **
  • Posts: 318
  • Gender: Male
    • 16 Air Defence Regiment Members
Re: Event Registration Mod
« Reply #25 on: August 18, 2009, 11:21:02 PM »
xlant work
Don't Follow me I got No Idea what I'm Doing

Offline gameballa

  • Jr. Member
  • **
  • Posts: 108
    • GamerComp.com
Re: Event Registration Mod
« Reply #26 on: August 19, 2009, 06:03:51 AM »
can you make this work for polls and normal topics?? not just events..

I got what i wanted.. i wanted to have a way of posting events while in my fourms not just in the calender so I went to MessageIndex.template.php and edited this code


Code: [Select]

// Create the button set...
    $normal_buttons = array(
       
       
        'new_topic' => array('test' => 'can_post_new', 'text' => 'smf258', 'image' => 'new_topic.gif', 'lang' => true, 'url' => $scripturl . '?action=calendar;sa=post;board=' . $context['current_board'] . '.0'),

Online Videogame Competitions = Play 4 Free or 4 Cash @ GamerComp.com


"The only way you will ever have peace is if you no longer believe the lie is true"

Offline ricardo35

  • Semi-Newbie
  • *
  • Posts: 73
Re: Event Registration Mod
« Reply #27 on: August 19, 2009, 06:59:24 AM »
Unknown column 'cal.maxAttendants' in 'field list'
File: /home2/hyperio1/public_html/Sources/Calendar.php
Line: 350

Any support is appreciated, thanks :)

Code: [Select]
<?php
/**********************************************************************************
* Calendar.php                                                                    *
***********************************************************************************
* SMF: Simple Machines Forum                                                      *
* Open-Source Project Inspired by Zef Hemel (zef@zefhemel.com)                    *
* =============================================================================== *
* Software Version:           SMF 1.1.5                                           *
* Software by:                Simple Machines (http://www.simplemachines.org)     *
* Copyright 2006 by:          Simple Machines LLC (http://www.simplemachines.org) *
*           2001-2006 by:     Lewis Media (http://www.lewismedia.com)             *
* Support, News, Updates at:  http://www.simplemachines.org                       *
***********************************************************************************
* This program is free software; you may redistribute it and/or modify it under   *
* the terms of the provided license as published by Simple Machines LLC.          *
*                                                                                 *
* This program is distributed in the hope that it is and will be useful, but      *
* WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY    *
* or FITNESS FOR A PARTICULAR PURPOSE.                                            *
*                                                                                 *
* See the "license.txt" file for details of the Simple Machines license.          *
* The latest version can always be found at http://www.simplemachines.org.        *
***********************************************************************************
* Original module by Aaron O'Neil - aaron@mud-master.com                          *
***********************************************************************************/
if (!defined('SMF'))
    die(
'Hacking attempt...');

/*    This file has only one real task... showing the calendar.  Posting is done
    in Post.php - this just has the following functions:

    void CalendarMain()
        - loads the specified month's events, holidays, and birthdays.
        - requires the calendar_view permission.
        - depends on the cal_enabled setting, and many of the other cal_
          settings.
        - uses the calendar_start_day theme option. (Monday/Sunday)
        - uses the main sub template in the Calendar template.
        - goes to the month and year passed in 'month' and 'year' by
          get or post.
        - accessed through ?action=calendar.

    array calendarBirthdayArray(string earliest_date, string latest_date)
        - finds all the birthdays in the specified range of days.
        - earliest_date and latest_date are inclusive, and should both be in
          the YYYY-MM-DD format.
        - works with birthdays set for no year, or any other year, and
          respects month and year boundaries.
        - returns an array of days, each of which an array of birthday
          information for the context.

    array calendarEventArray(string earliest_date, string latest_date,
            bool use_permissions = true)
        - finds all the posted calendar events within a date range.
        - both the earliest_date and latest_date should be in the standard
          YYYY-MM-DD format.
        - censors the posted event titles.
        - uses the current user's permissions if use_permissions is true,
          otherwise it does nothing "permission specific".
        - returns an array of contextual information if use_permissions is
          true, and an array of the data needed to build that otherwise.

    array calendarHolidayArray(string earliest_date, string latest_date)
        - finds all the applicable holidays for the specified date range.
        - earliest_date and latest_date should be YYYY-MM-DD.
        - returns an array of days, which are all arrays of holiday names.

    void calendarInsertEvent(int id_board, int id_topic, string title,
            int id_member, int month, int day, int year, int span)
        - inserts the passed event information into the calendar table.
        - recaches the calendar information after doing so.
        - expects the passed title not to have html characters.
        - handles spanned events by inserting them multiple times.
        - does not check any permissions of any sort.

    bool calendarCanLink()
        - checks if the current user can link the current topic to the
          calendar, permissions et al.
        - this requires the calendar_post permission, a forum moderator, or a
          topic starter.
        - expects the $topic and $board variables to be set.
        - returns true or false corresponding to whether they can or cannot
          link this topic to the calendar.

    void CalendarPost()
        - processes posting/editing/deleting a calendar event.
        - calls Post() function if event is linked to a post.
        - calls calendarInsertEvent() to insert the event if not linked to post.
        - requires the calendar_post permission to use.
        - uses the event_post sub template in the Calendar template.
        - is accessed with ?action=calendar;sa=post.
*/

// Show the calendar.
function CalendarMain()
{
    global 
$txt$context$modSettings$scripturl$options;

    
// If we are posting a new event defect to the posting function.
    
if (isset($_GET['sa']) && $_GET['sa'] == 'post')
        return 
CalendarPost();

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

    
// Permissions, permissions, permissions.
    
isAllowedTo('calendar_view');

    
// You can't do anything if the calendar is off.
    
if (empty($modSettings['cal_enabled']))
        
fatal_lang_error('calendar_off'false);

    
// Set the page title to mention the calendar ;).
    
$context['page_title'] = $context['forum_name'] . ': ' $txt['calendar24'];

    
// Get the current day of month...
    
$today = array(
        
'day' => (int) strftime('%d'forum_time()),
        
'month' => (int) strftime('%m'forum_time()),
        
'year' => (int) strftime('%Y'forum_time()),
    );
    
$today['date'] = sprintf('%04d-%02d-%02d'$today['year'], $today['month'], $today['day']);

    
// If the month and year are not passed in, use today's date as a starting point.
    
$curPage = array(
        
'month' => isset($_REQUEST['month']) ? (int) $_REQUEST['month'] : $today['month'],
        
'year' => isset($_REQUEST['year']) ? (int) $_REQUEST['year'] : $today['year']
    );

    
// Make sure the year and month are in valid ranges.
    
if ($curPage['month'] < || $curPage['month'] > 12)
        
fatal_lang_error('calendar1'false);
    if (
$curPage['year'] < $modSettings['cal_minyear'] || $curPage['year'] > $modSettings['cal_maxyear'])
        
fatal_lang_error('calendar2'false);

    
// Get information about the first day of this month.
    
$firstDayOfMonth = array(
        
'dayOfWeek' => (int) strftime('%w'mktime(000$curPage['month'], 1$curPage['year'])),
        
'weekNum' => (int) strftime('%U'mktime(000$curPage['month'], 1$curPage['year']))
    );

    
// Find the last day of the month.
    
$nLastDay = (int) strftime('%d'mktime(000$curPage['month'] == 12 $curPage['month'] + 10$curPage['month'] == 12 $curPage['year'] + $curPage['year']));

    
// The number of days the first row is shifted to the right for the starting day.
    
$nShift $firstDayOfMonth['dayOfWeek'];

    
// Calendar start day- default Sunday.
    
$nStartDay = !empty($options['calendar_start_day']) ? $options['calendar_start_day'] : 0;

    
// Starting any day other than Sunday means a shift...
    
if ($nStartDay)
    {
        
$nShift -= $nStartDay;
        if (
$nShift 0)
            
$nShift $nShift;
    }

    
// Number of rows required to fit the month.
    
$nRows floor(($nLastDay $nShift) / 7);
    if ((
$nLastDay $nShift) % 7)
        
$nRows++;

    
// Get the lowest and highest days of this month, in YYYY-MM-DD format. ($nLastDay is always 2 digits.)
    
$low $curPage['year'] . '-' sprintf('%02d'$curPage['month']) . '-01';
    
$high $curPage['year'] . '-' sprintf('%02d'$curPage['month']) . '-' $nLastDay;

    
// Fetch the arrays for birthdays, posted events, and holidays.
    
$bday = !empty($modSettings['cal_showbdaysoncalendar']) ? calendarBirthdayArray($low$high) : array();
    
$events = !empty($modSettings['cal_showeventsoncalendar']) ? calendarEventArray($low$high) : array();
    
$holidays = !empty($modSettings['cal_showholidaysoncalendar']) ? calendarHolidayArray($low$high) : array();

    
// Days of the week taking into consideration that they may want it to start on any day.
    
$context['week_days'] = array();
    
$count $nStartDay;
    for (
$i 0$i 7$i++)
    {
        
$context['week_days'][] = $count;
        
$count++;
        if (
$count == 7)
            
$count 0;
    }

    
// An adjustment value to apply to all calculated week numbers.
    
if (!empty($modSettings['cal_showweeknum']))
    {
        
// Need to know what day the first of the year was on.
        
$foy = (int) strftime('%w'mktime(00011$curPage['year']));

        
// If the first day of the year is a Sunday, then there is no adjustment
        // to be made. However, if the first day of the year is not a Sunday, then there is a partial
        // week at the start of the year that needs to be accounted for.
        
if ($nStartDay == 0)
            
$nWeekAdjust $foy == 1;
        
// If we are viewing the weeks, with a starting date other than Sunday, then things get complicated!
        // Basically, as PHP is calculating the weeks with a Sunday starting date, we need to take this into account
        // and offset the whole year dependant on whether the first day in the year is above or below our starting date.
        // Note that we offset by two, as some of this will get undone quite quickly by the statement below.
        
else
            
$nWeekAdjust $nStartDay $foy && $foy != 1;

        
// If our week starts on a day greater than the day the month starts on, then our week numbers will be one too high.
        // So we need to reduce it by one - all these thoughts of offsets makes my head hurt...
        
if ($firstDayOfMonth['dayOfWeek'] < $nStartDay)
            
$nWeekAdjust--;
    }
    else
        
$nWeekAdjust 0;

    
// Basic template stuff.
    
$context['can_post'] = allowedTo('calendar_post');
    
$context['last_day'] = $nLastDay;
    
$context['current_month'] = $curPage['month'];
    
$context['current_year'] = $curPage['year'];

    
// Load up the linktree!
    
$context['linktree'][] = array(
        
'url' => $scripturl '?action=calendar;year=' $context['current_year'] . ';month=' $context['current_month'],
        
'name' => $txt['months'][$context['current_month']] . ' ' $context['current_year']
    );

    
// Iterate through each week.
    
$context['weeks'] = array();
    for (
$nRow 0$nRow $nRows$nRow++)
    {
        
// Start off the week - and don't let it go above 52, since that's the number of weeks in a year.
        
$context['weeks'][$nRow] = array(
            
'days' => array(),
            
'number' => $firstDayOfMonth['weekNum'] + $nRow $nWeekAdjust
        
);
        
// Handle the dreaded "week 53", it can happen, but only once in a blue moon ;)
        
if ($context['weeks'][$nRow]['number'] == 53 && $nShift != 4)
            
$context['weeks'][$nRow]['number'] = 1;

        
// And figure out all the days.
        
for ($nCol 0$nCol 7$nCol++)
        {
            
$nDay = ($nRow 7) + $nCol $nShift 1;

            if (
$nDay || $nDay $context['last_day'])
                
$nDay 0;

            
$date sprintf('%04d-%02d-%02d'$curPage['year'], $curPage['month'], $nDay);

            
$context['weeks'][$nRow]['days'][$nCol] = array(
                
'day' => $nDay,
                
'date' => $date,
                
'is_today' => $date == $today['date'],
                
'is_first_day' => !empty($modSettings['cal_showweeknum']) && (($firstDayOfMonth['dayOfWeek'] + $nDay 1) % == $nStartDay),
                
'holidays' => !empty($holidays[$date]) ? $holidays[$date] : array(),
                
'events' => !empty($events[$date]) ? $events[$date] : array(),
                
'birthdays' => !empty($bday[$date]) ? $bday[$date] : array()
            );
        }
    }

    
// Find the previous month. (if we can go back that far.)
    
if ($curPage['month'] > || ($curPage['month'] == && $curPage['year'] > $modSettings['cal_minyear']))
    {
        
// Need to roll the year back one?
        
$context['previous_calendar'] = array(
            
'year' => $curPage['month'] == $curPage['year'] - $curPage['year'],
            
'month' => $curPage['month'] == 12 $curPage['month'] - 1,
        );
        
$context['previous_calendar']['href'] = $scripturl '?action=calendar;year=' $context['previous_calendar']['year'] . ';month=' $context['previous_calendar']['month'];
    }

    
// The next month... (or can we go that far?)
    
if ($curPage['month'] < 12 || ($curPage['month'] == 12 && $curPage['year'] < $modSettings['cal_maxyear']))
    {
        
$context['next_calendar'] = array(
            
'year' => $curPage['month'] == 12 $curPage['year'] + $curPage['year'],
            
'month' => $curPage['month'] == 12 $curPage['month'] + 1
        
);
        
$context['next_calendar']['href'] = $scripturl '?action=calendar;year=' $context['next_calendar']['year'] . ';month=' $context['next_calendar']['month'];
    }
}

// This is used by the board index to only find members of the current day. (month PLUS one!)
function calendarBirthdayArray($low_date$high_date)
{
    global 
$db_prefix$scripturl$modSettings;

    
// Birthdays people set without specifying a year (no age, see?) are the easiest ;).
    
if (substr($low_date04) != substr($high_date04))
        
$allyear_part "birthdate BETWEEN '0004" substr($low_date4) . "' AND '0004-12-31'
            OR birthdate BETWEEN '0004-01-01' AND '0004" 
substr($high_date4) . "'";
    else
        
$allyear_part "birthdate BETWEEN '0004" substr($low_date4) . "' AND '0004" substr($high_date4) . "'";

    
// We need to search for any birthday in this range, and whatever year that birthday is on.
    
$year_low = (int) substr($low_date04);
    
$year_high = (int) substr($high_date04);

    
// Collect all of the birthdays for this month.  I know, it's a painful query.
    
$result db_query("
        SELECT ID_MEMBER, realName, YEAR(birthdate) AS birthYear, birthdate
        FROM 
{$db_prefix}members
        WHERE YEAR(birthdate) != '0001'
            AND    (
$allyear_part
                OR DATE_FORMAT(birthdate, '
{$year_low}-%m-%d') BETWEEN '$low_date' AND '$high_date'" . ($year_low == $year_high '' "
                OR DATE_FORMAT(birthdate, '
{$year_high}-%m-%d') BETWEEN '$low_date' AND '$high_date'") . ")
            AND is_activated = 1"
__FILE____LINE__);
    
$bday = array();
    while (
$row mysql_fetch_assoc($result))
    {
        if (
$year_low != $year_high)
            
$age_year substr($row['birthdate'], 5) < substr($high_date5) ? $year_high $year_low;
        else
            
$age_year $year_low;

        
$bday[$age_year substr($row['birthdate'], 4)][] = array(
            
'id' => $row['ID_MEMBER'],
            
'name' => $row['realName'],
            
'age' => $row['birthYear'] > && $row['birthYear'] <= $age_year $age_year $row['birthYear'] : null,
            
'is_last' => false
        
);
    }
    
mysql_free_result($result);

    
// Set is_last, so the themes know when to stop placing separators.
    
foreach ($bday as $mday => $array)
        
$bday[$mday][count($array) - 1]['is_last'] = true;

    return 
$bday;
}

// Create an array of events occurring in this day/month.
function calendarEventArray($low_date$high_date$use_permissions true)
{
    global 
$db_prefix$ID_MEMBER$scripturl$modSettings$user_info$sc;

    
$low_date_time sscanf($low_date'%04d-%02d-%02d');
    
$low_date_time mktime(000$low_date_time[1], $low_date_time[2], $low_date_time[0]);
    
$high_date_time sscanf($high_date'%04d-%02d-%02d');
    
$high_date_time mktime(000$high_date_time[1], $high_date_time[2], $high_date_time[0]);

    
// Find all the calendar info...
    
$result db_query("
        SELECT
            cal.ID_EVENT, cal.startDate, cal.endDate, cal.title, cal.ID_MEMBER, cal.ID_TOPIC,
            cal.ID_BOARD, b.memberGroups, t.ID_FIRST_MSG
            , cal.maxAttendants, cal.daysSort, cal.daysConfirm, cal.daysClosed

        FROM 
{$db_prefix}calendar AS cal
            LEFT JOIN 
{$db_prefix}boards AS b ON (b.ID_BOARD = cal.ID_BOARD)
            LEFT JOIN 
{$db_prefix}topics AS t ON (t.ID_TOPIC = cal.ID_TOPIC)
        WHERE cal.startDate <= '
$high_date'
                AND cal.endDate >= '
$low_date'" . ($use_permissions "
            AND (cal.ID_BOARD = 0 OR 
$user_info[query_see_board])" ''), __FILE____LINE__);
    
$events = array();
    while (
$row mysql_fetch_assoc($result))
    {
        
// Censor the title.
        
censorText($row['title']);

        
$startDate sscanf($row['startDate'], '%04d-%02d-%02d');
        
$startDate max(mktime(000$startDate[1], $startDate[2], $startDate[0]), $low_date_time);
        
$endDate sscanf($row['endDate'], '%04d-%02d-%02d');
        
$endDate min(mktime(000$endDate[1], $endDate[2], $endDate[0]), $high_date_time);

        
$lastDate '';
        for (
$date $startDate$date <= $endDate$date += 86400)
        {
            
// Attempt to avoid DST problems.
            //!!! Resolve this properly at some point.
            
if (strftime('%Y-%m-%d'$date) == $lastDate)
                
$date += 3601;
            
$lastDate strftime('%Y-%m-%d'$date);

            
// If we're using permissions (calendar pages?) then just ouput normal contextual style information.
            
if ($use_permissions)
                
$events[strftime('%Y-%m-%d'$date)][] = array(
                    
'id' => $row['ID_EVENT'],
                    
'title' => $row['title'],
                    
'can_edit' => allowedTo('calendar_edit_any') || ($row['ID_MEMBER'] == $ID_MEMBER && allowedTo('calendar_edit_own')),
                    
'modify_href' => $scripturl '?action=' . ($row['ID_BOARD'] == 'calendar;sa=post;' 'post;msg=' $row['ID_FIRST_MSG'] . ';topic=' $row['ID_TOPIC'] . '.0;calendar;') . 'eventid=' $row['ID_EVENT'] . ';sesc=' $sc,
                    
'href' => $row['ID_BOARD'] == '' $scripturl '?topic=' $row['ID_TOPIC'] . '.0',
                    
'link' => $row['ID_BOARD'] == $row['title'] : '<a href="' $scripturl '?topic=' $row['ID_TOPIC'] . '.0">' $row['title'] . '</a>',
                    
'start_date' => $row['startDate'],
                    
'end_date' => $row['endDate'],
                    
'maxAttendants' => $row['maxAttendants'],
                    
'daysSort' => $row['daysSort'],
                    
'daysConfirm' => $row['daysConfirm'],
                    
'daysClosed' => $row['daysClosed'],

                    
'is_last' => false
                
);
            
// Otherwise, this is going to be cached and the VIEWER'S permissions should apply... just put together some info.
            
else
                
$events[strftime('%Y-%m-%d'$date)][] = array(
                    
'id' => $row['ID_EVENT'],
                    
'title' => $row['title'],
                    
'topic' => $row['ID_TOPIC'],
                    
'msg' => $row['ID_FIRST_MSG'],
                    
'poster' => $row['ID_MEMBER'],
                    
'start_date' => $row['startDate'],
                    
'end_date' => $row['endDate'],
                    
'maxAttendants' => $row['maxAttendants'],
                    
'daysSort' => $row['daysSort'],
                    
'daysConfirm' => $row['daysConfirm'],
                    
'daysClosed' => $row['daysClosed'],

                    
'is_last' => false,
                    
'allowed_groups' => explode(','$row['memberGroups']),
                    
'maxAttendants' => $row['maxAttendants'],
                    
'daysSort' => $row['daysSort'],
                    
'daysConfirm' => $row['daysConfirm'],
                    
'daysClosed' => $row['daysClosed'],

                );
        }
    }
    
mysql_free_result($result);

    
// If we're doing normal contextual data, go through and make things clear to the templates ;).
    
if ($use_permissions)
    {
        foreach (
$events as $mday => $array)
            
$events[$mday][count($array) - 1]['is_last'] = true;
    }

    return 
$events;
}

// Builds an array of holiday strings for a particular month.  Note... month PLUS 1 not just month.
function calendarHolidayArray($low_date$high_date)
{
    global 
$db_prefix;

    
// Get the lowest and highest dates for "all years".
    
if (substr($low_date04) != substr($high_date04))
        
$allyear_part "eventDate BETWEEN '0004" substr($low_date4) . "' AND '0004-12-31'
            OR eventDate BETWEEN '0004-01-01' AND '0004" 
substr($high_date4) . "'";
    else
        
$allyear_part "eventDate BETWEEN '0004" substr($low_date4) . "' AND '0004" substr($high_date4) . "'";

    
// Find some holidays... ;).
    
$result db_query("
        SELECT eventDate, YEAR(eventDate) AS year, title
        FROM 
{$db_prefix}calendar_holidays
        WHERE eventDate BETWEEN '
$low_date' AND '$high_date'
            OR 
$allyear_part"__FILE____LINE__);
    
$holidays = array();
    while (
$row mysql_fetch_assoc($result))
    {
        if (
substr($low_date04) != substr($high_date04))
            
$event_year substr($row['eventDate'], 5) < substr($high_date5) ? substr($high_date04) : substr($low_date04);
        else
            
$event_year substr($low_date04);

        
$holidays[$event_year substr($row['eventDate'], 4)][] = $row['title'];
    }
    
mysql_free_result($result);

    return 
$holidays;
}

// Consolidating the various INSERT statements into this function.
function calendarInsertEvent($id_board$id_topic$title$id_member$month$day$year$span$maxAttendants$daysSort$daysConfirm$daysClosed)

{
    global 
$db_prefix$modSettings$func;

    
// Add special chars to the title.
    
$title $func['htmlspecialchars']($titleENT_QUOTES);

    
// Add some sanity checking to the span.
    
$span = empty($span) || trim($span) == '' min((int) $modSettings['cal_maxspan'], (int) $span 1);

    
// Insert the event!
    
db_query("
        INSERT INTO 
{$db_prefix}calendar
            (ID_BOARD, ID_TOPIC, title, ID_MEMBER, startDate, endDate,
            maxAttendants, daysSort, daysConfirm, daysClosed)
        VALUES (
$id_board$id_topic, SUBSTRING('$title', 1, 48), $id_member, '" strftime('%Y-%m-%d'mktime(000$month$day$year)) . "', '" strftime('%Y-%m-%d'mktime(000$month$day$year) + $span 86400) . "', $maxAttendants$daysSort$daysConfirm$daysClosed)"__FILE____LINE__);

    
updateStats('calendar');
}

// Returns true if this user is allowed to link the topic in question.
function calendarCanLink()
{
    global 
$ID_MEMBER$db_prefix$user_info$topic$board;

    
// If you can't post, you can't link.
    
isAllowedTo('calendar_post');

    
// No board?  No topic?!?
    
if (empty($board))
        
fatal_lang_error('calendar38'false);
    if (empty(
$topic))
        
fatal_lang_error('calendar39'false);

    
// Administrator, Moderator, or owner.  Period.
    
if (!allowedTo('admin_forum') && !allowedTo('moderate_board'))
    {
        
// Not admin or a moderator of this board. You better be the owner - or else.
        
$result db_query("
            SELECT ID_MEMBER_STARTED
            FROM 
{$db_prefix}topics
            WHERE ID_TOPIC = 
$topic
            LIMIT 1"
__FILE____LINE__);
        if (
$row mysql_fetch_assoc($result))
        {
            
// Not the owner of the topic.
            
if ($row['ID_MEMBER_STARTED'] != $ID_MEMBER)
                
fatal_lang_error('calendar41');
        }
        
// Topic/Board doesn't exist.....
        
else
            
fatal_lang_error('calendar40');
        
mysql_free_result($result);
    }

    
// If you got this far, it's okay.
    
return true;
}

function 
CalendarPost()
{
    global 
$context$txt$db_prefix$user_info$sourcedir$scripturl;
    global 
$modSettings$topic$ID_MEMBER$func;

    
// Well - can they?
    
isAllowedTo('calendar_post');

    
// Cast this for safety...    if (isset($_REQUEST['maxAttendants']))
        
$_REQUEST['maxAttendants'] = (int) $_REQUEST['maxAttendants'];
       
    if (isset(
$_POST['maxAttendants']))
        
$_POST['maxAttendants'] = (int) $_POST['maxAttendants'];
       
    if (isset(
$_POST['daysConfirm']))
        
$_POST['daysConfirm'] = (int) $_POST['daysConfirm'];
       
    if (isset(
$_POST['daysSort']))
        
$_POST['daysSort'] = (int) $_POST['daysSort'];
       
    if (isset(
$_POST['daysClosed']))
        
$_POST['daysClosed'] = (int) $_POST['daysClosed'];


    if (isset(
$_REQUEST['eventid']))
        
$_REQUEST['eventid'] = (int) $_REQUEST['eventid'];

    
// Submitting?
    
if (isset($_POST['sc'], $_REQUEST['eventid']))
    {
        
checkSession();

        
// Validate the post...
        
if (!isset($_POST['link_to_board']))
        {
            require_once(
$sourcedir '/Subs-Post.php');
            
calendarValidatePost();
        }

        
// If you're not allowed to edit any events, you have to be the poster.
        
if ($_REQUEST['eventid'] > && !allowedTo('calendar_edit_any'))
        {
            
// Get the event's poster.
            
$request db_query("
                SELECT ID_MEMBER
                FROM 
{$db_prefix}calendar
                WHERE ID_EVENT = 
$_REQUEST[eventid]
                LIMIT 1"
__FILE____LINE__);
            list (
$poster) = mysql_fetch_row($request);
            
mysql_free_result($request);

            
// Finally, test if they can either edit ANY, or just their own...
            
if (!allowedTo('calendar_edit_any'))
                
isAllowedTo('calendar_edit_' . ($poster == $ID_MEMBER 'own' 'any'));
        }

        
// New - and directing?
        
if ($_REQUEST['eventid'] == -&& isset($_POST['link_to_board']))
        {
            
$_REQUEST['calendar'] = 1;
            require_once(
$sourcedir '/Post.php');
            return 
Post();
        }
        
// New...
        
elseif ($_REQUEST['eventid'] == -1)
            
calendarInsertEvent(00$_POST['evtitle'], $ID_MEMBER$_POST['month'], $_POST['day'], $_POST['year'], isset($_POST['span']) ? $_POST['span'] : null$_POST['maxAttendants'], $_POST['daysSort'], $_POST['daysConfirm'], $_POST['daysClosed']);

        
// Deleting...
        
elseif (isset($_REQUEST['deleteevent']))
            
db_query("
                DELETE FROM 
{$db_prefix}calendar
                WHERE ID_EVENT = 
$_REQUEST[eventid]
                LIMIT 1"
__FILE____LINE__);
        
// ... or just update it?
        
else
        {
            
// Calculate the eventDate depending on span.
            
$span = empty($modSettings['cal_allowspan']) || empty($_POST['span']) || $_POST['span'] == || empty($modSettings['cal_maxspan']) || $_POST['span'] > $modSettings['cal_maxspan'] ? min((int) $modSettings['cal_maxspan'], (int) $_POST['span'] - 1);
            
$start_time mktime(000, (int) $_REQUEST['month'], (int) $_REQUEST['day'], (int) $_REQUEST['year']);

            
db_query("
                UPDATE 
{$db_prefix}calendar
                SET
                    startDate = '" 
strftime('%Y-%m-%d'$start_time) . "',
                    endDate = '" 
strftime('%Y-%m-%d'$start_time $span 86400) . "',                    title = '" $func['htmlspecialchars']($_REQUEST['evtitle'], ENT_QUOTES) . "'
            , maxAttendants = '
$_REQUEST[maxAttendants]'
            , daysSort = '
$_REQUEST[daysSort]'
            , daysConfirm = '
$_REQUEST[daysConfirm]'
            , daysClosed = '
$_REQUEST[daysClosed]'

                WHERE ID_EVENT = 
$_REQUEST[eventid]
                LIMIT 1"
__FILE____LINE__);
        }

        
updateStats('calendar');

        
// No point hanging around here now...
        
redirectexit($scripturl '?action=calendar;month=' $_POST['month'] . ';year=' $_POST['year']);
    }

    
// If we are not enabled... we are not enabled.
    
if (empty($modSettings['cal_allow_unlinked']) && empty($_REQUEST['eventid']))
    {
        
$_REQUEST['calendar'] = 1;
        require_once(
$sourcedir '/Post.php');
        return 
Post();
    }

    
// New?
    
if (!isset($_REQUEST['eventid']))
    {
        
$today getdate();

        
$context['event'] = array(
            
'boards' => array(),
            
'board' => !empty($modSettings['cal_defaultboard']) ? $modSettings['cal_defaultboard'] : 0,
            
'new' => 1,
            
'eventid' => -1,
            
'year' => isset($_REQUEST['year']) ? $_REQUEST['year'] : $today['year'],
            
'month' => isset($_REQUEST['month']) ? $_REQUEST['month'] : $today['mon'],
            
'day' => isset($_REQUEST['day']) ? $_REQUEST['day'] : $today['mday'],
            
'title' => '',
            
'span' => 1,
            
'maxAttendants' => $_REQUEST['maxAttendants'],
            
'daysSort' => $_REQUEST['daysSort'],
            
'daysConfirm' => $_REQUEST['daysConfirm'],
            
'daysClosed' => $_REQUEST['daysClosed'],

        );

        
// Get list of boards that can be posted in.
        
$boards boardsAllowedTo('post_new');
        if (empty(
$boards))
            
fatal_lang_error('cannot_post_new');

        
$request db_query("
            SELECT c.name AS catName, c.ID_CAT, b.ID_BOARD, b.name AS boardName, b.childLevel
            FROM 
{$db_prefix}boards AS b
                LEFT JOIN 
{$db_prefix}categories AS c ON (c.ID_CAT = b.ID_CAT)
            WHERE 
$user_info[query_see_board]. (in_array(0$boards) ? '' "
                AND b.ID_BOARD IN (" 
implode(', '$boards) . ")"), __FILE____LINE__);
        while (
$row mysql_fetch_assoc($request))
            
$context['event']['boards'][] = array(
                
'id' => $row['ID_BOARD'],
                
'name' => $row['boardName'],
                
'childLevel' => $row['childLevel'],
                
'prefix' => str_repeat('&nbsp;'$row['childLevel'] * 3),
                
'cat' => array(
                    
'id' => $row['ID_CAT'],
                    
'name' => $row['catName']
                )
            );
        
mysql_free_result($request);
    }
    else
    {
        
$request db_query("
            SELECT
                c.ID_EVENT, c.ID_BOARD, c.ID_TOPIC, MONTH(c.startDate) AS month,
                DAYOFMONTH(c.startDate) AS day, YEAR(c.startDate) AS year,
                (TO_DAYS(c.endDate) - TO_DAYS(c.startDate)) AS span, c.ID_MEMBER, c.title,
                t.ID_FIRST_MSG, t.ID_MEMBER_STARTED
            , c.maxAttendants, c.daysSort, c.daysConfirm, c.daysClosed

            FROM 
{$db_prefix}calendar AS c
                LEFT JOIN 
{$db_prefix}topics AS t ON (t.ID_TOPIC = c.ID_TOPIC)
            WHERE c.ID_EVENT = 
$_REQUEST[eventid]"__FILE____LINE__);
        
// If nothing returned, we are in poo, poo.
        
if (mysql_num_rows($request) == 0)
            
fatal_lang_error(1);
        
$row mysql_fetch_assoc($request);
        
mysql_free_result($request);

        
// If it has a board, then they should be editing it within the topic.
        
if ($row['ID_TOPIC'] && $row['ID_FIRST_MSG'])
        {
            
// We load the board up, for a check on the board access rights...
            
$topic $row['ID_TOPIC'];
            
loadBoard();
        }

        
// Make sure the user is allowed to edit this event.
        
if ($row['ID_MEMBER'] != $ID_MEMBER)
            
isAllowedTo('calendar_edit_any');
        elseif (!
allowedTo('calendar_edit_any'))
            
isAllowedTo('calendar_edit_own');

        
$context['event'] = array(
            
'boards' => array(),
            
'board' => $row['ID_BOARD'],
            
'new' => 0,
            
'eventid' => $_REQUEST['eventid'],
            
'year' => $row['year'],
            
'month' => $row['month'],
            
'day' => $row['day'],
            
'title' => $row['title'],
            
'span' => $row['span'],
            
'maxAttendants' => $row['maxAttendants'],
            
'daysSort' => $row['daysSort'],
            
'daysConfirm' => $row['daysConfirm'],
            
'daysClosed' => $row['daysClosed'],

        );
    }

    
$context['event']['last_day'] = (int) strftime('%d'mktime(000$context['event']['month'] == 12 $context['event']['month'] + 10$context['event']['month'] == 12 $context['event']['year'] + $context['event']['year']));

    
// Template, sub template, etc.
    
loadTemplate('Calendar');
    
$context['sub_template'] = 'event_post';

    
$context['page_title'] = isset($_REQUEST['eventid']) ? $txt['calendar20'] : $txt['calendar23'];
    
$context['linktree'][] = array(
        
'name' => $context['page_title'],
    );
}

?>

Offline kripz

  • Semi-Newbie
  • *
  • Posts: 63
Re: Event Registration Mod
« Reply #28 on: August 19, 2009, 07:15:06 PM »
can you make this work for polls and normal topics?? not just events..

I got what i wanted.. i wanted to have a way of posting events while in my fourms not just in the calender so I went to MessageIndex.template.php and edited this code


Code: [Select]

// Create the button set...
    $normal_buttons = array(
       
       
        'new_topic' => array('test' => 'can_post_new', 'text' => 'smf258', 'image' => 'new_topic.gif', 'lang' => true, 'url' => $scripturl . '?action=calendar;sa=post;board=' . $context['current_board'] . '.0'),


Havent had a chance to look at it yet, does it just add a button?

Unknown column 'cal.maxAttendants' in 'field list'
File: /home2/hyperio1/public_html/Sources/Calendar.php
Line: 350

Any support is appreciated, thanks :)

Did you have any failures? What version of ERM/SMF? Mods?

Offline gameballa

  • Jr. Member
  • **
  • Posts: 108
    • GamerComp.com
Re: Event Registration Mod
« Reply #29 on: August 20, 2009, 02:05:58 PM »
yes it adds a button and it automaticly gets posted in that spacific board... and I can add a poll afterwards. I didnt really want to go to the calender to post an event so I am happy with that simple fix
Online Videogame Competitions = Play 4 Free or 4 Cash @ GamerComp.com


"The only way you will ever have peace is if you no longer believe the lie is true"

Offline TW1ST3D

  • Jr. Member
  • **
  • Posts: 178
    • The Georgia LX Club
Re: Event Registration Mod
« Reply #30 on: August 20, 2009, 09:20:00 PM »
Something like this for 2.x would be sexy.

Congrats on your mod being approved !!!

Do we have to start begging to get this for 2.0 RC X.X?
Running 2.0 Gold.......SMF Rocks!!

Offline Ryanitto

  • Newbie
  • *
  • Posts: 2
Re: Event Registration Mod
« Reply #31 on: August 21, 2009, 12:28:33 AM »
I really like this mod so far -- suggestion however:

I've been noticing that when you post the event, it closes on the same day. It would be something minor, but fantastic if there was a set TIME (rather than date) it closes. For example, it would detect the time the event is occuring and close "1 hour before," and it could be selected from a drop-down menu possibly with choices of "1 hour, 2 hours, 3 hours, 4 hours, etc." before. I think it cutting off on midnight on the same day as the event is too restricting.

I also saw a comment on a possible reminder PM, or an automated EMAIL, to those who have signed up would be amazing.

Offline RustyBarnacle

  • Sr. Member
  • ****
  • Posts: 722
    • Saving Tallingroth
Re: Event Registration Mod
« Reply #32 on: August 21, 2009, 12:43:01 PM »
Hehe, this is great and I really appreciate your work.

Since someone is already working on a version of this for SMF 2, my request would be the ability to add guests who aren't on the forum.  A +x button since they may bring more than one guest.

Offline thefley

  • Jr. Member
  • **
  • Posts: 173
    • Great Plains Riders
Re: Event Registration Mod
« Reply #33 on: August 21, 2009, 10:50:58 PM »
Great mod!!!   how about a way to enable and dissable when we add something to the calendar, I don't want to use it everytime I add an event to the calendar.

Offline kripz

  • Semi-Newbie
  • *
  • Posts: 63
Re: Event Registration Mod
« Reply #34 on: August 22, 2009, 02:52:59 AM »
I really like this mod so far -- suggestion however:

I've been noticing that when you post the event, it closes on the same day. It would be something minor, but fantastic if there was a set TIME (rather than date) it closes. For example, it would detect the time the event is occuring and close "1 hour before," and it could be selected from a drop-down menu possibly with choices of "1 hour, 2 hours, 3 hours, 4 hours, etc." before. I think it cutting off on midnight on the same day as the event is too restricting.

I also saw a comment on a possible reminder PM, or an automated EMAIL, to those who have signed up would be amazing.

Automated emails are not possible in 1.x. If you have access to schedular/cron then it could be done.
Great mod!!!   how about a way to enable and dissable when we add something to the calendar, I don't want to use it everytime I add an event to the calendar.

Permissions and options are coming. I dont know how to do it yet.

Offline Ryanitto

  • Newbie
  • *
  • Posts: 2
Re: Event Registration Mod
« Reply #35 on: August 22, 2009, 03:21:13 PM »
I really like this mod so far -- suggestion however:

I've been noticing that when you post the event, it closes on the same day. It would be something minor, but fantastic if there was a set TIME (rather than date) it closes. For example, it would detect the time the event is occuring and close "1 hour before," and it could be selected from a drop-down menu possibly with choices of "1 hour, 2 hours, 3 hours, 4 hours, etc." before. I think it cutting off on midnight on the same day as the event is too restricting.

I also saw a comment on a possible reminder PM, or an automated EMAIL, to those who have signed up would be amazing.

Automated emails are not possible in 1.x. If you have access to schedular/cron then it could be done.


Then just ignore that part. :P

Offline Tony Reid

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,154
  • Gender: Male
    • @AbsoluteBreeze on Twitter
    • www.fertilityfriends.co.uk
Re: Event Registration Mod
« Reply #36 on: August 24, 2009, 04:51:18 AM »
This is a very useful mod - however I think the time option is needed - otherwise members can not register for events on the same day.

If for instance, an event is at 20:00 - registration closes @ 00:00 - 20 hours earlier.

Tony Reid


My Big Board
www.FertilityFriends.co.uk/forum - An SMF powered forum with over 5 million posts

Offline clashbot

  • Semi-Newbie
  • *
  • Posts: 54
  • Gender: Male
Re: Event Registration Mod
« Reply #37 on: August 26, 2009, 01:05:56 PM »
hey kripz, got a suggestion request from one of my users.

I run a gaming forum, where we have many alts, is there a way to allow someone to register multiple times with a field for listing alt names?

Also, is there a way of posting a link to a page that displays the terms and conditions so that someone can recheck them after registering for an event without unreg and re-reg (and possibly losing a slot)?

Other than that, great mod and no probs installing or using.

Offline SWR

  • Semi-Newbie
  • *
  • Posts: 21
Re: Event Registration Mod
« Reply #38 on: August 27, 2009, 11:45:21 AM »
Man.......This is the mod I've been waiting for, but something ain't right.  Won't allow registration.  No matter what I do it tells me "Registrations have closed".

I would also like to see members + (#)guests added to this mod.

Thanks for any help.

Offline Largo_npc

  • Semi-Newbie
  • *
  • Posts: 81
Re: Event Registration Mod
« Reply #39 on: August 28, 2009, 04:00:23 AM »
This is exactly what I've been looking for too but I'm using 2.0 rc1.2.
Any plans to support this version?