Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

Added RSS feed for activities #217

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/application/controllers/project.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ public function get_index()
));
}

public function get_rss()
{
return Response::make(View::make('project/rss',
array('project' => Project::current(),
'activities' => Project::current()->activity(10, '_rss')
)), 200, array('Content-Type' => 'text/xml'));
}
/**
* Display issues for a project
* /project/(:num)
Expand Down
9 changes: 5 additions & 4 deletions app/application/models/project.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,10 @@ public function count_assigned_issues($user_id = null)
* Select activity for a project
*
* @param int $activity_limit
* @param string $rss_path (default: empty -> Non-RSS form)
* @return array
*/
public function activity($activity_limit)
public function activity($activity_limit, $rss_path='')
{
$users = $issues = $comments = $activity_type = array();

Expand Down Expand Up @@ -153,7 +154,7 @@ public function activity($activity_limit)
switch($row->type_id)
{
case 2:
$return[] = View::make('activity/' . $activity_type[$row->type_id]->activity, array(
$return[] = View::make('activity' . $rss_path . '/' . $activity_type[$row->type_id]->activity, array(
'issue' => $issues[$row->item_id],
'project' => $this,
'user' => $users[$row->user_id],
Expand All @@ -165,7 +166,7 @@ public function activity($activity_limit)

case 5:

$return[] = View::make('activity/' . $activity_type[$row->type_id]->activity, array(
$return[] = View::make('activity' . $rss_path . '/' . $activity_type[$row->type_id]->activity, array(
'issue' => $issues[$row->item_id],
'project' => $this,
'user' => $users[$row->user_id],
Expand All @@ -177,7 +178,7 @@ public function activity($activity_limit)

default:

$return[] = View::make('activity/' . $activity_type[$row->type_id]->activity, array(
$return[] = View::make('activity' . $rss_path . '/' . $activity_type[$row->type_id]->activity, array(
'issue' => $issues[$row->item_id],
'project' => $this,
'user' => $users[$row->user_id],
Expand Down
1 change: 1 addition & 0 deletions app/application/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
|--------------------------------------------------------------------------
*/
Route::any('project/(:num)', 'project@index');
Route::any('project/(:num)/rss', 'project@rss');
Route::any('project/(:num)/(:any)', 'project@(:2)');
Route::any('project/(:num)/issue/new', 'project.issue@new');
Route::any('project/(:num)/issue/(:num)', 'project.issue@index');
Expand Down
6 changes: 6 additions & 0 deletions app/application/views/activity_rss/close-issue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<item>
<title><?php echo __('tinyissue.label_closed') . ': ' . $issue->title; ?></title>
<link><?php echo $issue->to(); ?></link>
<description><?php echo $issue->title . ' ' . __('tinyissue.was_closed_by') . ' ' . $user->firstname . ' ' . $user->lastname; ?></description>
<pubDate><?php echo date("D, d M Y H:i:s O", strtotime($activity->created_at)); ?></pubDate>
</item>
6 changes: 6 additions & 0 deletions app/application/views/activity_rss/comment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<item>
<title><?php echo __('tinyissue.label_comment') . ' ' . __('tinyissue.on_issue') . ': ' . $issue->title . ' ' . __('tinyissue.by') . ' ' . $user->firstname . ' ' . $user->lastname; ?></title>
<link><?php echo $issue->to(); ?>#comment<?php echo $comment->id; ?></link>
<description><?php echo str_replace('>', '&gt;', str_replace('<', '&lt;', $comment->comment)); ?></description>
<pubDate><?php echo date("D, d M Y H:i:s O", strtotime($activity->created_at)); ?></pubDate>
</item>
6 changes: 6 additions & 0 deletions app/application/views/activity_rss/create-issue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<item>
<title><?php echo __('tinyissue.label_created') . ': ' . $issue->title; ?></title>
<link><?php echo $issue->to(); ?></link>
<description><?php echo $issue->title . ' ' . __('tinyissue.was_created_by') . ' ' . $user->firstname . ' ' . $user->lastname; ?></description>
<pubDate><?php echo date("D, d M Y H:i:s O", strtotime($activity->created_at)); ?></pubDate>
</item>
11 changes: 11 additions & 0 deletions app/application/views/activity_rss/reassign-issue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<item>
<title><?php echo __('tinyissue.label_reassigned') . ': ' . $issue->title; ?></title>
<link><?php echo $issue->to(); ?></link>
<description><?php if($activity->action_id > 0): ?>
<?php echo $issue->title . ' ' . __('tinyissue.was_reassigned_to') . ' ' . $user->firstname . ' ' . $user->lastname; ?>
<?php else: ?>
<?php echo $issue->title . ' ' . __('tinyissue.was_reassigned_to') . ' ' . __('tinyissue.no_one'); ?>
<?php endif; ?>
<?php echo __('tinyissue.by') . ' ' . $user->firstname . ' ' . $user->lastname; ?></description>
<pubDate><?php echo date("D, d M Y H:i:s O", strtotime($activity->created_at)); ?></pubDate>
</item>
6 changes: 6 additions & 0 deletions app/application/views/activity_rss/reopen-issue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<item>
<title><?php echo __('tinyissue.label_reopened') . ': ' . $issue->title; ?></title>
<link><?php echo $issue->to(); ?></link>
<description><?php echo $issue->title . ' ' . __('tinyissue.was_reopened_by') . ' ' . $user->firstname . ' ' . $user->lastname; ?></description>
<pubDate><?php echo date("D, d M Y H:i:s O", strtotime($activity->created_at)); ?></pubDate>
</item>
3 changes: 3 additions & 0 deletions app/application/views/project/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<li <?php echo $active == 'activity' ? 'class="active"' : ''; ?>>
<a href="<?php echo Project::current()->to(); ?>"><?php echo __('tinyissue.activity');?></a>
</li>
<li <?php echo $active == 'rss' ? 'class="active"' : ''; ?>>
<a href="<?php echo Project::current()->to('rss'); ?>">Activity RSS<?php /*echo __('tinyissue.activity');*/ ?></a>
</li>
<li <?php echo $active == 'open' ? 'class="active"' : ''; ?>>
<a href="<?php echo Project::current()->to('issues'); ?>">
<?php echo $open_count == 1 ? '1 '.__('tinyissue.open_issue') : $open_count . ' '.__('tinyissue.open_issues'); ?>
Expand Down
12 changes: 12 additions & 0 deletions app/application/views/project/rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php echo "<?xml version='1.0' encoding='UTF-8' ?>"; ?>
<rss version='2.0'>
<channel>
<title><?php echo 'Project activity RSS for ' . $project->name; ?></title>
<link><?php echo $project->to(); ?></link>
<description><?php echo 'Recent activities in' . $project->name; ?></description>
<language>hu</language>
<?php foreach($activities as $activity): ?>
<?php echo $activity; ?>
<?php endforeach; ?>
</channel>
</rss>