Fixed iconurl integration

This commit is contained in:
Andrey
2013-06-12 11:29:41 +02:00
parent ec5a38d5f5
commit 9a5baff4a0
4 changed files with 36 additions and 39 deletions

View File

@@ -124,12 +124,14 @@ class Publications implements ControllerProviderInterface
); );
$feed = $app["EM"]->find('Entities\Feed', $id); $feed = $app["EM"]->find('Entities\Feed', $id);
if (null === $feed) {
$app->abort(404, "Feed not found");
}
$request = $app["request"]; $request = $app["request"];
if (!$feed->getOwner($app['authentication']->getUser())) { if (!$feed->isOwner($app['authentication']->getUser())) {
$datas['message'] = 'You are not allowed to do that'; $app->abort(403, "Access Forbidden");
return $app->json($datas);
} }
try { try {
@@ -170,6 +172,15 @@ class Publications implements ControllerProviderInterface
unset($media); unset($media);
$feed->setIconUrl(true);
$app['EM']->persist($feed);
$app['EM']->flush();
$baseDir = realpath(__DIR__ . '/../../../../../');
$app['filesystem']->copy($tmpname, $baseDir . '/config/feed_' . $feed->getId() . '.jpg');
$app['filesystem']->copy($tmpname, 'custom/feed_' . $feed->getId() . '.jpg');
$app['filesystem']->remove($tmpname); $app['filesystem']->remove($tmpname);
$datas['success'] = true; $datas['success'] = true;
@@ -217,7 +228,7 @@ class Publications implements ControllerProviderInterface
$publisher = $app["EM"]->find('Entities\FeedPublisher', $request->request->get('publisher_id')); $publisher = $app["EM"]->find('Entities\FeedPublisher', $request->request->get('publisher_id'));
if (null === $publisher) { if (null === $publisher) {
throw new \Exception_Feed_PublisherNotFound(); $app->abort(404, "Feed Publisher not found");
} }
$user = $publisher->getUser($app); $user = $publisher->getUser($app);

View File

@@ -11,7 +11,11 @@
<div class="control-group"> <div class="control-group">
<div id="pub_icon"> <div id="pub_icon">
<div class="thumb_wrapper"> <div class="thumb_wrapper">
<img id="img_before" src="{{ feed.getIconUrl() }}" /> <img id="img_before" src="{% if feed.getIconUrl() == false %}
/skins/icons/rss32.gif
{% else %}
/custom/feed_{{ feed.getId() }}.jpg
{% endif %}" />
</div> </div>
</div> </div>
<div id="pub_fileupload"> <div id="pub_fileupload">
@@ -145,7 +149,7 @@
{{ publisher.getUser(app).get_email() }} {{ publisher.getUser(app).get_email() }}
</td> </td>
<td valign="center" align="center"> <td valign="center" align="center">
{% if publisher.getOwner() == true %} {% if publisher.isOwner() == true %}
X X
{% else %} {% else %}
<form class="no-ajax form_publication" method="post" action="{{ path('admin_feeds_feed_remove_publisher', { 'id' : feed.getId() }) }}" style="margin:0;"> <form class="no-ajax form_publication" method="post" action="{{ path('admin_feeds_feed_remove_publisher', { 'id' : feed.getId() }) }}" style="margin:0;">

View File

@@ -64,7 +64,11 @@
<td> <td>
<div style="border:1px solid #ccc; width:22px; height:22px; margin:2px;"> <div style="border:1px solid #ccc; width:22px; height:22px; margin:2px;">
<a href="{{ path('admin_feeds_feed', { 'id' : feed.getId() }) }}"> <a href="{{ path('admin_feeds_feed', { 'id' : feed.getId() }) }}">
<img src="{{feed.getIconUrl() ~ '?' ~ random(1000) }}" id="pub_icon" style="margin:3px; width:16px; height:16px;"/> <img src="{% if feed.getIconUrl() == false %}
/skins/icons/rss32.gif
{% else %}
/custom/feed_{{ feed.getId() }}.jpg
{% endif %}" id="pub_icon" style="margin:3px; width:16px; height:16px;"/>
</a> </a>
</div> </div>
</td> </td>

View File

@@ -107,32 +107,22 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
public function testIconUploadErrorOwner() public function testIconUploadErrorOwner()
{ {
$this->markTestSkipped(); // icon upload being changed $feed = $this->insertOneFeed(self::$DI['user_alt1']);
$feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user_alt1'], "salut", 'coucou'); self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->getId() . "/iconupload/", array(), array(), array('HTTP_ACCEPT' => 'application/json'));
self::$DI['client']->request("POST", "/admin/publications/feed/" . $feed->get_id() . "/iconupload/", array(), array(), array('HTTP_ACCEPT' => 'application/json'));
$response = self::$DI['client']->getResponse(); $response = self::$DI['client']->getResponse();
$this->assertTrue($response->isOk()); $this->assertEquals(403, $response->getStatusCode());
$content = json_decode($response->getContent());
$this->assertFalse($content->success);
$feed->delete();
} }
public function testIconUploadErrorFileData() public function testIconUploadErrorFileData()
{ {
$this->markTestSkipped(); // icon upload being changed $feed = $this->insertOneFeed(self::$DI['user']);
$feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], "salut", 'coucou');
self::$DI['client']->request( self::$DI['client']->request(
"POST" "POST"
, "/admin/publications/feed/" . $feed->get_id() . "/iconupload/" , "/admin/publications/feed/" . $feed->getId() . "/iconupload/"
, array() , array()
, array('Filedata' => array('error' => 1)) , array('Filedata' => array('error' => 1))
); );
@@ -142,19 +132,15 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
$content = json_decode($response->getContent()); $content = json_decode($response->getContent());
$this->assertFalse($content->success); $this->assertFalse($content->success);
$feed->delete();
} }
public function testIconUploadErrorFileType() public function testIconUploadErrorFileType()
{ {
$this->markTestSkipped(); // icon upload being changed $feed = $this->insertOneFeed(self::$DI['user']);
$feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], "salut", 'coucou');
self::$DI['client']->request( self::$DI['client']->request(
"POST" "POST"
, "/admin/publications/feed/" . $feed->get_id() . "/iconupload/" , "/admin/publications/feed/" . $feed->getId() . "/iconupload/"
, array() , array()
, array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../../files/test007.ppt')) , array('Filedata' => array('error' => 0, 'tmp_name' => __DIR__ . '/../../../../../files/test007.ppt'))
); );
@@ -164,15 +150,11 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
$content = json_decode($response->getContent()); $content = json_decode($response->getContent());
$this->assertFalse($content->success); $this->assertFalse($content->success);
$feed->delete();
} }
public function testIconUpload() public function testIconUpload()
{ {
$this->markTestSkipped(); // icon upload being changed $feed = $this->insertOneFeed(self::$DI['user']);
$feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], "salut", 'coucou');
$files = array( $files = array(
'files' => array( 'files' => array(
@@ -184,7 +166,7 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
self::$DI['client']->request( self::$DI['client']->request(
"POST" "POST"
, "/admin/publications/feed/" . $feed->get_id() . "/iconupload/" , "/admin/publications/feed/" . $feed->getId() . "/iconupload/"
, array() , array()
, $files , $files
); );
@@ -196,10 +178,6 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic
$content = json_decode($response->getContent()); $content = json_decode($response->getContent());
$this->assertTrue($content->success); $this->assertTrue($content->success);
$feed = new \Feed_Adapter(self::$DI['app'], $feed->get_id());
$feed->delete();
} }
public function testAddPublisher() public function testAddPublisher()