Index: /Users/jbitner/Sites/activity/sites/all/modules/contrib/activity/activity.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/activity/activity.module,v retrieving revision 1.1.2.2.2.17 diff -u -r1.1.2.2.2.17 activity.module --- activity.module 21 Jan 2008 14:47:31 -0000 1.1.2.2.2.17 +++ activity.module 10 Feb 2008 22:10:14 -0000 @@ -52,6 +51,12 @@ 'access' => user_access('view public activity'), ); $items[] = array( + 'path' => 'activity/all/json', + 'callback' => 'activity_json', + 'callback arguments' => array(ACTIVITY_ALL, 1), + 'access' => user_access('view public activity'), + ); + $items[] = array( 'path' => 'admin/settings/activity', 'title' => t('Activity Settings'), 'description' => t('Customize what will display on your users activity page.'), @@ -67,7 +72,12 @@ 'callback' => 'activity_feed', 'callback arguments' => array($user->uid), 'type' => MENU_CALLBACK, - + ); + $items[] = array( + 'path' => 'activity/'. $user->uid. '/json', + 'callback' => 'activity_json', + 'callback arguments' => array($user->uid, 1), + 'type' => MENU_CALLBACK, ); } } @@ -509,6 +518,42 @@ } /** + * output our activity as json + * $arg[0] = ACTIVITY_ALL or $uid + * $arg[1] = number of activities to retreive + */ +function activity_json($arg) { + global $locale; + $args = func_get_args(); + if ($args[0] == ACTIVITY_ALL) { + // get the latest activity posted + $activities = activity_get_activity(ACTIVITY_ALL, NULL, $args[1]); + $url = url('activity/all', NULL, NULL, TRUE); + $feed_title = t('All activity'); + } + else if (is_numeric($args[0])) { + $user = db_fetch_object(db_query('SELECT uid, name FROM {users} WHERE uid = %d', $args[0])); + if ($user) { + // get the latest activity posted pertaining to this user + $activities = activity_get_activity($arg[0], NULL, $args[1]); + $url = url('activity/'. $user->uid, NULL, NULL, TRUE); + $feed_title = t('Activity for @username', array('@username' => theme('username', $user))); + } + } + if (count($activities) > 0) { + foreach ($activities as $activity) { + $message = activity_token_replace($activity); + $items .= ''. format_date($activity['created'], 'small') .''; + $items .= ''. url('activity/'. $user->uid, NULL, NULL, TRUE) .''; + $items .= ''. $message .''; + } + } + drupal_set_header('Content-Type: application/x-javascript'); + print drupal_to_js($items); + die(); +} + +/** * Token module integration. */ function activity_token_list($type = 'all') {