Skip to content
Snippets Groups Projects
Commit 44115488 authored by Matthias Meusburger's avatar Matthias Meusburger
Browse files

RF13038: Adds comments edition on records and articles when in moderation.

parent 3f9a384f
Branches
Tags
4 merge requests!258Dev/13872 Orphee Allow Hold Available Items,!63Rf13038,!56Rf13038 Front,!55Rf13038 - Comments editing on admin side
......@@ -63,10 +63,11 @@ class Admin_ModoController extends ZendAfi_Controller_Action {
$form->addElement('text', 'url', ['label' => 'Permalien de la notice concernée *',
'size' => '100',
'required' => true,
'allowEmpty' => false,
'validators' => ['url']]);
$form->addElement('textarea', 'avis', ['label' => 'Contenu de l\'avis',
'value' => $avis->getAvis()]);
if ($this->_editavisnoticePost($form, $avis)) {
$this->_redirect('admin/modo/avisnotice');
return;
......@@ -84,19 +85,28 @@ class Admin_ModoController extends ZendAfi_Controller_Action {
|| !$form->isValid($this->_request->getPost()))
return false;
// url routing to extract params as if it is a Bokeh url
$request = (new Zend_Controller_Router_Rewrite())
->route(new Zend_Controller_Request_Http($form->url->getValue()));
if ('viewnotice' != $request->getActionName()
|| !($notice = Class_Notice::find((int)$request->getParam('id')))
|| $notice->getClefAlpha() != $request->getParam('clef')) {
$form->url->addError('L\'url saisie ne correspond pas à un permalien de notice');
return false;
if ($avis->getAvis() != $form->avis->getValue()) {
$avis->setAvis($form->avis->getValue())->save();
$this->_helper->notify($this->view->_('Contenu de l\'avis modifié'));
}
if ($form->url->getValue()) {
// url routing to extract params as if it is a Bokeh url
$request = (new Zend_Controller_Router_Rewrite())
->route(new Zend_Controller_Request_Http($form->url->getValue()));
if ('viewnotice' != $request->getActionName()
|| !($notice = Class_Notice::find((int)$request->getParam('id')))
|| $notice->getClefAlpha() != $request->getParam('clef')) {
$form->url->addError('L\'url saisie ne correspond pas à un permalien de notice');
return false;
}
$avis->setClefOeuvre($notice->getClefOeuvre())->save();
$this->_helper->notify($this->view->_('Avis rattaché à la notice "%s"', $notice->getTitrePrincipal()));
$avis->setClefOeuvre($notice->getClefOeuvre())->save();
$this->_helper->notify($this->view->_('Avis rattaché à la notice "%s"', $notice->getTitrePrincipal()));
}
return true;
}
......
......@@ -167,6 +167,10 @@ class AdminAvisModerationControllerAvisEditTest extends AdminAvisModerationContr
public function testRecordURLInputIsPresent() {
$this->assertXPath('//input[@name="url"]');
}
public function testRecordAvisInputIsPresent() {
$this->assertXPath('//textarea[@name="avis"]');
}
}
......@@ -175,10 +179,13 @@ class AdminAvisModerationControllerAvisEditPostTest extends AdminAvisModerationC
parent::setUp();
$this->fixture('Class_Notice', ['id' => 1190178,
'clef_oeuvre' => 'GARCONNIERELA--GREMILLONH-',
'clef_alpha' => 'GARCONNIERELA--GREMILLONH--FLAMMARION-2013-1']);
'clef_alpha' => 'GARCONNIERELA--GREMILLONH--FLAMMARION-2013-1',
'avis' => 'before'
]);
$this->postDispatch('/admin/modo/editavisnotice/id/38',
['url' => 'http://localhost/recherche/viewnotice/expressionRecherche/la+garconniere/tri/%2A/facette/T1/clef/GARCONNIERELA--GREMILLONH--FLAMMARION-2013-1/id/1190178'], true);
['url' => 'http://localhost/recherche/viewnotice/expressionRecherche/la+garconniere/tri/%2A/facette/T1/clef/GARCONNIERELA--GREMILLONH--FLAMMARION-2013-1/id/1190178',
'avis' => 'after'], true);
}
......@@ -187,6 +194,10 @@ class AdminAvisModerationControllerAvisEditPostTest extends AdminAvisModerationC
Class_AvisNotice::find(38)->getClefOeuvre());
}
public function testRecordShouldBeUpdated() {
$this->assertEquals('after',
Class_AvisNotice::find(38)->getAvis());
}
public function testRedirectToAvisPage() {
$this->assertRedirectTo('/admin/modo/avisnotice');
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment