I’m actually new to this forum but was directed this way by a trusted friend. My problem is actually fairly simple but I think after playing with it for so long I have confused and over complicated it in my own eyes so much, now I have no chance of getting it right. It is simply a database call for a script overhaul I am writting. The code makes it pretty obvious I am taking a old php based calendar and trying to import new information into the old template and various other systems.
Original Code:
[php]
if ( $user_can_view_events )
{
//find any events on this day
$start_temp_date = gmmktime(0,0,0,$date[‘month_no’], $j, $date[‘year’]) - $user->timezone - $user->dst;
$end_temp_date = $start_temp_date + 86399;
if( $disp_events_only_on_start == 0 )
{
$sql = 'SELECT * FROM ' . CALENDAR_EVENTS_TABLE . '
WHERE ( (event_access_level = 2) OR
(poster_id = '.$db->sql_escape($user->data['user_id']).' ) OR
(event_access_level = 1 AND ('.$group_options.') ) ) '.$etype_options.' AND
((( event_start_time >= '.$db->sql_escape($start_temp_date).' AND event_start_time <= '.$db->sql_escape($end_temp_date).' ) OR
( event_end_time > '.$db->sql_escape($start_temp_date).' AND event_end_time <= '.$db->sql_escape($end_temp_date).' ) OR
( event_start_time < '.$db->sql_escape($start_temp_date).' AND event_end_time > '.$db->sql_escape($end_temp_date)." )) OR
((event_all_day = 1) AND (event_day LIKE '" . $db->sql_escape(sprintf('%2d-%2d-%4d', $j, $date['month_no'], $date['year'])) . "'))) ORDER BY event_start_time ASC";
}
else
{
$sql = 'SELECT * FROM ' . CALENDAR_EVENTS_TABLE . '
WHERE ( (event_access_level = 2) OR
(poster_id = '.$db->sql_escape($user->data['user_id']).' ) OR
(event_access_level = 1 AND ('.$group_options.') ) ) '.$etype_options.' AND
(( event_start_time >= '.$db->sql_escape($start_temp_date).' AND event_start_time <= '.$db->sql_escape($end_temp_date)." ) OR
((event_all_day = 1) AND (event_day LIKE '" . $db->sql_escape(sprintf('%2d-%2d-%4d', $j, $date['month_no'], $date['year'])) . "'))) ORDER BY event_start_time ASC";
}
$result = $db->sql_query($sql);
}
}
[/php]
What I am trying to do is change the table being called to “phpbb_task_manager” where $db->sql_escape($user->data[‘user_id’]) (which is the current user) is equal to task_user_id or task_assigned_id in the same table. Basically this passing the pertinent information from the database to the template on hand. I am running into problems when switching start dates to task_created, end dates to due_date, and the described above. Just curious if someone could help me with a markup to work with as a structure to my continued development.
[php]
if ( $user_can_view_events )
{
//find any events on this day
$start_temp_date = gmmktime(0,0,0,$date[‘month_no’], $j, $date[‘year’]) - $user->timezone - $user->dst;
$end_temp_date = $start_temp_date + 86399;
if( $disp_events_only_on_start == 0 )
{
$sql = 'SELECT * FROM ' . phpbb_task_manager . '
WHERE ((task_user_id = '.$db->sql_escape($user->data['user_id']).' ) OR (task_assigned_to = '.$db->sql_escape($user->data['user_id']).' ) '.$etype_options.' AND
((( task_time >= '.$db->sql_escape($start_temp_date).' AND task_time <= '.$db->sql_escape($end_temp_date).' ) OR
( task_time > '.$db->sql_escape($start_temp_date).' AND task_time <= '.$db->sql_escape($end_temp_date).' ) OR
( task_time < '.$db->sql_escape($start_temp_date).' AND task_time > '.$db->sql_escape($end_temp_date)." )) OR
((task_time LIKE '" . $db->sql_escape(sprintf('%2d-%2d-%4d', $j, $date['month_no'], $date['year'])) . "'))) ORDER BY task_time ASC";
}
else
{
$sql = 'SELECT * FROM ' . phpbb_task_manager . '
WHERE ( (task_user_id = '.$db->sql_escape($user->data['user_id']).' ) OR (task_assigned_to = '.$db->sql_escape($user->data['user_id']).' )
) '.$etype_options.' AND
(( task_time >= '.$db->sql_escape($start_temp_date).' AND task_time <= '.$db->sql_escape($end_temp_date)." ) OR
((event_day LIKE '" . $db->sql_escape(sprintf('%2d-%2d-%4d', $j, $date['month_no'], $date['year'])) . "'))) ORDER BY task_time ASC";
}
$result = $db->sql_query($sql);
}
}
[/php]