Retriview Event Data – GSoC – week #9

To create event, new content type was declared as ‘Event’ content type. There were used Date , Views , Calendar and OG  modules. With aid of OG module I was capable to create Event nodes  with specific to group visible.
Next part is getting these Event node from database and pass it to TimelineJS as JSON string. For that function implementing taken in this week.

The function is all about mapping user ID with OG group table and and realated nodes. Its take 3 steps.
1. Get user groups IDs by User ID mapping.

global $user;
$sql1 = ‘SELECT gid FROM {og_membership} ogm WHERE ogm.etid = :log’;
$group_result = db_query($sql1,
array(
‘:log’ => $user->uid,
)
);
2. Get Node IDs by each of groups IDs.

foreach ($group_result as $groupID){
$sql2 = ‘SELECT etid FROM {og_membership} ogm WHERE ogm.gid = :group AND entity_type = :type’;
$events_group = db_query($sql2,
array(
‘:type’ => ‘node’,
‘:group’ => $groupID->gid,
)
);

3. Load the all node IDs data in to render array .

foreach ($events_group as $row) {
$node = node_load($row->etid);
$renderable_array[‘node_list’][]= node_view($node, ‘example_node_list’);
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s