/[drupal]/contributions/modules/activitystream_qik/activitystream_qik.module
ViewVC logotype

Contents of /contributions/modules/activitystream_qik/activitystream_qik.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download) (as text)
Thu Jun 25 12:19:12 2009 UTC (5 months ago) by liamgh
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, HEAD
Branch point for: DRUPAL-5, DRUPAL-6--1
File MIME type: text/x-php
Initial commit of activitystream_qik module. Provides Qik.com integration for activitystream
1 <?php
2 // $Id$
3 /**
4 * @file
5 * Queries Qik.com for recent user activity and reports it to Activity Stream
6 */
7
8 /*
9 * The API passes in a $user object that contains four properties:
10 * uid, userid, password, feed. These properties contain the account
11 * information entered into the user's settings page, along with the
12 * uid of their Drupal account.
13 */
14 function activitystream_qik_streamapi($user) {
15 // This user doesn't have a Qik ID entered
16 if (!$user->userid) {
17 return;
18 }
19
20 // Use the activitystream_feed module to pull in the user's
21 // history.
22 $user->feed = 'http://qik.com/'. $user->userid .'/latest-videos';
23 $items = activitystream_feed_streamapi($user);
24 return $items;
25 }
26
27
28 /*
29 * Implement a user settings form hook. Modules should build a form
30 * using an array that mirrors the Drupal form API. activitystream.module
31 * will add the form elements to a tab called Activity Streams on the
32 * user's Profile Edit page. Fields should be named
33 * yourmodulename_fieldname. For instance, to store the user ID for
34 * Flickr, the field name is activitystream_flickr_userid
35 *
36 * To avoid collisions with other activitystream module's forms
37 * use your module's name as the form array's key.
38 *
39 * @param $edit
40 * The values of the form fields, used for setting defaults
41 *
42 */
43 function activitystream_qik_activitystream_settings(&$edit) {
44 $form['activitystream_qik'] = array(
45 '#type' => 'fieldset',
46 '#title' => t('Qik settings'));
47 $form['activitystream_qik']['activitystream_qik_userid'] = array(
48 '#type' => 'textfield',
49 '#title' => t('Username'),
50 '#default_value' => empty($edit['activitystream_qik_userid']) ? '' : $edit['activitystream_qik_userid'],
51 '#description' => t('The username for your Qik account'),
52 '#weight' => 0);
53 return $form;
54 }
55
56 /**
57 * Function to return an icon for each activity stream qik item
58 */
59 function theme_activitystream_qik_icon() {
60 return theme_image(drupal_get_path('module', 'activitystream_qik') .'/qik.png', 'Qik');
61 }
62
63 /**
64 * Function to generate HTML for an activity stream qik item
65 */
66 function theme_activitystream_qik_item($activity) {
67 $node = node_load($activity->nid);
68 $date = theme('activitystream_date', $node->created);
69 $user = activitystream_user_load($node->uid);
70 $name = theme('activitystream_username', $user);
71 return '<span class="activitystream-item">'.theme('activitystream_qik_icon')." <span>$name streamed ".l($node->title, $activity->link)." using Qik <span class=\"activitystream-created\">$date</span></span>".l('#', 'node/' . $node->nid, array('class' => 'permalink')).'</span>';
72 }

  ViewVC Help
Powered by ViewVC 1.1.2