require_once (JPATH_ROOT.DS.'components'.DS.'com_jfbconnect'.DS.'helpers'.DS.'facebookhelper.php');
JFBConnectFacebookHelper::init();
$fbclient = JFBConnectFacebookHelper::getFbClient();
if (is_object($fbclient) && $fbclient->user && !$fbclient->users_hasAppPermission("publish_stream"))
$onchange = "FB.Connect.showPermissionDialog('publish_stream', function(x){if (x=='publish_stream') document.getElementById('involvement').submit();}); "; // involvement
else // else, just submit
$onchange = "document.getElementById('involvement').submit();";
The $onchange then goes in the select part of the form:
$form = <<<EOT
<form method="post" action="calendar.php" id="involvement" promptpermission="publish_stream" >
<input type="hidden" name="op" value="myevent">
<input type="hidden" name="a[cid]" value="1417">
<input type="hidden" name="a[userid]" value="2359">
<span class="contribute"><strong>My Events</strong></span>:
<select name="a[involvement]" id="ainvolvement" onchange="$onchange" >
<option value="none" >I will not go to this event</option>
<option value="visit" selected="selected">I plan to visit this event</option>
<option value="compete" >I plan to compete in this event</option>
</form>
EOT;
(btw the form attribute promptpermission="publish_stream" doesn't work. i was hoping for that solution originally...)
and then when the form is submitted, the following code is executed:
$fbmessage = "i will go to this event"; // or similar, depending on value of $a[involvement]
$attachment['name'] = $event[eventname];
$attachment['href'] = "http://example.com/calendar.php?eid=$a[cid]";
$attachment['description'] = strip_tags(substr($event[eventdesc], 0, 200))."...";
if (file_exists("components/com_calendar/images/$a[cid]-s.jpg"))
{
$attachment['media'][0]['type'] = 'image';
$attachment['media'][0]['src'] = "http://example.com/components/com_calendar/images/$a[cid]-s.jpg";
$attachment['media'][0]['href'] = "http://example.com/calendar.php?eid=$a[cid]";
}
$attachment = json_encode($attachment);
$action_links[0]['text'] = $event[eventname];
$action_links[0]['href'] = "http://example.com/calendar.php?eid=$a[cid]";
$action_links = json_encode($action_links);
$fbclient->stream_publish($fbmessage, $attachment, $action_links);Join our newsletter to get alerts for Joomla releases, tips and tricks and extension updates.
