| 1 |
<?php
|
| 2 |
// $Id$
|
| 3 |
/*
|
| 4 |
* The API passes in a $user object that contains four properties:
|
| 5 |
* uid, userid, password, feed. These properties contain the account
|
| 6 |
* information entered into the user's settings page, along with the
|
| 7 |
* uid of their Drupal account.
|
| 8 |
*/
|
| 9 |
function activitystream_facebook_streamapi($user) {
|
| 10 |
// This user doesn't have a lastfm ID entered
|
| 11 |
if (!$user->feed) {
|
| 12 |
return;
|
| 13 |
}
|
| 14 |
|
| 15 |
// Use the activitystream_feed module to pull in the user's
|
| 16 |
// history.
|
| 17 |
$user->feed = $user->feed;
|
| 18 |
//$user->feed = 'http://ws.audioscrobbler.com/1.0/user/'. $user->userid .'/recenttracks.rss';
|
| 19 |
$items = activitystream_feed_streamapi($user);
|
| 20 |
//print_r($user);
|
| 21 |
///exit;
|
| 22 |
return $items;
|
| 23 |
}
|
| 24 |
/*
|
| 25 |
* Implement a user settings form hook. Modules should build a form
|
| 26 |
* using an array that mirrors the Drupal form API. activitystream.module
|
| 27 |
* will add the form elements to a tab called Activity Streams on the
|
| 28 |
* user's Profile Edit page. Fields should be named
|
| 29 |
* yourmodulename_fieldname. For instance, to store the user ID for
|
| 30 |
* Flickr, the field name is activitystream_flickr_userid
|
| 31 |
*
|
| 32 |
* To avoid collisions with other activitystream module's forms
|
| 33 |
* use your module's name as the form array's key.
|
| 34 |
*
|
| 35 |
* @param $edit
|
| 36 |
* The values of the form fields, used for setting defaults
|
| 37 |
*
|
| 38 |
*/
|
| 39 |
function activitystream_facebook_activitystream_settings(&$edit) {
|
| 40 |
$form['activitystream_facebook'] = array(
|
| 41 |
'#type' => 'fieldset',
|
| 42 |
'#title' => t('facebook settings'));
|
| 43 |
$form['activitystream_facebook']['activitystream_facebook_feed'] = array(
|
| 44 |
'#type' => 'textfield',
|
| 45 |
'#title' => t('Facebook Status RSS feed URL'),
|
| 46 |
'#default_value' => empty($edit['activitystream_facebook_feed']) ? '' : $edit['activitystream_facebook_feed'],
|
| 47 |
'#description' => t('<a href="http://heidisoft.com/blogs/subscribe-new-facebook-feeds" target="_blank">Click here</a> for more information'));
|
| 48 |
return $form;
|
| 49 |
}
|
| 50 |
|
| 51 |
|
| 52 |
function theme_activitystream_facebook_icon() {
|
| 53 |
return theme_image(drupal_get_path('module', 'activitystream_facebook') .'/facebook.png', 'facebook');
|
| 54 |
}
|
| 55 |
|
| 56 |
|
| 57 |
function theme_activitystream_facebook_item($activity) {
|
| 58 |
$node = node_load($activity->nid);
|
| 59 |
$date = theme('activitystream_date', $node->created);
|
| 60 |
$user = activitystream_user_load($node->uid);
|
| 61 |
$name = theme('activitystream_username', $user);
|
| 62 |
return '<span class="activitystream-item">' . theme('activitystream_facebook_icon') . " <span>$name " . l($node->title, $activity->link) . " <span class=\"activitystream-created\">$date</span></span>" . l('#', 'node/' . $node->nid, array('class' => 'permalink')) . '</span>';
|
| 63 |
}
|