Add RSS feed for users and change address of project feeds
This commit is contained in:
56
app/Controller/Feed.php
Normal file
56
app/Controller/Feed.php
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Controller;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Atom/RSS Feed controller
|
||||||
|
*
|
||||||
|
* @package controller
|
||||||
|
* @author Frederic Guillot
|
||||||
|
*/
|
||||||
|
class Feed extends Base
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* RSS feed for a user
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
$token = $this->request->getStringParam('token');
|
||||||
|
$user = $this->user->getByToken($token);
|
||||||
|
|
||||||
|
// Token verification
|
||||||
|
if (empty($user)) {
|
||||||
|
$this->forbidden(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$projects = $this->projectPermission->getActiveMemberProjects($user['id']);
|
||||||
|
|
||||||
|
$this->response->xml($this->template->render('feed/user', array(
|
||||||
|
'events' => $this->projectActivity->getProjects(array_keys($projects)),
|
||||||
|
'user' => $user,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSS feed for a project
|
||||||
|
*
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
public function project()
|
||||||
|
{
|
||||||
|
$token = $this->request->getStringParam('token');
|
||||||
|
$project = $this->project->getByToken($token);
|
||||||
|
|
||||||
|
// Token verification
|
||||||
|
if (empty($project)) {
|
||||||
|
$this->forbidden(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->response->xml($this->template->render('feed/project', array(
|
||||||
|
'events' => $this->projectActivity->getProject($project['id']),
|
||||||
|
'project' => $project,
|
||||||
|
)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -394,27 +394,6 @@ class Project extends Base
|
|||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* RSS feed for a project (public)
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
*/
|
|
||||||
public function feed()
|
|
||||||
{
|
|
||||||
$token = $this->request->getStringParam('token');
|
|
||||||
$project = $this->project->getByToken($token);
|
|
||||||
|
|
||||||
// Token verification
|
|
||||||
if (empty($project)) {
|
|
||||||
$this->forbidden(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->response->xml($this->template->render('project/feed', array(
|
|
||||||
'events' => $this->projectActivity->getProject($project['id']),
|
|
||||||
'project' => $project,
|
|
||||||
)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a form to create a new project
|
* Display a form to create a new project
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -21,10 +21,10 @@ class Acl extends Base
|
|||||||
'user' => array('google', 'github'),
|
'user' => array('google', 'github'),
|
||||||
'task' => array('readonly'),
|
'task' => array('readonly'),
|
||||||
'board' => array('readonly'),
|
'board' => array('readonly'),
|
||||||
'project' => array('feed'),
|
|
||||||
'webhook' => '*',
|
|
||||||
'app' => array('colors'),
|
'app' => array('colors'),
|
||||||
|
'webhook' => '*',
|
||||||
'ical' => '*',
|
'ical' => '*',
|
||||||
|
'feed' => '*',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
|
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
|
||||||
<title><?= t('%s\'s activity', $project['name']) ?></title>
|
<title><?= t('%s\'s activity', $project['name']) ?></title>
|
||||||
<link rel="alternate" type="text/html" href="<?= $this->url->base() ?>"/>
|
<link rel="alternate" type="text/html" href="<?= $this->url->base() ?>"/>
|
||||||
<link rel="self" type="application/atom+xml" href="<?= $this->url->base().$this->url->href('project', 'feed', array('token' => $project['token'])) ?>"/>
|
<link rel="self" type="application/atom+xml" href="<?= $this->url->base().$this->url->href('feed', 'project', array('token' => $project['token'])) ?>"/>
|
||||||
<updated><?= date(DATE_ATOM) ?></updated>
|
<updated><?= date(DATE_ATOM) ?></updated>
|
||||||
<id><?= $this->url->base() ?></id>
|
<id><?= $this->url->base().$this->url->href('feed', 'project', array('token' => $project['token'])) ?></id>
|
||||||
<icon><?= $this->url->base() ?>assets/img/favicon.png</icon>
|
<icon><?= $this->url->base() ?>assets/img/favicon.png</icon>
|
||||||
|
|
||||||
<?php foreach ($events as $e): ?>
|
<?php foreach ($events as $e): ?>
|
||||||
27
app/Template/feed/user.php
Normal file
27
app/Template/feed/user.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?= '<?xml version="1.0" encoding="utf-8"?>' ?>
|
||||||
|
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom">
|
||||||
|
<title><?= t('Project activities for %s', $user['name'] ?: $user['username']) ?></title>
|
||||||
|
<link rel="alternate" type="text/html" href="<?= $this->url->base() ?>"/>
|
||||||
|
<link rel="self" type="application/atom+xml" href="<?= $this->url->base().$this->url->href('feed', 'user', array('token' => $user['token'])) ?>"/>
|
||||||
|
<updated><?= date(DATE_ATOM) ?></updated>
|
||||||
|
<id><?= $this->url->base().$this->url->href('feed', 'user', array('token' => $user['token'])) ?></id>
|
||||||
|
<icon><?= $this->url->base() ?>assets/img/favicon.png</icon>
|
||||||
|
|
||||||
|
<?php foreach ($events as $e): ?>
|
||||||
|
<entry>
|
||||||
|
<title type="text"><?= $e['event_title'] ?></title>
|
||||||
|
<link rel="alternate" href="<?= $this->url->base().$this->url->href('task', 'show', array('task_id' => $e['task_id'])) ?>"/>
|
||||||
|
<id><?= $e['id'].'-'.$e['event_name'].'-'.$e['task_id'].'-'.$e['date_creation'] ?></id>
|
||||||
|
<published><?= date(DATE_ATOM, $e['date_creation']) ?></published>
|
||||||
|
<updated><?= date(DATE_ATOM, $e['date_creation']) ?></updated>
|
||||||
|
<author>
|
||||||
|
<name><?= $this->e($e['author']) ?></name>
|
||||||
|
</author>
|
||||||
|
<content type="html">
|
||||||
|
<![CDATA[
|
||||||
|
<?= $e['event_content'] ?>
|
||||||
|
]]>
|
||||||
|
</content>
|
||||||
|
</entry>
|
||||||
|
<?php endforeach ?>
|
||||||
|
</feed>
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<div class="listing">
|
<div class="listing">
|
||||||
<ul class="no-bullet">
|
<ul class="no-bullet">
|
||||||
<li><strong><i class="fa fa-share-alt"></i> <?= $this->url->link(t('Public link'), 'board', 'readonly', array('token' => $project['token']), false, '', '', true) ?></strong></li>
|
<li><strong><i class="fa fa-share-alt"></i> <?= $this->url->link(t('Public link'), 'board', 'readonly', array('token' => $project['token']), false, '', '', true) ?></strong></li>
|
||||||
<li><strong><i class="fa fa-rss-square"></i> <?= $this->url->link(t('RSS feed'), 'project', 'feed', array('token' => $project['token']), false, '', '', true) ?></strong></li>
|
<li><strong><i class="fa fa-rss-square"></i> <?= $this->url->link(t('RSS feed'), 'feed', 'project', array('token' => $project['token']), false, '', '', true) ?></strong></li>
|
||||||
<li><strong><i class="fa fa-calendar"></i> <?= $this->url->link(t('iCal feed'), 'ical', 'project', array('token' => $project['token']), false, '', '', true) ?></strong></li>
|
<li><strong><i class="fa fa-calendar"></i> <?= $this->url->link(t('iCal feed'), 'ical', 'project', array('token' => $project['token']), false, '', '', true) ?></strong></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
<?php if ($project['is_public']): ?>
|
<?php if ($project['is_public']): ?>
|
||||||
<li><i class="fa fa-share-alt"></i> <?= $this->url->link(t('Public link'), 'board', 'readonly', array('token' => $project['token']), false, '', '', true) ?></li>
|
<li><i class="fa fa-share-alt"></i> <?= $this->url->link(t('Public link'), 'board', 'readonly', array('token' => $project['token']), false, '', '', true) ?></li>
|
||||||
<li><i class="fa fa-rss-square"></i> <?= $this->url->link(t('RSS feed'), 'project', 'feed', array('token' => $project['token']), false, '', '', true) ?></li>
|
<li><i class="fa fa-rss-square"></i> <?= $this->url->link(t('RSS feed'), 'feed', 'project', array('token' => $project['token']), false, '', '', true) ?></li>
|
||||||
<li><i class="fa fa-calendar"></i> <?= $this->url->link(t('iCal feed'), 'ical', 'project', array('token' => $project['token'])) ?></li>
|
<li><i class="fa fa-calendar"></i> <?= $this->url->link(t('iCal feed'), 'ical', 'project', array('token' => $project['token'])) ?></li>
|
||||||
<?php else: ?>
|
<?php else: ?>
|
||||||
<li><?= t('Public access disabled') ?></li>
|
<li><?= t('Public access disabled') ?></li>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
<?= $this->url->link(t('All projects'), 'project', 'index') ?>
|
<?= $this->url->link(t('All projects'), 'project', 'index') ?>
|
||||||
</li>
|
</li>
|
||||||
<?php if ($project['is_public']): ?>
|
<?php if ($project['is_public']): ?>
|
||||||
<li><i class="fa fa-rss-square fa-fw"></i><?= $this->url->link(t('RSS feed'), 'project', 'feed', array('token' => $project['token']), false, '', '', true) ?></li>
|
<li><i class="fa fa-rss-square fa-fw"></i><?= $this->url->link(t('RSS feed'), 'feed', 'project', array('token' => $project['token']), false, '', '', true) ?></li>
|
||||||
<li><i class="fa fa-calendar fa-fw"></i><?= $this->url->link(t('iCal feed'), 'ical', 'project', array('token' => $project['token'])) ?></li>
|
<li><i class="fa fa-calendar fa-fw"></i><?= $this->url->link(t('iCal feed'), 'ical', 'project', array('token' => $project['token'])) ?></li>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
<div class="listing">
|
<div class="listing">
|
||||||
<ul class="no-bullet">
|
<ul class="no-bullet">
|
||||||
|
<li><strong><i class="fa fa-rss-square"></i> <?= $this->url->link(t('RSS feed'), 'feed', 'user', array('token' => $user['token']), false, '', '', true) ?></strong></li>
|
||||||
<li><strong><i class="fa fa-calendar"></i> <?= $this->url->link(t('iCal feed'), 'ical', 'user', array('token' => $user['token']), false, '', '', true) ?></strong></li>
|
<li><strong><i class="fa fa-calendar"></i> <?= $this->url->link(t('iCal feed'), 'ical', 'user', array('token' => $user['token']), false, '', '', true) ?></strong></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
<div class="listing">
|
<div class="listing">
|
||||||
<ul class="no-bullet">
|
<ul class="no-bullet">
|
||||||
|
<li><strong><i class="fa fa-rss-square"></i> <?= $this->url->link(t('RSS feed'), 'feed', 'user', array('token' => $user['token']), false, '', '', true) ?></strong></li>
|
||||||
<li><strong><i class="fa fa-calendar"></i> <?= $this->url->link(t('iCal feed'), 'ical', 'user', array('token' => $user['token']), false, '', '', true) ?></strong></li>
|
<li><strong><i class="fa fa-calendar"></i> <?= $this->url->link(t('iCal feed'), 'ical', 'user', array('token' => $user['token']), false, '', '', true) ?></strong></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class AclTest extends Base
|
|||||||
$this->assertTrue($acl->isPublicAction('board', 'readonly'));
|
$this->assertTrue($acl->isPublicAction('board', 'readonly'));
|
||||||
$this->assertFalse($acl->isPublicAction('board', 'show'));
|
$this->assertFalse($acl->isPublicAction('board', 'show'));
|
||||||
$this->assertTrue($acl->isPublicAction('app', 'colors'));
|
$this->assertTrue($acl->isPublicAction('app', 'colors'));
|
||||||
|
$this->assertTrue($acl->isPublicAction('feed', 'project'));
|
||||||
|
$this->assertTrue($acl->isPublicAction('feed', 'user'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAdminActions()
|
public function testAdminActions()
|
||||||
|
|||||||
Reference in New Issue
Block a user