Ajax Event Calendar Support Product Page

How to show only users events ?

Asked 16 Apr 2010 14:53:49
1
has this question
16 Apr 2010 14:53:49 Alvarez Frédéric posted:
Hi,

i use ajax events calendar to let users store events.I use my own database table including user_id field. When i call event page i can see all events.i would like users can see only his own events.

I already create a recordset to show event by filtering on user_id session but seems it's not take by script.

What's wrong ?


Thanks for help

Replies

Replied 19 Apr 2010 09:33:21
19 Apr 2010 09:33:21 Miroslav Zografski replied:
Hello Alvarez,

That can be done but you need to alter the calendar_get_events#.asp/php file to be filtered by the user id you have set as well as the other filtering.
If this is hard for you to do I can help you on achieving this. My e-mail is

Regards,
Replied 28 Apr 2010 19:01:21
28 Apr 2010 19:01:21 Alvarez Frédéric replied:
OK this is how to for people who needs to filter events shown by user_id.

It's suppose you have a listing page and you paste parameter in url to ajax_calendar_event page.

First you need to customize your page where ajax calendar is setup.
Find "ajax_feeds:[{url:"calendar_ajax/calendar_get_events1.php " and replace by
Example for "user_id" Url become: "calendar_ajax/calendar_get_events1.php?user_id=<?php echo $_GET['user_id']?>


Now you need to customize calendar_get_events.php
1. Before "$query_start = intval($_GET['start']);"
add your filter like this:
$query_filter = intval($_GET['user_id']);

2. Add filter in query_events:
after WHERE add "`filter` = %3$s" and at the end before last "" add ",$query_filter".
=>you must change 'filter' by your database field you want to compare parameter.

Test it, must show only user event.

Thanks to Miro

Replied 30 Apr 2010 01:30:38
30 Apr 2010 01:30:38 tuteri marco replied:
I'm trying to filter events shown by user_id.
This is the code of calendar_get_events.php, but does not work.
What's wrong ?

.......
{
$query_filter = intval($_GET['user_id']);
$query_start = intval($_GET['start']);
$query_stop = intval($_GET['stop']);
mysql_select_db($database_tvg_conn, $tvg_conn);
$query_events = sprintf("SELECT `event_title` AS title, `start` AS start, `stop` AS stop , `description` AS description, `type` AS type, `link` AS link, `user` AS user, `event_id` AS event_id FROM `eventi` WHERE `user` = %3$s AND UNIX_TIMESTAMP(`start`) <= %d AND UNIX_TIMESTAMP(`stop`) >= %d",$query_stop, $query_start, $query_filter);
$events_set = mysql_query($query_events, $tvg_conn) or die(mysql_error());
$result_array = array();
while ($row = mysql_fetch_assoc($events_set))
{
$result_array[] = $row;
}
header("Cache-Control: no-cache";
if(isset($_GET['callback']))
{
echo $_GET['callback']."(".json_encode($result_array).";";
}
.......
.......
Replied 25 Oct 2010 10:23:38
25 Oct 2010 10:23:38 Miroslav Zografski replied:
Hello Tuteri Marco,

do you get any errors executing the Calendar page?

Regards,

Reply to this topic